From 6c0c6b6a7164b77c805401ec1b0bf50d4271c918 Mon Sep 17 00:00:00 2001 From: Colin Leroy Date: Thu, 12 Aug 2004 08:37:25 +0000 Subject: [PATCH 1/1] 2004-08-12 [colin] 0.9.12cvs57.5 * sylpheed.desktop * configure.ac * src/Makefile.am * src/main.c Add support for Freedesktop.org's startup notification --- ChangeLog-gtk2.claws | 8 ++++++ PATCHSETS | 1 + configure.ac | 23 ++++++++++++++- src/Makefile.am | 6 ++-- src/main.c | 67 ++++++++++++++++++++++++++++++++++++++++++-- sylpheed.desktop | 1 + 6 files changed, 101 insertions(+), 5 deletions(-) diff --git a/ChangeLog-gtk2.claws b/ChangeLog-gtk2.claws index 28d7b4d67..8f1e6c97c 100644 --- a/ChangeLog-gtk2.claws +++ b/ChangeLog-gtk2.claws @@ -1,3 +1,11 @@ +2004-08-12 [colin] 0.9.12cvs57.5 + + * sylpheed.desktop + * configure.ac + * src/Makefile.am + * src/main.c + Add support for Freedesktop.org's startup notification + 2004-08-11 [colin] 0.9.12cvs57.4 * src/textview.c diff --git a/PATCHSETS b/PATCHSETS index 886014579..17f8d5209 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -115,3 +115,4 @@ ( cvs diff -u -r 1.15.2.6 -r 1.15.2.7 src/summary_search.c; ) > 0.9.12cvs57.2.patchset ( cvs diff -u -r 1.3.12.4 -r 1.3.12.5 src/message_search.c; cvs diff -u -r 1.15.2.7 -r 1.15.2.8 src/summary_search.c; cvs diff -u -r 1.96.2.15 -r 1.96.2.16 src/textview.c; ) > 0.9.12cvs57.3.patchset ( cvs diff -u -r 1.96.2.16 -r 1.96.2.17 src/textview.c; ) > 0.9.12cvs57.4.patchset +( cvs diff -u -r 1.7 -r 1.8 sylpheed.desktop; cvs diff -u -r 1.654.2.147 -r 1.654.2.148 configure.ac; cvs diff -u -r 1.155.2.9 -r 1.155.2.10 src/Makefile.am; cvs diff -u -r 1.115.2.14 -r 1.115.2.15 src/main.c; ) > 0.9.12cvs57.5.patchset diff --git a/configure.ac b/configure.ac index 4d03ee665..51174cd09 100644 --- a/configure.ac +++ b/configure.ac @@ -13,7 +13,7 @@ INTERFACE_AGE=0 BINARY_AGE=0 EXTRA_VERSION=57 EXTRA_RELEASE= -EXTRA_GTK2_VERSION=.4 +EXTRA_GTK2_VERSION=.5 if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}${EXTRA_RELEASE}${EXTRA_GTK2_VERSION} @@ -597,6 +597,27 @@ 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 **************************** diff --git a/src/Makefile.am b/src/Makefile.am index 1da9c7d36..6b9c713ef 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -369,7 +369,8 @@ sylpheed_LDADD = \ $(COMPFACE_LIBS) \ $(JPILOT_LIBS) \ $(PTHREAD_LIBS) \ - $(LIBICONV) + $(LIBICONV) \ + $(STARTUP_NOTIFICATION_LIBS) AM_CPPFLAGS = \ -DG_LOG_DOMAIN=\"Sylpheed\" \ @@ -381,6 +382,7 @@ AM_CPPFLAGS = \ $(ASPELL_CFLAGS) \ $(GTK_CFLAGS) \ $(GPGME_CFLAGS) \ - $(OPENSSL_CFLAGS) + $(OPENSSL_CFLAGS) \ + $(STARTUP_NOTIFICATION_CFLAGS) AM_YFLAGS = -d diff --git a/src/main.c b/src/main.c index bfa12ed34..a9cb8555b 100644 --- a/src/main.c +++ b/src/main.c @@ -37,6 +37,12 @@ #include #include +#ifdef HAVE_STARTUP_NOTIFICATION +# define SN_API_NOT_YET_FROZEN +# include +# include +#endif + #if USE_GPGME # include # 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,8 +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."); lock_socket_remove(); @@ -282,6 +340,7 @@ int main(int argc, char *argv[]) mh_gtk_init(); imap_gtk_init(); news_gtk_init(); + mainwin = main_window_create (prefs_common.sep_folder | prefs_common.sep_msg << 1); folderview = mainwin->folderview; @@ -368,6 +427,10 @@ int main(int argc, char *argv[]) plugin_load_all("GTK2"); static_mainwindow = mainwin; + +#ifdef HAVE_STARTUP_NOTIFICATION + startup_notification_complete(FALSE); +#endif gtk_main(); exit_sylpheed(mainwin); diff --git a/sylpheed.desktop b/sylpheed.desktop index d11de03f4..b70367ebc 100644 --- a/sylpheed.desktop +++ b/sylpheed.desktop @@ -8,3 +8,4 @@ Icon=sylpheed.png Terminal=0 Type=Application Categories=Application;Network; +StartupNotify=true -- 2.25.1