summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2012-06-19 18:58:13 +0200
committerMatthias Clasen <mclasen@redhat.com>2012-06-22 13:50:33 -0400
commitfb91fa2fbd5ca93afd44744d23c47518cef55ef4 (patch)
tree927f660d0f27f46098f8e15759461b0e79c4c5cb
parent330d63868336f6ae59716493a69651b9f0cabe62 (diff)
downloadgtk+-fb91fa2fbd5ca93afd44744d23c47518cef55ef4.tar.gz
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
-rw-r--r--docs/reference/gtk/gtk3-sections.txt1
-rw-r--r--gtk/gtk.symbols1
-rw-r--r--gtk/gtkiconview.c100
-rw-r--r--gtk/gtkiconview.h5
4 files changed, 73 insertions, 34 deletions
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index cf2399b0da..a80d569f6b 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 0247de8fa8..7a86608761 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 d838331dd7..2d33fe443e 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 6e9f6c4963..469e9ffa81 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,