[gnome-color-manager] Port to GtkApplication



commit 293151906c31b32b1378d2a0a36e3dc62ed0fd3c
Author: Richard Hughes <richard hughsie com>
Date:   Thu Jun 17 18:22:09 2010 +0100

    Port to GtkApplication

 configure.ac     |    2 +-
 src/gcm-picker.c |   27 ++++++---------------------
 src/gcm-prefs.c  |   27 ++++++---------------------
 3 files changed, 13 insertions(+), 43 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 411198e..161e960 100644
--- a/configure.ac
+++ b/configure.ac
@@ -103,7 +103,7 @@ dnl - Check library dependencies
 dnl ---------------------------------------------------------------------------
 PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.14.0 gobject-2.0 gthread-2.0 gio-2.0 >= 2.25.9)
 PKG_CHECK_MODULES(XORG, xxf86vm xrandr)
-PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 2.90.0)
+PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 2.90.3)
 PKG_CHECK_MODULES(GNOMEDESKTOP, gnome-desktop-3.0 >= 2.90.0)
 PKG_CHECK_MODULES(GUDEV, gudev-1.0)
 PKG_CHECK_MODULES(LCMS, lcms)
diff --git a/src/gcm-picker.c b/src/gcm-picker.c
index a6ebab8..ba3534e 100644
--- a/src/gcm-picker.c
+++ b/src/gcm-picker.c
@@ -232,8 +232,8 @@ gcm_picker_xyz_notify_cb (GcmCalibrate *calibrate_, GParamSpec *pspec, gpointer
 static void
 gcm_picker_close_cb (GtkWidget *widget, gpointer data)
 {
-	GApplication *application = (GApplication *) data;
-	g_application_quit_with_data (application, NULL);
+	GtkApplication *application = (GtkApplication *) data;
+	gtk_application_quit (application);
 }
 
 /**
@@ -462,20 +462,6 @@ 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
@@ -484,7 +470,7 @@ main (int argc, char *argv[])
 	GOptionContext *context;
 	guint retval = 0;
 	GError *error = NULL;
-	GApplication *application;
+	GtkApplication *application;
 	GtkWidget *main_window;
 	GtkWidget *widget;
 	guint xid = 0;
@@ -521,9 +507,7 @@ main (int argc, char *argv[])
 	g_option_context_free (context);
 
 	/* ensure single instance */
-	application = g_application_new ("org.gnome.ColorManager.Picker", argc, argv);
-	g_signal_connect (application, "prepare-activation",
-			  G_CALLBACK (gcm_prefs_application_prepare_action_cb), NULL);
+	application = gtk_application_new ("org.gnome.ColorManager.Picker", &argc, &argv);
 
 	/* get UI */
 	builder = gtk_builder_new ();
@@ -535,6 +519,7 @@ main (int argc, char *argv[])
 	}
 
 	main_window = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_picker"));
+	gtk_application_add_window (application, GTK_WINDOW (main_window));
 	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), application);
@@ -610,7 +595,7 @@ main (int argc, char *argv[])
 
 	/* wait */
 	gtk_widget_show (main_window);
-	g_application_run (application);
+	gtk_application_run (application);
 
 out:
 	g_object_unref (application);
diff --git a/src/gcm-prefs.c b/src/gcm-prefs.c
index 5abd7fa..5ead7bc 100644
--- a/src/gcm-prefs.c
+++ b/src/gcm-prefs.c
@@ -129,8 +129,8 @@ gcm_prefs_error_dialog (const gchar *title, const gchar *message)
 static void
 gcm_prefs_close_cb (GtkWidget *widget, gpointer data)
 {
-	GApplication *application = (GApplication *) data;
-	g_application_quit_with_data (application, NULL);
+	GtkApplication *application = (GtkApplication *) data;
+	gtk_application_quit (application);
 }
 
 /**
@@ -3211,20 +3211,6 @@ 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
@@ -3241,7 +3227,7 @@ main (int argc, char **argv)
 	GtkWidget *info_bar_vcgt_label;
 	GtkWidget *info_bar_profiles_label;
 	GdkScreen *screen;
-	GApplication *application;
+	GtkApplication *application;
 
 	const GOptionEntry options[] = {
 		{ "parent-window", 'p', 0, G_OPTION_ARG_INT, &xid,
@@ -3266,9 +3252,7 @@ main (int argc, char **argv)
 	g_option_context_free (context);
 
 	/* ensure single instance */
-	application = g_application_new ("org.gnome.ColorManager.Prefs", argc, argv);
-	g_signal_connect (application, "prepare-activation",
-			  G_CALLBACK (gcm_prefs_application_prepare_action_cb), NULL);
+	application = gtk_application_new ("org.gnome.ColorManager.Prefs", &argc, &argv);
 
 	/* setup defaults */
 	settings = g_settings_new (GCM_SETTINGS_SCHEMA);
@@ -3347,6 +3331,7 @@ main (int argc, char **argv)
 	gtk_tree_view_set_reorderable (GTK_TREE_VIEW (widget), TRUE);
 
 	main_window = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_prefs"));
+	gtk_application_add_window (application, GTK_WINDOW (main_window));
 
 	/* Hide window first so that the dialogue resizes itself without redrawing */
 	gtk_widget_hide (main_window);
@@ -3624,7 +3609,7 @@ main (int argc, char **argv)
 	g_idle_add (gcm_prefs_startup_phase1_idle_cb, NULL);
 
 	/* wait */
-	g_application_run (application);
+	gtk_application_run (application);
 out:
 	g_object_unref (application);
 	if (current_device != NULL)



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