From: Peng Huang Date: Sat, 28 Nov 2009 07:38:41 +0000 (+0800) Subject: Remember panel position X-Git-Tag: 1.2.0.20091204~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=89a1e54e0761d7d4d0bb5c3ac3dd6c6893ab2c68;p=platform%2Fupstream%2Fibus.git Remember panel position --- diff --git a/data/ibus.schemas.in b/data/ibus.schemas.in index 019557e..466ca76 100644 --- a/data/ibus.schemas.in +++ b/data/ibus.schemas.in @@ -60,6 +60,39 @@ + /schemas/desktop/ibus/panel/x + /desktop/ibus/panel/x + ibus + int + -1 + + Position of panel + + + + /schemas/desktop/ibus/panel/y + /desktop/ibus/panel/y + ibus + int + -1 + + Position of panel + + + + /schemas/desktop/ibus/panel/lookup_table_orientation /desktop/ibus/panel/lookup_table_orientation ibus diff --git a/setup/main.py b/setup/main.py index f454b44..1ac0de7 100644 --- a/setup/main.py +++ b/setup/main.py @@ -140,19 +140,22 @@ class Setup(object): self.__config.get_value("panel", "show", 1)) self.__combobox_panel_show.connect("changed", self.__combobox_panel_show_changed_cb) + # panel position + self.__combobox_panel_position = self.__builder.get_object("combobox_panel_position") + self.__combobox_panel_position.set_active( + self.__config.get_value("panel", "position", 3)) + self.__combobox_panel_position.connect("changed", self.__combobox_panel_position_changed_cb) + # custom font self.__checkbutton_custom_font = self.__builder.get_object("checkbutton_custom_font") self.__checkbutton_custom_font.set_active( self.__config.get_value("panel", "use_custom_font", False)) self.__checkbutton_custom_font.connect("toggled", self.__checkbutton_custom_font_toggled_cb) - self.__label_custom_font = self.__builder.get_object("label_custom_font") self.__fontbutton_custom_font = self.__builder.get_object("fontbutton_custom_font") if self.__config.get_value("panel", "use_custom_font", False): - self.__label_custom_font.set_sensitive(True) self.__fontbutton_custom_font.set_sensitive(True) else: - self.__label_custom_font.set_sensitive(False) self.__fontbutton_custom_font.set_sensitive(False) font_name = gtk.settings_get_default().get_property("gtk-font-name") font_name = unicode(font_name, "utf-8") @@ -375,13 +378,16 @@ class Setup(object): "panel", "show", self.__combobox_panel_show.get_active()) + def __combobox_panel_position_changed_cb(self, combobox): + self.__config.set_value( + "panel", "position", + self.__combobox_panel_position.get_active()) + def __checkbutton_custom_font_toggled_cb(self, button): if self.__checkbutton_custom_font.get_active(): - self.__label_custom_font.set_sensitive(True) self.__fontbutton_custom_font.set_sensitive(True) self.__config.set_value("panel", "use_custom_font", True) else: - self.__label_custom_font.set_sensitive(False) self.__fontbutton_custom_font.set_sensitive(False) self.__config.set_value("panel", "use_custom_font", False) diff --git a/setup/setup.ui b/setup/setup.ui index c2d608c..89ce5fb 100644 --- a/setup/setup.ui +++ b/setup/setup.ui @@ -2,7 +2,7 @@ - + @@ -16,7 +16,7 @@ - + @@ -275,7 +275,7 @@ True - model1 + model_candidates_orientation @@ -312,7 +312,7 @@ True - model2 + model_panel_show_mode @@ -330,26 +330,47 @@ - - Show icon on system tray - True - True - False - True - Show icon on system tray - True + + True + True + + + 0 + Language panel position: + right + + + False + 0 + + + + + model_panel_position + + + + 0 + + + + + 1 + + 2 - - Show input method name on language bar + + Show icon on system tray True True False - Show input method's name on language bar when check the checkbox + True + Show icon on system tray True @@ -357,13 +378,12 @@ - - Use custom font + + Show input method name on language bar True True False - Use custom font for language bar and candidates - True + Show input method's name on language bar when check the checkbox True @@ -371,14 +391,17 @@ - + True + True - + + Use custom font True - Font for language bar and candidates - 0 - Custom font: + True + False + True + True 0 @@ -388,7 +411,7 @@ True True - False + True 1 @@ -841,4 +864,27 @@ Homepage: http://code.google.com/p/ibus + + + + + + + + Top left corner + + + Top right corner + + + Bottom left corner + + + Bottom right corner + + + Custom + + + diff --git a/ui/gtk/languagebar.py b/ui/gtk/languagebar.py index 4e7dcc6..604df12 100644 --- a/ui/gtk/languagebar.py +++ b/ui/gtk/languagebar.py @@ -54,7 +54,10 @@ class LanguageBar(gtk.Toolbar): gobject.SIGNAL_RUN_LAST, gobject.TYPE_PYOBJECT, ()), - + "position-changed" : ( + gobject.SIGNAL_RUN_LAST, + gobject.TYPE_NONE, + (gobject.TYPE_INT, gobject.TYPE_INT)), } def __init__ (self): @@ -80,8 +83,7 @@ class LanguageBar(gtk.Toolbar): except: w, h = root.get_size() self.__work_area = 0, 0, w, h - self.__position = self.__work_area[0] + self.__work_area[2] - 20, self.__work_area[1] + self.__work_area[3] - 20 - self.__toplevel.move(*self.__position) + self.set_position(-1, -1) def __create_ui(self): # create move handle @@ -125,10 +127,11 @@ class LanguageBar(gtk.Toolbar): x, y = self.__toplevel.get_position() w, h = self.__toplevel.get_size() self.__position = x + w, y + h + self.emit("position-changed", *self.__position) def __toplevel_size_allocate_cb(self, toplevel, allocation): x, y = self.__position - if x - self.__work_area[0] >= self.__work_area[2] - 80: + if x - self.__work_area[0] >= self.__work_area[2] - 80 or True: self.__toplevel.move(x - allocation.width, y - allocation.height) def __remove_properties(self): @@ -195,6 +198,19 @@ class LanguageBar(gtk.Toolbar): else: self.focus_out() + def set_position(self, x, y): + if x < 0 or y < 0: + x = self.__work_area[0] + self.__work_area[2] - 20 + y = self.__work_area[1] + self.__work_area[3] - 20 + if x > self.__work_area[2]: + x = self.__work_area[0] + self.__work_area[2] - 20 + if y > self.__work_area[3]: + y = self.__work_area[1] + self.__work_area[3] - 20 + + self.__position = x, y + w, h = self.__toplevel.get_size() + self.__toplevel.move(self.__position[0] - w, self.__position[1] - h) + def get_show(self): return self.__show diff --git a/ui/gtk/panel.py b/ui/gtk/panel.py index 08ffe4d..615eb58 100644 --- a/ui/gtk/panel.py +++ b/ui/gtk/panel.py @@ -88,6 +88,8 @@ class Panel(ibus.PanelBase): self.__get_im_menu_cb) self.__language_bar.connect("show-engine-about", self.__show_engine_about_cb) + self.__language_bar.connect("position-changed", + self.__position_changed_cb) self.__language_bar.focus_out() self.__language_bar.show_all() @@ -113,6 +115,7 @@ class Panel(ibus.PanelBase): self.__config_load_lookup_table_orientation() self.__config_load_show() + self.__config_load_position() self.__config_load_custom_font() self.__config_load_show_icon_on_systray() self.__config_load_show_im_name() @@ -264,6 +267,12 @@ class Panel(ibus.PanelBase): show = self.__config.get_value("panel", "show", 1) self.__language_bar.set_show(show) + def __config_load_position(self): + position = self.__config.get_value("panel", "position", 3) + x = self.__config.get_value("panel", "x", -1) + y = self.__config.get_value("panel", "y", -1) + self.__language_bar.set_position(x, y) + def __config_load_custom_font(self): use_custom_font = self.__config.get_value("panel", "use_custom_font", False) font_name = gtk.settings_get_default().get_property("gtk-font-name") @@ -296,6 +305,8 @@ class Panel(ibus.PanelBase): self.__config_load_lookup_table_orientation() elif name == "show": self.__config_load_show() + # elif name == "position": + # self.__config_load_position() elif name == "use_custom_font" or name == "custom_font": self.__config_load_custom_font() elif name == "show_icon_on_systray": @@ -387,7 +398,7 @@ class Panel(ibus.PanelBase): menu = self.__create_im_menu() return menu - def __show_engine_about_cb(self, langiagebar): + def __show_engine_about_cb(self, langagebar): try: engine = self.__focus_ic.get_engine() dlg = EngineAbout(engine) @@ -396,6 +407,10 @@ class Panel(ibus.PanelBase): except: pass + def __position_changed_cb(self, langagebar, x, y): + self.__config.set_value("panel", "x", x) + self.__config.set_value("panel", "y", y) + def __status_icon_popup_menu_cb(self, status_icon, button, active_time): menu = self.__create_sys_menu() menu.popup(None, None,