[tasks] Some initial tooltip code



commit b64c289dfe73861a0ff03dbcd36fb70a8510f4f4
Author: Ross Burton <ross linux intel com>
Date:   Fri Mar 20 16:08:30 2009 +0000

    Some initial tooltip code
---
 libkoto/koto-task-view.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/libkoto/koto-task-view.c b/libkoto/koto-task-view.c
index a610a31..c182bdc 100644
--- a/libkoto/koto-task-view.c
+++ b/libkoto/koto-task-view.c
@@ -263,6 +263,53 @@ on_note_activated (KotoCellRendererPixbuf *cell, const char *path, GtkTreeView *
   }
 }
 
+static gboolean
+on_query_tooltip (GtkWidget *widget,
+                  int x, int y,
+                  gboolean keyboard_mode,
+                  GtkTooltip *tooltip,
+                  gpointer user_data)
+{
+  GtkTreeView *treeview = GTK_TREE_VIEW (widget);
+  GtkTreeModel *model;
+  GtkTreePath *path;
+  GtkTreeIter iter;
+  KotoTask *task = NULL;
+  const char *desc;
+  gboolean ret = FALSE;
+
+  if (keyboard_mode)
+    return FALSE;
+
+  model = gtk_tree_view_get_model (treeview);
+
+  gtk_tree_view_convert_widget_to_bin_window_coords
+    (treeview, x, y, &x, &y);
+
+  if (!gtk_tree_view_get_path_at_pos
+      (treeview, x, y, &path, NULL, NULL, NULL))
+    return FALSE;
+
+  if (!gtk_tree_model_get_iter (model, &iter, path))
+    return FALSE;
+  gtk_tree_path_free (path);
+
+  gtk_tree_model_get (model, &iter, COLUMN_TASK, &task, -1);
+  if (!task)
+    return FALSE;
+
+  desc = icalcomponent_get_description (task->comp);
+
+  if (desc) {
+    gtk_tooltip_set_text (tooltip, desc);
+    ret = TRUE;
+  }
+
+  koto_task_unref (task);
+
+  return ret;
+}
+
 /*
  * Object methods.
  */
@@ -469,6 +516,9 @@ koto_task_view_init (KotoTaskView *self)
                                            note_icon_func, treeview, NULL);
   
   gtk_tree_view_append_column (treeview, column);
+
+  gtk_widget_set_has_tooltip (GTK_WIDGET (treeview), TRUE);
+  g_signal_connect (treeview, "query-tooltip", G_CALLBACK (on_query_tooltip), NULL);
 }
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]