Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJCTutorius <charlie@tutorius-dev.(none)>2009-12-27 19:31:21 (GMT)
committer JCTutorius <charlie@tutorius-dev.(none)>2009-12-27 19:31:21 (GMT)
commitc37cd77ae2b3be4cd216d5ffd3130f1e8fb1663c (patch)
tree2ab287c6be20a9998183a4b6dee1dbd99536c1b7
parent1f896f9f8892935c6eda88782f8cca08c0b0512d (diff)
Encircle action
-rw-r--r--tutorius/overlayer.py164
-rw-r--r--tutorius/translator.py2
2 files changed, 73 insertions, 93 deletions
diff --git a/tutorius/overlayer.py b/tutorius/overlayer.py
index ec611ab..f20ba83 100644
--- a/tutorius/overlayer.py
+++ b/tutorius/overlayer.py
@@ -769,98 +769,78 @@ class Mask(gtk.EventBox):
gobject.type_register(Mask)
-##class Encircle(gtk.EventBox):
-## """
-## A CanvasDrawableWidget drawing a rectangle over a specified widget.
-## """
-## def __init__(self, catch_events=False, pass_thru=()):
-## """
-## Creates a new Rectangle
-##
-## @param catch_events whether the Mask should catch events
-## @param pass_thru the widgets that "punch holes" through this Mask.
-## Events will pass through to those widgets.
-## """
-## gtk.EventBox.__init__(self)
-## self.no_expose = True # ignored
-## self._catch_events = False
-## self.catch_events = catch_events
-## self.pass_thru = list(pass_thru)
-##
-## def __del__(self):
-## for widget in self.pass_thru:
-## widget.drag_unhighlight()
-##
-## def mask(self, widget):
-## """
-## Remove the widget from the unmasked list.
-## @param widget a widget to remask
-## """
-## assert widget in self.pass_thru, \
-## "trying to mask already masked widget"
-## self.pass_thru.remove(widget)
-## widget.drag_unhighlight()
-##
-## def unmask(self, widget):
-## """
-## Add to the unmasked list the widget passed.
-## A hole will be punched through the mask at that widget's position.
-## @param widget a widget to unmask
-## """
-## if widget not in self.pass_thru:
-## widget.drag_highlight()
-## self.pass_thru.append(widget)
-##
-##
-## def set_catch_events(self, do_catch):
-## """Sets whether the mask catches events of widgets under it"""
-## if bool(self._catch_events) ^ bool(do_catch):
-## if do_catch:
-## self._catch_events = True
-## self.grab_add()
-## else:
-## self.grab_remove()
-## self._catch_events = False
-##
-## def get_catch_events(self):
-## """Gets whether the mask catches events of widgets under it"""
-## return bool(self._catch_handle)
-##
-## catch_events = property(fset=set_catch_events, fget=get_catch_events)
-##
-## def draw_with_context(self, context):
-## """
-## Draw using the passed cairo context instead of creating a new cairo
-## context. This eases blending between multiple cairo-rendered
-## widgets.
-## """
-## # Fill container
-## mask_alloc = self.get_allocation()
-## oldrule = context.get_fill_rule()
-## context.set_fill_rule(cairo.FILL_RULE_EVEN_ODD)
-## x, y = self.translate_coordinates(self, 0, 0)
-##
-## context.rectangle(x, y, mask_alloc.width + 5, mask_alloc.height + 5)
-## # Draw the "hole" in the rectangle to give a rectangle outline to the widget
-## context.rectangle(x, y, mask_alloc.width, mask_allocx.height)
-## context.set_source_rgba(0, 0, 0, 0.7)
-## context.fill()
-## context.set_fill_rule(oldrule)
-##
-## def do_size_request(self, requisition):
-## """Fill requisition with size occupied by the masked widget."""
-## # This is required for the event box to span across the widget
-## #alloc = self.parent.get_allocation()
-## alloc = self.get_allocation()
-## # Add 5 pixels more than the height and width of the widget to make a rectangle outline around it
-## requisition.width = alloc.width + 5
-## requisition.height = alloc.height +5
-##
-## def do_size_allocate(self, allocation):
-## """Save zone allocated to the widget."""
-## self.allocation = allocation
-##
-##gobject.type_register(Encircle)
+class Encircle(gtk.EventBox):
+ """
+ A CanvasDrawableWidget drawing a rectangle over a specified widget.
+ """
+ def __init__(self, widget, catch_events=False, pass_thru=()):
+ """
+ Creates a new Rectangle
+
+ @param catch_events whether the Mask should catch events
+ @param pass_thru the widgets that "punch holes" through this Mask.
+ Events will pass through to those widgets.
+ """
+ gtk.EventBox.__init__(self)
+ self.wid = widget
+ self.no_expose = True # ignored
+ self._catch_events = False
+ self.catch_events = catch_events
+ self.pass_thru = list(pass_thru)
+
+ def __del__(self):
+ for widget in self.pass_thru:
+ widget.drag_unhighlight()
+
+
+ def set_catch_events(self, do_catch):
+ """Sets whether the mask catches events of widgets under it"""
+ if bool(self._catch_events) ^ bool(do_catch):
+ if do_catch:
+ self._catch_events = True
+ self.grab_add()
+ else:
+ self.grab_remove()
+ self._catch_events = False
+
+ def get_catch_events(self):
+ """Gets whether the mask catches events of widgets under it"""
+ return bool(self._catch_handle)
+
+ catch_events = property(fset=set_catch_events, fget=get_catch_events)
+
+ def draw_with_context(self, context):
+ """
+ Draw using the passed cairo context instead of creating a new cairo
+ context. This eases blending between multiple cairo-rendered
+ widgets.
+ """
+ # Fill container
+ mask_alloc = self.wid.get_allocation()
+ oldrule = context.get_fill_rule()
+ context.set_fill_rule(cairo.FILL_RULE_EVEN_ODD)
+ x, y = self.wid.translate_coordinates(self, 0, 0)
+
+ context.rectangle(x-8, y-8, mask_alloc.width+16, mask_alloc.height+16)
+ # Draw the "hole" in the rectangle to give a rectangle outline to the widget
+ context.rectangle(x-2, y-2, mask_alloc.width+4, mask_alloc.height+4)
+ context.set_source_rgb(*xo_fill_color)
+ context.fill()
+ context.set_fill_rule(oldrule)
+
+ def do_size_request(self, requisition):
+ """Fill requisition with size occupied by the masked widget."""
+ # This is required for the event box to span across the widget
+ alloc = self.wid.get_allocation()
+ # Add 5 pixels more than the height and width of the widget to make a rectangle outline around it
+ requisition.width = alloc.width + 16
+ requisition.height = alloc.height +16
+
+ def do_size_allocate(self, allocation):
+ """Save zone allocated to the widget."""
+ self.allocation = allocation
+
+gobject.type_register(Encircle)
# vim:set ts=4 sts=4 sw=4 et:
diff --git a/tutorius/translator.py b/tutorius/translator.py
index bd24f8f..f1c088b 100644
--- a/tutorius/translator.py
+++ b/tutorius/translator.py
@@ -172,7 +172,7 @@ class ResourceTranslator(object):
# was installed
action_installed_cb(address)
- def action_install_error(self, install_error_cb, old_action, exception):
+ def action_install_error(self, install_error_cb, old_action, new_action, exception):
# Warn the upper layer that the installation failed
install_error_cb(old_action, exception)