From b87cc7f6f7d0784ad9f504444b8de3619619297d Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 09 Mar 2011 05:55:17 +0000 Subject: Updated UI + Toolbars --- diff --git a/helpactivity.py b/helpactivity.py index ab113b0..7baa1f0 100755 --- a/helpactivity.py +++ b/helpactivity.py @@ -42,22 +42,74 @@ class HelpActivity(activity.Activity): self._web_view = Browser() - toolbox = activity.ActivityToolbox(self) - self.set_toolbox(toolbox) - toolbox.show() - - toolbar = Toolbar(self._web_view) - toolbox.add_toolbar(_('Navigation'), toolbar) - toolbar.show() - viewtoolbar = ViewToolbar(self) - toolbox.add_toolbar(_('View'),viewtoolbar) - viewtoolbar.show() - + try: + from sugar.graphics.toolbarbox import ToolbarBox, ToolbarButton + from sugar.activity.widgets import ActivityToolbarButton, StopButton, \ + ShareButton, KeepButton + from mybutton import MyActivityToolbarButton + + toolbar_box = ToolbarBox() + activity_button = MyActivityToolbarButton(self) + toolbar_box.toolbar.insert(activity_button, 0) + activity_button.show() + + viewtoolbar = ViewToolbar(self) + viewbutton = ToolbarButton(page=viewtoolbar, \ + icon_name='camera') + toolbar_box.toolbar.insert(viewbutton, -1) + viewbutton.show() + + separator = gtk.SeparatorToolItem() + separator.props.draw = False + separator.set_expand(True) + toolbar_box.toolbar.insert(separator, -1) + separator.show() + + #lets reuse the code below + navtoolbar = Toolbar(self._web_view) + navtoolbar._home.reparent(self) + toolbar_box.toolbar.insert(navtoolbar._home, -1) + navtoolbar._home.show() + + navtoolbar._back.reparent(self) + toolbar_box.toolbar.insert(navtoolbar._back, -1) + navtoolbar._back.show() + + navtoolbar._forward.reparent(self) + toolbar_box.toolbar.insert(navtoolbar._forward, -1) + navtoolbar._forward.show() + + separator = gtk.SeparatorToolItem() + separator.props.draw = False + separator.set_expand(True) + toolbar_box.toolbar.insert(separator, -1) + separator.show() + + stop_button = StopButton(self) + stop_button.props.accelerator = 'Q' + toolbar_box.toolbar.insert(stop_button, -1) + stop_button.show() + + self.set_toolbar_box(toolbar_box) + toolbar_box.show() + + except ImportError: + toolbox = activity.ActivityToolbox(self) + self.set_toolbox(toolbox) + toolbox.show() + + toolbar = Toolbar(self._web_view) + toolbox.add_toolbar(_('Navigation'), toolbar) + toolbar.show() + viewtoolbar = ViewToolbar(self) + toolbox.add_toolbar(_('View'),viewtoolbar) + viewtoolbar.show() + + toolbox.set_current_toolbar(1) + self.set_canvas(self._web_view) self._web_view.show() - toolbox.set_current_toolbar(1) - self._web_view.load_uri(HOME) class Toolbar(gtk.Toolbar): @@ -80,11 +132,11 @@ class Toolbar(gtk.Toolbar): self.insert(self._forward, -1) self._forward.show() - home = ToolButton('go-home') - home.set_tooltip(_('Home')) - home.connect('clicked', self._go_home_cb) - self.insert(home, -1) - home.show() + self._home = ToolButton('go-home') + self._home.set_tooltip(_('Home')) + self._home.connect('clicked', self._go_home_cb) + self.insert(self._home, -1) + self._home.show() progress_listener = self._web_view.progress progress_listener.connect('location-changed', diff --git a/mybutton.py b/mybutton.py new file mode 100644 index 0000000..e5c461b --- /dev/null +++ b/mybutton.py @@ -0,0 +1,54 @@ +# mybutton.py A version of ActivityToolbarButton that hides the "Keep" +# button. + +# Copyright (C) 2010 James D. Simmons +# +# 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 US +import gtk +import gconf + +from sugar.graphics.toolbarbox import ToolbarButton +from sugar.activity.widgets import ActivityToolbar +from sugar.graphics.xocolor import XoColor +from sugar.graphics.icon import Icon +from sugar.bundle.activitybundle import ActivityBundle + +def _create_activity_icon(metadata): + if metadata.get('icon-color', ''): + color = XoColor(metadata['icon-color']) + else: + client = gconf.client_get_default() + color = XoColor(client.get_string('/desktop/sugar/user/color')) + + from sugar.activity.activity import get_bundle_path + bundle = ActivityBundle(get_bundle_path()) + icon = Icon(file=bundle.get_icon(), xo_color=color) + + return icon + +class MyActivityToolbarButton(ToolbarButton): + + def __init__(self, activity, **kwargs): + toolbar = ActivityToolbar(activity, orientation_left=True) + toolbar.share.hide() + toolbar.stop.hide() + toolbar.keep.hide() + toolbar.title.unset_flags(gtk.CAN_FOCUS) + + ToolbarButton.__init__(self, page=toolbar, **kwargs) + + icon = _create_activity_icon(activity.metadata) + self.set_icon_widget(icon) + icon.show() -- cgit v0.9.1