diff options
author | Simon Schampijer <simon@schampijer.de> | 2012-08-16 08:16:31 (GMT) |
---|---|---|
committer | Simon Schampijer <simon@schampijer.de> | 2012-08-21 03:42:57 (GMT) |
commit | d0f3471a38b7b5a13fc841f48ab475afb76b878b (patch) | |
tree | 58e3a72ccf48347cb1971d24bb28ca986470266f /extensions | |
parent | 3aa88a85143c48b64cf57ab7c79b4531dcfa6e8b (diff) |
Frame: reveal Palette on left click for device, friends and clipboard items
In previous design discussions we agreed on making the Palette appear
immediately on left click. Actually some device icons like Speech or
Speaker have been already doing this.
The device icons that change to that behavior with this patch
are: all the network items, the volume item and the battery item.
All the items are listening to the 'button-release-event'
and do not propagate the event further after revealing the Palette.
The Friends items behave the same as the device icons technically
(both are TrayIcons) and UI-wise.
We could think about handling the left click directly in the TrayIcon
there are a few exceptions like the touchpad device icon and the volume
icons which do have a primary action on left click.
As well the clipboard icons will reveal now the Palette on left
click. This is also true when selecting a clipboard item. Technically we
have to listen to the 'button-release-event' of the child widget
as the RadioToolButton does only emit a clicked signal. Using this
would colide with the state changes of the clipboard items as those
emit a signal [1]. We do let the event propagate further
(return False) so that the state change when selecting another
item is picked up.
Signed-off-by: Simon Schampijer <simon@laptop.org>
Acked-by: Manuel QuiƱones <manuq@laptop.org>
[1] http://developer.gnome.org/gtk3/3.4/GtkToggleToolButton.html#gtk-toggle-tool-button-set-active
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/deviceicon/battery.py | 5 | ||||
-rw-r--r-- | extensions/deviceicon/network.py | 20 | ||||
-rw-r--r-- | extensions/deviceicon/volume.py | 28 |
3 files changed, 49 insertions, 4 deletions
diff --git a/extensions/deviceicon/battery.py b/extensions/deviceicon/battery.py index a70458a..5a6d99a 100644 --- a/extensions/deviceicon/battery.py +++ b/extensions/deviceicon/battery.py @@ -70,10 +70,15 @@ class DeviceView(TrayIcon): self._model = DeviceModel(battery) self.palette = BatteryPalette(glib.markup_escape_text(_('My Battery'))) self.palette.set_group_id('frame') + self.connect('button-release-event', self.__button_release_event_cb) self._model.connect('updated', self.__battery_status_changed_cb) self._update_info() + def __button_release_event_cb(self, widget, event): + self.palette_invoker.notify_right_click() + return True + def _update_info(self): name = _ICON_NAME current_level = self._model.props.level diff --git a/extensions/deviceicon/network.py b/extensions/deviceicon/network.py index 96713fb..ff451f4 100644 --- a/extensions/deviceicon/network.py +++ b/extensions/deviceicon/network.py @@ -400,6 +400,7 @@ class WirelessDeviceView(ToolButton): self.__deactivate_connection_cb) self.set_palette(self._palette) self._palette.set_group_id('frame') + self.connect('clicked', self.__toolbutton_clicked_cb) self._device_props = dbus.Interface(self._device, dbus.PROPERTIES_IFACE) @@ -569,6 +570,10 @@ class WirelessDeviceView(ToolButton): def __activate_error_cb(self, err): logging.debug('Failed to create network: %s', err) + def __toolbutton_clicked_cb(self, button): + self.palette_invoker.notify_right_click() + return True + class OlpcMeshDeviceView(ToolButton): _ICON_NAME = 'network-mesh' @@ -600,6 +605,7 @@ class OlpcMeshDeviceView(ToolButton): self.__deactivate_connection) self.set_palette(self._palette) self._palette.set_group_id('frame') + self.connect('clicked', self.__toolbutton_clicked_cb) self.update_state(state) @@ -684,6 +690,10 @@ class OlpcMeshDeviceView(ToolButton): except dbus.exceptions.DBusException: pass + def __toolbutton_clicked_cb(self, button): + self.palette_invoker.notify_right_click() + return True + class WiredDeviceView(TrayIcon): @@ -701,6 +711,11 @@ class WiredDeviceView(TrayIcon): self.set_palette(self._palette) self._palette.set_group_id('frame') self._palette.set_connected(speed, address) + self.connect('button-release-event', self.__button_release_event_cb) + + def __button_release_event_cb(self, widget, event): + self.palette_invoker.notify_right_click() + return True class GsmDeviceView(TrayIcon): @@ -721,6 +736,7 @@ class GsmDeviceView(TrayIcon): self._device = device self._palette = None self.set_palette_invoker(FrameWidgetInvoker(self)) + self.connect('button-release-event', self.__button_release_event_cb) self._bus.add_signal_receiver(self.__state_changed_cb, signal_name='StateChanged', @@ -747,6 +763,10 @@ class GsmDeviceView(TrayIcon): return palette + def __button_release_event_cb(self, widget, event): + self.palette_invoker.notify_right_click() + return True + def __gsm_connect_cb(self, palette, data=None): connection = network.find_gsm_connection() if connection is not None: diff --git a/extensions/deviceicon/volume.py b/extensions/deviceicon/volume.py index ea2377d..49e3711 100644 --- a/extensions/deviceicon/volume.py +++ b/extensions/deviceicon/volume.py @@ -15,6 +15,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import logging +from gettext import gettext as _ import gobject import gio @@ -23,6 +24,8 @@ import gconf from sugar.graphics.tray import TrayIcon from sugar.graphics.xocolor import XoColor +from sugar.graphics.menuitem import MenuItem +from sugar.graphics.icon import Icon from jarabe.journal import journalactivity from jarabe.view.palettes import VolumePalette @@ -40,16 +43,17 @@ class DeviceView(TrayIcon): self._mount = mount - icon_name = None + self._icon_name = None icon_theme = gtk.icon_theme_get_default() for icon_name in self._mount.get_icon().props.names: icon_info = icon_theme.lookup_icon(icon_name, gtk.ICON_SIZE_LARGE_TOOLBAR, 0) if icon_info is not None: + self._icon_name = icon_name break - if icon_name is None: - icon_name = 'drive' + if self._icon_name is None: + self._icon_name = 'drive' # TODO: retrieve the colors from the owner of the device client = gconf.client_get_default() @@ -64,13 +68,29 @@ class DeviceView(TrayIcon): def create_palette(self): palette = VolumePalette(self._mount) palette.set_group_id('frame') + + menu_item = MenuItem(_('Show contents')) + client = gconf.client_get_default() + color = XoColor(client.get_string('/desktop/sugar/user/color')) + icon = Icon(icon_name=self._icon_name, icon_size=gtk.ICON_SIZE_MENU, + xo_color=color) + menu_item.set_image(icon) + icon.show() + + menu_item.connect('activate', self.__show_contents_cb) + palette.menu.insert(menu_item, 0) + menu_item.show() + return palette def __button_release_event_cb(self, widget, event): + self.palette_invoker.notify_right_click() + return True + + def __show_contents_cb(self, menu_item): journal = journalactivity.get_journal() journal.set_active_volume(self._mount) journal.reveal() - return True def setup(tray): |