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 |
30 | 30 | from sugar3.graphics.icon import CanvasIcon |
31 | 31 | from sugar3.graphics import style |
32 | 32 | from sugar3.graphics.palette import Palette |
33 | | from sugar3.graphics.menuitem import MenuItem |
| 33 | from sugar3.graphics.palettemenu import PaletteMenuBox |
| 34 | from sugar3.graphics.palettemenu import PaletteMenuItem |
34 | 35 | |
35 | 36 | from jarabe.model import neighborhood |
36 | 37 | from jarabe.model.buddy import get_owner_instance |
… |
… |
class _ActivityIcon(CanvasIcon): |
57 | 58 | size=style.STANDARD_ICON_SIZE): |
58 | 59 | CanvasIcon.__init__(self, file_name=file_name, |
59 | 60 | xo_color=xo_color, pixel_size=size) |
| 61 | |
60 | 62 | self._model = model |
61 | | self.connect('button-release-event', |
62 | | self.__button_release_event_cb) |
| 63 | self.palette_invoker.props.toggle_palette = True |
63 | 64 | |
64 | 65 | def create_palette(self): |
65 | 66 | primary_text = GLib.markup_escape_text(self._model.bundle.get_name()) |
… |
… |
class _ActivityIcon(CanvasIcon): |
75 | 76 | private = self._model.props.private |
76 | 77 | joined = get_owner_instance() in self._model.props.buddies |
77 | 78 | |
| 79 | menu_box = PaletteMenuBox() |
| 80 | |
78 | 81 | 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) |
80 | 85 | item.connect('activate', self.__palette_item_clicked_cb) |
81 | | item.show() |
82 | | palette.menu.append(item) |
| 86 | menu_box.append_item(item) |
83 | 87 | 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) |
85 | 91 | 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() |
88 | 96 | |
89 | 97 | self.connect_to_palette_pop_events(palette) |
90 | 98 | return palette |
91 | 99 | |
92 | | def __button_release_event_cb(self, widget, event): |
93 | | self.props.palette.popup(immediate=True, state=Palette.SECONDARY) |
94 | | |
95 | 100 | def __palette_item_clicked_cb(self, item): |
96 | 101 | bundle = self._model.get_bundle() |
97 | 102 | misc.launch(bundle, activity_id=self._model.activity_id, |