mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-02 17:00:19 +00:00
Give the action muxer a widget
This will be used in the future to obtain widget class actions.
This commit is contained in:
parent
aa6f5dae5a
commit
9b62da10e6
@ -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 >
|
||||
|
@ -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,
|
||||
|
@ -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 ();
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user