Don't allow to quit vimb if there are running downloads.
authorDaniel Carl <danielcarl@gmx.de>
Mon, 14 Jul 2014 20:22:27 +0000 (22:22 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Mon, 14 Jul 2014 20:22:27 +0000 (22:22 +0200)
Added :quit! to force quit even when there are still running downloads.

doc/vimb.1
src/ex.c
src/main.c
src/main.h
src/normal.c

index 31c87b2..bbd855e 100644 (file)
@@ -87,7 +87,7 @@ Opend the Web Inspector for current page.
 Pass the next key press directly to gtk.
 .TP
 .B CTRL\-Q
-Quit the browser.
+Quit the browser if there are no running downloads.
 .SS Navigation
 .TP
 .B o
@@ -587,7 +587,10 @@ is given, download under this file name or path. \fIPATH\fP is expanded and
 can therefor contain '~/', '${ENV}' and '~user' pattern.
 .TP
 .B :q[uit]
-Close the browser.
+Close the browser. This will be refused if there are running downloads.
+.TP
+.B :q[uit]!
+Close the browser independent from an running download.
 .TP
 .BI :e[val] " JAVASCRIPT"
 Runs the given \fIJAVASCRIPT\fP in the current page and display the evaluated
index 36fef1a..88ea453 100644 (file)
--- a/src/ex.c
+++ b/src/ex.c
@@ -168,7 +168,7 @@ static ExInfo commands[] = {
     {"normal",           EX_NORMAL,      ex_normal,     EX_FLAG_BANG|EX_FLAG_LHS},
     {"nunmap",           EX_NUNMAP,      ex_unmap,      EX_FLAG_LHS},
     {"open",             EX_OPEN,        ex_open,       EX_FLAG_RHS},
-    {"quit",             EX_QUIT,        ex_quit,       EX_FLAG_NONE},
+    {"quit",             EX_QUIT,        ex_quit,       EX_FLAG_NONE|EX_FLAG_BANG},
 #ifdef FEATURE_QUEUE
     {"qunshift",         EX_QUNSHIFT,    ex_queue,      EX_FLAG_RHS},
     {"qclear",           EX_QCLEAR,      ex_queue,      EX_FLAG_RHS},
@@ -832,7 +832,7 @@ static gboolean ex_queue(const ExArg *arg)
 
 static gboolean ex_quit(const ExArg *arg)
 {
-    vb_quit();
+    vb_quit(arg->bang);
     return true;
 }
 
index bb148bf..96212f6 100644 (file)
@@ -372,8 +372,14 @@ void vb_update_urlbar(const char *uri)
 #endif
 }
 
-void vb_quit(void)
+void vb_quit(gboolean force)
 {
+    /* if not forced quit - don't quit if there are still runinng downloads */
+    if (!force && vb.state.downloads) {
+        vb_echo_force(VB_MSG_ERROR, true, "Can't quit: there are running downloads");
+        return;
+    }
+
     /* write last URL into file for recreation */
     if (vb.state.uri) {
         g_file_set_contents(vb.files[FILES_CLOSED], vb.state.uri, -1, NULL);
@@ -600,7 +606,7 @@ static void webview_request_starting_cb(WebKitWebView *view,
 
 static void destroy_window_cb(GtkWidget *widget)
 {
-    vb_quit();
+    vb_quit(true);
 }
 
 static void scroll_cb(GtkAdjustment *adjustment)
index ef9c0d9..f99cf44 100644 (file)
@@ -382,6 +382,6 @@ void vb_update_urlbar(const char *uri);
 void vb_register_add(char buf, const char *value);
 const char *vb_register_get(char buf);
 gboolean vb_download(WebKitWebView *view, WebKitDownload *download, const char *path);
-void vb_quit(void);
+void vb_quit(gboolean force);
 
 #endif /* end of include guard: _MAIN_H */
index 7ea484e..540f58e 100644 (file)
@@ -637,7 +637,7 @@ static VbResult normal_queue(const NormalCmdInfo *info)
 
 static VbResult normal_quit(const NormalCmdInfo *info)
 {
-    vb_quit();
+    vb_quit(false);
     return RESULT_COMPLETE;
 }