Remove old browser and fix makefiles
This commit is contained in:
parent
37c5aaf139
commit
e176a531ab
@ -1 +1 @@
|
|||||||
SUBDIRS = browser chat groupchat terminal
|
SUBDIRS = chat groupchat terminal web
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
import gobject
|
|
||||||
import gtk
|
|
||||||
|
|
||||||
from _sugar import AddressEntry
|
|
||||||
|
|
||||||
class AddressItem(gtk.ToolItem):
|
|
||||||
__gsignals__ = {
|
|
||||||
'open-address': (gobject.SIGNAL_RUN_FIRST,
|
|
||||||
gobject.TYPE_NONE, ([str])),
|
|
||||||
}
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
gtk.ToolItem.__init__(self)
|
|
||||||
|
|
||||||
entry = AddressEntry()
|
|
||||||
width = int(gtk.gdk.screen_width() / 3 * 2)
|
|
||||||
entry.set_size_request(width, -1)
|
|
||||||
entry.connect("activate", self.__activate_cb)
|
|
||||||
self.add(entry)
|
|
||||||
entry.show()
|
|
||||||
|
|
||||||
self._entry = entry
|
|
||||||
|
|
||||||
def __activate_cb(self, entry):
|
|
||||||
self.emit('open-address', entry.get_text())
|
|
||||||
|
|
||||||
def set_progress(self, progress):
|
|
||||||
self._entry.set_property('progress', progress)
|
|
||||||
|
|
||||||
def set_address(self, address):
|
|
||||||
self._entry.set_text(address)
|
|
@ -1,208 +0,0 @@
|
|||||||
import os
|
|
||||||
import logging
|
|
||||||
|
|
||||||
import gtk
|
|
||||||
import gtkmozembed
|
|
||||||
import gobject
|
|
||||||
|
|
||||||
from sugar.activity.Activity import Activity
|
|
||||||
from sugar.presence.PresenceService import PresenceService
|
|
||||||
from sugar.p2p.model.LocalModel import LocalModel
|
|
||||||
from sugar.p2p.model.RemoteModel import RemoteModel
|
|
||||||
import _sugar
|
|
||||||
|
|
||||||
from NotificationBar import NotificationBar
|
|
||||||
from NavigationToolbar import NavigationToolbar
|
|
||||||
from sugar import env
|
|
||||||
|
|
||||||
class PopupCreator(gobject.GObject):
|
|
||||||
__gsignals__ = {
|
|
||||||
'popup-created': (gobject.SIGNAL_RUN_FIRST,
|
|
||||||
gobject.TYPE_NONE, ([])),
|
|
||||||
}
|
|
||||||
|
|
||||||
def __init__(self, parent_window):
|
|
||||||
gobject.GObject.__init__(self)
|
|
||||||
|
|
||||||
logging.debug('Creating the popup widget')
|
|
||||||
|
|
||||||
self._sized_popup = False
|
|
||||||
self._parent_window = parent_window
|
|
||||||
|
|
||||||
self._dialog = gtk.Window()
|
|
||||||
self._dialog.set_resizable(True)
|
|
||||||
|
|
||||||
self._dialog.realize()
|
|
||||||
self._dialog.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
|
|
||||||
|
|
||||||
self._embed = Browser()
|
|
||||||
self._size_to_sid = self._embed.connect('size_to', self._size_to_cb)
|
|
||||||
self._vis_sid = self._embed.connect('visibility', self._visibility_cb)
|
|
||||||
|
|
||||||
self._dialog.add(self._embed)
|
|
||||||
|
|
||||||
def _size_to_cb(self, embed, width, height):
|
|
||||||
logging.debug('Resize the popup to %d %d' % (width, height))
|
|
||||||
self._sized_popup = True
|
|
||||||
self._dialog.resize(width, height)
|
|
||||||
|
|
||||||
def _visibility_cb(self, embed, visible):
|
|
||||||
if visible:
|
|
||||||
if self._sized_popup:
|
|
||||||
logging.debug('Show the popup')
|
|
||||||
self._embed.show()
|
|
||||||
self._dialog.set_transient_for(self._parent_window)
|
|
||||||
self._dialog.show()
|
|
||||||
else:
|
|
||||||
logging.debug('Open a new activity for the popup')
|
|
||||||
self._dialog.remove(self._embed)
|
|
||||||
|
|
||||||
activity = BrowserActivity(self._embed)
|
|
||||||
activity.set_type('com.redhat.Sugar.BrowserActivity')
|
|
||||||
|
|
||||||
self._embed.disconnect(self._size_to_sid)
|
|
||||||
self._embed.disconnect(self._vis_sid)
|
|
||||||
|
|
||||||
self.emit('popup-created')
|
|
||||||
|
|
||||||
def get_embed(self):
|
|
||||||
return self._embed
|
|
||||||
|
|
||||||
class Browser(_sugar.Browser):
|
|
||||||
__gtype_name__ = "SugarWebBrowser"
|
|
||||||
def __init__(self):
|
|
||||||
_sugar.Browser.__init__(self)
|
|
||||||
self._popup_creators = []
|
|
||||||
|
|
||||||
def do_create_window(self):
|
|
||||||
popup_creator = PopupCreator(self.get_toplevel())
|
|
||||||
popup_creator.connect('popup-created', self._popup_created_cb)
|
|
||||||
|
|
||||||
self._popup_creators.append(popup_creator)
|
|
||||||
|
|
||||||
return popup_creator.get_embed()
|
|
||||||
|
|
||||||
def _popup_created_cb(self, creator):
|
|
||||||
self._popup_creators.remove(creator)
|
|
||||||
|
|
||||||
class BrowserActivity(Activity):
|
|
||||||
def __init__(self, embed=None):
|
|
||||||
Activity.__init__(self)
|
|
||||||
|
|
||||||
self._embed = embed
|
|
||||||
self._share_service = None
|
|
||||||
self._model_service = None
|
|
||||||
self._notif_service = None
|
|
||||||
self._model = None
|
|
||||||
|
|
||||||
self.set_title("Web Page")
|
|
||||||
self.connect('destroy', self._destroy_cb)
|
|
||||||
|
|
||||||
vbox = gtk.VBox()
|
|
||||||
|
|
||||||
nav_toolbar = NavigationToolbar()
|
|
||||||
vbox.pack_start(nav_toolbar, False)
|
|
||||||
nav_toolbar.show()
|
|
||||||
|
|
||||||
self._notif_bar = NotificationBar()
|
|
||||||
vbox.pack_start(self._notif_bar, False)
|
|
||||||
self._notif_bar.connect('action', self.__notif_bar_action_cb)
|
|
||||||
|
|
||||||
if not self._embed:
|
|
||||||
self._embed = Browser()
|
|
||||||
self._embed.connect("title", self.__title_cb)
|
|
||||||
vbox.pack_start(self._embed)
|
|
||||||
self._embed.show()
|
|
||||||
|
|
||||||
nav_toolbar.set_embed(self._embed)
|
|
||||||
self._embed.load_url('http://www.google.com')
|
|
||||||
|
|
||||||
self.add(vbox)
|
|
||||||
vbox.show()
|
|
||||||
|
|
||||||
def join(self, activity_ps):
|
|
||||||
Activity.join(self, activity_ps)
|
|
||||||
|
|
||||||
activity_ps.connect('service-appeared', self._service_appeared_cb)
|
|
||||||
|
|
||||||
services = activity_ps.get_services_of_type(self._default_type)
|
|
||||||
if len(services) > 0:
|
|
||||||
self._notif_service = services[0]
|
|
||||||
|
|
||||||
services = activity_ps.get_services_of_type(LocalModel.SERVICE_TYPE)
|
|
||||||
if len(services) > 0:
|
|
||||||
self._model_service = services[0]
|
|
||||||
|
|
||||||
if self._notif_service and self._model_service:
|
|
||||||
self._listen_to_model()
|
|
||||||
|
|
||||||
def _service_appeared_cb(self, pservice, service):
|
|
||||||
if service.get_type() == self._default_type:
|
|
||||||
self._notif_service = service
|
|
||||||
elif service.get_type() == LocalModel.SERVICE_TYPE:
|
|
||||||
self._model_service = service
|
|
||||||
|
|
||||||
if not self._model and self._notif_service and self._model_service:
|
|
||||||
self._listen_to_model()
|
|
||||||
|
|
||||||
def _listen_to_model(self):
|
|
||||||
self._model = RemoteModel(self._model_service, self._notif_service)
|
|
||||||
self._model.add_listener(self.__shared_location_changed_cb)
|
|
||||||
self._go_to_shared_location()
|
|
||||||
|
|
||||||
def _update_shared_location(self):
|
|
||||||
address = self._embed.get_location()
|
|
||||||
self._model.set_value('address', address)
|
|
||||||
title = self._embed.get_title()
|
|
||||||
self._model.set_value('title', title)
|
|
||||||
|
|
||||||
def __notif_bar_action_cb(self, bar, action_id):
|
|
||||||
if action_id == 'set_shared_location':
|
|
||||||
self._update_shared_location()
|
|
||||||
elif action_id == 'goto_shared_location':
|
|
||||||
self._go_to_shared_location()
|
|
||||||
|
|
||||||
def _go_to_shared_location(self):
|
|
||||||
address = self._model.get_value("address")
|
|
||||||
self._embed.load_url(address)
|
|
||||||
self._notif_bar.hide()
|
|
||||||
|
|
||||||
def get_embed(self):
|
|
||||||
return self._embed
|
|
||||||
|
|
||||||
def share(self):
|
|
||||||
Activity.share(self)
|
|
||||||
|
|
||||||
self._model = LocalModel(self, self._pservice, self._service)
|
|
||||||
self._model.set_value('owner', self._pservice.get_owner().get_name())
|
|
||||||
self._update_shared_location()
|
|
||||||
|
|
||||||
self._notif_bar.set_text('Share this page with the group.')
|
|
||||||
self._notif_bar.set_action('set_shared_location', 'Share')
|
|
||||||
self._notif_bar.set_icon('stock_shared-by-me')
|
|
||||||
self._notif_bar.show()
|
|
||||||
|
|
||||||
def __title_cb(self, embed):
|
|
||||||
self.set_title(embed.get_title())
|
|
||||||
|
|
||||||
def __shared_location_changed_cb(self, model, key):
|
|
||||||
self._notify_shared_location_change()
|
|
||||||
|
|
||||||
def _notify_shared_location_change(self):
|
|
||||||
owner = self._model.get_value('owner')
|
|
||||||
title = self._model.get_value('title')
|
|
||||||
|
|
||||||
text = '<b>' + owner + '</b> is reading <i>' + title + '</i>'
|
|
||||||
self._notif_bar.set_text(text)
|
|
||||||
self._notif_bar.set_action('goto_shared_location', 'Go There')
|
|
||||||
self._notif_bar.set_icon('stock_right')
|
|
||||||
self._notif_bar.show()
|
|
||||||
|
|
||||||
def _destroy_cb(self, window):
|
|
||||||
if self._model:
|
|
||||||
self._model.shutdown()
|
|
||||||
|
|
||||||
def start():
|
|
||||||
gtkmozembed.set_profile_path(env.get_profile_path(), 'gecko')
|
|
||||||
gtkmozembed.push_startup()
|
|
||||||
_sugar.startup_browser()
|
|
@ -1,9 +0,0 @@
|
|||||||
sugardir = $(pkgdatadir)/activities/browser
|
|
||||||
sugar_PYTHON = \
|
|
||||||
__init__.py \
|
|
||||||
NotificationBar.py \
|
|
||||||
AddressItem.py \
|
|
||||||
BrowserActivity.py \
|
|
||||||
NavigationToolbar.py
|
|
||||||
|
|
||||||
EXTRA_DIST = browser.activity
|
|
@ -1,72 +0,0 @@
|
|||||||
import gtk
|
|
||||||
|
|
||||||
from gettext import gettext as _
|
|
||||||
|
|
||||||
from AddressItem import AddressItem
|
|
||||||
|
|
||||||
class NavigationToolbar(gtk.Toolbar):
|
|
||||||
def __init__(self):
|
|
||||||
gtk.Toolbar.__init__(self)
|
|
||||||
|
|
||||||
self.set_style(gtk.TOOLBAR_BOTH_HORIZ)
|
|
||||||
|
|
||||||
self._insert_spring()
|
|
||||||
|
|
||||||
self.back = gtk.ToolButton(None, _('Back'))
|
|
||||||
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(None, _('Forward'))
|
|
||||||
self.forward.set_icon_name('stock-forward')
|
|
||||||
self.forward.connect("clicked", self.__go_forward_cb)
|
|
||||||
self.insert(self.forward, -1)
|
|
||||||
self.forward.show()
|
|
||||||
|
|
||||||
separator = gtk.SeparatorToolItem()
|
|
||||||
separator.set_draw(False)
|
|
||||||
self.insert(separator, -1)
|
|
||||||
separator.show()
|
|
||||||
|
|
||||||
self._address_item = AddressItem()
|
|
||||||
self._address_item.connect('open-address', self.__open_address_cb)
|
|
||||||
self.insert(self._address_item, -1)
|
|
||||||
self._address_item.show()
|
|
||||||
|
|
||||||
self._insert_spring()
|
|
||||||
|
|
||||||
def _insert_spring(self):
|
|
||||||
separator = gtk.SeparatorToolItem()
|
|
||||||
separator.set_draw(False)
|
|
||||||
separator.set_expand(True)
|
|
||||||
self.insert(separator, -1)
|
|
||||||
separator.show()
|
|
||||||
|
|
||||||
def set_embed(self, embed):
|
|
||||||
self._embed = embed
|
|
||||||
|
|
||||||
self._embed.connect("location", self.__location_changed)
|
|
||||||
self._update_sensitivity()
|
|
||||||
|
|
||||||
self._embed.connect("notify::progress", self._progress_changed_cb)
|
|
||||||
|
|
||||||
def _update_sensitivity(self):
|
|
||||||
self.back.set_sensitive(self._embed.can_go_back())
|
|
||||||
self.forward.set_sensitive(self._embed.can_go_forward())
|
|
||||||
|
|
||||||
def _progress_changed_cb(self, embed, pspec):
|
|
||||||
self._address_item.set_progress(embed.props.progress)
|
|
||||||
|
|
||||||
def __go_back_cb(self, button):
|
|
||||||
self._embed.go_back()
|
|
||||||
|
|
||||||
def __go_forward_cb(self, button):
|
|
||||||
self._embed.go_forward()
|
|
||||||
|
|
||||||
def __location_changed(self, embed):
|
|
||||||
self._address_item.set_address(embed.get_location())
|
|
||||||
self._update_sensitivity()
|
|
||||||
|
|
||||||
def __open_address_cb(self, item, address):
|
|
||||||
self._embed.load_url(address)
|
|
@ -1,56 +0,0 @@
|
|||||||
import gtk
|
|
||||||
import gobject
|
|
||||||
|
|
||||||
class NotificationBar(gtk.HBox):
|
|
||||||
__gsignals__ = {
|
|
||||||
'action': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
|
||||||
([gobject.TYPE_STRING]))
|
|
||||||
}
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
gtk.HBox.__init__(self, False, 12)
|
|
||||||
|
|
||||||
self.set_name("notif bar")
|
|
||||||
self.set_border_width(3)
|
|
||||||
|
|
||||||
self._icon = gtk.Image()
|
|
||||||
self.pack_start(self._icon, False)
|
|
||||||
|
|
||||||
self._text_label = gtk.Label()
|
|
||||||
self._text_label.set_alignment(0.0, 0.5)
|
|
||||||
self.pack_start(self._text_label)
|
|
||||||
self._text_label.show()
|
|
||||||
|
|
||||||
self._action_button = gtk.Button()
|
|
||||||
self._action_button.connect('clicked', self.__button_clicked)
|
|
||||||
self.pack_start(self._action_button, False)
|
|
||||||
self._action_button.show()
|
|
||||||
|
|
||||||
self.connect('expose_event', self.expose)
|
|
||||||
|
|
||||||
def expose(self, widget, event):
|
|
||||||
rect = self.get_allocation()
|
|
||||||
ctx = widget.window.cairo_create()
|
|
||||||
|
|
||||||
ctx.new_path()
|
|
||||||
ctx.rectangle(rect.x, rect.y, rect.width, rect.height)
|
|
||||||
ctx.set_source_rgb(0.56 , 0.75 , 1)
|
|
||||||
ctx.fill_preserve()
|
|
||||||
ctx.set_source_rgb(0.16 , 0.35 , 0.6)
|
|
||||||
ctx.stroke()
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
def set_icon(self, icon_name):
|
|
||||||
self._icon.set_from_icon_name(icon_name, gtk.ICON_SIZE_BUTTON)
|
|
||||||
self._icon.show()
|
|
||||||
|
|
||||||
def set_text(self, text):
|
|
||||||
self._text_label.set_markup(text)
|
|
||||||
|
|
||||||
def set_action(self, action_id, action_text):
|
|
||||||
self._action_id = action_id
|
|
||||||
self._action_button.set_label(action_text)
|
|
||||||
|
|
||||||
def __button_clicked(self, button):
|
|
||||||
self.emit("action", self._action_id)
|
|
@ -1,6 +0,0 @@
|
|||||||
[Activity]
|
|
||||||
name = Web
|
|
||||||
id = com.redhat.Sugar.BrowserActivity
|
|
||||||
icon = activity-web
|
|
||||||
python_module = browser.BrowserActivity.BrowserActivity
|
|
||||||
show_launcher = no
|
|
@ -1,6 +1,11 @@
|
|||||||
sugardir = $(pkgdatadir)/activities/web
|
sugardir = $(pkgdatadir)/activities/web
|
||||||
sugar_PYTHON = \
|
sugar_PYTHON = \
|
||||||
__init__.py \
|
__init__.py \
|
||||||
|
linkscontroller.py \
|
||||||
|
linksmodel.py \
|
||||||
|
linksview.py \
|
||||||
|
stylesheet.py \
|
||||||
|
toolbar.py \
|
||||||
webactivity.py \
|
webactivity.py \
|
||||||
webbrowser.py
|
webbrowser.py
|
||||||
|
|
||||||
|
@ -47,7 +47,6 @@ AC_OUTPUT([
|
|||||||
Makefile
|
Makefile
|
||||||
dbus-installed.conf
|
dbus-installed.conf
|
||||||
activities/Makefile
|
activities/Makefile
|
||||||
activities/browser/Makefile
|
|
||||||
activities/web/Makefile
|
activities/web/Makefile
|
||||||
activities/chat/Makefile
|
activities/chat/Makefile
|
||||||
activities/groupchat/Makefile
|
activities/groupchat/Makefile
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
sugardir = $(pythondir)/sugar/graphics
|
sugardir = $(pythondir)/sugar/graphics
|
||||||
sugar_PYTHON = \
|
sugar_PYTHON = \
|
||||||
__init__.py \
|
__init__.py \
|
||||||
|
bubble.py \
|
||||||
canvasicon.py \
|
canvasicon.py \
|
||||||
colors.py \
|
colors.py \
|
||||||
grid.py \
|
grid.py \
|
||||||
|
Loading…
Reference in New Issue
Block a user