Пример #1
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.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()
Пример #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.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()
Пример #3
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.new(PLUGVIEWS_GSCHEMA)
     single = gsettings.get_boolean('layout-single')
     self._initViewModel(single)
     self._setupActions()
Пример #4
0
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
Пример #5
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)
Пример #6
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.new(PLUGVIEWS_GSCHEMA)
     single = gsettings.get_boolean("layout-single")
     self._initViewModel(single)
     self._setupActions()
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()
Пример #8
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)
Пример #9
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
Пример #10
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
Пример #11
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.new(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)
Пример #12
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.new(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)
Пример #13
0
    def __init__(self, node):
        '''
    Initialize the window.
    
    @param node: Main application's node.
    @type node: L{Node}
    '''
        gtk.Window.__init__(self)
        self.set_icon_name('accerciser')
        self.set_title(_('Accerciser Accessibility Explorer'))
        self.connect('key-press-event', self._onKeyPress)
        node.connect('blink-done', self._onBlinkDone)
        self.gsettings = GSettings.new(GSCHEMA)
        width = self.gsettings.get_int('window-width') or 640
        height = self.gsettings.get_int('window-height') or 640
        self.set_default_size(width, height)
        self.add_accel_group(ui_manager.uimanager.get_accel_group())
        # Populate window
        self._populateUI(node)

        selection = self.treeview.get_selection()
        selection.connect('changed', self._onSelectionChanged)
Пример #14
0
    def __init__(self, node):
        """
    Initialize the window.
    
    @param node: Main application's node.
    @type node: L{Node}
    """
        gtk.Window.__init__(self)
        self.set_icon_name("accerciser")
        self.set_title(_("Accerciser Accessibility Explorer"))
        self.connect("key-press-event", self._onKeyPress)
        node.connect("blink-done", self._onBlinkDone)
        self.gsettings = GSettings.new(GSCHEMA)
        width = self.gsettings.get_int("window-width") or 640
        height = self.gsettings.get_int("window-height") or 640
        self.set_default_size(width, height)
        self.add_accel_group(ui_manager.uimanager.get_accel_group())
        # Populate window
        self._populateUI(node)

        selection = self.treeview.get_selection()
        selection.connect("changed", self._onSelectionChanged)
Пример #15
0
 def __init__(self):
   gtk.Alignment.__init__(self)
   self.set_padding(12, 12, 18, 12)
   self.gsettings = GSettings.new('org.a11y.Accerciser')
   self._buildUI()
Пример #16
0
from gi.repository.Gtk import accelerator_parse
from gi.repository.Gio import Settings

# Check if gschema installed
if 'org.gnome.gedit.plugins.imitation' not in Settings.list_schemas():

    class ImitationPluginConfigError(Exception):
        pass

    raise ImitationPluginConfigError('Imitation gschema not installed')

# Functions for getting config values
s = Settings.new('org.gnome.gedit.plugins.imitation').get_string


def p(accel_str):
    """ Parse accelerator string and warn of invalid formats """
    # Always results in lowercase keyvals (accounted for when matching)
    accel = accelerator_parse(accel_str)
    if accel[0] == 0:
        print 'Imitation plugin: invalid accelerator string "' + accel_str + '"'
    return accel


# configurable (restart gedit to apply changes)
MARK_TOGGLE = p(s('mark-toggle'))
MARK_UP = p(s('mark-up'))
MARK_DOWN = p(s('mark-down'))
MARK_ALT_UP = p(s('mark-alt-up'))
MARK_ALT_DOWN = p(s('mark-alt-down'))
Пример #17
0
from gi.repository.Gtk import accelerator_parse
from gi.repository.Gio import Settings


# Check if gschema installed
if 'org.gnome.gedit.plugins.imitation' not in Settings.list_schemas():
    class ImitationPluginConfigError(Exception):
        pass
    raise ImitationPluginConfigError('Imitation gschema not installed')


# Functions for getting config values
s = Settings.new('org.gnome.gedit.plugins.imitation').get_string

def p(accel_str):
    """ Parse accelerator string and warn of invalid formats """
    # Always results in lowercase keyvals (accounted for when matching)
    accel = accelerator_parse(accel_str)
    if accel[0] == 0:
        print('Imitation plugin: invalid accelerator string "' + accel_str + '"')
    return accel


# configurable (restart gedit to apply changes)
MARK_TOGGLE = p(s('mark-toggle'))
MARK_UP = p(s('mark-up'))
MARK_DOWN = p(s('mark-down'))
MARK_ALT_UP = p(s('mark-alt-up'))
MARK_ALT_DOWN = p(s('mark-alt-down'))
Пример #18
0
import gi

from gi.repository import Gtk as gtk
from gi.repository import Gdk as gdk
from gi.repository import GLib
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 ToolsAccessor, parseColorString

MAX_BLINKS = 6

gsettings = GSettings.new('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)
    
Пример #19
0
 def __init__(self):
     gtk.Alignment.__init__(self)
     self.set_padding(12, 12, 18, 12)
     self.gsettings = GSettings.new('org.a11y.Accerciser')
     self._buildUI()
Пример #20
0
import gi

from gi.repository import Gtk as gtk
from gi.repository import Gdk as gdk
from gi.repository import GLib
from gi.repository import GObject
from gi.repository.Gio import Settings as GSettings
from gi.repository import Rsvg as rsvg
import cairo
import pyatspi
import string
from .tools import ToolsAccessor, parseColorString

MAX_BLINKS = 6

gsettings = GSettings.new('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)