Exemplo n.º 1
0
    def __init__(self):
        TweakModule.__init__(self, 'sourcecenter.ui')

        self.url = SOURCE_VERSION_URL
        set_label_for_stock_button(self.sync_button, _('_Sync'))

        self.cateview = CategoryView(os.path.join(SOURCE_ROOT, 'cates.json'))
        self.cate_selection = self.cateview.get_selection()
        self.cate_selection.connect('changed', self.on_category_changed)
        self.left_sw.add(self.cateview)

        self.sourceview = SourcesView()
        self.sourceview.connect('sourcechanged', self.on_source_changed)
        self.sourceview.selection.connect('changed', self.on_selection_changed)
        self.sourceview.set_sensitive(False)
        self.sourceview.set_rules_hint(True)
        self.right_sw.add(self.sourceview)

        self.expander = gtk.Expander(_('Details'))
        self.vbox1.pack_start(self.expander, False, False, 0)
        self.sourcedetail = SourceDetail()
        self.expander.set_sensitive(False)
        self.expander.add(self.sourcedetail)

        un_lock = PolkitButton()
        un_lock.connect('changed', self.on_polkit_action)
        self.hbox2.pack_end(un_lock, False, False, 0)
        self.hbox2.reorder_child(un_lock, 0)

        #TODO when server is ready, work on it again
#        try:
#            if os.getenv('LANG').startswith('zh_CN'):
#                if TweakSettings.get_use_mirror_ppa():
#                    gobject.idle_add(self.start_check_cn_ppa)
#                else:
#                    self.sourceview.unconver_ubuntu_cn_mirror()
#        except AttributeError:
#            pass

#        CONFIG.get_client().notify_add('/apps/ubuntu-tweak/use_mirror_ppa',
#                                       self.value_changed)

        self.update_timestamp()
        UPDATE_SETTING.set_value(False)
        UPDATE_SETTING.connect_notify(self.on_have_update, data=None)

        if TweakSettings.get_sync_notify():
            thread.start_new_thread(self.check_update, ())
        gobject.timeout_add(60000, self.update_timestamp)

        self.reparent(self.main_vbox)
Exemplo n.º 2
0
    def __init__(self):
        TweakModule.__init__(self, 'thirdsoft.ui')

        self.cateview = CategoryView(os.path.join(SOURCE_ROOT, 'cates.json'))
        self.cate_selection = self.cateview.get_selection()
        self.cate_selection.connect('changed', self.on_category_changed)
        self.left_sw.add(self.cateview)

        self.sourceview = SourcesView()
        self.sourceview.connect('sourcechanged', self.colleague_changed)
        self.sourceview.selection.connect('changed', self.on_selection_changed)
        self.sourceview.set_sensitive(False)
        self.sourceview.set_rules_hint(True)
        self.right_sw.add(self.sourceview)

        self.expander = gtk.Expander(_('Details'))
        self.vbox1.pack_start(self.expander, False, False, 0)
        self.sourcedetail = SourceDetail()
        self.expander.set_sensitive(False)
        self.expander.add(self.sourcedetail)

        un_lock = PolkitButton()
        un_lock.connect('changed', self.on_polkit_action)
        self.hbox2.pack_end(un_lock, False, False, 0)
        self.hbox2.reorder_child(un_lock, 0)


        #FIXME China mirror hack
        if os.getenv('LANG').startswith('zh_CN'):
            if TweakSettings.get_use_mirror_ppa():
                gobject.idle_add(self.start_check_cn_ppa)
            else:
                self.sourceview.unconver_ubuntu_cn_mirror()

        config.get_client().notify_add('/apps/ubuntu-tweak/use_mirror_ppa', self.value_changed)

        gobject.idle_add(self.on_idle_check)
Exemplo n.º 3
0
class SourceCenter(TweakModule):
    __title__  = _('Source Center')
    __desc__ = _('A collection of software sources to ensure your applications are always up-to-date.\n'
                 'Here you can add applications unavailable in the official repositories.\n'
                 'A list of available software sources will be obtained automatically from a remote server.\n'
                 'You can click the "Sync" button to manually check for updates')
    __icon__ = 'software-properties'
    __url__ = 'http://ubuntu-tweak.com/source/'
    __urltitle__ = _('Visit online Source Center')
    __category__ = 'application'

    def __init__(self):
        TweakModule.__init__(self, 'sourcecenter.ui')

        self.url = SOURCE_VERSION_URL
        set_label_for_stock_button(self.sync_button, _('_Sync'))

        self.sourceview = SourcesView()

        self.sourceview.set_status_active(TweakSettings.get_enable_new_item())
        self.sourceview.update_model()
        self.sourceview.connect('sourcechanged', self.on_source_changed)
        self.sourceview.selection.connect('changed', self.on_selection_changed)
        self.sourceview.set_sensitive(False)
        self.sourceview.set_rules_hint(True)
        self.source_selection = self.sourceview.get_selection()
        self.source_selection.connect('changed', self.on_source_selection)
        self.right_sw.add(self.sourceview)

        self.cateview = CategoryView(os.path.join(SOURCE_ROOT, 'cates.json'))
        self.cateview.set_status_from_view(self.sourceview)
        self.cateview.update_model()
        self.cate_selection = self.cateview.get_selection()
        self.cate_selection.connect('changed', self.on_category_changed)
        self.left_sw.add(self.cateview)

        self.expander = gtk.Expander(_('Details'))
        self.vbox1.pack_start(self.expander, False, False, 0)
        self.sourcedetail = SourceDetail()
        self.expander.set_sensitive(False)
        self.expander.add(self.sourcedetail)

        un_lock = PolkitButton()
        un_lock.connect('changed', self.on_polkit_action)
        self.hbox2.pack_end(un_lock, False, False, 0)
        self.hbox2.reorder_child(un_lock, 0)

        #TODO when server is ready, work on it again
#        try:
#            if os.getenv('LANG').startswith('zh_CN'):
#                if TweakSettings.get_use_mirror_ppa():
#                    gobject.idle_add(self.start_check_cn_ppa)
#                else:
#                    self.sourceview.unconver_ubuntu_cn_mirror()
#        except AttributeError:
#            pass

#        CONFIG.get_client().notify_add('/apps/ubuntu-tweak/use_mirror_ppa',
#                                       self.value_changed)

        self.update_timestamp()
        UPDATE_SETTING.set_value(False)
        UPDATE_SETTING.connect_notify(self.on_have_update, data=None)

        if TweakSettings.get_sync_notify():
            log.debug('Start check update')
            thread.start_new_thread(self.check_update, ())
        gobject.timeout_add(60000, self.update_timestamp)

        if self.check_source_upgradable() and UPGRADE_DICT:
            gobject.idle_add(self.upgrade_sources)

        self.reparent(self.main_vbox)

    def check_source_upgradable(self):
        log.debug("The check source string is: \"%s\"" % self.__get_disable_string())
        for source in SourcesList():
            if self.__get_disable_string() in source.str() and \
                    source.uri in UPGRADE_DICT and \
                    source.disabled:
                return True

        return False

    def __get_disable_string(self):
        APP="update-manager"
        DIR="/usr/share/locale"

        gettext.bindtextdomain(APP, DIR)
        gettext.textdomain(APP)

        #the "%s" is in front, some is the end, so just return the long one
        translated = gettext.gettext("disabled on upgrade to %s")
        a, b = translated.split('%s')
        return a.strip() or b.strip()

    def update_timestamp(self):
        self.time_label.set_text(_('Last synced:') + ' ' + utdata.get_last_synced(SOURCE_ROOT))
        return True

    def upgrade_sources(self):
        dialog = QuestionDialog(_('After a successful distribution upgrade, '
            'any third-party sources you use will be disabled by default.\n'
            'Would you like to re-enable any sources disabled by Update Manager?'),
            title=_('Upgrade Third Party Sources'))
        response = dialog.run()
        dialog.destroy()
        if response == gtk.RESPONSE_YES:
            proxy.upgrade_sources(self.__get_disable_string(), UPGRADE_DICT)
            if not self.check_source_upgradable():
                InfoDialog(_('Upgrade Successful!')).launch()
            else:
                ErrorDialog(_('Upgrade Failed!')).launch()
            self.emit('call', 'ubuntutweak.modules.sourceeditor', 'update_source_combo', {})
            self.update_thirdparty()

    def on_have_update(self, client, id, entry, data):
        if entry.get_value().get_bool():
            if self.check_update():
                dialog = QuestionDialog(_('New source data available, would you like to update?'))
                response = dialog.run()
                dialog.destroy()

                if response == gtk.RESPONSE_YES:
                    dialog = FetchingDialog(get_source_data_url(),
                                            self.get_toplevel())
                    dialog.connect('destroy', self.on_source_data_downloaded)
                    dialog.run()
                    dialog.destroy()

    def check_update(self):
        try:
            return utdata.check_update_function(self.url, SOURCE_ROOT, \
                                            UPDATE_SETTING, VERSION_SETTING, \
                                            auto=True)
        except Exception, error:
            print error
Exemplo n.º 4
0
class ThirdSoft(TweakModule):
    __title__  = _('Third-Party Software Sources')
    __desc__ = _('After every release of Ubuntu there comes a feature freeze.\nThis means only applications with bug-fixes get into the repository.\nBy using third-party DEB repositories, you can always keep up-to-date with the latest version.\nAfter adding these repositories, locate and install them using Add/Remove.')
    __icon__ = 'software-properties'
    __category__ = 'application'

    def __init__(self):
        TweakModule.__init__(self, 'thirdsoft.ui')

        self.cateview = CategoryView(os.path.join(SOURCE_ROOT, 'cates.json'))
        self.cate_selection = self.cateview.get_selection()
        self.cate_selection.connect('changed', self.on_category_changed)
        self.left_sw.add(self.cateview)

        self.sourceview = SourcesView()
        self.sourceview.connect('sourcechanged', self.colleague_changed)
        self.sourceview.selection.connect('changed', self.on_selection_changed)
        self.sourceview.set_sensitive(False)
        self.sourceview.set_rules_hint(True)
        self.right_sw.add(self.sourceview)

        self.expander = gtk.Expander(_('Details'))
        self.vbox1.pack_start(self.expander, False, False, 0)
        self.sourcedetail = SourceDetail()
        self.expander.set_sensitive(False)
        self.expander.add(self.sourcedetail)

        un_lock = PolkitButton()
        un_lock.connect('changed', self.on_polkit_action)
        self.hbox2.pack_end(un_lock, False, False, 0)
        self.hbox2.reorder_child(un_lock, 0)


        #FIXME China mirror hack
        if os.getenv('LANG').startswith('zh_CN'):
            if TweakSettings.get_use_mirror_ppa():
                gobject.idle_add(self.start_check_cn_ppa)
            else:
                self.sourceview.unconver_ubuntu_cn_mirror()

        config.get_client().notify_add('/apps/ubuntu-tweak/use_mirror_ppa', self.value_changed)

        gobject.idle_add(self.on_idle_check)

    def on_idle_check(self):
        gtk.gdk.threads_enter()
        if self.check_update():
            dialog = QuestionDialog(_('New sources data available, would you like to update?'))
            response = dialog.run()
            dialog.destroy()

            if response == gtk.RESPONSE_YES:
                dialog = FetchingDialog(SOURCE_URL, self.get_toplevel())
                dialog.connect('destroy', self.on_source_data_downloaded)
                dialog.run()
                dialog.destroy()

        gtk.gdk.threads_leave()

    def check_update(self):
        try:
            return check_update_function(SOURCE_VERSION_URL)
        except Exception, e:
            #TODO use logging
            print e
Exemplo n.º 5
0
    def __init__(self):
        TweakModule.__init__(self, 'sourcecenter.ui')

        self.url = SOURCE_VERSION_URL
        set_label_for_stock_button(self.sync_button, _('_Sync'))

        self.sourceview = SourcesView()

        self.sourceview.set_status_active(TweakSettings.get_enable_new_item())
        self.sourceview.update_model()
        self.sourceview.connect('sourcechanged', self.on_source_changed)
        self.sourceview.selection.connect('changed', self.on_selection_changed)
        self.sourceview.set_sensitive(False)
        self.sourceview.set_rules_hint(True)
        self.source_selection = self.sourceview.get_selection()
        self.source_selection.connect('changed', self.on_source_selection)
        self.right_sw.add(self.sourceview)

        self.cateview = CategoryView(os.path.join(SOURCE_ROOT, 'cates.json'))
        self.cateview.set_status_from_view(self.sourceview)
        self.cateview.update_model()
        self.cate_selection = self.cateview.get_selection()
        self.cate_selection.connect('changed', self.on_category_changed)
        self.left_sw.add(self.cateview)

        self.expander = gtk.Expander(_('Details'))
        self.vbox1.pack_start(self.expander, False, False, 0)
        self.sourcedetail = SourceDetail()
        self.expander.set_sensitive(False)
        self.expander.add(self.sourcedetail)

        un_lock = PolkitButton()
        un_lock.connect('changed', self.on_polkit_action)
        self.hbuttonbox1.pack_end(un_lock, False, False, 0)

        #TODO when server is ready, work on it again
        #        try:
        #            if os.getenv('LANG').startswith('zh_CN'):
        #                if TweakSettings.get_use_mirror_ppa():
        #                    gobject.idle_add(self.start_check_cn_ppa)
        #                else:
        #                    self.sourceview.unconver_ubuntu_cn_mirror()
        #        except AttributeError:
        #            pass

        #        CONFIG.get_client().notify_add('/apps/ubuntu-tweak/use_mirror_ppa',
        #                                       self.value_changed)

        self.update_timestamp()
        UPDATE_SETTING.set_value(False)
        UPDATE_SETTING.connect_notify(self.on_have_update, data=None)

        if TweakSettings.get_sync_notify():
            log.debug('Start check update')
            thread.start_new_thread(self.check_update, ())
        gobject.timeout_add(60000, self.update_timestamp)

        if self.check_source_upgradable() and UPGRADE_DICT:
            gobject.idle_add(self.upgrade_sources)

        self.reparent(self.main_vbox)
Exemplo n.º 6
0
class SourceCenter(TweakModule):
    __title__ = _('Source Center')
    __desc__ = _(
        'A collection of software sources to ensure your applications are always up-to-date.\n'
        'Here you can add applications unavailable in the official repositories.\n'
        'A list of available software sources will be obtained automatically from a remote server.\n'
        'You can click the "Sync" button to manually check for updates')
    __icon__ = 'software-properties'
    __url__ = 'http://ubuntu-tweak.com/source/'
    __urltitle__ = _('Visit online Source Center')
    __category__ = 'application'

    def __init__(self):
        TweakModule.__init__(self, 'sourcecenter.ui')

        self.url = SOURCE_VERSION_URL
        set_label_for_stock_button(self.sync_button, _('_Sync'))

        self.sourceview = SourcesView()

        self.sourceview.set_status_active(TweakSettings.get_enable_new_item())
        self.sourceview.update_model()
        self.sourceview.connect('sourcechanged', self.on_source_changed)
        self.sourceview.selection.connect('changed', self.on_selection_changed)
        self.sourceview.set_sensitive(False)
        self.sourceview.set_rules_hint(True)
        self.source_selection = self.sourceview.get_selection()
        self.source_selection.connect('changed', self.on_source_selection)
        self.right_sw.add(self.sourceview)

        self.cateview = CategoryView(os.path.join(SOURCE_ROOT, 'cates.json'))
        self.cateview.set_status_from_view(self.sourceview)
        self.cateview.update_model()
        self.cate_selection = self.cateview.get_selection()
        self.cate_selection.connect('changed', self.on_category_changed)
        self.left_sw.add(self.cateview)

        self.expander = gtk.Expander(_('Details'))
        self.vbox1.pack_start(self.expander, False, False, 0)
        self.sourcedetail = SourceDetail()
        self.expander.set_sensitive(False)
        self.expander.add(self.sourcedetail)

        un_lock = PolkitButton()
        un_lock.connect('changed', self.on_polkit_action)
        self.hbuttonbox1.pack_end(un_lock, False, False, 0)

        #TODO when server is ready, work on it again
        #        try:
        #            if os.getenv('LANG').startswith('zh_CN'):
        #                if TweakSettings.get_use_mirror_ppa():
        #                    gobject.idle_add(self.start_check_cn_ppa)
        #                else:
        #                    self.sourceview.unconver_ubuntu_cn_mirror()
        #        except AttributeError:
        #            pass

        #        CONFIG.get_client().notify_add('/apps/ubuntu-tweak/use_mirror_ppa',
        #                                       self.value_changed)

        self.update_timestamp()
        UPDATE_SETTING.set_value(False)
        UPDATE_SETTING.connect_notify(self.on_have_update, data=None)

        if TweakSettings.get_sync_notify():
            log.debug('Start check update')
            thread.start_new_thread(self.check_update, ())
        gobject.timeout_add(60000, self.update_timestamp)

        if self.check_source_upgradable() and UPGRADE_DICT:
            gobject.idle_add(self.upgrade_sources)

        self.reparent(self.main_vbox)

    def check_source_upgradable(self):
        log.debug("The check source string is: \"%s\"" %
                  self.__get_disable_string())
        for source in SourcesList():
            if self.__get_disable_string() in source.str() and \
                    source.uri in UPGRADE_DICT and \
                    source.disabled:
                return True

        return False

    def __get_disable_string(self):
        APP = "update-manager"
        DIR = "/usr/share/locale"

        gettext.bindtextdomain(APP, DIR)
        gettext.textdomain(APP)

        #the "%s" is in front, some is the end, so just return the long one
        translated = gettext.gettext("disabled on upgrade to %s")
        a, b = translated.split('%s')
        return a.strip() or b.strip()

    def update_timestamp(self):
        self.time_label.set_text(
            _('Last synced:') + ' ' + utdata.get_last_synced(SOURCE_ROOT))
        return True

    def upgrade_sources(self):
        dialog = QuestionDialog(_(
            'After a successful distribution upgrade, '
            'any third-party sources you use will be disabled by default.\n'
            'Would you like to re-enable any sources disabled by Update Manager?'
        ),
                                title=_('Upgrade Third Party Sources'))
        response = dialog.run()
        dialog.destroy()
        if response == gtk.RESPONSE_YES:
            proxy.upgrade_sources(self.__get_disable_string(), UPGRADE_DICT)
            if not self.check_source_upgradable():
                InfoDialog(_('Upgrade Successful!')).launch()
            else:
                ErrorDialog(_('Upgrade Failed!')).launch()
            self.emit('call', 'ubuntutweak.modules.sourceeditor',
                      'update_source_combo', {})
            self.update_thirdparty()

    def on_have_update(self, client, id, entry, data):
        if entry.get_value().get_bool():
            if self.check_update():
                dialog = QuestionDialog(
                    _('New source data available, would you like to update?'))
                response = dialog.run()
                dialog.destroy()

                if response == gtk.RESPONSE_YES:
                    dialog = FetchingDialog(get_source_data_url(),
                                            self.get_toplevel())
                    dialog.connect('destroy', self.on_source_data_downloaded)
                    dialog.run()
                    dialog.destroy()

    def check_update(self):
        try:
            return utdata.check_update_function(self.url, SOURCE_ROOT, \
                                            UPDATE_SETTING, VERSION_SETTING, \
                                            auto=True)
        except Exception, error:
            print error
Exemplo n.º 7
0
class SourceCenter(TweakModule):
    __title__  = _('Source Center')
    __desc__ = _('A source center to keep your applications always up-to-date.\n'
                 'You can also get the application which isn\'t in the official repository.\n'
                 'Data will be automatically synchronized with the remote side.\n'
                 'You can click the "Sync" button to check the update manually.')
    __icon__ = 'software-properties'
    __url__ = 'http://ubuntu-tweak.com/source/'
    __urltitle__ = _('Visit online Source Center')
    __category__ = 'application'

    def __init__(self):
        TweakModule.__init__(self, 'sourcecenter.ui')

        self.url = SOURCE_VERSION_URL
        set_label_for_stock_button(self.sync_button, _('_Sync'))

        self.cateview = CategoryView(os.path.join(SOURCE_ROOT, 'cates.json'))
        self.cate_selection = self.cateview.get_selection()
        self.cate_selection.connect('changed', self.on_category_changed)
        self.left_sw.add(self.cateview)

        self.sourceview = SourcesView()
        self.sourceview.connect('sourcechanged', self.on_source_changed)
        self.sourceview.selection.connect('changed', self.on_selection_changed)
        self.sourceview.set_sensitive(False)
        self.sourceview.set_rules_hint(True)
        self.right_sw.add(self.sourceview)

        self.expander = gtk.Expander(_('Details'))
        self.vbox1.pack_start(self.expander, False, False, 0)
        self.sourcedetail = SourceDetail()
        self.expander.set_sensitive(False)
        self.expander.add(self.sourcedetail)

        un_lock = PolkitButton()
        un_lock.connect('changed', self.on_polkit_action)
        self.hbox2.pack_end(un_lock, False, False, 0)
        self.hbox2.reorder_child(un_lock, 0)

        #TODO when server is ready, work on it again
#        try:
#            if os.getenv('LANG').startswith('zh_CN'):
#                if TweakSettings.get_use_mirror_ppa():
#                    gobject.idle_add(self.start_check_cn_ppa)
#                else:
#                    self.sourceview.unconver_ubuntu_cn_mirror()
#        except AttributeError:
#            pass

#        CONFIG.get_client().notify_add('/apps/ubuntu-tweak/use_mirror_ppa',
#                                       self.value_changed)

        self.update_timestamp()
        UPDATE_SETTING.set_value(False)
        UPDATE_SETTING.connect_notify(self.on_have_update, data=None)

        if TweakSettings.get_sync_notify():
            thread.start_new_thread(self.check_update, ())
        gobject.timeout_add(60000, self.update_timestamp)

        self.reparent(self.main_vbox)

    def update_timestamp(self):
        self.time_label.set_text(_('Last synced:') + ' ' + utdata.get_last_synced(SOURCE_ROOT))
        return True

    def on_have_update(self, client, id, entry, data):
        if entry.get_value().get_bool():
            if self.check_update():
                dialog = QuestionDialog(_('New sources data available, would you like to update?'))
                response = dialog.run()
                dialog.destroy()

                if response == gtk.RESPONSE_YES:
                    dialog = FetchingDialog(get_source_data_url(),
                                            self.get_toplevel())
                    dialog.connect('destroy', self.on_source_data_downloaded)
                    dialog.run()
                    dialog.destroy()

    def check_update(self):
        try:
            return utdata.check_update_function(self.url, SOURCE_ROOT, \
                                            UPDATE_SETTING, VERSION_SETTING, \
                                            auto=True)
        except Exception, error:
            print error