Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2011-05-18 08:27:27 (GMT)
committer Bastien Guerry <bzg@altern.org>2011-05-18 08:27:27 (GMT)
commite8125889188b3a7a0da43527a1077ae928fb1388 (patch)
treeba474e8afb2dd6c47b51a3bd14fb4a59de196c59
parentbb90d990d64e063090d691c97926834bc13ea1c3 (diff)
UI update: add mybutton.py.
-rw-r--r--mybutton.py53
-rwxr-xr-xxoexploreactivity.py100
2 files changed, 136 insertions, 17 deletions
diff --git a/mybutton.py b/mybutton.py
new file mode 100644
index 0000000..b1f1f84
--- /dev/null
+++ b/mybutton.py
@@ -0,0 +1,53 @@
+# 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.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()
diff --git a/xoexploreactivity.py b/xoexploreactivity.py
index c4da786..607ef3a 100755
--- a/xoexploreactivity.py
+++ b/xoexploreactivity.py
@@ -20,6 +20,7 @@ import gobject
from sugar.activity import activity
from sugar.graphics.toolbutton import ToolButton
+from sugar.graphics.toolcombobox import ToolComboBox
import hulahop
hulahop.startup(os.path.join(activity.get_activity_root(), 'data/gecko'))
@@ -28,11 +29,10 @@ hulahop.startup(os.path.join(activity.get_activity_root(), 'data/gecko'))
from browser import Browser
import xpcom
from xpcom.components import interfaces
-
+from viewtoolbar import ViewToolbar
gobject.threads_init()
HOME = os.path.join(activity.get_bundle_path(), 'xoexplore/index.html')
-#HOME = "http://website.com/something.html"
class XoexploreActivity(activity.Activity):
def __init__(self, handle):
@@ -42,19 +42,85 @@ class XoexploreActivity(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()
-
+ 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)
+
+ toolitem = gtk.ToolItem()
+ navtoolbar._home.reparent(toolitem)
+ toolbar_box.toolbar.insert(toolitem, -1)
+ navtoolbar._home.show()
+ toolitem.show()
+
+ toolitem = gtk.ToolItem()
+ navtoolbar._back.reparent(toolitem)
+ toolbar_box.toolbar.insert(toolitem, -1)
+ navtoolbar._back.show()
+ toolitem.show()
+
+ toolitem = gtk.ToolItem()
+ navtoolbar._forward.reparent(toolitem)
+ toolbar_box.toolbar.insert(toolitem, -1)
+ navtoolbar._forward.show()
+ toolitem.show()
+
+ # we do not have collaboration features
+ # make the share option insensitive
+ self.max_participants = 1
+
+ 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 = '<Ctrl><Shift>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):
@@ -77,11 +143,11 @@ class Toolbar(gtk.Toolbar):
self.insert(self._forward, -1)
self._forward.show()
- home = ToolButton('zoom-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',