[accerciser] Fix for bug #625902 - Port to GSettings
- From: Javier HernÃndez AntÃnez <jhernandez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [accerciser] Fix for bug #625902 - Port to GSettings
- Date: Sun, 4 Sep 2011 03:29:10 +0000 (UTC)
commit 85fc11dc5503dfd826f27b55f680d8c1b16ca469
Author: Javier HernÃndez <jhernandez emergya es>
Date: Sun Sep 4 05:24:57 2011 +0200
Fix for bug #625902 - Port to GSettings
Makefile.am | 30 +-----
accerciser.schemas.in | 68 -------------
configure.in | 5 +-
org.a11y.Accerciser.gschema.xml | 94 ++++++++++++++++++
po/POTFILES.in | 1 -
src/lib/accerciser/accerciser.py | 3 -
src/lib/accerciser/accessible_treeview.py | 1 +
src/lib/accerciser/hotkey_manager.py | 61 ++++++++----
src/lib/accerciser/main_window.py | 24 ++---
src/lib/accerciser/node.py | 10 +-
src/lib/accerciser/plugin/plugin_manager.py | 25 ++++--
src/lib/accerciser/plugin/view.py | 141 +++++++++++++++------------
src/lib/accerciser/prefs_dialog.py | 28 +++---
src/lib/accerciser/tools.py | 57 -----------
14 files changed, 267 insertions(+), 281 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index c220e8b..84c6629 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -10,11 +10,6 @@ desktop_in_files=accerciser.desktop.in
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@
-schemasdir = $(GCONF_SCHEMA_FILE_DIR)
-schemas_in_files = accerciser.schemas.in
-schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)
- INTLTOOL_SCHEMAS_RULE@
-
EXTRA_DIST = \
$(desktop_in_files) \
$(desktop_DATA) \
@@ -22,8 +17,7 @@ EXTRA_DIST = \
accerciser.spec \
gnome-doc-utils.make \
$(INTLTOOL) \
- $(schemas_in_files) \
- $(schemas_DATA)
+ org.a11y.Accerciser.gschema.xml
DISTCHECK_CONFIGURE_FLAGS = \
--disable-scrollkeeper \
@@ -34,22 +28,10 @@ DISTCLEANFILES = \
intltool-extract \
intltool-merge \
intltool-update \
- gnome-doc-utils.make \
- $(schemas_DATA)
+ gnome-doc-utils.make
-if GCONF_SCHEMAS_INSTALL
-install-data-local:
- if test -z "$(DESTDIR)" ; then \
- for p in $(schemas_DATA) ; do \
- GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(srcdir)/$$p ; \
- done \
- fi
-uninstall-local:
- for p in $(schemas_DATA) ; do \
- GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-uninstall-rule $(srcdir)/$$p ; \
- done
-else
-install-data-local:
-uninstall-local:
-endif
+gsettings_SCHEMAS = \
+ org.a11y.Accerciser.gschema.xml
+
+ GSETTINGS_RULES@
diff --git a/configure.in b/configure.in
index 6fb2d9b..bc90024 100644
--- a/configure.in
+++ b/configure.in
@@ -12,6 +12,7 @@ dnl == requeriments ==
GTK_REQUIRED=3.1.13
PYGOBJECT_REQUIRED=2.90.3
ATSPI_REQUIRED=2.1.5
+GLIB_GSETTINGS
dnl == check for requeriments ==
PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= GTK_REQUIRED])
@@ -27,10 +28,6 @@ AM_GLIB_GNU_GETTEXT
dnl == intltool check ==
IT_PROG_INTLTOOL([0.35.0])
-dnl == gconf config ==
-AC_PATH_PROG(GCONFTOOL, gconftool-2)
-AM_GCONF_SOURCE_2
-
dnl == generate makefiles ==
AC_OUTPUT([
Makefile
diff --git a/org.a11y.Accerciser.gschema.xml b/org.a11y.Accerciser.gschema.xml
new file mode 100644
index 0000000..1368e96
--- /dev/null
+++ b/org.a11y.Accerciser.gschema.xml
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schemalist>
+ <schema path="/apps/accerciser/" id="org.a11y.Accerciser" gettext-domain="accerciser">
+ <key type="as" name="disabled-plugins">
+ <default>[]</default>
+ <summary>A list of plugins that are disabled by default</summary>
+ <description>A list of plugins that are disabled by default.</description>
+ </key>
+ <key type="d" name="highlight-duration">
+ <default>0.5</default>
+ <summary>Highlight duration</summary>
+ <description>The duration of the highlight box when selecting accessible nodes.</description>
+ </key>
+ <key type="s" name="highlight-fill">
+ <default>"#ff00006f"</default>
+ <summary>Highlight fill color</summary>
+ <description>The color and opacity of the highlight fill.</description>
+ </key>
+ <key type="s" name="highlight-border">
+ <default>"#ff0000ff"</default>
+ <summary>Highlight border color</summary>
+ <description>The color and opacity of the highlight border.</description>
+ </key>
+ <key type="i" name="hpaned">
+ <default>250</default>
+ <summary>hpaned value</summary>
+ <description>The hpaned value for the main window.</description>
+ </key>
+ <key type="i" name="vpaned">
+ <default>350</default>
+ <summary>vpaned value</summary>
+ <description>The vpaned value for the main window.</description>
+ </key>
+ <key type="i" name="window-height">
+ <default>600</default>
+ <summary>Default window height</summary>
+ <description>The window height value.</description>
+ </key>
+ <key type="i" name="window-width">
+ <default>800</default>
+ <summary>Default window width</summary>
+ <description>The window width value.</description>
+ </key>
+ <child schema="org.a11y.Accerciser.pluginviews" name="pluginviews"/>
+ <child schema="org.a11y.Accerciser.newpluginviews" name="newpluginviews"/>
+ <child schema="org.a11y.Accerciser.hotkeys" name="hotkeys"/>
+ </schema>
+ <schema path="/apps/accerciser/pluginviews/" id="org.a11y.Accerciser.pluginviews" gettext-domain="accerciser">
+ <key type="as" name="bottom-panel-layout">
+ <default>["IPython Console"]</default>
+ <summary>The layout for the bottom panel</summary>
+ <description>The layout for the bottom panel pluginview.</description>
+ </key>
+ <key type="as" name="top-panel-layout">
+ <default>["Interface Viewer", "API Browser", "Event Monitor", "Script Recorder"]</default>
+ <summary>The layout for the top panel</summary>
+ <description>The layout for the top panel pluginview.</description>
+ </key>
+ <key type="b" name="layout-single">
+ <default>false</default>
+ <summary>Single layout view</summary>
+ <description>View plugins in a single layout.</description>
+ </key>
+ <key type="as" name="available-newviews">
+ <default>[]</default>
+ <summary>Available new pluginviews</summary>
+ <description>This list contains all the new available pluginviews</description>
+ </key>
+ </schema>
+ <schema id="org.a11y.Accerciser.newpluginviews" gettext-domain="accerciser">
+ <key type="as" name="layout">
+ <default>[]</default>
+ <summary>The pluginview layout</summary>
+ <description>The default plugin layout for the top panel.</description>
+ </key>
+ <key type="i" name="height">
+ <default>480</default>
+ <summary>Window height</summary>
+ <description>Window height value.</description>
+ </key>
+ <key type="i" name="width">
+ <default>480</default>
+ <summary>Window width</summary>
+ <description>Window width value.</description>
+ </key>
+ </schema>
+ <schema id="org.a11y.Accerciser.hotkeys" gettext-domain="accerciser">
+ <key type="s" name="hotkey-combo">
+ <default>""</default>
+ <summary>Hotkey combination</summary>
+ <description>Hotkey combination for related action.</description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 09287b4..d350049 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,6 +1,5 @@
[encoding: UTF-8]
accerciser.desktop.in.in
-accerciser.schemas.in
plugins/api_view.py
plugins/console.py
[type: gettext/glade]plugins/event_monitor.ui
diff --git a/src/lib/accerciser/accerciser.py b/src/lib/accerciser/accerciser.py
index 9a5443e..7ab5065 100644
--- a/src/lib/accerciser/accerciser.py
+++ b/src/lib/accerciser/accerciser.py
@@ -17,7 +17,6 @@ is available at U{http://www.opensource.org/licenses/bsd-license.php}
from gi.repository import Gtk as gtk
from gi.repository import Gdk as gdk
from gi.repository import Wnck as wnck
-from gi.repository import GConf as gconf
from gi.repository import GObject
from gi.repository import Atk as atk
from gi.repository.Gio import Settings
@@ -40,8 +39,6 @@ from prefs_dialog import AccerciserPreferencesDialog
from main_window import AccerciserMainWindow
import ui_manager
-GCONF_GENERAL = '/apps/accerciser/general'
-
class Main(Tools):
'''
Class for the main accerciser window.
diff --git a/src/lib/accerciser/accessible_treeview.py b/src/lib/accerciser/accessible_treeview.py
index a6b247b..793de2f 100644
--- a/src/lib/accerciser/accessible_treeview.py
+++ b/src/lib/accerciser/accessible_treeview.py
@@ -517,6 +517,7 @@ class AccessibleTreeView(gtk.TreeView, Tools):
@type: gtk.Action
'''
path = self.get_cursor()[0]
+ if path == None: return
is_expanded = self.row_expanded(path)
self._refreshChildren(self.model.get_iter(path))
if is_expanded:
diff --git a/src/lib/accerciser/hotkey_manager.py b/src/lib/accerciser/hotkey_manager.py
index 8caf721..332d2b0 100644
--- a/src/lib/accerciser/hotkey_manager.py
+++ b/src/lib/accerciser/hotkey_manager.py
@@ -12,12 +12,13 @@ is available at U{http://www.opensource.org/licenses/bsd-license.php}
'''
from gi.repository import Gtk as gtk
from gi.repository import Gdk as gdk
-from gi.repository import GConf as gconf
+from gi.repository.Gio import Settings as GSettings
from i18n import _
import pyatspi
-GCONF_HOTKEYS = '/apps/accerciser/global_hotkeys'
+HOTKEYS_GSCHEMA = 'org.a11y.Accerciser.hotkeys'
+HOTKEYS_BASEPATH = '/apps/accerciser/hotkeys/'
COL_COMPONENT = 0
COL_DESC = 1
@@ -55,7 +56,6 @@ class HotkeyManager(gtk.ListStore):
'''
gtk.ListStore.__init__(self, str, str, object, int, int, str)
self.connect('row-changed', self._onComboChanged)
- self.gconf_client = gconf.Client.get_default()
masks = [mask for mask in pyatspi.allModifiers()]
pyatspi.Registry.registerKeystrokeListener(
@@ -129,10 +129,11 @@ class HotkeyManager(gtk.ListStore):
path = component_desc_pairs.index((component, description))
self[path][COL_CALLBACK] = callback
else:
- combo_gconf_key = self._getComboGConfKey(component, description)
- if self.gconf_client.get(combo_gconf_key):
+ 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(
- self.gconf_client.get_string(combo_gconf_key))
+ gsettings.get_string('hotkey-combo'))
else:
final_keypress, final_modifiers = keypress, modifiers
self.append([component, description, callback,
@@ -161,12 +162,12 @@ class HotkeyManager(gtk.ListStore):
while iter:
if self[iter][COL_CALLBACK] == callback:
# We never really remove it, just set the callback to None
- self[iter][COL_CALLBACK] = None
+ self[iter][COL_CALLBACK] = ''
iter = self.iter_next(iter)
def _onComboChanged(self, model, path, iter):
'''
- Callback for row changes. Copies the changed key combos over to gconf.
+ 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}
@@ -177,30 +178,50 @@ class HotkeyManager(gtk.ListStore):
'''
if not model[iter][COL_COMPONENT] or not model[iter][COL_DESC]:
return
- combo_gconf_key = self._getComboGConfKey(model[iter][COL_COMPONENT],
- model[iter][COL_DESC])
+
+ 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]))
- if self.gconf_client.get_string(combo_gconf_key) != combo_name:
- self.gconf_client.set_string(combo_gconf_key, combo_name)
+ key = gsettings.get_string('hotkey-combo')
+
+ if key != combo_name and key != '/':
+ gsettings.set_string('hotkey-combo', combo_name)
- def _getComboGConfKey(self, component, description):
+
+ def _getComboGSettingsPath(self, component, description):
'''
- A convinience method to expand the full gconf path for a specific key combo.
+ Useful method that build and returns a gsettings path for a key combo.
@param component: The component of the hotkey.
@type component: string
@param description: The description of the hotkey action
@type description: string
- @return: A full gconf key name
+ @return: A full gsettings path
+ @rtype: string
+ '''
+ dash_component = self.__dasherize(component)
+ dash_description = self.__dasherize(description)
+
+ path = '/'.join([dash_component, dash_description])
+
+ return HOTKEYS_BASEPATH + path + '/'
+
+
+ def __dasherize(self, item):
+ '''
+ This method dasherize and decapitalize a given string.
+
+ @param component: The given string
+ @type component: string
+
+ @return: A dasherized and decapitalized string
@rtype: string
'''
- combo_gconf_key = '%s/%s/%s/key_combo' % \
- (GCONF_HOTKEYS, gconf.escape_key(component, len(component)),
- gconf.escape_key(description, len(description)))
- return combo_gconf_key
+ return item.lower().replace(' ', '-')
class HotkeyTreeView(gtk.TreeView):
'''
@@ -355,7 +376,7 @@ class HotkeyTreeView(gtk.TreeView):
keysym = _charToKeySym(new_text)
except:
keysym = _charToKeySym(new_text[0])
- self.hotkey_manager[path][COL_KEYPRESS] = keysym
+ self.hotkey_manager[path][COL_KEYPRESS] = int(keysym)
def _onModToggled(self, renderer_toggle, path, mask):
'''
diff --git a/src/lib/accerciser/main_window.py b/src/lib/accerciser/main_window.py
index e141353..39e2c4c 100644
--- a/src/lib/accerciser/main_window.py
+++ b/src/lib/accerciser/main_window.py
@@ -1,6 +1,6 @@
from gi.repository import Gtk as gtk
from gi.repository import Gdk as gdk
-from gi.repository import GConf as gconf
+from gi.repository.Gio import Settings as GSettings
from plugin import PluginView
from i18n import _, N_
@@ -8,7 +8,7 @@ from accessible_treeview import *
import ui_manager
from ui_manager import uimanager
-GCONF_GENERAL = '/apps/accerciser/general'
+GSCHEMA = 'org.a11y.Accerciser'
class AccerciserMainWindow(gtk.Window):
'''
@@ -42,9 +42,9 @@ class AccerciserMainWindow(gtk.Window):
self.set_title(_('Accerciser Accessibility Explorer'))
self.connect('key-press-event', self._onKeyPress)
node.connect('blink-done', self._onBlinkDone)
- cl = gconf.Client.get_default()
- width = cl.get_int(GCONF_GENERAL+'/window_width') or 640
- height = cl.get_int(GCONF_GENERAL+'/window_height') or 640
+ self.gsettings = GSettings(schema=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
@@ -103,10 +103,9 @@ class AccerciserMainWindow(gtk.Window):
sw.add(self.treeview)
self._hpaned.add1(sw)
- cl = gconf.Client.get_default()
for paned in (self._vpaned, self._hpaned):
- if not cl.get(GCONF_GENERAL+'/'+paned.get_name()): continue
- paned_position = cl.get_int(GCONF_GENERAL+'/'+paned.get_name())
+ if not self.gsettings.get_int(paned.get_name()): continue
+ paned_position = self.gsettings.get_int(paned.get_name())
paned.set_position(paned_position)
paned.set_data('last_position', paned.get_position())
@@ -164,16 +163,15 @@ class AccerciserMainWindow(gtk.Window):
'''
Save the dimensions of the main window, and the position of the panes.
'''
- cl = gconf.Client.get_default()
- cl.set_int(GCONF_GENERAL+'/window_width', self.get_allocated_width())
- cl.set_int(GCONF_GENERAL+'/window_height', self.get_allocated_height())
- cl.set_int(GCONF_GENERAL+'/hpaned', self._hpaned.get_position())
+ self.gsettings.set_int('window-width', self.get_allocated_width())
+ self.gsettings.set_int('window-height', self.get_allocated_height())
+ self.gsettings.set_int('hpaned', self._hpaned.get_position())
if self.pluginview2.get_n_pages():
position = self._vpaned.get_position()
else:
position = self._vpaned.get_data('last_position')
if position is not None:
- cl.set_int(GCONF_GENERAL+'/vpaned', position)
+ self.gsettings.set_int('vpaned', position)
def _onBlinkDone(self, node):
'''
diff --git a/src/lib/accerciser/node.py b/src/lib/accerciser/node.py
index c1933bc..1973d9e 100644
--- a/src/lib/accerciser/node.py
+++ b/src/lib/accerciser/node.py
@@ -16,7 +16,7 @@ import gi
from gi.repository import Gtk as gtk
from gi.repository import Gdk as gdk
from gi.repository import GObject
-from gi.repository import GConf as gconf
+from gi.repository.Gio import Settings as GSettings
#from gi.repository import cairo
import cairo
import pyatspi
@@ -25,14 +25,14 @@ from tools import Tools, parseColorString
MAX_BLINKS = 6
-cl = gconf.Client.get_default()
+gsettings = GSettings(schema='org.a11y.Accerciser')
BORDER_COLOR, BORDER_ALPHA = parseColorString(
- cl.get_string('/apps/accerciser/highlight_border') or '#ff0000ff')
+ gsettings.get_string('highlight-border'))
FILL_COLOR, FILL_ALPHA = parseColorString(
- cl.get_string('/apps/accerciser/highlight_fill') or '#ff00006f')
+ gsettings.get_string('highlight-fill'))
-HL_DURATION = int(cl.get_float('/apps/accerciser/highlight_duration')*1000)
+HL_DURATION = int(gsettings.get_double('highlight-duration')*1000)
class Bag(object):
'''
diff --git a/src/lib/accerciser/plugin/plugin_manager.py b/src/lib/accerciser/plugin/plugin_manager.py
index bbd5470..0db1df3 100644
--- a/src/lib/accerciser/plugin/plugin_manager.py
+++ b/src/lib/accerciser/plugin/plugin_manager.py
@@ -14,11 +14,11 @@ is available at U{http://www.opensource.org/licenses/bsd-license.php}
import gi
from gi.repository import Gtk as gtk
-from gi.repository import GConf as gconf
+from gi.repository.Gio import Settings as GSettings
from base_plugin import Plugin
from view import ViewManager
-from accerciser.tools import Tools, GConfListWrapper, getTreePathBoundingBox
+from accerciser.tools import Tools, getTreePathBoundingBox
from message import MessageManager
import os
import sys
@@ -26,7 +26,7 @@ import imp
import traceback
from accerciser.i18n import _, N_, C_
-GCONF_PLUGIN_DISABLED = '/apps/accerciser/disabled_plugins'
+GSCHEMA = 'org.a11y.Accerciser'
class PluginManager(gtk.ListStore, Tools):
'''
@@ -68,6 +68,7 @@ class PluginManager(gtk.ListStore, Tools):
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',
@@ -169,8 +170,9 @@ class PluginManager(gtk.ListStore, Tools):
iter_id = self.append([None, plugin_locals[symbol], plugin_dir])
self.handler_unblock(self._row_changed_handler)
# if a plugin class is found, initialize
+ disabled_list = self.gsettings.get_strv('disabled-plugins')
enabled = plugin_locals[symbol].plugin_name not in \
- GConfListWrapper(GCONF_PLUGIN_DISABLED)
+ disabled_list
if enabled:
self._enablePlugin(iter_id)
self.row_changed(self.get_path(iter_id), iter_id)
@@ -206,6 +208,10 @@ class PluginManager(gtk.ListStore, Tools):
if isinstance(plugin_instance, gtk.Widget):
self.view_manager.addElement(plugin_instance)
plugin_instance.onAccChanged(plugin_instance.node.acc)
+ disabled_list = self.gsettings.get_strv('disabled-plugins')
+ if plugin_instance.plugin_name in disabled_list:
+ disabled_list.remove(plugin_instance.plugin_name)
+ self.gsettings.set_strv('disabled-plugins', disabled_list)
def _disablePlugin(self, iter):
'''
@@ -222,7 +228,12 @@ class PluginManager(gtk.ListStore, Tools):
if isinstance(plugin_instance, gtk.Widget):
plugin_instance.destroy()
plugin_instance._close()
-
+
+ disabled_list = self.gsettings.get_strv('disabled-plugins')
+ if not plugin_instance.plugin_name in disabled_list:
+ disabled_list.append(plugin_instance.plugin_name)
+ self.gsettings.set_strv('disabled-plugins', disabled_list)
+
self[iter][self.COL_INSTANCE] = False
def _reloadPlugin(self, iter):
@@ -309,7 +320,7 @@ class PluginManager(gtk.ListStore, Tools):
def _onPluginRowChanged(self, model, path, iter):
'''
Callback for model row changes. Persists plugins state (enabled/disabled)
- in gconf.
+ in gsettings.
@param model: Current model, actually self.
@type model: gtk.ListStore
@@ -322,7 +333,7 @@ class PluginManager(gtk.ListStore, Tools):
if plugin_class is None:
return
plugin_instance = model[iter][self.COL_INSTANCE]
- disabled_list = GConfListWrapper(GCONF_PLUGIN_DISABLED)
+ disabled_list = self.gsettings.get_strv('disabled-plugins')
if plugin_instance is None:
if plugin_class.plugin_name not in disabled_list:
disabled_list.append(plugin_class.plugin_name)
diff --git a/src/lib/accerciser/plugin/view.py b/src/lib/accerciser/plugin/view.py
index 808c811..5869d95 100644
--- a/src/lib/accerciser/plugin/view.py
+++ b/src/lib/accerciser/plugin/view.py
@@ -12,7 +12,7 @@ is available at U{http://www.opensource.org/licenses/bsd-license.php}
'''
from gi.repository import Gtk as gtk
from gi.repository import Gdk as gdk
-from gi.repository import GConf as gconf
+from gi.repository.Gio import Settings as GSettings
from gi.repository import GObject
from base_plugin import Plugin
@@ -25,8 +25,12 @@ from accerciser.i18n import _, N_
import gc
from accerciser import ui_manager
-GCONF_PLUGINVIEWS = '/apps/accerciser/pluginviews'
-GCONF_LAYOUT_SINGLE = '/apps/accerciser/general/layout_single'
+
+GSCHEMA = 'org.a11y.Accerciser'
+PLUGVIEWS_GSCHEMA = 'org.a11y.Accerciser.pluginviews'
+NEWPLUGVIEWS_GSCHEMA = 'org.a11y.Accerciser.newpluginviews'
+NEWPLUGVIEWS_PATH = '/apps/accerciser/newpluginviews/'
+
class PluginView(gtk.Notebook):
'''
@@ -269,7 +273,7 @@ class PluginView(gtk.Notebook):
class PluginViewWindow(gtk.Window, Tools):
'''
- Standalone window with a plugn view.
+ Standalone window with a plugin view.
@ivar plugin_view: Embedded plugin view.
@type plugin_view: L{PluginView}
@@ -285,10 +289,10 @@ class PluginViewWindow(gtk.Window, Tools):
self.plugin_view = PluginView(view_name)
self.add(self.plugin_view)
- cl = gconf.Client.get_default()
- escaped_view_name = '/%s' % gconf.escape_key(view_name, len(view_name))
- width = cl.get_int(GCONF_PLUGINVIEWS+escaped_view_name+'/width') or 480
- height = cl.get_int(GCONF_PLUGINVIEWS+escaped_view_name+'/height') or 480
+ 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)
@@ -308,12 +312,10 @@ class PluginViewWindow(gtk.Window, Tools):
@type allocation: gtk.gdk.Rectangle
'''
view_name = self.plugin_view.view_name
- key_prefix = '%s/%s' % \
- (GCONF_PLUGINVIEWS,
- gconf.escape_key(view_name, len(view_name)))
- cl = gconf.Client.get_default()
- cl.set_int(key_prefix+'/width', self.get_allocated_width())
- cl.set_int(key_prefix+'/height', self.get_allocated_height())
+ 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())
def _onPluginRemoved(self, pluginview, page, page_num):
'''
@@ -360,8 +362,8 @@ class ViewManager(object):
@type perm_views: list of {PluginView}
'''
self._perm_views = perm_views
- cl = gconf.Client.get_default()
- single = cl.get_bool(GCONF_LAYOUT_SINGLE)
+ gsettings = GSettings(schema=PLUGVIEWS_GSCHEMA)
+ single = gsettings.get_boolean('layout-single')
self._initViewModel(single)
self._setupActions()
@@ -402,8 +404,8 @@ class ViewManager(object):
'''
if isinstance(self._view_model, SingleViewModel) == single:
return
- cl = gconf.Client.get_default()
- cl.set_bool(GCONF_LAYOUT_SINGLE, single)
+ gsettings = GSettings(schema=PLUGVIEWS_GSCHEMA)
+ gsettings.set_boolean('layout-single', single)
plugins = self._view_model.getViewedPlugins()
self._view_model.close()
del self._view_model
@@ -519,7 +521,7 @@ class BaseViewModel(Tools):
'''
Add an element to a plugin view. If the element is a message tab, put it as
the first tab in the main view. If the element is a plugin, check if it's
- placement is cached in this instance or read it's position from gconf.
+ placement is cached in this instance or read it's position from gsettings.
By default a plugin is appended to the main view.
@param element: The element to be added to a view.
@@ -537,7 +539,7 @@ class BaseViewModel(Tools):
def addPlugin(self, plugin):
'''
Add a plugin to the view. Check if it's placement is cached in this
- instance or read it's position from gconf. By default a plugin is
+ instance or read it's position from gsettings. By default a plugin is
appended to the main view.
@param plugin: Plugin to add.
@@ -670,13 +672,13 @@ class MultiViewModel(list, BaseViewModel):
@ivar main_view: Main view.
@type main_view: L{PluginView}
@ivar _ignore_insertion: A list of tuples with view and plugin names that
- should be ignored and not go in to gconf. This is to avoid recursive gconf
- modification.
+ should be ignored and not go in to gsettings. This is to avoid recursive
+ gsettings modification.
@type _ignore_insertion: list of tuples
@ivar _placement_cache: A cache of recently disabled plugins with their
placement. allowsthem to be enabled in to the same position.
@type _placement_cache: dictionary
- @ivar _closed: Indicator to stop writing plugin remove events to gconf.
+ @ivar _closed: Indicator to stop writing plugin remove events to gsettings.
@type _closed: boolean
'''
COL_NAME = 0
@@ -698,13 +700,13 @@ class MultiViewModel(list, BaseViewModel):
def close(self):
'''
- Stops gconf maniputaion.
+ Stops gsettings maniputaion.
'''
self._closed = True
def getViewNameForPlugin(self, plugin_name):
'''
- Get the view name for a given plugin name as defined in gconf.
+ Get the view name for a given plugin name as defined in gsettings.
Or return name of main view.
@param plugin_name: Plugin's name to lookup view for.
@@ -713,7 +715,7 @@ class MultiViewModel(list, BaseViewModel):
@return: View name for plugin.
@rtype: string
'''
- plugin_layouts = self._StoredViewsLayout()
+ plugin_layouts = self._getPluginLayouts()
for view_name in plugin_layouts:
if plugin_name in plugin_layouts[view_name]:
return view_name
@@ -845,16 +847,16 @@ class MultiViewModel(list, BaseViewModel):
@type view: :{PluginView}
'''
if isinstance(view.get_parent(), PluginViewWindow):
- view.get_parent().connect('delete_event', Proxy(self._onViewDelete))
- view.connect('plugin_drag_end', Proxy(self._onPluginDragEnd))
- view.connect('tab_popup_menu', Proxy(self._onTabPopupMenu))
- view.connect('page_added', Proxy(self._onViewLayoutChanged), 'added')
- view.connect('page_removed', Proxy(self._onViewLayoutChanged), 'removed')
- view.connect('page_reordered', Proxy(self._onViewLayoutChanged), 'reordered')
+ view.get_parent().connect('delete-event', Proxy(self._onViewDelete))
+ view.connect('plugin-drag-end', Proxy(self._onPluginDragEnd))
+ view.connect('tab-popup-menu', Proxy(self._onTabPopupMenu))
+ view.connect('page-added', Proxy(self._onViewLayoutChanged), 'added')
+ view.connect('page-removed', Proxy(self._onViewLayoutChanged), 'removed')
+ view.connect('page-reordered', Proxy(self._onViewLayoutChanged), 'reordered')
def _onViewLayoutChanged(self, view, plugin, page_num, action):
'''
- Callback for all layout changes. Updates gconf.
+ Callback for all layout changes. Updates gsettings.
@param view: View that emitted the signal.
@type view: L{PluginView}
@@ -864,14 +866,15 @@ class MultiViewModel(list, BaseViewModel):
@type page_num: integer
@param action: Action that triggered this event.
@type action: string
- '''
+ '''
if self._closed or not isinstance(plugin, Plugin): return
if (view.view_name, plugin.plugin_name) in self._ignore_insertion:
self._ignore_insertion.remove((view.view_name, plugin.plugin_name))
return
if self._placement_cache.has_key(plugin.plugin_name):
self._placement_cache.pop(plugin.plugin_name)
- plugin_layouts = self._StoredViewsLayout()
+
+ plugin_layouts = self._getPluginLayouts()
try:
plugin_layout = plugin_layouts[view.view_name]
except KeyError:
@@ -886,10 +889,44 @@ class MultiViewModel(list, BaseViewModel):
if len(plugin_layout) == 0:
self._removeView(view)
+ self._setPluginLayouts(plugin_layouts)
+
+ 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)
+
+ 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
+
+
def addPlugin(self, plugin):
'''
Add a plugin to the view. Check if it's placement is cached in this
- instance or read it's position from gconf. By default a plugin is
+ instance or read it's position from gsettings. By default a plugin is
appended to the main view.
@param plugin: Plugin to add.
@@ -901,7 +938,7 @@ class MultiViewModel(list, BaseViewModel):
else:
view_name = self.getViewNameForPlugin(plugin.plugin_name)
view = self._getViewOrNewView(view_name)
- plugin_layouts = self._StoredViewsLayout()
+ plugin_layouts = self._getPluginLayouts()
try:
plugin_layout = plugin_layouts[view.view_name]
except KeyError:
@@ -917,6 +954,7 @@ class MultiViewModel(list, BaseViewModel):
index = child_index
break
self._ignore_insertion.append((view.view_name, plugin.plugin_name))
+ self._setPluginLayouts(plugin_layouts)
view.insert_page(plugin, position=index)
view.set_tab_detachable(plugin, True)
@@ -1103,8 +1141,8 @@ class MultiViewModel(list, BaseViewModel):
self.entry = gtk.Entry()
self.entry.set_completion(completion)
self.entry.connect('activate', self._onEntryActivate)
- self.vbox = self.get_children()[0]
- self.vbox.add(self.entry)
+ self.box = self.get_children()[0]
+ self.box.add(self.entry)
self.entry.show()
def getEntryText(self):
@@ -1125,28 +1163,3 @@ class MultiViewModel(list, BaseViewModel):
'''
self.response(gtk.ResponseType.OK)
- class _StoredViewsLayout(object):
- '''
- Convenience class for emulating a dictionary of all plugin
- view layout lists.
- '''
- def __init__(self):
- self.gconf_client = gconf.Client.get_default()
- def __len__(self):
- view_dirs = self.gconf_client.all_dirs(GCONF_PLUGINVIEWS)
- return len(view_dirs)
- def __getitem__(self, key):
- view_dirs = self.gconf_client.all_dirs(GCONF_PLUGINVIEWS)
- for dir in view_dirs:
- if key == gconf.unescape_key(dir.split('/')[-1],
- len(dir.split('/')[-1])):
- return GConfListWrapper(dir+'/layout')
- raise KeyError, key
- def __setitem__(self, key, value):
- gconf_key = '%s/%s/layout' % \
- (GCONF_PLUGINVIEWS, gconf.escape_key(key, len(key)))
- self.gconf_client.set_list(gconf_key, gconf.ValueType.STRING, value)
- def __iter__(self):
- view_dirs = self.gconf_client.all_dirs(GCONF_PLUGINVIEWS)
- for dir in view_dirs:
- yield gconf.unescape_key(dir.split('/')[-1], len(dir.split('/')[-1]))
diff --git a/src/lib/accerciser/prefs_dialog.py b/src/lib/accerciser/prefs_dialog.py
index 44c936a..ee0ef40 100644
--- a/src/lib/accerciser/prefs_dialog.py
+++ b/src/lib/accerciser/prefs_dialog.py
@@ -16,7 +16,7 @@ import gi
from gi.repository import Gtk as gtk
from gi.repository import Gdk as gdk
from gi.repository import Atk as atk
-from gi.repository import GConf as gconf
+from gi.repository.Gio import Settings as GSettings
from i18n import _
import node
@@ -72,7 +72,7 @@ class _HighlighterView(gtk.Alignment):
def __init__(self):
gtk.Alignment.__init__(self)
self.set_padding(12, 12, 18, 12)
- self.gconf_cl = gconf.Client.get_default()
+ self.gsettings = GSettings(schema='org.a11y.Accerciser')
self._buildUI()
def _buildUI(self):
@@ -88,17 +88,16 @@ class _HighlighterView(gtk.Alignment):
controls[0] = gtk.SpinButton()
controls[0].set_range(0.01, 5)
controls[0].set_digits(2)
- controls[0].set_value(
- self.gconf_cl.get_float('/apps/accerciser/highlight_duration'))
+ controls[0].set_value(self.gsettings.get_double('highlight-duration'))
controls[0].set_increments(0.01, 0.1)
controls[0].connect('value-changed', self._onDurationChanged)
labels[1] = gtk.Label(_('Border color:'))
controls[1] = self._ColorButton(node.BORDER_COLOR, node.BORDER_ALPHA)
- controls[1].connect('color-set', self._onColorSet, 'highlight_border')
+ controls[1].connect('color-set', self._onColorSet, 'highlight-border')
controls[1].set_tooltip_text(_('The border color of the highlight box'))
labels[2] = gtk.Label(_('Fill color:'))
controls[2] = self._ColorButton(node.FILL_COLOR, node.FILL_ALPHA)
- controls[2].connect('color-set', self._onColorSet, 'highlight_fill')
+ controls[2].connect('color-set', self._onColorSet, 'highlight-fill')
controls[2].set_tooltip_text(_('The fill color of the highlight box'))
for label, control, row in zip(labels, controls, range(3)):
@@ -113,36 +112,35 @@ class _HighlighterView(gtk.Alignment):
def _onDurationChanged(self, spin_button):
'''
- Callback for the duration spin button. Update gconf and the global variable
+ Callback for the duration spin button. Update key and the global variable
in the L{node} module.
@param spin_button: The spin button that emitted the value-changed signal.
@type spin_button: gtk.SpinButton
'''
node.HL_DURATION = int(spin_button.get_value()*1000)
- self.gconf_cl.set_float('/apps/accerciser/highlight_duration',
+ self.gsettings.set_double('highlight-duration',
spin_button.get_value())
- def _onColorSet(self, color_button, gconf_key):
+ def _onColorSet(self, color_button, key):
'''
- Callback for a color button. Update gconf and the global variables
+ Callback for a color button. Update gsettings and the global variables
in the L{node} module.
@param color_button: The color button that emitted the color-set signal.
@type color_button: l{_HighlighterView._ColorButton}
- @param gconf_key: the key name suffix for this color setting.
- @type gconf_key: string
+ @param key: the key name suffix for this color setting.
+ @type key: string
'''
- if 'fill' in gconf_key:
+ if 'fill' in key:
node.FILL_COLOR = color_button.get_rgb_string()
node.FILL_ALPHA = color_button.get_alpha_float()
else:
node.BORDER_COLOR = color_button.get_rgb_string()
node.BORDER_ALPHA = color_button.get_alpha_float()
- self.gconf_cl.set_string('/apps/accerciser/' + gconf_key,
- color_button.get_rgba_string())
+ self.gsettings.set_string(key, color_button.get_rgba_string())
class _ColorButton(gtk.ColorButton):
'''
diff --git a/src/lib/accerciser/tools.py b/src/lib/accerciser/tools.py
index f119f42..07f7109 100644
--- a/src/lib/accerciser/tools.py
+++ b/src/lib/accerciser/tools.py
@@ -10,8 +10,6 @@ All rights reserved. This program and the accompanying materials are made
available under the terms of the BSD which accompanies this distribution, and
is available at U{http://www.opensource.org/licenses/bsd-license.php}
'''
-from gi.repository import GConf as gconf
-
import os
import pickle
import weakref
@@ -60,61 +58,6 @@ class Tools(object):
return True
return False
-class GConfListWrapper(object):
- '''
- Wrapper for gconf list types. It keeps the list stateless, and updates
- gconf on every list change.
- '''
- def __init__(self, key):
- self.gconf_key = key
- self.wrapped_list = []
- def __str__(self):
- return self._wrap('__str__')
- def __iter__(self):
- return self._wrap('__iter__')
- def __repr__(self):
- return self._wrap('__repr__')
- def __len__(self):
- return self._wrap('__len__')
- def __getitem__(self, key):
- return self._wrap('__getitem__', key)
- def __setitem__(self, key, value):
- return self._wrap('__setitem__', key, value)
- def __delitem__(self, key):
- return self._wrap('__delitem__', key)
- def __getslice__(self, i, j):
- return self._wrap('__getslice__', i, j)
- def __setslice__(self, i, j, sequence):
- return self._wrap('__setslice__', i, j, sequence)
- def __delslice__(self, i, j):
- return self._wrap('__delslice__', i, j)
- def __contains__(self, i):
- l = [x.type for x in self]#if x.type == gconf.ValueType.STRING]
- return self.wrapped_list.__contains__(i)
- def _wrap(self, name, *args, **kwargs):
- obj = self._CallWrapper(name, self.gconf_key)
- return obj(*args, **kwargs)
- def __getattr__(self, name):
- obj = getattr(self.wrapped_list, name)
- if callable(obj):
- return self._CallWrapper(name, self.gconf_key)
- else:
- return obj
-
- class _CallWrapper(object):
- '''
- Does the actual wrapping.
- '''
- def __init__ (self, name, gconf_key):
- self.name = name
- self.gconf_key = gconf_key
- def __call__(self, *args, **kwargs):
- cl = gconf.Client.get_default()
- gcval = cl.get(self.gconf_key)
- l = gcval.get_list()
- rv = getattr(l, self.name)(*args, **kwargs)
- cl.set_list(self.gconf_key, gconf.ValueType.STRING, l)
- return rv
class Proxy(object):
'''
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]