Exemple #1
0
    def __init__(self, backend, parent_win, ent_dir, prod_dir):
        """
        Create a new 'My Subscriptions' tab.
        """
        super(MySubscriptionsTab, self).__init__()
        self.backend = backend
        self.identity = inj.require(inj.IDENTITY)
        self.parent_win = parent_win
        self.entitlement_dir = ent_dir
        self.product_dir = prod_dir
        self.sub_details = widgets.ContractSubDetailsWidget(prod_dir)
        self.async_bind = AsyncBind(self.backend.certlib)
        self.pooltype_cache = inj.require(inj.POOLTYPE_CACHE)

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

        # Put the details widget in the middle
        details = self.sub_details.get_widget()
        self.details_box.pack_start(details, True, True, 0)

        # Set up columns on the view
        text_renderer = ga_Gtk.CellRendererText()
        image_renderer = ga_Gtk.CellRendererPixbuf()
        column = ga_Gtk.TreeViewColumn(_('Subscription'))
        column.set_expand(True)
        column.pack_start(image_renderer, False)
        column.pack_start(text_renderer, False)
        column.add_attribute(image_renderer, 'pixbuf', self.store['image'])
        column.add_attribute(text_renderer, 'text', self.store['subscription'])
        column.add_attribute(text_renderer, 'cell-background',
                             self.store['background'])
        column.add_attribute(image_renderer, 'cell-background',
                             self.store['background'])
        column.set_sizing(ga_Gtk.TreeViewColumnSizing.AUTOSIZE)

        self.top_view.append_column(column)
        cols = []
        cols.append((column, 'text', 'subscription'))

        progress_renderer = ga_Gtk.CellRendererProgress()
        products_column = ga_Gtk.TreeViewColumn(
            _("Installed Products"),
            progress_renderer,
            value=self.store['installed_value'],
            text=self.store['installed_text'])
        products_column.add_attribute(progress_renderer, 'cell-background',
                                      self.store['background'])
        self.empty_progress_renderer = ga_Gtk.CellRendererText()
        products_column.pack_end(self.empty_progress_renderer, True)
        products_column.set_cell_data_func(progress_renderer,
                                           self._update_progress_renderer)
        self.top_view.append_column(products_column)

        column = self.add_date_column(_("End Date"), 'expiration_date')
        cols.append((column, 'date', 'expiration_date'))

        column = self.add_text_column(_("Quantity"), 'quantity')
        cols.append((column, 'text', 'quantity'))

        self.set_sorts(self.store, cols)

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

        # Don't update the icon in the first run, we don't have real compliance data yet
        self.update_subscriptions(update_dbus=False)

        self.connect_signals(
            {'on_unsubscribe_button_clicked': self.unsubscribe_button_clicked})
    def __init__(self, backend, consumer, facts, parent_win, ent_dir,
                 prod_dir):
        """
        Create a new 'My Subscriptions' tab.
        """
        super(MySubscriptionsTab, self).__init__('mysubs.glade')
        self.backend = backend
        self.consumer = consumer
        self.facts = facts
        self.parent_win = parent_win
        self.entitlement_dir = ent_dir
        self.product_dir = prod_dir

        self.sub_details = widgets.ContractSubDetailsWidget(prod_dir)

        # Put the details widget in the middle
        details = self.sub_details.get_widget()
        self.details_box.pack_start(details)

        # Set up columns on the view
        text_renderer = gtk.CellRendererText()
        image_renderer = gtk.CellRendererPixbuf()
        column = gtk.TreeViewColumn(_('Subscription'))
        column.set_expand(True)
        column.pack_start(image_renderer, False)
        column.pack_start(text_renderer, False)
        column.add_attribute(image_renderer, 'pixbuf', self.store['image'])
        column.add_attribute(text_renderer, 'text', self.store['subscription'])
        column.add_attribute(text_renderer, 'cell-background',
                             self.store['background'])
        column.add_attribute(image_renderer, 'cell-background',
                             self.store['background'])

        self.top_view.append_column(column)
        cols = []
        cols.append((column, 'text', 'subscription'))

        progress_renderer = gtk.CellRendererProgress()
        products_column = gtk.TreeViewColumn(
            _("Installed Products"),
            progress_renderer,
            value=self.store['installed_value'],
            text=self.store['installed_text'])
        self.empty_progress_renderer = gtk.CellRendererText()
        products_column.pack_end(self.empty_progress_renderer, True)
        products_column.set_cell_data_func(progress_renderer,
                                           self._update_progress_renderer)
        self.top_view.append_column(products_column)

        column = self.add_date_column(_("End Date"), 'expiration_date')
        cols.append((column, 'date', 'expiration_date'))

        # Disable row striping on the tree view as we are overriding the behavior
        # to display stacking groups as one color.
        self.top_view.set_rules_hint(False)

        column = self.add_text_column(_("Quantity"), 'quantity')
        cols.append((column, 'text', 'quantity'))

        self.set_sorts(cols)

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

        self.update_subscriptions()

        self.glade.signal_autoconnect(
            {'on_unsubscribe_button_clicked': self.unsubscribe_button_clicked})

        # Monitor entitlements/products for additions/deletions
        def on_cert_change(filemonitor):
            self.update_subscriptions()

        self.backend.monitor_certs(on_cert_change)