[gtk+] Add gtk_icon_view_get_cell_area
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Add gtk_icon_view_get_cell_area
- Date: Fri, 22 Jun 2012 17:53:12 +0000 (UTC)
commit fb91fa2fbd5ca93afd44744d23c47518cef55ef4
Author: Alexander Larsson <alexl redhat com>
Date: Tue Jun 19 18:58:13 2012 +0200
Add gtk_icon_view_get_cell_area
This gets the current cell area of a particular item. Its similar
to gtk_tree_view_get_cell_area().
The code is extracted from gtk_icon_view_set_tooltip_cell which now
just calls the old code.
https://bugzilla.gnome.org/show_bug.cgi?id=678418
docs/reference/gtk/gtk3-sections.txt | 1 +
gtk/gtk.symbols | 1 +
gtk/gtkiconview.c | 100 ++++++++++++++++++++++------------
gtk/gtkiconview.h | 5 ++
4 files changed, 73 insertions(+), 34 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index cf2399b..a80d569 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -1741,6 +1741,7 @@ gtk_icon_view_set_margin
gtk_icon_view_get_margin
gtk_icon_view_set_item_padding
gtk_icon_view_get_item_padding
+gtk_icon_view_get_cell_area
gtk_icon_view_select_path
gtk_icon_view_unselect_path
gtk_icon_view_path_is_selected
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 0247de8..7a86608 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -1293,6 +1293,7 @@ gtk_icon_view_create_drag_icon
gtk_icon_view_drop_position_get_type
gtk_icon_view_enable_model_drag_dest
gtk_icon_view_enable_model_drag_source
+gtk_icon_view_get_cell_area
gtk_icon_view_get_columns
gtk_icon_view_get_column_spacing
gtk_icon_view_get_cursor
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c
index d838331..2d33fe4 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -4451,6 +4451,69 @@ gtk_icon_view_get_item_at_pos (GtkIconView *icon_view,
}
/**
+ * gtk_icon_view_get_cell_area:
+ * @icon_view: a #GtkIconView
+ * @path: a #GtkTreePath
+ * @cell: (allow-none): a #GtkCellRenderer or %NULL
+ * @rect: (out): rectangle to fill with cell rect
+ *
+ * Fills the bounding rectangle in widget coordinates for the cell specified by
+ * @path and @cell. If @cell is %NULL the main cell area is used.
+ *
+ * This function is only valid if @icon_view is realized.
+ *
+ * Return value: %FALSE if there is no such item, %TRUE otherwise
+ *
+ * Since: 3.6
+ */
+gboolean
+gtk_icon_view_get_cell_area (GtkIconView *icon_view,
+ GtkTreePath *path,
+ GtkCellRenderer *cell,
+ GdkRectangle *rect)
+{
+ GtkIconViewItem *item = NULL;
+ gint x, y;
+
+ g_return_val_if_fail (GTK_IS_ICON_VIEW (icon_view), FALSE);
+ g_return_val_if_fail (cell == NULL || GTK_IS_CELL_RENDERER (cell), FALSE);
+
+ 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 FALSE;
+
+ if (cell)
+ {
+ GtkCellAreaContext *context;
+
+ context = g_ptr_array_index (icon_view->priv->row_contexts, item->row);
+ _gtk_icon_view_set_cell_data (icon_view, item);
+ gtk_cell_area_get_cell_allocation (icon_view->priv->cell_area, context,
+ GTK_WIDGET (icon_view),
+ cell, &item->cell_area, rect);
+ }
+ else
+ {
+ rect->x = item->cell_area.x - icon_view->priv->item_padding;
+ rect->y = item->cell_area.y - icon_view->priv->item_padding;
+ rect->width = item->cell_area.width + icon_view->priv->item_padding * 2;
+ rect->height = item->cell_area.height + icon_view->priv->item_padding * 2;
+ }
+
+ if (icon_view->priv->bin_window)
+ {
+ gdk_window_get_position (icon_view->priv->bin_window, &x, &y);
+ rect->x += x;
+ rect->y += y;
+ }
+
+ return TRUE;
+}
+
+/**
* gtk_icon_view_set_tooltip_item:
* @icon_view: a #GtkIconView
* @tooltip: a #GtkTooltip
@@ -4494,46 +4557,15 @@ gtk_icon_view_set_tooltip_cell (GtkIconView *icon_view,
GtkCellRenderer *cell)
{
GdkRectangle rect;
- GtkIconViewItem *item = NULL;
- gint x, y;
-
+
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)
+ if (!gtk_icon_view_get_cell_area (icon_view, path, cell, &rect))
return;
- if (cell)
- {
- GtkCellAreaContext *context;
-
- context = g_ptr_array_index (icon_view->priv->row_contexts, item->row);
- _gtk_icon_view_set_cell_data (icon_view, item);
- gtk_cell_area_get_cell_allocation (icon_view->priv->cell_area, context,
- GTK_WIDGET (icon_view),
- cell, &item->cell_area, &rect);
- }
- else
- {
- rect.x = item->cell_area.x - icon_view->priv->item_padding;
- rect.y = item->cell_area.y - icon_view->priv->item_padding;
- rect.width = item->cell_area.width + icon_view->priv->item_padding * 2;
- rect.height = item->cell_area.height + icon_view->priv->item_padding * 2;
- }
-
- if (icon_view->priv->bin_window)
- {
- 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_tooltip_set_tip_area (tooltip, &rect);
}
diff --git a/gtk/gtkiconview.h b/gtk/gtkiconview.h
index 6e9f6c4..469e9ff 100644
--- a/gtk/gtkiconview.h
+++ b/gtk/gtkiconview.h
@@ -235,6 +235,11 @@ void gtk_icon_view_convert_widget_to_bin_window_coords (GtkIconView *icon
gint wy,
gint *bx,
gint *by);
+GDK_AVAILABLE_IN_3_6
+gboolean gtk_icon_view_get_cell_area (GtkIconView *icon_view,
+ GtkTreePath *path,
+ GtkCellRenderer *cell,
+ GdkRectangle *rect);
void gtk_icon_view_set_tooltip_item (GtkIconView *icon_view,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]