[gnome-power-manager] Port to GtkApplication



commit b9f9334b5f118833391ae7daa57514c61f90e261
Author: Richard Hughes <richard hughsie com>
Date:   Thu Jun 17 19:00:52 2010 +0100

    Port to GtkApplication

 configure.ac         |    6 +++---
 src/gpm-prefs.c      |   14 +++++++-------
 src/gpm-statistics.c |   29 ++++++++---------------------
 3 files changed, 18 insertions(+), 31 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 57ba838..8bef374 100644
--- a/configure.ac
+++ b/configure.ac
@@ -118,14 +118,14 @@ PKG_CHECK_MODULES(DBUS,[
  gthread-2.0])
 
 PKG_CHECK_MODULES(GNOME, [
- gtk+-3.0 >= 2.90.2
+ gtk+-3.0 >= 2.90.3
  gconf-2.0 >= 2.31.1
  gnome-keyring-1 >= 0.6.0
  cairo >= 1.0.0])
 
 PKG_CHECK_MODULES(GDK, [
- gdk-3.0 >= 2.90.2
- gdk-x11-3.0 >= 2.90.2])
+ gdk-3.0 >= 2.90.3
+ gdk-x11-3.0])
 
 PKG_CHECK_MODULES(X11, [
  xrandr >= 1.2.0
diff --git a/src/gpm-prefs.c b/src/gpm-prefs.c
index dd75cb7..a591fae 100644
--- a/src/gpm-prefs.c
+++ b/src/gpm-prefs.c
@@ -39,7 +39,7 @@
  * gpm_prefs_help_cb
  **/
 static void
-gpm_prefs_help_cb (GpmPrefs *prefs, GApplication *application)
+gpm_prefs_help_cb (GpmPrefs *prefs, GtkApplication *application)
 {
 	gpm_help_display ("preferences");
 }
@@ -48,16 +48,16 @@ gpm_prefs_help_cb (GpmPrefs *prefs, GApplication *application)
  * gpm_prefs_close_cb
  **/
 static void
-gpm_prefs_close_cb (GpmPrefs *prefs, GApplication *application)
+gpm_prefs_close_cb (GpmPrefs *prefs, GtkApplication *application)
 {
-	g_application_quit_with_data (application, NULL);
+	gtk_application_quit (application);
 }
 
 /**
  * gpm_prefs_application_prepare_action_cb:
  **/
 static void
-gpm_prefs_application_prepare_action_cb (GApplication *application, GVariant *arguments,
+gpm_prefs_application_prepare_action_cb (GtkApplication *application, GVariant *arguments,
 					 GVariant *platform_data, GpmPrefs *prefs)
 {
 	gpm_prefs_activate_window (prefs);
@@ -72,7 +72,7 @@ main (int argc, char **argv)
 	gboolean verbose = FALSE;
 	GOptionContext *context;
 	GpmPrefs *prefs = NULL;
-	GApplication *application;
+	GtkApplication *application;
 
 	const GOptionEntry options[] = {
 		{ "verbose", '\0', 0, G_OPTION_ARG_NONE, &verbose,
@@ -97,7 +97,7 @@ main (int argc, char **argv)
 	prefs = gpm_prefs_new ();
 
 	/* ensure single instance */
-	application = g_application_new ("org.gnome.PowerManager.Preferences", argc, argv);
+	application = gtk_application_new ("org.gnome.PowerManager.Preferences", &argc, &argv);
 	g_signal_connect (application, "prepare-activation",
 			  G_CALLBACK (gpm_prefs_application_prepare_action_cb), prefs);
 	g_signal_connect (prefs, "action-help",
@@ -106,7 +106,7 @@ main (int argc, char **argv)
 			  G_CALLBACK (gpm_prefs_close_cb), application);
 
 	/* run */
-	g_application_run (application);
+	gtk_application_run (application);
 
 	g_object_unref (prefs);
 	g_object_unref (application);
diff --git a/src/gpm-statistics.c b/src/gpm-statistics.c
index ae16f5e..37e13d7 100644
--- a/src/gpm-statistics.c
+++ b/src/gpm-statistics.c
@@ -1156,18 +1156,6 @@ gpm_stats_devices_treeview_clicked_cb (GtkTreeSelection *selection, gpointer use
 }
 
 /**
- * gpm_stats_application_prepare_action_cb:
- **/
-static void
-gpm_stats_application_prepare_action_cb (GApplication *application, GVariant *arguments,
-					 GVariant *platform_data, gpointer user_data)
-{
-	GtkWidget *widget;
-	widget = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_stats"));
-	gtk_window_present (GTK_WINDOW (widget));
-}
-
-/**
  * gpm_stats_add_device:
  **/
 static void
@@ -1506,9 +1494,9 @@ gpm_stats_highlight_device (const gchar *object_path)
  * gpm_stats_delete_event_cb:
  **/
 static gboolean
-gpm_stats_delete_event_cb (GtkWidget *widget, GdkEvent *event, GApplication *application)
+gpm_stats_delete_event_cb (GtkWidget *widget, GdkEvent *event, GtkApplication *application)
 {
-	g_application_quit_with_data (application, NULL);
+	gtk_application_quit (application);
 	return FALSE;
 }
 
@@ -1516,9 +1504,9 @@ gpm_stats_delete_event_cb (GtkWidget *widget, GdkEvent *event, GApplication *app
  * gpm_stats_button_close_cb:
  **/
 static void
-gpm_stats_button_close_cb (GtkWidget *widget, GApplication *application)
+gpm_stats_button_close_cb (GtkWidget *widget, GtkApplication *application)
 {
-	g_application_quit_with_data (application, NULL);
+	gtk_application_quit (application);
 }
 
 /**
@@ -1532,7 +1520,7 @@ main (int argc, char *argv[])
 	GtkBox *box;
 	GtkWidget *widget;
 	GtkTreeSelection *selection;
-	GApplication *application;
+	GtkApplication *application;
 	gboolean ret;
 	UpClient *client;
 	GPtrArray *devices;
@@ -1577,9 +1565,7 @@ main (int argc, char *argv[])
 	gtk_init (&argc, &argv);
 
 	/* are we already activated? */
-	application = g_application_new ("org.gnome.PowerManager.Statistics", argc, argv);
-	g_signal_connect (application, "prepare-activation",
-			  G_CALLBACK (gpm_stats_application_prepare_action_cb), NULL);
+	application = gtk_application_new ("org.gnome.PowerManager.Statistics", &argc, &argv);
 
 	/* add application specific icons to search path */
 	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
@@ -1611,6 +1597,7 @@ main (int argc, char *argv[])
 	gtk_widget_show (graph_statistics);
 
 	widget = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_stats"));
+	gtk_application_add_window (application, GTK_WINDOW (widget));
 	gtk_window_set_default_size (GTK_WINDOW(widget), 800, 500);
 	gtk_window_set_default_icon_name (GPM_STOCK_APP_ICON);
 
@@ -1819,7 +1806,7 @@ main (int argc, char *argv[])
 	gtk_widget_show (widget);
 
 	/* run */
-	g_application_run (application);
+	gtk_application_run (application);
 
 out:
 	g_object_unref (settings);



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