diff options
author | Alexander Larsson <alexl@redhat.com> | 2013-06-11 16:13:00 +0200 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2013-06-11 16:14:59 +0200 |
commit | 524deace1a31c19f6de32c7950c5975ff075c595 (patch) | |
tree | 62dd9366b713a994bae83543d0af630d504d5e5e | |
parent | e10404cceea13232bd96b9846c9b8e03de696542 (diff) | |
download | gtk+-524deace1a31c19f6de32c7950c5975ff075c595.tar.gz |
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.
-rw-r--r-- | gtk/gtklistbox.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c index 8bf9269fc7..a59c7a5d9f 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))) { |