Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/palettes.py
diff options
context:
space:
mode:
authorManuel Quiñones <manuq@laptop.org>2013-04-15 19:52:12 (GMT)
committer Manuel Quiñones <manuq@laptop.org>2013-04-15 19:58:36 (GMT)
commit6d61b4339c6181ba0fb37e517250cf5fe6f5cb54 (patch)
treef425deb96c51e60bd28fad3566b95a60cda4d710 /palettes.py
parent7e5b1df2789a5ec2d5ab019589700440a9010d4f (diff)
Palette: restructure the checks for link, image, selection - SL #4262
This is part of making the palette handle images which are also links. Signed-off-by: Manuel Quiñones <manuq@laptop.org>
Diffstat (limited to 'palettes.py')
-rw-r--r--palettes.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/palettes.py b/palettes.py
index 3571ae0..5f63a06 100644
--- a/palettes.py
+++ b/palettes.py
@@ -117,7 +117,13 @@ class ContentInvoker(Invoker):
def _handle_event(self, event):
hit_test = self._browser.get_hit_test_result(event)
- if hit_test.props.context & WebKit.HitTestResultContext.LINK:
+ hit_context = hit_test.props.context
+ hit_info = {
+ 'is link': hit_context & WebKit.HitTestResultContext.LINK,
+ 'is image': hit_context & WebKit.HitTestResultContext.IMAGE,
+ 'is selection': hit_context & WebKit.HitTestResultContext.SELECTION,
+ }
+ if hit_info['is link']:
link_uri = hit_test.props.link_uri
if isinstance(hit_test.props.inner_node,
WebKit.DOMHTMLImageElement):
@@ -126,12 +132,12 @@ class ContentInvoker(Invoker):
title = hit_test.props.inner_node.get_text_content()
self.palette = LinkPalette(self._browser, title, link_uri)
self.notify_right_click()
- elif hit_test.props.context & WebKit.HitTestResultContext.IMAGE:
+ elif hit_info['is image']:
title = hit_test.props.inner_node.get_title()
self.palette = ImagePalette(self._browser, title,
hit_test.props.image_uri)
self.notify_right_click()
- elif hit_test.props.context & WebKit.HitTestResultContext.SELECTION:
+ elif hit_info['is selection']:
# TODO: find a way to get the selected text so we can use
# it as the title of the Palette.
# The function webkit_web_view_get_selected_text was removed