deskbar-applet r2147 - in trunk: . deskbar/interfaces deskbar/ui/cuemiac
- From: sebp svn gnome org
- To: svn-commits-list gnome org
- Subject: deskbar-applet r2147 - in trunk: . deskbar/interfaces deskbar/ui/cuemiac
- Date: Thu, 1 May 2008 11:12:58 +0100 (BST)
Author: sebp
Date: Thu May 1 10:12:57 2008
New Revision: 2147
URL: http://svn.gnome.org/viewvc/deskbar-applet?rev=2147&view=rev
Log:
Added get_tooltip method to Action interface.
Override this method to display a tooltip when the user hovers over the match (the default action's tooltip is displayed) or over an action in the list of additional actions.
Modified:
trunk/ChangeLog
trunk/deskbar/interfaces/Action.py
trunk/deskbar/ui/cuemiac/CuemiacActionsTreeView.py
trunk/deskbar/ui/cuemiac/CuemiacTreeView.py
Modified: trunk/deskbar/interfaces/Action.py
==============================================================================
--- trunk/deskbar/interfaces/Action.py (original)
+++ trunk/deskbar/interfaces/Action.py Thu May 1 10:12:57 2008
@@ -83,6 +83,19 @@
- Execute %(prog)s
"""
raise NotImplementedError
+
+ def get_tooltip(self, text=None):
+ """
+ Returns the tooltip markup string associated to this action.
+
+ The passed string is the complete query string.
+
+ Examples:
+ - URI: http://...
+
+ @since: 2.24
+ """
+ return None
def get_name(self, text=None):
"""
Modified: trunk/deskbar/ui/cuemiac/CuemiacActionsTreeView.py
==============================================================================
--- trunk/deskbar/ui/cuemiac/CuemiacActionsTreeView.py (original)
+++ trunk/deskbar/ui/cuemiac/CuemiacActionsTreeView.py Thu May 1 10:12:57 2008
@@ -40,9 +40,11 @@
def __init__(self, model=None):
gtk.TreeView.__init__(self, model)
self.set_property ("headers-visible", False)
+ self.set_property ("has-tooltip", True)
self.set_enable_search (False)
self.connect("button-press-event", self.__on_button_press_event)
self.connect("key-press-event", self.__on_key_press_event)
+ self.connect("query-tooltip", self.__on_query_tooltip)
cell_icon = gtk.CellRendererPixbuf()
cell_icon.set_property("xpad", 10)
@@ -94,4 +96,24 @@
gobject.idle_add(self.scroll_to_cell, path )
self.set_cursor_on_cell( path )
+ def __on_query_tooltip(self, widget, x, y, keyboard_mode, tooltip):
+ path = self.get_path_at_pos(x, y)
+ if path == None:
+ return False
+
+ tree_path = path[0]
+
+ model = self.get_model()
+ iter = model.get_iter(tree_path)
+ action = model[iter][model.ACTION_COL]
+
+ qstring = model[iter][model.QUERY_COL]
+ markup = action.get_tooltip (qstring)
+ # Return False to not show a blank tooltip
+ if markup != None and len(markup) != 0:
+ tooltip.set_markup (markup)
+ self.set_tooltip_row (tooltip, tree_path)
+ return True
+
+ return False
Modified: trunk/deskbar/ui/cuemiac/CuemiacTreeView.py
==============================================================================
--- trunk/deskbar/ui/cuemiac/CuemiacTreeView.py (original)
+++ trunk/deskbar/ui/cuemiac/CuemiacTreeView.py Thu May 1 10:12:57 2008
@@ -39,18 +39,18 @@
icon = gtk.CellRendererPixbuf ()
#icon.set_property("xpad", 10)
- hit_title = CuemiacCellRendererMatch ()
- hit_title.connect("activated", self.__on_do_action_activated)
- hit_title.set_property ("ellipsize", pango.ELLIPSIZE_END)
+ self._match_renderer = CuemiacCellRendererMatch ()
+ self._match_renderer.connect("activated", self.__on_do_action_activated)
+ self._match_renderer.set_property ("ellipsize", pango.ELLIPSIZE_END)
self._action_renderer = CuemiacCellRendererAction ()
self._action_renderer.connect("activated", self.__on_show_actions_activated)
self._hits_column = gtk.TreeViewColumn ("Hits")
self._hits_column.pack_start (icon, expand=False)
- self._hits_column.pack_start (hit_title)
+ self._hits_column.pack_start (self._match_renderer)
self._hits_column.pack_end (self._action_renderer, expand=False)
- self._hits_column.set_cell_data_func(hit_title, self.__get_match_title_for_cell)
+ self._hits_column.set_cell_data_func(self._match_renderer, self.__get_match_title_for_cell)
self._hits_column.set_cell_data_func(icon, self.__get_match_icon_for_cell)
self._hits_column.set_cell_data_func(self._action_renderer, self.__get_match_action_for_cell)
self.append_column (self._hits_column)
@@ -230,19 +230,39 @@
tree_path, col, cell_x = path[:3]
+ model = self.get_model()
+ iter = model.get_iter(tree_path)
+ match = model[iter][model.MATCHES]
+
+ if not isinstance(match, Match):
+ return False
+
# x coordinate gives us the blank area left of the icon
cell_area = self.get_cell_area(tree_path, col)
# x coordinate of the action renderer
# WITHOUT the blank area on the left
action_renderer_x = col.cell_get_position(self._action_renderer)[0]
+ match_renderer_x = col.cell_get_position(self._match_renderer)[0]
+ # Check if we're in the cell containing the arrow
if cell_x > action_renderer_x + cell_area.x:
- model = self.get_model()
- iter = model.get_iter(tree_path)
- match = model[iter][model.MATCHES]
- if isinstance(match, Match) \
- and len(match.get_actions()) > 1:
+ if len(match.get_actions()) > 1:
tooltip.set_markup(_("Display additional actions"))
+ self.set_tooltip_cell (tooltip, tree_path,
+ col, self._action_renderer)
+ return True
+ elif cell_x > match_renderer_x + cell_area.x:
+ qstring = model[iter][model.QUERY]
+ action = match.get_default_action ()
+ if action == None:
+ action = match.get_actions()[0]
+
+ markup = action.get_tooltip (qstring)
+ # Return False to not show a blank tooltip
+ if markup != None and len(markup) != 0:
+ tooltip.set_markup (markup)
+ self.set_tooltip_cell (tooltip, tree_path,
+ col, self._match_renderer)
return True
return False
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]