[gnome-color-manager] Port to GApplication
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] Port to GApplication
- Date: Tue, 8 Jun 2010 09:40:00 +0000 (UTC)
commit 0f6ac2bc70e67ea5a62f65ce0ffd95f1feb22089
Author: Richard Hughes <richard hughsie com>
Date: Tue Jun 8 10:39:52 2010 +0100
Port to GApplication
configure.ac | 4 +--
contrib/gnome-color-manager.spec.in | 3 +-
src/Makefile.am | 5 ---
src/gcm-picker.c | 62 +++++++++++++-------------------
src/gcm-prefs.c | 66 ++++++++++++++--------------------
5 files changed, 54 insertions(+), 86 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index f5303e0..fd06c29 100644
--- a/configure.ac
+++ b/configure.ac
@@ -104,10 +104,9 @@ dnl ---------------------------------------------------------------------------
GLIB_REQUIRED=2.14.0
GTK_REQUIRED=2.14.0
GNOMEDESKTOP_REQUIRED=2.14.0
-UNIQUE_REQUIRED=1.0.0
VTE_REQUIRED=0.25.1
CANBERRA_REQUIRED=0.10
-GIO_REQUIRED=2.25.1
+GIO_REQUIRED=2.25.8
dnl ---------------------------------------------------------------------------
dnl - Check library dependencies
@@ -116,7 +115,6 @@ PKG_CHECK_MODULES(GLIB, glib-2.0 >= $GLIB_REQUIRED gobject-2.0 gthread-2.0 gio-2
PKG_CHECK_MODULES(XORG, xxf86vm xrandr)
PKG_CHECK_MODULES(GTK, gtk+-2.0 >= $GTK_REQUIRED)
PKG_CHECK_MODULES(GNOMEDESKTOP, gnome-desktop-2.0 >= $GNOMEDESKTOP_REQUIRED)
-PKG_CHECK_MODULES(UNIQUE, unique-1.0 >= $UNIQUE_REQUIRED)
PKG_CHECK_MODULES(VTE, vte >= $VTE_REQUIRED)
PKG_CHECK_MODULES(GUDEV, gudev-1.0)
PKG_CHECK_MODULES(LCMS, lcms)
diff --git a/contrib/gnome-color-manager.spec.in b/contrib/gnome-color-manager.spec.in
index c7620fe..37e44bb 100644
--- a/contrib/gnome-color-manager.spec.in
+++ b/contrib/gnome-color-manager.spec.in
@@ -29,7 +29,6 @@ BuildRequires: gettext
BuildRequires: libtool
BuildRequires: vte-devel
BuildRequires: gnome-doc-utils
-BuildRequires: unique-devel >= 1.0.0
BuildRequires: intltool
BuildRequires: libgudev1-devel
BuildRequires: libXxf86vm-devel
@@ -43,7 +42,7 @@ BuildRequires: libexif-devel
BuildRequires: exiv2-devel
BuildRequires: libcanberra-devel
BuildRequires: libnotify-devel
-BuildRequires: glib2-devel >= 2.25.1
+BuildRequires: glib2-devel >= 2.25.8
%description
gnome-color-manager is a session framework that makes it easy to manage, install
diff --git a/src/Makefile.am b/src/Makefile.am
index 9484ff9..3c06daf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,7 +3,6 @@ INCLUDES = \
$(X11_CFLAGS) \
$(GTK_CFLAGS) \
$(GNOMEDESKTOP_CFLAGS) \
- $(UNIQUE_CFLAGS) \
$(VTE_CFLAGS) \
$(LCMS_CFLAGS) \
$(XORG_CFLAGS) \
@@ -252,7 +251,6 @@ gcm_prefs_LDADD = \
$(GLIB_LIBS) \
$(X11_LIBS) \
$(GNOMEDESKTOP_LIBS) \
- $(UNIQUE_LIBS) \
$(VTE_LIBS) \
$(GUDEV_LIBS) \
$(LCMS_LIBS) \
@@ -276,7 +274,6 @@ gcm_picker_LDADD = \
$(GLIB_LIBS) \
$(X11_LIBS) \
$(GNOMEDESKTOP_LIBS) \
- $(UNIQUE_LIBS) \
$(VTE_LIBS) \
$(GUDEV_LIBS) \
$(LCMS_LIBS) \
@@ -300,7 +297,6 @@ gcm_session_LDADD = \
$(GLIB_LIBS) \
$(X11_LIBS) \
$(GNOMEDESKTOP_LIBS) \
- $(UNIQUE_LIBS) \
$(GUDEV_LIBS) \
$(LCMS_LIBS) \
$(XORG_LIBS) \
@@ -329,7 +325,6 @@ gcm_self_test_LDADD = \
$(GLIB_LIBS) \
$(X11_LIBS) \
$(GNOMEDESKTOP_LIBS) \
- $(UNIQUE_LIBS) \
$(GUDEV_LIBS) \
$(LCMS_LIBS) \
$(XORG_LIBS) \
diff --git a/src/gcm-picker.c b/src/gcm-picker.c
index 4274283..50be184 100644
--- a/src/gcm-picker.c
+++ b/src/gcm-picker.c
@@ -28,7 +28,6 @@
#include <gio/gio.h>
#include <locale.h>
#include <gtk/gtk.h>
-#include <unique/unique.h>
#include <lcms.h>
#include "egg-debug.h"
@@ -233,8 +232,8 @@ gcm_picker_xyz_notify_cb (GcmCalibrate *calibrate_, GParamSpec *pspec, gpointer
static void
gcm_picker_close_cb (GtkWidget *widget, gpointer data)
{
- GMainLoop *loop = (GMainLoop *) data;
- g_main_loop_quit (loop);
+ GApplication *application = (GApplication *) data;
+ g_application_quit (application, 0);
}
/**
@@ -298,20 +297,6 @@ gcm_picker_colorimeter_changed_cb (GcmColorimeter *colorimeter, gpointer user_da
}
/**
- * gcm_picker_message_received_cb
- **/
-static UniqueResponse
-gcm_picker_message_received_cb (UniqueApp *app, UniqueCommand command, UniqueMessageData *message_data, guint time_ms, gpointer data)
-{
- GtkWindow *window;
- if (command == UNIQUE_ACTIVATE) {
- window = GTK_WINDOW (gtk_builder_get_object (builder, "dialog_picker"));
- gtk_window_present (window);
- }
- return UNIQUE_RESPONSE_OK;
-}
-
-/**
* gcm_window_set_parent_xid:
**/
static void
@@ -477,6 +462,20 @@ gcm_prefs_setup_space_combobox (GtkWidget *widget)
}
/**
+ * gcm_prefs_application_prepare_action_cb:
+ **/
+static void
+gcm_prefs_application_prepare_action_cb (GApplication *application, GVariant *arguments,
+ GVariant *platform_data, gpointer user_data)
+{
+ GtkWindow *window;
+
+ egg_debug ("application prepare action");
+ window = GTK_WINDOW (gtk_builder_get_object (builder, "dialog_picker"));
+ gtk_window_present (window);
+}
+
+/**
* main:
**/
int
@@ -485,10 +484,9 @@ main (int argc, char *argv[])
GOptionContext *context;
guint retval = 0;
GError *error = NULL;
- GMainLoop *loop;
+ GApplication *application;
GtkWidget *main_window;
GtkWidget *widget;
- UniqueApp *unique_app;
guint xid = 0;
GcmColorimeter *colorimeter = NULL;
@@ -522,19 +520,10 @@ main (int argc, char *argv[])
g_option_context_parse (context, &argc, &argv, NULL);
g_option_context_free (context);
- /* block in a loop */
- loop = g_main_loop_new (NULL, FALSE);
-
-
- /* are we already activated? */
- unique_app = unique_app_new ("org.gnome.ColorManager.Picker", NULL);
- if (unique_app_is_running (unique_app)) {
- egg_debug ("You have another instance running. This program will now close");
- unique_app_send_message (unique_app, UNIQUE_ACTIVATE, NULL);
- goto out;
- }
- g_signal_connect (unique_app, "message-received",
- G_CALLBACK (gcm_picker_message_received_cb), NULL);
+ /* ensure single instance */
+ application = g_application_new_and_register ("org.gnome.ColorManager.Picker", argc, argv);
+ g_signal_connect (application, "prepare-activation",
+ G_CALLBACK (gcm_prefs_application_prepare_action_cb), NULL);
/* get UI */
builder = gtk_builder_new ();
@@ -548,11 +537,11 @@ main (int argc, char *argv[])
main_window = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_picker"));
gtk_window_set_icon_name (GTK_WINDOW (main_window), GCM_STOCK_ICON);
g_signal_connect (main_window, "delete_event",
- G_CALLBACK (gcm_picker_delete_event_cb), loop);
+ G_CALLBACK (gcm_picker_delete_event_cb), application);
widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_close"));
g_signal_connect (widget, "clicked",
- G_CALLBACK (gcm_picker_close_cb), loop);
+ G_CALLBACK (gcm_picker_close_cb), application);
widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_help"));
g_signal_connect (widget, "clicked",
@@ -621,10 +610,10 @@ main (int argc, char *argv[])
/* wait */
gtk_widget_show (main_window);
- g_main_loop_run (loop);
+ g_application_run (application);
out:
- g_object_unref (unique_app);
+ g_object_unref (application);
if (profile_store != NULL)
g_object_unref (profile_store);
if (colorimeter != NULL)
@@ -633,7 +622,6 @@ out:
g_object_unref (calibrate);
if (builder != NULL)
g_object_unref (builder);
- g_main_loop_unref (loop);
return retval;
}
diff --git a/src/gcm-prefs.c b/src/gcm-prefs.c
index 3fb9546..fbc4fb0 100644
--- a/src/gcm-prefs.c
+++ b/src/gcm-prefs.c
@@ -24,7 +24,6 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <math.h>
-#include <unique/unique.h>
#include <glib/gstdio.h>
#include <gudev/gudev.h>
#include <libgnomeui/gnome-rr.h>
@@ -129,8 +128,8 @@ gcm_prefs_error_dialog (const gchar *title, const gchar *message)
static void
gcm_prefs_close_cb (GtkWidget *widget, gpointer data)
{
- GMainLoop *loop = (GMainLoop *) data;
- g_main_loop_quit (loop);
+ GApplication *application = (GApplication *) data;
+ g_application_quit (application, 0);
}
/**
@@ -1449,20 +1448,6 @@ gcm_prefs_reset_cb (GtkWidget *widget, gpointer data)
}
/**
- * gcm_prefs_message_received_cb
- **/
-static UniqueResponse
-gcm_prefs_message_received_cb (UniqueApp *app, UniqueCommand command, UniqueMessageData *message_data, guint time_ms, gpointer data)
-{
- GtkWindow *window;
- if (command == UNIQUE_ACTIVATE) {
- window = GTK_WINDOW (gtk_builder_get_object (builder, "dialog_prefs"));
- gtk_window_present (window);
- }
- return UNIQUE_RESPONSE_OK;
-}
-
-/**
* gcm_window_set_parent_xid:
**/
static void
@@ -3116,6 +3101,20 @@ gcm_prefs_button_virtual_entry_changed_cb (GtkEntry *entry, GParamSpec *pspec, g
}
/**
+ * gcm_prefs_application_prepare_action_cb:
+ **/
+static void
+gcm_prefs_application_prepare_action_cb (GApplication *application, GVariant *arguments,
+ GVariant *platform_data, gpointer user_data)
+{
+ GtkWindow *window;
+
+ egg_debug ("application prepare action");
+ window = GTK_WINDOW (gtk_builder_get_object (builder, "dialog_prefs"));
+ gtk_window_present (window);
+}
+
+/**
* main:
**/
int
@@ -3125,15 +3124,14 @@ main (int argc, char **argv)
GOptionContext *context;
GtkWidget *main_window;
GtkWidget *widget;
- UniqueApp *unique_app;
guint xid = 0;
GError *error = NULL;
- GMainLoop *loop;
GtkTreeSelection *selection;
GtkWidget *info_bar_loading_label;
GtkWidget *info_bar_vcgt_label;
GtkWidget *info_bar_profiles_label;
GdkScreen *screen;
+ GApplication *application;
const GOptionEntry options[] = {
{ "parent-window", 'p', 0, G_OPTION_ARG_INT, &xid,
@@ -3157,18 +3155,10 @@ main (int argc, char **argv)
g_option_context_parse (context, &argc, &argv, NULL);
g_option_context_free (context);
- /* block in a loop */
- loop = g_main_loop_new (NULL, FALSE);
-
- /* are we already activated? */
- unique_app = unique_app_new ("org.gnome.ColorManager.Prefs", NULL);
- if (unique_app_is_running (unique_app)) {
- egg_debug ("You have another instance running. This program will now close");
- unique_app_send_message (unique_app, UNIQUE_ACTIVATE, NULL);
- goto out;
- }
- g_signal_connect (unique_app, "message-received",
- G_CALLBACK (gcm_prefs_message_received_cb), NULL);
+ /* ensure single instance */
+ application = g_application_new_and_register ("org.gnome.ColorManager.Prefs", argc, argv);
+ g_signal_connect (application, "prepare-activation",
+ G_CALLBACK (gcm_prefs_application_prepare_action_cb), NULL);
/* get UI */
builder = gtk_builder_new ();
@@ -3249,17 +3239,17 @@ main (int argc, char **argv)
gtk_widget_hide (main_window);
gtk_window_set_icon_name (GTK_WINDOW (main_window), GCM_STOCK_ICON);
g_signal_connect (main_window, "delete_event",
- G_CALLBACK (gcm_prefs_delete_event_cb), loop);
+ G_CALLBACK (gcm_prefs_delete_event_cb), application);
g_signal_connect (main_window, "drag-data-received",
- G_CALLBACK (gcm_prefs_drag_data_received_cb), loop);
+ G_CALLBACK (gcm_prefs_drag_data_received_cb), application);
gcm_prefs_setup_drag_and_drop (GTK_WIDGET(main_window));
widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_close"));
g_signal_connect (widget, "clicked",
- G_CALLBACK (gcm_prefs_close_cb), loop);
+ G_CALLBACK (gcm_prefs_close_cb), application);
widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_default"));
g_signal_connect (widget, "clicked",
- G_CALLBACK (gcm_prefs_default_cb), loop);
+ G_CALLBACK (gcm_prefs_default_cb), application);
widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_help"));
g_signal_connect (widget, "clicked",
G_CALLBACK (gcm_prefs_help_cb), NULL);
@@ -3506,11 +3496,9 @@ main (int argc, char **argv)
g_idle_add (gcm_prefs_startup_phase1_idle_cb, NULL);
/* wait */
- g_main_loop_run (loop);
-
+ g_application_run (application);
out:
- g_object_unref (unique_app);
- g_main_loop_unref (loop);
+ g_object_unref (application);
if (current_device != NULL)
g_object_unref (current_device);
if (colorimeter != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]