[gtk/wip/matthiasc/popup2: 331/353] popup: Implement the GtkRoot::default-widget
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/popup2: 331/353] popup: Implement the GtkRoot::default-widget
- Date: Sun, 7 Apr 2019 16:51:11 +0000 (UTC)
commit 14617f92ddfcc08654cb4407f339bcd7f4d451a5
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Mar 3 19:59:15 2019 -0500
popup: Implement the GtkRoot::default-widget
Add the ::default-widget property.
gtk/gtkpopup.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
---
diff --git a/gtk/gtkpopup.c b/gtk/gtkpopup.c
index 3c9ab3cdda..9a34384c6e 100644
--- a/gtk/gtkpopup.c
+++ b/gtk/gtkpopup.c
@@ -39,6 +39,7 @@ typedef struct {
GtkWidget *relative_to;
GtkWidget *focus_widget;
gboolean active;
+ GtkWidget *default_widget;
} GtkPopupPrivate;
@@ -355,6 +356,9 @@ gtk_popup_size_allocate (GtkWidget *widget,
static void gtk_popup_set_focus (GtkPopup *popup,
GtkWidget *widget);
+static void gtk_popup_set_default (GtkPopup *popup,
+ GtkWidget *widget);
+
static void
gtk_popup_set_property (GObject *object,
guint prop_id,
@@ -368,6 +372,9 @@ gtk_popup_set_property (GObject *object,
case 1 + GTK_ROOT_PROP_FOCUS_WIDGET:
gtk_popup_set_focus (popup, g_value_get_object (value));
break;
+ case 1 + GTK_ROOT_PROP_DEFAULT_WIDGET:
+ gtk_popup_set_default (popup, g_value_get_object (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -388,6 +395,9 @@ gtk_popup_get_property (GObject *object,
case 1 + GTK_ROOT_PROP_FOCUS_WIDGET:
g_value_set_object (value, priv->focus_widget);
break;
+ case 1 + GTK_ROOT_PROP_DEFAULT_WIDGET:
+ g_value_set_object (value, priv->default_widget);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -562,3 +572,42 @@ gtk_popup_get_popups (void)
return G_LIST_MODEL (popup_list);
}
+
+static void
+gtk_popup_set_default (GtkPopup *popup,
+ GtkWidget *widget)
+{
+ GtkPopupPrivate *priv = gtk_popup_get_instance_private (popup);
+
+ g_return_if_fail (GTK_IS_POPUP (popup));
+
+ if (widget && !gtk_widget_get_can_default (widget))
+ return;
+
+ if (priv->default_widget == widget)
+ return;
+
+ if (priv->default_widget)
+ {
+ if (priv->focus_widget != priv->default_widget ||
+ !gtk_widget_get_receives_default (priv->default_widget))
+ _gtk_widget_set_has_default (priv->default_widget, FALSE);
+
+ gtk_widget_queue_draw (priv->default_widget);
+ g_object_notify (G_OBJECT (priv->default_widget), "has-default");
+ }
+
+ g_set_object (&priv->default_widget, widget);
+
+ if (priv->default_widget)
+ {
+ if (priv->focus_widget == NULL ||
+ !gtk_widget_get_receives_default (priv->focus_widget))
+ _gtk_widget_set_has_default (priv->default_widget, TRUE);
+
+ gtk_widget_queue_draw (priv->default_widget);
+ g_object_notify (G_OBJECT (priv->default_widget), "has-default");
+ }
+
+ g_object_notify (G_OBJECT (popup), "default-widget");
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]