[gtk/wip/otte/listview: 33/38] widget: Make gtk_widget_activate_action() return TRUE/FALSE
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/listview: 33/38] widget: Make gtk_widget_activate_action() return TRUE/FALSE
- Date: Tue, 15 Oct 2019 04:49:33 +0000 (UTC)
commit d8c9b4b99e9db63cb7f58ea09d1d9a0439cd171e
Author: Benjamin Otte <otte redhat com>
Date: Mon Oct 14 21:34:00 2019 +0200
widget: Make gtk_widget_activate_action() return TRUE/FALSE
TRUE if an action was successfully activated, FALSE if it wasn't found.
gtk/gtkwidget.c | 26 +++++++++++++++++++++-----
gtk/gtkwidget.h | 6 +++---
2 files changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 9fd6f9feb4..6f1f95b926 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -12454,8 +12454,11 @@ gtk_widget_get_template_child (GtkWidget *widget,
*
* The arguments must match the actions expected parameter
* type, as returned by g_action_get_parameter_type().
+ *
+ * Returns: %TRUE if the action was activated, %FALSE if the action does
+ * not exist.
*/
-void
+gboolean
gtk_widget_activate_action_variant (GtkWidget *widget,
const char *name,
GVariant *args)
@@ -12463,8 +12466,15 @@ gtk_widget_activate_action_variant (GtkWidget *widget,
GtkActionMuxer *muxer;
muxer = _gtk_widget_get_action_muxer (widget, FALSE);
- if (muxer)
- g_action_group_activate_action (G_ACTION_GROUP (muxer), name, args);
+ if (muxer == NULL)
+ return FALSE;
+
+ if (!g_action_group_has_action (G_ACTION_GROUP (muxer), name))
+ return FALSE;
+
+ g_action_group_activate_action (G_ACTION_GROUP (muxer), name, args);
+
+ return TRUE;
}
/**
@@ -12480,14 +12490,18 @@ gtk_widget_activate_action_variant (GtkWidget *widget,
*
* This is a wrapper around gtk_widget_activate_action_variant()
* that constructs the @args variant according to @format_string.
+ *
+ * Returns: %TRUE if the action was activated, %FALSE if the action does
+ * not exist.
*/
-void
+gboolean
gtk_widget_activate_action (GtkWidget *widget,
const char *name,
const char *format_string,
...)
{
GVariant *parameters = NULL;
+ gboolean result;
if (format_string != NULL)
{
@@ -12500,9 +12514,11 @@ gtk_widget_activate_action (GtkWidget *widget,
g_variant_ref_sink (parameters);
}
- gtk_widget_activate_action_variant (widget, name, parameters);
+ result = gtk_widget_activate_action_variant (widget, name, parameters);
g_clear_pointer (¶meters, g_variant_unref);
+
+ return result;
}
/**
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index cc511f5f26..67b752edf0 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -972,17 +972,17 @@ void gtk_widget_insert_action_group (GtkWidget *widget,
GActionGroup *group);
GDK_AVAILABLE_IN_ALL
-void gtk_widget_activate_action (GtkWidget *widget,
+gboolean gtk_widget_activate_action (GtkWidget *widget,
const char *name,
const char *format_string,
...);
GDK_AVAILABLE_IN_ALL
-void gtk_widget_activate_action_variant (GtkWidget *widget,
+gboolean gtk_widget_activate_action_variant (GtkWidget *widget,
const char *name,
GVariant *args);
GDK_AVAILABLE_IN_ALL
-void gtk_widget_activate_default (GtkWidget *widget);
+void gtk_widget_activate_default (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
void gtk_widget_set_font_map (GtkWidget *widget,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]