2005-05-30 [paul] 1.0.4cvs14
[claws.git] / src / prefs_actions.c
index e85273a6ff5fa0eeb665aa3823d12cd74c5cfe0f..833e6ff1de466440e9f129694f76b5a0a1334a5d 100644 (file)
@@ -43,6 +43,7 @@
 #include "prefs_actions.h"
 #include "action.h"
 #include "description_window.h"
+#include "gtkutils.h"
 
 static struct Actions
 {
@@ -56,6 +57,8 @@ static struct Actions
        GtkWidget *actions_clist;
 } actions;
 
+static int modified = FALSE;
+
 /* widget creating functions */
 static void prefs_actions_create       (MainWindow *mainwin);
 static void prefs_actions_set_dialog   (void);
@@ -491,6 +494,7 @@ static gint prefs_actions_clist_set_row(gint row)
 static void prefs_actions_register_cb(GtkWidget *w, gpointer data)
 {
        prefs_actions_clist_set_row(-1);
+       modified = FALSE;
 }
 
 static void prefs_actions_substitute_cb(GtkWidget *w, gpointer data)
@@ -508,6 +512,7 @@ static void prefs_actions_substitute_cb(GtkWidget *w, gpointer data)
        if (!action) return;
 
        prefs_actions_clist_set_row(row);
+       modified = FALSE;
 }
 
 static void prefs_actions_delete_cb(GtkWidget *w, gpointer data)
@@ -608,10 +613,24 @@ static void prefs_actions_key_pressed(GtkWidget *widget, GdkEventKey *event,
 {
        if (event && event->keyval == GDK_Escape)
                prefs_actions_cancel(widget, data);
+       else {
+               GtkWidget *focused = gtkut_get_focused_child(
+                                       GTK_CONTAINER(widget));
+               if (focused && GTK_IS_EDITABLE(focused)) {
+                       modified = TRUE;
+               }
+       }
+       return;
 }
 
 static void prefs_actions_cancel(GtkWidget *w, gpointer data)
 {
+       if (modified && alertpanel(_("Entry not saved"),
+                                _("The entry was not saved. Close anyway?"),
+                                _("Yes"), _("No"), NULL) != G_ALERTDEFAULT) {
+               return;
+       }
+       modified = FALSE;
        prefs_actions_read_config();
        gtk_widget_hide(actions.window);
        inc_unlock();
@@ -625,6 +644,12 @@ static void prefs_actions_ok(GtkWidget *widget, gpointer data)
        MessageView *msgview;
        Compose *compose;
 
+       if (modified && alertpanel(_("Entry not saved"),
+                                _("The entry was not saved. Close anyway?"),
+                                _("Yes"), _("No"), NULL) != G_ALERTDEFAULT) {
+               return;
+       }
+       modified = FALSE;
        prefs_actions_write_config();
 
        /* Update mainwindow actions menu */