GConf to GSettings port

This commit is contained in:
Emil Dudev 2013-12-26 17:53:36 +02:00 committed by Daniel Narvaez
parent 93437ddedf
commit db2ba3e579
7 changed files with 52 additions and 43 deletions

View File

@ -58,10 +58,10 @@ import StringIO
import cairo import cairo
import json import json
from gi.repository import GConf
from gi.repository import Gtk from gi.repository import Gtk
from gi.repository import Gdk from gi.repository import Gdk
from gi.repository import GObject from gi.repository import GObject
from gi.repository import Gio
import dbus import dbus
import dbus.service import dbus.service
from dbus import PROPERTIES_IFACE from dbus import PROPERTIES_IFACE
@ -375,8 +375,8 @@ class Activity(Window, Gtk.Container):
def _initialize_journal_object(self): def _initialize_journal_object(self):
title = _('%s Activity') % get_bundle_name() title = _('%s Activity') % get_bundle_name()
client = GConf.Client.get_default() settings = Gio.Settings('org.sugarlabs.user')
icon_color = client.get_string('/desktop/sugar/user/color') icon_color = settings.get_string('color')
jobject = datastore.create() jobject = datastore.create()
jobject.metadata['title'] = title jobject.metadata['title'] = title

View File

@ -20,7 +20,6 @@
from gi.repository import Gdk from gi.repository import Gdk
from gi.repository import Gtk from gi.repository import Gtk
import gettext import gettext
from gi.repository import GConf
from sugar3.graphics.toolbutton import ToolButton from sugar3.graphics.toolbutton import ToolButton
from sugar3.graphics.toolbarbox import ToolbarButton from sugar3.graphics.toolbarbox import ToolbarButton
@ -31,6 +30,7 @@ from sugar3.graphics.icon import Icon
from sugar3.bundle.activitybundle import ActivityBundle from sugar3.bundle.activitybundle import ActivityBundle
from sugar3.graphics import style from sugar3.graphics import style
from sugar3.graphics.palettemenu import PaletteMenuBox from sugar3.graphics.palettemenu import PaletteMenuBox
from sugar3 import profile
_ = lambda msg: gettext.dgettext('sugar-toolkit-gtk3', msg) _ = lambda msg: gettext.dgettext('sugar-toolkit-gtk3', msg)
@ -40,8 +40,7 @@ def _create_activity_icon(metadata):
if metadata is not None and metadata.get('icon-color'): if metadata is not None and metadata.get('icon-color'):
color = XoColor(metadata['icon-color']) color = XoColor(metadata['icon-color'])
else: else:
client = GConf.Client.get_default() color = profile.get_color()
color = XoColor(client.get_string('/desktop/sugar/user/color'))
from sugar3.activity.activity import get_bundle_path from sugar3.activity.activity import get_bundle_path
bundle = ActivityBundle(get_bundle_path()) bundle = ActivityBundle(get_bundle_path())

View File

@ -26,7 +26,6 @@ from datetime import datetime
import os import os
import tempfile import tempfile
from gi.repository import GObject from gi.repository import GObject
from gi.repository import GConf
from gi.repository import Gio from gi.repository import Gio
import dbus import dbus
@ -225,7 +224,7 @@ class RawObject(object):
def __init__(self, file_path): def __init__(self, file_path):
stat = os.stat(file_path) stat = os.stat(file_path)
client = GConf.Client.get_default() settings = Gio.Settings('org.sugarlabs.user')
metadata = { metadata = {
'uid': file_path, 'uid': file_path,
'title': os.path.basename(file_path), 'title': os.path.basename(file_path),
@ -233,7 +232,7 @@ class RawObject(object):
'mime_type': Gio.content_type_guess(file_path, None)[0], 'mime_type': Gio.content_type_guess(file_path, None)[0],
'activity': '', 'activity': '',
'activity_id': '', 'activity_id': '',
'icon-color': client.get_string('/desktop/sugar/user/color'), 'icon-color': settings.get_string('color'),
'description': file_path, 'description': file_path,
} }

View File

@ -27,7 +27,7 @@ import logging
from gi.repository import Gdk from gi.repository import Gdk
from gi.repository import Pango from gi.repository import Pango
from gi.repository import GConf from gi.repository import Gio
FOCUS_LINE_WIDTH = 2 FOCUS_LINE_WIDTH = 2
@ -115,9 +115,9 @@ MEDIUM_ICON_SIZE = zoom(55 * 1.5)
LARGE_ICON_SIZE = zoom(55 * 2.0) LARGE_ICON_SIZE = zoom(55 * 2.0)
XLARGE_ICON_SIZE = zoom(55 * 2.75) XLARGE_ICON_SIZE = zoom(55 * 2.75)
client = GConf.Client.get_default() settings = Gio.Settings('org.sugarlabs.font')
FONT_SIZE = client.get_float('/desktop/sugar/font/default_size') FONT_SIZE = settings.get_double('default-size')
FONT_FACE = client.get_string('/desktop/sugar/font/default_face') FONT_FACE = settings.get_string('default-face')
FONT_NORMAL = Font('%s %f' % (FONT_FACE, FONT_SIZE)) FONT_NORMAL = Font('%s %f' % (FONT_FACE, FONT_SIZE))
FONT_BOLD = Font('%s bold %f' % (FONT_FACE, FONT_SIZE)) FONT_BOLD = Font('%s bold %f' % (FONT_FACE, FONT_SIZE))

View File

@ -22,7 +22,7 @@ STABLE.
import random import random
import logging import logging
from gi.repository import GConf from gi.repository import Gio
colors = [['#B20008', '#FF2B34'], colors = [['#B20008', '#FF2B34'],
['#FF2B34', '#B20008'], ['#FF2B34', '#B20008'],
@ -229,8 +229,8 @@ class XoColor:
parsed_color = None parsed_color = None
if color_string is None: if color_string is None:
client = GConf.Client.get_default() settings = Gio.Settings('org.sugarlabs.user')
color_string = client.get_string('/desktop/sugar/user/color') color_string = settings.get_string('color')
if color_string is not None: if color_string is not None:
parsed_color = _parse_string(color_string) parsed_color = _parse_string(color_string)

View File

@ -24,8 +24,8 @@ STABLE.
import logging import logging
from gi.repository import GObject from gi.repository import GObject
from gi.repository import Gio
import dbus import dbus
from gi.repository import GConf
from telepathy.interfaces import CONNECTION, \ from telepathy.interfaces import CONNECTION, \
CONNECTION_INTERFACE_ALIASING, \ CONNECTION_INTERFACE_ALIASING, \
CONNECTION_INTERFACE_CONTACTS CONNECTION_INTERFACE_CONTACTS
@ -243,6 +243,6 @@ class Owner(BaseBuddy):
def __init__(self): def __init__(self):
BaseBuddy.__init__(self) BaseBuddy.__init__(self)
client = GConf.Client.get_default() settings = Gio.Settings('org.sugarlabs.user')
self.props.nick = client.get_string('/desktop/sugar/user/nick') self.props.nick = settings.get_string('nick')
self.props.color = client.get_string('/desktop/sugar/user/color') self.props.color = settings.get_string('color')

View File

@ -20,7 +20,7 @@
DEPRECATED. We are using GConf now to store preferences. DEPRECATED. We are using GConf now to store preferences.
""" """
from gi.repository import GConf from gi.repository import Gio
import os import os
import logging import logging
from ConfigParser import ConfigParser from ConfigParser import ConfigParser
@ -68,9 +68,9 @@ class Profile(object):
privkey_hash = property(fget=_get_privkey_hash) privkey_hash = property(fget=_get_privkey_hash)
def is_valid(self): def is_valid(self):
client = GConf.Client.get_default() settings = Gio.Settings('org.sugarlabs.user')
nick = client.get_string('/desktop/sugar/user/nick') nick = settings.get_string('nick')
color = client.get_string('/desktop/sugar/user/color') color = settings.get_string('color')
return nick is not '' and \ return nick is not '' and \
color is not '' and \ color is not '' and \
@ -140,47 +140,58 @@ class Profile(object):
path = os.path.join(env.get_profile_path(), 'config') path = os.path.join(env.get_profile_path(), 'config')
cp.read([path]) cp.read([path])
client = GConf.Client.get_default() settings = Gio.Settings('org.sugarlabs.user')
if cp.has_option('Buddy', 'NickName'): if cp.has_option('Buddy', 'NickName'):
name = cp.get('Buddy', 'NickName') name = cp.get('Buddy', 'NickName')
# decode nickname from ascii-safe chars to unicode # decode nickname from ascii-safe chars to unicode
nick = name.decode('utf-8') nick = name.decode('utf-8')
client.set_string('/desktop/sugar/user/nick', nick) settings.set_string('nick', nick)
if cp.has_option('Buddy', 'Color'): if cp.has_option('Buddy', 'Color'):
color = cp.get('Buddy', 'Color') color = cp.get('Buddy', 'Color')
client.set_string('/desktop/sugar/user/color', color) settings.set_string('color', color)
if cp.has_option('Jabber', 'Server'): if cp.has_option('Jabber', 'Server'):
server = cp.get('Jabber', 'Server') server = cp.get('Jabber', 'Server')
client.set_string('/desktop/sugar/collaboration/jabber_server', settings = Gio.Settings('org.sugarlabs.collaboration')
server) settings.set_string('jabber-server', server)
if cp.has_option('Date', 'Timezone'): if cp.has_option('Date', 'Timezone'):
timezone = cp.get('Date', 'Timezone') timezone = cp.get('Date', 'Timezone')
client.set_string('/desktop/sugar/date/timezone', timezone) settings = Gio.Settings('org.sugarlabs.date')
settings.set_string('timezone', timezone)
settings = Gio.Settings('org.sugarlabs.frame')
if cp.has_option('Frame', 'HotCorners'): if cp.has_option('Frame', 'HotCorners'):
delay = float(cp.get('Frame', 'HotCorners')) delay = float(cp.get('Frame', 'HotCorners'))
client.set_int('/desktop/sugar/frame/corner_delay', int(delay)) settings.set_int('corner-delay', int(delay))
if cp.has_option('Frame', 'WarmEdges'): if cp.has_option('Frame', 'WarmEdges'):
delay = float(cp.get('Frame', 'WarmEdges')) delay = float(cp.get('Frame', 'WarmEdges'))
client.set_int('/desktop/sugar/frame/edge_delay', int(delay)) settings.set_int('edge-delay', int(delay))
if cp.has_option('Server', 'Backup1'): if cp.has_option('Server', 'Backup1'):
backup1 = cp.get('Server', 'Backup1') backup1 = cp.get('Server', 'Backup1')
client.set_string('/desktop/sugar/backup_url', backup1) settings = Gio.Settings('org.sugarlabs')
settings.set_string('backup-url', backup1)
if cp.has_option('Sound', 'Volume'): if cp.has_option('Sound', 'Volume'):
volume = float(cp.get('Sound', 'Volume')) volume = float(cp.get('Sound', 'Volume'))
client.set_int('/desktop/sugar/sound/volume', int(volume)) settings = Gio.Settings('org.sugarlabs.sound')
settings.set_int('volume', int(volume))
settings = Gio.Settings('org.sugarlabs.power')
if cp.has_option('Power', 'AutomaticPM'): if cp.has_option('Power', 'AutomaticPM'):
state = cp.get('Power', 'AutomaticPM') state = cp.get('Power', 'AutomaticPM')
if state.lower() == 'true': if state.lower() == 'true':
client.set_bool('/desktop/sugar/power/automatic', True) settings.set_boolean('automatic', True)
if cp.has_option('Power', 'ExtremePM'): if cp.has_option('Power', 'ExtremePM'):
state = cp.get('Power', 'ExtremePM') state = cp.get('Power', 'ExtremePM')
if state.lower() == 'true': if state.lower() == 'true':
client.set_bool('/desktop/sugar/power/extreme', True) settings.set_boolean('extreme', True)
if cp.has_option('Shell', 'FavoritesLayout'): if cp.has_option('Shell', 'FavoritesLayout'):
layout = cp.get('Shell', 'FavoritesLayout') layout = cp.get('Shell', 'FavoritesLayout')
client.set_string('/desktop/sugar/desktop/favorites_layout', settings = Gio.Settings('org.sugarlabs.desktop')
layout) settings.set_string('favorites-layout', layout)
del cp del cp
try: try:
os.unlink(path) os.unlink(path)
@ -199,13 +210,13 @@ def get_profile():
def get_nick_name(): def get_nick_name():
client = GConf.Client.get_default() settings = Gio.Settings('org.sugarlabs.user')
return client.get_string('/desktop/sugar/user/nick') return settings.get_string('nick')
def get_color(): def get_color():
client = GConf.Client.get_default() settings = Gio.Settings('org.sugarlabs.user')
color = client.get_string('/desktop/sugar/user/color') color = settings.get_string('color')
return XoColor(color) return XoColor(color)