gnome-media r4182 - in trunk: . gnome-volume-control gnome-volume-control/src
- From: hadess svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-media r4182 - in trunk: . gnome-volume-control gnome-volume-control/src
- Date: Wed, 11 Feb 2009 10:56:51 +0000 (UTC)
Author: hadess
Date: Wed Feb 11 10:56:51 2009
New Revision: 4182
URL: http://svn.gnome.org/viewvc/gnome-media?rev=4182&view=rev
Log:
2009-02-11 Bastien Nocera <hadess hadess net>
* configure.ac: Require libunique for the new
volume control, and don't use dbus-glib directly
2009-02-11 Bastien Nocera <hadess hadess net>
* src/applet-main.c (main): Use libunique instead of D-Bus
and refuse to run if an applet is already running
* src/dialog-main.c (message_received_cb), (on_control_ready),
(main): present the application when it's already running
(Closes: #542727)
Modified:
trunk/ChangeLog
trunk/configure.ac
trunk/gnome-volume-control/ChangeLog
trunk/gnome-volume-control/src/applet-main.c
trunk/gnome-volume-control/src/dialog-main.c
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Wed Feb 11 10:56:51 2009
@@ -59,7 +59,6 @@
dnl Start of pkg-config checks - common libs
dnl=======================================================================
-DBUS_GLIB_REQUIRED_VERSION=0.74
GLIB_REQUIRED_VERSION=2.18.2
GTK_REQUIRED_VERSION=2.10.0
LIBGLADE_REQUIRED_VERSION=1.99.2
@@ -91,12 +90,12 @@
GTK_REQUIRED_VERSION=2.15.1
PKG_CHECK_MODULES(VOLUME_CONTROL,
- dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION
gobject-2.0 >= $GLIB_REQUIRED_VERSION
gtk+-2.0 >= $GTK_REQUIRED_VERSION
gio-2.0
gconf-2.0 >= $GCONF_REQUIRED_VERSION
libcanberra-gtk >= $CANBERRA_REQUIRED_VERSION
+ unique-1.0
libxml-2.0
)
AC_SUBST(VOLUME_CONTROL_CFLAGS)
Modified: trunk/gnome-volume-control/src/applet-main.c
==============================================================================
--- trunk/gnome-volume-control/src/applet-main.c (original)
+++ trunk/gnome-volume-control/src/applet-main.c Wed Feb 11 10:56:51 2009
@@ -29,11 +29,7 @@
#include <glib/gi18n.h>
#include <glib/goption.h>
#include <gtk/gtk.h>
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-bindings.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include <unique/uniqueapp.h>
#include "gvc-applet.h"
@@ -44,112 +40,12 @@
static gboolean show_version = FALSE;
static gboolean debug = FALSE;
-static void
-on_bus_name_lost (DBusGProxy *bus_proxy,
- const char *name,
- gpointer data)
-{
- g_warning ("Lost name on bus: %s, exiting", name);
- exit (1);
-}
-
-static gboolean
-acquire_name_on_proxy (DBusGProxy *bus_proxy,
- const char *name)
-{
- GError *error;
- guint result;
- gboolean res;
- gboolean ret;
-
- ret = FALSE;
-
- if (bus_proxy == NULL) {
- goto out;
- }
-
- error = NULL;
- res = dbus_g_proxy_call (bus_proxy,
- "RequestName",
- &error,
- G_TYPE_STRING, name,
- G_TYPE_UINT, 0,
- G_TYPE_INVALID,
- G_TYPE_UINT, &result,
- G_TYPE_INVALID);
- if (! res) {
- if (error != NULL) {
- g_warning ("Failed to acquire %s: %s", name, error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to acquire %s", name);
- }
- goto out;
- }
-
- if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
- if (error != NULL) {
- g_warning ("Failed to acquire %s: %s", name, error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to acquire %s", name);
- }
- goto out;
- }
-
- /* register for name lost */
- dbus_g_proxy_add_signal (bus_proxy,
- "NameLost",
- G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (bus_proxy,
- "NameLost",
- G_CALLBACK (on_bus_name_lost),
- NULL,
- NULL);
-
-
- ret = TRUE;
-
- out:
- return ret;
-}
-
-static gboolean
-acquire_name (void)
-{
- DBusGProxy *bus_proxy;
- GError *error;
- DBusGConnection *connection;
-
- error = NULL;
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (connection == NULL) {
- g_warning ("Could not connect to session bus: %s",
- error->message);
- exit (1);
- }
-
- bus_proxy = dbus_g_proxy_new_for_name (connection,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS);
-
- if (! acquire_name_on_proxy (bus_proxy, GVCA_DBUS_NAME) ) {
- g_warning ("Could not acquire name on session bus");
- exit (1);
- }
-
- g_object_unref (bus_proxy);
-
- return TRUE;
-}
-
int
main (int argc, char **argv)
{
GError *error;
GvcApplet *applet;
+ UniqueApp *app;
static GOptionEntry entries[] = {
{ "debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Enable debugging code"), NULL },
{ "version", 0, 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL },
@@ -175,7 +71,11 @@
exit (1);
}
- acquire_name ();
+ app = unique_app_new (GVCA_DBUS_NAME, NULL);
+ if (unique_app_is_running (app)) {
+ g_warning ("Applet is already running, exiting");
+ return 0;
+ }
gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
ICON_DATA_DIR);
Modified: trunk/gnome-volume-control/src/dialog-main.c
==============================================================================
--- trunk/gnome-volume-control/src/dialog-main.c (original)
+++ trunk/gnome-volume-control/src/dialog-main.c Wed Feb 11 10:56:51 2009
@@ -29,11 +29,7 @@
#include <glib/gi18n.h>
#include <glib/goption.h>
#include <gtk/gtk.h>
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-bindings.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include <unique/uniqueapp.h>
#include "gvc-mixer-dialog.h"
@@ -46,107 +42,6 @@
static gchar* page = NULL;
static void
-on_bus_name_lost (DBusGProxy *bus_proxy,
- const char *name,
- gpointer data)
-{
- g_warning ("Lost name on bus: %s, exiting", name);
- exit (1);
-}
-
-static gboolean
-acquire_name_on_proxy (DBusGProxy *bus_proxy,
- const char *name)
-{
- GError *error;
- guint result;
- gboolean res;
- gboolean ret;
-
- ret = FALSE;
-
- if (bus_proxy == NULL) {
- goto out;
- }
-
- error = NULL;
- res = dbus_g_proxy_call (bus_proxy,
- "RequestName",
- &error,
- G_TYPE_STRING, name,
- G_TYPE_UINT, 0,
- G_TYPE_INVALID,
- G_TYPE_UINT, &result,
- G_TYPE_INVALID);
- if (! res) {
- if (error != NULL) {
- g_warning ("Failed to acquire %s: %s", name, error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to acquire %s", name);
- }
- goto out;
- }
-
- if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
- if (error != NULL) {
- g_warning ("Failed to acquire %s: %s", name, error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to acquire %s", name);
- }
- goto out;
- }
-
- /* register for name lost */
- dbus_g_proxy_add_signal (bus_proxy,
- "NameLost",
- G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (bus_proxy,
- "NameLost",
- G_CALLBACK (on_bus_name_lost),
- NULL,
- NULL);
-
-
- ret = TRUE;
-
- out:
- return ret;
-}
-
-static gboolean
-acquire_name (void)
-{
- DBusGProxy *bus_proxy;
- GError *error;
- DBusGConnection *connection;
-
- error = NULL;
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (connection == NULL) {
- g_warning ("Could not connect to session bus: %s",
- error->message);
- exit (1);
- }
-
- bus_proxy = dbus_g_proxy_new_for_name (connection,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS);
-
- if (! acquire_name_on_proxy (bus_proxy, GVCA_DBUS_NAME) ) {
- g_warning ("Could not acquire name on session bus");
- exit (1);
- }
-
- g_object_unref (bus_proxy);
-
- return TRUE;
-}
-
-static void
on_dialog_response (GtkDialog *dialog,
guint response_id,
gpointer data)
@@ -156,14 +51,26 @@
static void
on_dialog_close (GtkDialog *dialog,
- gpointer data)
+ gpointer data)
{
gtk_main_quit ();
}
+static UniqueResponse
+message_received_cb (UniqueApp *app,
+ int command,
+ UniqueMessageData *message_data,
+ guint time_,
+ gpointer user_data)
+{
+ gtk_window_present (GTK_WINDOW (user_data));
+
+ return UNIQUE_RESPONSE_OK;
+}
+
static void
on_control_ready (GvcMixerControl *control,
- gpointer data)
+ UniqueApp *app)
{
GvcMixerDialog *dialog;
@@ -180,6 +87,9 @@
if (page != NULL)
gvc_mixer_dialog_set_page(dialog, page);
+ g_signal_connect (app, "message-received",
+ G_CALLBACK (message_received_cb), dialog);
+
gtk_widget_show (GTK_WIDGET (dialog));
}
@@ -188,6 +98,7 @@
{
GError *error;
GvcMixerControl *control;
+ UniqueApp *app;
static GOptionEntry entries[] = {
{ "page", 'p', 0, G_OPTION_ARG_STRING, &page, N_("Startup page"), "playback|recording|effects|applications" },
{ "debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Enable debugging code"), NULL },
@@ -214,7 +125,11 @@
exit (1);
}
- acquire_name ();
+ app = unique_app_new (GVCA_DBUS_NAME, NULL);
+ if (unique_app_is_running (app)) {
+ unique_app_send_message (app, UNIQUE_ACTIVATE, NULL);
+ exit (0);
+ }
gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
ICON_DATA_DIR);
@@ -223,7 +138,7 @@
g_signal_connect (control,
"ready",
G_CALLBACK (on_control_ready),
- control);
+ app);
gvc_mixer_control_open (control);
/* FIXME: add timeout in case ready doesn't happen */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]