summaryrefslogtreecommitdiffstats
path: root/gconf
diff options
context:
space:
mode:
authorHuang Peng <shawn.p.huang@gmail.com>2008-07-05 09:17:58 +0800
committerHuang Peng <shawn.p.huang@gmail.com>2008-07-05 09:17:58 +0800
commit2266e16f4fed8dde3b8c0414731937eefc631ef8 (patch)
tree9c03368cba4ba791f9a379ed302448ea8be61344 /gconf
parent7cc23bb2ce8ca9b4c8c4f39c135ae774c33e6425 (diff)
downloadibus-2266e16f4fed8dde3b8c0414731937eefc631ef8.tar.gz
ibus-2266e16f4fed8dde3b8c0414731937eefc631ef8.tar.xz
ibus-2266e16f4fed8dde3b8c0414731937eefc631ef8.zip
Add gconf module.
Diffstat (limited to 'gconf')
-rw-r--r--gconf/Makefile.am48
-rw-r--r--gconf/config.py50
-rw-r--r--gconf/ibus-gconf23
-rw-r--r--gconf/ibus-gconf.in23
-rw-r--r--gconf/main.py88
5 files changed, 232 insertions, 0 deletions
diff --git a/gconf/Makefile.am b/gconf/Makefile.am
new file mode 100644
index 0000000..9c5416f
--- /dev/null
+++ b/gconf/Makefile.am
@@ -0,0 +1,48 @@
+# vim:set noet ts=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
+
+gconf_PYTHON = \
+ candidategconf.py \
+ handle.py \
+ image.py \
+ lang.py \
+ languagebar.py \
+ main.py \
+ menu.py \
+ gconf.py \
+ propitem.py \
+ toolitem.py \
+ $(NULL)
+
+gconfdir = $(pkgdatadir)/gconf
+
+libexec_SCRIPTS = ibus-gconf
+
+CLEANFILES = \
+ *.pyc \
+ $(NULL)
+
+EXTRA_DIST = \
+ ibus-gconf.in \
+ $(NULL)
+
+test:
+ $(ENV) PYTHONPATH=$(top_srcdir) $(PYTHON) $(srcdir)/main.py
diff --git a/gconf/config.py b/gconf/config.py
new file mode 100644
index 0000000..43e021e
--- /dev/null
+++ b/gconf/config.py
@@ -0,0 +1,50 @@
+import gconf
+import ibus
+from ibus import interface
+
+class Config (ibus.Object):
+ def __init__ (self, proxy):
+ ibus.Object.__init__ (self)
+ self._proxy = proxy
+ self._client = gconf.Client ()
+ self._client.connect ("value-changed", self._value_changed_cb)
+ self._client.add_dir ("/", gconf.CLIENT_PRELOAD_NONE)
+
+ def get_string (self, key):
+ pass
+ def get_int (self, key):
+ pass
+ def get_bool (self, key):
+ pass
+
+ def set_string (self, key, value):
+ pass
+ def set_int (self, key, value):
+ pass
+ def set_bool (self, key, value):
+ pass
+
+ def _value_changed_cb (self, gconf, key, value):
+ value = self._client.get_value (key)
+ print key, type (value), value
+ self._proxy.ValueChanged (key, value)
+
+class ConfigProxy (interface.IConfig):
+ def __init__ (self, dbusconn, object_path, _ibus):
+ interface.IConfig.__init__ (self, dbusconn, object_path)
+ self._dbusconn = dbusconn
+ self._config = Config (self)
+
+ 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)
+
+ 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)
diff --git a/gconf/ibus-gconf b/gconf/ibus-gconf
new file mode 100644
index 0000000..f7ee86d
--- /dev/null
+++ b/gconf/ibus-gconf
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+# 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
+
+exec python /usr/share/ibus/gconf/main.py $@
+
diff --git a/gconf/ibus-gconf.in b/gconf/ibus-gconf.in
new file mode 100644
index 0000000..a662d34
--- /dev/null
+++ b/gconf/ibus-gconf.in
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+# 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
+
+exec python @prefix@/share/ibus/gconf/main.py $@
+
diff --git a/gconf/main.py b/gconf/main.py
new file mode 100644
index 0000000..92bc82d
--- /dev/null
+++ b/gconf/main.py
@@ -0,0 +1,88 @@
+# vim:set noet ts=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
+
+import os
+import sys
+import getopt
+import ibus
+import dbus
+import dbus.mainloop.glib
+import config
+import gtk
+
+class GconfApplication:
+ def __init__ (self):
+ self._dbusconn = dbus.connection.Connection (ibus.IBUS_ADDR)
+ self._dbusconn.add_signal_receiver (self._disconnected_cb,
+ "Disconnected",
+ dbus_interface = dbus.LOCAL_IFACE)
+
+ self._ibus = self._dbusconn.get_object (ibus.IBUS_NAME, ibus.IBUS_PATH)
+ self._config = config.ConfigProxy (self._dbusconn, "/org/freedesktop/IBus/Config", self._ibus)
+
+ # self._ibus.RegisterPanel (self._panel, True)
+
+ def run (self):
+ gtk.main ()
+
+ def _disconnected_cb (self):
+ print "disconnected"
+ gtk.main_quit ()
+
+
+
+def launch_gconf ():
+ dbus.mainloop.glib.DBusGMainLoop (set_as_default=True)
+ # gtk.settings_get_default ().props.gtk_theme_name = "/home/phuang/.themes/aud-Default/gtk-2.0/gtkrc"
+ # gtk.rc_parse ("./themes/default/gtkrc")
+ GconfApplication ().run ()
+
+def print_help (out, v = 0):
+ print >> out, "-h, --help show this message."
+ print >> out, "-d, --daemonize daemonize ibus"
+ sys.exit (v)
+
+def main ():
+ daemonize = False
+ shortopt = "hd"
+ longopt = ["help", "daemonize"]
+ try:
+ opts, args = getopt.getopt (sys.argv[1:], shortopt, longopt)
+ except getopt.GetoptError, err:
+ print_help (sys.stderr, 1)
+
+ for o, a in opts:
+ if o in ("-h", "--help"):
+ print_help (sys.stdout)
+ elif o in ("-d", "--daemonize"):
+ daemonize = True
+ else:
+ print >> sys.stderr, "Unknown argument: %s" % o
+ print_help (sys.stderr, 1)
+
+ if daemonize:
+ if os.fork ():
+ sys.exit ()
+
+ launch_gconf ()
+
+if __name__ == "__main__":
+ main ()