X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Fgdbusactiongroup.c;h=57454edd589f0d43913cd69c60edfc8e7636af46;hb=356a3987cee7ceddcb3fe623edf0bd2881895add;hp=e7c94631306701095b00b26e95e6bee0337098c1;hpb=f109415d950edae973ca630046deb7aebf3c8ddd;p=platform%2Fupstream%2Fglib.git
diff --git a/gio/gdbusactiongroup.c b/gio/gdbusactiongroup.c
index e7c9463..57454ed 100644
--- a/gio/gdbusactiongroup.c
+++ b/gio/gdbusactiongroup.c
@@ -13,17 +13,16 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see .
*
* Authors: Ryan Lortie
*/
#include "config.h"
-#include "gdbusactiongroup.h"
+#include "gdbusactiongroup-private.h"
+#include "gremoteactiongroup.h"
#include "gdbusconnection.h"
#include "gactiongroup.h"
@@ -31,7 +30,8 @@
* SECTION:gdbusactiongroup
* @title: GDBusActionGroup
* @short_description: A D-Bus GActionGroup implementation
- * @see_also: GActionGroup exporter
+ * @include: gio/gio.h
+ * @see_also: [GActionGroup exporter][gio-GActionGroup-exporter]
*
* #GDBusActionGroup is an implementation of the #GActionGroup
* interface that can be used as a proxy for an action group
@@ -91,7 +91,7 @@ action_info_free (gpointer user_data)
g_slice_free (ActionInfo, info);
}
-ActionInfo *
+static ActionInfo *
action_info_new_from_iter (GVariantIter *iter)
{
const gchar *param_str;
@@ -100,7 +100,7 @@ action_info_new_from_iter (GVariantIter *iter)
GVariant *state;
gchar *name;
- if (!g_variant_iter_next (iter, "{s(bg@av)}", &name,
+ if (!g_variant_iter_next (iter, "{s(b&g@av)}", &name,
&enabled, ¶m_str, &state))
return NULL;
@@ -122,9 +122,11 @@ action_info_new_from_iter (GVariantIter *iter)
return info;
}
-static void g_dbus_action_group_iface_init (GActionGroupInterface *);
+static void g_dbus_action_group_remote_iface_init (GRemoteActionGroupInterface *iface);
+static void g_dbus_action_group_iface_init (GActionGroupInterface *iface);
G_DEFINE_TYPE_WITH_CODE (GDBusActionGroup, g_dbus_action_group, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_GROUP, g_dbus_action_group_iface_init))
+ G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_GROUP, g_dbus_action_group_iface_init)
+ G_IMPLEMENT_INTERFACE (G_TYPE_REMOTE_ACTION_GROUP, g_dbus_action_group_remote_iface_init))
static void
g_dbus_action_group_changed (GDBusConnection *connection,
@@ -229,6 +231,7 @@ g_dbus_action_group_changed (GDBusConnection *connection,
else
action_info_free (info);
}
+ g_variant_iter_free (iter);
}
}
}
@@ -264,6 +267,8 @@ g_dbus_action_group_describe_all_done (GObject *source,
g_variant_iter_free (iter);
g_variant_unref (reply);
}
+
+ g_object_unref (group);
}
@@ -279,7 +284,7 @@ g_dbus_action_group_async_init (GDBusActionGroup *group)
g_dbus_connection_call (group->connection, group->bus_name, group->object_path, "org.gtk.Actions", "DescribeAll", NULL,
G_VARIANT_TYPE ("(a{s(bgav)})"), G_DBUS_CALL_FLAGS_NONE, -1, NULL,
- g_dbus_action_group_describe_all_done, group);
+ g_dbus_action_group_describe_all_done, g_object_ref (group));
}
static gchar **
@@ -356,30 +361,19 @@ g_dbus_action_group_query_action (GActionGroup *g_group,
else
{
g_dbus_action_group_async_init (group);
+ group->strict = TRUE;
return FALSE;
}
}
static void
-g_dbus_action_group_change_state (GActionGroup *g_group,
- const gchar *action_name,
- GVariant *value)
-{
- GDBusActionGroup *group = G_DBUS_ACTION_GROUP (g_group);
-
- /* Don't bother with the checks. The other side will do it again. */
- g_dbus_connection_call (group->connection, group->bus_name, group->object_path, "org.gtk.Actions", "SetState",
- g_variant_new ("(sva{sv})", action_name, value, NULL),
- NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
-}
-
-static void
-g_dbus_action_group_activate (GActionGroup *g_group,
- const gchar *action_name,
- GVariant *parameter)
+g_dbus_action_group_activate_action_full (GRemoteActionGroup *remote,
+ const gchar *action_name,
+ GVariant *parameter,
+ GVariant *platform_data)
{
- GDBusActionGroup *group = G_DBUS_ACTION_GROUP (g_group);
+ GDBusActionGroup *group = G_DBUS_ACTION_GROUP (remote);
GVariantBuilder builder;
g_variant_builder_init (&builder, G_VARIANT_TYPE ("av"));
@@ -388,11 +382,42 @@ g_dbus_action_group_activate (GActionGroup *g_group,
g_variant_builder_add (&builder, "v", parameter);
g_dbus_connection_call (group->connection, group->bus_name, group->object_path, "org.gtk.Actions", "Activate",
- g_variant_new ("(sava{sv})", action_name, &builder, NULL),
+ g_variant_new ("(sav@a{sv})", action_name, &builder, platform_data),
NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
}
static void
+g_dbus_action_group_change_action_state_full (GRemoteActionGroup *remote,
+ const gchar *action_name,
+ GVariant *value,
+ GVariant *platform_data)
+{
+ GDBusActionGroup *group = G_DBUS_ACTION_GROUP (remote);
+
+ g_dbus_connection_call (group->connection, group->bus_name, group->object_path, "org.gtk.Actions", "SetState",
+ g_variant_new ("(sv@a{sv})", action_name, value, platform_data),
+ NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
+}
+
+static void
+g_dbus_action_group_change_state (GActionGroup *group,
+ const gchar *action_name,
+ GVariant *value)
+{
+ g_dbus_action_group_change_action_state_full (G_REMOTE_ACTION_GROUP (group),
+ action_name, value, g_variant_new ("a{sv}", NULL));
+}
+
+static void
+g_dbus_action_group_activate (GActionGroup *group,
+ const gchar *action_name,
+ GVariant *parameter)
+{
+ g_dbus_action_group_activate_action_full (G_REMOTE_ACTION_GROUP (group),
+ action_name, parameter, g_variant_new ("a{sv}", NULL));
+}
+
+static void
g_dbus_action_group_finalize (GObject *object)
{
GDBusActionGroup *group = G_DBUS_ACTION_GROUP (object);
@@ -425,6 +450,13 @@ g_dbus_action_group_class_init (GDBusActionGroupClass *class)
}
static void
+g_dbus_action_group_remote_iface_init (GRemoteActionGroupInterface *iface)
+{
+ iface->activate_action_full = g_dbus_action_group_activate_action_full;
+ iface->change_action_state_full = g_dbus_action_group_change_action_state_full;
+}
+
+static void
g_dbus_action_group_iface_init (GActionGroupInterface *iface)
{
iface->list_actions = g_dbus_action_group_list_actions;
@@ -439,7 +471,7 @@ g_dbus_action_group_iface_init (GActionGroupInterface *iface)
* @bus_name: the bus name which exports the action group
* @object_path: the object path at which the action group is exported
*
- * Obtains a #GDBusAcitonGroup for the action group which is exported at
+ * Obtains a #GDBusActionGroup for the action group which is exported at
* the given @bus_name and @object_path.
*
* The thread default main context is taken at the time of this call.
@@ -472,7 +504,7 @@ g_dbus_action_group_get (GDBusConnection *connection,
return group;
}
-G_GNUC_INTERNAL gboolean
+gboolean
g_dbus_action_group_sync (GDBusActionGroup *group,
GCancellable *cancellable,
GError **error)
@@ -494,6 +526,9 @@ g_dbus_action_group_sync (GDBusActionGroup *group,
GVariantIter *iter;
ActionInfo *action;
+ g_assert (group->actions == NULL);
+ group->actions = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, action_info_free);
+
g_variant_get (reply, "(a{s(bgav)})", &iter);
while ((action = action_info_new_from_iter (iter)))
g_hash_table_insert (group->actions, action->name, action);