[gtk/widget-class-actions: 13/22] Give the action muxer a widget
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/widget-class-actions: 13/22] Give the action muxer a widget
- Date: Sun, 16 Jun 2019 02:20:56 +0000 (UTC)
commit d80abbf8872bf1203f3cc87050322ccd2d9aff2a
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jun 15 23:08:39 2019 +0000
Give the action muxer a widget
This will be used in the future to obtain
widget class actions.
gtk/gtkactionmuxer.c | 26 ++++++++++++++++++++++++--
gtk/gtkactionmuxerprivate.h | 3 ++-
gtk/gtkapplication.c | 2 +-
gtk/gtkwidget.c | 2 +-
4 files changed, 28 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkactionmuxer.c b/gtk/gtkactionmuxer.c
index 5020f69359..f358f8cbbd 100644
--- a/gtk/gtkactionmuxer.c
+++ b/gtk/gtkactionmuxer.c
@@ -25,6 +25,7 @@
#include "gtkactionobserverprivate.h"
#include "gtkintl.h"
#include "gtkmarshalers.h"
+#include "gtkwidget.h"
#include <string.h>
@@ -69,6 +70,8 @@ struct _GtkActionMuxer
GHashTable *groups;
GHashTable *primary_accels;
GtkActionMuxer *parent;
+
+ GtkWidget *widget;
};
G_DEFINE_TYPE_WITH_CODE (GtkActionMuxer, gtk_action_muxer, G_TYPE_OBJECT,
@@ -79,6 +82,7 @@ enum
{
PROP_0,
PROP_PARENT,
+ PROP_WIDGET,
NUM_PROPERTIES
};
@@ -592,6 +596,10 @@ gtk_action_muxer_get_property (GObject *object,
g_value_set_object (value, gtk_action_muxer_get_parent (muxer));
break;
+ case PROP_WIDGET:
+ g_value_set_object (value, muxer->widget);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -611,6 +619,10 @@ gtk_action_muxer_set_property (GObject *object,
gtk_action_muxer_set_parent (muxer, g_value_get_object (value));
break;
+ case PROP_WIDGET:
+ muxer->widget = g_value_get_object (value);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -664,6 +676,13 @@ gtk_action_muxer_class_init (GObjectClass *class)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS);
+ properties[PROP_WIDGET] = g_param_spec_object ("widget", "Widget",
+ "The widget that owns the muxer",
+ GTK_TYPE_WIDGET,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
g_object_class_install_properties (class, NUM_PROPERTIES, properties);
}
@@ -771,13 +790,16 @@ gtk_action_muxer_lookup (GtkActionMuxer *muxer,
/*< private >
* gtk_action_muxer_new:
+ * @widget: the widget to which the muxer belongs
*
* Creates a new #GtkActionMuxer.
*/
GtkActionMuxer *
-gtk_action_muxer_new (void)
+gtk_action_muxer_new (GtkWidget *widget)
{
- return g_object_new (GTK_TYPE_ACTION_MUXER, NULL);
+ return g_object_new (GTK_TYPE_ACTION_MUXER,
+ "widget", widget,
+ NULL);
}
/*< private >
diff --git a/gtk/gtkactionmuxerprivate.h b/gtk/gtkactionmuxerprivate.h
index 01b6f14bd1..190728fafd 100644
--- a/gtk/gtkactionmuxerprivate.h
+++ b/gtk/gtkactionmuxerprivate.h
@@ -21,6 +21,7 @@
#define __GTK_ACTION_MUXER_H__
#include <gio/gio.h>
+#include "gtkwidget.h"
G_BEGIN_DECLS
@@ -33,7 +34,7 @@ G_BEGIN_DECLS
typedef struct _GtkActionMuxer GtkActionMuxer;
GType gtk_action_muxer_get_type (void);
-GtkActionMuxer * gtk_action_muxer_new (void);
+GtkActionMuxer * gtk_action_muxer_new (GtkWidget *widget);
void gtk_action_muxer_insert (GtkActionMuxer *muxer,
const gchar *prefix,
diff --git a/gtk/gtkapplication.c b/gtk/gtkapplication.c
index cf3070e088..f90fd827fc 100644
--- a/gtk/gtkapplication.c
+++ b/gtk/gtkapplication.c
@@ -394,7 +394,7 @@ gtk_application_init (GtkApplication *application)
{
GtkApplicationPrivate *priv = gtk_application_get_instance_private (application);
- priv->muxer = gtk_action_muxer_new ();
+ priv->muxer = gtk_action_muxer_new (NULL);
priv->accels = gtk_application_accels_new ();
}
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 532aecb3cb..444ecbe4dd 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -11904,7 +11904,7 @@ _gtk_widget_get_action_muxer (GtkWidget *widget,
if (create)
{
- muxer = gtk_action_muxer_new ();
+ muxer = gtk_action_muxer_new (widget);
g_object_set_qdata_full (G_OBJECT (widget),
quark_action_muxer,
muxer,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]