diff options
author | Matthias Clasen <mclasen@redhat.com> | 2018-01-11 21:43:01 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2018-01-14 17:05:04 -0500 |
commit | c2793de6e24abe7f405b4422781cdb9a9253dd3a (patch) | |
tree | e74c5459e5517265ef82e0a574556133168aa7c7 /gdk/gdkkeys.c | |
parent | a074eba16b2043f00db1a3e8d0b5c914e648ebe1 (diff) | |
download | gtk+-c2793de6e24abe7f405b4422781cdb9a9253dd3a.tar.gz |
Add a display property to keymaps
This is a general pattern we want to follow for all
objects in GDK. Also add a getter.
Diffstat (limited to 'gdk/gdkkeys.c')
-rw-r--r-- | gdk/gdkkeys.c | 65 |
1 files changed, 63 insertions, 2 deletions
diff --git a/gdk/gdkkeys.c b/gdk/gdkkeys.c index 84f9cda201..9f29e5dbe6 100644 --- a/gdk/gdkkeys.c +++ b/gdk/gdkkeys.c @@ -98,6 +98,11 @@ * gdk_keymap_translate_keyboard_state() just to get the keyval. */ +enum { + PROP_0, + PROP_DISPLAY, + LAST_PROP +}; enum { DIRECTION_CHANGED, @@ -106,22 +111,70 @@ enum { LAST_SIGNAL }; +static GParamSpec *props[LAST_PROP] = { NULL, }; +static guint signals[LAST_SIGNAL] = { 0 }; static GdkModifierType gdk_keymap_real_get_modifier_mask (GdkKeymap *keymap, GdkModifierIntent intent); +G_DEFINE_TYPE (GdkKeymap, gdk_keymap, G_TYPE_OBJECT) -static guint signals[LAST_SIGNAL] = { 0 }; +static void +gdk_keymap_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + GdkKeymap *keymap = GDK_KEYMAP (object); -G_DEFINE_TYPE (GdkKeymap, gdk_keymap, G_TYPE_OBJECT) + switch (prop_id) + { + case PROP_DISPLAY: + g_value_set_object (value, keymap->display); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +gdk_keymap_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GdkKeymap *keymap = GDK_KEYMAP (object); + + switch (prop_id) + { + case PROP_DISPLAY: + keymap->display = g_value_get_object (value); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} static void gdk_keymap_class_init (GdkKeymapClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + object_class->get_property = gdk_keymap_get_property; + object_class->set_property = gdk_keymap_set_property; + klass->get_modifier_mask = gdk_keymap_real_get_modifier_mask; + props[PROP_DISPLAY] = + g_param_spec_object ("display", + "Display", + "The display of the keymap", + GDK_TYPE_DISPLAY, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, LAST_PROP, props); + /** * GdkKeymap::direction-changed: * @keymap: the object on which the signal is emitted @@ -185,6 +238,14 @@ gdk_keymap_init (GdkKeymap *keymap) { } +GdkDisplay * +gdk_keymap_get_display (GdkKeymap *keymap) +{ + g_return_val_if_fail (GDK_IS_KEYMAP (keymap), NULL); + + return keymap->display; +} + /* Other key-handling stuff */ |