Ticket #4065: toggle_state.patch

File toggle_state.patch, 10.8 KB (added by erikos, 11 years ago)

Shell patch that changes the device icons to set the toggle propperty available in the toolkit

  • extensions/deviceicon/battery.py

    diff --git a/extensions/deviceicon/battery.py b/extensions/deviceicon/battery.py
    index fa1a40d..7fcca8d 100644
    a b class DeviceView(TrayIcon): 
    6969        self._model = DeviceModel(battery)
    7070        self.palette = BatteryPalette(glib.markup_escape_text(_('My Battery')))
    7171        self.palette.set_group_id('frame')
    72         self.connect('button-release-event', self.__button_release_event_cb)
     72        self.palette_invoker.props.toggle_palette = True
    7373        self._model.connect('updated',
    7474                            self.__battery_status_changed_cb)
    7575        self._update_info()
    7676
    77     def __button_release_event_cb(self, widget, event):
    78         self.palette_invoker.notify_right_click()
    79         return True
    80 
    8177    def _update_info(self):
    8278        name = _ICON_NAME
    8379        current_level = self._model.props.level
  • extensions/deviceicon/network.py

    diff --git a/extensions/deviceicon/network.py b/extensions/deviceicon/network.py
    index f014418..b8724e3 100644
    a b class WirelessDeviceView(ToolButton): 
    399399        self._icon.show()
    400400
    401401        self.set_palette_invoker(FrameWidgetInvoker(self))
     402        self.palette_invoker.props.toggle_palette = True
     403
    402404        self._palette = WirelessPalette(self._display_name)
    403405        self._palette.connect('deactivate-connection',
    404406                              self.__deactivate_connection_cb)
    405407        self.set_palette(self._palette)
    406408        self._palette.set_group_id('frame')
    407         self.connect('clicked', self.__toolbutton_clicked_cb)
    408409
    409410        self._device_props = dbus.Interface(self._device,
    410411                                            dbus.PROPERTIES_IFACE)
    class WirelessDeviceView(ToolButton): 
    575576    def __activate_error_cb(self, err):
    576577        logging.debug('Failed to create network: %s', err)
    577578
    578     def __toolbutton_clicked_cb(self, button):
    579         self.palette_invoker.notify_right_click()
    580         return True
    581 
    582579
    583580class OlpcMeshDeviceView(ToolButton):
    584581    _ICON_NAME = 'network-mesh'
    class OlpcMeshDeviceView(ToolButton): 
    604601        self._icon.show()
    605602
    606603        self.set_palette_invoker(FrameWidgetInvoker(self))
     604        self.palette_invoker.props.toggle_palette = True
     605
    607606        title = _('Mesh Network')
    608607        self._palette = WirelessPalette(glib.markup_escape_text(title))
    609608        self._palette.connect('deactivate-connection',
    610609                              self.__deactivate_connection)
    611610        self.set_palette(self._palette)
    612611        self._palette.set_group_id('frame')
    613         self.connect('clicked', self.__toolbutton_clicked_cb)
    614612
    615613        self.update_state(state)
    616614
    class OlpcMeshDeviceView(ToolButton): 
    695693            except dbus.exceptions.DBusException:
    696694                pass
    697695
    698     def __toolbutton_clicked_cb(self, button):
    699         self.palette_invoker.notify_right_click()
    700         return True
    701 
    702696
    703697class WiredDeviceView(TrayIcon):
    704698
    class WiredDeviceView(TrayIcon): 
    716710        self.set_palette(self._palette)
    717711        self._palette.set_group_id('frame')
    718712        self._palette.set_connected(speed, address)
    719         self.connect('button-release-event', self.__button_release_event_cb)
    720 
    721     def __button_release_event_cb(self, widget, event):
    722         self.palette_invoker.notify_right_click()
    723         return True
     713        self.palette_invoker.props.toggle_palette = True
    724714
    725715
    726716class GsmDeviceView(TrayIcon):
    class GsmDeviceView(TrayIcon): 
    742732        self._device = device
    743733        self._palette = None
    744734        self.set_palette_invoker(FrameWidgetInvoker(self))
    745         self.connect('button-release-event', self.__button_release_event_cb)
     735        self.palette_invoker.props.toggle_palette = True
    746736
    747737        self._bus.add_signal_receiver(self.__state_changed_cb,
    748738                                      signal_name='StateChanged',
    class GsmDeviceView(TrayIcon): 
    769759
    770760        return palette
    771761
    772     def __button_release_event_cb(self, widget, event):
    773         self.palette_invoker.notify_right_click()
    774         return True
    775 
    776762    def __gsm_connect_cb(self, palette, data=None):
    777763        connection = network.find_gsm_connection()
    778764        if connection is not None:
  • extensions/deviceicon/speaker.py

    diff --git a/extensions/deviceicon/speaker.py b/extensions/deviceicon/speaker.py
    index 5dab329..8260d49 100644
    a b class DeviceView(TrayIcon): 
    4646        TrayIcon.__init__(self, icon_name=_ICON_NAME, xo_color=self._color)
    4747
    4848        self.set_palette_invoker(FrameWidgetInvoker(self))
     49        self.palette_invoker.props.toggle_palette = True
    4950
    5051        self._model = DeviceModel()
    5152        self._model.connect('notify::level', self.__speaker_status_changed_cb)
    class DeviceView(TrayIcon): 
    5354
    5455        self.connect('draw', self.__draw_cb)
    5556
    56         self._icon_widget.connect('button-release-event',
    57                                   self.__button_release_event_cb)
    58 
    5957        self._update_info()
    6058
    6159    def create_palette(self):
    class DeviceView(TrayIcon): 
    7876                                                   step=-1)
    7977        self.icon.props.xo_color = xo_color
    8078
    81     def __button_release_event_cb(self, widget, event):
    82         if event.button != 1:
    83             return False
    84 
    85         self.palette_invoker.notify_right_click()
    86         return True
    87 
    8879    def __draw_cb(self, *args):
    8980        self._update_info()
    9081
  • extensions/deviceicon/speech.py

    diff --git a/extensions/deviceicon/speech.py b/extensions/deviceicon/speech.py
    index c3115f7..1f7bf02 100644
    a b class SpeechDeviceView(TrayIcon): 
    4545        self._color = XoColor(client.get_string('/desktop/sugar/user/color'))
    4646        TrayIcon.__init__(self, icon_name=_ICON_NAME, xo_color=self._color)
    4747        self.set_palette_invoker(FrameWidgetInvoker(self))
     48        self.palette_invoker.props.toggle_palette = True
     49
    4850        self._manager = speech.get_speech_manager()
    49         self._icon_widget.connect('button-release-event',
    50                                   self.__button_release_event_cb)
    5151
    5252    def create_palette(self):
    5353        label = glib.markup_escape_text(_('Speech'))
    class SpeechDeviceView(TrayIcon): 
    5555        palette.set_group_id('frame')
    5656        return palette
    5757
    58     def __button_release_event_cb(self, widget, event):
    59         self.palette_invoker.notify_right_click()
    60         return True
    61 
    6258
    6359class SpeechPalette(Palette):
    6460
  • extensions/deviceicon/volume.py

    diff --git a/extensions/deviceicon/volume.py b/extensions/deviceicon/volume.py
    index f1f223c..6930811 100644
    a b class DeviceView(TrayIcon): 
    6464        TrayIcon.__init__(self, icon_name=icon_name, xo_color=color)
    6565
    6666        self.set_palette_invoker(FrameWidgetInvoker(self))
    67 
    68         self.connect('button-release-event', self.__button_release_event_cb)
     67        self.palette_invoker.props.toggle_palette = True
    6968
    7069    def create_palette(self):
    7170        palette = VolumePalette(self._mount)
    class DeviceView(TrayIcon): 
    8685
    8786        return palette
    8887
    89     def __button_release_event_cb(self, widget, event):
    90         self.palette_invoker.notify_right_click()
    91         return True
    92 
    9388    def __show_contents_cb(self, menu_item):
    9489        journal = journalactivity.get_journal()
    9590        journal.set_active_volume(self._mount)
  • src/jarabe/desktop/networkviews.py

    diff --git a/src/jarabe/desktop/networkviews.py b/src/jarabe/desktop/networkviews.py
    index 64b4be3..c7d21c6 100644
    a b class WirelessNetworkView(EventPulsingIcon): 
    8686                                          (xocolor.colors[index][0],
    8787                                           xocolor.colors[index][1]))
    8888
    89         self.connect('button-release-event', self.__button_release_event_cb)
    90 
    9189        pulse_color = XoColor('%s,%s' % (style.COLOR_BUTTON_GREY.get_svg(),
    9290                                         style.COLOR_TRANSPARENT.get_svg()))
    9391        self.props.pulse_color = pulse_color
    9492
     93        self.props.palette_invoker.props.toggle_palette = True
    9594        self._palette = self._create_palette()
    9695        self.set_palette(self._palette)
    9796        self._palette_icon.props.xo_color = self._color
    class WirelessNetworkView(EventPulsingIcon): 
    332331    def __connect_activate_cb(self, icon):
    333332        self._connect()
    334333
    335     def __button_release_event_cb(self, icon, event):
    336         self._palette.popup(immediate=True,
    337                             state=palette.Palette.SECONDARY)
    338 
    339334    def _connect(self):
    340335        # Activate existing connection, if there is one
    341336        connection = network.find_connection_by_ssid(self._ssid)
  • src/jarabe/frame/clipboardicon.py

    diff --git a/src/jarabe/frame/clipboardicon.py b/src/jarabe/frame/clipboardicon.py
    index 1cee867..81b3131 100644
    a b class ClipboardIcon(RadioToolButton): 
    4040        RadioToolButton.__init__(self, group=group)
    4141
    4242        self.props.palette_invoker = FrameWidgetInvoker(self)
     43        self.palette_invoker.props.toggle_palette = True
    4344
    4445        self._cb_object = cb_object
    4546        self.owns_clipboard = False
    class ClipboardIcon(RadioToolButton): 
    6263
    6364        child = self.get_child()
    6465        child.connect('drag_data_get', self._drag_data_get_cb)
    65         child.connect('button-release-event', self.__button_release_event_cb)
    6666        self.connect('notify::active', self._notify_active_cb)
    6767
    6868    def create_palette(self):
    class ClipboardIcon(RadioToolButton): 
    7070        palette.set_group_id('frame')
    7171        return palette
    7272
    73     def __button_release_event_cb(self, widget, event):
    74         if event.button != 1:
    75             return False
    76         self.props.palette_invoker.notify_right_click()
    77         return False
    78 
    7973    def get_object_id(self):
    8074        return self._cb_object.get_id()
    8175
  • src/jarabe/frame/friendstray.py

    diff --git a/src/jarabe/frame/friendstray.py b/src/jarabe/frame/friendstray.py
    index 00d951f..099a3b6 100644
    a b class FriendIcon(TrayIcon): 
    3333        self._buddy = buddy
    3434        self.set_palette_invoker(FrameWidgetInvoker(self))
    3535        self.palette_invoker.cache_palette = False
    36         self.connect('button-release-event', self.__button_release_event_cb)
     36        self.palette_invoker.props.toggle_palette = True
    3737
    3838    def create_palette(self):
    3939        palette = BuddyMenu(self._buddy)
    class FriendIcon(TrayIcon): 
    4141        palette.set_group_id('frame')
    4242        return palette
    4343
    44     def __button_release_event_cb(self, widget, event):
    45         self.palette_invoker.notify_right_click()
    46         return True
    47 
    4844
    4945class FriendsTray(VTray):
    5046    def __init__(self):