Add a bunch of files I forgot
This commit is contained in:
parent
b10be5bf00
commit
c566726f46
7
activities/web/Makefile.am
Normal file
7
activities/web/Makefile.am
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
sugardir = $(pkgdatadir)/activities/web
|
||||||
|
sugar_PYTHON = \
|
||||||
|
__init__.py \
|
||||||
|
webactivity.py \
|
||||||
|
webbrowser.py
|
||||||
|
|
||||||
|
EXTRA_DIST = web.activity
|
0
activities/web/__init__.py
Normal file
0
activities/web/__init__.py
Normal file
40
activities/web/toolbar.py
Normal file
40
activities/web/toolbar.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import gtk
|
||||||
|
|
||||||
|
class Toolbar(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()
|
14
activities/web/webactivity.py
Normal file
14
activities/web/webactivity.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
from sugar.activity.Activity import Activity
|
||||||
|
from webbrowser import WebBrowser
|
||||||
|
|
||||||
|
_HOMEPAGE = 'http://www.google.com'
|
||||||
|
|
||||||
|
class WebActivity(Activity):
|
||||||
|
def __init__(self):
|
||||||
|
Activity.__init__(self)
|
||||||
|
|
||||||
|
self._browser = WebBrowser()
|
||||||
|
self.add(self._browser)
|
||||||
|
self._browser.show()
|
||||||
|
|
||||||
|
self._browser.load_url(_HOMEPAGE)
|
73
activities/web/webbrowser.py
Normal file
73
activities/web/webbrowser.py
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
import gobject
|
||||||
|
|
||||||
|
from _sugar import Browser
|
||||||
|
|
||||||
|
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 WebBrowser(Browser):
|
||||||
|
__gtype_name__ = "SugarWebBrowser"
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
Browser.__init__(self)
|
||||||
|
|
||||||
|
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)
|
Loading…
Reference in New Issue
Block a user