Ticket #4323: 0001-clipboard-palette-port.patch

File 0001-clipboard-palette-port.patch, 3.6 KB (added by manuq, 10 years ago)

I have tried a port to the palettes with custom widgets, but is not useful at all as we haven't implemented submenus in them.

  • src/jarabe/frame/clipboardmenu.py

    From 445e0dc2611a6d430edf4310d560b84c85f750b5 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
    Date: Mon, 17 Dec 2012 15:31:10 -0300
    Subject: [PATCH shell] clipboard palette port
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
    
    Signed-off-by: Manuel Quiñones <manuq@laptop.org>
    ---
     src/jarabe/frame/clipboardmenu.py | 30 +++++++++++++++++++-----------
     1 file changed, 19 insertions(+), 11 deletions(-)
    
    diff --git a/src/jarabe/frame/clipboardmenu.py b/src/jarabe/frame/clipboardmenu.py
    index bef007b..8ee2766 100644
    a b from gi.repository import GLib 
    2525from gi.repository import Gtk
    2626
    2727from sugar3.graphics.palette import Palette
    28 from sugar3.graphics.menuitem import MenuItem
     28from sugar3.graphics.palettemenu import PaletteMenuBox
     29from sugar3.graphics.palettemenu import PaletteMenuItem
    2930from sugar3.graphics.icon import Icon
    3031from sugar3.graphics.xocolor import XoColor
    3132from sugar3.datastore import datastore
    class ClipboardMenu(Palette): 
    5354
    5455        self._progress_bar = None
    5556
    56         self._remove_item = MenuItem(pgettext('Clipboard', 'Remove'),
    57                                      'list-remove')
     57        menu_box = PaletteMenuBox()
     58        self.set_content(menu_box)
     59        menu_box.show()
     60
     61        self._remove_item = PaletteMenuItem(pgettext('Clipboard', 'Remove'))
     62        icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name='list-remove')
     63        self._remove_item.set_image(icon)
     64
    5865        self._remove_item.connect('activate', self._remove_item_activate_cb)
    59         self.menu.append(self._remove_item)
     66        menu_box.append_item(self._remove_item)
    6067        self._remove_item.show()
    6168
    62         self._open_item = MenuItem(_('Open'), 'zoom-activity')
     69        self._open_item = PaletteMenuItem(_('Open'))
     70        icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name='zoom-activity')
    6371        self._open_item.connect('activate', self._open_item_activate_cb)
    64         self.menu.append(self._open_item)
     72        self._open_item.set_image(icon)
     73        menu_box.append_item(self._open_item)
    6574        self._open_item.show()
    6675
    67         self._journal_item = MenuItem(_('Keep'))
     76        self._journal_item = PaletteMenuItem(_('Keep'))
    6877        client = GConf.Client.get_default()
    6978        color = XoColor(client.get_string('/desktop/sugar/user/color'))
    7079        icon = Icon(icon_name='document-save', icon_size=Gtk.IconSize.MENU,
    class ClipboardMenu(Palette): 
    7281        self._journal_item.set_image(icon)
    7382
    7483        self._journal_item.connect('activate', self._journal_item_activate_cb)
    75         self.menu.append(self._journal_item)
     84        menu_box.append_item(self._journal_item)
    7685        self._journal_item.show()
    7786
    7887        self._update()
    class ClipboardMenu(Palette): 
    8089    def _update_open_submenu(self):
    8190        activities = self._get_activities()
    8291        logging.debug('_update_open_submenu: %r', activities)
    83         child = self._open_item.get_child()
    8492        if activities is None or len(activities) <= 1:
    85             child.set_text(_('Open'))
     93            self._open_item.set_label(_('Open'))
    8694            if self._open_item.get_submenu() is not None:
    8795                self._open_item.set_submenu(None)
    8896            return
    8997
    90         child.set_text(_('Open with'))
     98        self._open_item.set_label(_('Open with'))
    9199        submenu = self._open_item.get_submenu()
    92100        if submenu is None:
    93101            submenu = Gtk.Menu()