[Sugar-devel] [PATCH sugar] Frame: reveal Palette on left click for device, friends and clipboard items

Manuel Quiñones manuq at laptop.org
Thu Aug 16 08:28:40 EDT 2012


Great.

For the exceptions, tray icons that have a primary action, we can
rethink this in the future, as we are mixing primary actions and
palettes.

2012/8/16 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
> ---
>  extensions/deviceicon/battery.py  |  5 +++++
>  extensions/deviceicon/network.py  | 20 ++++++++++++++++++++
>  src/jarabe/frame/clipboardicon.py |  7 +++++++
>  src/jarabe/frame/friendstray.py   |  5 +++++
>  4 files changed, 37 insertions(+)
>
> 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/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