• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python gsettings.GSetting类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中ubuntutweak.settings.gsettings.GSetting的典型用法代码示例。如果您正苦于以下问题:Python GSetting类的具体用法?Python GSetting怎么用?Python GSetting使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了GSetting类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: Entry

class Entry(Gtk.Entry):
    def __init__(self, key=None, default=None, backend=GConf):
        gobject.GObject.__init__(self)

        if backend == GConf:
            self.setting = GconfSetting(key=key, default=default, type=str)
        else:
            self.setting = GSetting(key=key, default=default, type=str)

        string = self.setting.get_value()
        if string:
            self.set_text(str(string))
        else:
            self.set_text(_("Unset"))

        self.connect('activate', self.on_edit_finished_cb)

    def is_changed(self):
        return self.setting.get_value() != self.get_text()

    def get_gsetting(self):
        return self.setting

    def on_edit_finished_cb(self, widget):
        if self.get_text():
            print self.get_text()
            self.setting.set_value(self.get_text())
        else:
            self.setting.client.unset(self.setting.key)
            self.set_text(_("Unset"))
开发者ID:Thongor,项目名称:ubuntu-tweak,代码行数:30,代码来源:widgets.py


示例2: func_wrapper

    def func_wrapper(self, *args, **kwargs):
        launcher_setting = GSetting('com.canonical.Unity.Launcher.favorites')
        is_user_desktop_file = self.is_user_desktop_file()
        if not is_user_desktop_file:
            log.debug("Copy %s to user folder, then write it" % self.filename)
            shutil.copy(self.get_system_desktop_file(),
                        self.get_user_desktop_file())
            self.filename = self.get_user_desktop_file()
            self.parse(self.filename)

        func(self, *args, **kwargs)

        if not is_user_desktop_file:
            current_list = launcher_setting.get_value()
            try:
                index = current_list.index(self.get_system_desktop_file())
            except Exception, e:
                log.debug(e)
                index = current_list.index(os.path.basename(self.get_system_desktop_file()))

            current_list[index] = self.filename

            launcher_setting.set_value(current_list)
            log.debug("current_list: %s" % current_list)
            log.debug("Now set the current list")
开发者ID:0x7E,项目名称:ubuntu-tweak,代码行数:25,代码来源:quicklists.py


示例3: Entry

class Entry(Gtk.Entry):
    def __init__(self, key=None, default=None, backend='gconf'):
        GObject.GObject.__init__(self)

        if backend == 'gconf':
            self._setting = GconfSetting(key=key, default=default, type=str)
        else:
            self._setting = GSetting(key=key, default=default, type=str)

        string = self._setting.get_value()
        if string:
            self.set_text(str(string))

        text_buffer = self.get_buffer()
        text_buffer.connect('inserted-text', self.on_edit_finished_cb)
        text_buffer.connect('deleted-text', self.on_edit_finished_cb)

        self.connect('activate', self.on_edit_finished_cb)

    def is_changed(self):
        return self._setting.get_value() != self.get_text()

    def get_gsetting(self):
        return self._setting

    def on_edit_finished_cb(self, widget, *args):
        log.debug('Entry: on_edit_finished_cb: %s' % self.get_text())
        self._setting.set_value(self.get_text())
开发者ID:juzerdana,项目名称:ubuntu-tweak,代码行数:28,代码来源:widgets.py


示例4: QuickLists

class QuickLists(TweakModule):
    __title__ = _('QuickLists Editor')
    __desc__ = _('Unity Launcher QuickLists Editor')
    __icon__ = 'plugin-unityshell'
    __category__ = 'desktop'
    __desktop__ = ['ubuntu', 'ubuntu-2d']
    __utactive__ = True

    (DESKTOP_FILE,
     DESKTOP_ICON,
     DESKTOP_NAME,
     DESKTOP_ENTRY) = range(4)

    (ACTION_NAME,
     ACTION_FULLNAME,
     ACTION_EXEC,
     ACTION_ENABLED,
     ACTION_ENTRY) = range(5)

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

        self.launcher_setting = GSetting('com.canonical.Unity.Launcher.favorites')
        self.launcher_setting.connect_notify(self.update_launch_icon_model)

        self.action_view.get_selection().connect('changed', self.on_action_selection_changed)

        self.update_launch_icon_model()

        self.add_start(self.main_paned)

    @log_func(log)
    def update_launch_icon_model(self, *args):
        self.icon_model.clear()

        for desktop_file in self.launcher_setting.get_value():
            log.debug('Processing with "%s"...' % desktop_file)
            if desktop_file.startswith('/') and os.path.exists(desktop_file):
                path = desktop_file
            else:
                if os.path.exists('/usr/share/applications/%s' % desktop_file):
                    path = '/usr/share/applications/%s' % desktop_file
                else:
                    log.debug("No desktop file avaialbe in for %s" % desktop_file)
                    continue
            try:
                entry = NewDesktopEntry(path)
            except Exception, e:
                log_traceback(log)
                continue

            self.icon_model.append((path,\
                                    icon.get_from_name(entry.getIcon(), size=32),\
                                    entry.getName(),
                                    entry))

        first_iter = self.icon_model.get_iter_first()
        if first_iter:
            self.icon_view.get_selection().select_iter(first_iter)
开发者ID:c326277320,项目名称:ubuntu-tweak,代码行数:59,代码来源:quicklists.py


示例5: on_wallpaper_downloaded

    def on_wallpaper_downloaded(self, downloader):
        os.rename(downloader.get_downloaded_file(), self.wallpaper_path)

        wallpaper_setting = GSetting('org.gnome.desktop.background.picture-uri')
        wallpaper_setting.set_value(GLib.filename_to_uri(self.wallpaper_path, None))

        n = Notify.Notification.new(self.__title__, "Set wallpaper successfully!", 'ubuntu-tweak')
        n.show()
开发者ID:0xBADCA7,项目名称:ubuntu-tweak,代码行数:8,代码来源:lovewallpaperhd.py


示例6: __init__

    def __init__(self, key, min=0, max=0, step=0, backend='gconf'):
        if backend == 'gconf':
            self._setting = GconfSetting(key=key, type=int)
        else:
            self._setting = GSetting(key=key, type=int)

        adjust = Gtk.Adjustment(self._setting.get_value(), min, max, step)
        GObject.GObject.__init__(self, adjustment=adjust)
        self.connect('value-changed', self.on_value_changed)
开发者ID:juzerdana,项目名称:ubuntu-tweak,代码行数:9,代码来源:widgets.py


示例7: QuickLists

class QuickLists(TweakModule):
    __title__ = _("QuickLists Editor")
    __desc__ = _("Unity Launcher QuickLists Editor")
    __icon__ = "plugin-unityshell"
    __category__ = "desktop"
    __desktop__ = ["ubuntu", "ubuntu-2d"]
    __utactive__ = True

    (DESKTOP_FILE, DESKTOP_ICON, DESKTOP_NAME, DESKTOP_ENTRY) = range(4)

    (ACTION_NAME, ACTION_FULLNAME, ACTION_EXEC, ACTION_ENABLED, ACTION_ENTRY) = range(5)

    def __init__(self):
        TweakModule.__init__(self, "quicklists.ui")

        self.launcher_setting = GSetting("com.canonical.Unity.Launcher.favorites")
        self.launcher_setting.connect_notify(self.update_launch_icon_model)

        self.action_view.get_selection().connect("changed", self.on_action_selection_changed)

        self.update_launch_icon_model()

        self.add_start(self.main_paned)

    @log_func(log)
    def update_launch_icon_model(self, *args):
        self.icon_model.clear()

        for desktop_file in self.launcher_setting.get_value():
            log.debug('Processing with "%s"...' % desktop_file)
            if desktop_file.startswith("/") and os.path.exists(desktop_file):
                path = desktop_file
            else:
                user_path = os.path.join(NewDesktopEntry.user_folder, desktop_file)
                system_path = os.path.join(NewDesktopEntry.system_folder, desktop_file)

                if os.path.exists(user_path):
                    path = user_path
                elif os.path.exists(system_path):
                    path = system_path
                else:
                    log.debug("No desktop file avaialbe in for %s" % desktop_file)
                    continue
            try:
                entry = NewDesktopEntry(path)
            except Exception, e:
                log_traceback(log)
                continue

            self.icon_model.append((path, icon.get_from_name(entry.getIcon(), size=32), entry.getName(), entry))

        first_iter = self.icon_model.get_iter_first()
        if first_iter:
            self.icon_view.get_selection().select_iter(first_iter)
开发者ID:bruiselee,项目名称:ubuntu-tweak,代码行数:54,代码来源:quicklists.py


示例8: __init__

    def __init__(self, key, backend=GConf):
        gobject.GObject.__init__(self)

        if backend == GConf:
            self.setting = GconfSetting(key=key, type=bool)
        else:
            self.setting = GSetting(key=key, type=bool)

        self.set_property('image', 
                          Gtk.Image.new_from_stock(Gtk.STOCK_REVERT_TO_SAVED, Gtk.IconSize.MENU))

        self.set_tooltip_text(_('Reset setting to default value: %s') % self.get_default_value())
开发者ID:Thongor,项目名称:ubuntu-tweak,代码行数:12,代码来源:widgets.py


示例9: __init__

    def __init__(self, key=None, default=None, backend='gconf'):
        GObject.GObject.__init__(self)
        self.set_use_font(True)
        self.set_use_size(True)

        if backend == 'gconf':
            self._setting = GconfSetting(key=key, default=default, type=str)
        else:
            self._setting = GSetting(key=key, default=default, type=str)

        self.on_value_changed()

        self.connect('font-set', self.on_font_set)
        self._setting.connect_notify(self.on_value_changed)
开发者ID:nayanapriyankara,项目名称:ubuntu-tweak,代码行数:14,代码来源:widgets.py


示例10: ClipPage

class ClipPage(Gtk.VBox, GuiBuilder):
    __gsignals__ = {
        'load_module': (GObject.SignalFlags.RUN_FIRST,
                            None,
                            (GObject.TYPE_STRING,)),
        'load_feature': (GObject.SignalFlags.RUN_FIRST,
                            None,
                            (GObject.TYPE_STRING,))
    }

    def __init__(self):
        GObject.GObject.__init__(self)
        GuiBuilder.__init__(self, 'clippage.ui')

        self.recently_used_settings = GSetting('com.ubuntu-tweak.tweak.recently-used')
        self.clips_settings = GSetting('com.ubuntu-tweak.tweak.clips')

        self.load_cips()
        self.setup_recently_used()

        self.pack_start(self.get_object('hbox1'), True, True, 0)
        self.recently_used_settings.connect_notify(self.setup_recently_used)
        self.clips_settings.connect_notify(self.load_cips, True)

        self.show()

    def load_cips(self, a=None, b=None, do_remove=False):
        log.debug("Load clips, do_remove: %s" % do_remove)

        if do_remove:
            for child in self.clipvbox.get_children():
                log.debug("Remove clip: %s" % child)
                self.clipvbox.remove(child)

        clips = self.clips_settings.get_value()
        log.debug("All clips to load: %s" % clips)

        if clips and clips != ['']:
            loader = ModuleLoader('clips')

            for name in clips:
                try:
                    ClipClass = loader.get_module(name)
                    log.debug("Load clip: %s" % name)
                    clip = ClipClass()
                    clip.connect('load_module', self._on_module_button_clicked)
                    clip.connect('load_feature', self.on_clip_load_feature)
                    clip.show_all()
                    self.clipvbox.pack_start(clip, False, False, 0)
                except Exception, e:
                    log.error(traceback.print_exc())
                    if name in self.clips_settings.get_value():
                        new_list = self.clips_settings.get_value().remove(name)
                        self.clips_settings.set_value(new_list)
开发者ID:0tli4nitsa,项目名称:ubuntu-tweak,代码行数:54,代码来源:__init__.py


示例11: __init__

    def __init__(self):
        GObject.GObject.__init__(self)
        GuiBuilder.__init__(self, 'clippage.ui')

        self.recently_used_settings = GSetting('com.ubuntu-tweak.tweak.recently-used')
        self.clips_settings = GSetting('com.ubuntu-tweak.tweak.clips')

        self.load_cips()
        self.setup_recently_used()

        self.pack_start(self.get_object('hbox1'), True, True, 0)
        self.recently_used_settings.connect_notify(self.setup_recently_used)
        self.clips_settings.connect_notify(self.load_cips, True)

        self.show()
开发者ID:0tli4nitsa,项目名称:ubuntu-tweak,代码行数:15,代码来源:__init__.py


示例12: __init__

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

        self.launcher_setting = GSetting('com.canonical.Unity.Launcher.favorites')
        self.launcher_setting.connect_notify(self.update_launch_icon_model)

        self.action_view.get_selection().connect('changed', self.on_action_selection_changed)

        self.update_launch_icon_model()

        self.add_start(self.main_paned)
开发者ID:0x7E,项目名称:ubuntu-tweak,代码行数:11,代码来源:quicklists.py


示例13: __init__

    def __init__(self):
        gobject.GObject.__init__(self)
        GuiBuilder.__init__(self, 'clippage.ui')

        self.rencently_used_settings = GSetting('com.ubuntu-tweak.tweak.rencently-used')
        self.clips_settings = GSetting('com.ubuntu-tweak.tweak.clips')

        self._up_clips = []
        self._showed_clips = []
        self._down_clips = []

        self.load_cips()
        self.setup_rencently_used()

        self.pack_start(self.get_object('hbox1'), True, True, 0)
        self.connect('expose-event', self.on_expose_event)
        self.rencently_used_settings.connect_notify(self.setup_rencently_used)
        self.clips_settings.connect_notify(self.load_cips, True)

        self.show()
开发者ID:Thongor,项目名称:ubuntu-tweak,代码行数:20,代码来源:__init__.py


示例14: FontButton

class FontButton(Gtk.FontButton):
    def __init__(self, key=None, default=None, backend='gconf'):
        GObject.GObject.__init__(self)
        self.set_use_font(True)
        self.set_use_size(True)

        if backend == 'gconf':
            self._setting = GconfSetting(key=key, default=default, type=str)
        else:
            self._setting = GSetting(key=key, default=default, type=str)

        self.on_value_changed()

        self.connect('font-set', self.on_font_set)
        self._setting.connect_notify(self.on_value_changed)

    def on_font_set(self, widget):
        self._setting.set_value(self.get_font_name())

    def on_value_changed(self, *args):
        string = self._setting.get_value()

        if string:
            self.set_font_name(string)
开发者ID:nayanapriyankara,项目名称:ubuntu-tweak,代码行数:24,代码来源:widgets.py


示例15: ResetButton

class ResetButton(Gtk.Button):
    def __init__(self, key, backend='gconf'):
        GObject.GObject.__init__(self)

        if backend == 'gconf':
            self._setting = GconfSetting(key=key, type=bool)
        elif backend == 'compiz':
            self._setting = CompizSetting(key=key)
        else:
            self._setting = GSetting(key=key, type=bool)

        self.set_property('image', 
                          Gtk.Image.new_from_stock(Gtk.STOCK_REVERT_TO_SAVED, Gtk.IconSize.MENU))

        self.set_tooltip_text(_('Reset setting to default value: %s') % self.get_default_value())

    def get_default_value(self):
        return self._setting.get_schema_value()
开发者ID:juzerdana,项目名称:ubuntu-tweak,代码行数:18,代码来源:widgets.py


示例16: TestRencently

class TestRencently(unittest.TestCase):
    def setUp(self):
        self.window = UbuntuTweakWindow()
        self.window.loaded_modules = {}
        self.window.modules_index = {}
        self.window.navigation_dict = {'tweaks': [None, None]}
        self.setting = GSetting('com.ubuntu-tweak.tweak.rencently-used')

    def test_rencetly(self):
        self.setting.set_value([])
        self.assertEqual(self.setting.get_value(), [])

        self.window.load_module('Icon')
        self.assertEqual(self.setting.get_value(), ['Icon'])

        self.window.load_module('Nautilus')
        self.assertEqual(self.setting.get_value(), ['Nautilus', 'Icon'])

    def tearDown(self):
        self.setting.set_value([])
        del self.window
开发者ID:Thongor,项目名称:ubuntu-tweak,代码行数:21,代码来源:test_rencently.py


示例17: CheckButton

class CheckButton(Gtk.CheckButton):
    def __str__(self):
        return '<CheckButton with key: %s>' % self.setting.key

    def __init__(self, label=None, key=None,
                 default=None, tooltip=None, backend=GConf):
        gobject.GObject.__init__(self, label=label)
        if backend == GConf:
            self.setting = GconfSetting(key=key, default=default, type=bool)
        elif backend == Gio:
            self.setting = GSetting(key=key, default=default, type=bool)

        self.set_active(self.setting.get_value())
        if tooltip:
            self.set_tooltip_text(tooltip)

        self.setting.connect_notify(self.on_value_changed)
        self.connect('toggled', self.on_button_toggled)

    def on_value_changed(self, *args):
        self.set_active(self.setting.get_value())

    def on_button_toggled(self, widget):
        self.setting.set_value(self.get_active())
开发者ID:Thongor,项目名称:ubuntu-tweak,代码行数:24,代码来源:widgets.py


示例18: ClipPage

class ClipPage(Gtk.VBox, GuiBuilder):
    __gsignals__ = {
        'load_module': (gobject.SIGNAL_RUN_FIRST,
                            gobject.TYPE_NONE,
                            (gobject.TYPE_STRING,)),
        'load_feature': (gobject.SIGNAL_RUN_FIRST,
                            gobject.TYPE_NONE,
                            (gobject.TYPE_STRING,))
    }

    max_recently_used_size = 200

    (DIRECTION_UP, DIRECTION_DOWN) = ('UP', 'DOWN')
    direction = None

    def __init__(self):
        gobject.GObject.__init__(self)
        GuiBuilder.__init__(self, 'clippage.ui')

        self.rencently_used_settings = GSetting('com.ubuntu-tweak.tweak.rencently-used')
        self.clips_settings = GSetting('com.ubuntu-tweak.tweak.clips')

        self._up_clips = []
        self._showed_clips = []
        self._down_clips = []

        self.load_cips()
        self.setup_rencently_used()

        self.pack_start(self.get_object('hbox1'), True, True, 0)
        self.connect('expose-event', self.on_expose_event)
        self.rencently_used_settings.connect_notify(self.setup_rencently_used)
        self.clips_settings.connect_notify(self.load_cips, True)

        self.show()

    def on_expose_event(self, widget, event):
        frame_width = int(self.get_allocation().width / 4.5)

        if frame_width > self.max_recently_used_size:
            frame_width = self.max_recently_used_size
        self.rencently_frame.set_size_request(frame_width, -1)

        self.slide_clips()

    def load_cips(self, a=None, b=None, do_remove=False):
        log.debug("Load clips, do_remove: %s" % do_remove)

        if do_remove:
            for child in self.clipvbox.get_children():
                log.debug("Remove clip: %s" % child)
                self.clipvbox.remove(child)

        clips = self.clips_settings.get_value()

        if clips != ['']:
            loader = ModuleLoader('clips')

            self._up_clips = []
            self._showed_clips = []
            self._down_clips = []
            self.clipvbox.set_data('direction', 0)

            for name in clips:
                try:
                    ClipClass = loader.get_module(name)
                    log.debug("Load clip: %s" % name)
                    clip = ClipClass()
                    clip.connect('load_module', self._on_module_button_clicked)
                    clip.connect('load_feature', self.on_clip_load_feature)
                    clip.show()
                    self.clipvbox.pack_start(clip, False, False, 0)
                except Exception, e:
                    log.error(traceback.print_exc())
                    if name in self.clips_settings.get_value():
                        new_list = self.clips_settings.get_value().remove(name)
                        self.clips_settings.set_value(new_list)
开发者ID:Thongor,项目名称:ubuntu-tweak,代码行数:77,代码来源:__init__.py


示例19: setUp

 def setUp(self):
     self.window = UbuntuTweakWindow()
     self.window.loaded_modules = {}
     self.window.modules_index = {}
     self.window.navigation_dict = {'tweaks': [None, None]}
     self.setting = GSetting('com.ubuntu-tweak.tweak.rencently-used')
开发者ID:Thongor,项目名称:ubuntu-tweak,代码行数:6,代码来源:test_rencently.py


示例20: QuickLists

class QuickLists(TweakModule):
    __title__ = _('QuickLists Editor')
    __desc__ = _('Unity Launcher QuickLists Editor')
    __icon__ = 'plugin-unityshell'
    __category__ = 'desktop'
    __desktop__ = ['ubuntu', 'ubuntu-2d']
    __utactive__ = True

    (DESKTOP_FILE,
     DESKTOP_ICON,
     DESKTOP_NAME,
     DESKTOP_ENTRY) = range(4)

    (ACTION_NAME,
     ACTION_FULLNAME,
     ACTION_EXEC,
     ACTION_ENABLED,
     ACTION_ENTRY) = range(5)

    QUANTAL_SPECIFIC_ITEMS = {
        'unity://running-apps': _('Running Apps'),
        'unity://expo-icon': _('Workspace Switcher'),
        'unity://devices': _('Devices')
    }

    UNITY_WEBAPPS_ACTION_PATTERN = re.compile('^S\d{1}$')

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

        self.launcher_setting = GSetting('com.canonical.Unity.Launcher.favorites')
        self.launcher_setting.connect_notify(self.update_launch_icon_model)

        self.action_view.get_selection().connect('changed', self.on_action_selection_changed)

        self.update_launch_icon_model()

        self.add_start(self.main_paned)

    @log_func(log)
    def update_launch_icon_model(self, *args):
        self.icon_model.clear()

        for desktop_file in self.launcher_setting.get_value():
            log.debug('Processing with "%s"...' % desktop_file)
            if desktop_file.startswith('/') and os.path.exists(desktop_file):
                path = desktop_file
            else:
                if desktop_file.startswith('application://'):
                    desktop_file = desktop_file.split('application://')[1]
                    log.debug("Desktop file for quantal: %s" % desktop_file)

                user_path = os.path.join(NewDesktopEntry.user_folder, desktop_file)
                system_path = os.path.join(NewDesktopEntry.system_folder, desktop_file)

                if os.path.exists(user_path):
                    path = user_path
                elif os.path.exists(system_path):
                    path = system_path
                else:
                    path = desktop_file

            try:
                entry = NewDesktopEntry(path)

                self.icon_model.append((path,
                                        icon.get_from_name(entry.getIcon(), size=32),
                                        entry.getName(),
                                        entry))
            except Exception, e:
                log_traceback(log)
                if path in self.QUANTAL_SPECIFIC_ITEMS.keys():
                    self.icon_model.append((path,
                                            icon.get_from_name('plugin-unityshell', size=32),
                                            self.QUANTAL_SPECIFIC_ITEMS[path],
                                            None))

        first_iter = self.icon_model.get_iter_first()
        if first_iter:
            self.icon_view.get_selection().select_iter(first_iter)
开发者ID:0x7E,项目名称:ubuntu-tweak,代码行数:80,代码来源:quicklists.py



注:本文中的ubuntutweak.settings.gsettings.GSetting类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python icon.get_from_name函数代码示例发布时间:2022-05-27
下一篇:
Python settings.GSetting类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap