[gedit/dbus] Use proxy watch to call to existing gedit service
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/dbus] Use proxy watch to call to existing gedit service
- Date: Mon, 3 May 2010 19:40:10 +0000 (UTC)
commit c4c5b17045f8958e266047bdd452cacd91c73edd
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Mon May 3 21:38:53 2010 +0200
Use proxy watch to call to existing gedit service
gedit/gedit-dbus.c | 89 +++++++++++++++++++++++++++++----------------------
1 files changed, 51 insertions(+), 38 deletions(-)
---
diff --git a/gedit/gedit-dbus.c b/gedit/gedit-dbus.c
index b3c0d0e..0b96a58 100644
--- a/gedit/gedit-dbus.c
+++ b/gedit/gedit-dbus.c
@@ -298,47 +298,17 @@ on_open_proxy_signal (GDBusProxy *proxy,
}
}
-static GeditDBusResult
-handle_slave (GeditDBus *dbus)
+static void
+command_line_proxy_appeared (GDBusConnection *connection,
+ const gchar *name,
+ const gchar *owner_name,
+ GDBusProxy *proxy,
+ GeditDBus *dbus)
{
- /* send the requested commands to the master */
- GDBusConnection *conn;
- GDBusProxy *proxy;
- GDBusInvokeMethodFlags flags;
GeditCommandLine *command_line;
- conn = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
-
- if (conn == NULL)
- {
- return GEDIT_DBUS_RESULT_FAILED;
- }
-
command_line = gedit_command_line_get_default ();
- flags = G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES;
-
- if (!gedit_command_line_get_wait (command_line))
- {
- flags |= G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS;
- }
-
- proxy = g_dbus_proxy_new_sync (conn,
- G_TYPE_DBUS_PROXY,
- flags,
- NULL,
- "org.gnome.gedit",
- "/org/gnome/gedit",
- "org.gnome.gedit.CommandLine",
- NULL,
- NULL);
-
- if (proxy == NULL)
- {
- g_object_unref (conn);
- return GEDIT_DBUS_RESULT_FAILED;
- }
-
if (gedit_command_line_get_wait (command_line))
{
g_signal_connect (proxy,
@@ -355,13 +325,56 @@ handle_slave (GeditDBus *dbus)
NULL,
(GAsyncReadyCallback)slave_open_ready_cb,
dbus);
+}
- g_object_unref (proxy);
- g_object_unref (conn);
+static void
+command_line_proxy_vanished (GDBusConnection *connection,
+ const gchar *name,
+ GeditDBus *dbus)
+{
+ dbus->priv->result = GEDIT_DBUS_RESULT_FAILED;
+ g_main_loop_quit (dbus->priv->main_loop);
+}
+
+static GeditDBusResult
+handle_slave (GeditDBus *dbus)
+{
+ /* send the requested commands to the master */
+ GDBusConnection *conn;
+ GDBusInvokeMethodFlags flags;
+ GeditCommandLine *command_line;
+
+ conn = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+
+ if (conn == NULL)
+ {
+ return GEDIT_DBUS_RESULT_FAILED;
+ }
+
+ flags = G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES;
+ command_line = gedit_command_line_get_default ();
+
+ if (!gedit_command_line_get_wait (command_line))
+ {
+ flags |= G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS;
+ }
+
+ g_bus_watch_proxy (G_BUS_TYPE_SESSION,
+ "org.gnome.gedit",
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ "/org/gnome/gedit",
+ "org.gnome.gedit.CommandLine",
+ G_TYPE_DBUS_PROXY,
+ flags,
+ (GBusProxyAppearedCallback)command_line_proxy_appeared,
+ (GBusProxyVanishedCallback)command_line_proxy_vanished,
+ dbus,
+ NULL);
dbus->priv->main_loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (dbus->priv->main_loop);
+ g_object_unref (conn);
g_main_loop_unref (dbus->priv->main_loop);
return dbus->priv->result;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]