Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2012-10-09 12:01:12 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2012-10-09 13:30:31 (GMT)
commite82cec217f8a3178ad8cccc38b941618c6fb431b (patch)
tree3b2bbab5356c10ad450cfdb687be786d771a5202
parent21af7cc988320c8a53c946253d52fe1bb6ff9a7e (diff)
Use sugar-toolkit-gtk3 MenuItem
Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
-rw-r--r--readactivity.py41
-rw-r--r--sugarmenuitem.py95
2 files changed, 17 insertions, 119 deletions
diff --git a/readactivity.py b/readactivity.py
index 519251a..eaedf81 100644
--- a/readactivity.py
+++ b/readactivity.py
@@ -57,7 +57,7 @@ from readtoolbar import EditToolbar
from readtoolbar import ViewToolbar
from bookmarkview import BookmarkView
from readdb import BookmarkManager
-from sugarmenuitem import SugarMenuItem
+from sugar3.graphics.menuitem import MenuItem
from linkbutton import LinkButton
_HARDWARE_MANAGER_INTERFACE = 'org.laptop.HardwareManager'
@@ -352,20 +352,16 @@ class ReadActivity(activity.Activity):
back.props.sensitive = False
palette = back.get_palette()
- vbox_menu = Gtk.VBox()
- previous_page = SugarMenuItem(text_label=_("Previous page"))
- vbox_menu.add(previous_page)
- previous_bookmark = SugarMenuItem(text_label=_("Previous bookmark"))
- vbox_menu.add(previous_bookmark)
- vbox_menu.show_all()
-
- palette.set_content(vbox_menu)
- # HACK
- palette._content.set_border_width(1)
+ previous_page = MenuItem(text_label=_("Previous page"))
+ previous_page.show()
+ previous_bookmark = MenuItem(text_label=_("Previous bookmark"))
+ previous_bookmark.show()
+ palette.menu.append(previous_page)
+ palette.menu.append(previous_bookmark)
back.connect('clicked', self.__go_back_cb)
- previous_page.connect('clicked', self.__go_back_page_cb)
- previous_bookmark.connect('clicked', self.__prev_bookmark_activate_cb)
+ previous_page.connect('activate', self.__go_back_page_cb)
+ previous_bookmark.connect('activate', self.__prev_bookmark_activate_cb)
return back
def _create_forward_button(self):
@@ -374,20 +370,17 @@ class ReadActivity(activity.Activity):
forward.props.sensitive = False
palette = forward.get_palette()
- vbox_menu = Gtk.VBox()
- next_page = SugarMenuItem(text_label=_("Next page"))
- vbox_menu.add(next_page)
- next_bookmark = SugarMenuItem(text_label=_("Next bookmark"))
- vbox_menu.add(next_bookmark)
- vbox_menu.show_all()
+ next_page = MenuItem(text_label=_("Next page"))
+ next_page.show()
+ next_bookmark = MenuItem(text_label=_("Next bookmark"))
+ next_bookmark.show()
- palette.set_content(vbox_menu)
- # HACK
- palette._content.set_border_width(1)
+ palette.menu.append(next_page)
+ palette.menu.append(next_bookmark)
forward.connect('clicked', self.__go_forward_cb)
- next_page.connect('clicked', self.__go_forward_page_cb)
- next_bookmark.connect('clicked', self.__next_bookmark_activate_cb)
+ next_page.connect('activate', self.__go_forward_page_cb)
+ next_bookmark.connect('activate', self.__next_bookmark_activate_cb)
return forward
def _create_search(self):
diff --git a/sugarmenuitem.py b/sugarmenuitem.py
deleted file mode 100644
index 5071406..0000000
--- a/sugarmenuitem.py
+++ /dev/null
@@ -1,95 +0,0 @@
-# Copyright 2012 One Laptop Per Child
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-from gi.repository import GObject
-from gi.repository import Gtk
-
-from sugar3.graphics.icon import Icon
-from sugar3.graphics import style
-
-
-class SugarMenuItem(Gtk.EventBox):
-
- __gsignals__ = {
- 'clicked': (GObject.SignalFlags.RUN_FIRST, None, [])
- }
-
- def __init__(self, text_label='', icon_name=None):
- Gtk.EventBox.__init__(self)
- self._sensitive = True
- vbox = Gtk.VBox()
- hbox = Gtk.HBox()
- vbox.set_border_width(style.DEFAULT_PADDING)
- if icon_name is not None:
- self.icon = Icon()
- self.icon.props.icon_name = icon_name
- hbox.pack_start(self.icon, expand=False, fill=False,
- padding=style.DEFAULT_PADDING)
- align = Gtk.Alignment(xalign=0.0, yalign=0.5, xscale=0.0, yscale=0.0)
- text = '<span foreground="%s">' % style.COLOR_WHITE.get_html() + \
- text_label + '</span>'
- self.label = Gtk.Label()
- self.label.set_use_markup(True)
- self.label.set_markup(text)
- align.add(self.label)
- hbox.pack_start(align, expand=True, fill=True,
- padding=style.DEFAULT_PADDING)
- vbox.pack_start(hbox, expand=False, fill=False,
- padding=style.DEFAULT_PADDING)
- self.add(vbox)
- self.id_bt_release_cb = self.connect('button-release-event',
- self.__button_release_cb)
- self.id_enter_notify_cb = self.connect('enter-notify-event',
- self.__enter_notify_cb)
- self.id_leave_notify_cb = self.connect('leave-notify-event',
- self.__leave_notify_cb)
- self.modify_bg(Gtk.StateType.NORMAL, style.COLOR_BLACK.get_gdk_color())
- self.show_all()
- self.set_above_child(True)
-
- def __button_release_cb(self, widget, event):
- self.emit('clicked')
-
- def __enter_notify_cb(self, widget, event):
- self.modify_bg(Gtk.StateType.NORMAL,
- style.COLOR_BUTTON_GREY.get_gdk_color())
-
- def __leave_notify_cb(self, widget, event):
- self.modify_bg(Gtk.StateType.NORMAL, style.COLOR_BLACK.get_gdk_color())
-
- def set_icon(self, icon_name):
- self.icon.props.icon_name = icon_name
-
- def set_label(self, text_label):
- text = '<span foreground="%s">' % style.COLOR_WHITE.get_html() + \
- text_label + '</span>'
- self.label.set_markup(text)
-
- def set_sensitive(self, sensitive):
- if self._sensitive == sensitive:
- return
-
- self._sensitive = sensitive
- if sensitive:
- self.handler_unblock(self.id_bt_release_cb)
- self.handler_unblock(self.id_enter_notify_cb)
- self.handler_unblock(self.id_leave_notify_cb)
- else:
- self.handler_block(self.id_bt_release_cb)
- self.handler_block(self.id_enter_notify_cb)
- self.handler_block(self.id_leave_notify_cb)
- self.modify_bg(Gtk.StateType.NORMAL,
- style.COLOR_BLACK.get_gdk_color())