[Xfce4-commits] <xfce4-panel:devel> Add running instance detection.
Nick Schermer
nick at xfce.org
Tue Aug 11 20:28:45 CEST 2009
Updating branch refs/heads/devel
to 9252e4407a0de19474992945ca85b8dd88b372a7 (commit)
from de74be2cf5f10ec91ec1fbc034ebfdeed831fe83 (commit)
commit 9252e4407a0de19474992945ca85b8dd88b372a7
Author: Nick Schermer <nick at xfce.org>
Date: Sat Mar 7 00:50:22 2009 +0100
Add running instance detection.
panel/main.c | 12 ++++++------
panel/panel-dbus-client.c | 31 +++++++++++++++++++++++--------
panel/panel-dbus-client.h | 2 +-
3 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/panel/main.c b/panel/main.c
index 192c3c3..519ce37 100644
--- a/panel/main.c
+++ b/panel/main.c
@@ -37,6 +37,7 @@
#include <glib.h>
#include <xfconf/xfconf.h>
#include <libxfce4util/libxfce4util.h>
+#include <libxfce4ui/libxfce4ui.h>
#include <panel/panel-application.h>
#include <panel/panel-dbus-service.h>
@@ -215,14 +216,13 @@ main (gint argc, gchar **argv)
goto dbus_return;
}
- else if (panel_dbus_client_check_client_running (&error))
+ else if (panel_dbus_client_check_instance_running ())
{
/* quit without error if and instance is running */
- result = !!(error == NULL);
+ result = TRUE;
/* print message */
- if (G_LIKELY (result == TRUE))
- g_message (_("There is already a running instance..."));
+ g_message (_("There is already a running instance..."));
goto dbus_return;
}
@@ -284,8 +284,8 @@ main (gint argc, gchar **argv)
if (G_UNLIKELY (error != NULL))
{
- /* print warning */
- g_critical ("Failed to send D-BUS message: %s", error ? error->message : "No error message");
+ /* show error dialog */
+ xfce_dialog_show_error (NULL, error, _("Failed to send D-Bus message"));
/* cleanup */
g_error_free (error);
diff --git a/panel/panel-dbus-client.c b/panel/panel-dbus-client.c
index d0404ba..a1a8124 100644
--- a/panel/panel-dbus-client.c
+++ b/panel/panel-dbus-client.c
@@ -45,8 +45,11 @@ panel_dbus_client_get_proxy (GError **error)
return NULL;
/* get the proxy */
- dbus_proxy = dbus_g_proxy_new_for_name (dbus_connection, PANEL_DBUS_PANEL_INTERFACE,
- PANEL_DBUS_PATH, PANEL_DBUS_PANEL_INTERFACE);
+ dbus_proxy = dbus_g_proxy_new_for_name_owner (dbus_connection,
+ PANEL_DBUS_PANEL_INTERFACE,
+ PANEL_DBUS_PATH,
+ PANEL_DBUS_PANEL_INTERFACE,
+ error);
return dbus_proxy;
}
@@ -54,11 +57,19 @@ panel_dbus_client_get_proxy (GError **error)
gboolean
-panel_dbus_client_check_client_running (GError **error)
+panel_dbus_client_check_instance_running (void)
{
- panel_return_val_if_fail (error == NULL || *error == NULL, TRUE);
+ DBusGProxy *dbus_proxy;
+
+ /* get the proxy */
+ dbus_proxy = panel_dbus_client_get_proxy (NULL);
+ if (G_UNLIKELY (dbus_proxy == NULL))
+ return FALSE;
+
+ /* cleanup */
+ g_object_unref (G_OBJECT (dbus_proxy));
- return FALSE;
+ return TRUE;
}
@@ -78,7 +89,8 @@ panel_dbus_client_display_preferences_dialog (guint active,
return FALSE;
/* call */
- result = _panel_dbus_client_display_preferences_dialog (dbus_proxy, active, error);
+ result = _panel_dbus_client_display_preferences_dialog (dbus_proxy,
+ active, error);
/* cleanup */
g_object_unref (G_OBJECT (dbus_proxy));
@@ -103,7 +115,8 @@ panel_dbus_client_display_items_dialog (guint active,
return FALSE;
/* call */
- result = _panel_dbus_client_display_items_dialog (dbus_proxy, active, error);
+ result = _panel_dbus_client_display_items_dialog (dbus_proxy, active,
+ error);
/* cleanup */
g_object_unref (G_OBJECT (dbus_proxy));
@@ -151,7 +164,9 @@ panel_dbus_client_add_new_item (const gchar *plugin_name,
return FALSE;
/* call */
- result = _panel_dbus_client_add_new_item (dbus_proxy, plugin_name, (const gchar **) arguments, error);
+ result = _panel_dbus_client_add_new_item (dbus_proxy, plugin_name,
+ (const gchar **) arguments,
+ error);
g_object_unref (G_OBJECT (dbus_proxy));
return result;
diff --git a/panel/panel-dbus-client.h b/panel/panel-dbus-client.h
index 69f9d29..82024be 100644
--- a/panel/panel-dbus-client.h
+++ b/panel/panel-dbus-client.h
@@ -23,7 +23,7 @@
#include <glib.h>
#include <gdk/gdk.h>
-gboolean panel_dbus_client_check_client_running (GError **error);
+gboolean panel_dbus_client_check_instance_running (void);
gboolean panel_dbus_client_display_preferences_dialog (guint active,
GError **error);
More information about the Xfce4-commits
mailing list