[file-roller] add a service timeout manually instead of using the IS_SERVICE flag



commit 36ee00a42934708a57c7b013314b7eb74a360324
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Tue Jun 19 20:00:56 2012 +0200

    add a service timeout manually instead of using the IS_SERVICE flag
    
    because with the IS_SERVICE flag active registration fails if the service is
    already running and this doesn't allow to open other windows from the
    command line.

 src/main.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/src/main.c b/src/main.c
index 2735c4a..a0a8402 100644
--- a/src/main.c
+++ b/src/main.c
@@ -42,6 +42,7 @@
 
 
 #define ORG_GNOME_ARCHIVEMANAGER_XML "/org/gnome/FileRoller/../data/org.gnome.ArchiveManager1.xml"
+#define SERVICE_TIMEOUT 10
 
 
 gint                ForceDirectoryCreation;
@@ -526,6 +527,14 @@ on_bus_acquired_for_archive_manager (GDBusConnection *connection,
 }
 
 
+static gboolean
+service_timeout_cb (gpointer user_data)
+{
+	g_application_release (G_APPLICATION (user_data));
+	return FALSE;
+}
+
+
 static void
 fr_application_register_archive_manager_service (FrApplication *self)
 {
@@ -533,6 +542,8 @@ fr_application_register_archive_manager_service (FrApplication *self)
 	guchar       *buffer;
 	GInputStream *stream;
 
+	g_application_hold (G_APPLICATION (self));
+
 	g_resources_get_info (ORG_GNOME_ARCHIVEMANAGER_XML, 0, &size, NULL, NULL);
 	buffer = g_new (guchar, size);
 	stream = g_resources_open_stream (ORG_GNOME_ARCHIVEMANAGER_XML, 0, NULL);
@@ -548,6 +559,8 @@ fr_application_register_archive_manager_service (FrApplication *self)
 					 self,
 					 NULL);
 
+	g_timeout_add_seconds (SERVICE_TIMEOUT, service_timeout_cb, self);
+
 	g_free (buffer);
 }
 
@@ -857,7 +870,7 @@ fr_application_new (void)
 {
         return g_object_new (fr_application_get_type (),
                              "application-id", "org.gnome.FileRoller",
-                             "flags", G_APPLICATION_IS_SERVICE,
+                             "flags", G_APPLICATION_FLAGS_NONE,
                              NULL);
 }
 



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