summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHuang Peng <shawn.p.huang@gmail.com>2008-08-24 10:00:42 +0800
committerHuang Peng <shawn.p.huang@gmail.com>2008-08-24 10:00:42 +0800
commit99261ce1e497fbd6dc20a3b61a30bb3b60bcc3eb (patch)
treeae860da20e53346e4b2d988faf64fa24a480aa65
parentb512009d51575fa189ef46eaf21b36ea951d492a (diff)
downloadibus-99261ce1e497fbd6dc20a3b61a30bb3b60bcc3eb.tar.gz
ibus-99261ce1e497fbd6dc20a3b61a30bb3b60bcc3eb.tar.xz
ibus-99261ce1e497fbd6dc20a3b61a30bb3b60bcc3eb.zip
Support custom font.
-rw-r--r--panel/candidatepanel.py13
-rw-r--r--panel/panel.py27
2 files changed, 34 insertions, 6 deletions
diff --git a/panel/candidatepanel.py b/panel/candidatepanel.py
index 4052ecb..e1aad1e 100644
--- a/panel/candidatepanel.py
+++ b/panel/candidatepanel.py
@@ -26,6 +26,9 @@ import pango
import ibus
from ibus.gtk import PangoAttrList
+class Label(gtk.Label): pass
+gobject.type_register(Label, "IBusPanelLabel")
+
class HSeparator(gtk.HBox):
def __init__ (self):
gtk.HBox.__init__ (self)
@@ -54,11 +57,11 @@ class CandidateArea(gtk.HBox):
self.pack_start(self.__vbox2, True, True, 4)
for i in xrange(1, 11):
- label1 = gtk.Label("%d." % (i % 10))
+ label1 = Label("%d." % (i % 10))
label1.set_alignment(0.0, 0.5)
label1.set_no_show_all(True)
- label2 = gtk.Label()
+ label2 = Label()
label2.set_alignment(0.0, 0.5)
label2.set_no_show_all(True)
@@ -168,7 +171,7 @@ class CandidatePanel(gtk.VBox):
self.remove(w)
w.destroy()
# create preedit label
- self.__preedit_label = gtk.Label(self.__preedit_string)
+ self.__preedit_label = Label(self.__preedit_string)
self.__preedit_label.set_attributes(self.__preedit_attrs)
self.__preedit_label.set_alignment(0.0, 0.5)
self.__preedit_label.set_padding(8, 0)
@@ -177,7 +180,7 @@ class CandidatePanel(gtk.VBox):
self.__preedit_label.show()
# create aux label
- self.__aux_label = gtk.Label(self.__aux_string)
+ self.__aux_label = Label(self.__aux_string)
self.__aux_label.set_attributes(self.__aux_attrs)
self.__aux_label.set_alignment(0.0, 0.5)
self.__aux_label.set_padding(8, 0)
@@ -192,7 +195,7 @@ class CandidatePanel(gtk.VBox):
self.update_lookup_table(self.__lookup_table, self.__lookup_table_visible)
# create state label
- self.__state_label = gtk.Label()
+ self.__state_label = Label()
self.__state_label.set_size_request(20, -1)
# create buttons
diff --git a/panel/panel.py b/panel/panel.py
index 9948c6e..eb4ccf4 100644
--- a/panel/panel.py
+++ b/panel/panel.py
@@ -59,7 +59,6 @@ class Panel(ibus.PanelBase):
self.__language_bar.show_all()
self.__candidate_panel = CandidatePanel()
- self.__config_load_lookup_table_orientation()
self.__candidate_panel.connect("cursor-up",
lambda widget: self.cursor_up())
self.__candidate_panel.connect("cursor-down",
@@ -72,6 +71,10 @@ class Panel(ibus.PanelBase):
self.__status_icon.set_tooltip("iBus - Running")
self.__status_icon.set_visible(True)
+ self.__config_load_lookup_table_orientation()
+ self.__config_load_auto_hide()
+ self.__config_load_custom_font()
+
def set_cursor_location(self, x, y, w, h):
self.__candidate_panel.set_cursor_location(x + w, y + h)
@@ -185,9 +188,31 @@ class Panel(ibus.PanelBase):
else:
self.__candidate_panel.set_orientation(gtk.ORIENTATION_VERTICAL)
+ def __config_load_auto_hide(self):
+ self.__auto_hide = self.__bus.config_get_value("/panel/auto_hide", False)
+
+ def __config_load_custom_font(self):
+ self.__use_custom_font = self.__bus.config_get_value("/panel/use_custom_font", False)
+ font_name = gtk.settings_get_default().get_property("gtk-font-name")
+ self.__custom_font = self.__bus.config_get_value("/panel/custom_font", font_name)
+ style_string = 'style "custom-font" { font_name="%s" }\nclass "IBusPanelLabel" style "custom-font"\n'
+ if self.__use_custom_font:
+ style_string = style_string % self.__custom_font
+ gtk.rc_parse_string(style_string)
+ else:
+ style_string = style_string % ""
+ gtk.rc_parse_string(style_string)
+
+ settings = gtk.settings_get_default()
+ gtk.rc_reset_styles(settings)
+
def __config_value_changed_cb(self, bus, key, value):
if key == "/panel/lookup_table_orientation":
self.__config_load_lookup_table_orientation()
+ elif key == "/panel/auto_hide":
+ self.__config_load_auto_hide()
+ elif key == "/panel/use_custom_font" or key == "/panel/custom_font":
+ self.__config_load_custom_font()
def __config_reloaded_cb(self, bus):
pass