Exemplo n.º 1
0
    def set_enable(self, key, enable):
        # To make other module use the source enable feature, move the logical to here
        # So that other module can call
        gpg_key = self.get_key(key)
        url = self.get_url(key)
        distro = self.get_distro(key)
        comps = self.get_comps(key)
        comment = self.get_name(key)
        package = self.get_slug(key)

        if gpg_key:
            proxy.add_apt_key_from_content(gpg_key)

        if not comps and distro:
            distro = distro + '/'
        elif not comps and not distro:
            distro = './'

        if TweakSettings.get_separated_sources():
            result = proxy.set_separated_entry(url, distro, comps,
                                               comment, enable, package)
        else:
            result = proxy.set_entry(url, distro, comps, comment, enable)

        return str(result)
Exemplo n.º 2
0
    def set_enable(self, key, enable):
        # To make other module use the source enable feature, move the logical to here
        # So that other module can call
        gpg_key = self.get_key(key)
        url = self.get_url(key)
        distro = self.get_distro(key)
        comps = self.get_comps(key)
        comment = self.get_name(key)

        if ppa.is_ppa(url):
            file_name = '%s-%s' % (ppa.get_source_file_name(url), distro)
        else:
            file_name = self.get_slug(key)

        if gpg_key:
            proxy.add_apt_key_from_content(gpg_key)

        if not comps and distro:
            distro = distro + '/'
        elif not comps and not distro:
            distro = './'

        if TweakSettings.get_separated_sources():
            result = proxy.set_separated_entry(url, distro, comps, comment,
                                               enable, file_name)
        else:
            result = proxy.set_entry(url, distro, comps, comment, enable)

        return str(result)
Exemplo n.º 3
0
    def do_source_enable(self, iter, enable):
        """
        Do the really source enable or disable action by iter
        Only emmit signal when source is changed
        """
        model = self.modelfilter.get_model()

        url = model.get_value(iter, self.COLUMN_URL)
        icon = model.get_value(iter, self.COLUMN_LOGO)
        distro = model.get_value(iter, self.COLUMN_DISTRO)
        comment = model.get_value(iter, self.COLUMN_NAME)
        package = model.get_value(iter, self.COLUMN_SLUG)
        comps = model.get_value(iter, self.COLUMN_COMPS)
        key = model.get_value(iter, self.COLUMN_KEY)

        pre_status = self.get_sourcelist_status(url)

        if key:
            proxy.add_apt_key_from_content(key)

        if not comps and distro:
            distro = distro + "/"
        elif not comps and not distro:
            distro = "./"

        if TweakSettings.get_separated_sources():
            result = proxy.set_separated_entry(url, distro, comps, comment, enable, package)
        else:
            result = proxy.set_entry(url, distro, comps, comment, enable)

        if str(result) == "enabled":
            model.set(iter, self.COLUMN_ENABLED, True)
        else:
            model.set(iter, self.COLUMN_ENABLED, False)

        if pre_status != enable:
            self.emit("sourcechanged")

        if enable:
            notify = pynotify.Notification(
                _("New source has been enabled"),
                _("%s is enabled now, Please click the refresh button to update the application cache.") % comment,
            )
            notify.set_icon_from_pixbuf(icon)
            notify.set_hint_string("x-canonical-append", "")
            notify.show()
Exemplo n.º 4
0
    def do_source_enable(self, iter, enable):
        '''
        Do the really source enable or disable action by iter
        Only emmit signal when source is changed
        '''
        model = self.modelfilter.get_model()

        url = model.get_value(iter, self.COLUMN_URL)
        icon = model.get_value(iter, self.COLUMN_LOGO)
        distro = model.get_value(iter, self.COLUMN_DISTRO)
        comment = model.get_value(iter, self.COLUMN_NAME)
        package = model.get_value(iter, self.COLUMN_SLUG)
        comps = model.get_value(iter, self.COLUMN_COMPS)
        key = model.get_value(iter, self.COLUMN_KEY)

        pre_status = self.get_sourcelist_status(url)

        if key:
            proxy.add_apt_key_from_content(key)

        if not comps and distro:
            distro = distro + '/'
        elif not comps and not distro:
            distro = './'

        if TweakSettings.get_separated_sources():
            result = proxy.set_separated_entry(url, distro, comps,
                                               comment, enable, package)
        else:
            result = proxy.set_entry(url, distro, comps, comment, enable)

        if str(result) == 'enabled':
            model.set(iter, self.COLUMN_ENABLED, True)
        else:
            model.set(iter, self.COLUMN_ENABLED, False)

        if pre_status != enable:
            self.emit('sourcechanged')

        if enable:
            notify.update(_('New source has been enabled'),
                          _('%s is enabled now, Please click the refresh button to update the application cache.') % comment)
            notify.set_icon_from_pixbuf(icon)
            notify.show()
Exemplo n.º 5
0
    def __init__(self):
        gtk.Window.__init__(self)

        self.notify_func = None

        self.connect("destroy", self.destroy)
        self.set_title(APP)
        self.set_default_size(740, 480)
        self.set_position(gtk.WIN_POS_CENTER)
        self.set_border_width(10)

        vbox = gtk.VBox(False, 6)
        self.add(vbox)

        self.hpaned = gtk.HPaned()
        vbox.pack_start(self.hpaned, True, True, 0)

        swindow = gtk.ScrolledWindow()
        swindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        swindow.set_size_request(150, -1)
        self.hpaned.pack1(swindow)

        self.model = self.__create_model()
        self.update_model()
        self.treeview = gtk.TreeView(self.model)
        self.treeview.set_enable_tree_lines(True)

        self.__add_columns(self.treeview)
        selection = self.treeview.get_selection()
        selection.connect("changed", self.selection_cb)
        self.treeview.expand_all()

        swindow.add(self.treeview)

        self.notebook = self.create_notebook()
        self.moduletable = {'0': 0}
        self.modules = {}
        self.hpaned.pack2(self.notebook)

        hbox = gtk.HBox(False, 12)
        vbox.pack_start(hbox, False, False, 0)

        l_hbutton_box = gtk.HButtonBox()
        l_hbutton_box.set_spacing(12)
        hbox.pack_start(l_hbutton_box, False, False, 0)

        button = gtk.Button(stock=gtk.STOCK_ABOUT)
        button.connect("clicked", self.show_about)
        l_hbutton_box.pack_start(button, False, False, 0)

        d_button = gtk.Button(stock=gtk.STOCK_YES)
        set_label_for_stock_button(d_button, _('_Donate'))
        d_button.connect("clicked", self.on_d_clicked)
        l_hbutton_box.pack_start(d_button, False, False, 0)

        r_hbutton_box = gtk.HButtonBox()
        r_hbutton_box.set_spacing(12)
        hbox.pack_end(r_hbutton_box, False, False, 0)

        button = gtk.Button(stock=gtk.STOCK_PREFERENCES)
        button.connect('clicked', self.on_preferences_clicked)
        r_hbutton_box.pack_end(button, False, False, 0)

        button = gtk.Button(stock=gtk.STOCK_QUIT)
        button.connect("clicked", self.destroy)
        r_hbutton_box.pack_end(button, False, False, 0)

        self.get_gui_state()
        self.set_icon(icon.get_from_name('ubuntu-tweak', size=48))
        self.show_all()

        if TweakSettings.get_check_update():
            log.debug("get_check_update will start after 5 seconds")
            gobject.timeout_add(5000, self.on_timeout)

        launch = TweakSettings.get_default_launch()
        try:
            if launch and not launch.isdigit():
                self.__create_newpage(launch)
        except:
            pass

        # Only check if the distribution is supported
        if system.is_supported():
            gobject.idle_add(self.notify_stable_source)

        try:
            log.debug("Check the sources list to make it valid")
            valid, disabled_list = proxy.check_sources_is_valid(
                TweakSettings.get_separated_sources())
            if not valid:
                gobject.idle_add(self.notify_invalid_sources, disabled_list)
        except Exception, e:
            log.error(e)
Exemplo n.º 6
0
    def __init__(self):
        gtk.Window.__init__(self)

        self.notify_func = None

        self.connect("destroy", self.destroy)
        self.set_title(APP)
        self.set_default_size(740, 480)
        self.set_position(gtk.WIN_POS_CENTER)
        self.set_border_width(10)

        vbox = gtk.VBox(False, 6)
        self.add(vbox)

        self.hpaned = gtk.HPaned()
        vbox.pack_start(self.hpaned, True, True, 0)

        swindow = gtk.ScrolledWindow()
        swindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        swindow.set_size_request(150, -1)
        self.hpaned.pack1(swindow)

        self.model = self.__create_model()
        self.update_model()
        self.treeview = gtk.TreeView(self.model)
        self.treeview.set_enable_tree_lines(True)

        self.__add_columns(self.treeview)
        selection = self.treeview.get_selection()
        selection.connect("changed", self.selection_cb)
        self.treeview.expand_all()

        swindow.add(self.treeview)

        self.notebook = self.create_notebook()
        self.moduletable = {"0": 0}
        self.modules = {}
        self.hpaned.pack2(self.notebook)

        hbox = gtk.HBox(False, 12)
        vbox.pack_start(hbox, False, False, 0)

        l_hbutton_box = gtk.HButtonBox()
        l_hbutton_box.set_spacing(12)
        hbox.pack_start(l_hbutton_box, False, False, 0)

        button = gtk.Button(stock=gtk.STOCK_ABOUT)
        button.connect("clicked", self.show_about)
        l_hbutton_box.pack_start(button, False, False, 0)

        d_button = gtk.Button(stock=gtk.STOCK_YES)
        set_label_for_stock_button(d_button, _("_Donate"))
        d_button.connect("clicked", self.on_d_clicked)
        l_hbutton_box.pack_start(d_button, False, False, 0)

        r_hbutton_box = gtk.HButtonBox()
        r_hbutton_box.set_spacing(12)
        hbox.pack_end(r_hbutton_box, False, False, 0)

        button = gtk.Button(stock=gtk.STOCK_PREFERENCES)
        button.connect("clicked", self.on_preferences_clicked)
        r_hbutton_box.pack_end(button, False, False, 0)

        button = gtk.Button(stock=gtk.STOCK_QUIT)
        button.connect("clicked", self.destroy)
        r_hbutton_box.pack_end(button, False, False, 0)

        self.get_gui_state()
        self.set_icon(icon.get_from_name("ubuntu-tweak", size=48))
        self.show_all()

        if TweakSettings.get_check_update():
            log.debug("get_check_update will start after 5 seconds")
            gobject.timeout_add(5000, self.on_timeout)

        launch = TweakSettings.get_default_launch()
        try:
            if launch and not launch.isdigit():
                self.__create_newpage(launch)
        except:
            pass

        # Only check if the distribution is supported
        if system.is_supported():
            gobject.idle_add(self.notify_stable_source)

        try:
            log.debug("Check the sources list to make it valid")
            valid, disabled_list = proxy.check_sources_is_valid(TweakSettings.get_separated_sources())
            if not valid:
                gobject.idle_add(self.notify_invalid_sources, disabled_list)
        except Exception, e:
            log.error(e)