Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2006-04-21 17:32:03 (GMT)
committer Dan Williams <dcbw@redhat.com>2006-04-21 17:32:03 (GMT)
commitd13cf9a91d2fb8fb2802504ca6dcb10810dcefdf (patch)
tree2489ccfe974dbb7c7e64784670d32a9311957061 /shell
parenta77e678a556c9f6920821e9dd85453094a203b65 (diff)
Make focus poking async and introduce activity_shutdown in the example-activity.
Diffstat (limited to 'shell')
-rwxr-xr-xshell/example-activity/example-activity.py30
-rwxr-xr-xshell/src/shell.py41
2 files changed, 63 insertions, 8 deletions
diff --git a/shell/example-activity/example-activity.py b/shell/example-activity/example-activity.py
index 619f04d..17b640c 100755
--- a/shell/example-activity/example-activity.py
+++ b/shell/example-activity/example-activity.py
@@ -2,6 +2,7 @@
import string
+import gc
import dbus
import dbus.service
import dbus.glib
@@ -86,6 +87,17 @@ class Activity(dbus.service.Object):
def activity_get_id(self):
return self.__activity_id
+
+ def __reply_cb(self):
+ print "in __reply_cb"
+ self.activity_on_disconnected_from_shell()
+
+ def __error_cb(self, error):
+ print "in __error_cb"
+
+ def activity_shutdown(self):
+ self.__activity_object.shutdown(reply_handler = self.__reply_cb, error_handler = self.__error_cb)
+
# pure virtual methods
def activity_on_connected_to_shell(self):
@@ -134,11 +146,16 @@ class ExampleActivity(Activity):
def activity_on_disconnected_from_shell(self):
print "act %d: in activity_on_disconnected_to_shell"%self.activity_get_id()
print "act %d: Shell disappeared..."%self.activity_get_id()
- deferred_exit()
+ plug = self.activity_get_gtk_plug()
+ plug.destroy()
+
+ del self
+
+ gc.collect()
def activity_on_close_from_user(self):
print "act %d: in activity_on_close_from_user"%self.activity_get_id()
- deferred_exit()
+ self.activity_shutdown()
def activity_on_lost_focus(self):
print "act %d: in activity_on_lost_focus"%self.activity_get_id()
@@ -146,16 +163,19 @@ class ExampleActivity(Activity):
def activity_on_got_focus(self):
print "act %d: in activity_on_got_focus"%self.activity_get_id()
+ def __del__(self):
+ print "in __del__ for ExampleActivity"
+
if len(sys.argv) != 2:
print "usage: example-activity.py <name_of_activity>"
sys.exit(1)
+gc.set_debug(gc.DEBUG_LEAK)
+
example_activity = ExampleActivity(sys.argv[1])
example_activity.activity_connect_to_shell()
-
-example_activity2 = ExampleActivity(sys.argv[1] + " (2nd)")
-example_activity2.activity_connect_to_shell()
+example_activity = None
gtk.main()
diff --git a/shell/src/shell.py b/shell/src/shell.py
index f1c45dc..b450f7b 100755
--- a/shell/src/shell.py
+++ b/shell/src/shell.py
@@ -62,7 +62,7 @@ class ActivityHost(dbus.service.Object):
notebook = self.activity_container.notebook
index = notebook.append_page(self.socket, hbox)
- #notebook.set_current_page(index)
+ notebook.set_current_page(index)
def tab_close_button_clicked(self, button):
self.peer_service.close_from_user()
@@ -92,6 +92,24 @@ class ActivityHost(dbus.service.Object):
def set_tab_text(self, text):
self.tab_label.set_text(text)
+ @dbus.service.method("com.redhat.Sugar.Shell.ActivityHost", \
+ in_signature="", \
+ out_signature="")
+ def shutdown(self):
+ print "shutdown"
+ for owner, activity in self.activity_container.activities[:]:
+ if activity == self:
+ self.activity_container.activities.remove((owner, activity))
+
+ for i in range(self.activity_container.notebook.get_n_pages()):
+ child = self.activity_container.notebook.get_nth_page(i)
+ if child == self.socket:
+ print "found child"
+ self.activity_container.notebook.remove_page(i)
+ break
+
+ del self
+
def get_host_activity_id(self):
return self.activity_id
@@ -114,6 +132,7 @@ class ActivityContainer(dbus.service.Object):
self.window = gtk.Window()
self.window.set_title("OLPC Sugar")
self.window.resize(640, 480)
+ self.window.set_geometry_hints(min_width = 640, max_width = 640, min_height = 480, max_height = 480)
self.notebook = gtk.Notebook()
tab_label = gtk.Label("My Laptop")
empty_label = gtk.Label("This activity could launch other activities / be a help page")
@@ -129,6 +148,13 @@ class ActivityContainer(dbus.service.Object):
self.current_activity = None
+ def __focus_reply_cb(self):
+ pass
+
+ def __focus_error_cb(self, error):
+ pass
+
+
def notebook_tab_changed(self, notebook, page, page_number):
print "in notebook_tab_changed"
new_activity = notebook.get_nth_page(page_number).get_data("sugar-activity")
@@ -136,14 +162,23 @@ class ActivityContainer(dbus.service.Object):
print " New activity: ", new_activity
if self.current_activity != None:
- self.current_activity.peer_service.lost_focus()
+ if self.has_activity(self.current_activity):
+ self.current_activity.peer_service.lost_focus(reply_handler = self.__focus_reply_cb, error_handler = self.__focus_error_cb)
self.current_activity = new_activity
if self.current_activity != None:
- self.current_activity.peer_service.got_focus()
+ if self.has_activity(self.current_activity):
+ self.current_activity.peer_service.got_focus(reply_handler = self.__focus_reply_cb, error_handler = self.__focus_error_cb)
+ def has_activity(self, activity_to_check_for):
+ for owner, activity in self.activities[:]:
+ if activity_to_check_for == activity:
+ return True
+ return False
+
+
def name_owner_changed(self, service_name, old_service_name, new_service_name):
print "in name_owner_changed: svc=%s oldsvc=%s newsvc=%s"%(service_name, old_service_name, new_service_name)
for owner, activity in self.activities[:]: