[balsa] Give unique_app_new a non-NULL startup-id



commit fed7a1bf7b0cc5d95e23dc6a6ed0ccad47408843
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Tue May 31 20:48:23 2011 -0400

    Give unique_app_new a non-NULL startup-id
    
    	* src/main.c (mw_message_received_cb): present compose window;
    	(main): give unique_app_new_with_commands a non-NULL startup-id,
    	because when NULL it creates a fake timestamp, which results in
    	the running window being presented.

 ChangeLog  |    7 +++++++
 src/main.c |   18 ++++++++++++++++--
 2 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e1dce0c..7e0abcf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-05-31  Peter Bloomfield
+
+	* src/main.c (mw_message_received_cb): present compose window;
+	(main): give unique_app_new_with_commands a non-NULL startup-id,
+	because when NULL it creates a fake timestamp, which results in
+	the running window being presented.
+
 2011-05-28  Pawel Salek
 
 	* libbalsa/mime.c: Correct the conditional compilation regression
diff --git a/src/main.c b/src/main.c
index f073e45..76897c4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -24,6 +24,7 @@
 #endif                          /* HAVE_CONFIG_H */
 
 #if HAVE_UNIQUE
+#include <gdk/gdkx.h>
 #include <gtk/gtk.h>
 #include <unique/unique.h>
 #endif                          /* HAVE_UNIQUE */
@@ -226,7 +227,6 @@ mw_message_received_cb(UniqueApp         *app,
     case COMMAND_COMPOSE:
         gdk_threads_enter();
         snd = sendmsg_window_compose();
-        gdk_threads_leave();
 
         uris = unique_message_data_get_uris(message);
         text = uris[0];
@@ -243,6 +243,13 @@ mw_message_received_cb(UniqueApp         *app,
         }
         g_strfreev(uris);
         snd->quit_on_close = FALSE;
+
+        window = GTK_WINDOW(snd->window);
+        gtk_window_set_screen(window,
+                              unique_message_data_get_screen(message));
+        gtk_window_present(window);
+        gdk_threads_leave();
+
         break;
     default:
         break;
@@ -953,6 +960,8 @@ main(int argc, char *argv[])
 #endif
     gchar *default_icon;
 #if HAVE_UNIQUE
+    GdkDisplay *display;
+    gchar *startup_id;
     UniqueApp *app;
 #endif                          /* HAVE_UNIQUE */
 
@@ -983,7 +992,11 @@ main(int argc, char *argv[])
      * we requested ("org.mydomain.MyApplication", in the example) or we
      * don't because there already is an application using the same name
      */
-    app = unique_app_new_with_commands("org.desktop.Balsa", NULL,
+    display = gdk_display_get_default();
+    startup_id =
+        g_strdup_printf("%s%u_TIME%lu", g_get_host_name(), (guint) getpid(),
+                        (gulong) gdk_x11_display_get_user_time(display));
+    app = unique_app_new_with_commands("org.desktop.Balsa", startup_id,
                                        "check-mail",   COMMAND_CHECK_MAIL,
                                        "get-stats",    COMMAND_GET_STATS,
                                        "open-unread",  COMMAND_OPEN_UNREAD,
@@ -991,6 +1004,7 @@ main(int argc, char *argv[])
                                        "open-mailbox", COMMAND_OPEN_MAILBOX,
                                        "compose",      COMMAND_COMPOSE,
                                        NULL);
+    g_free(startup_id);
 
     /* if there already is an instance running, this will return TRUE; there
      * is no race condition because the check is already performed at



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