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, 11 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 27 27 from gi.repository import WebKit 28 28 29 29 from sugar3.graphics.palette import Palette, Invoker 30 from sugar3.graphics.palettemenuitem import PaletteMenuItem 30 31 from sugar3 import profile 31 32 32 from sugarmenuitem import SugarMenuItem33 34 33 35 34 class ContentInvoker(Invoker): 36 35 def __init__(self, browser): … … class SelectionPalette(Palette): 123 122 124 123 self.props.primary_text = title 125 124 126 menu_item = SugarMenuItem(_('Copy text'), 'edit-copy')125 menu_item = PaletteMenuItem(_('Copy text'), 'edit-copy') 127 126 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) 129 128 menu_box.pack_end(menu_item, False, False, 0) 130 129 menu_item.show() 131 130 … … class LinkPalette(Palette): 158 157 menu_box.show() 159 158 self._content.set_border_width(1) 160 159 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) 163 162 menu_box.pack_end(menu_item, False, False, 0) 164 163 menu_item.show() 165 164 166 menu_item = SugarMenuItem(_('Follow link in new tab'),165 menu_item = PaletteMenuItem(_('Follow link in new tab'), 167 166 '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) 169 168 menu_box.pack_end(menu_item, False, False, 0) 170 169 menu_item.show() 171 170 172 menu_item = SugarMenuItem(_('Keep link'), 'document-save')171 menu_item = PaletteMenuItem(_('Keep link'), 'document-save') 173 172 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) 175 174 menu_box.pack_end(menu_item, False, False, 0) 176 175 menu_item.show() 177 176 178 menu_item = SugarMenuItem(_('Copy link'), 'edit-copy')177 menu_item = PaletteMenuItem(_('Copy link'), 'edit-copy') 179 178 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) 181 180 menu_box.pack_end(menu_item, False, False, 0) 182 181 menu_item.show() 183 182 … … class ImagePalette(Palette): 225 224 menu_box.show() 226 225 self._content.set_border_width(1) 227 226 228 menu_item = SugarMenuItem(_('Copy image'), 'edit-copy')227 menu_item = PaletteMenuItem(_('Copy image'), 'edit-copy') 229 228 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) 231 230 menu_box.pack_end(menu_item, False, False, 0) 232 231 menu_item.show() 233 232 234 menu_item = SugarMenuItem(_('Keep image'), 'document-save')233 menu_item = PaletteMenuItem(_('Keep image'), 'document-save') 235 234 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) 237 236 menu_box.pack_end(menu_item, False, False, 0) 238 237 menu_item.show() 239 238 -
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 Child2 #3 # This program is free software; you can redistribute it and/or modify4 # it under the terms of the GNU General Public License as published by5 # the Free Software Foundation; either version 2 of the License, or6 # (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 of10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11 # GNU General Public License for more details.12 #13 # You should have received a copy of the GNU General Public License14 # along with this program; if not, write to the Free Software15 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA16 17 from gi.repository import GObject18 from gi.repository import Gtk19 20 from sugar3.graphics.icon import Icon21 from sugar3.graphics import style22 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 = True33 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_name39 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_name75 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 return84 85 self._sensitive = sensitive86 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 27 27 from sugar3.graphics.toolbutton import ToolButton 28 28 from sugar3.graphics import iconentry 29 29 from sugar3.graphics.toolbarbox import ToolbarBox as ToolbarBase 30 from sugar3.graphics.palettemenuitem import PaletteMenuItem 30 31 from sugar3.activity.widgets import ActivityToolbarButton 31 32 from sugar3.activity.widgets import StopButton 32 33 33 34 import filepicker 34 35 import places 35 from sugarmenuitem import SugarMenuItem36 36 from browser import Browser 37 37 38 38 … … class PrimaryToolbar(ToolbarBase): 442 442 if not isinstance(title, unicode): 443 443 title = unicode(title, 'utf-8') 444 444 # 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, 447 447 item_index) 448 448 return menu_item 449 449 … … class PrimaryToolbar(ToolbarBase): 469 469 item_index += 1 470 470 471 471 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) 472 474 self._browser.set_history_index(index) 473 475 474 476 def _link_add_clicked_cb(self, button):