[gtk/default-handling: 2/18] window: Add a default-widget property
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/default-handling: 2/18] window: Add a default-widget property
- Date: Sun, 28 Apr 2019 19:31:58 +0000 (UTC)
commit 36376338b5d325322eb16ac7a7081aaf6c7c4dd6
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Apr 28 16:45:22 2019 +0000
window: Add a default-widget property
This is a part of redoing default widget handling.
gtk/gtkwindow.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index fd12df3266..a39b108f41 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -325,6 +325,8 @@ enum {
PROP_TRANSIENT_FOR,
PROP_ATTACHED_TO,
PROP_APPLICATION,
+ PROP_DEFAULT_WIDGET,
+
/* Readonly properties */
PROP_IS_ACTIVE,
@@ -1057,6 +1059,13 @@ gtk_window_class_init (GtkWindowClass *klass)
GTK_TYPE_APPLICATION,
GTK_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
+ window_props[PROP_DEFAULT_WIDGET] =
+ g_param_spec_object ("default-widget",
+ P_("Default widget"),
+ P_("The default widget"),
+ GTK_TYPE_WIDGET,
+ GTK_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
+
g_object_class_install_properties (gobject_class, LAST_ARG, window_props);
gtk_root_install_properties (gobject_class, LAST_ARG);
@@ -1985,6 +1994,9 @@ gtk_window_set_property (GObject *object,
case PROP_APPLICATION:
gtk_window_set_application (window, g_value_get_object (value));
break;
+ case PROP_DEFAULT_WIDGET:
+ gtk_window_set_default (window, g_value_get_object (value));
+ break;
case PROP_MNEMONICS_VISIBLE:
gtk_window_set_mnemonics_visible (window, g_value_get_boolean (value));
break;
@@ -2082,6 +2094,9 @@ gtk_window_get_property (GObject *object,
case PROP_APPLICATION:
g_value_set_object (value, gtk_window_get_application (window));
break;
+ case PROP_DEFAULT_WIDGET:
+ g_value_set_object (value, gtk_window_get_default_widget (window));
+ break;
case PROP_MNEMONICS_VISIBLE:
g_value_set_boolean (value, priv->mnemonics_visible);
break;
@@ -2541,7 +2556,7 @@ gtk_window_set_default (GtkWindow *window,
if (priv->default_widget != default_widget)
{
GtkWidget *old_default_widget = NULL;
-
+
if (default_widget)
g_object_ref (default_widget);
@@ -2569,12 +2584,14 @@ gtk_window_set_default (GtkWindow *window,
if (old_default_widget)
g_object_notify (G_OBJECT (old_default_widget), "has-default");
-
+
if (default_widget)
{
g_object_notify (G_OBJECT (default_widget), "has-default");
g_object_unref (default_widget);
}
+
+ g_object_notify_by_pspec (G_OBJECT (window), window_props[PROP_DEFAULT_WIDGET]);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]