Пример #1
0
    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)
Пример #2
0
    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)
Пример #3
0
 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.new_with_path(NEWPLUGVIEWS_GSCHEMA, gspath)
     gsettings.set_int('width', self.get_allocated_width())
     gsettings.set_int('height', self.get_allocated_height())
Пример #4
0
 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.new_with_path(NEWPLUGVIEWS_GSCHEMA, gspath)
     gsettings.set_int("width", self.get_allocated_width())
     gsettings.set_int("height", self.get_allocated_height())
Пример #5
0
    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
Пример #6
0
    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.new_with_path(HOTKEYS_GSCHEMA, 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
            ])
Пример #7
0
    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
Пример #8
0
  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.new_with_path(HOTKEYS_GSCHEMA, 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])
Пример #9
0
    def __init__(self, view_name):
        '''
    Initialize a new plugin view window.
    
    @param view_name: The name of the view.
    @type view_name: string
    '''
        gtk.Window.__init__(self)
        self.plugin_view = PluginView(view_name)
        self.add(self.plugin_view)

        gspath = NEWPLUGVIEWS_PATH + view_name.lower().replace(' ', '-') + '/'
        gsettings = GSettings.new_with_path(NEWPLUGVIEWS_GSCHEMA, gspath)
        width = gsettings.get_int('width')
        height = gsettings.get_int('height')
        self.set_default_size(width, height)
        self.connect('key_press_event', self._onKeyPress)
        self.plugin_view.connect_after('page_removed', self._onPluginRemoved)
        self.set_title(view_name)
        self.set_position(gtk.WindowPosition.MOUSE)
        self.show_all()
        self.connect('size-allocate', self._onResize)
Пример #10
0
    def __init__(self, view_name):
        """
    Initialize a new plugin view window.
    
    @param view_name: The name of the view.
    @type view_name: string
    """
        gtk.Window.__init__(self)
        self.plugin_view = PluginView(view_name)
        self.add(self.plugin_view)

        gspath = NEWPLUGVIEWS_PATH + view_name.lower().replace(" ", "-") + "/"
        gsettings = GSettings.new_with_path(NEWPLUGVIEWS_GSCHEMA, gspath)
        width = gsettings.get_int("width")
        height = gsettings.get_int("height")
        self.set_default_size(width, height)
        self.connect("key_press_event", self._onKeyPress)
        self.plugin_view.connect_after("page_removed", self._onPluginRemoved)
        self.set_title(view_name)
        self.set_position(gtk.WindowPosition.MOUSE)
        self.show_all()
        self.connect("size-allocate", self._onResize)
Пример #11
0
  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.new_with_path(HOTKEYS_GSCHEMA, 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)
Пример #12
0
    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.new_with_path(HOTKEYS_GSCHEMA, 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)