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()).
This commit is contained in:
Michael Natterer 2009-08-07 08:53:32 +02:00
parent b514c6ac22
commit eb0a5721d9
3 changed files with 58 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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);