[gtk+] Bug 69872 – GTK_WIDGET_SET_FLAGS should be deprecated
- From: Michael Natterer <mitch src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+] Bug 69872 – GTK_WIDGET_SET_FLAGS should be deprecated
- Date: Fri, 7 Aug 2009 06:55:54 +0000 (UTC)
commit eb0a5721d96bc937daeb742c9c216549a9456eba
Author: Michael Natterer <mitch gimp org>
Date: Fri Aug 7 08:53:32 2009 +0200
Bug 69872 â?? GTK_WIDGET_SET_FLAGS should be deprecated
Add gtk_widget_get_visible(). For symmetry reasons and for convenience
when a widget's visibility state is available as a boolean condition,
also add gtk_widget_set_visible() (which simply calls show()/hide()).
gtk/gtk.symbols | 2 ++
gtk/gtkwidget.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
gtk/gtkwidget.h | 4 ++++
3 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index ba61ba3..bf2e861 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -4998,6 +4998,7 @@ gtk_widget_get_tooltip_text
gtk_widget_get_tooltip_window
gtk_widget_get_toplevel
gtk_widget_get_type G_GNUC_CONST
+gtk_widget_get_visible
gtk_widget_get_visual
gtk_widget_grab_default
gtk_widget_grab_focus
@@ -5076,6 +5077,7 @@ gtk_widget_set_style
gtk_widget_set_tooltip_markup
gtk_widget_set_tooltip_text
gtk_widget_set_tooltip_window
+gtk_widget_set_visible
gtk_widget_shape_combine_mask
gtk_widget_input_shape_combine_mask
gtk_widget_show
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index a81dc2d..28422b2 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -5578,6 +5578,58 @@ gtk_widget_get_state (GtkWidget *widget)
}
/**
+ * gtk_widget_set_visible:
+ * @widget: a #GtkWidget
+ * @visible: whether the widget should be shown or not
+ *
+ * Sets the visibility state of @widget. Note that setting this to
+ * %TRUE doesn't mean the widget is actually viewable, see
+ * gtk_widget_get_visible().
+ *
+ * This function simply calls gtk_widget_show() or gtk_widget_hide()
+ * but is nicer to use when the visibility of the widget depends on
+ * some condition.
+ *
+ * Since: 2.18
+ **/
+void
+gtk_widget_set_visible (GtkWidget *widget,
+ gboolean visible)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ if (visible != GTK_WIDGET_VISIBLE (widget))
+ {
+ if (visible)
+ gtk_widget_show (widget);
+ else
+ gtk_widget_hide (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.
+ *
+ * See gtk_widget_set_visible().
+ *
+ * Return value: %TRUE if the widget is visible
+ *
+ * Since: 2.18
+ **/
+gboolean
+gtk_widget_get_visible (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return (GTK_WIDGET_FLAGS (widget) & GTK_VISIBLE) != 0;
+}
+
+/**
* 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 e074baa..d5de8bd 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -574,6 +574,10 @@ void gtk_widget_set_sensitive (GtkWidget *widget,
gboolean gtk_widget_get_sensitive (GtkWidget *widget);
gboolean gtk_widget_is_sensitive (GtkWidget *widget);
+void gtk_widget_set_visible (GtkWidget *widget,
+ gboolean visible);
+gboolean gtk_widget_get_visible (GtkWidget *widget);
+
void gtk_widget_set_has_window (GtkWidget *widget,
gboolean has_window);
gboolean gtk_widget_get_has_window (GtkWidget *widget);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]