Пример #1
0
    def populate_treeview(self):
        renderer = ga_Gtk.CellRendererText()
        column = ga_Gtk.TreeViewColumn(_("Contract"),
                                       renderer,
                                       text=self.model['contract_number'])
        column.set_expand(True)
        column.set_sort_column_id(self.model['contract_number'])
        self.model.set_sort_func(self.model['contract_number'],
                                 self._sort_text, None)
        self.contract_selection_treeview.append_column(column)

        column = widgets.MachineTypeColumn(self.model['is_virt_only'])
        column.set_sort_column_id(self.model['is_virt_only'])
        self.model.set_sort_func(self.model['is_virt_only'],
                                 self._sort_machine_type, column)
        self.contract_selection_treeview.append_column(column)

        renderer = ga_Gtk.CellRendererText()
        renderer.set_property("xalign", 0.5)
        column = ga_Gtk.TreeViewColumn(_("Used / Total"),
                                    renderer,
                                    text=self.model['consumed_fraction'])
        self.contract_selection_treeview.append_column(column)

        renderer = widgets.CellRendererDate()
        column = ga_Gtk.TreeViewColumn(_("Start Date"),
                                    renderer,
                                    date=self.model['start_date'])
        column.set_sort_column_id(self.model['start_date'])
        self.model.set_sort_func(self.model['start_date'],
                                 self._sort_date, None)
        self.contract_selection_treeview.append_column(column)

        renderer = widgets.CellRendererDate()
        column = ga_Gtk.TreeViewColumn(_("End Date"),
                                    renderer,
                                    date=self.model['end_date'])
        column.set_sort_column_id(self.model['end_date'])
        self.model.set_sort_func(self.model['end_date'],
                                 self._sort_date,
                                 None)
        self.contract_selection_treeview.append_column(column)

        column = widgets.QuantitySelectionColumn(_("Quantity"), self.model,
                self.model['default_quantity'],
                self.model['multi_entitlement'],
                self.model['quantity_available'],
                self.model['quantity_increment'])
        self.contract_selection_treeview.append_column(column)

        self.edit_quantity_label.set_label(column.get_column_legend_text())
    def populate_treeview(self):
        renderer = gtk.CellRendererText()
        column = gtk.TreeViewColumn(_("Contract"), renderer,
                text=0)
        column.set_expand(True)
        column.set_sort_column_id(0)
        self.model.set_sort_func(0, self._sort_text, None)
        self.contract_selection_treeview.append_column(column)

        column = MachineTypeColumn(7)
        column.set_sort_column_id(7)
        self.model.set_sort_func(7, self._sort_machine_type, column)
        self.contract_selection_treeview.append_column(column)

        renderer = gtk.CellRendererText()
        renderer.set_property("xalign", 0.5)
        column = gtk.TreeViewColumn(_("Used / Total"), renderer,
                text=1)
        self.contract_selection_treeview.append_column(column)

        renderer = widgets.CellRendererDate()
        column = gtk.TreeViewColumn(_("Start Date"), renderer, date=2)
        column.set_sort_column_id(2)
        self.model.set_sort_func(2, self._sort_date, None)
        self.contract_selection_treeview.append_column(column)

        renderer = widgets.CellRendererDate()
        column = gtk.TreeViewColumn(_("End Date"), renderer, date=3)
        column.set_sort_column_id(3)
        self.model.set_sort_func(3, self._sort_date, None)
        self.contract_selection_treeview.append_column(column)

        column = MultiEntitlementColumn(8)
        self.contract_selection_treeview.append_column(column)

        column = widgets.QuantitySelectionColumn(_("Quantity"), self.model, 4, 8, 9)
        self.contract_selection_treeview.append_column(column)

        self.edit_quantity_label.set_label(column.get_column_legend_text())
Пример #3
0
    def __init__(self, backend, parent_win):

        super(AllSubscriptionsTab, self).__init__()

        # Set up dynamic elements
        self.no_subs_label, self.no_subs_label_viewport = widgets.get_scrollable_label(
        )
        # Add at-spi because we no longer create this widget from glade
        self.top_view.get_accessible().set_name(_("All Subscriptions View"))
        self.widget_switcher = widgets.WidgetSwitcher(
            self.scrolledwindow, self.no_subs_label_viewport, self.top_view)
        self.widget_switcher.set_active(0)

        self.parent_win = parent_win
        self.backend = backend
        self.identity = require(IDENTITY)

        # Progress bar
        self.pb = None
        self.timer = 0

        self.pool_stash = managerlib.PoolStash()

        self.async_bind = async .AsyncBind(self.backend.certlib)

        today = datetime.date.today()
        self.date_picker = widgets.DatePicker(today)
        self.date_picker_hbox.add(self.date_picker)

        # Custom build of the subscription column.
        title_text_renderer = ga_Gtk.CellRendererText()
        title_text_renderer.set_property('xalign', 0.0)
        subscription_column = ga_Gtk.TreeViewColumn(
            _('Subscription'),
            title_text_renderer,
            markup=self.store['product_name_formatted'])
        subscription_column.set_expand(True)
        self.top_view.append_column(subscription_column)
        cols = []
        cols.append((subscription_column, 'text', 'product_name_formatted'))

        machine_type_col = widgets.MachineTypeColumn(self.store['virt_only'])
        self.top_view.append_column(machine_type_col)
        cols.append((machine_type_col, 'text', 'virt_only'))

        column = self.add_text_column(_('Available'), 'available')
        cols.append((column, 'text', 'available'))

        # Set up the quantity column.
        quantity_column = widgets.QuantitySelectionColumn(
            _("Quantity"), self.store, self.store['quantity_to_consume'],
            self.store['multi-entitlement'], self.store['quantity_available'],
            self.store['quantity_increment'])
        self.top_view.append_column(quantity_column)

        self.set_sorts(self.store, cols)

        self.edit_quantity_label.set_label(
            quantity_column.get_column_legend_text())

        # FIXME: Likely a correct way to do this now, so stub this out now
        # Ensure all cells are colored according the the store.
        #set_background_model_index(self.top_view, self.store['background'])
        # FIXME

        self.top_view.connect(
            "row_activated", widgets.expand_collapse_on_row_activated_callback)

        # This option should be selected by default:
        self.sub_details = widgets.SubDetailsWidget(backend.product_dir)
        self.details_box.add(self.sub_details.get_widget())

        self.contract_selection = None

        self.filters = Filters(show_compatible=True, show_no_overlapping=True)
        self.filter_dialog = FilterOptionsWindow(self.filters, self)

        self.update_applied_filters_label()
        self.connect_signals({
            "on_search_button_clicked":
            self.search_button_clicked,
            "on_subscribe_button_clicked":
            self.subscribe_button_clicked,
            "on_filter_options_button_clicked":
            self.filter_options_button_clicked,
        })

        # Nothing displayed initially:
        self.clear_pools()