Shutdown the factory when all activities has been destroyed.

Initialize the profile.
This commit is contained in:
Marco Pesenti Gritti 2006-10-13 11:24:07 +02:00
parent c7fdae2606
commit 395472edea
2 changed files with 17 additions and 1 deletions

View File

@ -1,7 +1,9 @@
import gtk
from gettext import gettext as _ from gettext import gettext as _
import gtk
import gtkmozembed
from sugar.activity.Activity import Activity from sugar.activity.Activity import Activity
from sugar import env
from webbrowser import WebBrowser from webbrowser import WebBrowser
from toolbar import Toolbar from toolbar import Toolbar
@ -32,3 +34,6 @@ class WebActivity(Activity):
def _title_changed_cb(self, embed, pspec): def _title_changed_cb(self, embed, pspec):
self.set_title(embed.props.title) self.set_title(embed.props.title)
def start():
gtkmozembed.set_profile_path(env.get_profile_path(), 'gecko')

View File

@ -4,6 +4,7 @@ import logging
import dbus import dbus
import dbus.service import dbus.service
import gobject import gobject
import gtk
from sugar.presence.PresenceService import PresenceService from sugar.presence.PresenceService import PresenceService
from sugar.activity import Activity from sugar.activity import Activity
@ -21,6 +22,7 @@ class ActivityFactory(dbus.service.Object):
def __init__(self, activity_type, activity_class): def __init__(self, activity_type, activity_class):
self._activity_type = activity_type self._activity_type = activity_type
self._activities = []
splitted_module = activity_class.rsplit('.', 1) splitted_module = activity_class.rsplit('.', 1)
module_name = splitted_module[0] module_name = splitted_module[0]
@ -43,8 +45,17 @@ class ActivityFactory(dbus.service.Object):
def create(self): def create(self):
activity = self._class() activity = self._class()
activity.set_type(self._activity_type) activity.set_type(self._activity_type)
self._activities.append(activity)
activity.connect('destroy', self._activity_destroy_cb)
return activity.window.xid return activity.window.xid
def _activity_destroy_cb(self, activity):
self._activities.remove(activity)
if len(self._activities) == 0:
gtk.main_quit()
def create(activity_name): def create(activity_name):
"""Create a new activity from his name.""" """Create a new activity from his name."""
bus = dbus.SessionBus() bus = dbus.SessionBus()