Ticket #3455: 0001-Use-PaletteMenuItem-instead-local-SugarMenuItem-SL-3.2.patch

File 0001-Use-PaletteMenuItem-instead-local-SugarMenuItem-SL-3.2.patch, 9.7 KB (added by humitos, 10 years ago)

Last patch rebased

  • palettes.py

    From 7393c2f153f195e831ac9322f3bc60a958c22423 Mon Sep 17 00:00:00 2001
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Fri, 23 Nov 2012 10:23:59 -0300
    Subject: [PATCH Browse] Use PaletteMenuItem instead local SugarMenuItem SL
     #3455
    
    With this patch Browse uses PaletteMenuItem from
    'sugar3.graphics.palettemenu' instead of the local SugarMenuItem
    defined by Browse in "sugarmenuitem" module. In fact, this module was
    removed.
    
    Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
    ---
     palettes.py      | 31 +++++++++---------
     sugarmenuitem.py | 95 --------------------------------------------------------
     webtoolbar.py    |  8 +++--
     3 files changed, 20 insertions(+), 114 deletions(-)
     delete mode 100644 sugarmenuitem.py
    
    diff --git a/palettes.py b/palettes.py
    index 00cf26a..bfb27e9 100644
    a b from gi.repository import WebKit 
    2929from gi.repository import SugarGestures
    3030
    3131from sugar3.graphics.palette import Palette, Invoker
     32from sugar3.graphics.palettemenu import PaletteMenuItem
    3233from sugar3 import profile
    3334
    34 from sugarmenuitem import SugarMenuItem
    35 
    3635
    3736class ContentInvoker(Invoker):
    3837    def __init__(self, browser):
    class SelectionPalette(Palette): 
    165164
    166165        self.props.primary_text = title
    167166
    168         menu_item = SugarMenuItem(_('Copy text'), 'edit-copy')
     167        menu_item = PaletteMenuItem(_('Copy text'), 'edit-copy')
    169168        menu_item.icon.props.xo_color = profile.get_color()
    170         menu_item.connect('clicked', self.__copy_activate_cb)
     169        menu_item.connect('activate', self.__copy_activate_cb)
    171170        menu_box.pack_end(menu_item, False, False, 0)
    172171        menu_item.show()
    173172
    class LinkPalette(Palette): 
    200199        menu_box.show()
    201200        self._content.set_border_width(1)
    202201
    203         menu_item = SugarMenuItem(_('Follow link'), 'browse-follow-link')
    204         menu_item.connect('clicked', self.__follow_activate_cb)
     202        menu_item = PaletteMenuItem(_('Follow link'), 'browse-follow-link')
     203        menu_item.connect('activate', self.__follow_activate_cb)
    205204        menu_box.pack_start(menu_item, False, False, 0)
    206205        menu_item.show()
    207206
    208         menu_item = SugarMenuItem(_('Follow link in new tab'),
     207        menu_item = PaletteMenuItem(_('Follow link in new tab'),
    209208                                  'browse-follow-link-new-tab')
    210         menu_item.connect('clicked', self.__follow_activate_cb, True)
     209        menu_item.connect('activate', self.__follow_activate_cb, True)
    211210        menu_box.pack_start(menu_item, False, False, 0)
    212211        menu_item.show()
    213212
    214         menu_item = SugarMenuItem(_('Keep link'), 'document-save')
     213        menu_item = PaletteMenuItem(_('Keep link'), 'document-save')
    215214        menu_item.icon.props.xo_color = profile.get_color()
    216         menu_item.connect('clicked', self.__download_activate_cb)
     215        menu_item.connect('activate', self.__download_activate_cb)
    217216        menu_box.pack_start(menu_item, False, False, 0)
    218217        menu_item.show()
    219218
    220         menu_item = SugarMenuItem(_('Copy link'), 'edit-copy')
     219        menu_item = PaletteMenuItem(_('Copy link'), 'edit-copy')
    221220        menu_item.icon.props.xo_color = profile.get_color()
    222         menu_item.connect('clicked', self.__copy_activate_cb)
     221        menu_item.connect('activate', self.__copy_activate_cb)
    223222        menu_box.pack_start(menu_item, False, False, 0)
    224223        menu_item.show()
    225224
    class ImagePalette(Palette): 
    267266        menu_box.show()
    268267        self._content.set_border_width(1)
    269268
    270         menu_item = SugarMenuItem(_('Copy image'), 'edit-copy')
     269        menu_item = PaletteMenuItem(_('Copy image'), 'edit-copy')
    271270        menu_item.icon.props.xo_color = profile.get_color()
    272         menu_item.connect('clicked', self.__copy_activate_cb)
     271        menu_item.connect('activate', self.__copy_activate_cb)
    273272        menu_box.pack_end(menu_item, False, False, 0)
    274273        menu_item.show()
    275274
    276         menu_item = SugarMenuItem(_('Keep image'), 'document-save')
     275        menu_item = PaletteMenuItem(_('Keep image'), 'document-save')
    277276        menu_item.icon.props.xo_color = profile.get_color()
    278         menu_item.connect('clicked', self.__download_activate_cb)
     277        menu_item.connect('activate', self.__download_activate_cb)
    279278        menu_box.pack_end(menu_item, False, False, 0)
    280279        menu_item.show()
    281280
  • deleted file sugarmenuitem.py

    diff --git a/sugarmenuitem.py b/sugarmenuitem.py
    deleted file mode 100644
    index 5071406..0000000
    + -  
    1 # Copyright 2012 One Laptop Per Child
    2 #
    3 # This program is free software; you can redistribute it and/or modify
    4 # it under the terms of the GNU General Public License as published by
    5 # the Free Software Foundation; either version 2 of the License, or
    6 # (at your option) any later version.
    7 #
    8 # This program is distributed in the hope that it will be useful,
    9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    11 # GNU General Public License for more details.
    12 #
    13 # You should have received a copy of the GNU General Public License
    14 # along with this program; if not, write to the Free Software
    15 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    16 
    17 from gi.repository import GObject
    18 from gi.repository import Gtk
    19 
    20 from sugar3.graphics.icon import Icon
    21 from sugar3.graphics import style
    22 
    23 
    24 class SugarMenuItem(Gtk.EventBox):
    25 
    26     __gsignals__ = {
    27         'clicked': (GObject.SignalFlags.RUN_FIRST, None, [])
    28     }
    29 
    30     def __init__(self, text_label='', icon_name=None):
    31         Gtk.EventBox.__init__(self)
    32         self._sensitive = True
    33         vbox = Gtk.VBox()
    34         hbox = Gtk.HBox()
    35         vbox.set_border_width(style.DEFAULT_PADDING)
    36         if icon_name is not None:
    37             self.icon = Icon()
    38             self.icon.props.icon_name = icon_name
    39             hbox.pack_start(self.icon, expand=False, fill=False,
    40                     padding=style.DEFAULT_PADDING)
    41         align = Gtk.Alignment(xalign=0.0, yalign=0.5, xscale=0.0, yscale=0.0)
    42         text = '<span foreground="%s">' % style.COLOR_WHITE.get_html() + \
    43                     text_label + '</span>'
    44         self.label = Gtk.Label()
    45         self.label.set_use_markup(True)
    46         self.label.set_markup(text)
    47         align.add(self.label)
    48         hbox.pack_start(align, expand=True, fill=True,
    49                 padding=style.DEFAULT_PADDING)
    50         vbox.pack_start(hbox, expand=False, fill=False,
    51                 padding=style.DEFAULT_PADDING)
    52         self.add(vbox)
    53         self.id_bt_release_cb = self.connect('button-release-event',
    54                 self.__button_release_cb)
    55         self.id_enter_notify_cb = self.connect('enter-notify-event',
    56                 self.__enter_notify_cb)
    57         self.id_leave_notify_cb = self.connect('leave-notify-event',
    58                 self.__leave_notify_cb)
    59         self.modify_bg(Gtk.StateType.NORMAL, style.COLOR_BLACK.get_gdk_color())
    60         self.show_all()
    61         self.set_above_child(True)
    62 
    63     def __button_release_cb(self, widget, event):
    64         self.emit('clicked')
    65 
    66     def __enter_notify_cb(self, widget, event):
    67         self.modify_bg(Gtk.StateType.NORMAL,
    68                 style.COLOR_BUTTON_GREY.get_gdk_color())
    69 
    70     def __leave_notify_cb(self, widget, event):
    71         self.modify_bg(Gtk.StateType.NORMAL, style.COLOR_BLACK.get_gdk_color())
    72 
    73     def set_icon(self, icon_name):
    74         self.icon.props.icon_name = icon_name
    75 
    76     def set_label(self, text_label):
    77         text = '<span foreground="%s">' % style.COLOR_WHITE.get_html() + \
    78                     text_label + '</span>'
    79         self.label.set_markup(text)
    80 
    81     def set_sensitive(self, sensitive):
    82         if self._sensitive == sensitive:
    83             return
    84 
    85         self._sensitive = sensitive
    86         if sensitive:
    87             self.handler_unblock(self.id_bt_release_cb)
    88             self.handler_unblock(self.id_enter_notify_cb)
    89             self.handler_unblock(self.id_leave_notify_cb)
    90         else:
    91             self.handler_block(self.id_bt_release_cb)
    92             self.handler_block(self.id_enter_notify_cb)
    93             self.handler_block(self.id_leave_notify_cb)
    94             self.modify_bg(Gtk.StateType.NORMAL,
    95                     style.COLOR_BLACK.get_gdk_color())
  • webtoolbar.py

    diff --git a/webtoolbar.py b/webtoolbar.py
    index 3a0ec57..642b310 100644
    a b from gi.repository import WebKit 
    2727from sugar3.graphics.toolbutton import ToolButton
    2828from sugar3.graphics import iconentry
    2929from sugar3.graphics.toolbarbox import ToolbarBox as ToolbarBase
     30from sugar3.graphics.palettemenu import PaletteMenuItem
    3031from sugar3.graphics import style
    3132from sugar3.activity.widgets import ActivityToolbarButton
    3233from sugar3.activity.widgets import StopButton
    3334
    3435import filepicker
    3536import places
    36 from sugarmenuitem import SugarMenuItem
    3737from browser import Browser
    3838from pdfviewer import DummyBrowser
    3939
    class PrimaryToolbar(ToolbarBase): 
    492492            if not isinstance(title, unicode):
    493493                title = unicode(title, 'utf-8')
    494494            # This is a fix until the Sugar MenuItem is fixed:
    495             menu_item = SugarMenuItem(text_label=title)
    496             menu_item.connect('clicked', self._history_item_activated_cb,
     495            menu_item = PaletteMenuItem(text_label=title)
     496            menu_item.connect('activate', self._history_item_activated_cb,
    497497                              item_index)
    498498            return menu_item
    499499
    class PrimaryToolbar(ToolbarBase): 
    519519            item_index += 1
    520520
    521521    def _history_item_activated_cb(self, menu_item, index):
     522        self._back.get_palette().popdown(immediate=True)
     523        self._forward.get_palette().popdown(immediate=True)
    522524        self._browser.set_history_index(index)
    523525
    524526    def _link_add_clicked_cb(self, button):