From da5e3e0a76a7a9222a4a36d251aeff7c8d227f5b Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Mon, 22 Oct 2012 14:08:54 +0000 Subject: Frame: use the new toggle_palette invoker property, SL #4065 For the device icons, the friends icons and the clipboard ones we use the toggle_palette invoker property to achieve the following behavior: the Palette will popup/popdown on button left click/touch tap. The property has been added in c4165967d5e05607db8b3e0969b516da87855431 to the toolkit. For the network device icons OlpcMeshDeviceView and WirelessDeviceView we do have to set an extra property to make this work. They are ToolButtons and not TrayIcons like the other icons. By default the toolbutton does popdown the Palette on a click. Signed-off-by: Simon Schampijer Acked-by: Manuel QuiƱones --- (limited to 'src') diff --git a/src/jarabe/desktop/networkviews.py b/src/jarabe/desktop/networkviews.py index 64b4be3..c7d21c6 100644 --- a/src/jarabe/desktop/networkviews.py +++ b/src/jarabe/desktop/networkviews.py @@ -86,12 +86,11 @@ class WirelessNetworkView(EventPulsingIcon): (xocolor.colors[index][0], xocolor.colors[index][1])) - self.connect('button-release-event', self.__button_release_event_cb) - pulse_color = XoColor('%s,%s' % (style.COLOR_BUTTON_GREY.get_svg(), style.COLOR_TRANSPARENT.get_svg())) self.props.pulse_color = pulse_color + self.props.palette_invoker.props.toggle_palette = True self._palette = self._create_palette() self.set_palette(self._palette) self._palette_icon.props.xo_color = self._color @@ -332,10 +331,6 @@ class WirelessNetworkView(EventPulsingIcon): def __connect_activate_cb(self, icon): self._connect() - def __button_release_event_cb(self, icon, event): - self._palette.popup(immediate=True, - state=palette.Palette.SECONDARY) - def _connect(self): # Activate existing connection, if there is one connection = network.find_connection_by_ssid(self._ssid) diff --git a/src/jarabe/frame/clipboardicon.py b/src/jarabe/frame/clipboardicon.py index 1cee867..81b3131 100644 --- a/src/jarabe/frame/clipboardicon.py +++ b/src/jarabe/frame/clipboardicon.py @@ -40,6 +40,7 @@ class ClipboardIcon(RadioToolButton): RadioToolButton.__init__(self, group=group) self.props.palette_invoker = FrameWidgetInvoker(self) + self.palette_invoker.props.toggle_palette = True self._cb_object = cb_object self.owns_clipboard = False @@ -62,7 +63,6 @@ class ClipboardIcon(RadioToolButton): child = self.get_child() child.connect('drag_data_get', self._drag_data_get_cb) - child.connect('button-release-event', self.__button_release_event_cb) self.connect('notify::active', self._notify_active_cb) def create_palette(self): @@ -70,12 +70,6 @@ class ClipboardIcon(RadioToolButton): palette.set_group_id('frame') return palette - def __button_release_event_cb(self, widget, event): - if event.button != 1: - return False - self.props.palette_invoker.notify_right_click() - return False - def get_object_id(self): return self._cb_object.get_id() diff --git a/src/jarabe/frame/friendstray.py b/src/jarabe/frame/friendstray.py index 00d951f..099a3b6 100644 --- a/src/jarabe/frame/friendstray.py +++ b/src/jarabe/frame/friendstray.py @@ -33,7 +33,7 @@ class FriendIcon(TrayIcon): self._buddy = buddy self.set_palette_invoker(FrameWidgetInvoker(self)) self.palette_invoker.cache_palette = False - self.connect('button-release-event', self.__button_release_event_cb) + self.palette_invoker.props.toggle_palette = True def create_palette(self): palette = BuddyMenu(self._buddy) @@ -41,10 +41,6 @@ class FriendIcon(TrayIcon): palette.set_group_id('frame') return palette - def __button_release_event_cb(self, widget, event): - self.palette_invoker.notify_right_click() - return True - class FriendsTray(VTray): def __init__(self): -- cgit v0.9.1