[gtk/default-handling: 1/18] widget: Add a convenience api to activate actions
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/default-handling: 1/18] widget: Add a convenience api to activate actions
- Date: Sun, 28 Apr 2019 19:31:53 +0000 (UTC)
commit 6b9bb4e58dd282822e33311fc3e69bfff71ac84c
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Apr 28 18:04:28 2019 +0000
widget: Add a convenience api to activate actions
Since actions are used increasingly, we should
have a convenient way to trigger an action in
the context of a widget.
docs/reference/gtk/gtk4-sections.txt | 3 ++-
gtk/gtkwidget.c | 30 ++++++++++++++++++++++++++++++
gtk/gtkwidget.h | 5 +++++
3 files changed, 37 insertions(+), 1 deletion(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index 33f5984760..33db802937 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -4538,13 +4538,14 @@ gtk_widget_get_realized
gtk_widget_get_mapped
gtk_widget_device_is_shadowed
gtk_widget_get_modifier_mask
-gtk_widget_insert_action_group
gtk_widget_get_opacity
gtk_widget_set_opacity
gtk_widget_get_overflow
gtk_widget_set_overflow
+gtk_widget_insert_action_group
gtk_widget_list_action_prefixes
gtk_widget_get_action_group
+gtk_widget_activate_action
gtk_widget_measure
gtk_widget_snapshot_child
gtk_widget_get_next_sibling
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index faf5318a95..89e633021a 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -12900,6 +12900,36 @@ gtk_widget_get_action_group (GtkWidget *widget,
return NULL;
}
+/**
+ * gtk_widget_activate_action:
+ * @widget: a #GtkWidget
+ * @name: a prefixed action name
+ * @parameter: parameters that required by the action
+ *
+ * Looks up the action in the action groups associated
+ * with @widget and its ancestors, and activates it.
+ *
+ * The action name is expected to be prefixed with the
+ * prefix that was used when adding the action group
+ * with gtk_widget_insert_action_group().
+ *
+ * The @parameter must match the actions expected parameter
+ * type, as returned by g_action_get_parameter_type().
+ */
+void
+gtk_widget_activate_action (GtkWidget *widget,
+ const char *name,
+ GVariant *parameter)
+{
+ GtkActionMuxer *muxer;
+
+ muxer = _gtk_widget_get_action_muxer (widget, FALSE);
+ if (muxer)
+ g_action_group_activate_action (G_ACTION_GROUP (muxer),
+ name,
+ parameter);
+}
+
void
gtk_widget_cancel_event_sequence (GtkWidget *widget,
GtkGesture *gesture,
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 9b17b56845..5fa35ef1ab 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -1011,6 +1011,11 @@ GActionGroup *gtk_widget_get_action_group (GtkWidget *
GDK_AVAILABLE_IN_ALL
const gchar ** gtk_widget_list_action_prefixes (GtkWidget *widget);
+GDK_AVAILABLE_IN_ALL
+void gtk_widget_activate_action (GtkWidget *widget,
+ const char *name,
+ GVariant *parameter);
+
GDK_AVAILABLE_IN_ALL
void gtk_widget_set_font_map (GtkWidget *widget,
PangoFontMap *font_map);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]