From 57877ac31e28b94cacb5c4b45974bed1b1381f7b Mon Sep 17 00:00:00 2001 From: Huang Peng Date: Mon, 23 Jun 2008 19:59:04 +0800 Subject: [PATCH] Position the popup menu. --- panel/languagebar.py | 4 +++- panel/panel.py | 36 ++---------------------------------- 2 files changed, 5 insertions(+), 35 deletions(-) diff --git a/panel/languagebar.py b/panel/languagebar.py index b4c43ff..f1497e0 100644 --- a/panel/languagebar.py +++ b/panel/languagebar.py @@ -25,6 +25,7 @@ import gobject import ibus from image import Image from handle import Handle +import menu ICON_SIZE = gtk.ICON_SIZE_MENU @@ -208,7 +209,8 @@ class LanguageBar (gtk.Toolbar): self.emit ("property-activate", prop._name, prop._state) def _property_menu_clicked (self, widget, prop, menu): - menu.popup (None, None, None, 0, 0) + menu.popup (None, None, menu.menu_position, + 0, gtk.get_current_event_time (), widget) gobject.type_register (LanguageBar, "IBusLanguageBar") diff --git a/panel/panel.py b/panel/panel.py index 1f51514..a7a6194 100644 --- a/panel/panel.py +++ b/panel/panel.py @@ -28,6 +28,7 @@ from lang import LANGUAGES from ibus import interface from languagebar import LanguageBar from candidatepanel import CandidatePanel +import menu class Panel (ibus.Object): def __init__ (self, proxy, _ibus): @@ -131,43 +132,10 @@ class Panel (ibus.Object): menu.set_take_focus (False) return menu - def _menu_position_cb (self, menu, button): - screen = button.get_screen () - monitor = screen.get_monitor_at_window (button.window) - monitor_allocation = screen.get_monitor_geometry (monitor) - - x, y = button.window.get_origin () - x += button.allocation.x - y += button.allocation.y - - menu_width, menu_height = menu.size_request () - - if x + menu_width >= monitor_allocation.width: - x -= menu_width - button.allocation.width - elif x - menu_width <= 0: - pass - else: - if x <= monitor_allocation.width * 3 / 4: - pass - else: - x -= menu_width - button.allocation.width - - if y + button.allocation.height + menu_height >= monitor_allocation.height: - y -= menu_height - elif y - menu_height <= 0: - y += button.allocation.height - else: - if y <= monitor_allocation.height * 3 / 4: - y += button.allocation.height - else: - y -= menu_height - - return (x, y, False) - def _im_menu_popup_cb (self, languagebar, button): menu = self._create_im_menu () menu.popup (None, None, - self._menu_position_cb, + menu.menu_position, 0, gtk.get_current_event_time (), button) -- 2.7.4