forked from AuroraMiddleware/gtk
widget: Add a GtkWidget::root property and gtk_widget_get_root()
The property is just for API completeness, the getter is meant to replace toplevel usage.
This commit is contained in:
parent
4ca1f7e29f
commit
ddf2a3681d
@ -507,6 +507,7 @@ enum {
|
||||
PROP_0,
|
||||
PROP_NAME,
|
||||
PROP_PARENT,
|
||||
PROP_ROOT,
|
||||
PROP_WIDTH_REQUEST,
|
||||
PROP_HEIGHT_REQUEST,
|
||||
PROP_VISIBLE,
|
||||
@ -964,6 +965,19 @@ gtk_widget_class_init (GtkWidgetClass *klass)
|
||||
GTK_TYPE_WIDGET,
|
||||
GTK_PARAM_READABLE|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkWidget:root:
|
||||
*
|
||||
* The #GtkRoot widget of the widget tree containing this widget or %NULL if
|
||||
* the widget is not contained in a root widget.
|
||||
*/
|
||||
widget_props[PROP_ROOT] =
|
||||
g_param_spec_object ("root",
|
||||
P_("Root widget"),
|
||||
P_("The root widget in the widget tree."),
|
||||
GTK_TYPE_ROOT,
|
||||
GTK_PARAM_READABLE|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
widget_props[PROP_WIDTH_REQUEST] =
|
||||
g_param_spec_int ("width-request",
|
||||
P_("Width request"),
|
||||
@ -2384,6 +2398,9 @@ gtk_widget_get_property (GObject *object,
|
||||
case PROP_PARENT:
|
||||
g_value_set_object (value, priv->parent);
|
||||
break;
|
||||
case PROP_ROOT:
|
||||
g_value_set_object (value, priv->root);
|
||||
break;
|
||||
case PROP_WIDTH_REQUEST:
|
||||
{
|
||||
int w;
|
||||
@ -3031,6 +3048,8 @@ gtk_widget_root (GtkWidget *widget)
|
||||
priv->root = priv->parent->priv->root;
|
||||
|
||||
GTK_WIDGET_GET_CLASS (widget)->root (widget);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_ROOT]);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -3048,6 +3067,8 @@ gtk_widget_unroot (GtkWidget *widget)
|
||||
GTK_WIDGET_GET_CLASS (widget)->unroot (widget);
|
||||
|
||||
priv->root = NULL;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_ROOT]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -6736,6 +6757,25 @@ gtk_widget_get_parent (GtkWidget *widget)
|
||||
return priv->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_widget_get_root:
|
||||
* @widget: a #GtkWidget
|
||||
*
|
||||
* Returns the #GtkRoot widget of @widget or %NULL if the widget is not contained
|
||||
* inside a widget tree with a root widget.
|
||||
*
|
||||
* #GtkRoot widgets will return themselves here.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the root widget of @widget, or %NULL
|
||||
**/
|
||||
GtkRoot *
|
||||
gtk_widget_get_root (GtkWidget *widget)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||
|
||||
return _gtk_widget_get_root (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_widget_real_direction_changed (GtkWidget *widget,
|
||||
GtkTextDirection previous_direction)
|
||||
|
@ -564,13 +564,16 @@ GDK_AVAILABLE_IN_ALL
|
||||
void gtk_widget_set_parent (GtkWidget *widget,
|
||||
GtkWidget *parent);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget * gtk_widget_get_parent (GtkWidget *widget);
|
||||
GtkWidget * gtk_widget_get_parent (GtkWidget *widget);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkRoot * gtk_widget_get_root (GtkWidget *widget);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_widget_set_parent_surface (GtkWidget *widget,
|
||||
GdkSurface *parent_surface);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkSurface * gtk_widget_get_parent_surface (GtkWidget *widget);
|
||||
GdkSurface * gtk_widget_get_parent_surface (GtkWidget *widget);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_widget_set_child_visible (GtkWidget *widget,
|
||||
|
@ -422,6 +422,12 @@ _gtk_widget_get_toplevel (GtkWidget *widget)
|
||||
return widget;
|
||||
}
|
||||
|
||||
static inline GtkRoot *
|
||||
_gtk_widget_get_root (GtkWidget *widget)
|
||||
{
|
||||
return widget->priv->root;
|
||||
}
|
||||
|
||||
static inline GdkDisplay *
|
||||
_gtk_widget_get_display (GtkWidget *widget)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user