[gtk/wip/matthiasc/shortcut: 8/106] bindings: Add gtk_binding_entry_add_signal_variant()
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/shortcut: 8/106] bindings: Add gtk_binding_entry_add_signal_variant()
- Date: Tue, 17 Mar 2020 23:59:55 +0000 (UTC)
commit e503b795d93203d3938e9bf9cd3ce6fffea31fa9
Author: Benjamin Otte <otte redhat com>
Date: Tue Jul 31 21:32:34 2018 +0200
bindings: Add gtk_binding_entry_add_signal_variant()
This function is the replacement for
gtk_binding_entry_add_signall().
The GVariant will be demarshalled and passed to the action signal upon
binding activation. The same rules apply as used to apply for
GtkBindingArg, in that long, double and string args are now replaced by
"x", "d" and "s" variant types.
docs/reference/gtk/gtk4-sections.txt | 1 +
gtk/gtkbindings.c | 57 ++++++++++++++++++++++--------------
gtk/gtkbindings.h | 6 ++++
3 files changed, 42 insertions(+), 22 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index 13b3f831f6..732f822f4f 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -4632,6 +4632,7 @@ gtk_binding_entry_add_action_variant
GtkBindingCallback
gtk_binding_entry_add_callback
gtk_binding_entry_add_signal
+gtk_binding_entry_add_signal_variant
gtk_binding_entry_add_signal_from_string
gtk_binding_entry_skip
gtk_binding_entry_remove
diff --git a/gtk/gtkbindings.c b/gtk/gtkbindings.c
index dd1de0abc2..d54c8d1724 100644
--- a/gtk/gtkbindings.c
+++ b/gtk/gtkbindings.c
@@ -1078,18 +1078,44 @@ gtk_binding_entry_add_binding_signal (GtkBindingSet *binding_set,
*signal_p = signal;
}
-/*
- * gtk_binding_entry_add_signall:
+/**
+ * gtk_binding_entry_add_signal_variant:
* @binding_set: a #GtkBindingSet to add a signal to
* @keyval: key value
* @modifiers: key modifier
* @signal_name: signal name to be bound
- * @binding_args: (transfer none) (element-type GtkBindingArg):
- * list of #GtkBindingArg signal arguments
+ * @binding_args: a #GVariant containing a struct with the arguments to pass.
*
* Override or install a new key binding for @keyval with @modifiers on
* @binding_set.
*/
+void
+gtk_binding_entry_add_signal_variant (GtkBindingSet *binding_set,
+ guint keyval,
+ GdkModifierType modifiers,
+ const gchar *signal_name,
+ GVariant *binding_args)
+{
+ GtkBindingEntry *entry;
+ GtkBindingSignal *signal, **signal_p;
+
+ keyval = gdk_keyval_to_lower (keyval);
+ modifiers = modifiers & BINDING_MOD_MASK ();
+
+ signal = binding_signal_new_signal (signal_name, binding_args);
+
+ entry = binding_ht_lookup_entry (binding_set, keyval, modifiers);
+ if (!entry)
+ {
+ gtk_binding_entry_clear_internal (binding_set, keyval, modifiers);
+ entry = binding_ht_lookup_entry (binding_set, keyval, modifiers);
+ }
+ signal_p = &entry->signals;
+ while (*signal_p)
+ signal_p = &(*signal_p)->next;
+ *signal_p = signal;
+}
+
static void
gtk_binding_entry_add_signall (GtkBindingSet *binding_set,
guint keyval,
@@ -1097,19 +1123,13 @@ gtk_binding_entry_add_signall (GtkBindingSet *binding_set,
const gchar *signal_name,
GSList *binding_args)
{
- GtkBindingSignal *signal;
GSList *slist;
guint n = 0;
GVariantBuilder builder;
- GtkBindingEntry *entry;
- GtkBindingSignal **signal_p;
g_return_if_fail (binding_set != NULL);
g_return_if_fail (signal_name != NULL);
- keyval = gdk_keyval_to_lower (keyval);
- modifiers = modifiers & BINDING_MOD_MASK ();
-
g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE);
for (slist = binding_args; slist; slist = slist->next)
@@ -1148,18 +1168,11 @@ gtk_binding_entry_add_signall (GtkBindingSet *binding_set,
}
}
- signal = binding_signal_new_signal (signal_name, g_variant_builder_end (&builder));
-
- entry = binding_ht_lookup_entry (binding_set, keyval, modifiers);
- if (!entry)
- {
- gtk_binding_entry_clear_internal (binding_set, keyval, modifiers);
- entry = binding_ht_lookup_entry (binding_set, keyval, modifiers);
- }
- signal_p = &entry->signals;
- while (*signal_p)
- signal_p = &(*signal_p)->next;
- *signal_p = signal;
+ gtk_binding_entry_add_signal_variant (binding_set,
+ keyval,
+ modifiers,
+ signal_name,
+ g_variant_builder_end (&builder));
}
/**
diff --git a/gtk/gtkbindings.h b/gtk/gtkbindings.h
index ef8756f6bd..e7ba0f1655 100644
--- a/gtk/gtkbindings.h
+++ b/gtk/gtkbindings.h
@@ -79,6 +79,12 @@ void gtk_binding_entry_skip (GtkBindingSet *binding_set,
guint keyval,
GdkModifierType modifiers);
GDK_AVAILABLE_IN_ALL
+void gtk_binding_entry_add_signal_variant (GtkBindingSet*binding_set,
+ guint keyval,
+ GdkModifierType modifiers,
+ const gchar *signal_name,
+ GVariant *binding_args);
+GDK_AVAILABLE_IN_ALL
void gtk_binding_entry_add_signal (GtkBindingSet *binding_set,
guint keyval,
GdkModifierType modifiers,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]