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

File 0001-Use-PaletteMenuItem-instead-local-SugarMenuItem-SL-3.patch, 9.6 KB (added by humitos, 10 years ago)
  • palettes.py

    From cd2c17acfaef2f756b89b6f7a043684879c7c8b1 Mon Sep 17 00:00:00 2001
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Mon, 1 Oct 2012 10:37:55 -0300
    Subject: [PATCH Browse] Use PaletteMenuItem instead local SugarMenuItem SL
     #3455
    
    With this patch Browse uses PaletteMenuItem from
    sugar3.graphics.palettemenuitem instead of the local SugarMenuItem
    defined by Browse in "sugarmenuitem" module. 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 bbebce8..536f8c5 100644
    a b from gi.repository import Gdk 
    2727from gi.repository import WebKit
    2828
    2929from sugar3.graphics.palette import Palette, Invoker
     30from sugar3.graphics.palettemenuitem import PaletteMenuItem
    3031from sugar3 import profile
    3132
    32 from sugarmenuitem import SugarMenuItem
    33 
    3433
    3534class ContentInvoker(Invoker):
    3635    def __init__(self, browser):
    class SelectionPalette(Palette): 
    123122
    124123        self.props.primary_text = title
    125124
    126         menu_item = SugarMenuItem(_('Copy text'), 'edit-copy')
     125        menu_item = PaletteMenuItem(_('Copy text'), 'edit-copy')
    127126        menu_item.icon.props.xo_color = profile.get_color()
    128         menu_item.connect('clicked', self.__copy_activate_cb)
     127        menu_item.connect('activate', self.__copy_activate_cb)
    129128        menu_box.pack_end(menu_item, False, False, 0)
    130129        menu_item.show()
    131130
    class LinkPalette(Palette): 
    158157        menu_box.show()
    159158        self._content.set_border_width(1)
    160159
    161         menu_item = SugarMenuItem(_('Follow link'), 'browse-follow-link')
    162         menu_item.connect('clicked', self.__follow_activate_cb)
     160        menu_item = PaletteMenuItem(_('Follow link'), 'browse-follow-link')
     161        menu_item.connect('activate', self.__follow_activate_cb)
    163162        menu_box.pack_end(menu_item, False, False, 0)
    164163        menu_item.show()
    165164
    166         menu_item = SugarMenuItem(_('Follow link in new tab'),
     165        menu_item = PaletteMenuItem(_('Follow link in new tab'),
    167166                                  'browse-follow-link-new-tab')
    168         menu_item.connect('clicked', self.__follow_activate_cb, True)
     167        menu_item.connect('activate', self.__follow_activate_cb, True)
    169168        menu_box.pack_end(menu_item, False, False, 0)
    170169        menu_item.show()
    171170
    172         menu_item = SugarMenuItem(_('Keep link'), 'document-save')
     171        menu_item = PaletteMenuItem(_('Keep link'), 'document-save')
    173172        menu_item.icon.props.xo_color = profile.get_color()
    174         menu_item.connect('clicked', self.__download_activate_cb)
     173        menu_item.connect('activate', self.__download_activate_cb)
    175174        menu_box.pack_end(menu_item, False, False, 0)
    176175        menu_item.show()
    177176
    178         menu_item = SugarMenuItem(_('Copy link'), 'edit-copy')
     177        menu_item = PaletteMenuItem(_('Copy link'), 'edit-copy')
    179178        menu_item.icon.props.xo_color = profile.get_color()
    180         menu_item.connect('clicked', self.__copy_activate_cb)
     179        menu_item.connect('activate', self.__copy_activate_cb)
    181180        menu_box.pack_end(menu_item, False, False, 0)
    182181        menu_item.show()
    183182
    class ImagePalette(Palette): 
    225224        menu_box.show()
    226225        self._content.set_border_width(1)
    227226
    228         menu_item = SugarMenuItem(_('Copy image'), 'edit-copy')
     227        menu_item = PaletteMenuItem(_('Copy image'), 'edit-copy')
    229228        menu_item.icon.props.xo_color = profile.get_color()
    230         menu_item.connect('clicked', self.__copy_activate_cb)
     229        menu_item.connect('activate', self.__copy_activate_cb)
    231230        menu_box.pack_end(menu_item, False, False, 0)
    232231        menu_item.show()
    233232
    234         menu_item = SugarMenuItem(_('Keep image'), 'document-save')
     233        menu_item = PaletteMenuItem(_('Keep image'), 'document-save')
    235234        menu_item.icon.props.xo_color = profile.get_color()
    236         menu_item.connect('clicked', self.__download_activate_cb)
     235        menu_item.connect('activate', self.__download_activate_cb)
    237236        menu_box.pack_end(menu_item, False, False, 0)
    238237        menu_item.show()
    239238
  • 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 6350dfb..e06031c 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.palettemenuitem import PaletteMenuItem
    3031from sugar3.activity.widgets import ActivityToolbarButton
    3132from sugar3.activity.widgets import StopButton
    3233
    3334import filepicker
    3435import places
    35 from sugarmenuitem import SugarMenuItem
    3636from browser import Browser
    3737
    3838
    class PrimaryToolbar(ToolbarBase): 
    442442            if not isinstance(title, unicode):
    443443                title = unicode(title, 'utf-8')
    444444            # This is a fix until the Sugar MenuItem is fixed:
    445             menu_item = SugarMenuItem(text_label=title)
    446             menu_item.connect('clicked', self._history_item_activated_cb,
     445            menu_item = PaletteMenuItem(text_label=title)
     446            menu_item.connect('activate', self._history_item_activated_cb,
    447447                              item_index)
    448448            return menu_item
    449449
    class PrimaryToolbar(ToolbarBase): 
    469469            item_index += 1
    470470
    471471    def _history_item_activated_cb(self, menu_item, index):
     472        self._back.get_palette().popdown(immediate=True)
     473        self._forward.get_palette().popdown(immediate=True)
    472474        self._browser.set_history_index(index)
    473475
    474476    def _link_add_clicked_cb(self, button):