[gtk+] GtkListBox: Track visible in the row
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] GtkListBox: Track visible in the row
- Date: Thu, 13 Jun 2013 10:18:59 +0000 (UTC)
commit 9510b79d781ddf9172c6990fc85709597d1813c6
Author: Alexander Larsson <alexl redhat com>
Date: Tue Jun 11 16:13:00 2013 +0200
GtkListBox: Track visible in the row
This is a minor performance improvement, but its mainly to
allow us to track when n_visible_children changes.
gtk/gtklistbox.c | 27 +++++++++++++++++++--------
1 files changed, 19 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c
index 8bf9269..a59c7a5 100644
--- a/gtk/gtklistbox.c
+++ b/gtk/gtklistbox.c
@@ -88,6 +88,7 @@ struct _GtkListBoxRowPrivate
GtkWidget *header;
gint y;
gint height;
+ gboolean visible;
};
enum {
@@ -1312,6 +1313,19 @@ gtk_list_box_real_realize (GtkWidget* widget)
gtk_widget_set_window (GTK_WIDGET (list_box), window); /* Passes ownership */
}
+/* Children are visible if they are shown by the app (visible)
+ and not filtered out (child_visible) by the listbox */
+static void
+update_row_is_visible (GtkListBoxRow *row)
+{
+ row->priv->visible = gtk_widget_get_visible (GTK_WIDGET (row)) && gtk_widget_get_child_visible (GTK_WIDGET
(row));
+}
+
+static gboolean
+row_is_visible (GtkListBoxRow *row)
+{
+ return row->priv->visible;
+}
static void
gtk_list_box_apply_filter (GtkListBox *list_box, GtkListBoxRow *row)
@@ -1324,6 +1338,8 @@ gtk_list_box_apply_filter (GtkListBox *list_box, GtkListBoxRow *row)
do_show = priv->filter_func (row, priv->filter_func_target);
gtk_widget_set_child_visible (GTK_WIDGET (row), do_show);
+
+ update_row_is_visible (row);
}
static void
@@ -1342,14 +1358,6 @@ gtk_list_box_apply_filter_all (GtkListBox *list_box)
}
}
-/* Children are visible if they are shown by the app (visible)
- and not filtered out (child_visible) by the listbox */
-static gboolean
-row_is_visible (GtkListBoxRow *row)
-{
- return gtk_widget_get_visible (GTK_WIDGET (row)) && gtk_widget_get_child_visible (GTK_WIDGET (row));
-}
-
static GtkListBoxRow *
gtk_list_box_get_first_visible (GtkListBox *list_box)
{
@@ -1502,6 +1510,8 @@ gtk_list_box_update_header (GtkListBox *list_box, GSequenceIter* iter)
static void
gtk_list_box_row_visibility_changed (GtkListBox *list_box, GtkListBoxRow *row)
{
+ update_row_is_visible (row);
+
if (gtk_widget_get_visible (GTK_WIDGET (list_box)))
{
gtk_list_box_update_header (list_box, row->priv->iter);
@@ -1535,6 +1545,7 @@ gtk_list_box_real_add (GtkContainer* container, GtkWidget *child)
row->priv->iter = iter;
gtk_widget_set_parent (GTK_WIDGET (row), GTK_WIDGET (list_box));
+ row->priv->visible = gtk_widget_get_visible (GTK_WIDGET (row));
gtk_list_box_apply_filter (list_box, row);
if (gtk_widget_get_visible (GTK_WIDGET (list_box)))
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]