[gitg] Added getting tree view column cell renderer at specific x position
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: svn-commits-list gnome org
- Subject: [gitg] Added getting tree view column cell renderer at specific x position
- Date: Sun, 5 Jul 2009 01:12:54 +0000 (UTC)
commit a861f8821faba6d2d17f272c1b06b0774f5a83de
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Sun Jun 28 23:45:59 2009 +0200
Added getting tree view column cell renderer at specific x position
gitg/gitg-utils.c | 39 +++++++++++++++++++++++++++++++++++++++
gitg/gitg-utils.h | 1 +
2 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/gitg/gitg-utils.c b/gitg/gitg-utils.c
index 27168ca..afabee3 100644
--- a/gitg/gitg-utils.c
+++ b/gitg/gitg-utils.c
@@ -505,3 +505,42 @@ gitg_utils_timestamp_to_str(guint64 timestamp)
strftime(buf, 254, "%c", tms);
return gitg_utils_convert_utf8(buf, -1);
}
+
+GtkCellRenderer *
+gitg_utils_find_cell_at_pos (GtkTreeView *tree_view, GtkTreeViewColumn *column, GtkTreePath *path, gint x)
+{
+ GList *cells;
+ GList *item;
+ GtkTreeIter iter;
+ GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
+
+ gtk_tree_model_get_iter (model, &iter, path);
+
+ gtk_tree_view_column_cell_set_cell_data (column, model, &iter, FALSE, FALSE);
+
+ cells = gtk_tree_view_column_get_cell_renderers (column);
+ GtkCellRenderer *ret = NULL;
+
+ for (item = cells; item; item = g_list_next (item))
+ {
+ GtkCellRenderer *renderer = GTK_CELL_RENDERER (item->data);
+ gint start;
+ gint width;
+
+ if (!gtk_tree_view_column_cell_get_position (column, renderer, &start, &width))
+ {
+ continue;
+ }
+
+ gtk_cell_renderer_get_size (renderer, GTK_WIDGET (tree_view), NULL, NULL, NULL, &width, 0);
+
+ if (x >= start && x <= start + width)
+ {
+ ret = renderer;
+ break;
+ }
+ }
+
+ g_list_free (cells);
+ return ret;
+}
diff --git a/gitg/gitg-utils.h b/gitg/gitg-utils.h
index 3d08241..05fb90a 100644
--- a/gitg/gitg-utils.h
+++ b/gitg/gitg-utils.h
@@ -64,5 +64,6 @@ void gitg_utils_set_monospace_font(GtkWidget *widget);
gchar *gitg_utils_timestamp_to_str(guint64 timestamp);
GtkBuilder *gitg_utils_new_builder(gchar const *filename);
+GtkCellRenderer *gitg_utils_find_cell_at_pos (GtkTreeView *tree_view, GtkTreeViewColumn *column, GtkTreePath *path, gint x);
#endif /* __GITG_UTILS_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]