Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tutorius
diff options
context:
space:
mode:
Diffstat (limited to 'tutorius')
-rw-r--r--tutorius/TProbe.py10
-rw-r--r--tutorius/constants.py2
-rw-r--r--tutorius/overlayer.py69
3 files changed, 74 insertions, 7 deletions
diff --git a/tutorius/TProbe.py b/tutorius/TProbe.py
index e2fe556..eea0465 100644
--- a/tutorius/TProbe.py
+++ b/tutorius/TProbe.py
@@ -57,11 +57,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 +79,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 +96,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):
diff --git a/tutorius/constants.py b/tutorius/constants.py
new file mode 100644
index 0000000..377b4a5
--- /dev/null
+++ b/tutorius/constants.py
@@ -0,0 +1,2 @@
+TARGET_TYPE_WIDGET = 81
+WIDGET_ID = "widget"
diff --git a/tutorius/overlayer.py b/tutorius/overlayer.py
index 9e4adbf..0b78c53 100644
--- a/tutorius/overlayer.py
+++ b/tutorius/overlayer.py
@@ -25,6 +25,7 @@ import pangocairo
from math import pi
from sugar import profile
+from .constants import *
# for easy profile access from cairo
color = profile.get_color().get_stroke_color()
@@ -152,6 +153,61 @@ 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)
+ self._vbox = gtk.VBox()
+ self._overlayer = Overlayer(self._vbox)
+ self.add(self._overlayer)
+ self._vbox.show()
+ self._overlayer.show()
+ self.show_all()
+
+ toCanvas = [ ( WIDGET_ID, 0, TARGET_TYPE_WIDGET ) ]
+ self._overlayer.drag_dest_set(gtk.DEST_DEFAULT_MOTION |
+ gtk.DEST_DEFAULT_HIGHLIGHT |
+ gtk.DEST_DEFAULT_DROP,
+ toCanvas, 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
+
+ gtk.Window.show(self)
+ self.expose = self.connect("expose-event", self.apply_mask)
+
+ def apply_mask(self,*args):
+ self.px = gtk.gdk.Pixmap(None, 1173, 800, 1) # source, size, colors
+ self.cr = self.px.cairo_create()
+ self.cr.set_operator(cairo.OPERATOR_CLEAR)
+ self.cr.paint()
+ self.cr.set_source_rgb(1,1,1)
+ self.cr.set_operator(cairo.OPERATOR_SOURCE)
+
+ for widget in self._widgets:
+ widget.draw_with_context(self.cr)
+ self.shape_combine_mask(self.px, 0, 0) # pixmap, offset
+
+ def put(self,widget, offset_x, offset_y):
+ self._widgets.append(widget)
+ widget.show()
+ self._overlayer.put(widget, offset_x, offset_y)
+ self._overlayer.queue_draw()
+
+ def move(self, widget, x, y):
+ self._overlayer.move(widget,x,y)
+
+ def remove(self, widget):
+ self._widgets.remove(widget)
+ self._overlayer.remove(widget)
+
+ def queue_draw(self):
+ self._overlayer.queue_draw()
+
class TextBubble(gtk.Widget):
"""
A CanvasDrawableWidget drawing a round textbox and a tail pointing
@@ -424,13 +480,20 @@ class TextBubbleWImg(gtk.Widget):
#ct = cairo.Context(surface)
# paint image
+ img_upper_left_x = int((self.allocation.width-self.imgsize[0])/2)
+ img_upper_left_y = int(self.line_width+self.padding/2)
context.set_source_pixbuf(
self.pixbuf,
- int((self.allocation.width-self.imgsize[0])/2),
- int(self.line_width+self.padding/2))
+ img_upper_left_x,
+ img_upper_left_y)
+ # Set a rectangle
+ context.rectangle(img_upper_left_x, img_upper_left_y,
+ self.imgsize[0], self.imgsize[1])
+ context.clip()
context.paint()
-
+ context.reset_clip()
+
# work done. Be kind to next cairo widgets and reset matrix.
context.identity_matrix()