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-07-07 15:00:20 (GMT)
committer Dan Williams <dcbw@redhat.com>2006-07-07 15:00:20 (GMT)
commit8270a84e0955dffabdcd733a572cb2552e58d00a (patch)
tree3508f92cc82727316c724149d6590e1ec8ec93e8 /shell
parent679d92dac8999988b71d5a4fb7f081f824bcfde0 (diff)
Fix activity double-join bug where opening a shared activity twice opened a blank tab
Diffstat (limited to 'shell')
-rw-r--r--shell/StartPage.py30
-rwxr-xr-xshell/shell.py47
2 files changed, 60 insertions, 17 deletions
diff --git a/shell/StartPage.py b/shell/StartPage.py
index a43d8e1..d2f7e44 100644
--- a/shell/StartPage.py
+++ b/shell/StartPage.py
@@ -8,6 +8,7 @@ import xml.sax.saxutils
import gobject
import socket
+import dbus_bindings
from google import google
from sugar.presence.PresenceService import PresenceService
@@ -101,11 +102,12 @@ class ActivitiesModel(gtk.ListStore):
self.append([ title, address, subtitle, service ])
class ActivitiesView(gtk.TreeView):
- def __init__(self, model):
+ def __init__(self, activity_controller, model):
gtk.TreeView.__init__(self, model)
self._owner = None
-
+ self._activity_controller = activity_controller
+
self.set_headers_visible(False)
theme = gtk.icon_theme_get_default()
@@ -160,14 +162,26 @@ class ActivitiesView(gtk.TreeView):
if service is None:
browser_shell.open_browser(address)
- else:
- if not self._owner:
- raise RuntimeError("We don't have an owner yet!")
- serialized_service = service.serialize(self._owner)
+ return
+
+ if not self._owner:
+ raise RuntimeError("We don't have an owner yet!")
+
+ # If the activity is already started, switch to it
+ service_act_id = service.get_activity_id()
+ if service_act_id and self._activity_controller.have_activity(service_act_id):
+ self._activity_controller.switch_to_activity(service_act_id)
+ return
+
+ # Start a new activity
+ serialized_service = service.serialize(self._owner)
+ try:
browser_shell.open_browser(address, serialized_service)
+ except dbus_bindings.DBusException, exc:
+ pass
class StartPage(gtk.HBox):
- def __init__(self, ac_signal_object):
+ def __init__(self, activity_controller, ac_signal_object):
gtk.HBox.__init__(self)
self._ac_signal_object = ac_signal_object
@@ -245,7 +259,7 @@ class StartPage(gtk.HBox):
self._activities_model = ActivitiesModel()
owner = self._pservice.get_owner()
- self._activities = ActivitiesView(self._activities_model)
+ self._activities = ActivitiesView(activity_controller, self._activities_model)
sw.add(self._activities)
self._activities.show()
diff --git a/shell/shell.py b/shell/shell.py
index c293d5f..a3f07c8 100755
--- a/shell/shell.py
+++ b/shell/shell.py
@@ -106,7 +106,8 @@ class ActivityHost(dbus.service.Object):
self.peer_service.got_focus()
def lost_focus(self):
- self.peer_service.lost_focus()
+ if self.peer_service != None:
+ self.peer_service.lost_focus()
def get_chat(self):
return self._activity_chat
@@ -211,7 +212,7 @@ class ActivityHost(dbus.service.Object):
in_signature="ayibiiii", \
out_signature="")
def set_tab_icon(self, data, colorspace, has_alpha, bits_per_sample, width, height, rowstride):
- #print "width=%d, height=%d"%(width, height)
+ #print "width=%d, height=%d"%(width, height)
#print " data = ", data
pixstr = ""
for c in data:
@@ -329,7 +330,7 @@ class ActivityContainer(dbus.service.Object):
self.notebook.set_scrollable(True)
tab_label = gtk.Label("Everyone")
- self._start_page = StartPage(self._signal_helper)
+ self._start_page = StartPage(self, self._signal_helper)
self.notebook.append_page(self._start_page, tab_label)
self._start_page.show()
@@ -376,6 +377,9 @@ class ActivityContainer(dbus.service.Object):
self.window.show()
def set_current_activity(self, activity):
+ if self.current_activity != None:
+ self.current_activity.lost_focus()
+
self.current_activity = activity
self._presence_window.set_activity(activity)
@@ -388,16 +392,35 @@ class ActivityContainer(dbus.service.Object):
# For some reason the substitution screw up window position
self._chat_wm.update()
+ if self.current_activity != None:
+ self.current_activity.got_focus()
+
def notebook_tab_changed(self, notebook, page, page_number):
new_activity = notebook.get_nth_page(page_number).get_data("sugar-activity")
-
- if self.current_activity != None:
- self.current_activity.lost_focus()
-
self.set_current_activity(new_activity)
- if self.current_activity != None:
- self.current_activity.got_focus()
+ def switch_to_activity(self, activity_id):
+ found = False
+ for owner, activity in self.activities:
+ if activity.get_host_activity_id() == activity_id:
+ found = True
+ break
+ if not found:
+ return
+
+ # Find the activity in the notebook
+ activity_page = None
+ npages = self.notebook.get_n_pages()
+ for pageno in range(1, npages):
+ activity = self.notebook.get_nth_page(pageno).get_data("sugar-activity")
+ if activity and activity.get_host_activity_id() == activity_id:
+ activity_page = pageno
+ break
+ if not activity_page:
+ return
+
+ print "switching to activity page %d" % activity_page
+ self.notebook.set_current_page(activity_page)
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)
@@ -408,6 +431,12 @@ class ActivityContainer(dbus.service.Object):
self.activities.remove((owner, activity))
#self.__print_activities()
+ def have_activity(self, activity_id):
+ for owner, activity in self.activities:
+ list_activity_id = activity.get_host_activity_id()
+ if activity_id == list_activity_id:
+ return True
+ return False
@dbus.service.method("com.redhat.Sugar.Shell.ActivityContainer", \
in_signature="ss", \