2004-08-12 [colin] 0.9.12cvs58
authorColin Leroy <colin@colino.net>
Thu, 12 Aug 2004 09:36:15 +0000 (09:36 +0000)
committerColin Leroy <colin@colino.net>
Thu, 12 Aug 2004 09:36:15 +0000 (09:36 +0000)
* configure.ac
* sylpheed.desktop
* src/Makefile.am
* src/main.c
Add support for Freedesktop.org's startup notification

ChangeLog.claws
PATCHSETS
configure.ac
src/Makefile.am
src/main.c
sylpheed.desktop

index c8b53e9..37fc0af 100644 (file)
@@ -1,3 +1,11 @@
+2004-08-12 [colin]     0.9.12cvs58
+
+       * configure.ac
+       * sylpheed.desktop
+       * src/Makefile.am
+       * src/main.c
+               Add support for Freedesktop.org's startup notification
+
 2004-08-10 [colin]     0.9.12cvs57
 
        * src/main.c
index 4fe1fcc..0037e64 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
@@ -39,3 +39,4 @@
 ( cvs diff -u -r 1.139 -r 1.140 src/main.c; cvs diff -u -r 1.13 -r 1.14 src/common/ssl.c; cvs diff -u -r 1.7 -r 1.8 src/common/sylpheed.c; cvs diff -u -r 1.5 -r 1.6 src/common/sylpheed.h; ) > 0.9.12cvs55.patchset
 ( cvs diff -u -r 1.140 -r 1.141 src/main.c; cvs diff -u -r 1.14 -r 1.15 src/common/ssl.c; cvs diff -u -r 1.8 -r 1.9 src/common/sylpheed.c; cvs diff -u -r 1.6 -r 1.7 src/common/sylpheed.h; ) > 0.9.12cvs56.patchset
 ( cvs diff -u -r 1.141 -r 1.142 src/main.c; cvs diff -u -r 1.14 -r 1.15 src/common/socket.c; cvs diff -u -r 1.15 -r 1.16 src/common/ssl.c; cvs diff -u -r 1.9 -r 1.10 src/common/sylpheed.c; cvs diff -u -r 1.7 -r 1.8 src/common/sylpheed.h; ) > 0.9.12cvs57.patchset
+( cvs diff -u -r 1.1117 -r 1.1118 configure.ac; cvs diff -u -r 1.7 -r 1.8 sylpheed.desktop; cvs diff -u -r 1.185 -r 1.186 src/Makefile.am; cvs diff -u -r 1.142 -r 1.143 src/main.c; ) > 0.9.12cvs58.patchset
index 79c8a5b..09003a6 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=12
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=57
+EXTRA_VERSION=58
 EXTRA_RELEASE=
 
 if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
@@ -576,6 +576,28 @@ fi
 AC_SUBST(CLAMAV_LIBS)
 AM_CONDITIONAL(BUILD_CLAMAV_PLUGIN, test x"$ac_cv_enable_clamav_plugin" = xyes)
 
+dnl #######################################################################
+dnl # Check for startup notification
+dnl #######################################################################
+AC_ARG_ENABLE(startup-notification, [  --disable-startup-notification    compile without startup notification support],,enable_startup_notification=yes)
+
+if test "x$enable_startup_notification" = "xyes"; then
+       PKG_CHECK_MODULES(STARTUP_NOTIFICATION, libstartup-notification-1.0 >= 0.5,
+       [
+               AC_DEFINE(HAVE_STARTUP_NOTIFICATION, 1, [Define if we're using libstartup-notification.])
+               echo "Building with libstartup-notification"
+               enable_startup_notification=yes
+       ],
+       [
+               echo "Building without libstartup-notification"
+               enable_startup_notification=no
+       ])
+
+       AC_SUBST(STARTUP_NOTIFICATION_CFLAGS)
+       AC_SUBST(STARTUP_NOTIFICATION_LIBS)
+fi
+
+
 dnl ****************************
 dnl ** Final configure output **
 dnl ****************************
index 7eafec7..26992e5 100644 (file)
@@ -373,7 +373,8 @@ sylpheed_LDADD = \
        $(COMPFACE_LIBS) \
        $(JPILOT_LIBS) \
        $(PTHREAD_LIBS) \
-       $(LIBICONV)
+       $(LIBICONV) \
+       $(STARTUP_NOTIFICATION_LIBS)
 
 AM_CPPFLAGS = \
        -DG_LOG_DOMAIN=\"Sylpheed\" \
@@ -385,6 +386,7 @@ AM_CPPFLAGS = \
        $(ASPELL_CFLAGS) \
        $(GTK_CFLAGS) \
        $(GPGME_CFLAGS) \
-       $(OPENSSL_CFLAGS)
+       $(OPENSSL_CFLAGS) \
+       $(STARTUP_NOTIFICATION_CFLAGS)
 
 AM_YFLAGS = -d
index c353840..428078e 100644 (file)
 #include <sys/types.h>
 #include <signal.h>
 
+#ifdef HAVE_STARTUP_NOTIFICATION
+# define SN_API_NOT_YET_FROZEN
+# include <libsn/sn-launchee.h>
+# include <gdk/gdkx.h>
+#endif
+
 #if USE_GPGME
 #  include <gpgme.h>
 #  include "passphrase.h"
@@ -93,6 +99,11 @@ gchar *prog_version;
 gchar *argv0;
 #endif
 
+#ifdef HAVE_STARTUP_NOTIFICATION
+static SnLauncheeContext *sn_context = NULL;
+static SnDisplay *sn_display = NULL;
+#endif
+
 static gint lock_socket = -1;
 static gint lock_socket_tag = 0;
 
@@ -165,6 +176,48 @@ _("File `%s' already exists.\n"
 
 static MainWindow *static_mainwindow;
 
+#ifdef HAVE_STARTUP_NOTIFICATION
+static void sn_error_trap_push(SnDisplay *display, Display *xdisplay)
+{
+       gdk_error_trap_push();
+}
+
+static void sn_error_trap_pop(SnDisplay *display, Display *xdisplay)
+{
+       gdk_error_trap_pop();
+}
+
+static void startup_notification_complete(gboolean with_window)
+{
+       Display *xdisplay;
+       GtkWidget *hack = NULL;
+
+       if (with_window) {
+               /* this is needed to make the startup notification leave,
+                * if we have been launched from a menu.
+                * We have to display a window, so let it be very little */
+               hack = gtk_window_new(GTK_WINDOW_POPUP);
+               gtk_widget_set_uposition(hack, 0, 0);
+               gtk_widget_set_usize(hack, 1, 1);
+               gtk_widget_show(hack);
+       }
+
+       xdisplay = GDK_DISPLAY();
+       sn_display = sn_display_new(xdisplay,
+                               sn_error_trap_push,
+                               sn_error_trap_pop);
+       sn_context = sn_launchee_context_new_from_environment(sn_display,
+                                                DefaultScreen(xdisplay));
+
+       if (sn_context != NULL)
+       {
+               sn_launchee_context_complete(sn_context);
+               sn_launchee_context_unref(sn_context);
+               sn_display_unref(sn_display);
+       }
+}
+#endif /* HAVE_STARTUP_NOTIFICATION */
+
 void sylpheed_gtk_idle(void) 
 {
        while(gtk_events_pending())
@@ -201,7 +254,13 @@ int main(int argc, char *argv[])
 
        /* check and create unix domain socket */
        lock_socket = prohibit_duplicate_launch();
-       if (lock_socket < 0) return 0;
+       if (lock_socket < 0) {
+#ifdef HAVE_STARTUP_NOTIFICATION
+               if(gtk_init_check(&argc, &argv))
+                       startup_notification_complete(TRUE);
+#endif
+               return 0;
+       }
 
        if (cmd.status || cmd.status_full) {
                puts("0 Sylpheed not running.");
@@ -364,6 +423,10 @@ int main(int argc, char *argv[])
        plugin_load_all("GTK");
        
        static_mainwindow = mainwin;
+
+#ifdef HAVE_STARTUP_NOTIFICATION
+       startup_notification_complete(FALSE);
+#endif 
        gtk_main();
 
        exit_sylpheed(mainwin);
index d11de03..b70367e 100644 (file)
@@ -8,3 +8,4 @@ Icon=sylpheed.png
 Terminal=0
 Type=Application
 Categories=Application;Network;
+StartupNotify=true