Example #1
0
    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 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)
Example #2
0
 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(schema=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()
Example #3
0
    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
Example #4
0
 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()
Example #5
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(schema=NEWPLUGVIEWS_GSCHEMA, path=gspath)
     gsettings.set_int('width', self.get_allocated_width())
     gsettings.set_int('height', self.get_allocated_height())
Example #6
0
 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)
Example #7
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 = 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
            ])
Example #8
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(schema=NEWPLUGVIEWS_GSCHEMA, path=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)
Example #9
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(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)
Example #10
0
 def __init__(self):
     gtk.Alignment.__init__(self)
     self.set_padding(12, 12, 18, 12)
     self.gsettings = GSettings(schema='org.a11y.Accerciser')
     self._buildUI()
Example #11
0
'''
import gi

from gi.repository import Gtk as gtk
from gi.repository import Gdk as gdk
from gi.repository import GObject
from gi.repository.Gio import Settings as GSettings
#from gi.repository import cairo
import cairo
import pyatspi
import string
from tools import Tools, parseColorString

MAX_BLINKS = 6

gsettings = GSettings(schema='org.a11y.Accerciser')
BORDER_COLOR, BORDER_ALPHA = parseColorString(
  gsettings.get_string('highlight-border'))

FILL_COLOR, FILL_ALPHA  = parseColorString(
  gsettings.get_string('highlight-fill'))

HL_DURATION = int(gsettings.get_double('highlight-duration')*1000)

class Bag(object):
  '''
  Bag class for converting a dicionary to an object with attributes.
  '''
  def __init__(self, **kwargs):
    self.__dict__.update(kwargs)
    
# Script prevents window close by unsetting and setting the dconf value
# It works, but has a downside - some delay

# Examples found here:
# https://python.hotexamples.com/examples/gi.repository.Gio/Settings/-/python-settings-class-examples.html

# Some Gio docs here:
# https://lazka.github.io/pgi-docs/#Gio-2.0/classes/Settings.html#Gio.Settings.reset

from gi.repository.Gio import Settings as GSettings
import time
KB_SCHEMA = 'org.gnome.Terminal.Legacy.Keybindings'
KB_PATH = '/org/gnome/terminal/legacy/keybindings/'

gsettings = GSettings(schema=KB_SCHEMA, path=KB_PATH)

# Reset close tab combination to default "<Control><Shift>w"
# https://lazka.github.io/pgi-docs/#Gio-2.0/classes/Settings.html#Gio.Settings.reset
gsettings.reset('close-tab')

# Send combination
keyboard.send_keys('<ctrl>+w')

# Alternative:
# keyboard.press_key('<ctrl>')
# keyboard.fake_keypress('w')
# keyboard.release_key('<ctrl>')

# Sleep 2 seconds for the system to process the event
time.sleep(2)