]> git.deb.at Git - pkg/abook.git/commitdiff
quit without saving command
authorJaakko Heinonen <jheinonen@users.sourceforge.net>
Thu, 6 Nov 2003 17:32:00 +0000 (17:32 +0000)
committerJaakko Heinonen <jheinonen@users.sourceforge.net>
Thu, 6 Nov 2003 17:32:00 +0000 (17:32 +0000)
ChangeLog
abook.c
abook.h
help.h
ui.c

index 110d9372e6730285e63596bcd6fcbd5e17f5675c..624a9792088c7ad2a6bb5d63b899029bbccf81eb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 0.5.1
  - sort by field command
+ - duplicate item command
+ - quit without saving command
  - minor filter fixes
  - tried to fix \" quotation problem with mutt import filter
  - removed obsolete filesel_sort option from abookrc manual page
diff --git a/abook.c b/abook.c
index 7ce99ae3366d9269b12bfb21d9ca49afd8b387ed..51812032f7bd55af529028d24514908d05b10506 100644 (file)
--- a/abook.c
+++ b/abook.c
@@ -137,12 +137,15 @@ init_abook()
 }
 
 void
-quit_abook()
+quit_abook(int save_db)
 {
-       if(opt_get_bool(BOOL_AUTOSAVE))
-               save_database();
-       else if(statusline_ask_boolean("Save database", TRUE))
-               save_database();
+       if(save_db)  {
+               if(opt_get_bool(BOOL_AUTOSAVE))
+                       save_database();
+               else if(statusline_ask_boolean("Save database", TRUE))
+                       save_database();
+       } else if(!statusline_ask_boolean("Quit without saving", FALSE))
+               return;
 
        free_opts();
        close_database();
@@ -155,7 +158,7 @@ quit_abook()
 static void
 quit_abook_sig(int i)
 {
-       quit_abook();
+       quit_abook(QUIT_SAVE);
 }
 
 int
@@ -171,7 +174,7 @@ main(int argc, char **argv)
 
        get_commands(); 
 
-       quit_abook();
+       quit_abook(QUIT_SAVE);
 
        return 0;
 }
@@ -577,7 +580,7 @@ abook_malloc(size_t size)
 
        if ( (ptr = malloc(size)) == NULL ) {
                if( is_ui_initialized() )
-                       quit_abook();
+                       quit_abook(QUIT_SAVE);
                perror("malloc() failed");
                exit(1);
        }
@@ -595,7 +598,7 @@ abook_realloc(void *ptr, size_t size)
 
        if(ptr == NULL) {
                if(is_ui_initialized())
-                       quit_abook();
+                       quit_abook(QUIT_SAVE);
                perror("realloc() failed");
                exit(1);
        }
diff --git a/abook.h b/abook.h
index 790d0523cd566b73e339397382cfb9c909101330..f6c756b70428737b6caa17a2fe1dd1e462a037d6 100644 (file)
--- a/abook.h
+++ b/abook.h
@@ -6,7 +6,7 @@
 void           *abook_malloc(size_t size);
 void           *abook_realloc(void *ptr, size_t size);
 FILE           *abook_fopen (const char *path, const char *mode);
-void           quit_abook();
+void           quit_abook(int save_db);
 void           launch_wwwbrowser(int item);
 void           launch_mutt(int item);
 void           print_stderr(int item);
@@ -28,6 +28,9 @@ int           strncasecmp (const char *, const char *, size_t);
 
 #define RCFILE         "abookrc"
 
+#define QUIT_SAVE      1
+#define QUIT_DONTSAVE  0
+
 /*
  * some "abookwide" useful macros
  */
diff --git a/help.h b/help.h
index 95d27f4bc76c80a71c1acf7f4cb3019ee1ce3857..181aa454d557f7e16703dc37028c38fdfeaf8ba4 100644 (file)
--- a/help.h
+++ b/help.h
@@ -9,7 +9,8 @@ static char *mainhelp[] = {
 
 "      ?               help\n",
 "      q               quit\n",
-"      Q               quit and print selected item(s) to stderr\n",
+"      Q               quit without saving\n",
+"      P               quit and print selected item(s) to stderr\n",
 "      ^L              refresh screen\n",
 "\n",
 "      arrows / j,k    scroll list\n",
diff --git a/ui.c b/ui.c
index 9d59cc796d62b2a5f404f59646326af8bcfa6071..3d7e01a8f7469ae640e014509808b1802a371167 100644 (file)
--- a/ui.c
+++ b/ui.c
@@ -383,7 +383,8 @@ get_commands()
                can_resize = FALSE; /* it's not safe to resize anymore */
                switch( ch ) {
                        case 'q': return;
-                       case 'Q': print_stderr(selected_items() ?
+                       case 'Q': quit_abook(QUIT_DONTSAVE);    break;
+                       case 'P': print_stderr(selected_items() ?
                                                  -1 : list_current_item());
                                  return;
                        case '?':