def gtk_quit_on_fail(self):
        try:
            self.fail("registergui didn't get a signal before the timeout.")
        except Exception:
            self.exc_infos.append(sys.exc_info())

        ga_Gtk.main_quit()
 def _getting_started_item_clicked(self, widget):
     try:
         # try to open documentation in yelp
         ga_Gtk.show_uri(None, 'ghelp:subscription-manager', time.time())
     except Exception as e:
         # if we can't open it, it's probably because the user didn't
         # install the docs, or yelp. no need to bother them.
         log.warn("Unable to open help documentation: %s", e)
Exemple #3
0
 def _getting_started_item_clicked(self, widget):
     try:
         # try to open documentation in yelp
         ga_Gtk.show_uri(None, 'ghelp:subscription-manager', time.time())
     except Exception as e:
         # if we can't open it, it's probably because the user didn't
         # install the docs, or yelp. no need to bother them.
         log.warn("Unable to open help documentation: %s", e)
Exemple #4
0
    def __init__(self, table_widget):
        table_widget.get_selection().set_mode(ga_Gtk.SelectionMode.NONE)
        self.override_store = ga_Gtk.ListStore(str, str)
        table_widget.set_model(self.override_store)

        for idx, colname in enumerate([_("Name"), _("Value")]):
            column = ga_Gtk.TreeViewColumn(colname, ga_Gtk.CellRendererText(), markup=0, text=idx)
            column.set_expand(True)
            table_widget.append_column(column)
Exemple #5
0
def get_scrollable_label():
    label = ga_Gtk.Label()
    label.set_use_markup(True)
    label.set_line_wrap(True)
    label.set_line_wrap_mode(ga_Pango.WrapMode.WORD)
    viewport = ga_Gtk.Viewport()
    viewport.add(label)
    viewport.show_all()
    return label, viewport
    def _add_column(self, name, order):
        """Adds a Gtk.TreeViewColumn suitable for displaying text to
        the facts Gtk.TreeView.

        @type   name: string
        @param  name: The name of the created column
        @type  order: integer
        @param order: The 0-based index of the created column
        (in relation to other columns)
        """
        column = ga_Gtk.TreeViewColumn(name, ga_Gtk.CellRendererText(), text=order)
        self.facts_view.append_column(column)
Exemple #7
0
    def __init__(self, backend, tab_icon, parent, ent_dir, prod_dir):
        # The row striping in this TreeView is handled automatically
        # because we have the rules_hint set to True in the Glade file.
        super(InstalledProductsTab, self).__init__()

        self.tab_icon = tab_icon

        self.identity = inj.require(inj.IDENTITY)
        self.entitlement_dir = ent_dir

        self.backend = backend

        # Product column
        text_renderer = ga_Gtk.CellRendererText()
        image_renderer = ga_Gtk.CellRendererPixbuf()
        column = ga_Gtk.TreeViewColumn(_('Product'))

        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['product'])
        self.top_view.append_column(column)
        cols = []
        cols.append((column, 'text', 'product'))

        column = self.add_text_column(_('Version'), 'version')
        cols.append((column, 'text', 'version'))

        column = self.add_text_column(_('Status'), 'status')
        cols.append((column, 'text', 'status'))

        column = self.add_date_column(_('Start Date'), 'start_date')
        cols.append((column, 'date', 'start_date'))

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

        self.set_sorts(self.store, cols)

        if is_owner_using_golden_ticket():
            self.update_certificates_button.set_property("visible", False)

        self.connect_signals({
            "on_update_certificates_button_clicked":
            parent._update_certificates_button_clicked,
            "on_register_button_clicked":
            parent._register_item_clicked,
        })

        self._entries = []
    def __init__(self, facts):

        super(SystemFactsDialog, self).__init__()

        #self.consumer = consumer
        self.identity = inj.require(inj.IDENTITY)
        self.cp_provider = inj.require(inj.CP_PROVIDER)
        self.facts = facts
        self.connect_signals({
            "on_system_facts_dialog_delete_event":
            self._hide_callback,
            "on_close_button_clicked":
            self._hide_callback,
            "on_facts_update_button_clicked":
            self._update_facts_callback
        })

        # Set up the model
        self.facts_store = ga_Gtk.TreeStore(str, str)
        self.facts_view.set_model(self.facts_store)

        # Set up columns on the view
        self._add_column(_("Fact"), 0)
        self._add_column(_("Value"), 1)

        # set up the signals from the view
        self.facts_view.connect(
            "row_activated", widgets.expand_collapse_on_row_activated_callback)
Exemple #9
0
 def __init__(self, column_title, model_idx):
     super(ToggleTextColumn, self).__init__(column_title)
     self.model_idx = model_idx
     self.renderer = ga_Gtk.CellRendererText()
     self.renderer.set_property('xalign', 0.5)
     self.pack_start(self.renderer, False)
     self.set_cell_data_func(self.renderer, self._render_cell)
    def __init__(self):
        """
        Creates a new tab widget, given the specified glade file and a list of
        widget names to extract to instance variables.
        """
        # Mix the specified widgets with standard names in the
        # glade file by convention
        super(SubscriptionManagerTab, self).__init__()

#        self.builder = BuilderFileGui.from_file(glade_file)

        self.content.unparent()

        # In the allsubs tab, we don't show the treeview until it is populated
        if self.top_view is None:
            self.top_view = ga_Gtk.TreeView()

        # grid lines seem busted in rhel5, so we disable
        # in glade and turn on here for unbroken versions
        if ga_Gtk.check_version(self.MIN_GTK_MAJOR_GRID,
                                self.MIN_GTK_MINOR_GRID,
                                self.MIN_GTK_MICRO_GRID) is None:
            self.top_view.set_enable_tree_lines(ga_Gtk.TREE_VIEW_GRID_LINES_BOTH)

        self.store = self.get_store()
        self.top_view.set_model(self.store)

        selection = self.top_view.get_selection()
        selection.connect('changed', self._selection_callback)
Exemple #11
0
    def __init__(self,
                 store,
                 column_title,
                 store_key,
                 expand=False,
                 markup=False):
        self.column_title = column_title
        self.text_renderer = ga_Gtk.CellRendererText()
        self.store_key = store_key

        # FIXME: this is kind of weird...
        if markup:
            super(TextTreeViewColumn, self).__init__(self.column_title,
                                                     self.text_renderer,
                                                     markup=store[store_key])
        else:
            super(TextTreeViewColumn, self).__init__(self.column_title,
                                                     self.text_renderer,
                                                     text=store[store_key])

        if expand:
            self.set_expand(True)
        elif 'align' in store:
            self.add_attribute(self.text_renderer, 'xalign', store['align'])

        if 'background' in store:
            self.add_attribute(self.text_renderer, 'cell-background',
                               store['background'])
Exemple #12
0
    def __init__(self, text, parent=None, title=None):
        ga_GObject.GObject.__init__(self)
        self.rc = None

        # this seems to be wordwrapping text passed to
        # it, which is making for ugly error messages
        self.dialog = ga_Gtk.MessageDialog(parent, 0, self.STYLE, self.BUTTONS)

        if title:
            self.dialog.set_title(title)

        # escape product strings see rh bz#633438
        self.dialog.set_markup(text)

        self.dialog.set_default_response(0)

        self.dialog.set_position(ga_Gtk.WindowPosition.CENTER_ON_PARENT)
        self.dialog.show_all()
        self.dialog.set_icon_name('subscription-manager')

        self.dialog.set_modal(True)
        #this seems spurious, but without it, a ref to this obj gets "lost"
        ga_GObject.add_emission_hook(self, 'response', self.noop_hook)

        self.dialog.connect("response", self._on_response_event)
    def _assert_column_value(self, column_class, model_bool_val, expected_text):
        model = ga_Gtk.ListStore(bool)
        model.append([model_bool_val])

        column = column_class(0)
        column._render_cell(None, column.renderer, model, model.get_iter_first())
        self.assertEqual(expected_text, column.renderer.get_property("text"))
Exemple #14
0
    def _update_cell_based_on_data(self,
                                   column,
                                   cell_renderer,
                                   tree_model,
                                   tree_iter,
                                   Data=None):
        # Clear the cell if we are a parent row.
        if tree_model.iter_n_children(tree_iter) > 0:
            cell_renderer.set_property("text", "")

        # Disable editor if not multi-entitled.
        is_multi_entitled = tree_model.get_value(
            tree_iter, self.is_multi_entitled_store_idx)
        cell_renderer.set_property("editable", is_multi_entitled)

        if is_multi_entitled:
            quantity = tree_model.get_value(tree_iter, self.quantity_store_idx)
            cell_renderer.set_property("text", "%s *" % quantity)

        if self.available_store_idx is not None:
            available = tree_model.get_value(tree_iter,
                                             self.available_store_idx)
            if available and available != -1:
                if self.quantity_increment_idx is not None:
                    increment = tree_model.get_value(
                        tree_iter, self.quantity_increment_idx)
                else:
                    increment = 1

                cell_renderer.set_property(
                    "adjustment",
                    ga_Gtk.Adjustment(lower=int(increment),
                                      upper=int(available),
                                      step_incr=int(increment)))
Exemple #15
0
    def __init__(self, parent, backend):
        self.backend = backend
        self.dialog = ga_Gtk.AboutDialog()
        self.dialog.set_transient_for(parent)
        self.dialog.set_modal(True)
        self.dialog.set_name(_("Subscription Manager"))
        self.dialog.set_license(LICENSE)
        self.dialog.set_wrap_license(True)
        if not get_running_as_firstboot():
            self.dialog.set_website(
                "https://fedorahosted.org/subscription-manager/")
        self.dialog.set_copyright(_("Copyright (c) 2012 Red Hat, Inc."))
        self.dialog.set_logo_icon_name("subscription-manager")
        self.dialog.set_icon_name("subscription-manager")
        self.dialog.set_authors(["The Subscription Manager Team"])

        next_update_label = ga_Gtk.Label()
        python_rhsm_version_label = ga_Gtk.Label()
        sub_man_version_label = ga_Gtk.Label()
        backend_version_label = ga_Gtk.Label()
        context_box = self.dialog.vbox.get_children()[0]
        context_box.pack_end(next_update_label, True, True, 0)
        context_box.pack_end(python_rhsm_version_label, True, True, 0)
        context_box.pack_end(sub_man_version_label, True, True, 0)
        context_box.pack_end(backend_version_label, True, True, 0)

        self._set_next_update(next_update_label)

        # Set the component versions.
        server_versions = get_server_versions(
            self.backend.cp_provider.get_consumer_auth_cp())
        client_versions = get_client_versions()

        python_rhsm_version_label.set_markup(
            _("<b>%s version:</b> %s") %
            ("python-rhsm", client_versions['python-rhsm']))
        sub_man_version_label.set_markup(
            _("<b>%s version:</b> %s") %
            ("subscription manager", client_versions['subscription-manager']))
        backend_version_label.set_markup(
            _("<b>subscription management service version:</b> %s") %
            server_versions['candlepin'])

        self.dialog.connect("response", self._handle_response)
        self.dialog.show_all()
    def _run_filter_value_test(self, test_input_value, is_allowed, upper=15, lower=1, step_incr=1):
        column, tree_model, tree_iter = self._setup_column(1, True)

        adjustment = ga_Gtk.Adjustment(upper=upper, lower=lower, value=7.0, step_incr=step_incr)
        # Simulate the editable created by the CellRendererSpin object.
        editable = ga_Gtk.SpinButton()
        editable.set_property("adjustment", adjustment)

        self.stopped = False

        def ensure_stopped(name):
            self.stopped = True

        editable.emit_stop_by_name = ensure_stopped

        column._filter_spinner_value("test-event", editable, test_input_value)

        self.assertEqual(not is_allowed, self.stopped)
Exemple #17
0
    def __init__(self):
        """
        Create a new widget backed by the give glade file (assumed to be in data/).
        The initial_widget_names is a list of widgets to pull in as instance
        variables.
        """
        self.log = logging.getLogger(__name__ + '.' + self.__class__.__name__)

        self.builder = ga_Gtk.Builder()
def main():
    parser = OptionParser(usage=USAGE,
                          formatter=WrappedIndentedHelpFormatter())
    parser.add_option("--register",
                      action='store_true',
                      help=_("launches the registration dialog on startup"))
    options, args = parser.parse_args(args=sys.argv)

    log = logging.getLogger("rhsm-app.subscription-manager-gui")

    try:
        bus = dbus.SessionBus()
    except dbus.exceptions.DBusException as e:
        log.debug("Enabled to connect to dbus SessionBus")
        log.exception(e)
        # Just ignore it if for some reason we can't find the session bus
        bus = None

    if already_running(bus):
        # Attempt to raise the running instance to the forefront
        try:
            remote_object = bus.get_object(BUS_NAME, BUS_PATH)
            remote_object.show_window(dbus_interface=BUS_NAME)
            log.debug(
                "subscription-manager-gui already running, showing main window"
            )
        except dbus.exceptions.DBusException as e:
            log.debug("Error attempting to show main window via dbus")
            log.debug("dbus remote_object with no show_window: %s" %
                      remote_object)
            log.debug(e)
            # failed to raise the window, maybe we raced dbus?
            # fallback to opening a new window
        else:
            # we raised the existing window, we are done
            sys.exit()

    try:
        main = managergui.MainWindow(auto_launch_registration=options.register)

        # Hook into dbus service - only if it is available
        if bus:
            SubscriptionManagerService(main.main_window)

        # Exit the gtk loop when the window is closed
        main.main_window.connect('hide', ga_Gtk.main_quit)

        sys.exit(ga_Gtk.main() or 0)
    except SystemExit as e:
        # this is a non-exceptional exception thrown by Python 2.4, just
        # re-raise, bypassing handle_exception
        raise e
    except KeyboardInterrupt:
        system_exit(0, "\nUser interrupted process.")
    except Exception as e:
        log.exception(e)
        system_exit(1, e)
Exemple #19
0
class TestLinkify(unittest.TestCase):
    no_url = "this does not have a url"
    https_url = "https://www.redhat.com"
    http_url = "http://www.redhat.com"
    expected_http_url = """<a href="%s">%s</a>""" % (http_url, http_url)
    expected_https_url = """<a href="%s">%s</a>""" % (https_url, https_url)

    http_url_dash = "http://example.com/something-foo/blah_something/"
    expected_http_url_dash = """<a href="%s">%s</a>""" % (http_url_dash,
                                                          http_url_dash)

    nested_space = """<small>http://www.redhat.com </small>"""
    nested = """<small>http://www.redhat.com</small>"""
    expected_nested = """<small><a href="%s">%s</a></small>""" % (http_url,
                                                                  http_url)
    expected_nested_space = """<small><a href="%s">%s</a> </small>""" % (
        http_url, http_url)

    example_1 = """https://access.redhat.com/kb/docs/DOC-45563"""
    example_2 = """https://www.redhat.com/wapps/sso/rhn/lostPassword.html"""
    expected_example_1 = """<a href="%s">%s</a>""" % (example_1, example_1)
    expected_example_2 = """<a href="%s">%s</a>""" % (example_2, example_2)

    if ga_Gtk.check_version(MIN_GTK_MAJOR, MIN_GTK_MINOR, MIN_GTK_MICRO):
        __test__ = False

    def test_no_url(self):
        ret = utils.linkify(self.no_url)
        self.assertEquals(ret, self.no_url)

    def test_https_url(self):
        ret = utils.linkify(self.https_url)
        self.assertEquals(ret, self.expected_https_url)

    def test_http_url(self):
        ret = utils.linkify(self.http_url)
        self.assertEquals(ret, self.expected_http_url)

    def test_http_nested_space(self):
        ret = utils.linkify(self.nested_space)
        self.assertEquals(ret, self.expected_nested_space)

    def test_nested(self):
        ret = utils.linkify(self.nested)
        self.assertEquals(ret, self.expected_nested)

    def test_dash(self):
        ret = utils.linkify(self.http_url_dash)
        self.assertEquals(ret, self.expected_http_url_dash)

    def test_example_1(self):
        ret = utils.linkify(self.example_1)
        self.assertEquals(ret, self.expected_example_1)

    def test_example_2(self):
        ret = utils.linkify(self.example_2)
        self.assertEquals(ret, self.expected_example_2)
Exemple #20
0
 def __init__(self, column_title, store, store_key, toggle_callback=None):
     self.store = store
     self.store_key = store_key
     self._toggle_callback = toggle_callback
     self.renderer = ga_Gtk.CellRendererToggle()
     self.renderer.set_radio(False)
     super(CheckBoxColumn, self).__init__(column_title,
                                          self.renderer,
                                          active=self.store[self.store_key])
     self.renderer.connect("toggled", self._on_toggle)
Exemple #21
0
    def show(self,
             name,
             contract=None,
             start=None,
             end=None,
             account=None,
             management=None,
             support_level="",
             support_type="",
             virt_only=None,
             products=None,
             highlight=None,
             sku=None,
             reasons=[],
             expiring=False,
             pool_type=""):
        """
        Show subscription details.

        Start and end should be datetime objects.
        Products is a list of tuples in the format (name, id)
        """
        products = products or []
        # set a new buffer to clear out all the old tag information
        self.subscription_text.set_buffer(ga_Gtk.TextBuffer())
        self._set(self.subscription_text, name)
        buf = self.subscription_text.get_buffer()
        tag = buf.create_tag("highlight-tag", weight=ga_Pango.Weight.BOLD)

        for index in utils.find_text(name, highlight):
            buf.apply_tag(tag, buf.get_iter_at_offset(index),
                          buf.get_iter_at_offset(index + len(highlight)))

        self._set(self.sku_text, sku)
        self._set(self.pool_type_text, pool_type)

        display_level = support_level
        if support_level == "":
            display_level = _("Not Set")
        if support_type != "":
            display_level_and_type = ", ".join([display_level, support_type])
        else:
            display_level_and_type = display_level

        self._set(self.support_level_and_type_text, display_level_and_type)

        self._show_other_details(name, contract, start, end, account,
                                 management, support_level, support_type,
                                 virt_only, products, highlight, sku, reasons,
                                 expiring)

        self.bundled_products.clear()
        for product in products:
            self.bundled_products.add_product(
                utils.apply_highlight(product[0], highlight), product[1])
Exemple #22
0
    def __init__(self, date):
        """
        Initialize the DatePicker. date is a python datetime.date object.
        """
        super(DatePicker, self).__init__()
        #GObject.GObject.__init__(self)

        image = ga_Gtk.Image.new_from_icon_name('x-office-calendar',
                                                ga_Gtk.IconSize.MENU)
        image.show()

        # set the timezone so we can sent it to the server
        self._date = datetime.datetime(date.year,
                                       date.month,
                                       date.day,
                                       tzinfo=tzlocal())
        self._date_entry = ga_Gtk.Entry()
        self._date_entry.set_width_chars(10)

        self._date_entry.set_text(self._date.date().isoformat())

        atk_entry = self._date_entry.get_accessible()
        atk_entry.set_name('date-entry')

        self._cal_button = ga_Gtk.Button()
        self._cal_button.set_image(image)
        atk_entry = self._cal_button.get_accessible()
        atk_entry.set_name("Calendar")

        self.pack_start(self._date_entry, True, True, 0)
        self.pack_start(self._cal_button, True, True, 0)
        self._cal_button.connect("clicked", self._button_clicked)
        self.connect('date-picked-cal', self._date_update_cal)
        self.connect('date-picked-text', self._date_update_text)

        self._calendar = ga_Gtk.Calendar()
        atk_entry = self._calendar.get_accessible()
        atk_entry.set_name("Calendar")

        self.show()
        self._date_entry.show()
        self._cal_button.show()
    def __init__(self, backend, parent):
        super(PreferencesDialog, self).__init__()
        self.backend = backend
        self.allow_callbacks = False
        self.identity = inj.require(inj.IDENTITY)
        self.async_updater = utils.AsyncWidgetUpdater(self.dialog)
        self.release_backend = release.ReleaseBackend()

        self.inputs = [
            self.sla_combobox, self.release_combobox, self.autoheal_checkbox,
            self.autoheal_event
        ]

        self.dialog.set_transient_for(parent)
        self.dialog.set_modal(True)

        # The first string is the displayed service level; the second is
        # the value sent to Candlepin.
        self.release_model = ga_Gtk.ListStore(str, str)
        self.sla_model = ga_Gtk.ListStore(str, str)

        self.release_combobox.set_model(self.release_model)
        self.sla_combobox.set_model(self.sla_model)

        cell_renderer = ga_Gtk.CellRendererText()
        self.release_combobox.pack_start(cell_renderer, True)
        self.release_combobox.add_attribute(cell_renderer, "text", 0)

        self.sla_combobox.pack_start(cell_renderer, True)
        self.sla_combobox.add_attribute(cell_renderer, "text", 0)

        self.close_button.connect("clicked", self._close_button_clicked)
        self.sla_combobox.connect("changed", self._sla_changed)
        self.release_combobox.connect("changed", self._release_changed)
        self.autoheal_checkbox.connect("toggled",
                                       self._on_autoheal_checkbox_toggled)
        self.autoheal_event.connect("button_press_event",
                                    self._on_autoheal_label_press)

        # Handle the dialog's delete event when ESC key is pressed.
        self.dialog.connect("delete-event", self._dialog_deleted)
def main():
    parser = OptionParser(usage=USAGE,
                          formatter=WrappedIndentedHelpFormatter())
    parser.add_option("--register", action='store_true',
                      help=_("launches the registration dialog on startup"))
    options, args = parser.parse_args(args=sys.argv)

    log = logging.getLogger("rhsm-app.subscription-manager-gui")

    try:
        bus = dbus.SessionBus()
    except dbus.exceptions.DBusException as e:
        log.debug("Enabled to connect to dbus SessionBus")
        log.exception(e)
        # Just ignore it if for some reason we can't find the session bus
        bus = None

    if already_running(bus):
        # Attempt to raise the running instance to the forefront
        try:
            remote_object = bus.get_object(BUS_NAME, BUS_PATH)
            remote_object.show_window(dbus_interface=BUS_NAME)
            log.debug("subscription-manager-gui already running, showing main window")
        except dbus.exceptions.DBusException as e:
            log.debug("Error attempting to show main window via dbus")
            log.debug("dbus remote_object with no show_window: %s" % remote_object)
            log.debug(e)
            # failed to raise the window, maybe we raced dbus?
            # fallback to opening a new window
        else:
            # we raised the existing window, we are done
            sys.exit()

    try:
        main = managergui.MainWindow(auto_launch_registration=options.register)

        # Hook into dbus service - only if it is available
        if bus:
            SubscriptionManagerService(main.main_window)

        # Exit the gtk loop when the window is closed
        main.main_window.connect('hide', ga_Gtk.main_quit)

        sys.exit(ga_Gtk.main() or 0)
    except SystemExit as e:
        # this is a non-exceptional exception thrown by Python 2.4, just
        # re-raise, bypassing handle_exception
        raise e
    except KeyboardInterrupt:
        system_exit(0, "\nUser interrupted process.")
    except Exception as e:
        log.exception(e)
        system_exit(1, e)
    def test_registration_error_returns_to_page(self):
        self.rs.initialize()

        self.correct_page = None

        self.rs.register_notebook.connect('notify::page', self.page_notify_handler)

        self.rs.connect('register-error', self.error_handler)

        ga_GObject.timeout_add(3000, self.gtk_quit_on_fail)
        ga_GObject.idle_add(self.emit_proceed)
        ga_GObject.idle_add(self.emit_error)

        # run till quit or timeout
        # if we get to the state we want we can call quit
        ga_Gtk.main()

        # If we saw any exceptions, raise them now so we fail nosetests
        for exc_info in self.exc_infos:
            six.reraise(*exc_info)

        self.assertTrue(self.correct_page)
Exemple #26
0
    def test_registration_error_returns_to_page(self):
        self.rs.initialize()

        self.correct_page = None

        self.rs.register_notebook.connect('notify::page', self.page_notify_handler)

        self.rs.connect('register-error', self.error_handler)

        ga_GObject.timeout_add(3000, self.gtk_quit_on_fail)
        ga_GObject.idle_add(self.emit_proceed)
        ga_GObject.idle_add(self.emit_error)

        # run till quit or timeout
        # if we get to the state we want we can call quit
        ga_Gtk.main()

        # If we saw any exceptions, raise them now so we fail nosetests
        for exc_info in self.exc_infos:
            raise exc_info[1], None, exc_info[2]

        self.assertTrue(self.correct_page)
Exemple #27
0
    def __init__(self, column_title, tree_model, quantity_store_idx, is_multi_entitled_store_idx,
                 available_store_idx=None, quantity_increment_idx=None, editable=True):
        self.quantity_store_idx = quantity_store_idx
        self.is_multi_entitled_store_idx = is_multi_entitled_store_idx
        self.available_store_idx = available_store_idx
        self.quantity_increment_idx = quantity_increment_idx

        self.quantity_renderer = ga_Gtk.CellRendererSpin()
        self.quantity_renderer.set_property("xalign", 0)
        self.quantity_renderer.set_property("adjustment",
            ga_Gtk.Adjustment(lower=1, upper=100, step_incr=1))
        self.quantity_renderer.set_property("editable", editable)
        self.quantity_renderer.connect("edited", self._on_edit, tree_model)
        self.quantity_renderer.connect("editing-started", self._setup_editor)

        super(QuantitySelectionColumn, self).__init__(column_title,
                                                      self.quantity_renderer,
                                                      text=self.quantity_store_idx)
        self.set_cell_data_func(self.quantity_renderer, self._update_cell_based_on_data)

        self.set_max_width(100)
        self.set_min_width(100)
Exemple #28
0
    def error_dialog(self, text):
        dlg = ga_Gtk.MessageDialog(None, 0, ga_Gtk.MessageType.ERROR,
                                   ga_Gtk.ButtonsType.OK, text)
        dlg.set_markup(text)
        dlg.set_skip_taskbar_hint(True)
        dlg.set_skip_pager_hint(True)
        dlg.set_position(ga_Gtk.WindowPosition.CENTER)

        def response_handler(obj, response_id):
            obj.destroy()

        dlg.connect('response', response_handler)
        dlg.set_modal(True)
        dlg.show()
Exemple #29
0
    def add_text_column(self, name, store_key, expand=False, markup=False):
        text_renderer = ga_Gtk.CellRendererText()

        if markup:
            column = ga_Gtk.TreeViewColumn(name,
                                           text_renderer,
                                           markup=self.store[store_key])
        else:
            column = ga_Gtk.TreeViewColumn(name,
                                           text_renderer,
                                           text=self.store[store_key])

        if expand:
            column.set_expand(True)
        else:
            column.add_attribute(text_renderer, 'xalign', self.store['align'])

        if 'background' in self.store:
            column.add_attribute(text_renderer, 'cell-background',
                                 self.store['background'])

        self.top_view.append_column(column)
        return column
Exemple #30
0
    def add_date_column(self, name, store_key, expand=False):
        date_renderer = CellRendererDate()
        column = ga_Gtk.TreeViewColumn(name,
                                       date_renderer,
                                       date=self.store[store_key])
        if expand:
            column.set_expand(True)
        else:
            column.add_attribute(date_renderer, 'xalign', self.store['align'])

        if 'background' in self.store:
            column.add_attribute(date_renderer, 'cell-background',
                                 self.store['background'])

        self.top_view.append_column(column)
        return column
    def on_registration_changed(self):
        # Show the All Subscriptions tab if registered, hide it otherwise:
        if self.registered() and self.notebook.get_n_pages() == 2:
            self.notebook.append_page(self.all_subs_tab.get_content(),
                    ga_Gtk.Label(self.all_subs_tab.get_label()))
        elif not self.registered() and self.notebook.get_n_pages() == 3:
            self.notebook.set_current_page(0)
            self.notebook.remove_page(2)

        # we've unregistered, clear pools from all subscriptions tab
        # so it's correct if we reshow it
        self.all_subs_tab.sub_details.clear()
        self.all_subs_tab.clear_pools()

        self.installed_tab.set_registered(self.registered())

        self._show_buttons()
        self._show_redemption_buttons()
Exemple #32
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())
Exemple #33
0
    def createScreen(self):
        """
        Create a new instance of gtk.VBox, pulling in child widgets from the
        glade file.
        """
        self.vbox = ga_Gtk.VBox()
        # self.vbox.pack_start(self.get_widget("register_widget"), False, False, 0)
        self.vbox.pack_start(self.register_widget.register_widget, False, False, 0)

        self.register_widget.connect('finished', self.on_finished)
        self.register_widget.connect('register-error', self.on_register_error)
        self.register_widget.connect('register-message', self.on_register_message)

        # In firstboot, we leverage the RHN setup proxy settings already
        # presented to the user, so hide the choose server screen's proxy
        # text and button. But, if we are standalone, show our versions.
        if not self.standalone:
            screen = self.register_widget._screens[registergui.CHOOSE_SERVER_PAGE]
            screen.proxy_frame.destroy()
Exemple #34
0
def linkify(msg):
    """
    Parse a string for any urls and wrap them in a hrefs, for use in a
    gtklabel.
    """
    # http (non whitespace or . or
    #  ? or () or - or / or ;
    url_regex = re.compile("""https?://[\w\.\?\(\)\-\/]*""")

    if ga_Gtk.check_version(MIN_GTK_MAJOR, MIN_GTK_MINOR, MIN_GTK_MICRO):
        return msg

    # dont linkify in firstboot
    if FIRSTBOOT:
        return msg

    def add_markup(mo):
        url = mo.group(0)
        return '<a href="%s">%s</a>' % (url, url)

    return url_regex.sub(add_markup, msg)
Exemple #35
0
def linkify(msg):
    """
    Parse a string for any urls and wrap them in a hrefs, for use in a
    gtklabel.
    """
    # http (non whitespace or . or
    #  ? or () or - or / or ;
    url_regex = re.compile("""https?://[\w\.\?\(\)\-\/]*""")

    if ga_Gtk.check_version(MIN_GTK_MAJOR, MIN_GTK_MINOR, MIN_GTK_MICRO):
        return msg

    # dont linkify in firstboot
    if FIRSTBOOT:
        return msg

    def add_markup(mo):
        url = mo.group(0)
        return '<a href="%s">%s</a>' % (url, url)

    return url_regex.sub(add_markup, msg)
Exemple #36
0
 def gtk_quit(self):
     ga_Gtk.main_quit()
 def gtk_quit(self):
     ga_Gtk.main_quit()