From bdf50bd4f621890c7d432da756d45ce00e5327b3 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 16 Jul 2007 14:04:35 +0000 Subject: [PATCH] Convenience functions to position tooltips on icon view items or cells. 2007-07-16 Matthias Clasen * gtk/gtk.symbols: * gtk/gtkiconview.h: * gtk/gtkiconview.c (gtk_icon_view_set_tooltip_item): (gtk_icon_view_set_tooltip_cell): Convenience functions to position tooltips on icon view items or cells. svn path=/trunk/; revision=18473 --- ChangeLog | 8 +++ docs/reference/ChangeLog | 9 ++++ docs/reference/gtk/gtk-sections.txt | 1 + gtk/gtk.symbols | 2 + gtk/gtkiconview.c | 80 ++++++++++++++++++++++++++++- gtk/gtkiconview.h | 10 ++++ 6 files changed, 109 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 1522931ac..23d362a5d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-07-16 Matthias Clasen + + * gtk/gtk.symbols: + * gtk/gtkiconview.h: + * gtk/gtkiconview.c (gtk_icon_view_set_tooltip_item): + (gtk_icon_view_set_tooltip_cell): Convenience functions to + position tooltips on icon view items or cells. + 2007-07-14 Richard Hult * gdk/quartz/gdkevents-quartz.c: diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index c5f2f2c83..7cacdb36f 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,9 +1,18 @@ +2007-07-16 Matthias Clasen + + * gtk/gtk-sections.txt: Add icon view tooltip convenience functions. + Thu Jul 12 18:12:04 2007 Tim Janik * gdk/tmpl/threads.sgml: clarify section about gdk_threads_enter/ gdk_threads_leave to be reworded in terms of events and to mention availability of gdk_threads_add_idle_full(). +2007-07-11 Matthias Clasen + + * gtk/tmpl/gtkbindings.sgml: Add a paragraph about + keybinding signals. + 2007-07-11 Matthias Clasen * gtk/tmpl/gtkrange.sgml: diff --git a/docs/reference/gtk/gtk-sections.txt b/docs/reference/gtk/gtk-sections.txt index 9fd970e1e..c23430c08 100644 --- a/docs/reference/gtk/gtk-sections.txt +++ b/docs/reference/gtk/gtk-sections.txt @@ -4746,6 +4746,7 @@ gtk_cell_layout_get_type GtkCellRendererState GtkCellRendererMode GtkCellRenderer +GtkCellRendererClass gtk_cell_renderer_get_size gtk_cell_renderer_render gtk_cell_renderer_activate diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index 0d305ee69..a993db776 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -1886,6 +1886,8 @@ gtk_icon_view_set_drag_dest_item gtk_icon_view_get_drag_dest_item gtk_icon_view_get_dest_item_at_pos gtk_icon_view_create_drag_icon +gtk_icon_view_set_tooltip_item +gtk_icon_view_set_tooltip_cell #endif #endif diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c index 88d75543d..d8b0677f3 100644 --- a/gtk/gtkiconview.c +++ b/gtk/gtkiconview.c @@ -4576,7 +4576,6 @@ gtk_icon_view_get_path_at_pos (GtkIconView *icon_view, { GtkIconViewItem *item; GtkTreePath *path; - gint px, py; g_return_val_if_fail (GTK_IS_ICON_VIEW (icon_view), NULL); @@ -4643,6 +4642,85 @@ gtk_icon_view_get_item_at_pos (GtkIconView *icon_view, return (item != NULL); } +/** + * gtk_icon_view_set_tooltip_item: + * @icon_view: a #GtkIconView + * @tooltip: a #GtkTooltip + * @path: a #GtkTreePath + * + * Sets the tip area of @tooltip to be the area covered by the item at @path. + * See also gtk_tooltip_set_tip_area(). + * + * Since: 2.12 + */ +void +gtk_icon_view_set_tooltip_item (GtkIconView *icon_view, + GtkTooltip *tooltip, + GtkTreePath *path) +{ + g_return_if_fail (GTK_IS_ICON_VIEW (icon_view)); + g_return_if_fail (GTK_IS_TOOLTIP (tooltip)); + + gtk_icon_view_set_tooltip_cell (icon_view, tooltip, path, NULL); +} + +/** + * gtk_icon_view_set_tooltip_cell: + * @icon_view: a #GtkIconView + * @tooltip: a #GtkTooltip + * @path: a #GtkTreePath + * @cell: a #GtkCellRenderer or %NULL + * + * Sets the tip area of @tooltip to the area which @cell occupies in + * the item pointed to by @path. See also gtk_tooltip_set_tip_area(). + * + * Since: 2.12 + */ +void +gtk_icon_view_set_tooltip_cell (GtkIconView *icon_view, + GtkTooltip *tooltip, + GtkTreePath *path, + GtkCellRenderer *cell) +{ + GdkRectangle rect; + GtkIconViewItem *item = NULL; + GtkIconViewCellInfo *info = NULL; + + g_return_if_fail (GTK_IS_ICON_VIEW (icon_view)); + g_return_if_fail (GTK_IS_TOOLTIP (tooltip)); + g_return_if_fail (cell == NULL || GTK_IS_CELL_RENDERER (cell)); + + if (gtk_tree_path_get_depth (path) > 0) + item = g_list_nth_data (icon_view->priv->items, + gtk_tree_path_get_indices(path)[0]); + + if (!item) + return; + + if (cell) + { + info = gtk_icon_view_get_cell_info (icon_view, cell); + gtk_icon_view_get_cell_area (icon_view, item, info, &rect); + } + else + { + rect.x = item->x; + rect.y = item->y; + rect.width = item->width; + rect.height = item->height; + } + + if (icon_view->priv->bin_window) + { + gint x, y; + + gdk_window_get_position (icon_view->priv->bin_window, &x, &y); + rect.x += x; + rect.y += y; + } + + gtk_tooltip_set_tip_area (tooltip, &rect); +} /** * gtk_icon_view_get_visible_range: diff --git a/gtk/gtkiconview.h b/gtk/gtkiconview.h index 62780c3f8..6aa35cea4 100644 --- a/gtk/gtkiconview.h +++ b/gtk/gtkiconview.h @@ -23,6 +23,7 @@ #include #include #include +#include G_BEGIN_DECLS @@ -202,6 +203,15 @@ void gtk_icon_view_convert_widget_to_bin_window_coords (GtkIconView *icon gint *by); +void gtk_icon_view_set_tooltip_item (GtkIconView *icon_view, + GtkTooltip *tooltip, + GtkTreePath *path); +void gtk_icon_view_set_tooltip_cell (GtkIconView *icon_view, + GtkTooltip *tooltip, + GtkTreePath *path, + GtkCellRenderer *cell); + + G_END_DECLS #endif /* __GTK_ICON_VIEW_H__ */ -- 2.43.2