diff options
author | Benjamin Otte <otte@redhat.com> | 2012-11-02 00:42:45 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2012-11-04 15:24:17 +0100 |
commit | 48ff2fc7ed1f418002def55fc496a7f86f9e7ef7 (patch) | |
tree | b090f8334690a8cbcd0a26b912e7d5e242a293e2 | |
parent | 9f6067a8043129ddcc0e223111d3b5a79c7b8100 (diff) | |
download | gtk+-48ff2fc7ed1f418002def55fc496a7f86f9e7ef7.tar.gz |
API: Add gtk_widget_is_visible()
This is a recursive gtk_widget_get_visible(): Returns TRUE if the widget
and all its parents are visible.
-rw-r--r-- | docs/reference/gtk/gtk3-sections.txt | 1 | ||||
-rw-r--r-- | gtk/gtk.symbols | 1 | ||||
-rw-r--r-- | gtk/gtkwidget.c | 41 | ||||
-rw-r--r-- | gtk/gtkwidget.h | 1 |
4 files changed, 41 insertions, 3 deletions
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index 9e159b160c..0cdc991737 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -5291,6 +5291,7 @@ gtk_widget_get_sensitive gtk_widget_is_sensitive gtk_widget_get_state gtk_widget_get_visible +gtk_widget_is_visible gtk_widget_set_visible gtk_widget_set_state_flags gtk_widget_unset_state_flags diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index 9a1a86b6b7..0e4eee4771 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -3708,6 +3708,7 @@ gtk_widget_is_composited gtk_widget_is_drawable gtk_widget_is_focus gtk_widget_is_sensitive +gtk_widget_is_visible gtk_widget_is_toplevel gtk_widget_keynav_failed gtk_widget_list_accel_closures diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 58ad57af23..2f4dc0871c 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -7484,9 +7484,11 @@ _gtk_widget_set_visible_flag (GtkWidget *widget, * gtk_widget_get_visible: * @widget: a #GtkWidget * - * Determines whether the widget is visible. Note that this doesn't - * take into account whether the widget's parent is also visible - * or the widget is obscured in any way. + * Determines whether the widget is visible. If you want to + * take into account whether the widget's parent is also marked as + * visible, use gtk_widget_is_visible() instead. + * + * This function does not check if the widget is obscured in any way. * * See gtk_widget_set_visible(). * @@ -7503,6 +7505,39 @@ gtk_widget_get_visible (GtkWidget *widget) } /** + * gtk_widget_is_visible: + * @widget: a #GtkWidget + * + * Determines whether the widget and all its parents are marked as + * visible. + * + * This function does not check if the widget is obscured in any way. + * + * See also gtk_widget_get_visible() and gtk_widget_set_visible() + * + * Return value: %TRUE if the widget and all its parents are visible + * + * Since: 3.8 + **/ +gboolean +gtk_widget_is_visible (GtkWidget *widget) +{ + g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); + + while (widget) + { + GtkWidgetPrivate *priv = widget->priv; + + if (!priv->visible) + return FALSE; + + widget = priv->parent; + } + + return TRUE; +} + +/** * gtk_widget_set_has_window: * @widget: a #GtkWidget * @has_window: whether or not @widget has a window. diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index c178478117..2cdc7f3e6f 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -589,6 +589,7 @@ gboolean gtk_widget_is_sensitive (GtkWidget *widget); void gtk_widget_set_visible (GtkWidget *widget, gboolean visible); gboolean gtk_widget_get_visible (GtkWidget *widget); +gboolean gtk_widget_is_visible (GtkWidget *widget); void gtk_widget_set_has_window (GtkWidget *widget, gboolean has_window); |