[glib/wip/menus-rebase2] GApplication: Implement query_action



commit ca9ed17b923eb83a8bc90801c4421ad321e39a7e
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Nov 25 22:52:36 2011 -0500

    GApplication: Implement query_action

 gio/gapplication.c |  106 +++++++++++++---------------------------------------
 1 files changed, 26 insertions(+), 80 deletions(-)
---
diff --git a/gio/gapplication.c b/gio/gapplication.c
index 092c919..ee7ccbd 100644
--- a/gio/gapplication.c
+++ b/gio/gapplication.c
@@ -1396,21 +1396,6 @@ g_application_run (GApplication  *application,
   return status;
 }
 
-static gboolean
-g_application_has_action (GActionGroup *action_group,
-                          const gchar  *action_name)
-{
-  GApplication *application = G_APPLICATION (action_group);
-
-  g_return_val_if_fail (application->priv->is_registered, FALSE);
-
-  if (application->priv->remote_actions != NULL)
-    return g_action_group_has_action (application->priv->remote_actions, action_name);
-
-  return application->priv->actions &&
-         g_action_group_has_action (application->priv->actions, action_name);
-}
-
 static gchar **
 g_application_list_actions (GActionGroup *action_group)
 {
@@ -1430,71 +1415,37 @@ g_application_list_actions (GActionGroup *action_group)
 }
 
 static gboolean
-g_application_get_action_enabled (GActionGroup *action_group,
-                                  const gchar  *action_name)
+g_application_query_action (GActionGroup        *group,
+                            const gchar         *action_name,
+                            gboolean            *enabled,
+                            const GVariantType **parameter_type,
+                            const GVariantType **state_type,
+                            GVariant           **state_hint,
+                            GVariant           **state)
 {
-  GApplication *application = G_APPLICATION (action_group);
+  GApplication *application = G_APPLICATION (group);
 
-  g_return_val_if_fail (application->priv->remote_actions != NULL ||
-                        application->priv->actions != NULL, FALSE);
   g_return_val_if_fail (application->priv->is_registered, FALSE);
 
-  if (application->priv->remote_actions)
-    return g_action_group_get_action_enabled (application->priv->remote_actions, action_name);
-
-  return g_action_group_get_action_enabled (application->priv->actions,
-                                            action_name);
-}
-
-static const GVariantType *
-g_application_get_action_parameter_type (GActionGroup *action_group,
-                                         const gchar  *action_name)
-{
-  GApplication *application = G_APPLICATION (action_group);
-
-  g_return_val_if_fail (application->priv->remote_actions != NULL ||
-                        application->priv->actions != NULL, NULL);
-  g_return_val_if_fail (application->priv->is_registered, NULL);
-
-  if (application->priv->remote_actions)
-    return g_action_group_get_action_parameter_type (application->priv->remote_actions, action_name);
-
-  return g_action_group_get_action_parameter_type (application->priv->actions,
-                                                   action_name);
-}
-
-static const GVariantType *
-g_application_get_action_state_type (GActionGroup *action_group,
-                                     const gchar  *action_name)
-{
-  GApplication *application = G_APPLICATION (action_group);
-
-  g_return_val_if_fail (application->priv->remote_actions != NULL ||
-                        application->priv->actions != NULL, NULL);
-  g_return_val_if_fail (application->priv->is_registered, NULL);
-
-  if (application->priv->remote_actions)
-    return g_action_group_get_action_state_type (application->priv->remote_actions, action_name);
-
-  return g_action_group_get_action_state_type (application->priv->actions,
-                                               action_name);
-}
-
-static GVariant *
-g_application_get_action_state (GActionGroup *action_group,
-                                const gchar  *action_name)
-{
-  GApplication *application = G_APPLICATION (action_group);
-
-  g_return_val_if_fail (application->priv->remote_actions != NULL ||
-                        application->priv->actions != NULL, NULL);
-  g_return_val_if_fail (application->priv->is_registered, NULL);
+  if (application->priv->remote_actions != NULL)
+    return g_action_group_query_action (application->priv->remote_actions,
+                                        action_name,
+                                        enabled,
+                                        parameter_type,
+                                        state_type,
+                                        state_hint,
+                                        state);
 
-  if (application->priv->remote_actions)
-    return g_action_group_get_action_state (application->priv->remote_actions, action_name);
+  if (application->priv->actions != NULL)
+    return g_action_group_query_action (application->priv->actions,
+                                        action_name,
+                                        enabled,
+                                        parameter_type,
+                                        state_type,
+                                        state_hint,
+                                        state);
 
-  return g_action_group_get_action_state (application->priv->actions,
-                                          action_name);
+  return FALSE;
 }
 
 static void
@@ -1538,13 +1489,8 @@ g_application_activate_action (GActionGroup *action_group,
 static void
 g_application_action_group_iface_init (GActionGroupInterface *iface)
 {
-  iface->has_action = g_application_has_action;
   iface->list_actions = g_application_list_actions;
-
-  iface->get_action_enabled = g_application_get_action_enabled;
-  iface->get_action_parameter_type = g_application_get_action_parameter_type;
-  iface->get_action_state_type = g_application_get_action_state_type;
-  iface->get_action_state = g_application_get_action_state;
+  iface->query_action = g_application_query_action;
   iface->change_action_state = g_application_change_action_state;
   iface->activate_action = g_application_activate_action;
 }



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