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, 11 years ago) |
---|
-
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 29 29 from gi.repository import SugarGestures 30 30 31 31 from sugar3.graphics.palette import Palette, Invoker 32 from sugar3.graphics.palettemenu import PaletteMenuItem 32 33 from sugar3 import profile 33 34 34 from sugarmenuitem import SugarMenuItem35 36 35 37 36 class ContentInvoker(Invoker): 38 37 def __init__(self, browser): … … class SelectionPalette(Palette): 165 164 166 165 self.props.primary_text = title 167 166 168 menu_item = SugarMenuItem(_('Copy text'), 'edit-copy')167 menu_item = PaletteMenuItem(_('Copy text'), 'edit-copy') 169 168 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) 171 170 menu_box.pack_end(menu_item, False, False, 0) 172 171 menu_item.show() 173 172 … … class LinkPalette(Palette): 200 199 menu_box.show() 201 200 self._content.set_border_width(1) 202 201 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) 205 204 menu_box.pack_start(menu_item, False, False, 0) 206 205 menu_item.show() 207 206 208 menu_item = SugarMenuItem(_('Follow link in new tab'),207 menu_item = PaletteMenuItem(_('Follow link in new tab'), 209 208 '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) 211 210 menu_box.pack_start(menu_item, False, False, 0) 212 211 menu_item.show() 213 212 214 menu_item = SugarMenuItem(_('Keep link'), 'document-save')213 menu_item = PaletteMenuItem(_('Keep link'), 'document-save') 215 214 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) 217 216 menu_box.pack_start(menu_item, False, False, 0) 218 217 menu_item.show() 219 218 220 menu_item = SugarMenuItem(_('Copy link'), 'edit-copy')219 menu_item = PaletteMenuItem(_('Copy link'), 'edit-copy') 221 220 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) 223 222 menu_box.pack_start(menu_item, False, False, 0) 224 223 menu_item.show() 225 224 … … class ImagePalette(Palette): 267 266 menu_box.show() 268 267 self._content.set_border_width(1) 269 268 270 menu_item = SugarMenuItem(_('Copy image'), 'edit-copy')269 menu_item = PaletteMenuItem(_('Copy image'), 'edit-copy') 271 270 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) 273 272 menu_box.pack_end(menu_item, False, False, 0) 274 273 menu_item.show() 275 274 276 menu_item = SugarMenuItem(_('Keep image'), 'document-save')275 menu_item = PaletteMenuItem(_('Keep image'), 'document-save') 277 276 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) 279 278 menu_box.pack_end(menu_item, False, False, 0) 280 279 menu_item.show() 281 280 -
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 3a0ec57..642b310 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.palettemenu import PaletteMenuItem 30 31 from sugar3.graphics import style 31 32 from sugar3.activity.widgets import ActivityToolbarButton 32 33 from sugar3.activity.widgets import StopButton 33 34 34 35 import filepicker 35 36 import places 36 from sugarmenuitem import SugarMenuItem37 37 from browser import Browser 38 38 from pdfviewer import DummyBrowser 39 39 … … class PrimaryToolbar(ToolbarBase): 492 492 if not isinstance(title, unicode): 493 493 title = unicode(title, 'utf-8') 494 494 # 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, 497 497 item_index) 498 498 return menu_item 499 499 … … class PrimaryToolbar(ToolbarBase): 519 519 item_index += 1 520 520 521 521 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) 522 524 self._browser.set_history_index(index) 523 525 524 526 def _link_add_clicked_cb(self, button):