From e821eea4f017cc7ae7689daed0c3a56859268c80 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 9 Feb 2010 13:40:58 -0500 Subject: [PATCH] Add some more goddamn accessors --- docs/reference/gtk/gtk-sections.txt | 4 ++ gtk/gtk.symbols | 4 ++ gtk/gtkwidget.c | 94 +++++++++++++++++++++++++++++ gtk/gtkwidget.h | 12 ++++ 4 files changed, 114 insertions(+) diff --git a/docs/reference/gtk/gtk-sections.txt b/docs/reference/gtk/gtk-sections.txt index 7a19709fe9..d79c5a8308 100644 --- a/docs/reference/gtk/gtk-sections.txt +++ b/docs/reference/gtk/gtk-sections.txt @@ -5749,6 +5749,10 @@ gtk_widget_is_toplevel gtk_widget_set_window gtk_widget_set_receives_default gtk_widget_get_receives_default +gtk_widget_set_realized +gtk_widget_get_realized +gtk_widget_set_mapped +gtk_widget_set_mapped gtk_requisition_copy diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index 9fafefb71a..d6aa08907d 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -5247,6 +5247,10 @@ gtk_widget_set_can_default gtk_widget_get_can_default gtk_widget_set_can_focus gtk_widget_get_can_focus +gtk_widget_set_realized +gtk_widget_get_realized +gtk_widget_set_mapped +gtk_widget_get_mapped #endif #endif diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 027cfeb5a8..98a58df152 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -5950,6 +5950,100 @@ gtk_widget_is_drawable (GtkWidget *widget) (GTK_WIDGET_FLAGS (widget) & GTK_MAPPED) != 0); } +/** + * gtk_widget_get_realized: + * @widget: a #GtkWidget + * + * Determines whether @widget is realized. + * + * Return value: %TRUE if @widget is realized, %FALSE otherwise + * + * Since: 2.20 + **/ +gboolean +gtk_widget_get_realized (GtkWidget *widget) +{ + g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); + + return (GTK_WIDGET_FLAGS (widget) & GTK_REALIZED) != 0; +} + +/** + * gtk_widget_set_realized: + * @widget: a #GtkWidget + * @realized: %TRUE to mark the widget as realized + * + * Marks the widget as being realized. + * + * This function should only ever be called in a derived widget's + * "realize" or "unrealize" implementation. + * + * Since: 2.20 + */ +void +gtk_widget_set_realized (GtkWidget *widget, + gboolean realized) +{ + g_return_if_fail (GTK_IS_WIDGET (widget)); + + realized = realized != FALSE; + + if (realized != gtk_widget_get_realized (widget)) + { + if (realized) + GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); + else + GTK_WIDGET_UNSET_FLAGS (widget, GTK_REALIZED); + } +} + +/** + * gtk_widget_get_mapped: + * @widget: a #GtkWidget + * + * Whether the widget is mapped. + * + * Return value: %TRUE if the widget is mapped, %FALSE otherwise. + * + * Since: 2.20 + */ +gboolean +gtk_widget_get_mapped (GtkWidget *widget) +{ + g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); + + return (GTK_WIDGET_FLAGS (widget) & GTK_MAPPED) != 0; +} + +/** + * gtk_widget_set_mapped: + * @widget: a #GtkWidget + * @mapped: %TRUE to mark the widget as mapped + * + * Marks the widget as being realized. + * + * This function should only ever be called in a derived widget's + * "map" or "unmap" implementation. + * + * Since: 2.20 + */ +void +gtk_widget_set_mapped (GtkWidget *widget, + gboolean mapped) +{ + g_return_if_fail (GTK_IS_WIDGET (widget)); + + mapped = mapped != FALSE; + + if (mapped != gtk_widget_get_mapped (widget)) + { + if (mapped) + GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED); + else + GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED); + } +} + /** * gtk_widget_set_app_paintable: * @widget: a #GtkWidget diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index f33484ba68..2490d8b596 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -874,6 +874,12 @@ void gtk_widget_child_notify (GtkWidget *widget, const gchar *child_property); void gtk_widget_thaw_child_notify (GtkWidget *widget); +void gtk_widget_set_realized (GtkWidget *widget, + gboolean realized); +gboolean gtk_widget_get_realized (GtkWidget *widget); +void gtk_widget_set_mapped (GtkWidget *widget, + gboolean mapped); +gboolean gtk_widget_get_mapped (GtkWidget *widget); void gtk_widget_set_can_focus (GtkWidget *widget, gboolean can_focus); gboolean gtk_widget_get_can_focus (GtkWidget *widget); @@ -916,6 +922,12 @@ gboolean gtk_widget_get_has_window (GtkWidget *widget); gboolean gtk_widget_is_toplevel (GtkWidget *widget); gboolean gtk_widget_is_drawable (GtkWidget *widget); +void gtk_widget_set_realized (GtkWidget *widget, + gboolean realized); +gboolean gtk_widget_get_realized (GtkWidget *widget); +void gtk_widget_set_mapped (GtkWidget *widget, + gboolean mapped); +gboolean gtk_widget_get_mapped (GtkWidget *widget); void gtk_widget_set_app_paintable (GtkWidget *widget, gboolean app_paintable);