def __init__(self, path, domain):
     Gtk.Application.__init__(
         self,
         application_id="com.ubuntu.SoftwareProperties",
         flags=Gio.ApplicationFlags.FLAGS_NONE)
     setup_ui(self, path, domain)
     self.connect("activate", self.on_activate)
예제 #2
0
    def __init__(self, parent, datadir):
        """setup up the gtk dialog"""
        self.parent = parent

        setup_ui(self,
                 os.path.join(datadir, "gtkbuilder", "dialog-auth.ui"),
                 domain="software-properties")

        self.dialog = self.dialog_auth
        self.dialog.set_title('')
        self.dialog.set_deletable(False)
        self.dialog.set_transient_for(parent)

        self.button_continue.grab_focus()

        self.account = None
        self.dispose_on_new_account = False
        self.goa_client = Goa.Client.new_sync(None)

        self._setup_model()
        self._check_ui(select=False)

        # Be ready to other accounts
        self.goa_client.connect('account-added', self._account_added_cb)
        self.goa_client.connect('account-removed', self._account_removed_cb)
예제 #3
0
    def __init__(self, parent, sourceslist, datadir, distro):
        """
    Initialize the dialog that allows to add a new source entering the
    raw apt line
    """
        self.sourceslist = sourceslist
        self.parent = parent
        self.datadir = datadir
        # gtk stuff
        setup_ui(self,
                 os.path.join(datadir, "gtkbuilder", "dialog-add.ui"),
                 domain="software-properties")

        self.dialog = self.dialog_add_custom
        self.dialog.set_transient_for(self.parent)
        self.entry = self.entry_source_line
        self.button_add = self.button_add_source
        self.entry.connect("changed", self.check_line)
        # Create an example deb line from the currently used distro
        if distro:
            example = "%s %s %s %s" % (
                distro.binary_type, distro.source_template.base_uri,
                distro.codename, distro.source_template.components[0].name)
        else:
            example = "deb http://ftp.debian.org sarge main"
        # L10N: the example is of the format: deb http://ftp.debian.org sarge main
        msg = _("The APT line includes the type, location and components of a "
                "repository, for example  '%s'.") % ("<i>%s</i>" % example)
        self.label_example_line.set_label(msg)
    def __init__(self, parent, datadir):
        """setup up the gtk dialog"""
        self.parent = parent

        setup_ui(self,
                 os.path.join(datadir, "gtkbuilder", "dialog-auth.ui"),
                 domain="software-properties")
        self.label_title.set_max_width_chars(50)

        self.dialog = self.dialog_auth
        self.dialog.use_header_bar = True
        self.dialog.set_transient_for(parent)

        self.listboxrow_new_account.account = None

        self.account = None
        self.dispose_on_new_account = False
        self.goa_client = Goa.Client.new_sync(None)

        self.listbox_accounts.connect('row-activated',
                                      self._listbox_accounts_row_activated_cb)

        # Be ready to other accounts
        self.goa_client.connect('account-added', self._account_added_cb)
        self.goa_client.connect('account-removed', self._account_removed_cb)

        self._setup_listbox_accounts()
        self._check_ui()
예제 #5
0
 def __init__(self, datadir, parent):
   # gtk stuff
   setup_ui(self, os.path.join(datadir, "gtkbuilder", "dialog-cdrom-progress.ui"), domain="software-properties")
   
   self.dialog_cdrom_progress.show()
   self.dialog_cdrom_progress.set_transient_for(parent)
   self.parent = parent
   self.button_cdrom_close.set_sensitive(False)
예제 #6
0
    def __init__(self, parent, datadir):
        """setup up the gtk dialog"""
        self.parent = parent

        setup_ui(self,
                 os.path.join(datadir, "gtkbuilder",
                              "dialog-cache-outofdate.ui"),
                 domain="software-properties")
        self.dialog = self.dialog_cache_outofdate
        self.dialog.set_transient_for(parent)
예제 #7
0
    def __init__(self, parent, datadir):
        """setup up the gtk dialog"""
        self.parent = parent

        setup_ui(
            self,
            os.path.join(datadir, "gtkbuilder", "dialog-livepatch-error.ui"),
            domain="software-properties")

        self.dialog = self.messagedialog_livepatch
        self.dialog.set_transient_for(parent)
예제 #8
0
    def __init__(self, parent, sourceslist, source_entry, datadir):
        self.sourceslist = sourceslist
        self.source_entry = source_entry

        # gtk stuff
        setup_ui(self,
                 os.path.join(datadir, "gtkbuilder", "dialog-edit-source.ui"),
                 domain="software-properties")
        self.main = self.dialog_edit
        self.main.set_transient_for(parent)

        # type
        if source_entry.type == "deb":
            self.combobox_type.set_active(0)
        elif source_entry.type == "deb-src":
            self.combobox_type.set_active(1)
        else:
            print("Error, unknown source type: '%s'" % source_entry.type)

        # uri
        self.entry_uri.set_text(source_entry.uri)
        self.entry_dist.set_text(source_entry.dist)

        comps = ""
        for c in source_entry.comps:
            if len(comps) > 0:
                comps = comps + " " + c
            else:
                comps = c
        self.entry_comps.set_text(comps)

        self.entry_comment.set_text(source_entry.comment)

        # finally set the signal so that the check function is not tiggered
        # during initialisation
        for entry in (self.entry_uri, self.entry_dist, self.entry_comps,
                      self.entry_comment):
            entry.connect("changed", self.check_line)
    def __init__(self, parent, sourceslist, source_renderer, get_comparable,
                 datadir, file):
        print(file)
        self.parent = parent
        self.source_renderer = source_renderer
        self.sourceslist = sourceslist
        self.get_comparable = get_comparable
        self.file = self.format_uri(file)

        setup_ui(self,
                 os.path.join(datadir, "gtkbuilder",
                              "dialog-add-sources-list.ui"),
                 domain="software-properties")

        self.dialog = self.dialog_add_sources_list
        self.label = self.label_sources
        self.treeview = self.treeview_sources
        self.scrolled = self.scrolled_window
        self.image = self.image_sources_list

        self.dialog.realize()
        if self.parent != None:
            self.dialog.set_transient_for(parent)
        else:
            self.dialog.set_title(_("Add Software Channels"))
        self.dialog.get_window().set_functions(Gdk.WMFunction.MOVE)

        # Setup the treeview
        self.store = Gtk.ListStore(GObject.TYPE_STRING)
        self.treeview.set_model(self.store)
        cell = Gtk.CellRendererText()
        cell.set_property("xpad", 2)
        cell.set_property("ypad", 2)
        column = Gtk.TreeViewColumn("Software Channel", cell, markup=0)
        column.set_max_width(500)
        self.treeview.append_column(column)

        # Parse the source.list file
        try:
            self.new_sources = SingleSourcesList(self.file)
        except:
            self.error()
            return

        # show the found channels or an error message
        if len(self.new_sources.list) > 0:
            counter = 0

            for source in self.new_sources.list:
                if source.invalid or source.disabled:
                    continue
                self.new_sources.matcher.match(source)
            # sort the list
            self.new_sources.list.sort(key=self.get_comparable)

            for source in self.new_sources.list:
                if source.invalid or source.disabled:
                    continue
                counter = counter + 1
                line = self.source_renderer(source)
                self.store.append([line])
            if counter == 0:
                self.error()
                return

            header = gettext.ngettext(
                "Install software additionally or "
                "only from this source?", "Install software additionally or "
                "only from these sources?", counter)
            body = _(
                "You can either add the following sources or replace your "
                "current sources by them. Only install software from "
                "trusted sources.")
            self.label.set_markup("<big><b>%s</b></big>\n\n%s" %
                                  (header, body))
        else:
            self.error()
            return
예제 #10
0
  def __init__(self, parent, datadir, distro, custom_mirrors):
    """
    Initialize the dialog that allows to choose a custom or official mirror
    """
    def is_separator(model, iter, data=None):
        return model.get_value(iter, COLUMN_SEPARATOR)

    self.custom_mirrors = custom_mirrors
    self.country_info = CountryInformation()

    setup_ui(self, os.path.join(datadir, "gtkbuilder", "dialog-mirror.ui"), domain="software-properties")
    
    self.dialog = self.dialog_mirror
    self.dialog.set_transient_for(parent)
    
    self.dialog_test = self.dialog_mirror_test
    self.dialog_test.set_transient_for(self.dialog)
    self.distro = distro
    self.treeview = self.treeview_mirrors
    self.button_edit = self.button_mirror_edit
    self.button_remove = self.button_mirror_remove
    self.button_choose = self.button_mirror_choose
    self.button_cancel = self.button_test_cancel
    self.label_test = self.label_test_mirror
    self.progressbar_test = self.progressbar_test_mirror
    self.combobox = self.combobox_mirror_proto
    self.progress = self.progressbar_test_mirror
    self.label_action = self.label_test_mirror

    # store each proto and its dir
    model_proto = Gtk.ListStore(GObject.TYPE_STRING,
                                GObject.TYPE_STRING)
    self.combobox.set_model(model_proto)
    cr = Gtk.CellRendererText()
    self.combobox.pack_start(cr, True)
    self.combobox.add_attribute(cr, "markup", 0)

    self.model = Gtk.TreeStore(GObject.TYPE_STRING,  # COLUMN_URI
                               GObject.TYPE_BOOLEAN, # COLUMN_SEPARATOR
                               GObject.TYPE_BOOLEAN, # COLUMN_CUSTOM
                               GObject.TYPE_PYOBJECT)# COLUMN_MIRROR
    self.treeview.set_row_separator_func(is_separator, None)
    self.model_sort = Gtk.TreeModelSort(model=self.model)

    self.distro = distro

    self.treeview.set_model(self.model_sort)
    # the cell renderer for the mirror uri
    self.renderer_mirror = Gtk.CellRendererText()
    self.renderer_mirror.connect('edited', 
                                 self.on_edited_custom_mirror, 
                                 self.model)
    # the visible column that holds the mirror uris
    self.column_mirror = Gtk.TreeViewColumn("URI", 
                                            self.renderer_mirror, 
                                            text=COLUMN_URI)
    self.treeview.append_column(self.column_mirror)

    # used to find the corresponding iter of a location
    map_loc = {}
    patriot = None
    model = self.treeview.get_model().get_model()
    # at first add all custom mirrors and a separator
    if len(self.custom_mirrors) > 0:
        for mirror in self.custom_mirrors:
            model.append(None, [mirror, False, True, None])
            self.column_mirror.add_attribute(self.renderer_mirror, 
                                             "editable", 
                                             COLUMN_CUSTOM)
        model.append(None, [None, True, False, None])
    # secondly add all official mirrors
    for hostname in self.distro.source_template.mirror_set.keys():
        mirror = self.distro.source_template.mirror_set[hostname]
        if mirror.location in map_loc:
            model.append(map_loc[mirror.location],
                         [hostname, False, False, mirror])
        elif mirror.location != None:
            parent = model.append(None, 
                                  [self.country_info.get_country_name(mirror.location), False, False, None])
            if mirror.location == self.country_info.code and patriot == None:
                patriot = parent
            model.append(parent, [hostname, False, False, mirror]),
            map_loc[mirror.location] = parent
        else:
            model.append(None, [hostname, False, False, mirror])
    # Scroll to the local mirror set
    if patriot != None:
        path_sort = self.model_sort.get_path(self.model_sort.convert_child_iter_to_iter(patriot)[1])
        self.treeview.expand_row(path_sort, False)
        self.treeview.set_cursor(path_sort, None, False)
        self.treeview.scroll_to_cell(path_sort, use_align=True, row_align=0.5)
    # set the sort function, this will also trigger a sort
    self.model_sort.set_default_sort_func(sort_mirrors, None)
예제 #11
0
 def __init__(self, path, domain):
     Gtk.Application.__init__(
         self, application_id="com.ubuntu.SoftwareProperties", flags=Gio.ApplicationFlags.FLAGS_NONE
     )
     setup_ui(self, path, domain)
     self.connect("activate", self.on_activate)