More work on the new design
This commit is contained in:
parent
0cbe559dbf
commit
d4cb9a2714
@ -26,7 +26,10 @@ class BrowserActivity(Activity):
|
|||||||
def __init__(self, args):
|
def __init__(self, args):
|
||||||
Activity.__init__(self, _BROWSER_ACTIVITY_TYPE)
|
Activity.__init__(self, _BROWSER_ACTIVITY_TYPE)
|
||||||
|
|
||||||
self.uri = args[0]
|
if len(args) > 0:
|
||||||
|
self.uri = args[0]
|
||||||
|
else:
|
||||||
|
self.uri = 'http://www.google.com'
|
||||||
|
|
||||||
self._mode = BrowserActivity.SOLO
|
self._mode = BrowserActivity.SOLO
|
||||||
self._share_service = None
|
self._share_service = None
|
||||||
@ -76,11 +79,7 @@ class BrowserActivity(Activity):
|
|||||||
self._notif_bar.show()
|
self._notif_bar.show()
|
||||||
|
|
||||||
def on_connected_to_shell(self):
|
def on_connected_to_shell(self):
|
||||||
self.set_ellipsize_tab(True)
|
self.set_title("Web Page")
|
||||||
self.set_can_close(True)
|
|
||||||
self.set_tab_text("Web Page")
|
|
||||||
self.set_tab_icon(name="web-browser")
|
|
||||||
self.set_show_tab_icon(True)
|
|
||||||
|
|
||||||
vbox = gtk.VBox()
|
vbox = gtk.VBox()
|
||||||
|
|
||||||
@ -99,10 +98,7 @@ class BrowserActivity(Activity):
|
|||||||
vbox.pack_start(nav_toolbar, False)
|
vbox.pack_start(nav_toolbar, False)
|
||||||
nav_toolbar.show()
|
nav_toolbar.show()
|
||||||
|
|
||||||
plug = self.gtk_plug()
|
self.add(vbox)
|
||||||
plug.add(vbox)
|
|
||||||
plug.show()
|
|
||||||
|
|
||||||
vbox.show()
|
vbox.show()
|
||||||
|
|
||||||
logging.debug('Start presence service')
|
logging.debug('Start presence service')
|
||||||
|
@ -7,7 +7,6 @@ from sugar.chat.ChatWindow import ChatWindow
|
|||||||
from sugar.chat.MeshChat import MeshChat
|
from sugar.chat.MeshChat import MeshChat
|
||||||
from ActivityHost import ActivityHost
|
from ActivityHost import ActivityHost
|
||||||
from PresenceWindow import PresenceWindow
|
from PresenceWindow import PresenceWindow
|
||||||
from HomeWindow import HomeWindow
|
|
||||||
from WindowManager import WindowManager
|
from WindowManager import WindowManager
|
||||||
from StartPage import StartPage
|
from StartPage import StartPage
|
||||||
from Owner import ShellOwner
|
from Owner import ShellOwner
|
||||||
@ -66,16 +65,6 @@ class ActivityContainer(dbus.service.Object):
|
|||||||
|
|
||||||
self._mesh_chat = MeshChat()
|
self._mesh_chat = MeshChat()
|
||||||
|
|
||||||
home_window = HomeWindow()
|
|
||||||
wm = WindowManager(home_window)
|
|
||||||
wm.set_type(WindowManager.TYPE_POPUP)
|
|
||||||
wm.set_animation(WindowManager.ANIMATION_SLIDE_IN)
|
|
||||||
wm.set_geometry(0.1, 0.1, 0.9, 0.9)
|
|
||||||
wm.set_key(gtk.keysyms.F2)
|
|
||||||
|
|
||||||
def show(self):
|
|
||||||
self.window.show()
|
|
||||||
|
|
||||||
def set_current_activity(self, activity):
|
def set_current_activity(self, activity):
|
||||||
self.current_activity = activity
|
self.current_activity = activity
|
||||||
self._presence_window.set_activity(activity)
|
self._presence_window.set_activity(activity)
|
||||||
@ -93,26 +82,21 @@ class ActivityContainer(dbus.service.Object):
|
|||||||
self._signal_helper.activity_ended(activity_id)
|
self._signal_helper.activity_ended(activity_id)
|
||||||
self._activities.remove((owner, activity))
|
self._activities.remove((owner, activity))
|
||||||
|
|
||||||
@dbus.service.method("com.redhat.Sugar.Shell.ActivityContainer", \
|
@dbus.service.method("com.redhat.Sugar.Shell.ActivityContainer")
|
||||||
in_signature="ss", \
|
def add_activity(self, default_type):
|
||||||
out_signature="s", \
|
activity = ActivityHost(self._service, default_type)
|
||||||
sender_keyword="sender")
|
self._activities.append(activity)
|
||||||
def add_activity(self, activity_name, default_type, sender):
|
|
||||||
activity = ActivityHost(self, activity_name, default_type)
|
|
||||||
self._activities.append((sender, activity))
|
|
||||||
|
|
||||||
activity_id = activity.get_host_activity_id()
|
activity_id = activity.get_id()
|
||||||
self._signal_helper.activity_started(activity_id)
|
self._signal_helper.activity_started(activity_id)
|
||||||
|
|
||||||
self.current_activity = activity
|
self.set_current_activity(activity)
|
||||||
return activity_id
|
return activity_id
|
||||||
|
|
||||||
@dbus.service.method("com.redhat.Sugar.Shell.ActivityContainer", \
|
@dbus.service.method("com.redhat.Sugar.Shell.ActivityContainer")
|
||||||
in_signature="sss", \
|
def add_activity_with_id(self, default_type, activity_id):
|
||||||
sender_keyword="sender")
|
activity = ActivityHost(self._service, default_type, activity_id)
|
||||||
def add_activity_with_id(self, activity_name, default_type, activity_id, sender):
|
self._activities.append(activity)
|
||||||
activity = ActivityHost(self, activity_name, default_type, activity_id)
|
|
||||||
self._activities.append((sender, activity))
|
|
||||||
activity_id = activity.get_host_activity_id()
|
activity_id = activity.get_host_activity_id()
|
||||||
self._signal_helper.activity_started(activity_id)
|
self._signal_helper.activity_started(activity_id)
|
||||||
self.current_activity = activity
|
self.current_activity = activity
|
||||||
|
@ -2,6 +2,10 @@ import dbus
|
|||||||
import gtk
|
import gtk
|
||||||
import gobject
|
import gobject
|
||||||
|
|
||||||
|
from sugar.chat.ActivityChat import ActivityChat
|
||||||
|
from WindowManager import WindowManager
|
||||||
|
import sugar.util
|
||||||
|
|
||||||
class ActivityHostSignalHelper(gobject.GObject):
|
class ActivityHostSignalHelper(gobject.GObject):
|
||||||
__gsignals__ = {
|
__gsignals__ = {
|
||||||
'shared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([]))
|
'shared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([]))
|
||||||
@ -15,22 +19,22 @@ class ActivityHostSignalHelper(gobject.GObject):
|
|||||||
self.emit('shared')
|
self.emit('shared')
|
||||||
|
|
||||||
class ActivityHost(dbus.service.Object):
|
class ActivityHost(dbus.service.Object):
|
||||||
def __init__(self, default_type, activity_id = None):
|
def __init__(self, bus_name, default_type, activity_id = None):
|
||||||
if activity_id is None:
|
if activity_id is None:
|
||||||
self.activity_id = sugar.util.unique_id()
|
self._activity_id = sugar.util.unique_id()
|
||||||
else:
|
else:
|
||||||
self.activity_id = activity_id
|
self._activity_id = activity_id
|
||||||
self._default_type = default_type
|
self._default_type = default_type
|
||||||
|
|
||||||
self.dbus_object_name = "/com/redhat/Sugar/Shell/Activities/%s" % self.activity_id
|
self.dbus_object_name = "/com/redhat/Sugar/Shell/Activities/%s" % self._activity_id
|
||||||
dbus.service.Object.__init__(self, activity_container.service, self.dbus_object_name)
|
dbus.service.Object.__init__(self, bus_name, self.dbus_object_name)
|
||||||
|
|
||||||
self._signal_helper = ActivityHostSignalHelper(self)
|
self._signal_helper = ActivityHostSignalHelper(self)
|
||||||
self.peer_service = None
|
self.peer_service = None
|
||||||
self._shared = False
|
self._shared = False
|
||||||
self._window = gtk.Window()
|
|
||||||
self._create_chat()
|
self._create_chat()
|
||||||
|
|
||||||
def _create_chat(self):
|
def _create_chat(self):
|
||||||
self._activity_chat = ActivityChat(self)
|
self._activity_chat = ActivityChat(self)
|
||||||
|
|
||||||
@ -54,15 +58,10 @@ class ActivityHost(dbus.service.Object):
|
|||||||
def connect(self, signal, func):
|
def connect(self, signal, func):
|
||||||
self._signal_helper.connect(signal, func)
|
self._signal_helper.connect(signal, func)
|
||||||
|
|
||||||
def get_host_activity_id(self):
|
|
||||||
"""Real function that the shell should use for getting the
|
|
||||||
activity's ID."""
|
|
||||||
return self.activity_id
|
|
||||||
|
|
||||||
def get_id(self):
|
def get_id(self):
|
||||||
"""Interface-type function to match activity.Activity's
|
"""Interface-type function to match activity.Activity's
|
||||||
get_id() function."""
|
get_id() function."""
|
||||||
return self.activity_id
|
return self._activity_id
|
||||||
|
|
||||||
def default_type(self):
|
def default_type(self):
|
||||||
"""Interface-type function to match activity.Activity's
|
"""Interface-type function to match activity.Activity's
|
||||||
@ -81,25 +80,20 @@ class ActivityHost(dbus.service.Object):
|
|||||||
self._shared = True
|
self._shared = True
|
||||||
self._signal_helper.emit_shared()
|
self._signal_helper.emit_shared()
|
||||||
|
|
||||||
@dbus.service.method("com.redhat.Sugar.Shell.ActivityHost", \
|
@dbus.service.method("com.redhat.Sugar.Shell.ActivityHost")
|
||||||
in_signature="ss", \
|
|
||||||
out_signature="")
|
|
||||||
def set_peer_service_name(self, peer_service_name, peer_object_name):
|
def set_peer_service_name(self, peer_service_name, peer_object_name):
|
||||||
self.__peer_service_name = peer_service_name
|
self.__peer_service_name = peer_service_name
|
||||||
self.__peer_object_name = peer_object_name
|
self.__peer_object_name = peer_object_name
|
||||||
self.peer_service = dbus.Interface(self.activity_container.bus.get_object( \
|
session_bus = dbus.SessionBus()
|
||||||
|
self.peer_service = dbus.Interface(session_bus.get_object( \
|
||||||
self.__peer_service_name, self.__peer_object_name), \
|
self.__peer_service_name, self.__peer_object_name), \
|
||||||
"com.redhat.Sugar.Activity")
|
"com.redhat.Sugar.Activity")
|
||||||
self.activity_container.bus.add_signal_receiver(self._shared_signal,
|
session_bus.add_signal_receiver(self._shared_signal,
|
||||||
signal_name="ActivityShared",
|
signal_name="ActivityShared",
|
||||||
dbus_interface="com.redhat.Sugar.Activity",
|
dbus_interface="com.redhat.Sugar.Activity",
|
||||||
named_service=self.__peer_service_name,
|
named_service=self.__peer_service_name,
|
||||||
path=self.__peer_object_name)
|
path=self.__peer_object_name)
|
||||||
|
|
||||||
@dbus.service.method("com.redhat.Sugar.Shell.ActivityHost")
|
|
||||||
def set_can_close(self, can_close):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@dbus.service.method("com.redhat.Sugar.Shell.ActivityHost")
|
@dbus.service.method("com.redhat.Sugar.Shell.ActivityHost")
|
||||||
def set_has_changes(self, has_changes):
|
def set_has_changes(self, has_changes):
|
||||||
pass
|
pass
|
||||||
|
@ -25,6 +25,5 @@ class ActivityRegistry(dbus.service.Object):
|
|||||||
def add(self, name, title):
|
def add(self, name, title):
|
||||||
self._activities.append(ActivityInfo(name, title))
|
self._activities.append(ActivityInfo(name, title))
|
||||||
|
|
||||||
@dbus.service.method("com.redhat.Sugar.ActivityRegistry")
|
|
||||||
def list_activities(self):
|
def list_activities(self):
|
||||||
return self._activities
|
return self._activities
|
||||||
|
@ -24,6 +24,7 @@ class ConsoleLogger(dbus.service.Object):
|
|||||||
console_wm = WindowManager(self._window)
|
console_wm = WindowManager(self._window)
|
||||||
console_wm.set_type(WindowManager.TYPE_POPUP)
|
console_wm.set_type(WindowManager.TYPE_POPUP)
|
||||||
console_wm.set_geometry(0.1, 0.1, 0.8, 0.8)
|
console_wm.set_geometry(0.1, 0.1, 0.8, 0.8)
|
||||||
|
console_wm.set_key(gtk.keysyms.F3)
|
||||||
|
|
||||||
def _create_console(self, application):
|
def _create_console(self, application):
|
||||||
sw = gtk.ScrolledWindow()
|
sw = gtk.ScrolledWindow()
|
||||||
|
@ -1,45 +1,50 @@
|
|||||||
|
from gettext import gettext as _
|
||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
|
|
||||||
from sugar.activity import Activity
|
from sugar.activity import Activity
|
||||||
|
|
||||||
class NewActivityButton(gtk.Button):
|
class NewActivityButton(gtk.MenuToolButton):
|
||||||
def __init__(self):
|
def __init__(self, shell):
|
||||||
gtk.Button.__init__(self)
|
gtk.MenuToolButton.__init__(self, None, _('New Activity'))
|
||||||
|
|
||||||
hbox = gtk.HBox(False, 6)
|
self._shell = shell
|
||||||
|
|
||||||
label = gtk.Label("New Activity")
|
self.set_menu(gtk.Menu())
|
||||||
hbox.pack_start(label)
|
self.connect("show-menu", self.__show_menu_cb)
|
||||||
label.show()
|
|
||||||
|
|
||||||
arrow = gtk.Arrow(gtk.ARROW_DOWN, gtk.SHADOW_NONE)
|
|
||||||
hbox.pack_start(arrow)
|
|
||||||
arrow.show()
|
|
||||||
|
|
||||||
self.set_image(hbox)
|
|
||||||
|
|
||||||
self.connect("clicked", self.__clicked_cb)
|
|
||||||
|
|
||||||
def __clicked_cb(self, button):
|
def __show_menu_cb(self, button):
|
||||||
print Activity.list_activities
|
menu = gtk.Menu()
|
||||||
|
|
||||||
class Toolbar(gtk.HBox):
|
|
||||||
def __init__(self):
|
|
||||||
gtk.HBox.__init__(self)
|
|
||||||
|
|
||||||
new_activity_button = NewActivityButton()
|
for activity_info in self._shell.get_registry().list_activities():
|
||||||
self.pack_start(new_activity_button)
|
item = gtk.MenuItem(activity_info.get_title(), False)
|
||||||
|
name = activity_info.get_name()
|
||||||
|
item.connect('activate', self.__menu_item_activate_cb, name)
|
||||||
|
menu.append(item)
|
||||||
|
item.show()
|
||||||
|
|
||||||
|
self.set_menu(menu)
|
||||||
|
|
||||||
|
def __menu_item_activate_cb(self, item, name):
|
||||||
|
Activity.create(name)
|
||||||
|
|
||||||
|
class Toolbar(gtk.Toolbar):
|
||||||
|
def __init__(self, shell):
|
||||||
|
gtk.Toolbar.__init__(self)
|
||||||
|
|
||||||
|
new_activity_button = NewActivityButton(shell)
|
||||||
|
self.insert(new_activity_button, -1)
|
||||||
new_activity_button.show()
|
new_activity_button.show()
|
||||||
|
|
||||||
class HomeWindow(gtk.Window):
|
class HomeWindow(gtk.Window):
|
||||||
def __init__(self):
|
def __init__(self, shell):
|
||||||
gtk.Window.__init__(self)
|
gtk.Window.__init__(self)
|
||||||
|
|
||||||
vbox = gtk.VBox()
|
vbox = gtk.VBox()
|
||||||
|
|
||||||
toolbar = Toolbar()
|
toolbar = Toolbar(shell)
|
||||||
vbox.pack_start(toolbar)
|
vbox.pack_start(toolbar, False)
|
||||||
toolbar.show()
|
toolbar.show()
|
||||||
|
|
||||||
self.add(vbox)
|
self.add(vbox)
|
||||||
|
vbox.show()
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import dbus
|
import dbus
|
||||||
|
import gtk
|
||||||
import gobject
|
import gobject
|
||||||
|
|
||||||
from sugar.LogWriter import LogWriter
|
from sugar.LogWriter import LogWriter
|
||||||
@ -6,6 +7,7 @@ from WindowManager import WindowManager
|
|||||||
from ConsoleLogger import ConsoleLogger
|
from ConsoleLogger import ConsoleLogger
|
||||||
from ActivityContainer import ActivityContainer
|
from ActivityContainer import ActivityContainer
|
||||||
from ActivityRegistry import ActivityRegistry
|
from ActivityRegistry import ActivityRegistry
|
||||||
|
from HomeWindow import HomeWindow
|
||||||
|
|
||||||
class Shell(gobject.GObject):
|
class Shell(gobject.GObject):
|
||||||
__gsignals__ = {
|
__gsignals__ = {
|
||||||
@ -22,12 +24,29 @@ class Shell(gobject.GObject):
|
|||||||
log_writer = LogWriter("Shell", False)
|
log_writer = LogWriter("Shell", False)
|
||||||
log_writer.start()
|
log_writer.start()
|
||||||
|
|
||||||
registry = ActivityRegistry()
|
self._registry = ActivityRegistry()
|
||||||
|
|
||||||
|
root_window = gtk.Window()
|
||||||
|
root_window.set_title('Sugar')
|
||||||
|
wm = WindowManager(root_window)
|
||||||
|
wm.set_type(WindowManager.TYPE_ROOT)
|
||||||
|
wm.show()
|
||||||
|
|
||||||
|
home_window = HomeWindow(self)
|
||||||
|
home_window.set_transient_for(root_window)
|
||||||
|
wm = WindowManager(home_window)
|
||||||
|
wm.set_type(WindowManager.TYPE_POPUP)
|
||||||
|
wm.set_animation(WindowManager.ANIMATION_SLIDE_IN)
|
||||||
|
wm.set_geometry(0.1, 0.1, 0.8, 0.8)
|
||||||
|
wm.set_key(gtk.keysyms.F2)
|
||||||
|
wm.show()
|
||||||
|
|
||||||
session_bus = dbus.SessionBus()
|
session_bus = dbus.SessionBus()
|
||||||
service = dbus.service.BusName("com.redhat.Sugar.Shell", bus=session_bus)
|
service = dbus.service.BusName("com.redhat.Sugar.Shell", bus=session_bus)
|
||||||
|
|
||||||
activity_container = ActivityContainer(service, session_bus)
|
activity_container = ActivityContainer(service, session_bus)
|
||||||
|
|
||||||
|
def get_registry(self):
|
||||||
|
return self._registry
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
shell = Shell()
|
shell = Shell()
|
||||||
|
@ -63,8 +63,9 @@ class SlidingHelper:
|
|||||||
class WindowManager:
|
class WindowManager:
|
||||||
__managers_list = []
|
__managers_list = []
|
||||||
|
|
||||||
TYPE_ACTIVITY = 0
|
TYPE_ROOT = 0
|
||||||
TYPE_POPUP = 1
|
TYPE_ACTIVITY = 1
|
||||||
|
TYPE_POPUP = 2
|
||||||
|
|
||||||
ANIMATION_NONE = 0
|
ANIMATION_NONE = 0
|
||||||
ANIMATION_SLIDE_IN = 1
|
ANIMATION_SLIDE_IN = 1
|
||||||
@ -134,7 +135,7 @@ class WindowManager:
|
|||||||
screen_height = DEFAULT_HEIGHT
|
screen_height = DEFAULT_HEIGHT
|
||||||
|
|
||||||
for manager in WindowManager.__managers_list:
|
for manager in WindowManager.__managers_list:
|
||||||
if manager._window_type == WindowManager.TYPE_ACTIVITY:
|
if manager._window_type == WindowManager.TYPE_ROOT:
|
||||||
screen_width = manager._window.allocation.width
|
screen_width = manager._window.allocation.width
|
||||||
screen_height = manager._window.allocation.height
|
screen_height = manager._window.allocation.height
|
||||||
|
|
||||||
@ -143,7 +144,7 @@ class WindowManager:
|
|||||||
def _get_screen_position(self):
|
def _get_screen_position(self):
|
||||||
result = (0, 0)
|
result = (0, 0)
|
||||||
for manager in WindowManager.__managers_list:
|
for manager in WindowManager.__managers_list:
|
||||||
if manager._window_type == WindowManager.TYPE_ACTIVITY:
|
if manager._window_type == WindowManager.TYPE_ROOT:
|
||||||
result = manager._window.get_position()
|
result = manager._window.get_position()
|
||||||
|
|
||||||
return result
|
return result
|
||||||
@ -171,7 +172,8 @@ class WindowManager:
|
|||||||
self._window.set_skip_taskbar_hint(True)
|
self._window.set_skip_taskbar_hint(True)
|
||||||
|
|
||||||
def _update_size(self):
|
def _update_size(self):
|
||||||
if self._window_type == WindowManager.TYPE_ACTIVITY:
|
if (self._window_type == WindowManager.TYPE_ACTIVITY) or \
|
||||||
|
(self._window_type == WindowManager.TYPE_ROOT):
|
||||||
self._window.resize(DEFAULT_WIDTH, DEFAULT_HEIGHT)
|
self._window.resize(DEFAULT_WIDTH, DEFAULT_HEIGHT)
|
||||||
else:
|
else:
|
||||||
(width, height) = self._transform_dimensions()
|
(width, height) = self._transform_dimensions()
|
||||||
|
@ -68,8 +68,8 @@ class ActivityFactory(dbus.service.Object):
|
|||||||
gobject.idle_add(self._start_activity_cb, activity, service)
|
gobject.idle_add(self._start_activity_cb, activity, service)
|
||||||
|
|
||||||
@dbus.service.method("com.redhat.Sugar.ActivityFactory")
|
@dbus.service.method("com.redhat.Sugar.ActivityFactory")
|
||||||
def create(self, args):
|
def create(self):
|
||||||
self.create_with_service(None, args)
|
self.create_with_service(None, [])
|
||||||
|
|
||||||
def _start_activity_cb(self, activity, service):
|
def _start_activity_cb(self, activity, service):
|
||||||
activity.connect_to_shell(service)
|
activity.connect_to_shell(service)
|
||||||
@ -84,17 +84,17 @@ def create(activity_name, service = None, args = None):
|
|||||||
proxy_obj = bus.get_object(factory_name, factory_path)
|
proxy_obj = bus.get_object(factory_name, factory_path)
|
||||||
factory = dbus.Interface(proxy_obj, "com.redhat.Sugar.ActivityFactory")
|
factory = dbus.Interface(proxy_obj, "com.redhat.Sugar.ActivityFactory")
|
||||||
|
|
||||||
if service:
|
if service and args:
|
||||||
serialized_service = service.serialize(service)
|
serialized_service = service.serialize(service)
|
||||||
factory.create_with_service(serialized_service, args)
|
factory.create_with_service(serialized_service, args)
|
||||||
else:
|
else:
|
||||||
factory.create(args)
|
factory.create()
|
||||||
|
|
||||||
def _get_registry():
|
def _get_registry():
|
||||||
bus = dbus.SessionBus()
|
bus = dbus.SessionBus()
|
||||||
proxy_obj = bus.get_object("com.redhat.Sugar.ActivityRegistry",
|
proxy_obj = bus.get_object("com.redhat.Sugar.ActivityRegistry",
|
||||||
"/com/redhat/Sugar/ActivityRegistry")
|
"/com/redhat/Sugar/ActivityRegistry")
|
||||||
registry = dbus.Interface(proxy_obj, "com.redhat.Sugar.ActivityRegistry")
|
return dbus.Interface(proxy_obj, "com.redhat.Sugar.ActivityRegistry")
|
||||||
|
|
||||||
def list_activities():
|
def list_activities():
|
||||||
registry = _get_registry()
|
registry = _get_registry()
|
||||||
@ -168,10 +168,10 @@ class ActivityDbusService(dbus.service.Object):
|
|||||||
SHELL_SERVICE_NAME + ".ActivityContainer")
|
SHELL_SERVICE_NAME + ".ActivityContainer")
|
||||||
|
|
||||||
if service is None:
|
if service is None:
|
||||||
self._activity_id = self._activity_container.add_activity("", self._activity.default_type())
|
self._activity_id = self._activity_container.add_activity(self._activity.default_type())
|
||||||
else:
|
else:
|
||||||
self._activity_id = service.get_activity_id()
|
self._activity_id = service.get_activity_id()
|
||||||
self._activity_container.add_activity_with_id("", self._activity.default_type(), self._activity_id)
|
self._activity_container.add_activity_with_id(self._activity.default_type(), self._activity_id)
|
||||||
|
|
||||||
self._object_path = SHELL_SERVICE_PATH + "/Activities/%s" % self._activity_id
|
self._object_path = SHELL_SERVICE_PATH + "/Activities/%s" % self._activity_id
|
||||||
|
|
||||||
@ -236,10 +236,12 @@ class ActivityDbusService(dbus.service.Object):
|
|||||||
def ActivityShared(self):
|
def ActivityShared(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class Activity(object):
|
class Activity(gtk.Window):
|
||||||
"""Base Activity class that all other Activities derive from."""
|
"""Base Activity class that all other Activities derive from."""
|
||||||
|
|
||||||
def __init__(self, default_type):
|
def __init__(self, default_type):
|
||||||
|
gtk.Window.__init__(self)
|
||||||
|
|
||||||
self._dbus_service = self._get_new_dbus_service()
|
self._dbus_service = self._get_new_dbus_service()
|
||||||
self._dbus_service.register_callback(ON_CONNECTED_TO_SHELL_CB, self._internal_on_connected_to_shell_cb)
|
self._dbus_service.register_callback(ON_CONNECTED_TO_SHELL_CB, self._internal_on_connected_to_shell_cb)
|
||||||
self._dbus_service.register_callback(ON_DISCONNECTED_FROM_SHELL_CB, self._internal_on_disconnected_from_shell_cb)
|
self._dbus_service.register_callback(ON_DISCONNECTED_FROM_SHELL_CB, self._internal_on_disconnected_from_shell_cb)
|
||||||
@ -249,7 +251,6 @@ class Activity(object):
|
|||||||
self._dbus_service.register_callback(ON_LOST_FOCUS_CB, self._internal_on_lost_focus_cb)
|
self._dbus_service.register_callback(ON_LOST_FOCUS_CB, self._internal_on_lost_focus_cb)
|
||||||
self._dbus_service.register_callback(ON_GOT_FOCUS_CB, self._internal_on_got_focus_cb)
|
self._dbus_service.register_callback(ON_GOT_FOCUS_CB, self._internal_on_got_focus_cb)
|
||||||
self._has_focus = False
|
self._has_focus = False
|
||||||
self._plug = None
|
|
||||||
self._initial_service = None
|
self._initial_service = None
|
||||||
self._activity_object = None
|
self._activity_object = None
|
||||||
self._shared = False
|
self._shared = False
|
||||||
@ -258,9 +259,6 @@ class Activity(object):
|
|||||||
self._default_type = default_type
|
self._default_type = default_type
|
||||||
|
|
||||||
def _cleanup(self):
|
def _cleanup(self):
|
||||||
if self._plug:
|
|
||||||
self._plug.destroy()
|
|
||||||
self._plug = None
|
|
||||||
if self._dbus_service:
|
if self._dbus_service:
|
||||||
del self._dbus_service
|
del self._dbus_service
|
||||||
self._dbus_service = None
|
self._dbus_service = None
|
||||||
@ -292,15 +290,13 @@ class Activity(object):
|
|||||||
def connect_to_shell(self, service = None):
|
def connect_to_shell(self, service = None):
|
||||||
"""Called by our controller to tell us to initialize and connect
|
"""Called by our controller to tell us to initialize and connect
|
||||||
to the shell."""
|
to the shell."""
|
||||||
|
self.show()
|
||||||
self._dbus_service.connect_to_shell(service)
|
self._dbus_service.connect_to_shell(service)
|
||||||
|
|
||||||
def _internal_on_connected_to_shell_cb(self, activity_object, activity_id, service=None):
|
def _internal_on_connected_to_shell_cb(self, activity_object, activity_id, service=None):
|
||||||
"""Callback when the dbus service object has connected to the shell."""
|
"""Callback when the dbus service object has connected to the shell."""
|
||||||
self._activity_object = activity_object
|
self._activity_object = activity_object
|
||||||
self._activity_id = activity_id
|
self._activity_id = activity_id
|
||||||
self._window_id = self._activity_object.get_host_xembed_id()
|
|
||||||
print "Activity: XEMBED window ID is %s" % self._window_id
|
|
||||||
self._plug = gtk.Plug(self._window_id)
|
|
||||||
self._initial_service = service
|
self._initial_service = service
|
||||||
if service:
|
if service:
|
||||||
self.set_shared()
|
self.set_shared()
|
||||||
@ -335,10 +331,6 @@ class Activity(object):
|
|||||||
self.set_has_changes(False)
|
self.set_has_changes(False)
|
||||||
self.on_got_focus()
|
self.on_got_focus()
|
||||||
|
|
||||||
def gtk_plug(self):
|
|
||||||
"""Return our GtkPlug widget."""
|
|
||||||
return self._plug
|
|
||||||
|
|
||||||
def set_ellipsize_tab(self, ellipsize):
|
def set_ellipsize_tab(self, ellipsize):
|
||||||
"""Sets this Activity's tab text to be ellipsized or not."""
|
"""Sets this Activity's tab text to be ellipsized or not."""
|
||||||
self._activity_object.set_ellipsize_tab(ellipsize)
|
self._activity_object.set_ellipsize_tab(ellipsize)
|
||||||
|
Loading…
Reference in New Issue
Block a user