From 21daa86bcb386240a1902c0bbad960285c900bcf Mon Sep 17 00:00:00 2001 From: erick Date: Sun, 06 Dec 2009 20:07:51 +0000 Subject: Merge branch 'frame_integration' Conflicts: tutorius/overlayer.py --- (limited to 'tutorius') diff --git a/tutorius/TProbe.py b/tutorius/TProbe.py index 2834f0c..acba26f 100644 --- a/tutorius/TProbe.py +++ b/tutorius/TProbe.py @@ -33,6 +33,7 @@ from . import properties from .services import ObjectStore from .dbustools import save_args, ignore, logError +from .gtkutils import find_widget, raddr_lookup import copy """ @@ -57,11 +58,13 @@ class TProbe(dbus.service.Object): a DBUS Interface. """ - def __init__(self, activity, service_proxy=None): + def __init__(self, activity, activity_name, unique_id, service_proxy=None): """ Create and register a TProbe for an activity. @param activity activity reference, must be a gtk container + @param activity_name generic name for the activity + @param unique_id specific name for this instance @param service_proxy A Service proxy object to do the registering """ # Moving the ObjectStore assignment here, in the meantime @@ -77,8 +80,8 @@ class TProbe(dbus.service.Object): ObjectStore().activity = activity - self._activity_name = activity.get_bundle_id() - self._unique_id = activity.get_id() + self._activity_name = activity_name + self._unique_id = unique_id LOGGER.debug("TProbe :: Creating TProbe for %s (%d)", self._activity_name, os.getpid()) LOGGER.debug("TProbe :: Current gobject context: %s", str(gobject.main_context_default())) @@ -94,7 +97,7 @@ class TProbe(dbus.service.Object): self._installedActions = {} self._subscribedEvents = {} - LOGGER.debug("TProbe :: registering '%s' with unique_id '%s'", self._activity_name, activity.get_id()) + LOGGER.debug("TProbe :: registering '%s' with unique_id '%s'", self._activity_name, self._unique_id) self._service_proxy.register_probe(self._activity_name, self._unique_id) def start(self): @@ -149,7 +152,7 @@ class TProbe(dbus.service.Object): action._props.update(loaded_action._props) if not is_editing: - action.do(activity=self._activity) + action.do(activity=self._activity, probe=self) else: action.enter_editmode() action.set_notification_cb(partial(self.update_action, address)) @@ -229,7 +232,7 @@ class TProbe(dbus.service.Object): def callback(*args): self.notify(eventfilter) - eventfilter.install_handlers(callback, activity=self._activity) + eventfilter.install_handlers(callback, activity=self._activity, probe=self) name = self._generate_event_reference(eventfilter) self._subscribedEvents[name] = eventfilter @@ -305,6 +308,108 @@ class TProbe(dbus.service.Object): return name + str(suffix) + # ------------------ Helper functions specific to a component -------------- + def find_widget(self, base, path, ignore_errors=True): + """ + Finds a widget from a base object. Symmetric with retrieve_path + + @param base the parent widget + @param path fqdn-style target object name + + @return widget found + """ + return find_widget(base, path, ignore_errors) + + def retrieve_path(self, widget): + """ + Retrieve the path to access a specific widget. + Symmetric with find_widget. + + @param widget the widget to find a path for + + @return path to the widget + """ + return raddr_lookup(widget) + +class FrameProbe(TProbe): + """ + Identical to the base probe except that helper functions are redefined + to handle the four windows that are part of the Frame. + """ + # ------------------ Helper functions specific to a component -------------- + def find_widget(self, base, path, ignore_errors=True): + """ + Finds a widget from a base object. Symmetric with retrieve_path + + format for the path for the frame should be: + + frame:/// + where panel: top | bottom | left | right + path: number[.number]* + + @param base the parent widget + @param path fqdn-style target object name + + @return widget found + """ + protocol, p = path.split("://") + assert protocol == "frame" + + window, object_id = p.split("/") + if window == "top": + return find_widget(base._top_panel, object_id, ignore_errors) + elif window == "bottom": + return find_widget(base._bottom_panel, object_id, ignore_errors) + elif window == "left": + return find_widget(base._left_panel, object_id, ignore_errors) + elif window == "right": + return find_widget(base._right_panel, object_id, ignore_errors) + else: + raise RuntimeWarning("Invalid frame panel: '%s'"%window) + + return find_widget(base, path, ignore_errors) + + def retrieve_path(self, widget): + """ + Retrieve the path to access a specific widget. + Symmetric with find_widget. + + format for the path for the frame should be: + + frame:/// + where panel: top | bottom | left | right + path: number[.number]* + + @param widget the widget to find a path for + + @return path to the widget + """ + name = [] + child = widget + parent = widget.parent + while parent: + name.append(str(parent.get_children().index(child))) + child = parent + parent = child.parent + + name.append("0") # root object itself + name.reverse() + + window = "" + if parent._position == gtk.POS_TOP: + window = "top" + elif parent._position == gtk.POS_BOTTOM: + window = "bottom" + elif parent._position == gtk.POS_LEFT: + window = "left" + elif parent._position == gtk.POS_RIGHT: + window = "right" + else: + raise RuntimeWarning("Invalid root panel in frame: %s"%str(parent)) + + return "frame://"+window+"/"+(".".join(name)) + + class ProbeProxy: """ ProbeProxy is a Proxy class for connecting to a remote TProbe. diff --git a/tutorius/creator.py b/tutorius/creator.py index 5ec0d18..9413186 100644 --- a/tutorius/creator.py +++ b/tutorius/creator.py @@ -149,6 +149,7 @@ class Creator(Object): frame._enter_notify_cb) self._propedit.window.connect('leave-notify-event', frame._leave_notify_cb) + self._propedit.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DOCK) self._overview = viewer.Viewer(self._tutorial, self) self._overview.win.set_transient_for(frame._bottom_panel) @@ -160,6 +161,7 @@ class Creator(Object): self._overview.win.move(style.GRID_CELL_SIZE, gtk.gdk.screen_height()-style.GRID_CELL_SIZE \ -self._overview.win.get_allocation().height) + self._overview.win.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DOCK) self._transitions = dict() diff --git a/tutorius/overlayer.py b/tutorius/overlayer.py index 7a1b18a..96e9acf 100644 --- a/tutorius/overlayer.py +++ b/tutorius/overlayer.py @@ -161,7 +161,6 @@ class Overlayer(gtk.Layout): if self._overlayed: self._overlayed.set_size_request(allocation.width, allocation.height) - class FrameOverlayer(gtk.Window): def __init__(self): gtk.Window.__init__(self) @@ -177,17 +176,14 @@ class FrameOverlayer(gtk.Window): gtk.DEST_DEFAULT_DROP, [ ( WIDGET_ID, 0, TARGET_TYPE_WIDGET ) ], gtk.gdk.ACTION_MOVE) - self._widgets = [] - - - def show(self): self.set_decorated(False) # Remove borders and title bar self.set_keep_above(True) # Always on top self.fullscreen() # Cover the entire screen + self.expose = self.connect("expose-event", self.apply_mask) + def show(self): gtk.Window.show(self) - self.expose = self.connect("expose-event", self.apply_mask) def apply_mask(self,*args): self.px = gtk.gdk.Pixmap(None, screen_width(), screen_height(), 1) # source, size, colors -- cgit v0.9.1