2008-07-28 07:45:16 +04:00
|
|
|
# vim:set et sts=4 sw=4:
|
|
|
|
#
|
|
|
|
# ibus - The Input Bus
|
|
|
|
#
|
|
|
|
# Copyright(c) 2007-2008 Huang Peng <shawn.p.huang@gmail.com>
|
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2 of the License, or(at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this program; if not, write to the
|
|
|
|
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
|
|
|
# Boston, MA 02111-1307 USA
|
|
|
|
|
2008-07-05 05:17:58 +04:00
|
|
|
import gconf
|
|
|
|
import ibus
|
|
|
|
from ibus import interface
|
|
|
|
|
2008-07-28 07:44:09 +04:00
|
|
|
class Config(ibus.Object):
|
|
|
|
def __init__ (self, conn, path):
|
2008-07-28 07:45:16 +04:00
|
|
|
super(Config, self).__init__()
|
2008-07-28 07:44:09 +04:00
|
|
|
self.__proxy = ConfigProxy(self, conn, path)
|
|
|
|
self.__client = gconf.Client()
|
|
|
|
self.__client.connect("value-changed", self.__value_changed_cb)
|
|
|
|
self.__client.add_dir("/", gconf.CLIENT_PRELOAD_NONE)
|
2008-07-05 05:17:58 +04:00
|
|
|
|
2008-07-28 07:44:09 +04:00
|
|
|
def get_string(self, key):
|
2008-07-15 12:57:18 +04:00
|
|
|
pass
|
2008-07-28 07:44:09 +04:00
|
|
|
def get_int(self, key):
|
2008-07-15 12:57:18 +04:00
|
|
|
pass
|
2008-07-28 07:44:09 +04:00
|
|
|
def get_bool(self, key):
|
2008-07-15 12:57:18 +04:00
|
|
|
pass
|
|
|
|
|
2008-07-28 07:44:09 +04:00
|
|
|
def set_string(self, key, value):
|
2008-07-15 12:57:18 +04:00
|
|
|
pass
|
2008-07-28 07:44:09 +04:00
|
|
|
def set_int(self, key, value):
|
2008-07-15 12:57:18 +04:00
|
|
|
pass
|
2008-07-28 07:44:09 +04:00
|
|
|
def set_bool(self, key, value):
|
2008-07-15 12:57:18 +04:00
|
|
|
pass
|
2008-07-05 05:17:58 +04:00
|
|
|
|
2008-07-28 10:59:17 +04:00
|
|
|
def do_destroy(self):
|
|
|
|
self.__proxy = None
|
|
|
|
|
2008-07-28 07:44:09 +04:00
|
|
|
def __value_changed_cb(self, gconf, key, value):
|
|
|
|
value = self.__client.get_value(key)
|
|
|
|
print key, type(value), value
|
|
|
|
self.__proxy.ValueChanged(key, value)
|
2008-07-05 05:17:58 +04:00
|
|
|
|
2008-07-28 07:44:09 +04:00
|
|
|
class ConfigProxy(interface.IConfig):
|
|
|
|
def __init__ (self, config, conn, object_path):
|
2008-07-28 07:45:16 +04:00
|
|
|
super(ConfigProxy, self).__init__(conn, object_path)
|
2008-07-28 07:44:09 +04:00
|
|
|
self.__config = config
|
2008-07-05 05:17:58 +04:00
|
|
|
|
2008-07-28 07:44:09 +04:00
|
|
|
def GetString(self, key):
|
|
|
|
return self.__config.get_string(key)
|
|
|
|
def GetInt(self, key):
|
|
|
|
return self.__config.get_int(key)
|
|
|
|
def GetBool(self, key):
|
|
|
|
return self.__config.get_bool(key)
|
2008-07-05 05:17:58 +04:00
|
|
|
|
2008-07-28 07:44:09 +04:00
|
|
|
def SetString(self, key, value):
|
|
|
|
self.__config.set_string(key, value)
|
|
|
|
def SetInt(self, key, value):
|
|
|
|
self.__config.set_int(key, value)
|
|
|
|
def SetBool(self, key, value):
|
|
|
|
self.__config.set_bool(key, value)
|
2008-07-28 10:59:17 +04:00
|
|
|
def Destroy(self):
|
|
|
|
self.remove_from_connection()
|
|
|
|
self.__config.destroy()
|
|
|
|
self.__config = None
|