[gtk/matthiasc-for-master: 2/11] action muxer: Add some convenience api



commit db7f0189dd7fa93096a865487ce77a73854da441
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jun 14 13:41:45 2019 -0400

    action muxer: Add some convenience api
    
    Instead of duplicating this code in multiple places,
    add an api to look up an action group for a prefixed
    name, and return the unprefixed name at the same time.

 gtk/gtkactionmuxer.c        | 13 +++++++++++++
 gtk/gtkactionmuxerprivate.h |  3 +++
 2 files changed, 16 insertions(+)
---
diff --git a/gtk/gtkactionmuxer.c b/gtk/gtkactionmuxer.c
index 72edec793b..d2e58b5dd4 100644
--- a/gtk/gtkactionmuxer.c
+++ b/gtk/gtkactionmuxer.c
@@ -166,6 +166,18 @@ gtk_action_muxer_find_group (GtkActionMuxer  *muxer,
   return group;
 }
 
+GActionGroup *
+gtk_action_muxer_find (GtkActionMuxer  *muxer,
+                       const char      *action_name,
+                       const char     **unprefixed_name)
+{
+  Group *group;
+
+  group = gtk_action_muxer_find_group (muxer, action_name, unprefixed_name);
+
+  return group->group;
+}
+
 static void
 gtk_action_muxer_action_enabled_changed (GtkActionMuxer *muxer,
                                          const gchar    *action_name,
@@ -959,3 +971,4 @@ gtk_normalise_detailed_action_name (const gchar *detailed_action_name)
 
   return action_and_target;
 }
+
diff --git a/gtk/gtkactionmuxerprivate.h b/gtk/gtkactionmuxerprivate.h
index b696fff29e..2eea5483c6 100644
--- a/gtk/gtkactionmuxerprivate.h
+++ b/gtk/gtkactionmuxerprivate.h
@@ -44,6 +44,9 @@ void                    gtk_action_muxer_remove                         (GtkActi
 const gchar **          gtk_action_muxer_list_prefixes                  (GtkActionMuxer *muxer);
 GActionGroup *          gtk_action_muxer_lookup                         (GtkActionMuxer *muxer,
                                                                          const gchar    *prefix);
+GActionGroup *          gtk_action_muxer_find                           (GtkActionMuxer *muxer,
+                                                                         const char     *action_name,
+                                                                         const char    **unprefixed_name);
 GtkActionMuxer *        gtk_action_muxer_get_parent                     (GtkActionMuxer *muxer);
 
 void                    gtk_action_muxer_set_parent                     (GtkActionMuxer *muxer,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]