From 8e9458ad22e9acc86cb22b0cf477682c4f7abba0 Mon Sep 17 00:00:00 2001 From: Colin Leroy Date: Tue, 5 Nov 2002 15:55:32 +0000 Subject: [PATCH] * src/compose.[ch] add compose_draft() * src/crash.c add SIGTERM handler * src/main.[ch] add clean_quit() for the SIGTERM handler --- ChangeLog.claws | 9 +++++++++ configure.in | 2 +- src/compose.c | 5 +++++ src/compose.h | 1 + src/crash.c | 14 ++++++++++++++ src/main.c | 24 ++++++++++++++++++++++++ src/main.h | 1 + 7 files changed, 55 insertions(+), 1 deletion(-) diff --git a/ChangeLog.claws b/ChangeLog.claws index b485e5848..7b7d75443 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,12 @@ +2002-11-05 [colin] 0.8.5claws74 + + * src/compose.[ch] + add compose_draft() + * src/crash.c + add SIGTERM handler + * src/main.[ch] + add clean_quit() for the SIGTERM handler + 2002-11-05 [paul] 0.8.5claws73 * po/es.po diff --git a/configure.in b/configure.in index 3972f38ed..2fc71d2c2 100644 --- a/configure.in +++ b/configure.in @@ -11,7 +11,7 @@ MINOR_VERSION=8 MICRO_VERSION=5 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=claws73 +EXTRA_VERSION=claws74 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION dnl set $target diff --git a/src/compose.c b/src/compose.c index 6430d8f43..58c1bc9e5 100644 --- a/src/compose.c +++ b/src/compose.c @@ -6269,6 +6269,11 @@ static void compose_send_later_cb(gpointer data, guint action, if (!val) gtk_widget_destroy(compose->window); } +void compose_draft (gpointer data) +{ + compose_draft_cb(data, 0, NULL); +} + static void compose_draft_cb(gpointer data, guint action, GtkWidget *widget) { Compose *compose = (Compose *)data; diff --git a/src/compose.h b/src/compose.h index b1c289823..57dc9ec96 100644 --- a/src/compose.h +++ b/src/compose.h @@ -271,5 +271,6 @@ void compose_reflect_prefs_all (void); void compose_reflect_prefs_pixmap_theme (void); void compose_destroy_all (void); +void compose_draft (gpointer data); #endif /* __COMPOSE_H__ */ diff --git a/src/crash.c b/src/crash.c index 8efa1b5ab..56181c848 100644 --- a/src/crash.c +++ b/src/crash.c @@ -41,6 +41,9 @@ # include #endif +#ifdef SIGTERM +#include "main.h" +#endif #include "intl.h" #include "crash.h" #include "utils.h" @@ -115,6 +118,11 @@ void crash_install_handlers(void) sigaddset(&mask, SIGABRT); #endif +#ifdef SIGTERM + signal(SIGTERM, crash_handler); + sigaddset(&mask, SIGTERM); +#endif + sigprocmask(SIG_UNBLOCK, &mask, 0); #endif /* CRASH_DIALOG */ } @@ -503,6 +511,12 @@ static void crash_handler(int sig) crashed_++; +#ifdef SIGTERM + if(sig == SIGTERM) { + clean_quit(); + } +#endif + /* * gnome ungrabs focus, and flushes gdk. mmmh, good idea. */ diff --git a/src/main.c b/src/main.c index 14f7c573b..610f84692 100644 --- a/src/main.c +++ b/src/main.c @@ -158,6 +158,7 @@ _("File `%s' already exists.\n" } \ } +static MainWindow *static_mainwindow; int main(int argc, char *argv[]) { gchar *userrc; @@ -370,6 +371,7 @@ int main(int argc, char *argv[]) if (cmd.online_mode == ONLINE_MODE_ONLINE) main_window_toggle_work_offline(mainwin, FALSE); + static_mainwindow = mainwin; gtk_main(); addressbook_destroy(); @@ -505,6 +507,28 @@ static void initial_processing(FolderItem *item, gpointer data) main_window_cursor_normal(mainwin); } +void clean_quit(void) +{ + GList * compose_list = compose_get_compose_list(); + GList * elem = NULL; + if(compose_list) { + for (elem = compose_list; elem != NULL && elem->data != NULL; elem = elem->next) { + Compose *c = (Compose*)elem->data; + compose_draft(c); + } + } + if (prefs_common.warn_queued_on_exit) + { /* disable the popup */ + prefs_common.warn_queued_on_exit = FALSE; + app_will_exit(NULL, static_mainwindow); + prefs_common.warn_queued_on_exit = TRUE; + prefs_common_save_config(); + } else { + app_will_exit(NULL, static_mainwindow); + } + exit(0); +} + void app_will_exit(GtkWidget *widget, gpointer data) { MainWindow *mainwin = data; diff --git a/src/main.h b/src/main.h index 0fb8c56f0..3e07b17e3 100644 --- a/src/main.h +++ b/src/main.h @@ -28,5 +28,6 @@ extern gchar *startup_dir; extern gboolean debug_mode; void app_will_exit (GtkWidget *widget, gpointer data); +void clean_quit (void); #endif /* __MAIN_H__ */ -- 2.25.1