From 50830412b037f937ee7db712a174f6205dd41266 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 11 Jun 2005 05:15:10 +0000 Subject: [PATCH] Add a function to determine what parts of the model are visible. (#306726, 2005-06-11 Matthias Clasen * gtk/gtk.symbols: * gtk/gtkiconview.h: * gtk/gtkiconview.c (gtk_icon_view_get_visible_range): Add a function to determine what parts of the model are visible. (#306726, Jonathan Blandford) --- ChangeLog | 6 +++++ ChangeLog.pre-2-10 | 6 +++++ ChangeLog.pre-2-8 | 6 +++++ gtk/gtk.symbols | 1 + gtk/gtkiconview.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ gtk/gtkiconview.h | 3 +++ 6 files changed, 78 insertions(+) diff --git a/ChangeLog b/ChangeLog index d5a67e8b6..f07b8112b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2005-06-11 Matthias Clasen + * gtk/gtk.symbols: + * gtk/gtkiconview.h: + * gtk/gtkiconview.c (gtk_icon_view_get_visible_range): + Add a function to determine what parts of the model are + visible. (#306726, Jonathan Blandford) + * gtk/gtkfilesystemunix.c (create_file_info): Treat backup files the same way as hidden files, to be closer to what Nautilus does. (#136196, Sean Middleditch) diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index d5a67e8b6..f07b8112b 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,5 +1,11 @@ 2005-06-11 Matthias Clasen + * gtk/gtk.symbols: + * gtk/gtkiconview.h: + * gtk/gtkiconview.c (gtk_icon_view_get_visible_range): + Add a function to determine what parts of the model are + visible. (#306726, Jonathan Blandford) + * gtk/gtkfilesystemunix.c (create_file_info): Treat backup files the same way as hidden files, to be closer to what Nautilus does. (#136196, Sean Middleditch) diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index d5a67e8b6..f07b8112b 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,5 +1,11 @@ 2005-06-11 Matthias Clasen + * gtk/gtk.symbols: + * gtk/gtkiconview.h: + * gtk/gtkiconview.c (gtk_icon_view_get_visible_range): + Add a function to determine what parts of the model are + visible. (#306726, Jonathan Blandford) + * gtk/gtkfilesystemunix.c (create_file_info): Treat backup files the same way as hidden files, to be closer to what Nautilus does. (#136196, Sean Middleditch) diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index 3ef52afe8..3399ab4a2 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -1675,6 +1675,7 @@ gtk_icon_view_get_selection_mode gtk_icon_view_get_spacing gtk_icon_view_get_text_column gtk_icon_view_get_type G_GNUC_CONST +gtk_icon_view_get_visible_range gtk_icon_view_item_activated gtk_icon_view_new gtk_icon_view_new_with_model diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c index 8c733dc3a..349884674 100644 --- a/gtk/gtkiconview.c +++ b/gtk/gtkiconview.c @@ -4373,6 +4373,62 @@ gtk_icon_view_get_item_at_pos (GtkIconView *icon_view, return (item != NULL); } + +/** + * gtk_icon_view_get_visible_range: + * @icon_view: A #GtkIconView + * @start_path: Return location for start of region, or %NULL + * @end_path: Return location for end of region, or %NULL + * + * Sets @start_path and @end_path to be the first and last visible path. + * Note that there may be invisible paths in between. + * + * Return value: %TRUE, if valid paths were placed in @start_path and @end_path + * + * Since: 2.8 + **/ +gboolean +gtk_icon_view_get_visible_range (GtkIconView *icon_view, + GtkTreePath **start_path, + GtkTreePath **end_path) +{ + gint start_index = -1; + gint end_index = -1; + GtkIconViewItem *item; + GList *icons; + + g_return_val_if_fail (GTK_IS_ICON_VIEW (icon_view), FALSE); + + if (icon_view->priv->hadjustment == NULL || + icon_view->priv->vadjustment == NULL) + return FALSE; + + if (start_path == NULL && end_path == NULL) + return FALSE; + + for (icons = icon_view->priv->items; icons; icons = icons->next) + { + GtkIconViewItem *item = icons->data; + + if ((item->x + item->width >= (int)icon_view->priv->hadjustment->value) && + (item->y + item->height >= (int)icon_view->priv->vadjustment->value) && + (item->x <= (int) (icon_view->priv->hadjustment->value + icon_view->priv->hadjustment->page_size)) && + (item->y <= (int) (icon_view->priv->vadjustment->value + icon_view->priv->vadjustment->page_size))) + { + if (start_index == -1) + start_index = item->index; + end_index = item->index; + } + } + + if (start_path && start_index != -1) + *start_path = gtk_tree_path_new_from_indices (start_index, -1); + if (end_path && end_index != -1) + *end_path = gtk_tree_path_new_from_indices (end_index, -1); + + return start_index != -1; +} + /** * gtk_icon_view_selected_foreach: * @icon_view: A #GtkIconView. diff --git a/gtk/gtkiconview.h b/gtk/gtkiconview.h index 0929ce694..b6e5d46be 100644 --- a/gtk/gtkiconview.h +++ b/gtk/gtkiconview.h @@ -129,6 +129,9 @@ gboolean gtk_icon_view_get_item_at_pos (GtkIconView *icon_view, gint y, GtkTreePath **path, GtkCellRenderer **cell); +gboolean gtk_icon_view_get_visible_range (GtkIconView *icon_view, + GtkTreePath **start_path, + GtkTreePath **end_path); void gtk_icon_view_selected_foreach (GtkIconView *icon_view, GtkIconViewForeachFunc func, -- 2.43.2