Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlinksview.py25
-rwxr-xr-xstylesheet.py27
-rwxr-xr-xwebactivity.py51
-rwxr-xr-xwebtoolbar.py (renamed from toolbar.py)92
4 files changed, 67 insertions, 128 deletions
diff --git a/linksview.py b/linksview.py
index fe0b02c..5e6388c 100755
--- a/linksview.py
+++ b/linksview.py
@@ -15,10 +15,10 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import os
-import gtk
import hippo
from sugar import env
+from sugar.graphics.toolbar import Toolbar
from sugar.graphics.menu import Menu
from sugar.graphics.menushell import MenuShell
from sugar.graphics.menuicon import MenuIcon
@@ -40,18 +40,14 @@ class LinkIcon(MenuIcon):
menu = Menu(self._link.title)
return menu
-class LinksView(hippo.Canvas):
- def __init__(self, model, browser):
- hippo.Canvas.__init__(self)
+class LinksView(Toolbar):
+ def __init__(self, model, browser, **kwargs):
+ Toolbar.__init__(self, orientation=hippo.ORIENTATION_VERTICAL)
self._icons = {}
self._browser = browser
self._menu_shell = MenuShell(self)
- self._box = hippo.CanvasBox()
- style.apply_stylesheet(self._box, 'links.Box')
- self.set_root(self._box)
-
for link in model:
self._add_link(link)
@@ -59,25 +55,19 @@ class LinksView(hippo.Canvas):
model.connect('link_removed', self._link_removed_cb)
def _add_link(self, link):
- if len(self._icons) == 0:
- self.show()
-
icon = LinkIcon(self._menu_shell, link)
icon.connect('activated', self._link_activated_cb, link)
style.apply_stylesheet(icon, 'links.Icon')
- self._box.append(icon)
+ self.append(icon)
self._icons[link] = icon
def _remove_link(self, link):
icon = self._icons[link]
- self._box.remove(icon)
+ self.remove(icon)
del self._icons[link]
- if len(self._icons) == 0:
- self.hide()
-
def _link_added_cb(self, model, link):
self._add_link(link)
@@ -86,3 +76,6 @@ class LinksView(hippo.Canvas):
def _link_activated_cb(self, link_item, link):
self._browser.load_url(link.url)
+
+ def get_link_count(self):
+ return len(self._icons)
diff --git a/stylesheet.py b/stylesheet.py
deleted file mode 100755
index 7b3abb9..0000000
--- a/stylesheet.py
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright (C) 2006, Red Hat, Inc.
-#
-# 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
-
-import gtk
-
-from sugar.graphics import style
-
-links_Icon = {
- 'scale' : style.standard_icon_scale
-}
-
-links_Box = {
- 'background_color' : 0x414141ff
-}
diff --git a/webactivity.py b/webactivity.py
index 5794183..78d8a41 100755
--- a/webactivity.py
+++ b/webactivity.py
@@ -15,20 +15,17 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
from gettext import gettext as _
-import gtk
+import hippo
import logging
import dbus
import _sugar
-from sugar.activity import ActivityFactory
from sugar.activity.Activity import Activity
from sugar.clipboard import clipboardservice
from sugar import env
-from sugar.graphics import style
-import stylesheet
from webview import WebView
-from toolbar import Toolbar
+from webtoolbar import WebToolbar
from linksmodel import LinksModel
from linksview import LinksView
from linkscontroller import LinksController
@@ -43,7 +40,12 @@ class WebActivity(Activity):
self.set_title(_('Web Activity'))
- vbox = gtk.VBox()
+ canvas = hippo.Canvas()
+ self.add(canvas)
+ canvas.show()
+
+ vbox = hippo.CanvasBox()
+ canvas.set_root(vbox)
if browser:
self._browser = browser
@@ -51,26 +53,33 @@ class WebActivity(Activity):
self._browser = WebView()
self._browser.connect('notify::title', self._title_changed_cb)
- self._links_model = LinksModel()
- links_view = LinksView(self._links_model, self._browser)
+ self._toolbar = WebToolbar(self._browser)
+ vbox.append(self._toolbar)
- self._toolbar = Toolbar(self._browser)
- vbox.pack_start(self._toolbar, False)
- self._toolbar.show()
+ self._hbox = hippo.CanvasBox(orientation=hippo.ORIENTATION_HORIZONTAL)
+ vbox.append(self._hbox, hippo.PACK_EXPAND)
- hbox = gtk.HBox()
+ self._links_model = LinksModel()
+ self._links_view = LinksView(self._links_model, self._browser)
+ self._hbox.append(self._links_view)
+ self._hbox.set_child_visible(self._links_view, False)
+
+ self._links_model.connect('link_added', self._link_added_cb)
+ self._links_model.connect('link_removed', self._link_removed_cb)
- hbox.pack_start(links_view, False)
- hbox.pack_start(self._browser)
- self._browser.show()
+ browser_widget = hippo.CanvasWidget()
+ browser_widget.props.widget = self._browser
+ self._hbox.append(browser_widget, hippo.PACK_EXPAND)
- vbox.pack_start(hbox)
- hbox.show()
+ self._browser.load_url(_HOMEPAGE)
- self.add(vbox)
- vbox.show()
+ def _link_added_cb(self, model, link):
+ if self._links_view.get_link_count() > 0:
+ self._hbox.set_child_visible(self._links_view, True)
- self._browser.load_url(_HOMEPAGE)
+ def _link_removed_cb(self, model, link):
+ if self._links_view.get_link_count() == 0:
+ self._hbox.set_child_visible(self._links_view, False)
def _setup_links_controller(self):
links_controller = LinksController(self._service, self._links_model)
@@ -105,8 +114,6 @@ def start():
if not _sugar.browser_startup(env.get_profile_path(), 'gecko'):
raise "Error when initializising the web activity."
- style.load_stylesheet(stylesheet)
-
download_manager = _sugar.get_download_manager()
download_manager.connect('download-started', download_started_cb)
download_manager.connect('download-completed', download_completed_cb)
diff --git a/toolbar.py b/webtoolbar.py
index ffae8f0..591863e 100755
--- a/toolbar.py
+++ b/webtoolbar.py
@@ -14,70 +14,43 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+import hippo
import gtk
from _sugar import AddressEntry
-class Toolbar(gtk.Toolbar):
+from sugar.graphics.toolbar import Toolbar
+from sugar.graphics.button import Button
+
+class WebToolbar(Toolbar):
def __init__(self, embed):
- gtk.Toolbar.__init__(self)
+ Toolbar.__init__(self)
- self.set_style(gtk.TOOLBAR_BOTH_HORIZ)
-
- self._insert_spring()
-
- self._back = gtk.ToolButton()
- self._back.props.sensitive = False
- self._back.set_icon_name('stock-back')
- self._back.connect("clicked", self._go_back_cb)
- self.insert(self._back, -1)
- self._back.show()
-
- self._forward = gtk.ToolButton()
- self._forward.props.sensitive = False
- self._forward.set_icon_name('stock-forward')
- self._forward.connect("clicked", self._go_forward_cb)
- self.insert(self._forward, -1)
- self._forward.show()
-
- self._stop_and_reload = gtk.ToolButton()
- self._forward.props.sensitive = False
- self._stop_and_reload.connect("clicked", self._stop_and_reload_cb)
- self.insert(self._stop_and_reload, -1)
- self._stop_and_reload.show()
+ self._back = Button('theme:stock-back')
+ self._back.props.active = False
+ self._back.connect("activated", self._go_back_cb)
+ self.append(self._back)
- separator = gtk.SeparatorToolItem()
- separator.set_draw(False)
- self.insert(separator, -1)
- separator.show()
+ self._forward = Button('theme:stock-forward')
+ self._forward.props.active = False
+ self._forward.connect("activated", self._go_forward_cb)
+ self.append(self._forward)
- address_item = gtk.ToolItem()
+ self._stop_and_reload = Button('theme:stock-close')
+ self._stop_and_reload.connect("activated", self._stop_and_reload_cb)
+ self.append(self._stop_and_reload)
self._entry = AddressEntry()
self._entry.connect("activate", self._entry_activate_cb)
- width = int(gtk.gdk.screen_width() / 1.8)
- self._entry.set_size_request(width, -1)
+ entry_widget = hippo.CanvasWidget()
+ entry_widget.props.widget = self._entry
+ self.append(entry_widget, hippo.PACK_EXPAND)
- address_item.add(self._entry)
- self._entry.show()
-
- self.insert(address_item, -1)
- address_item.show()
-
- separator = gtk.SeparatorToolItem()
- separator.set_draw(False)
- self.insert(separator, -1)
- separator.show()
-
- self._post = gtk.ToolButton()
- self._post.props.sensitive = False
- self._post.set_icon_name('stock-add')
- self._post.connect("clicked", self._post_cb)
- self.insert(self._post, -1)
- self._post.show()
-
- self._insert_spring()
+ self._post = Button('theme:stock-add')
+ self._post.props.active = False
+ self._post.connect("activated", self._post_cb)
+ self.append(self._post)
self._embed = embed
self._embed.connect("notify::progress", self._progress_changed_cb)
@@ -93,13 +66,13 @@ class Toolbar(gtk.Toolbar):
def set_links_controller(self, links_controller):
self._links_controller = links_controller
- self._post.props.sensitive = True
+ self._post.props.active = True
def _update_stop_and_reload_icon(self):
if self._embed.props.loading:
- self._stop_and_reload.set_icon_name('stock-close')
+ self._stop_and_reload.props.icon_name = 'theme:stock-close'
else:
- self._stop_and_reload.set_icon_name('stock-continue')
+ self._stop_and_reload.props.icon_name = 'theme:stock-continue'
def _progress_changed_cb(self, embed, spec):
self._entry.props.progress = embed.props.progress
@@ -114,10 +87,10 @@ class Toolbar(gtk.Toolbar):
self._entry.props.title = embed.props.title
def _can_go_back_changed_cb(self, embed, spec):
- self._back.props.sensitive = embed.props.can_go_back
+ self._back.props.active = embed.props.can_go_back
def _can_go_forward_changed_cb(self, embed, spec):
- self._forward.props.sensitive = embed.props.can_go_forward
+ self._forward.props.active = embed.props.can_go_forward
def _entry_activate_cb(self, entry):
self._embed.load_url(entry.get_text())
@@ -139,10 +112,3 @@ class Toolbar(gtk.Toolbar):
title = self._embed.get_title()
address = self._embed.get_location()
self._links_controller.post_link(title, address)
-
- def _insert_spring(self):
- separator = gtk.SeparatorToolItem()
- separator.set_draw(False)
- separator.set_expand(True)
- self.insert(separator, -1)
- separator.show()