gnome-bluetooth r375 - in trunk: . applet common properties wizard



Author: hadess
Date: Thu Feb 26 18:19:50 2009
New Revision: 375
URL: http://svn.gnome.org/viewvc/gnome-bluetooth?rev=375&view=rev

Log:
Remove use of BluetoothInstance and use libunique

Less code, less worries for us.

Removed:
   trunk/common/bluetooth-instance.c
   trunk/common/bluetooth-instance.h
   trunk/common/bluetooth-instance.xml
Modified:
   trunk/applet/main.c
   trunk/common/Makefile.am
   trunk/configure.ac
   trunk/properties/main.c
   trunk/wizard/main.c

Modified: trunk/applet/main.c
==============================================================================
--- trunk/applet/main.c	(original)
+++ trunk/applet/main.c	Thu Feb 26 18:19:50 2009
@@ -30,8 +30,8 @@
 #include <gtk/gtk.h>
 
 #include <gconf/gconf-client.h>
+#include <unique/uniqueapp.h>
 
-#include <bluetooth-instance.h>
 #include <bluetooth-client.h>
 #include <bluetooth-chooser.h>
 
@@ -407,7 +407,7 @@
 
 int main(int argc, char *argv[])
 {
-	BluetoothInstance *instance;
+	UniqueApp *app;
 	GtkStatusIcon *statusicon;
 	GtkWidget *menu;
 	GError *error = NULL;
@@ -428,9 +428,11 @@
 		return 1;
 	}
 
-	instance = bluetooth_instance_new("applet");
-	if (instance == NULL)
+	app = unique_app_new ("org.gnome.Bluetooth.applet", NULL);
+	if (unique_app_is_running (app)) {
+		g_warning ("Applet is already running, exiting");
 		return 0;
+	}
 
 	g_set_application_name(_("Bluetooth Applet"));
 
@@ -498,7 +500,7 @@
 
 	g_object_unref(client);
 
-	g_object_unref(instance);
+	g_object_unref (app);
 
 	return 0;
 }

Modified: trunk/common/Makefile.am
==============================================================================
--- trunk/common/Makefile.am	(original)
+++ trunk/common/Makefile.am	Thu Feb 26 18:19:50 2009
@@ -3,7 +3,6 @@
 lib_LTLIBRARIES = libgnome-bluetooth.la
 
 libcommon_la_SOURCES = helper.h helper.c \
-		bluetooth-instance.h bluetooth-instance.c \
 		bluetooth-client.h bluetooth-client.c \
 		bluetooth-agent.h bluetooth-agent.c \
 		obex-agent.h obex-agent.c \
@@ -37,7 +36,6 @@
 AM_CFLAGS = -I$(srcdir) $(LIBGNOMEBT_CFLAGS) $(WARN_CFLAGS) $(DISABLE_DEPRECATED)
 
 BUILT_SOURCES = marshal.h marshal.c \
-		bluetooth-instance-glue.h \
 		bluetooth-client-glue.h \
 		bluetooth-agent-glue.h \
 		obex-agent-glue.h
@@ -55,7 +53,6 @@
 test_deviceselection_LDADD = libgnome-bluetooth.la
 
 EXTRA_DIST = marshal.list \
-		bluetooth-instance.xml \
 		bluetooth-client.xml \
 		bluetooth-agent.xml \
 		obex-agent.xml
@@ -68,9 +65,6 @@
 marshal.c: marshal.list
 	$(GLIB_GENMARSHAL) --prefix=marshal $< --header --body > $@
 
-bluetooth-instance-glue.h: bluetooth-instance.xml
-	$(DBUS_BINDING_TOOL) --prefix=bluetooth_instance --mode=glib-server --output=$@ $<
-
 bluetooth-client-glue.h: bluetooth-client.xml
 	$(DBUS_BINDING_TOOL) --prefix=bluetooth_client --mode=glib-client --output=$@ $<
 

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Thu Feb 26 18:19:50 2009
@@ -70,14 +70,16 @@
 		  dbus-glib-1 >= $DBUS_GLIB_REQUIRED
 		  hal >= $HAL_REQUIRED
 		  gconf-2.0
-		  gtk+-2.0)
+		  gtk+-2.0
+		  unique-1.0)
 
 dnl Requires for the applet
 PKG_CHECK_MODULES(APPLET,
 		  dbus-glib-1 >= $DBUS_GLIB_REQUIRED
 		  gconf-2.0
 		  gtk+-2.0
-		  libnotify >= $NOTIFY_REQUIRED)
+		  libnotify >= $NOTIFY_REQUIRED
+		  unique-1.0)
 
 dnl Requires for the sendto app
 PKG_CHECK_MODULES(SENDTO,
@@ -88,7 +90,8 @@
 dnl Requires for the wizard dialogue
 PKG_CHECK_MODULES(WIZARD,
 		  dbus-glib-1 >= $DBUS_GLIB_REQUIRED
-		  gtk+-2.0)
+		  gtk+-2.0
+		  unique-1.0)
 
 dnl Requires for the libraries
 PKG_CHECK_MODULES(LIBGNOMEBT,

Modified: trunk/properties/main.c
==============================================================================
--- trunk/properties/main.c	(original)
+++ trunk/properties/main.c	Thu Feb 26 18:19:50 2009
@@ -28,8 +28,7 @@
 
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
-
-#include <bluetooth-instance.h>
+#include <unique/uniqueapp.h>
 
 #include "general.h"
 #include "adapter.h"
@@ -100,13 +99,25 @@
 	return window;
 }
 
+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 GOptionEntry options[] = {
 	{ NULL },
 };
 
 int main(int argc, char *argv[])
 {
-	BluetoothInstance *instance;
+	UniqueApp *app;
 	GtkWidget *window;
 	GtkWidget *notebook;
 	GError *error = NULL;
@@ -126,9 +137,11 @@
 		return 1;
 	}
 
-	instance = bluetooth_instance_new("properties");
-	if (instance == NULL)
+	app = unique_app_new ("org.gnome.Bluetooth.properties", NULL);
+	if (unique_app_is_running (app)) {
+		unique_app_send_message (app, UNIQUE_ACTIVATE, NULL);
 		return 0;
+	}
 
 	g_set_application_name(_("Bluetooth Properties"));
 
@@ -142,7 +155,8 @@
 
 	window = create_window(notebook);
 
-	bluetooth_instance_set_window(instance, GTK_WINDOW(window));
+	g_signal_connect (app, "message-received",
+			  G_CALLBACK (message_received_cb), window);
 
 	gtk_main();
 
@@ -150,7 +164,7 @@
 
 	cleanup_general();
 
-	g_object_unref(instance);
+	g_object_unref(app);
 
 	return 0;
 }

Modified: trunk/wizard/main.c
==============================================================================
--- trunk/wizard/main.c	(original)
+++ trunk/wizard/main.c	Thu Feb 26 18:19:50 2009
@@ -30,8 +30,8 @@
 #include <gdk/gdkkeysyms.h>
 
 #include <dbus/dbus-glib.h>
+#include <unique/uniqueapp.h>
 
-#include <bluetooth-instance.h>
 #include <bluetooth-client.h>
 #include <bluetooth-agent.h>
 
@@ -725,13 +725,25 @@
 	return assistant;
 }
 
+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 GOptionEntry options[] = {
 	{ NULL },
 };
 
 int main(int argc, char *argv[])
 {
-	BluetoothInstance *instance;
+	UniqueApp *app;
 	GtkWidget *window;
 	GError *error = NULL;
 
@@ -750,9 +762,11 @@
 		return 1;
 	}
 
-	instance = bluetooth_instance_new("wizard");
-	if (instance == NULL)
+	app = unique_app_new ("org.gnome.Bluetooth.wizard", NULL);
+	if (unique_app_is_running (app)) {
+		unique_app_send_message (app, UNIQUE_ACTIVATE, NULL);
 		return 0;
+	}
 
 	gtk_window_set_default_icon_name("bluetooth");
 
@@ -771,7 +785,8 @@
 	window = create_wizard();
 	window_assistant = window;
 
-	bluetooth_instance_set_window(instance, GTK_WINDOW(window));
+	g_signal_connect (app, "message-received",
+			  G_CALLBACK (message_received_cb), window);
 
 	gtk_main();
 
@@ -779,7 +794,7 @@
 
 	g_object_unref(client);
 
-	g_object_unref(instance);
+	g_object_unref(app);
 
 	return 0;
 }



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