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



commit 195ada8cd8c775951da3101f7017f2c1dc7ab665
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Nov 25 22:44:47 2011 -0500

    GDBusActionGroup: Implement query_action

 gio/gdbusactiongroup.c |  101 +++++++++--------------------------------------
 1 files changed, 20 insertions(+), 81 deletions(-)
---
diff --git a/gio/gdbusactiongroup.c b/gio/gdbusactiongroup.c
index 46180f3..bb05ebe 100644
--- a/gio/gdbusactiongroup.c
+++ b/gio/gdbusactiongroup.c
@@ -152,66 +152,13 @@ g_dbus_action_group_list_actions (GActionGroup *g_group)
 }
 
 static gboolean
-g_dbus_action_group_has_action (GActionGroup *g_group,
-                                const gchar  *action_name)
-{
-  GDBusActionGroup *group = G_DBUS_ACTION_GROUP (g_group);
-  gboolean has;
-
-  has = g_hash_table_lookup (group->actions, action_name) != NULL;
-
-  if (!has)
-    group->strict = TRUE;
-
-  return has;
-}
-
-static const GVariantType *
-g_dbus_action_group_get_parameter_type (GActionGroup *g_group,
-                                        const gchar  *action_name)
-{
-  GDBusActionGroup *group = G_DBUS_ACTION_GROUP (g_group);
-  ActionInfo *info;
-
-  info = g_hash_table_lookup (group->actions, action_name);
-
-  if (info == NULL)
-    {
-      group->strict = TRUE;
-      return NULL;
-    }
-
-  return info->parameter_type;
-}
-
-static const GVariantType *
-g_dbus_action_group_get_state_type (GActionGroup *g_group,
-                                    const gchar  *action_name)
-{
-  GDBusActionGroup *group = G_DBUS_ACTION_GROUP (g_group);
-  ActionInfo *info;
-
-  info = g_hash_table_lookup (group->actions, action_name);
-
-  if (info == NULL)
-    {
-      group->strict = TRUE;
-      return NULL;
-    }
-
-  return info->state ? g_variant_get_type (info->state) : NULL;
-}
-
-static GVariant *
-g_dbus_action_group_get_state_hint (GActionGroup *g_group,
-                                    const gchar  *action_name)
-{
-  return NULL;
-}
-
-static gboolean
-g_dbus_action_group_get_enabled (GActionGroup *g_group,
-                                 const gchar  *action_name)
+g_dbus_action_group_query_action (GActionGroup        *g_group,
+                                  const gchar         *action_name,
+                                  gboolean            *enabled,
+                                  const GVariantType **parameter_type,
+                                  const GVariantType **state_type,
+                                  GVariant           **state_hint,
+                                  GVariant           **state)
 {
   GDBusActionGroup *group = G_DBUS_ACTION_GROUP (g_group);
   ActionInfo *info;
@@ -224,25 +171,22 @@ g_dbus_action_group_get_enabled (GActionGroup *g_group,
       return FALSE;
     }
 
-  return info->enabled;
-}
+  if (enabled)
+    *enabled = info->enabled;
 
-static GVariant *
-g_dbus_action_group_get_state (GActionGroup *g_group,
-                               const gchar  *action_name)
-{
-  GDBusActionGroup *group = G_DBUS_ACTION_GROUP (g_group);
-  ActionInfo *info;
+  if (parameter_type)
+    *parameter_type = info->parameter_type;
 
-  info = g_hash_table_lookup (group->actions, action_name);
+  if (state_type)
+    *state_type = info->state ? g_variant_get_type (info->state) : NULL;
 
-  if (info == NULL)
-    {
-      group->strict = TRUE;
-      return NULL;
-    }
+  if (state_hint)
+    *state_hint = NULL;
+
+  if (state)
+    *state = g_variant_ref (info->state);
 
-  return info->state ? g_variant_ref (info->state) : NULL;
+  return TRUE;
 }
 
 static void
@@ -309,12 +253,7 @@ static void
 g_dbus_action_group_iface_init (GActionGroupInterface *iface)
 {
   iface->list_actions = g_dbus_action_group_list_actions;
-  iface->has_action = g_dbus_action_group_has_action;
-  iface->get_action_parameter_type = g_dbus_action_group_get_parameter_type;
-  iface->get_action_state_type = g_dbus_action_group_get_state_type;
-  iface->get_action_state_hint = g_dbus_action_group_get_state_hint;
-  iface->get_action_enabled = g_dbus_action_group_get_enabled;
-  iface->get_action_state = g_dbus_action_group_get_state;
+  iface->query_action = g_dbus_action_group_query_action;
   iface->change_action_state = g_dbus_action_group_change_state;
   iface->activate_action = g_dbus_action_group_activate;
 }



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