GConf to GSettings port
This commit is contained in:
		
							parent
							
								
									93437ddedf
								
							
						
					
					
						commit
						db2ba3e579
					
				@ -58,10 +58,10 @@ import StringIO
 | 
			
		||||
import cairo
 | 
			
		||||
import json
 | 
			
		||||
 | 
			
		||||
from gi.repository import GConf
 | 
			
		||||
from gi.repository import Gtk
 | 
			
		||||
from gi.repository import Gdk
 | 
			
		||||
from gi.repository import GObject
 | 
			
		||||
from gi.repository import Gio
 | 
			
		||||
import dbus
 | 
			
		||||
import dbus.service
 | 
			
		||||
from dbus import PROPERTIES_IFACE
 | 
			
		||||
@ -375,8 +375,8 @@ class Activity(Window, Gtk.Container):
 | 
			
		||||
 | 
			
		||||
    def _initialize_journal_object(self):
 | 
			
		||||
        title = _('%s Activity') % get_bundle_name()
 | 
			
		||||
        client = GConf.Client.get_default()
 | 
			
		||||
        icon_color = client.get_string('/desktop/sugar/user/color')
 | 
			
		||||
        settings = Gio.Settings('org.sugarlabs.user')
 | 
			
		||||
        icon_color = settings.get_string('color')
 | 
			
		||||
 | 
			
		||||
        jobject = datastore.create()
 | 
			
		||||
        jobject.metadata['title'] = title
 | 
			
		||||
 | 
			
		||||
@ -20,7 +20,6 @@
 | 
			
		||||
from gi.repository import Gdk
 | 
			
		||||
from gi.repository import Gtk
 | 
			
		||||
import gettext
 | 
			
		||||
from gi.repository import GConf
 | 
			
		||||
 | 
			
		||||
from sugar3.graphics.toolbutton import ToolButton
 | 
			
		||||
from sugar3.graphics.toolbarbox import ToolbarButton
 | 
			
		||||
@ -31,6 +30,7 @@ from sugar3.graphics.icon import Icon
 | 
			
		||||
from sugar3.bundle.activitybundle import ActivityBundle
 | 
			
		||||
from sugar3.graphics import style
 | 
			
		||||
from sugar3.graphics.palettemenu import PaletteMenuBox
 | 
			
		||||
from sugar3 import profile
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
_ = 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'):
 | 
			
		||||
        color = XoColor(metadata['icon-color'])
 | 
			
		||||
    else:
 | 
			
		||||
        client = GConf.Client.get_default()
 | 
			
		||||
        color = XoColor(client.get_string('/desktop/sugar/user/color'))
 | 
			
		||||
        color = profile.get_color()
 | 
			
		||||
 | 
			
		||||
    from sugar3.activity.activity import get_bundle_path
 | 
			
		||||
    bundle = ActivityBundle(get_bundle_path())
 | 
			
		||||
 | 
			
		||||
@ -26,7 +26,6 @@ from datetime import datetime
 | 
			
		||||
import os
 | 
			
		||||
import tempfile
 | 
			
		||||
from gi.repository import GObject
 | 
			
		||||
from gi.repository import GConf
 | 
			
		||||
from gi.repository import Gio
 | 
			
		||||
import dbus
 | 
			
		||||
 | 
			
		||||
@ -225,7 +224,7 @@ class RawObject(object):
 | 
			
		||||
 | 
			
		||||
    def __init__(self, file_path):
 | 
			
		||||
        stat = os.stat(file_path)
 | 
			
		||||
        client = GConf.Client.get_default()
 | 
			
		||||
        settings = Gio.Settings('org.sugarlabs.user')
 | 
			
		||||
        metadata = {
 | 
			
		||||
            'uid': 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],
 | 
			
		||||
            'activity': '',
 | 
			
		||||
            'activity_id': '',
 | 
			
		||||
            'icon-color': client.get_string('/desktop/sugar/user/color'),
 | 
			
		||||
            'icon-color': settings.get_string('color'),
 | 
			
		||||
            'description': file_path,
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -27,7 +27,7 @@ import logging
 | 
			
		||||
 | 
			
		||||
from gi.repository import Gdk
 | 
			
		||||
from gi.repository import Pango
 | 
			
		||||
from gi.repository import GConf
 | 
			
		||||
from gi.repository import Gio
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
FOCUS_LINE_WIDTH = 2
 | 
			
		||||
@ -115,9 +115,9 @@ MEDIUM_ICON_SIZE = zoom(55 * 1.5)
 | 
			
		||||
LARGE_ICON_SIZE = zoom(55 * 2.0)
 | 
			
		||||
XLARGE_ICON_SIZE = zoom(55 * 2.75)
 | 
			
		||||
 | 
			
		||||
client = GConf.Client.get_default()
 | 
			
		||||
FONT_SIZE = client.get_float('/desktop/sugar/font/default_size')
 | 
			
		||||
FONT_FACE = client.get_string('/desktop/sugar/font/default_face')
 | 
			
		||||
settings = Gio.Settings('org.sugarlabs.font')
 | 
			
		||||
FONT_SIZE = settings.get_double('default-size')
 | 
			
		||||
FONT_FACE = settings.get_string('default-face')
 | 
			
		||||
 | 
			
		||||
FONT_NORMAL = Font('%s %f' % (FONT_FACE, FONT_SIZE))
 | 
			
		||||
FONT_BOLD = Font('%s bold %f' % (FONT_FACE, FONT_SIZE))
 | 
			
		||||
 | 
			
		||||
@ -22,7 +22,7 @@ STABLE.
 | 
			
		||||
import random
 | 
			
		||||
import logging
 | 
			
		||||
 | 
			
		||||
from gi.repository import GConf
 | 
			
		||||
from gi.repository import Gio
 | 
			
		||||
 | 
			
		||||
colors = [['#B20008', '#FF2B34'],
 | 
			
		||||
          ['#FF2B34', '#B20008'],
 | 
			
		||||
@ -229,8 +229,8 @@ class XoColor:
 | 
			
		||||
        parsed_color = None
 | 
			
		||||
 | 
			
		||||
        if color_string is None:
 | 
			
		||||
            client = GConf.Client.get_default()
 | 
			
		||||
            color_string = client.get_string('/desktop/sugar/user/color')
 | 
			
		||||
            settings = Gio.Settings('org.sugarlabs.user')
 | 
			
		||||
            color_string = settings.get_string('color')
 | 
			
		||||
 | 
			
		||||
        if color_string is not None:
 | 
			
		||||
            parsed_color = _parse_string(color_string)
 | 
			
		||||
 | 
			
		||||
@ -24,8 +24,8 @@ STABLE.
 | 
			
		||||
import logging
 | 
			
		||||
 | 
			
		||||
from gi.repository import GObject
 | 
			
		||||
from gi.repository import Gio
 | 
			
		||||
import dbus
 | 
			
		||||
from gi.repository import GConf
 | 
			
		||||
from telepathy.interfaces import CONNECTION, \
 | 
			
		||||
    CONNECTION_INTERFACE_ALIASING, \
 | 
			
		||||
    CONNECTION_INTERFACE_CONTACTS
 | 
			
		||||
@ -243,6 +243,6 @@ class Owner(BaseBuddy):
 | 
			
		||||
    def __init__(self):
 | 
			
		||||
        BaseBuddy.__init__(self)
 | 
			
		||||
 | 
			
		||||
        client = GConf.Client.get_default()
 | 
			
		||||
        self.props.nick = client.get_string('/desktop/sugar/user/nick')
 | 
			
		||||
        self.props.color = client.get_string('/desktop/sugar/user/color')
 | 
			
		||||
        settings = Gio.Settings('org.sugarlabs.user')
 | 
			
		||||
        self.props.nick = settings.get_string('nick')
 | 
			
		||||
        self.props.color = settings.get_string('color')
 | 
			
		||||
 | 
			
		||||
@ -20,7 +20,7 @@
 | 
			
		||||
DEPRECATED. We are using GConf now to store preferences.
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
from gi.repository import GConf
 | 
			
		||||
from gi.repository import Gio
 | 
			
		||||
import os
 | 
			
		||||
import logging
 | 
			
		||||
from ConfigParser import ConfigParser
 | 
			
		||||
@ -68,9 +68,9 @@ class Profile(object):
 | 
			
		||||
    privkey_hash = property(fget=_get_privkey_hash)
 | 
			
		||||
 | 
			
		||||
    def is_valid(self):
 | 
			
		||||
        client = GConf.Client.get_default()
 | 
			
		||||
        nick = client.get_string('/desktop/sugar/user/nick')
 | 
			
		||||
        color = client.get_string('/desktop/sugar/user/color')
 | 
			
		||||
        settings = Gio.Settings('org.sugarlabs.user')
 | 
			
		||||
        nick = settings.get_string('nick')
 | 
			
		||||
        color = settings.get_string('color')
 | 
			
		||||
 | 
			
		||||
        return nick is not '' and \
 | 
			
		||||
            color is not '' and \
 | 
			
		||||
@ -140,47 +140,58 @@ class Profile(object):
 | 
			
		||||
        path = os.path.join(env.get_profile_path(), 'config')
 | 
			
		||||
        cp.read([path])
 | 
			
		||||
 | 
			
		||||
        client = GConf.Client.get_default()
 | 
			
		||||
 | 
			
		||||
        settings = Gio.Settings('org.sugarlabs.user')
 | 
			
		||||
        if cp.has_option('Buddy', 'NickName'):
 | 
			
		||||
            name = cp.get('Buddy', 'NickName')
 | 
			
		||||
            # decode nickname from ascii-safe chars to unicode
 | 
			
		||||
            nick = name.decode('utf-8')
 | 
			
		||||
            client.set_string('/desktop/sugar/user/nick', nick)
 | 
			
		||||
            settings.set_string('nick', nick)
 | 
			
		||||
        if cp.has_option('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'):
 | 
			
		||||
            server = cp.get('Jabber', 'Server')
 | 
			
		||||
            client.set_string('/desktop/sugar/collaboration/jabber_server',
 | 
			
		||||
                              server)
 | 
			
		||||
            settings = Gio.Settings('org.sugarlabs.collaboration')
 | 
			
		||||
            settings.set_string('jabber-server', server)
 | 
			
		||||
 | 
			
		||||
        if cp.has_option('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'):
 | 
			
		||||
            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'):
 | 
			
		||||
            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'):
 | 
			
		||||
            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'):
 | 
			
		||||
            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'):
 | 
			
		||||
            state = cp.get('Power', 'AutomaticPM')
 | 
			
		||||
            if state.lower() == 'true':
 | 
			
		||||
                client.set_bool('/desktop/sugar/power/automatic', True)
 | 
			
		||||
                settings.set_boolean('automatic', True)
 | 
			
		||||
        if cp.has_option('Power', 'ExtremePM'):
 | 
			
		||||
            state = cp.get('Power', 'ExtremePM')
 | 
			
		||||
            if state.lower() == 'true':
 | 
			
		||||
                client.set_bool('/desktop/sugar/power/extreme', True)
 | 
			
		||||
                settings.set_boolean('extreme', True)
 | 
			
		||||
 | 
			
		||||
        if cp.has_option('Shell', 'FavoritesLayout'):
 | 
			
		||||
            layout = cp.get('Shell', 'FavoritesLayout')
 | 
			
		||||
            client.set_string('/desktop/sugar/desktop/favorites_layout',
 | 
			
		||||
                              layout)
 | 
			
		||||
            settings = Gio.Settings('org.sugarlabs.desktop')
 | 
			
		||||
            settings.set_string('favorites-layout', layout)
 | 
			
		||||
        del cp
 | 
			
		||||
        try:
 | 
			
		||||
            os.unlink(path)
 | 
			
		||||
@ -199,13 +210,13 @@ def get_profile():
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_nick_name():
 | 
			
		||||
    client = GConf.Client.get_default()
 | 
			
		||||
    return client.get_string('/desktop/sugar/user/nick')
 | 
			
		||||
    settings = Gio.Settings('org.sugarlabs.user')
 | 
			
		||||
    return settings.get_string('nick')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_color():
 | 
			
		||||
    client = GConf.Client.get_default()
 | 
			
		||||
    color = client.get_string('/desktop/sugar/user/color')
 | 
			
		||||
    settings = Gio.Settings('org.sugarlabs.user')
 | 
			
		||||
    color = settings.get_string('color')
 | 
			
		||||
    return XoColor(color)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user