当前位置: 首页>>代码示例>>Python>>正文


Python Gio.Settings类代码示例

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


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

示例1: enableA11y

def enableA11y(enable=True):
    """
    Enables accessibility via DConf.
    """
    from gi.repository.Gio import Settings
    InterfaceSettings = Settings(schema=a11yDConfKey)
    InterfaceSettings.set_boolean('toolkit-accessibility', enable)
开发者ID:wangweiqing,项目名称:dogtail,代码行数:7,代码来源:utils.py

示例2: addKeyCombo

    def addKeyCombo(self, component, localized_component, description, callback, keypress, modifiers):
        """
    Adds the given key combination with the appropriate callbacks to 
    the L{HotkeyManager}. If an identical description with the identical 
    component already exists in the model, just reassign with the new callback.

    I{Note:} It is important that the component and description strings be
    unique.

    @param component: The component name, usually the plugin name, or "Core".
    @type component: string
    @param description: A description of the action performed during the given
    keycombo.
    @type description: string
    @param callback: The callback to call when the given key combination 
    is pressed.
    @type callback: callable
    @param keypress: The key symbol of the keystroke that performs given operation.
    @type keypress: long
    @param modifiers: The modifiers that must be depressed for function to 
    be perfomed.
    @type modifiers: int
    """
        component_desc_pairs = list(zip([row[COL_COMPONENT] for row in self], [row[COL_DESC] for row in self]))
        if (component, description) in component_desc_pairs:
            path = component_desc_pairs.index((component, description))
            self[path][COL_CALLBACK] = callback
        else:
            gspath = self._getComboGSettingsPath(component, description)
            gsettings = GSettings(schema=HOTKEYS_GSCHEMA, path=gspath)
            if gsettings.get_string("hotkey-combo"):
                final_keypress, final_modifiers = gtk.accelerator_parse(gsettings.get_string("hotkey-combo"))
            else:
                final_keypress, final_modifiers = keypress, modifiers
            self.append([component, description, callback, int(final_keypress), final_modifiers, localized_component])
开发者ID:javihernandez,项目名称:accerciser,代码行数:35,代码来源:hotkey_manager.py

示例3: __init__

 def __init__(self, *perm_views):
   '''
   Initialize view manager.
   
   @param perm_views: List of permanent views, at least one is required.
   @type perm_views: list of {PluginView}
   '''
   self._perm_views = perm_views
   gsettings = GSettings(schema=PLUGVIEWS_GSCHEMA)
   single = gsettings.get_boolean('layout-single')
   self._initViewModel(single)
   self._setupActions()
开发者ID:javihernandez,项目名称:accerciser,代码行数:12,代码来源:view.py

示例4: _setPluginLayouts

  def _setPluginLayouts(self, plugin_layouts):
    self.plugviews = GSettings(schema=PLUGVIEWS_GSCHEMA)
    self.plugviews.set_strv('top-panel-layout', plugin_layouts.pop('Top panel'))
    self.plugviews.set_strv('bottom-panel-layout', plugin_layouts.pop('Bottom panel'))

    for plugview in list(plugin_layouts.keys()):
      gspath = NEWPLUGVIEWS_PATH + plugview.lower().replace(' ', '-') + '/'
      newview = GSettings(schema=NEWPLUGVIEWS_GSCHEMA, path=gspath)
      newview.set_strv('layout', plugin_layouts[plugview])
      l = self.plugviews.get_strv('available-newviews')
      l.append(plugview)
      self.plugviews.set_strv('available-newviews', l)
开发者ID:javihernandez,项目名称:accerciser,代码行数:12,代码来源:view.py

示例5: _setPluginLayouts

    def _setPluginLayouts(self, plugin_layouts):
        self.plugviews = GSettings.new(PLUGVIEWS_GSCHEMA)
        self.plugviews.set_strv("top-panel-layout", plugin_layouts.pop("Top panel"))
        self.plugviews.set_strv("bottom-panel-layout", plugin_layouts.pop("Bottom panel"))

        for plugview in list(plugin_layouts.keys()):
            gspath = NEWPLUGVIEWS_PATH + plugview.lower().replace(" ", "-") + "/"
            newview = GSettings.new_with_path(NEWPLUGVIEWS_GSCHEMA, gspath)
            newview.set_strv("layout", plugin_layouts[plugview])
            l = self.plugviews.get_strv("available-newviews")
            l.append(plugview)
            self.plugviews.set_strv("available-newviews", l)
开发者ID:klown,项目名称:accerciser,代码行数:12,代码来源:view.py

示例6: isA11yEnabled

def isA11yEnabled():
    """
    Checks if accessibility is enabled via DConf.
    """
    from gi.repository.Gio import Settings
    InterfaceSettings = Settings(schema=a11yDConfKey)
    dconfEnabled = InterfaceSettings.get_boolean('toolkit-accessibility')
    if os.environ.get('GTK_MODULES', '').find('gail:atk-bridge') == -1:
        envEnabled = False
    else:
        envEnabled = True  # pragma: no cover
    return (dconfEnabled or envEnabled)
开发者ID:wangweiqing,项目名称:dogtail,代码行数:12,代码来源:utils.py

示例7: _onResize

 def _onResize(self, widget, allocation):
   '''
   Callback for window resizing. Used for persisting view sizes across
   sessions.
   
   @param widget: Window widget.
   @type widget: gtk.Widget
   @param allocation: The new allocation.
   @type allocation: gtk.gdk.Rectangle
   '''
   view_name = self.plugin_view.view_name
   gspath = NEWPLUGVIEWS_PATH + view_name.lower().replace(' ', '-') + '/'
   gsettings = GSettings(schema=NEWPLUGVIEWS_GSCHEMA, path=gspath)
   gsettings.set_int('width', self.get_allocated_width())
   gsettings.set_int('height', self.get_allocated_height())
开发者ID:javihernandez,项目名称:accerciser,代码行数:15,代码来源:view.py

示例8: isA11yEnabled

def isA11yEnabled():
    """
    Checks if accessibility is enabled via DConf.
    """
    from gi.repository.Gio import Settings
    try:
        InterfaceSettings = Settings(schema_id=a11yDConfKey)
    except TypeError: # if we have older glib that has deprecated param name
        InterfaceSettings = Settings(schema=a11yDConfKey)
    dconfEnabled = InterfaceSettings.get_boolean('toolkit-accessibility')
    if os.environ.get('GTK_MODULES', '').find('gail:atk-bridge') == -1:
        envEnabled = False
    else:
        envEnabled = True  # pragma: no cover
    return (dconfEnabled or envEnabled)
开发者ID:martiinsiimon,项目名称:dogtail,代码行数:15,代码来源:utils.py

示例9: __init__

 def __init__(self, node, hotkey_manager, *main_views):
   '''
   Initialize the plugin manager.
   
   @param node: The application's main node.
   @type node: L{Node}
   @param hotkey_manager: Application's hot key manager.
   @type hotkey_manager: L{HotkeyManager}
   @param main_views: List of permanent plugin views.
   @type main_views: list of {PluginView}
   '''
   gtk.ListStore.__init__(self,
                          object, # Plugin instance
                          object, # Plugin class
                          str) # Plugin path
   self.node = node
   self.hotkey_manager = hotkey_manager
   self.gsettings = GSettings.new(GSCHEMA)
   self.view_manager = ViewManager(*main_views)
   self.message_manager = MessageManager()
   self.message_manager.connect('plugin-reload-request', 
                                self._onPluginReloadRequest)
   self.message_manager.connect('module-reload-request', 
                                self._onModuleReloadRequest)
   message_tab = self.message_manager.getMessageTab()
   self.view_manager.addElement(message_tab)
   self._row_changed_handler = \
       self.connect('row_changed', self._onPluginRowChanged)
   self._loadPlugins()
开发者ID:GNOME,项目名称:accerciser,代码行数:29,代码来源:plugin_manager.py

示例10: _getPluginLayouts

  def _getPluginLayouts(self):
    plugin_layouts= {}
    self.plugviews = GSettings(schema=PLUGVIEWS_GSCHEMA)
    plugin_layouts['Top panel'] = self.plugviews.get_strv('top-panel-layout')
    plugin_layouts['Bottom panel'] = self.plugviews.get_strv('bottom-panel-layout')

    for plugview in self.plugviews.get_strv('available-newviews'):
      gspath = NEWPLUGVIEWS_PATH + plugview.lower().replace(' ', '-') + '/'
      newview = GSettings(schema=NEWPLUGVIEWS_GSCHEMA, path=gspath)
      layout = newview.get_strv('layout')
      if layout:
        plugin_layouts[plugview] = layout
      else:
        l = self.plugviews.get_strv('available-newviews')
        l.remove(plugview)
        self.plugviews.set_strv('available-newviews', l)
    return plugin_layouts
开发者ID:javihernandez,项目名称:accerciser,代码行数:17,代码来源:view.py

示例11: _getPluginLayouts

    def _getPluginLayouts(self):
        plugin_layouts = {}
        self.plugviews = GSettings.new(PLUGVIEWS_GSCHEMA)
        plugin_layouts["Top panel"] = self.plugviews.get_strv("top-panel-layout")
        plugin_layouts["Bottom panel"] = self.plugviews.get_strv("bottom-panel-layout")

        for plugview in self.plugviews.get_strv("available-newviews"):
            gspath = NEWPLUGVIEWS_PATH + plugview.lower().replace(" ", "-") + "/"
            newview = GSettings.new_with_path(NEWPLUGVIEWS_GSCHEMA, gspath)
            layout = newview.get_strv("layout")
            if layout:
                plugin_layouts[plugview] = layout
            else:
                l = self.plugviews.get_strv("available-newviews")
                l.remove(plugview)
                self.plugviews.set_strv("available-newviews", l)
        return plugin_layouts
开发者ID:klown,项目名称:accerciser,代码行数:17,代码来源:view.py

示例12: setSingleMode

 def setSingleMode(self, single):
   '''
   Toggle single mode on or off.
   
   @param single: True if we want single mode.
   @type single: boolean
   '''
   if isinstance(self._view_model, SingleViewModel) == single:
     return
   gsettings = GSettings(schema=PLUGVIEWS_GSCHEMA)
   gsettings.set_boolean('layout-single', single)
   plugins = self._view_model.getViewedPlugins()
   self._view_model.close()
   del self._view_model
   for plugin in plugins:
     if plugin.get_parent():
       plugin.get_parent().remove(plugin)
   self._initViewModel(single)
   for plugin in plugins:
     self._view_model.addElement(plugin)
开发者ID:javihernandez,项目名称:accerciser,代码行数:20,代码来源:view.py

示例13: _gsettings_set_as_background

def _gsettings_set_as_background(conf, file_location):
    """Sets the background path to the given path in gsettings"""
    gsettings = Settings.new(_GSETTINGS_SCHEMA)
    worked = gsettings.set_string(_GSETTINGS_KEY,"file://"+file_location)
    # I do not think i need this sync command.
    gsettings.sync()
    if worked:
        _log_succsess(conf,"gsetting")
    else:
        _log_failed(conf,"gsettings")
        raise _exceptions.Failed("could not set gsettings key")
    return
开发者ID:ohhdemgirls,项目名称:reddit_wallpaper,代码行数:12,代码来源:linux.py

示例14: _onComboChanged

    def _onComboChanged(self, model, path, iter):
        """
    Callback for row changes. Copies the changed key combos over to gsettings.

    @param model: The model that emitted the signal. Should be this class instance.
    @type model: L{gtk.TreeModel}
    @param path: The path of the row that has changed.
    @type path: tuple
    @param iter: The iter of the row that has changed.
    @type iter: L{gtk.TreeIter}
    """
        if not model[iter][COL_COMPONENT] or not model[iter][COL_DESC]:
            return

        gspath = self._getComboGSettingsPath(model[iter][COL_COMPONENT], model[iter][COL_DESC])
        gsettings = GSettings(schema=HOTKEYS_GSCHEMA, path=gspath)
        combo_name = gtk.accelerator_name(model[iter][COL_KEYPRESS], gdk.ModifierType(model[iter][COL_MOD]))

        key = gsettings.get_string("hotkey-combo")

        if key != combo_name and key != "/":
            gsettings.set_string("hotkey-combo", combo_name)
开发者ID:javihernandez,项目名称:accerciser,代码行数:22,代码来源:hotkey_manager.py

示例15: set_background

def set_background(image_path, check_exist=True):
    if check_exist:
        with open(image_path, 'rb') as f:
            f.read(1)

    path_to_file = path.abspath(image_path)
    if isinstance(path_to_file, unicode):
        path_to_file = path_to_file.encode('utf-8')
    uri = 'file://' + quote(path_to_file)

    bg_setting = Settings.new('org.gnome.desktop.background')
    bg_setting.set_string('picture-uri', uri)
    bg_setting.apply()
开发者ID:brisher777,项目名称:reddit_wallpapers,代码行数:13,代码来源:scrape_wallpapers.py


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