Commit eb0a5721 authored by Michael Natterer's avatar Michael Natterer 😴

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()).
parent b514c6ac
......@@ -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
......
......@@ -5577,6 +5577,58 @@ gtk_widget_get_state (GtkWidget *widget)
return widget->state;
}
/**
* 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
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment