Ticket #4283: 0001-ActivityIcon-in-neighborhood-port-to-custom-Palette-.patch

File 0001-ActivityIcon-in-neighborhood-port-to-custom-Palette-.patch, 3.3 KB (added by manuq, 10 years ago)

Patch.

  • src/jarabe/desktop/meshbox.py

    From 4e59c2a87f542296d1c0c25cc1b283fe658bcdd6 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
    Date: Tue, 11 Dec 2012 11:37:47 -0300
    Subject: [PATCH shell] ActivityIcon in neighborhood: port to custom Palette -
     SL #4283
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
    
    As per other icons in the same view, use custom Palette which has a
    toggle_palette property in the invoker that makes the popup/popdown
    occur on left click or tap.
    
    See commit a390ed68 for reference.
    
    Signed-off-by: Manuel Quiñones <manuq@laptop.org>
    ---
     src/jarabe/desktop/meshbox.py | 29 +++++++++++++++++------------
     1 file changed, 17 insertions(+), 12 deletions(-)
    
    diff --git a/src/jarabe/desktop/meshbox.py b/src/jarabe/desktop/meshbox.py
    index b79dd02..bc5dbde 100644
    a b from sugar3.graphics.icon import Icon 
    3030from sugar3.graphics.icon import CanvasIcon
    3131from sugar3.graphics import style
    3232from sugar3.graphics.palette import Palette
    33 from sugar3.graphics.menuitem import MenuItem
     33from sugar3.graphics.palettemenu import PaletteMenuBox
     34from sugar3.graphics.palettemenu import PaletteMenuItem
    3435
    3536from jarabe.model import neighborhood
    3637from jarabe.model.buddy import get_owner_instance
    class _ActivityIcon(CanvasIcon): 
    5758                 size=style.STANDARD_ICON_SIZE):
    5859        CanvasIcon.__init__(self, file_name=file_name,
    5960                            xo_color=xo_color, pixel_size=size)
     61
    6062        self._model = model
    61         self.connect('button-release-event',
    62                      self.__button_release_event_cb)
     63        self.palette_invoker.props.toggle_palette = True
    6364
    6465    def create_palette(self):
    6566        primary_text = GLib.markup_escape_text(self._model.bundle.get_name())
    class _ActivityIcon(CanvasIcon): 
    7576        private = self._model.props.private
    7677        joined = get_owner_instance() in self._model.props.buddies
    7778
     79        menu_box = PaletteMenuBox()
     80
    7881        if joined:
    79             item = MenuItem(_('Resume'), 'activity-start')
     82            item = PaletteMenuItem(_('Resume'))
     83            icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name='activity-start')
     84            item.set_image(icon)
    8085            item.connect('activate', self.__palette_item_clicked_cb)
    81             item.show()
    82             palette.menu.append(item)
     86            menu_box.append_item(item)
    8387        elif not private:
    84             item = MenuItem(_('Join'), 'activity-start')
     88            item = PaletteMenuItem(_('Join'))
     89            icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name='activity-start')
     90            item.set_image(icon)
    8591            item.connect('activate', self.__palette_item_clicked_cb)
    86             item.show()
    87             palette.menu.append(item)
     92            menu_box.append_item(item)
     93
     94        palette.set_content(menu_box)
     95        menu_box.show_all()
    8896
    8997        self.connect_to_palette_pop_events(palette)
    9098        return palette
    9199
    92     def __button_release_event_cb(self, widget, event):
    93         self.props.palette.popup(immediate=True, state=Palette.SECONDARY)
    94 
    95100    def __palette_item_clicked_cb(self, item):
    96101        bundle = self._model.get_bundle()
    97102        misc.launch(bundle, activity_id=self._model.activity_id,