summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Carl <danielcarl@gmx.de>2014-07-14 22:22:27 +0200
committerDaniel Carl <danielcarl@gmx.de>2014-07-14 22:22:27 +0200
commitfece73677081f5dbc01b7e87ec656f6fc6351a0b (patch)
treeb3d06fc8e97c381268ced4c92e9d7c99f4e793a1
parentcb8dd5480429caadebba2da5973a0831b079c44c (diff)
Don't allow to quit vimb if there are running downloads.
Added :quit! to force quit even when there are still running downloads.
-rw-r--r--doc/vimb.17
-rw-r--r--src/ex.c4
-rw-r--r--src/main.c10
-rw-r--r--src/main.h2
-rw-r--r--src/normal.c2
5 files changed, 17 insertions, 8 deletions
diff --git a/doc/vimb.1 b/doc/vimb.1
index 31c87b2..bbd855e 100644
--- a/doc/vimb.1
+++ b/doc/vimb.1
@@ -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
diff --git a/src/ex.c b/src/ex.c
index 36fef1a..88ea453 100644
--- 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;
}
diff --git a/src/main.c b/src/main.c
index bb148bf..96212f6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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)
diff --git a/src/main.h b/src/main.h
index ef9c0d9..f99cf44 100644
--- a/src/main.h
+++ b/src/main.h
@@ -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 */
diff --git a/src/normal.c b/src/normal.c
index 7ea484e..540f58e 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -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;
}