[Xfce4-commits] [apps/gigolo] 17/35: Properly implement GtkApplication for unique application support

noreply at xfce.org noreply at xfce.org
Mon Oct 31 18:18:51 CET 2016


This is an automated email from the git hooks/post-receive script.

landry pushed a commit to branch master
in repository apps/gigolo.

commit ad8107c2f6a5adc572350d5e5927390979dfd9f3
Author: Landry Breuil <landry at xfce.org>
Date:   Sun Jun 19 16:24:55 2016 +0200

    Properly implement GtkApplication for unique application support
    
    -i still works to spawn a new instance
---
 src/main.c | 45 ++++++++++++++++++++++++++++++++-------------
 1 file changed, 32 insertions(+), 13 deletions(-)

diff --git a/src/main.c b/src/main.c
index 6d6150a..6bd1ef6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -35,6 +35,8 @@
 #include "window.h"
 
 
+static int gigolo_create(GtkApplication *);
+
 static gboolean show_version = FALSE;
 static gboolean list_schemes = FALSE;
 static gboolean new_instance = FALSE;
@@ -95,21 +97,25 @@ static void print_supported_schemes(void)
 	}
 }
 
-static void activate (GApplication *app, gpointer user_data)
+static int activate (GtkApplication *app, gpointer user_data)
 {
-	GtkWidget *widget;
+	GList *list;
 
-	widget = gtk_application_window_new (GTK_APPLICATION (app));
-	gtk_widget_show (widget);
+	list = gtk_application_get_windows (app);
+	if (list)
+	{
+		gtk_window_present (GTK_WINDOW (list->data));
+	}
+	else
+		return gigolo_create(app);
+	return 0;
 }
 
 gint main(gint argc, gchar** argv)
 {
-	GigoloSettings *settings;
 	GtkApplication *gis = NULL;
-	gchar *accel_filename;
+	gint status;
 	GOptionContext *context;
-	GtkWidget *window;
 
 	bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
 	bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
@@ -122,8 +128,6 @@ gint main(gint argc, gchar** argv)
 	g_option_context_parse(context, &argc, &argv, NULL);
 	g_option_context_free(context);
 
-	gtk_init(&argc, &argv);
-
 	if (show_version)
 	{
 		g_print("%s %s\n\n", PACKAGE, VERSION);
@@ -148,16 +152,31 @@ gint main(gint argc, gchar** argv)
 		return ret ? EXIT_SUCCESS : EXIT_FAILURE;
 	}
 
+	verbose("Gigolo %s (GTK+ %u.%u.%u, GLib %u.%u.%u)",
+		VERSION,
+		gtk_major_version, gtk_minor_version, gtk_micro_version,
+		glib_major_version, glib_minor_version, glib_micro_version);
+
 	if (! new_instance)
 	{
 		gis = gtk_application_new("org.xfce.gigolo", G_APPLICATION_FLAGS_NONE);
 		g_signal_connect (gis, "activate", G_CALLBACK (activate), NULL);
+		status = g_application_run (G_APPLICATION (gis), argc, argv);
+	}
+	else
+	{
+		gtk_init(&argc, &argv);
+		status = gigolo_create(NULL);
 	}
 
-	verbose("Gigolo %s (GTK+ %u.%u.%u, GLib %u.%u.%u)",
-		VERSION,
-		gtk_major_version, gtk_minor_version, gtk_micro_version,
-		glib_major_version, glib_minor_version, glib_micro_version);
+	return status;
+}
+
+static int gigolo_create(GtkApplication *gis)
+{
+	GigoloSettings *settings;
+	gchar *accel_filename;
+	GtkWidget *window;
 
 	settings = gigolo_settings_new();
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list