Commit bb1824c1 authored by Christian Dywan's avatar Christian Dywan
Browse files

Deprecate flag macros for toplevel, state, no window and composite child

Deprecate widget flag macros GTK_WIDGET_STATE, GTK_WIDGET_SAVED_STATE,
GTK_WIDGET_FLAGS, GTK_WIDGET_TOPLEVEL, GTK_WIDGET_NO_WINDOW and
GTK_WIDGET_COMPOSITE_CHILD.

Also deprecate the type macros GTK_WIDGET_TYPE, GTK_OBJECT_TYPE_NAME and
GTK_OBJECT_TYPE which have become redundant.

Instances of GTK_WIDGET_TOPLEVEL are replaced with gtk_widget_is_toplevel,
GTK_WIDGET_TYPE is replaced with G_OBJECT_TYPE, GTK_WIDGET_COMPOSITE_CHILD
is replaced with use of the "composite-child" property and uses of
GTK_WIDGET_NO_WINDOW are adjusted to use gtk_widget_get_has_window.

Uses of GTK_WIDGET_SAVED_STATE and GTK_WIDGET_FLAGS inside GtkWidget are
changed to direct flag usage.

Documentation is updated to refer to gtk_widget_set_has_window and
gtk_widget_get_has_window.

Gail and tests are updated as well.

Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=69872
parent ac26960e
......@@ -124,11 +124,10 @@
However, in practice it is convenient to have widgets which do
not have a <classname>GdkWindow</classname> of their own, but
rather share the one from their parent widget. Such widgets
have the <constant>GTK_NO_WINDOW</constant> <link
linkend="GtkWidgetFlags">widget flag</link> turned on; this
can be tested easily with the <link
linkend="GTK-WIDGET-NO-WINDOW-CAPS"><function>GTK_WIDGET_NO_WINDOW()</function></link>
macro. As such, these are called <firstterm>no-window
have called <function>gtk_widget_set_has_window</function> to
disable it; this can be tested easily with the <link
linkend="gtk-widget-get-has-window"><function>gtk_widget_get_has_window()</function></link>
function. As such, these are called <firstterm>no-window
widgets</firstterm>.
</para>
......
......@@ -195,9 +195,8 @@
<para>
A widget that does not have a GdkWindow of its own on which to
draw its contents, but rather shares its <glossterm
linkend="parent">parent's</glossterm>. Such a widget has the
%GTK_NO_WINDOW <link linkend="GtkWidgetFlags">flag</link> set, and
can be tested with the GTK_WIDGET_NO_WINDOW() macro. See
linkend="parent">parent's</glossterm>. This can be tested with
the gtk_widget_get_has_window() function. See
<xref linkend="window-no-window-widgets"/> for a detailed
description of this flag.
</para>
......
......@@ -111,21 +111,6 @@ if all references are released.
</para>
<!-- ##### MACRO GTK_OBJECT_TYPE ##### -->
<para>
Gets the type of an object.
</para>
@object: a #GtkObject.
<!-- ##### MACRO GTK_OBJECT_TYPE_NAME ##### -->
<para>
Gets the name of an objects type.
</para>
@object: a #GtkObject.
<!-- ##### ENUM GtkObjectFlags ##### -->
<para>
......
......@@ -1695,7 +1695,7 @@ gtk_assistant_insert_page (GtkAssistant *assistant,
g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), 0);
g_return_val_if_fail (GTK_IS_WIDGET (page), 0);
g_return_val_if_fail (page->parent == NULL, 0);
g_return_val_if_fail (!GTK_WIDGET_TOPLEVEL (page), 0);
g_return_val_if_fail (!gtk_widget_is_toplevel (page), 0);
priv = assistant->priv;
......
......@@ -6149,7 +6149,7 @@ typedef struct
/* The window to which widget->window is relative */
#define ALLOCATION_WINDOW(widget) \
(GTK_WIDGET_NO_WINDOW (widget) ? \
(!gtk_widget_get_has_window (widget) ? \
(widget)->window : \
gdk_window_get_parent ((widget)->window))
......
......@@ -713,7 +713,7 @@ gtk_color_button_clicked (GtkButton *button)
color_dialog = GTK_COLOR_SELECTION_DIALOG (color_button->priv->cs_dialog);
if (GTK_WIDGET_TOPLEVEL (parent) && GTK_IS_WINDOW (parent))
if (gtk_widget_is_toplevel (parent) && GTK_IS_WINDOW (parent))
{
if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (color_dialog)))
gtk_window_set_transient_for (GTK_WINDOW (color_dialog), GTK_WINDOW (parent));
......
......@@ -1489,7 +1489,7 @@ gtk_combo_box_menu_position_below (GtkMenu *menu,
sx = sy = 0;
if (GTK_WIDGET_NO_WINDOW (child))
if (!gtk_widget_get_has_window (child))
{
sx += child->allocation.x;
sy += child->allocation.y;
......@@ -1652,7 +1652,7 @@ gtk_combo_box_list_position (GtkComboBox *combo_box,
*x = *y = 0;
if (GTK_WIDGET_NO_WINDOW (sample))
if (!gtk_widget_get_has_window (sample))
{
*x += sample->allocation.x;
*y += sample->allocation.y;
......
......@@ -1261,7 +1261,7 @@ gtk_container_set_resize_mode (GtkContainer *container,
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (resize_mode <= GTK_RESIZE_IMMEDIATE);
if (GTK_WIDGET_TOPLEVEL (container) &&
if (gtk_widget_is_toplevel (GTK_WIDGET (container)) &&
resize_mode == GTK_RESIZE_PARENT)
{
resize_mode = GTK_RESIZE_QUEUE;
......@@ -1380,7 +1380,7 @@ _gtk_container_queue_resize (GtkContainer *container)
if (resize_container)
{
if (GTK_WIDGET_VISIBLE (resize_container) &&
(GTK_WIDGET_TOPLEVEL (resize_container) || GTK_WIDGET_REALIZED (resize_container)))
(gtk_widget_is_toplevel (GTK_WIDGET (resize_container)) || GTK_WIDGET_REALIZED (resize_container)))
{
switch (resize_container->resize_mode)
{
......@@ -1690,11 +1690,14 @@ gchar*
_gtk_container_child_composite_name (GtkContainer *container,
GtkWidget *child)
{
gboolean composite_child;
g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
g_return_val_if_fail (GTK_IS_WIDGET (child), NULL);
g_return_val_if_fail (child->parent == GTK_WIDGET (container), NULL);
if (GTK_WIDGET_COMPOSITE_CHILD (child))
g_object_get (child, "composite-child", &composite_child, NULL);
if (composite_child)
{
static GQuark quark_composite_name = 0;
gchar *name;
......
......@@ -357,7 +357,7 @@ gtk_drag_highlight_expose (GtkWidget *widget,
{
cairo_t *cr;
if (GTK_WIDGET_NO_WINDOW (widget))
if (!gtk_widget_get_has_window (widget))
{
x = widget->allocation.x;
y = widget->allocation.y;
......@@ -434,7 +434,7 @@ get_toplevel_nswindow (GtkWidget *widget)
{
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
if (GTK_WIDGET_TOPLEVEL (toplevel) && toplevel->window)
if (gtk_widget_is_toplevel (toplevel) && toplevel->window)
return [gdk_quartz_window_get_nsview (toplevel->window) window];
else
return NULL;
......@@ -697,7 +697,7 @@ gtk_drag_find_widget (GtkWidget *widget,
allocation_to_window_x = widget->allocation.x;
allocation_to_window_y = widget->allocation.y;
if (!GTK_WIDGET_NO_WINDOW (widget))
if (gtk_widget_get_has_window (widget))
{
/* The allocation is relative to the parent window for
* window widgets, not to widget->window.
......
......@@ -1106,7 +1106,7 @@ gtk_drag_highlight_expose (GtkWidget *widget,
{
cairo_t *cr;
if (GTK_WIDGET_NO_WINDOW (widget))
if (!gtk_widget_get_has_window (widget))
{
x = widget->allocation.x;
y = widget->allocation.y;
......@@ -1860,7 +1860,7 @@ gtk_drag_find_widget (GtkWidget *widget,
allocation_to_window_x = widget->allocation.x;
allocation_to_window_y = widget->allocation.y;
if (!GTK_WIDGET_NO_WINDOW (widget))
if (gtk_widget_get_has_window (widget))
{
/* The allocation is relative to the parent window for
* window widgets, not to widget->window.
......@@ -2065,7 +2065,7 @@ gtk_drag_dest_realized (GtkWidget *widget)
{
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
if (GTK_WIDGET_TOPLEVEL (toplevel))
if (gtk_widget_is_toplevel (toplevel))
gdk_window_register_dnd (toplevel->window);
}
......@@ -2075,7 +2075,7 @@ gtk_drag_dest_hierarchy_changed (GtkWidget *widget,
{
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
if (GTK_WIDGET_TOPLEVEL (toplevel) && GTK_WIDGET_REALIZED (toplevel))
if (gtk_widget_is_toplevel (toplevel) && GTK_WIDGET_REALIZED (toplevel))
gdk_window_register_dnd (toplevel->window);
}
......
......@@ -79,7 +79,7 @@ gtk_drawing_area_realize (GtkWidget *widget)
GdkWindowAttr attributes;
gint attributes_mask;
if (GTK_WIDGET_NO_WINDOW (widget))
if (!gtk_widget_get_has_window (widget))
{
GTK_WIDGET_CLASS (gtk_drawing_area_parent_class)->realize (widget);
}
......@@ -121,7 +121,7 @@ gtk_drawing_area_size_allocate (GtkWidget *widget,
if (GTK_WIDGET_REALIZED (widget))
{
if (!GTK_WIDGET_NO_WINDOW (widget))
if (gtk_widget_get_has_window (widget))
gdk_window_move_resize (widget->window,
allocation->x, allocation->y,
allocation->width, allocation->height);
......
......@@ -2449,7 +2449,7 @@ open_dialog (GtkFileChooserButton *button)
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (button));
if (GTK_WIDGET_TOPLEVEL (toplevel) && GTK_IS_WINDOW (toplevel))
if (gtk_widget_is_toplevel (toplevel) && GTK_IS_WINDOW (toplevel))
{
if (GTK_WINDOW (toplevel) != gtk_window_get_transient_for (GTK_WINDOW (priv->dialog)))
gtk_window_set_transient_for (GTK_WINDOW (priv->dialog),
......
......@@ -927,7 +927,7 @@ get_toplevel (GtkWidget *widget)
GtkWidget *toplevel;
toplevel = gtk_widget_get_toplevel (widget);
if (!GTK_WIDGET_TOPLEVEL (toplevel))
if (!gtk_widget_is_toplevel (toplevel))
return NULL;
else
return GTK_WINDOW (toplevel);
......
......@@ -705,7 +705,7 @@ gtk_font_button_clicked (GtkButton *button)
font_dialog = GTK_FONT_SELECTION_DIALOG (font_button->priv->font_dialog);
if (GTK_WIDGET_TOPLEVEL (parent) && GTK_IS_WINDOW (parent))
if (gtk_widget_is_toplevel (parent) && GTK_IS_WINDOW (parent))
{
if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (font_dialog)))
gtk_window_set_transient_for (GTK_WINDOW (font_dialog), GTK_WINDOW (parent));
......
......@@ -273,7 +273,7 @@ list_row_activated (GtkWidget *widget)
GtkWindow *window;
window = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (widget)));
if (!GTK_WIDGET_TOPLEVEL (window))
if (!gtk_widget_is_toplevel (GTK_WIDGET (window)))
window = NULL;
if (window
......
......@@ -478,7 +478,7 @@ gtk_handle_box_style_set (GtkWidget *widget,
GtkHandleBox *hb = GTK_HANDLE_BOX (widget);
if (GTK_WIDGET_REALIZED (widget) &&
!GTK_WIDGET_NO_WINDOW (widget))
gtk_widget_get_has_window (widget))
{
gtk_style_set_background (widget->style, widget->window,
widget->state);
......
......@@ -8487,7 +8487,7 @@ gtk_icon_view_item_accessible_grab_focus (AtkComponent *component)
gtk_widget_grab_focus (item->widget);
gtk_icon_view_set_cursor_item (GTK_ICON_VIEW (item->widget), item->item, -1);
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (item->widget));
if (GTK_WIDGET_TOPLEVEL (toplevel))
if (gtk_widget_is_toplevel (toplevel))
gtk_window_present (GTK_WINDOW (toplevel));
return TRUE;
......
......@@ -1503,7 +1503,7 @@ gtk_label_setup_mnemonic (GtkLabel *label,
connect_mnemonics_visible_notify (GTK_LABEL (widget));
toplevel = gtk_widget_get_toplevel (widget);
if (GTK_WIDGET_TOPLEVEL (toplevel))
if (gtk_widget_is_toplevel (toplevel))
{
GtkWidget *menu_shell;
......
......@@ -1986,7 +1986,7 @@ gtk_menu_get_toplevel (GtkWidget *menu)
else if (GTK_IS_WIDGET (attach))
{
toplevel = gtk_widget_get_toplevel (attach);
if (GTK_WIDGET_TOPLEVEL (toplevel))
if (gtk_widget_is_toplevel (toplevel))
return toplevel;
}
......
......@@ -690,7 +690,7 @@ gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
if (old_toplevel)
remove_from_window (GTK_WINDOW (old_toplevel), menubar);
if (GTK_WIDGET_TOPLEVEL (toplevel))
if (gtk_widget_is_toplevel (toplevel))
add_to_window (GTK_WINDOW (toplevel), menubar);
}
......@@ -708,7 +708,7 @@ _gtk_menu_bar_cycle_focus (GtkMenuBar *menubar,
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menubar));
GtkMenuItem *to_activate = NULL;
if (GTK_WIDGET_TOPLEVEL (toplevel))
if (gtk_widget_is_toplevel (toplevel))
{
GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (toplevel));
GList *menubars;
......
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