[Sugar-devel] [PATCH sugar] Frame: reveal Palette on left click for device, friends and clipboard items v2
Manuel Quiñones
manuq at laptop.org
Mon Aug 20 22:30:03 EDT 2012
Have to say this again: interaction with the frame elemenst is much
better and less error prone with this patch.
2012/8/19 Simon Schampijer <simon at schampijer.de>:
> 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 and the battery item. For the volume
> item I opened a design discussion, it can be merged into that patch
> after agreement. 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 at laptop.org>
Acked-by: Manuel Quiñones <manuq at laptop.org>
> [1] http://developer.gnome.org/gtk3/3.4/GtkToggleToolButton.html#gtk-toggle-tool-button-set-active
>
> ---v2---
> Add bhavior for the Frame Device icon Volumes like discussed in:
Just note "bhavior" misspelling.
> http://lists.sugarlabs.org/archive/sugar-devel/2012-August/thread.html#39074
> ---
> extensions/deviceicon/battery.py | 5 +++++
> extensions/deviceicon/network.py | 20 ++++++++++++++++++++
> extensions/deviceicon/volume.py | 28 ++++++++++++++++++++++++----
> src/jarabe/frame/clipboardicon.py | 7 +++++++
> src/jarabe/frame/friendstray.py | 5 +++++
> 5 files changed, 61 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):
> diff --git a/src/jarabe/frame/clipboardicon.py b/src/jarabe/frame/clipboardicon.py
> index 315cdaa..ebf3ad1 100644
> --- a/src/jarabe/frame/clipboardicon.py
> +++ b/src/jarabe/frame/clipboardicon.py
> @@ -61,6 +61,7 @@ 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):
> @@ -68,6 +69,12 @@ 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 26a279b..eaae1fa 100644
> --- a/src/jarabe/frame/friendstray.py
> +++ b/src/jarabe/frame/friendstray.py
> @@ -33,6 +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)
>
> def create_palette(self):
> palette = BuddyMenu(self._buddy)
> @@ -40,6 +41,10 @@ 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):
> --
> 1.7.11.4
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
--
.. manuq ..
More information about the Sugar-devel
mailing list