def create_visual_elements(self):
        self.label = gtk.Label(
            "Packages included: 0\nSelected packages size: 0 MB")
        self.eventbox = self.add_onto_top_bar(self.label, 73)
        self.pack_start(self.eventbox, expand=False, fill=False)
        self.pack_start(self.group_align, expand=True, fill=True)

        # set visible members
        self.ins = HobNotebook()
        self.tables = []  # we need to modify table when the dialog is shown

        search_names = []
        search_tips = []
        # append the tab
        for page in self.pages:
            columns = page['columns']
            name = page['name']
            tab = HobViewTable(columns, name)
            search_names.append(page['search'])
            search_tips.append(page['searchtip'])
            filter = page['filter']
            sort_model = self.package_model.tree_model(filter, initial=True)
            tab.set_model(sort_model)
            tab.connect("toggled", self.table_toggled_cb, name)
            if name == "Included packages":
                tab.connect("button-release-event", self.button_click_cb)
                tab.connect("cell-fadeinout-stopped",
                            self.after_fadeout_checkin_include)
            if name == "All packages":
                tab.connect("button-release-event", self.button_click_cb)
                tab.connect("cell-fadeinout-stopped",
                            self.after_fadeout_checkin_include)
            self.ins.append_page(tab, page['name'], page['tooltip'])
            self.tables.append(tab)

        self.ins.set_entry(search_names, search_tips)
        self.ins.search.connect("changed", self.search_entry_changed)

        # add all into the dialog
        self.box_group_area.pack_start(self.ins, expand=True, fill=True)

        self.button_box = gtk.HBox(False, 6)
        self.box_group_area.pack_start(self.button_box,
                                       expand=False,
                                       fill=False)

        self.build_image_button = HobButton('Build image')
        #self.build_image_button.set_size_request(205, 49)
        self.build_image_button.set_tooltip_text("Build target image")
        self.build_image_button.set_flags(gtk.CAN_DEFAULT)
        self.build_image_button.grab_default()
        self.build_image_button.connect("clicked", self.build_image_clicked_cb)
        self.button_box.pack_end(self.build_image_button,
                                 expand=False,
                                 fill=False)

        self.back_button = HobAltButton('Cancel')
        self.back_button.connect("clicked", self.back_button_clicked_cb)
        self.button_box.pack_end(self.back_button, expand=False, fill=False)
    def create_visual_elements(self):
        self.label = gtk.Label("Packages included: 0\nSelected packages size: 0 MB")
        self.eventbox = self.add_onto_top_bar(self.label, 73)
        self.pack_start(self.eventbox, expand=False, fill=False)
        self.pack_start(self.group_align, expand=True, fill=True)

        # set visiable members
        self.ins = HobNotebook()
        self.tables = [] # we need to modify table when the dialog is shown
        # append the tab
        for page in self.pages:
            columns = page['columns']
            tab = HobViewTable(columns)
            filter = page['filter']
            tab.set_model(self.package_model.tree_model(filter))
            tab.connect("toggled", self.table_toggled_cb)
            if page['name'] == "Included":
                tab.connect("row-activated", self.tree_row_activated_cb)

            label = gtk.Label(page['name'])
            self.ins.append_page(tab, label)
            self.tables.append(tab)

        self.ins.set_entry("Search packages:")
        # set the search entry for each table
        for tab in self.tables:
            tab.set_search_entry(0, self.ins.search)

        # add all into the dialog
        self.box_group_area.pack_start(self.ins, expand=True, fill=True)

        button_box = gtk.HBox(False, 6)
        self.box_group_area.pack_start(button_box, expand=False, fill=False)

        self.build_image_button = gtk.Button()
        label = gtk.Label()
        mark = "<span %s>Build image</span>" % self.span_tag('24px', 'bold')
        label.set_markup(mark)
        self.build_image_button.set_image(label)
        self.build_image_button.set_size_request(205, 49)
        self.build_image_button.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(HobColors.ORANGE))
        self.build_image_button.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(HobColors.ORANGE))
        self.build_image_button.modify_bg(gtk.STATE_SELECTED, gtk.gdk.Color(HobColors.ORANGE))
        self.build_image_button.set_tooltip_text("Build image to get your target image")
        self.build_image_button.set_flags(gtk.CAN_DEFAULT)
        self.build_image_button.grab_default()
        self.build_image_button.connect("clicked", self.build_image_clicked_cb)
        button_box.pack_end(self.build_image_button, expand=False, fill=False)

        self.back_button = gtk.LinkButton("Go back to Image Configuration screen", "<< Back to image configuration")
        self.back_button.connect("clicked", self.back_button_clicked_cb)
        button_box.pack_start(self.back_button, expand=False, fill=False)
    def create_visual_elements(self):
        self.label = gtk.Label("Packages included: 0\nSelected packages size: 0 MB")
        self.eventbox = self.add_onto_top_bar(self.label, 73)
        self.pack_start(self.eventbox, expand=False, fill=False)
        self.pack_start(self.group_align, expand=True, fill=True)

        # set visible members
        self.ins = HobNotebook()
        self.tables = []  # we need to modify table when the dialog is shown

        search_names = []
        search_tips = []
        # append the tab
        for page in self.pages:
            columns = page["columns"]
            name = page["name"]
            tab = HobViewTable(columns, name)
            search_names.append(page["search"])
            search_tips.append(page["searchtip"])
            filter = page["filter"]
            sort_model = self.package_model.tree_model(filter, initial=True)
            tab.set_model(sort_model)
            tab.connect("toggled", self.table_toggled_cb, name)
            if name == "Included packages":
                tab.connect("button-release-event", self.button_click_cb)
                tab.connect("cell-fadeinout-stopped", self.after_fadeout_checkin_include)
            if name == "All packages":
                tab.connect("button-release-event", self.button_click_cb)
                tab.connect("cell-fadeinout-stopped", self.after_fadeout_checkin_include)
            self.ins.append_page(tab, page["name"], page["tooltip"])
            self.tables.append(tab)

        self.ins.set_entry(search_names, search_tips)
        self.ins.search.connect("changed", self.search_entry_changed)

        # add all into the dialog
        self.box_group_area.pack_start(self.ins, expand=True, fill=True)

        self.button_box = gtk.HBox(False, 6)
        self.box_group_area.pack_start(self.button_box, expand=False, fill=False)

        self.build_image_button = HobButton("Build image")
        # self.build_image_button.set_size_request(205, 49)
        self.build_image_button.set_tooltip_text("Build target image")
        self.build_image_button.set_flags(gtk.CAN_DEFAULT)
        self.build_image_button.grab_default()
        self.build_image_button.connect("clicked", self.build_image_clicked_cb)
        self.button_box.pack_end(self.build_image_button, expand=False, fill=False)

        self.back_button = HobAltButton("Cancel")
        self.back_button.connect("clicked", self.back_button_clicked_cb)
        self.button_box.pack_end(self.back_button, expand=False, fill=False)
Exemplo n.º 4
0
    def create_visual_elements(self):
        self.eventbox = self.add_onto_top_bar(None, 73)
        self.pack_start(self.eventbox, expand=False, fill=False)
        self.pack_start(self.group_align, expand=True, fill=True)

        # set visible members
        self.ins = HobNotebook()
        self.tables = []  # we need modify table when the dialog is shown
        # append the tabs in order
        for page in self.pages:
            columns = page['columns']
            tab = HobViewTable(columns)
            filter = page['filter']
            tab.set_model(self.recipe_model.tree_model(filter))
            tab.connect("toggled", self.table_toggled_cb, page['name'])
            if page['name'] == "Included":
                tab.connect("button-release-event", self.button_click_cb)
                tab.connect("cell-fadeinout-stopped",
                            self.after_fadeout_checkin_include)
            self.ins.append_page(tab, page['name'], page['tooltip'])
            self.tables.append(tab)

        self.ins.set_entry("Search recipes:")
        # set the search entry for each table
        for tab in self.tables:
            search_tip = "Enter a recipe's or task's name to find it"
            self.ins.search.set_tooltip_text(search_tip)
            self.ins.search.props.has_tooltip = True
            tab.set_search_entry(0, self.ins.search)

        # add all into the window
        self.box_group_area.pack_start(self.ins, expand=True, fill=True)

        button_box = gtk.HBox(False, 6)
        self.box_group_area.pack_end(button_box, expand=False, fill=False)

        self.build_packages_button = HobButton('Build packages')
        self.build_packages_button.set_size_request(205, 49)
        self.build_packages_button.set_tooltip_text(
            "Build selected recipes into packages")
        self.build_packages_button.set_flags(gtk.CAN_DEFAULT)
        self.build_packages_button.grab_default()
        self.build_packages_button.connect("clicked",
                                           self.build_packages_clicked_cb)
        button_box.pack_end(self.build_packages_button,
                            expand=False,
                            fill=False)

        self.back_button = HobAltButton("<< Back to image configuration")
        self.back_button.connect("clicked", self.back_button_clicked_cb)
        button_box.pack_start(self.back_button, expand=False, fill=False)
    def create_visual_elements(self):
        self.label = gtk.Label()
        self.eventbox = self.add_onto_top_bar(self.label, 73)
        self.pack_start(self.eventbox, expand=False, fill=False)
        self.pack_start(self.group_align, expand=True, fill=True)

        # set visiable members
        self.ins = HobNotebook()
        self.tables = [] # we need modify table when the dialog is shown
        # append the tabs in order
        for page in self.pages:
            columns = page['columns']
            tab = HobViewTable(columns)
            filter = page['filter']
            tab.set_model(self.recipe_model.tree_model(filter))
            tab.connect("toggled", self.table_toggled_cb, page['name'])
            if page['name'] == "Included":
                tab.connect("button-release-event", self.button_click_cb)
                tab.connect("cell-fadeinout-stopped", self.after_fadeout_checkin_include)
            label = gtk.Label(page['name'])
            label.set_selectable(False)
            label.set_tooltip_text(page['tooltip'])
            self.ins.append_page(tab, label)
            self.tables.append(tab)

        self.ins.set_entry("Search recipes:")
        # set the search entry for each table
        for tab in self.tables:
            search_tip = "Enter a recipe's or task's name to find it"
            self.ins.search.set_tooltip_text(search_tip)
            self.ins.search.props.has_tooltip = True
            tab.set_search_entry(0, self.ins.search)

        # add all into the window
        self.box_group_area.pack_start(self.ins, expand=True, fill=True)

        button_box = gtk.HBox(False, 6)
        self.box_group_area.pack_end(button_box, expand=False, fill=False)

        self.build_packages_button = HobButton('Build packages')
        self.build_packages_button.set_size_request(205, 49)
        self.build_packages_button.set_tooltip_text("Build selected recipes into packages")
        self.build_packages_button.set_flags(gtk.CAN_DEFAULT)
        self.build_packages_button.grab_default()
        self.build_packages_button.connect("clicked", self.build_packages_clicked_cb)
        button_box.pack_end(self.build_packages_button, expand=False, fill=False)

        self.back_button = HobAltButton("<< Back to image configuration")
        self.back_button.connect("clicked", self.back_button_clicked_cb)
        button_box.pack_start(self.back_button, expand=False, fill=False)
Exemplo n.º 6
0
    def create_visual_elements(self):
        self.eventbox = self.add_onto_top_bar(None, 73)
        self.pack_start(self.eventbox, expand=False, fill=False)
        self.pack_start(self.group_align, expand=True, fill=True)

        # set visible members
        self.ins = HobNotebook()
        self.tables = [] # we need modify table when the dialog is shown

        search_names = []
        search_tips = []
        # append the tabs in order
        for page in self.pages:
            columns = page['columns']
            name = page['name']
            tab = HobViewTable(columns, name)
            search_names.append(page['search'])
            search_tips.append(page['searchtip'])
            filter = page['filter']
            sort_model = self.recipe_model.tree_model(filter, initial=True)
            tab.set_model(sort_model)
            tab.connect("toggled", self.table_toggled_cb, name)
            tab.connect("button-release-event", self.button_click_cb)
            tab.connect("cell-fadeinout-stopped", self.after_fadeout_checkin_include, filter)
            self.ins.append_page(tab, page['name'], page['tooltip'])
            self.tables.append(tab)

        self.ins.set_entry(search_names, search_tips)
        self.ins.search.connect("changed", self.search_entry_changed)

        # add all into the window
        self.box_group_area.pack_start(self.ins, expand=True, fill=True)

        button_box = gtk.HBox(False, 6)
        self.box_group_area.pack_end(button_box, expand=False, fill=False)

        self.build_packages_button = HobButton('Build packages')
        #self.build_packages_button.set_size_request(205, 49)
        self.build_packages_button.set_tooltip_text("Build selected recipes into packages")
        self.build_packages_button.set_flags(gtk.CAN_DEFAULT)
        self.build_packages_button.grab_default()
        self.build_packages_button.connect("clicked", self.build_packages_clicked_cb)
        button_box.pack_end(self.build_packages_button, expand=False, fill=False)

        self.back_button = HobAltButton('Cancel')
        self.back_button.connect("clicked", self.back_button_clicked_cb)
        button_box.pack_end(self.back_button, expand=False, fill=False)
Exemplo n.º 7
0
    def create_visual_elements(self):
        self.label = gtk.Label(
            "Packages included: 0\nSelected packages size: 0 MB")
        self.eventbox = self.add_onto_top_bar(self.label, 73)
        self.pack_start(self.eventbox, expand=False, fill=False)
        self.pack_start(self.group_align, expand=True, fill=True)

        # set visible members
        self.ins = HobNotebook()
        self.tables = []  # we need to modify table when the dialog is shown
        # append the tab
        for page in self.pages:
            columns = page['columns']
            tab = HobViewTable(columns)
            filter = page['filter']
            tab.set_model(self.package_model.tree_model(filter))
            tab.connect("toggled", self.table_toggled_cb, page['name'])
            tab.connect_group_selection(self.table_selected_cb)
            if page['name'] == "Included":
                tab.connect("button-release-event", self.button_click_cb)
                tab.connect("cell-fadeinout-stopped",
                            self.after_fadeout_checkin_include)
            self.ins.append_page(tab, page['name'])
            self.tables.append(tab)

        self.ins.set_entry("Search packages:")
        # set the search entry for each table
        for tab in self.tables:
            tab.set_search_entry(0, self.ins.search)

        # add all into the dialog
        self.box_group_area.pack_start(self.ins, expand=True, fill=True)

        button_box = gtk.HBox(False, 6)
        self.box_group_area.pack_start(button_box, expand=False, fill=False)

        self.build_image_button = HobButton('Build image')
        self.build_image_button.set_size_request(205, 49)
        self.build_image_button.set_tooltip_text("Build target image")
        self.build_image_button.set_flags(gtk.CAN_DEFAULT)
        self.build_image_button.grab_default()
        self.build_image_button.connect("clicked", self.build_image_clicked_cb)
        button_box.pack_end(self.build_image_button, expand=False, fill=False)

        self.back_button = HobAltButton("<< Back to image configuration")
        self.back_button.connect("clicked", self.back_button_clicked_cb)
        button_box.pack_start(self.back_button, expand=False, fill=False)
Exemplo n.º 8
0
    def create_visual_elements(self):
        self.label = gtk.Label("Packages included: 0\nSelected packages size: 0 MB")
        self.eventbox = self.add_onto_top_bar(self.label, 73)
        self.pack_start(self.eventbox, expand=False, fill=False)
        self.pack_start(self.group_align, expand=True, fill=True)

        # set visible members
        self.ins = HobNotebook()
        self.tables = [] # we need to modify table when the dialog is shown
        # append the tab
        for page in self.pages:
            columns = page['columns']
            tab = HobViewTable(columns)
            filter = page['filter']
            tab.set_model(self.package_model.tree_model(filter))
            tab.connect("toggled", self.table_toggled_cb, page['name'])
            tab.connect_group_selection(self.table_selected_cb)
            if page['name'] == "Included":
                tab.connect("button-release-event", self.button_click_cb)
                tab.connect("cell-fadeinout-stopped", self.after_fadeout_checkin_include)
            self.ins.append_page(tab, page['name'])
            self.tables.append(tab)

        self.ins.set_entry("Search packages:")
        # set the search entry for each table
        for tab in self.tables:
            tab.set_search_entry(0, self.ins.search)

        # add all into the dialog
        self.box_group_area.pack_start(self.ins, expand=True, fill=True)

        button_box = gtk.HBox(False, 6)
        self.box_group_area.pack_start(button_box, expand=False, fill=False)

        self.build_image_button = HobButton('Build image')
        self.build_image_button.set_size_request(205, 49)
        self.build_image_button.set_tooltip_text("Build target image")
        self.build_image_button.set_flags(gtk.CAN_DEFAULT)
        self.build_image_button.grab_default()
        self.build_image_button.connect("clicked", self.build_image_clicked_cb)
        button_box.pack_end(self.build_image_button, expand=False, fill=False)

        self.back_button = HobAltButton("<< Back to image configuration")
        self.back_button.connect("clicked", self.back_button_clicked_cb)
        button_box.pack_start(self.back_button, expand=False, fill=False)
Exemplo n.º 9
0
class PackageSelectionPage(HobPage):

    pages = [{
        'name':
        'All packages',
        'tooltip':
        'All packages that have been built',
        'filter': {},
        'search':
        'Search packages by name',
        'searchtip':
        'Enter a package name to find it',
        'columns': [{
            'col_name': 'Included',
            'col_id': PackageListModel.COL_INC,
            'col_style': 'check toggle',
            'col_min': 50,
            'col_max': 50
        }, {
            'col_name': 'Package name',
            'col_id': PackageListModel.COL_NAME,
            'col_style': 'text',
            'col_min': 100,
            'col_max': 200,
            'expand': 'True'
        }, {
            'col_name': 'Size',
            'col_id': PackageListModel.COL_SIZE,
            'col_style': 'text',
            'col_min': 80,
            'col_max': 80,
            'expand': 'True'
        }, {
            'col_name': 'Brought in by',
            'col_id': PackageListModel.COL_BINB,
            'col_style': 'binb',
            'col_min': 150,
            'col_max': 170,
            'expand': 'True'
        }]
    }]

    (INCLUDED, ALL) = range(2)

    def __init__(self, builder):
        super(PackageSelectionPage, self).__init__(builder, "Edit packages")

        # set invisible members
        self.recipe_model = self.builder.recipe_model
        self.package_model = self.builder.package_model

        # create visual elements
        self.create_visual_elements()

    def create_visual_elements(self):
        self.label = gtk.Label(
            "Packages included: 0\nSelected packages size: 0 MB")
        self.eventbox = self.add_onto_top_bar(self.label, padding=15)
        self.pack_start(self.eventbox, expand=False, fill=False)
        self.pack_start(self.group_align, expand=True, fill=True)

        # set visible members
        self.ins = HobNotebook()
        self.tables = []  # we need to modify table when the dialog is shown

        search_names = []
        search_tips = []
        # append the tab
        page = self.pages[0]
        columns = page['columns']
        name = page['name']
        self.tab = HobViewTable(columns, name)
        search_names.append(page['search'])
        search_tips.append(page['searchtip'])
        self.ins.set_entry(search_names, search_tips)
        self.ins.search.connect("changed", self.search_entry_changed)
        filter = page['filter']
        sort_model = self.package_model.tree_model(filter, initial=True)
        self.tab.set_model(sort_model)
        self.tab.connect("toggled", self.table_toggled_cb, name)
        self.tab.connect("button-release-event", self.button_click_cb)
        self.tab.connect("cell-fadeinout-stopped",
                         self.after_fadeout_checkin_include, filter)
        #self.tab.set_size_request(-1, 350)
        self.ins.append_page(self.tab, page['name'], page['tooltip'])
        self.tables.append(self.tab)

        # add all into the dialog
        self.box_group_area.pack_start(self.ins, expand=True, fill=True)

        self.button_box = gtk.HBox(False, 6)
        self.box_group_area.pack_start(self.button_box,
                                       expand=False,
                                       fill=False)

        self.build_image_button = HobButton('Build image')
        self.build_image_button.set_tooltip_text("Build your image")
        self.build_image_button.set_flags(gtk.CAN_DEFAULT)
        self.build_image_button.grab_default()
        self.build_image_button.connect("clicked", self.build_image_clicked_cb)
        self.button_box.pack_end(self.build_image_button,
                                 expand=False,
                                 fill=False)

        self.back_button = HobAltButton('Cancel')
        self.back_button.connect("clicked", self.back_button_clicked_cb)
        self.button_box.pack_end(self.back_button, expand=False, fill=False)

    def search_entry_changed(self, entry):
        text = entry.get_text()
        if self.ins.search_focus:
            self.ins.search_focus = False
        elif self.ins.page_changed:
            self.ins.page_change = False
            self.filter_search(entry)
        elif text not in self.ins.search_names:
            self.filter_search(entry)

    def filter_search(self, entry):
        text = entry.get_text()
        current_tab = 0
        filter = self.pages[current_tab]['filter']
        filter[PackageListModel.COL_NAME] = text
        self.tables[current_tab].set_model(
            self.package_model.tree_model(filter, search_data=text))
        if self.package_model.filtered_nb == 0:
            if not self.tab.top_bar:
                self.tab.add_no_result_bar(entry)
                self.tab.top_bar.set_no_show_all(True)
            self.tab.top_bar.show()
            self.tab.scroll.hide()
        else:
            if self.tab.top_bar:
                self.tab.top_bar.hide()
            self.tab.scroll.show()
        if entry.get_text() == '':
            entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, False)
        else:
            entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, True)

    def button_click_cb(self, widget, event):
        path, col = widget.table_tree.get_cursor()
        tree_model = widget.table_tree.get_model()
        if path and col.get_title(
        ) != 'Included':  # else activation is likely a removal
            properties = {
                'binb': '',
                'name': '',
                'size': '',
                'recipe': '',
                'files_list': ''
            }
            properties['binb'] = tree_model.get_value(
                tree_model.get_iter(path), PackageListModel.COL_BINB)
            properties['name'] = tree_model.get_value(
                tree_model.get_iter(path), PackageListModel.COL_NAME)
            properties['size'] = tree_model.get_value(
                tree_model.get_iter(path), PackageListModel.COL_SIZE)
            properties['files_list'] = tree_model.get_value(
                tree_model.get_iter(path), PackageListModel.COL_FLIST)

            self.builder.show_recipe_property_dialog(properties)

    def open_log_clicked_cb(self, button, log_file):
        if log_file:
            log_file = "file:///" + log_file
            gtk.show_uri(screen=button.get_screen(), uri=log_file, timestamp=0)

    def show_page(self, log_file):
        children = self.button_box.get_children() or []
        for child in children:
            self.button_box.remove(child)
        # re-packed the buttons as request, add the 'open log' button if build success
        self.button_box.pack_end(self.build_image_button,
                                 expand=False,
                                 fill=False)
        if log_file:
            open_log_button = HobAltButton("Open log")
            open_log_button.connect("clicked", self.open_log_clicked_cb,
                                    log_file)
            open_log_button.set_tooltip_text("Open the build's log file")
            self.button_box.pack_end(open_log_button, expand=False, fill=False)
        self.button_box.pack_end(self.back_button, expand=False, fill=False)
        self.show_all()

    def build_image_clicked_cb(self, button):
        selected_pkgs = self.package_model.get_selected_packages()
        show_missing_pkg_dialog = False
        lbl = "<b>Missing important packages</b>\n\nYour list of included "
        lbl = lbl + " packages is missing:\n\n"
        if not ('eglibc' in selected_pkgs or 'uclibc' in selected_pkgs):
            show_missing_pkg_dialog = True
            lbl = lbl + "-A C library (choose eglibc or uclibc)\n\n"
        if not ('bash' in selected_pkgs or 'busybox' in selected_pkgs):
            show_missing_pkg_dialog = True
            lbl = lbl + "-A shell provider (choose bash or busybox)\n\n"
        if 'initscripts' not in selected_pkgs:
            show_missing_pkg_dialog = True
            lbl = lbl + "-Initialization scripts (choose initscripts)\n\n"

        if show_missing_pkg_dialog:
            dialog = CrumbsMessageDialog(None, lbl, gtk.STOCK_DIALOG_INFO)
            button = dialog.add_button("Build anyway", gtk.RESPONSE_OK)
            tooltip = "Build the image without changing the included packages"
            button.set_tooltip_text(tooltip)
            HobButton.style_button(button)
            button = dialog.add_button("Edit packages", gtk.RESPONSE_CANCEL)
            tooltip = "Change the list of included packages"
            button.set_tooltip_text(tooltip)
            HobButton.style_button(button)
            response = dialog.run()
            dialog.destroy()
            if response == gtk.RESPONSE_CANCEL:
                return
        self.builder.build_image()

    def refresh_tables(self):
        self.ins.reset_entry(self.ins.search, 0)
        for tab in self.tables:
            index = self.tables.index(tab)
            filter = self.pages[index]['filter']
            tab.set_model(self.package_model.tree_model(filter, initial=True))

    def back_button_clicked_cb(self, button):
        self.builder.restore_initial_selected_packages()
        self.refresh_selection()
        self.ins.search.set_text("")
        self.builder.recipe_model.set_selected_image(
            self.builder.configuration.initial_selected_image)
        self.builder.image_configuration_page.update_image_combo(
            self.builder.configuration.initial_selected_image)
        self.builder.image_configuration_page.update_image_desc()
        self.builder.show_configuration()
        self.refresh_tables()

    def refresh_selection(self):
        self.builder.configuration.selected_packages = self.package_model.get_selected_packages(
        )
        self.builder.configuration.user_selected_packages = self.package_model.get_user_selected_packages(
        )
        selected_packages_num = len(
            self.builder.configuration.selected_packages)
        selected_packages_size = self.package_model.get_packages_size()
        selected_packages_size_str = HobPage._size_to_string(
            selected_packages_size)

        self.label.set_label(
            "Packages included: %s   Selected packages size: %s" %
            (selected_packages_num, selected_packages_size_str))

    def toggle_item_idle_cb(self, path, view_tree, cell, pagename):
        if not self.package_model.path_included(path):
            self.package_model.include_item(item_path=path,
                                            binb="User Selected")
        else:
            self.pre_fadeout_checkout_include(view_tree)
            self.package_model.exclude_item(item_path=path)
            self.render_fadeout(view_tree, cell)

        self.refresh_selection()
        if not self.builder.customized:
            self.builder.customized = True
            self.builder.configuration.initial_selected_image = self.builder.configuration.selected_image
            self.builder.configuration.selected_image = self.recipe_model.__custom_image__
            self.builder.rcppkglist_populated()

        self.builder.window_sensitive(True)
        view_model = view_tree.get_model()
        vpath = self.package_model.convert_path_to_vpath(view_model, path)
        view_tree.set_cursor(vpath)

    def table_toggled_cb(self, table, cell, view_path, toggled_columnid,
                         view_tree, pagename):
        # Click to include a package
        self.builder.window_sensitive(False)
        view_model = view_tree.get_model()
        path = self.package_model.convert_vpath_to_path(view_model, view_path)
        glib.idle_add(self.toggle_item_idle_cb, path, view_tree, cell,
                      pagename)

    def pre_fadeout_checkout_include(self, tree):
        #after the fadeout the table will be sorted as before
        self.sort_column_id = self.package_model.sort_column_id
        self.sort_order = self.package_model.sort_order

        self.package_model.resync_fadeout_column(
            self.package_model.get_iter_first())
        # Check out a model which base on the column COL_FADE_INC,
        # it's save the prev state of column COL_INC before do exclude_item
        filter = {PackageListModel.COL_FADE_INC: [True]}
        new_model = self.package_model.tree_model(filter,
                                                  excluded_items_ahead=True)
        tree.set_model(new_model)
        tree.expand_all()

    def get_excluded_rows(self, to_render_cells, model, it):
        while it:
            path = model.get_path(it)
            prev_cell_is_active = model.get_value(
                it, PackageListModel.COL_FADE_INC)
            curr_cell_is_active = model.get_value(it, PackageListModel.COL_INC)
            if (prev_cell_is_active == True) and (curr_cell_is_active
                                                  == False):
                to_render_cells.append(path)
            if model.iter_has_child(it):
                self.get_excluded_rows(to_render_cells, model,
                                       model.iter_children(it))
            it = model.iter_next(it)

        return to_render_cells

    def render_fadeout(self, tree, cell):
        if (not cell) or (not tree):
            return
        to_render_cells = []
        view_model = tree.get_model()
        self.get_excluded_rows(to_render_cells, view_model,
                               view_model.get_iter_first())

        cell.fadeout(tree, 1000, to_render_cells)

    def after_fadeout_checkin_include(self, table, ctrl, cell, tree, filter):
        self.package_model.sort_column_id = self.sort_column_id
        self.package_model.sort_order = self.sort_order
        tree.set_model(self.package_model.tree_model(filter))
        tree.expand_all()
Exemplo n.º 10
0
    def show_page(self, step):
        build_succeeded = step == self.builder.IMAGE_GENERATED
        image_addr = self.builder.parameters.image_addr
        image_names = self.builder.parameters.image_names
        if build_succeeded:
            machine = self.builder.configuration.curr_mach
            base_image = self.builder.recipe_model.get_selected_image()
            layers = self.builder.configuration.layers
            pkg_num = "%s" % len(self.builder.package_model.get_selected_packages())
        else:
            pkg_num = "N/A"

        self._remove_all_widget()
        self.pack_start(self.details_top_buttons, expand=False, fill=False)
        self.pack_start(self.group_align, expand=True, fill=True)

        if build_succeeded:
            # building is the previous step
            icon = gtk.Image()
            pixmap_path = hic.ICON_INDI_CONFIRM_FILE
            color = HobColors.RUNNING
            pix_buffer = gtk.gdk.pixbuf_new_from_file(pixmap_path)
            icon.set_from_pixbuf(pix_buffer)
            varlist = [""]
            vallist = ["Your image is ready"]
            build_result = self.DetailBox(varlist=varlist, vallist=vallist, icon=icon, color=color)
            self.box_group_area.pack_start(build_result, expand=False, fill=False)

        # Name
        self.image_store.clear()
        for image_name in image_names:
            image_size = self._size_to_string(os.stat(os.path.join(image_addr, image_name)).st_size)
            self.image_store.set(self.image_store.append(), 0, image_name, 1, image_size, 2, False)
        image_table = HobViewTable(self.__columns__)
        image_table.set_model(self.image_store)
        image_table.toggle_default()
        image_size = self._size_to_string(os.stat(os.path.join(image_addr, image_names[0])).st_size)
        image_table.connect("toggled", self.toggled_cb)
        view_files_button = gtk.LinkButton("file://%s" % image_addr, "View files")
        self.box_group_area.pack_start(
            self.DetailBox(widget=image_table, button=view_files_button), expand=True, fill=True
        )

        # Machine, Base image and Layers
        layer_num_limit = 15
        varlist = ["Machine: ", "Base image: ", "Layers: "]
        vallist = []
        if build_succeeded:
            vallist.append(machine)
            vallist.append(base_image)
            i = 0
            for layer in layers:
                varlist.append(" - ")
                if i > layer_num_limit:
                    break
                i += 1
            vallist.append("")
            i = 0
            for layer in layers:
                if i > layer_num_limit:
                    break
                elif i == layer_num_limit:
                    vallist.append("and more...")
                else:
                    vallist.append(layer)
                i += 1

            edit_config_button = gtk.LinkButton("Changes settings for build", "Edit configuration")
            edit_config_button.connect("clicked", self.edit_config_button_clicked_cb)
            setting_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=edit_config_button)
            self.box_group_area.pack_start(setting_detail, expand=False, fill=False)

        # Packages included, and Total image size
        varlist = ["Packages included: ", "Total image size: "]
        vallist = []
        vallist.append(pkg_num)
        vallist.append(image_size)
        if build_succeeded:
            edit_packages_button = gtk.LinkButton("Change package selection for customization", "Edit packages")
            edit_packages_button.connect("clicked", self.edit_packages_button_clicked_cb)
        else:  # get to this page from "My images"
            edit_packages_button = None
        self.package_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=edit_packages_button)
        self.box_group_area.pack_start(self.package_detail, expand=False, fill=False)

        if build_succeeded:
            buttonlist = ["Build new image", "Save as template", "Run image", "Deploy image"]
        else:  # get to this page from "My images"
            buttonlist = ["Build new image", "Run image", "Deploy image"]
        details_bottom_buttons = self.create_bottom_buttons(buttonlist)
        self.box_group_area.pack_end(details_bottom_buttons, expand=False, fill=False)

        self.show_all()
Exemplo n.º 11
0
class ImageSelectionDialog (CrumbsDialog):

    __columns__ = [{
            'col_name' : 'Image name',
            'col_id'   : 0,
            'col_style': 'text',
            'col_min'  : 400,
            'col_max'  : 400
        }, {
            'col_name' : 'Select',
            'col_id'   : 1,
            'col_style': 'radio toggle',
            'col_min'  : 160,
            'col_max'  : 160
    }]


    def __init__(self, image_folder, image_types, title, parent, flags, buttons=None):
        super(ImageSelectionDialog, self).__init__(title, parent, flags, buttons)
        self.connect("response", self.response_cb)

        self.image_folder = image_folder
        self.image_types  = image_types
        self.image_list = []
        self.image_names = []

        # create visual elements on the dialog
        self.create_visual_elements()

        self.image_store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_BOOLEAN)
        self.fill_image_store()

    def create_visual_elements(self):
        hbox = gtk.HBox(False, 6)

        self.vbox.pack_start(hbox, expand=False, fill=False)

        entry = gtk.Entry()
        entry.set_text(self.image_folder)
        table = gtk.Table(1, 10, True)
        table.set_size_request(560, -1)
        hbox.pack_start(table, expand=False, fill=False)
        table.attach(entry, 0, 9, 0, 1)
        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_OPEN, gtk.ICON_SIZE_BUTTON)
        open_button = gtk.Button()
        open_button.set_image(image)
        open_button.connect("clicked", self.select_path_cb, self, entry)
        table.attach(open_button, 9, 10, 0, 1)

        self.image_table = HobViewTable(self.__columns__)
        self.image_table.set_size_request(-1, 300)
        self.image_table.connect("toggled", self.toggled_cb)
        self.vbox.pack_start(self.image_table, expand=True, fill=True)

        self.show_all()

    def toggled_cb(self, table, cell, path, columnid, tree):
        model = tree.get_model()
        if not model:
            return
        iter = model.get_iter_first()
        while iter:
            rowpath = model.get_path(iter)
            model[rowpath][columnid] = False
            iter = model.iter_next(iter)

        model[path][columnid] = True

    def select_path_cb(self, action, parent, entry):
        dialog = gtk.FileChooserDialog("", parent,
                                       gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
        button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
        HobAltButton.style_button(button)
        button = dialog.add_button("Open", gtk.RESPONSE_YES)
        HobButton.style_button(button)
        response = dialog.run()
        if response == gtk.RESPONSE_YES:
            path = dialog.get_filename()
            entry.set_text(path)
            self.image_folder = path
            self.fill_image_store()

        dialog.destroy()

    def fill_image_store(self):
        self.image_list = []
        self.image_store.clear()
        imageset = set()
        for root, dirs, files in os.walk(self.image_folder):
            # ignore the sub directories
            dirs[:] = []
            for f in files:
                for image_type in self.image_types:
                    for real_image_type in hcc.SUPPORTED_IMAGE_TYPES[image_type]:
                        if f.endswith('.' + real_image_type):
                            imageset.add(f.rsplit('.' + real_image_type)[0].rsplit('.rootfs')[0])
                            self.image_list.append(f)
        
        for image in imageset:
            self.image_store.set(self.image_store.append(), 0, image, 1, False)

        self.image_table.set_model(self.image_store)

    def response_cb(self, dialog, response_id):
        self.image_names = []
        if response_id == gtk.RESPONSE_YES:
            iter = self.image_store.get_iter_first()
            while iter:
                path = self.image_store.get_path(iter)
                if self.image_store[path][1]:
                    for f in self.image_list:
                        if f.startswith(self.image_store[path][0] + '.'):
                            self.image_names.append(f)
                    break            
                iter = self.image_store.iter_next(iter)
Exemplo n.º 12
0
class ImageSelectionDialog(CrumbsDialog):

    __columns__ = [{
        'col_name': 'Image name',
        'col_id': 0,
        'col_style': 'text',
        'col_min': 400,
        'col_max': 400
    }, {
        'col_name': 'Select',
        'col_id': 1,
        'col_style': 'radio toggle',
        'col_min': 160,
        'col_max': 160
    }]

    def __init__(self,
                 image_folder,
                 image_types,
                 title,
                 parent,
                 flags,
                 buttons=None,
                 image_extension={}):
        super(ImageSelectionDialog, self).__init__(title, parent, flags,
                                                   buttons)
        self.connect("response", self.response_cb)

        self.image_folder = image_folder
        self.image_types = image_types
        self.image_list = []
        self.image_names = []
        self.image_extension = image_extension

        # create visual elements on the dialog
        self.create_visual_elements()

        self.image_store = gtk.ListStore(gobject.TYPE_STRING,
                                         gobject.TYPE_BOOLEAN)
        self.fill_image_store()

    def create_visual_elements(self):
        hbox = gtk.HBox(False, 6)

        self.vbox.pack_start(hbox, expand=False, fill=False)

        entry = gtk.Entry()
        entry.set_text(self.image_folder)
        table = gtk.Table(1, 10, True)
        table.set_size_request(560, -1)
        hbox.pack_start(table, expand=False, fill=False)
        table.attach(entry, 0, 9, 0, 1)
        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_OPEN, gtk.ICON_SIZE_BUTTON)
        open_button = gtk.Button()
        open_button.set_image(image)
        open_button.connect("clicked", self.select_path_cb, self, entry)
        table.attach(open_button, 9, 10, 0, 1)

        self.image_table = HobViewTable(self.__columns__, "Images")
        self.image_table.set_size_request(-1, 300)
        self.image_table.connect("toggled", self.toggled_cb)
        self.image_table.connect_group_selection(self.table_selected_cb)
        self.image_table.connect("row-activated", self.row_actived_cb)
        self.vbox.pack_start(self.image_table, expand=True, fill=True)

        self.show_all()

    def change_image_cb(self, model, path, columnid):
        if not model:
            return
        iter = model.get_iter_first()
        while iter:
            rowpath = model.get_path(iter)
            model[rowpath][columnid] = False
            iter = model.iter_next(iter)

        model[path][columnid] = True

    def toggled_cb(self, table, cell, path, columnid, tree):
        model = tree.get_model()
        self.change_image_cb(model, path, columnid)

    def table_selected_cb(self, selection):
        model, paths = selection.get_selected_rows()
        if paths:
            self.change_image_cb(model, paths[0], 1)

    def row_actived_cb(self, tab, model, path):
        self.change_image_cb(model, path, 1)
        self.emit('response', gtk.RESPONSE_YES)

    def select_path_cb(self, action, parent, entry):
        dialog = gtk.FileChooserDialog("", parent,
                                       gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
        text = entry.get_text()
        dialog.set_current_folder(text if len(text) > 0 else os.getcwd())
        button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
        HobAltButton.style_button(button)
        button = dialog.add_button("Open", gtk.RESPONSE_YES)
        HobButton.style_button(button)
        response = dialog.run()
        if response == gtk.RESPONSE_YES:
            path = dialog.get_filename()
            entry.set_text(path)
            self.image_folder = path
            self.fill_image_store()

        dialog.destroy()

    def fill_image_store(self):
        self.image_list = []
        self.image_store.clear()
        imageset = set()
        for root, dirs, files in os.walk(self.image_folder):
            # ignore the sub directories
            dirs[:] = []
            for f in files:
                for image_type in self.image_types:
                    if image_type in self.image_extension:
                        real_types = self.image_extension[image_type]
                    else:
                        real_types = [image_type]
                    for real_image_type in real_types:
                        if f.endswith('.' + real_image_type):
                            imageset.add(
                                f.rsplit('.' + real_image_type)[0].rsplit(
                                    '.rootfs')[0])
                            self.image_list.append(f)

        for image in imageset:
            self.image_store.set(self.image_store.append(), 0, image, 1, False)

        self.image_table.set_model(self.image_store)

    def response_cb(self, dialog, response_id):
        self.image_names = []
        if response_id == gtk.RESPONSE_YES:
            iter = self.image_store.get_iter_first()
            while iter:
                path = self.image_store.get_path(iter)
                if self.image_store[path][1]:
                    for f in self.image_list:
                        if f.startswith(self.image_store[path][0] + '.'):
                            self.image_names.append(f)
                    break
                iter = self.image_store.iter_next(iter)
Exemplo n.º 13
0
    def create_visual_elements(self):
        self.label = gtk.Label("Recipes included: %s" % len(self.builder.configuration.selected_recipes))
        self.eventbox = self.add_onto_top_bar(self.label, 73)
        self.pack_start(self.eventbox, expand=False, fill=False)
        self.pack_start(self.group_align, expand=True, fill=True)

        # set visiable members
        self.grid = gtk.Table(10, 1, True)
        self.grid.set_col_spacings(3)

        # draw the left part of the window
        # a notebook
        self.ins = gtk.Notebook()
        self.ins.set_show_tabs(False)
        self.tables = [] # we need modify table when the dialog is shown
        # append the tabs in order
        for i in range(len(self.pages)):
            columns = self.pages[i]['columns']
            tab = HobViewTable(columns)
            filter = self.pages[i]['filter']
            tab.set_model(self.recipe_model.tree_model(filter))
            tab.connect("toggled", self.table_toggled_cb)
            if self.pages[i]['name'] == "Included":
                tab.connect("row-activated", self.tree_row_activated_cb)
            reset_button = gtk.Button("Reset")
            reset_button.connect("clicked", self.reset_clicked_cb)
            hbox = gtk.HBox(False, 5)
            hbox.pack_end(reset_button, expand=False, fill=False)
            tab.pack_start(hbox, expand=False, fill=False)

            label = gtk.Label(self.pages[i]['name'])
            self.ins.append_page(tab, label)
            self.tables.append(tab)

        self.grid.attach(self.ins, 0, 1, 1, 10, gtk.FILL | gtk.EXPAND, gtk.FILL | gtk.EXPAND)
        # a black bar associated with the notebook
        self.topbar = HobViewBar(self.ins)
        self.grid.attach(self.topbar, 0, 1, 0, 1, gtk.FILL | gtk.EXPAND, gtk.FILL | gtk.EXPAND)
        # set the search entry for each table
        for tab in self.tables:
            tab.set_search_entry(0, self.topbar.search)

        # add all into the window
        self.box_group_area.add(self.grid)

        button_box = gtk.HBox(False, 5)
        self.box_group_area.pack_end(button_box, expand=False, fill=False)

        self.build_packages_button = gtk.Button()
        label = gtk.Label()
        mark = "<span %s>Build packages</span>" % self.span_tag('24px', 'bold')
        label.set_markup(mark)
        self.build_packages_button.set_image(label)
        self.build_packages_button.set_size_request(205, 49)
        self.build_packages_button.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(HobColors.ORANGE))
        self.build_packages_button.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(HobColors.ORANGE))
        self.build_packages_button.modify_bg(gtk.STATE_SELECTED, gtk.gdk.Color(HobColors.ORANGE))
        self.build_packages_button.set_tooltip_text("Build packages for customization")
        self.build_packages_button.set_flags(gtk.CAN_DEFAULT)
        self.build_packages_button.grab_default()
        self.build_packages_button.connect("clicked", self.build_packages_clicked_cb)
        button_box.pack_end(self.build_packages_button, expand=False, fill=False)

        self.back_button = gtk.LinkButton("Go back to Image Configuration screen", "<< Back to image configuration")
        self.back_button.connect("clicked", self.back_button_clicked_cb)
        button_box.pack_start(self.back_button, expand=False, fill=False)
Exemplo n.º 14
0
class PackageSelectionPage (HobPage):

    pages = [
        {
         'name'      : 'All packages',
         'tooltip'   : 'All packages that have been built',
         'filter'    : {},
         'search'    : 'Search packages by name',
         'searchtip' : 'Enter a package name to find it',
         'columns'   : [{
                       'col_name' : 'Included',
                       'col_id'   : PackageListModel.COL_INC,
                       'col_style': 'check toggle',
                       'col_min'  : 50,
                       'col_max'  : 50
                      }, {
                       'col_name' : 'Package name',
                       'col_id'   : PackageListModel.COL_NAME,
                       'col_style': 'text',
                       'col_min'  : 100,
                       'col_max'  : 200,
                       'expand'   : 'True'
                      }, {
                       'col_name' : 'Size',
                       'col_id'   : PackageListModel.COL_SIZE,
                       'col_style': 'text',
                       'col_min'  : 80,
                       'col_max'  : 80,
                       'expand'   : 'True'
                      }, {
                       'col_name' : 'Brought in by',
                       'col_id'   : PackageListModel.COL_BINB,
                       'col_style': 'binb',
                       'col_min'  : 150,
                       'col_max'  : 170,
                       'expand'   : 'True'
                      }]
        }
    ]
    
    (INCLUDED,
     ALL) = range(2)

    def __init__(self, builder):
        super(PackageSelectionPage, self).__init__(builder, "Edit packages")

        # set invisible members
        self.recipe_model = self.builder.recipe_model
        self.package_model = self.builder.package_model

        # create visual elements
        self.create_visual_elements()

    def create_visual_elements(self):
        self.label = gtk.Label("Packages included: 0\nSelected packages size: 0 MB")
        self.eventbox = self.add_onto_top_bar(self.label, padding=15)
        self.pack_start(self.eventbox, expand=False, fill=False)
        self.pack_start(self.group_align, expand=True, fill=True)

        # set visible members
        self.ins = HobNotebook()
        self.tables = [] # we need to modify table when the dialog is shown

        search_names = []
        search_tips = []
        # append the tab
        page = self.pages[0]
        columns = page['columns']
        name = page['name']
        self.tab = HobViewTable(columns, name)
        search_names.append(page['search'])
        search_tips.append(page['searchtip'])
        self.ins.set_entry(search_names, search_tips)
        self.ins.search.connect("changed", self.search_entry_changed)
        filter = page['filter']
        sort_model = self.package_model.tree_model(filter, initial=True)
        self.tab.set_model(sort_model)
        self.tab.connect("toggled", self.table_toggled_cb, name)
        self.tab.connect("button-release-event", self.button_click_cb)
        self.tab.connect("cell-fadeinout-stopped", self.after_fadeout_checkin_include, filter)
        #self.tab.set_size_request(-1, 350)
        self.ins.append_page(self.tab, page['name'], page['tooltip'])
        self.tables.append(self.tab)

        # add all into the dialog
        self.box_group_area.pack_start(self.ins, expand=True, fill=True)

        self.button_box = gtk.HBox(False, 6)
        self.box_group_area.pack_start(self.button_box, expand=False, fill=False)

        self.build_image_button = HobButton('Build image')
        self.build_image_button.set_tooltip_text("Build your image")
        self.build_image_button.set_flags(gtk.CAN_DEFAULT)
        self.build_image_button.grab_default()
        self.build_image_button.connect("clicked", self.build_image_clicked_cb)
        self.button_box.pack_end(self.build_image_button, expand=False, fill=False)

        self.back_button = HobAltButton('Cancel')
        self.back_button.connect("clicked", self.back_button_clicked_cb)
        self.button_box.pack_end(self.back_button, expand=False, fill=False)

    def search_entry_changed(self, entry):
        text = entry.get_text()
        if self.ins.search_focus:
            self.ins.search_focus = False
        elif self.ins.page_changed:
            self.ins.page_change = False
            self.filter_search(entry)
        elif text not in self.ins.search_names:
            self.filter_search(entry)

    def filter_search(self, entry):
        text = entry.get_text()
        current_tab = 0
        filter = self.pages[current_tab]['filter']
        filter[PackageListModel.COL_NAME] = text
        self.tables[current_tab].set_model(self.package_model.tree_model(filter, search_data=text))
        if self.package_model.filtered_nb == 0:
            if not self.tab.top_bar:
                self.tab.add_no_result_bar(entry)
                self.tab.top_bar.set_no_show_all(True)
            self.tab.top_bar.show()
            self.tab.scroll.hide()
        else:
            if self.tab.top_bar:
                self.tab.top_bar.hide()
            self.tab.scroll.show()
        if entry.get_text() == '':
            entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, False)
        else:
            entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, True)

    def button_click_cb(self, widget, event):
        path, col = widget.table_tree.get_cursor()
        tree_model = widget.table_tree.get_model()
        if path and col.get_title() != 'Included': # else activation is likely a removal
            properties = {'binb': '' , 'name': '', 'size':'', 'recipe':'', 'files_list':''}
            properties['binb'] = tree_model.get_value(tree_model.get_iter(path), PackageListModel.COL_BINB)
            properties['name'] = tree_model.get_value(tree_model.get_iter(path), PackageListModel.COL_NAME)
            properties['size'] = tree_model.get_value(tree_model.get_iter(path), PackageListModel.COL_SIZE)
            properties['files_list'] = tree_model.get_value(tree_model.get_iter(path), PackageListModel.COL_FLIST)

            self.builder.show_recipe_property_dialog(properties)

    def open_log_clicked_cb(self, button, log_file):
        if log_file:
            log_file = "file:///" + log_file
            gtk.show_uri(screen=button.get_screen(), uri=log_file, timestamp=0)

    def show_page(self, log_file):
        children = self.button_box.get_children() or []
        for child in children:
            self.button_box.remove(child)
        # re-packed the buttons as request, add the 'open log' button if build success
        self.button_box.pack_end(self.build_image_button, expand=False, fill=False)
        if log_file:
            open_log_button = HobAltButton("Open log")
            open_log_button.connect("clicked", self.open_log_clicked_cb, log_file)
            open_log_button.set_tooltip_text("Open the build's log file")
            self.button_box.pack_end(open_log_button, expand=False, fill=False)
        self.button_box.pack_end(self.back_button, expand=False, fill=False)
        self.show_all()

    def build_image_clicked_cb(self, button):
        selected_pkgs = self.package_model.get_selected_packages()
        show_missing_pkg_dialog = False
        lbl = "<b>Missing important packages</b>\n\nYour list of included "
        lbl = lbl + " packages is missing:\n\n"
        if not ('eglibc' in selected_pkgs or 'uclibc' in selected_pkgs):
            show_missing_pkg_dialog = True
            lbl = lbl + "-A C library (choose eglibc or uclibc)\n\n"
        if not ('bash' in selected_pkgs or 'busybox'  in selected_pkgs):
            show_missing_pkg_dialog = True
            lbl = lbl + "-A shell provider (choose bash or busybox)\n\n"
        if 'initscripts' not in selected_pkgs:
            show_missing_pkg_dialog = True
            lbl = lbl + "-Initialization scripts (choose initscripts)\n\n"

        if show_missing_pkg_dialog:
            dialog = CrumbsMessageDialog(None, lbl, gtk.STOCK_DIALOG_INFO)
            button = dialog.add_button("Build anyway", gtk.RESPONSE_OK)
            tooltip = "Build the image without changing the included packages"
            button.set_tooltip_text(tooltip)
            HobButton.style_button(button)
            button = dialog.add_button("Edit packages", gtk.RESPONSE_CANCEL)
            tooltip = "Change the list of included packages"
            button.set_tooltip_text(tooltip)
            HobButton.style_button(button)
            response = dialog.run()
            dialog.destroy()
            if response == gtk.RESPONSE_CANCEL:
                return
        self.builder.build_image()

    def refresh_tables(self):
        self.ins.reset_entry(self.ins.search, 0)
        for tab in self.tables:
            index = self.tables.index(tab)
            filter = self.pages[index]['filter']
            tab.set_model(self.package_model.tree_model(filter, initial=True))

    def back_button_clicked_cb(self, button):
        self.builder.restore_initial_selected_packages()
        self.refresh_selection()
        self.ins.search.set_text("")
        self.builder.recipe_model.set_selected_image(self.builder.configuration.initial_selected_image)
        self.builder.image_configuration_page.update_image_combo(self.builder.configuration.initial_selected_image)
        self.builder.image_configuration_page.update_image_desc()
        self.builder.show_configuration()
        self.refresh_tables()

    def refresh_selection(self):
        self.builder.configuration.selected_packages = self.package_model.get_selected_packages()
        self.builder.configuration.user_selected_packages = self.package_model.get_user_selected_packages()
        selected_packages_num = len(self.builder.configuration.selected_packages)
        selected_packages_size = self.package_model.get_packages_size()
        selected_packages_size_str = HobPage._size_to_string(selected_packages_size)

        self.label.set_label("Packages included: %s   Selected packages size: %s" %
                            (selected_packages_num, selected_packages_size_str))

    def toggle_item_idle_cb(self, path, view_tree, cell, pagename):
        if not self.package_model.path_included(path):
            self.package_model.include_item(item_path=path, binb="User Selected")
        else:
            self.pre_fadeout_checkout_include(view_tree)
            self.package_model.exclude_item(item_path=path)
            self.render_fadeout(view_tree, cell)

        self.refresh_selection()
        if not self.builder.customized:
            self.builder.customized = True
            self.builder.configuration.initial_selected_image = self.builder.configuration.selected_image
            self.builder.configuration.selected_image = self.recipe_model.__custom_image__
            self.builder.rcppkglist_populated()

        self.builder.window_sensitive(True)
        view_model = view_tree.get_model()
        vpath = self.package_model.convert_path_to_vpath(view_model, path)
        view_tree.set_cursor(vpath)

    def table_toggled_cb(self, table, cell, view_path, toggled_columnid, view_tree, pagename):
        # Click to include a package
        self.builder.window_sensitive(False)
        view_model = view_tree.get_model()
        path = self.package_model.convert_vpath_to_path(view_model, view_path)
        glib.idle_add(self.toggle_item_idle_cb, path, view_tree, cell, pagename)

    def pre_fadeout_checkout_include(self, tree):
        #after the fadeout the table will be sorted as before
        self.sort_column_id = self.package_model.sort_column_id
        self.sort_order = self.package_model.sort_order

        self.package_model.resync_fadeout_column(self.package_model.get_iter_first())
        # Check out a model which base on the column COL_FADE_INC,
        # it's save the prev state of column COL_INC before do exclude_item
        filter = { PackageListModel.COL_FADE_INC  : [True]}
        new_model = self.package_model.tree_model(filter, excluded_items_ahead=True)
        tree.set_model(new_model)
        tree.expand_all()

    def get_excluded_rows(self, to_render_cells, model, it):
        while it:
            path = model.get_path(it)
            prev_cell_is_active = model.get_value(it, PackageListModel.COL_FADE_INC)
            curr_cell_is_active = model.get_value(it, PackageListModel.COL_INC)
            if (prev_cell_is_active == True) and (curr_cell_is_active == False):
                to_render_cells.append(path)
            if model.iter_has_child(it):
                self.get_excluded_rows(to_render_cells, model, model.iter_children(it))
            it = model.iter_next(it)

        return to_render_cells

    def render_fadeout(self, tree, cell):
        if (not cell) or (not tree):
            return
        to_render_cells = []
        view_model = tree.get_model()
        self.get_excluded_rows(to_render_cells, view_model, view_model.get_iter_first())

        cell.fadeout(tree, 1000, to_render_cells)

    def after_fadeout_checkin_include(self, table, ctrl, cell, tree, filter):
        self.package_model.sort_column_id = self.sort_column_id
        self.package_model.sort_order = self.sort_order
        tree.set_model(self.package_model.tree_model(filter))
        tree.expand_all()
Exemplo n.º 15
0
    def show_page(self, step):
        build_succeeded = (step == self.builder.IMAGE_GENERATED)
        image_addr = self.builder.parameters.image_addr
        image_names = self.builder.parameters.image_names
        if build_succeeded:
            machine = self.builder.configuration.curr_mach
            base_image = self.builder.recipe_model.get_selected_image()
            layers = self.builder.configuration.layers
            pkg_num = "%s" % len(self.builder.package_model.get_selected_packages())
        else:
            pkg_num = "N/A"

        # remove
        for button_id, button in self.button_ids.items():
            button.disconnect(button_id)
        self._remove_all_widget()

        # repack
        self.pack_start(self.details_top_buttons, expand=False, fill=False)
        self.pack_start(self.group_align, expand=True, fill=True)

        self.build_result = None
        if build_succeeded:
            # building is the previous step
            icon = gtk.Image()
            pixmap_path = hic.ICON_INDI_CONFIRM_FILE
            color = HobColors.RUNNING
            pix_buffer = gtk.gdk.pixbuf_new_from_file(pixmap_path)
            icon.set_from_pixbuf(pix_buffer)
            varlist = [""]
            vallist = ["Your image is ready"]
            self.build_result = self.DetailBox(varlist=varlist, vallist=vallist, icon=icon, color=color)
            self.box_group_area.pack_start(self.build_result, expand=False, fill=False)

        # create the buttons at the bottom first because the buttons are used in apply_button_per_image()
        if build_succeeded:
            self.buttonlist = ["Build new image", "Save as template", "Run image", "Deploy image"]
        else: # get to this page from "My images"
            self.buttonlist = ["Build new image", "Run image", "Deploy image"]

        # Name
        varlist = [""]
        vallist = ["Listed generated image and package files."]
        t = ''
        self.image_store.clear()
        default_toggled = False
        default_image_size = 0
        i = 0
        for image_name in image_names:
            image_size = HobPage._size_to_string(os.stat(os.path.join(image_addr, image_name)).st_size)
            if not default_toggled:
                default_toggled = (self.test_type_runnable(image_name) and self.test_mach_runnable(image_name)) \
                    or self.test_deployable(image_name)
                if i == (len(image_names) - 1):
                    default_toggled = True
                self.image_store.set(self.image_store.append(), 0, image_name, 1, image_size, 2, default_toggled)
                if default_toggled:
                    default_image_size = image_size
                    self.create_bottom_buttons(self.buttonlist, image_name)
                    if 'qemu' in image_name:
                        t = ' (Selected QEMU items to be as runnable image)'
                    else:
                        t = ' (Selected Targeted item to be deploy)'
            else:
                self.image_store.set(self.image_store.append(), 0, image_name, 1, image_size, 2, False)
            i = i + 1

        if build_succeeded:
            varlist = ["Name: ", "Directory: ", ". "]
            vallist = []
            vallist.append(image_name.split('.')[0])
            vallist.append(image_addr)
            vallist.append(t)
            image_table = None
        else:
            image_table = HobViewTable(self.__columns__)
            image_table.set_model(self.image_store)
            image_table.connect("row-activated", self.row_activated_cb)
            if default_image_size and ('qemu' in image_name):
                t = '\n(Selected QEMU items to be as runnable image, so you need to select prompted kernel to run)'
            vallist[0] += t

        view_files_button = HobAltButton("View files")
        view_files_button.connect("clicked", self.view_files_clicked_cb, image_addr)
        view_files_button.set_tooltip_text("Open the directory containing the image files")
        self.image_detail = self.DetailBox(widget=image_table, varlist=varlist, vallist=vallist, button=view_files_button)
        self.box_group_area.pack_start(self.image_detail, expand=True, fill=True)

        # Machine, Base image and Layers
        layer_num_limit = 15
        varlist = ["Machine: ", "Base image: ", "Layers: "]
        vallist = []
        self.setting_detail = None
        if build_succeeded:
            vallist.append(machine)
            vallist.append(base_image)
            i = 0
            for layer in layers:
                varlist.append(" - ")
                if i > layer_num_limit:
                    break
                i += 1
            vallist.append("")
            i = 0
            for layer in layers:
                if i > layer_num_limit:
                    break
                elif i == layer_num_limit:
                    vallist.append("and more...")
                else:
                    vallist.append(layer)
                i += 1

            edit_config_button = HobAltButton("Edit configuration")
            edit_config_button.set_tooltip_text("Edit machine, base image and recipes")
            edit_config_button.connect("clicked", self.edit_config_button_clicked_cb)
            self.setting_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=edit_config_button)
            self.box_group_area.pack_start(self.setting_detail, expand=True, fill=True)

        # Packages included, and Total image size
        varlist = ["Packages included: ", "Total image size: "]
        vallist = []
        vallist.append(pkg_num)
        vallist.append(default_image_size)
        if build_succeeded:
            edit_packages_button = HobAltButton("Edit packages")
            edit_packages_button.set_tooltip_text("Edit the packages included in your image")
            edit_packages_button.connect("clicked", self.edit_packages_button_clicked_cb)
        else: # get to this page from "My images"
            edit_packages_button = None
        self.package_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=edit_packages_button)
        self.box_group_area.pack_start(self.package_detail, expand=False, fill=False)

        # pack the buttons at the bottom, at this time they are already created.
        self.box_group_area.pack_end(self.details_bottom_buttons, expand=False, fill=False)

        self.show_all()
Exemplo n.º 16
0
    def show_page(self, step):
        build_succeeded = (step == self.builder.IMAGE_GENERATED)
        image_addr = self.builder.parameters.image_addr
        image_names = self.builder.parameters.image_names
        if build_succeeded:
            machine = self.builder.configuration.curr_mach
            base_image = self.builder.recipe_model.get_selected_image()
            layers = self.builder.configuration.layers
            pkg_num = "%s" % len(self.builder.package_model.get_selected_packages())
        else:
            pkg_num = "N/A"

        # remove
        for button_id, button in self.button_ids.items():
            button.disconnect(button_id)
        self._remove_all_widget()
        # repack
        self.pack_start(self.details_top_buttons, expand=False, fill=False)
        self.pack_start(self.group_align, expand=True, fill=True)

        self.build_result = None
        if build_succeeded:
            # building is the previous step
            icon = gtk.Image()
            pixmap_path = hic.ICON_INDI_CONFIRM_FILE
            color = HobColors.RUNNING
            pix_buffer = gtk.gdk.pixbuf_new_from_file(pixmap_path)
            icon.set_from_pixbuf(pix_buffer)
            varlist = [""]
            vallist = ["Your image is ready"]
            self.build_result = self.DetailBox(varlist=varlist, vallist=vallist, icon=icon, color=color)
            self.box_group_area.pack_start(self.build_result, expand=False, fill=False)

        # create the buttons at the bottom first because the buttons are used in apply_button_per_image()
        if build_succeeded:
            self.buttonlist = ["Build new image", "Save as template", "Run image", "Deploy image"]
        else: # get to this page from "My images"
            self.buttonlist = ["Build new image", "Run image", "Deploy image"]

        # Name
        self.image_store.clear()
        default_toggled = False
        default_image_size = 0
        i = 0
        for image_name in image_names:
            image_size = HobPage._size_to_string(os.stat(os.path.join(image_addr, image_name)).st_size)
            if not default_toggled:
                default_toggled = (self.test_type_runnable(image_name) and self.test_mach_runnable(image_name)) \
                    or self.test_deployable(image_name)
                if i == (len(image_names) - 1):
                    default_toggled = True
                self.image_store.set(self.image_store.append(), 0, image_name, 1, image_size, 2, default_toggled)
                if default_toggled:
                    default_image_size = image_size
                    self.create_bottom_buttons(self.buttonlist, image_name)
            else:
                self.image_store.set(self.image_store.append(), 0, image_name, 1, image_size, 2, False)
            i = i + 1
        image_table = HobViewTable(self.__columns__)
        image_table.set_model(self.image_store)
        image_table.connect("toggled", self.toggled_cb)
        view_files_button = HobAltButton("View files")
        view_files_button.connect("clicked", self.view_files_clicked_cb, image_addr)
        view_files_button.set_tooltip_text("Open the directory containing the image files")
        self.image_detail = self.DetailBox(widget=image_table, button=view_files_button)
        self.box_group_area.pack_start(self.image_detail, expand=True, fill=True)

        # Machine, Base image and Layers
        layer_num_limit = 15
        varlist = ["Machine: ", "Base image: ", "Layers: "]
        vallist = []
        self.setting_detail = None
        if build_succeeded:
            vallist.append(machine)
            vallist.append(base_image)
            i = 0
            for layer in layers:
                varlist.append(" - ")
                if i > layer_num_limit:
                    break
                i += 1
            vallist.append("")
            i = 0
            for layer in layers:
                if i > layer_num_limit:
                    break
                elif i == layer_num_limit:
                    vallist.append("and more...")
                else:
                    vallist.append(layer)
                i += 1

            edit_config_button = HobAltButton("Edit configuration")
            edit_config_button.set_tooltip_text("Edit machine, base image and recipes")
            edit_config_button.connect("clicked", self.edit_config_button_clicked_cb)
            self.setting_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=edit_config_button)
            self.box_group_area.pack_start(self.setting_detail, expand=False, fill=False)

        # Packages included, and Total image size
        varlist = ["Packages included: ", "Total image size: "]
        vallist = []
        vallist.append(pkg_num)
        vallist.append(default_image_size)
        if build_succeeded:
            edit_packages_button = HobAltButton("Edit packages")
            edit_packages_button.set_tooltip_text("Edit the packages included in your image")
            edit_packages_button.connect("clicked", self.edit_packages_button_clicked_cb)
        else: # get to this page from "My images"
            edit_packages_button = None
        self.package_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=edit_packages_button)
        self.box_group_area.pack_start(self.package_detail, expand=False, fill=False)

        # pack the buttons at the bottom, at this time they are already created.
        self.box_group_area.pack_end(self.details_bottom_buttons, expand=False, fill=False)

        self.show_all()