vimprobable-users Mailing List for Vimprobable (Page 21)
Vimprobable is a lean web browser optimised for full keyboard control
Brought to you by:
hanness
You can subscribe to this list here.
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(77) |
Sep
(44) |
Oct
(43) |
Nov
(38) |
Dec
(14) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2012 |
Jan
(40) |
Feb
(18) |
Mar
(12) |
Apr
(25) |
May
(12) |
Jun
(13) |
Jul
(17) |
Aug
(3) |
Sep
(20) |
Oct
(42) |
Nov
(9) |
Dec
(2) |
2013 |
Jan
(9) |
Feb
(29) |
Mar
(9) |
Apr
(7) |
May
(38) |
Jun
|
Jul
(7) |
Aug
|
Sep
(5) |
Oct
(10) |
Nov
(11) |
Dec
(1) |
2014 |
Jan
(16) |
Feb
(18) |
Mar
(11) |
Apr
(5) |
May
(13) |
Jun
(5) |
Jul
(5) |
Aug
(7) |
Sep
(30) |
Oct
|
Nov
|
Dec
(26) |
2015 |
Jan
(5) |
Feb
(19) |
Mar
(8) |
Apr
(15) |
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(16) |
Dec
(10) |
2016 |
Jan
|
Feb
(1) |
Mar
(14) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Hannes S. <ha...@yl...> - 2012-03-04 18:02:13
|
Before we get into code details, I think the concept should be clear and agreed on. Apart from the mailcap question which ruskie already asked, I see the following potential irritation: As you currently implemented this, a file is first downloaded to the regular download location (which I would assume to be some sort of permanent storage space) and then, if a definition is found for this MIME type, opened. What other browsers do is offer a choice to *either* download a file to permanent storage *or* open it. Not getting into the discussion of "opening" also involving downloading the file, it is usually stored in non-permanent space for that purpose, because when a file is selected to be "opened", I guess the assumption is that the user does not want to store it permanently. The other way around, it could also get annoying not to be able to simply *save* a file anymore *without* opening it immediately afterwards. So, what's everyone's views on this? Hannes |
From: Steffen S. <ssc...@un...> - 2012-03-03 19:27:49
|
On Sat, 3 Mar 2012, Andraž 'ruskie' Levstik wrote: > :2012-03-03T18:35:Steffen Schuldenzucker: > >> Hey Guys, >> >> I just implemented a feature that will e.g. automatically open your pdf viewer >> when you click on a pdf file. Also refactored the external URI handlers to be >> able to reuse most of their code. >> Steffen Schuldenzucker (3): >> utilities: add spawn_command_on; add is_prefix_of; refactor >> open_handler > > Why not reuse mailcap? In fact, my config.h looks like this: static FileHandler file_handlers[] = { { "application/pdf", "xdg-open %s" }, { "application/postscript", "xdg-open %s" }, ... } I had to set up xdg-open nevertheless because so many programs use it (acroread, chromium, ...) But you're probably more of an expert than me, so could you maybe explain how to handle this properly? Oh, btw. I just switched to alpine because my thunderbird was buggy :) -- Steffen |
From: Andraž 'r. L. <ru...@co...> - 2012-03-03 18:16:10
|
:2012-03-03T18:35:Steffen Schuldenzucker: > Hey Guys, > > I just implemented a feature that will e.g. automatically open your pdf viewer > when you click on a pdf file. Also refactored the external URI handlers to be > able to reuse most of their code. > Steffen Schuldenzucker (3): > utilities: add spawn_command_on; add is_prefix_of; refactor > open_handler Why not reuse mailcap? -- Andraž 'ruskie' Levstik Source Mage GNU/Linux Games/Xorg grimoire guru Re-Alpine Coordinator http://sourceforge.net/projects/re-alpine/ Geek/Hacker/Tinker Communities that make few or no demands on their members cannot command allegiance. All else being equal, members who feel most needed have the strongest allegiance. |
From: Steffen S. <ste...@gm...> - 2012-03-03 17:36:05
|
--- utilities.c | 4 ++-- utilities.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/utilities.c b/utilities.c index 7d41867..bc70f88 100644 --- a/utilities.c +++ b/utilities.c @@ -802,7 +802,7 @@ void make_uri_handlers_list(URIHandler *uri_handlers, int length) * also todo: Will leak mem if %s is used more than once. */ void -spawn_command_on(const char* p_cmd, char* arg) { +spawn_command_on(const char* p_cmd, const char* arg) { char *argv[64], cmd[MAX_SETTING_SIZE]; strncpy(cmd, p_cmd, MAX_SETTING_SIZE); char *dynarg = NULL; @@ -819,7 +819,7 @@ spawn_command_on(const char* p_cmd, char* arg) { } gboolean -is_prefix_of(char* s, char* t) { +is_prefix_of(const char* s, const char* t) { return strlen(s) <= strlen(t) && !strncmp(s, t, strlen(s)); } diff --git a/utilities.h b/utilities.h index 67338c1..c9f0633 100644 --- a/utilities.h +++ b/utilities.h @@ -35,9 +35,9 @@ char *find_uri_for_searchengine(const char *handle); void make_searchengines_list(Searchengine *searchengines, int length); void make_uri_handlers_list(URIHandler *uri_handlers, int length); void make_file_handlers_list(FileHandler *file_handlers, int length); -void spawn_command_on(const char* p_cmd, char* arg); +void spawn_command_on(const char* p_cmd, const char* arg); gboolean open_handler(char *uri); gboolean open_file_handler(const char *dst_uri, const char* content_type); -gboolean is_prefix_of(char* s, char* t); +gboolean is_prefix_of(const char* s, const char* t); -- 1.7.9.1 |
From: Steffen S. <ste...@gm...> - 2012-03-03 17:36:04
|
--- config.h | 11 +++++++++++ main.c | 18 ++++++++++++++++++ utilities.c | 32 +++++++++++++++++++++++++++++++- utilities.h | 3 +++ vimprobable.h | 5 +++++ 5 files changed, 68 insertions(+), 1 deletions(-) diff --git a/config.h b/config.h index c4b5b27..876e190 100644 --- a/config.h +++ b/config.h @@ -67,6 +67,17 @@ static URIHandler uri_handlers[] = { { "ftp://", "x-terminal-emulator -e wget ftp://%s" }, }; + +/* external file handlers: + * when a download is finished, look for an entry where the handle (first + * string) matches the beginning of its MIME type (Content-Type header). Then + * call the handler (second string) on it. + */ +static FileHandler file_handlers[] = { + { "application/pdf", "xpdf %s" }, + { "application/postscript", "gv %s" }, +}; + /* cookies */ #define ENABLE_COOKIE_SUPPORT #define COOKIES_STORAGE_FILENAME "%s/vimprobable/cookies", config_base diff --git a/main.c b/main.c index 48e884f..e7c1aad 100644 --- a/main.c +++ b/main.c @@ -88,6 +88,7 @@ static void ascii_bar(int total, int state, char *string); static gchar *jsapi_ref_to_string(JSContextRef context, JSValueRef ref); static void jsapi_evaluate_script(const gchar *script, gchar **value, gchar **message); static void download_progress(WebKitDownload *d, GParamSpec *pspec); +static gboolean try_open_file_handler(WebKitDownload* d); static void set_widget_font_and_color(GtkWidget *widget, const char *font_str, const char *bg_color_str, const char *fg_color_str); @@ -333,6 +334,7 @@ download_progress(WebKitDownload *d, GParamSpec *pspec) { a.i = Info; a.s = g_strdup_printf("Download %s finished", webkit_download_get_suggested_filename(d)); echo(&a); + try_open_file_handler(d); } g_free(a.s); activeDownloads = g_list_remove(activeDownloads, d); @@ -340,6 +342,21 @@ download_progress(WebKitDownload *d, GParamSpec *pspec) { update_state(); } +gboolean +try_open_file_handler(WebKitDownload* d) { + WebKitNetworkResponse *resp = webkit_download_get_network_response(d); + SoupMessage *msg = webkit_network_response_get_message(resp); + SoupMessageHeaders *resp_headers = msg->response_headers; + + const char* content_type = soup_message_headers_get_one(resp_headers, + "Content-Type"); + const char* dst_uri = (const char*) + webkit_download_get_destination_uri(d); + + if(!content_type) + return FALSE; + return open_file_handler(dst_uri, content_type); +} gboolean process_keypress(GdkEventKey *event) { @@ -2556,6 +2573,7 @@ main(int argc, char *argv[]) { make_searchengines_list(searchengines, LENGTH(searchengines)); make_uri_handlers_list(uri_handlers, LENGTH(uri_handlers)); + make_file_handlers_list(file_handlers, LENGTH(file_handlers)); /* Check if the specified file exists. */ /* And only warn the user, if they explicitly asked for a config on the diff --git a/utilities.c b/utilities.c index 387a466..7d41867 100644 --- a/utilities.c +++ b/utilities.c @@ -20,7 +20,8 @@ extern Key keys[]; extern char *error_msg; extern gboolean complete_case_sensitive; extern char *config_base; -static GList *dynamic_searchengines = NULL, *dynamic_uri_handlers = NULL; +static GList *dynamic_searchengines = NULL, *dynamic_uri_handlers = NULL, + *dynamic_file_handlers = NULL; void add_modkeys(char key); @@ -841,3 +842,32 @@ open_handler(char *uri) { return FALSE; } +void make_file_handlers_list(FileHandler *file_handlers, int length) +{ + int i; + for (i = 0; i < length; i++, file_handlers++) { + dynamic_file_handlers = g_list_prepend(dynamic_file_handlers, file_handlers); + } +} + +gboolean open_file_handler(const char *dst_uri, const char* content_type) { + const char* strip = "file://"; + size_t striplen = strlen(strip); + if(!(strlen(dst_uri) >= striplen && !strncmp(dst_uri, strip, striplen))) + return FALSE; /* strange */ + const char* path = dst_uri + striplen; + + if(dynamic_file_handlers) { + GList *l; + for(l = dynamic_file_handlers; l; l = g_list_next(l)) { + FileHandler *s = (FileHandler*)l->data; + if(is_prefix_of(s->handle, content_type)) { + if(strlen(s->handler) > 0) + spawn_command_on(s->handler, path); + return TRUE; + } + } + } + return FALSE; +} + diff --git a/utilities.h b/utilities.h index 8cfd7b9..67338c1 100644 --- a/utilities.h +++ b/utilities.h @@ -34,7 +34,10 @@ void free_list(Listelement *elementlist); char *find_uri_for_searchengine(const char *handle); void make_searchengines_list(Searchengine *searchengines, int length); void make_uri_handlers_list(URIHandler *uri_handlers, int length); +void make_file_handlers_list(FileHandler *file_handlers, int length); void spawn_command_on(const char* p_cmd, char* arg); gboolean open_handler(char *uri); +gboolean open_file_handler(const char *dst_uri, const char* content_type); + gboolean is_prefix_of(char* s, char* t); diff --git a/vimprobable.h b/vimprobable.h index 5a6c2df..55fbd67 100644 --- a/vimprobable.h +++ b/vimprobable.h @@ -143,6 +143,11 @@ typedef struct { char *handler; } URIHandler; +typedef struct { + char *handle; + char *handler; +} FileHandler; + struct map_pair { char *line; char what[20]; -- 1.7.9.1 |
From: Steffen S. <ste...@gm...> - 2012-03-03 17:36:02
|
--- utilities.c | 80 ++++++++++++++++++++++++++++------------------------------ utilities.h | 2 + 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/utilities.c b/utilities.c index 9bb4f49..387a466 100644 --- a/utilities.c +++ b/utilities.c @@ -795,50 +795,48 @@ void make_uri_handlers_list(URIHandler *uri_handlers, int length) } } +/* spawn_command_on("xpdf %s", "file.pdf") -> spawn "xpdf \"file.pdf\"" + * todo: no way to escape whitespace in p_cmd. (ws in path is ok) + * Maybe just escape, printf, execute via bash? + * also todo: Will leak mem if %s is used more than once. + */ +void +spawn_command_on(const char* p_cmd, char* arg) { + char *argv[64], cmd[MAX_SETTING_SIZE]; + strncpy(cmd, p_cmd, MAX_SETTING_SIZE); + char *dynarg = NULL; + int j; + char *word = strtok(cmd, " "); + for(j = 0; j < 62 && word; ++j, word = strtok(NULL, " ")) + argv[j] = (strstr(word, "%s") + ? dynarg = g_strdup_printf(word, arg) + : word); + argv[j] = NULL; + g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL); + if(dynarg) + g_free(dynarg); +} + +gboolean +is_prefix_of(char* s, char* t) { + return strlen(s) <= strlen(t) && !strncmp(s, t, strlen(s)); +} + gboolean open_handler(char *uri) { - char *argv[64]; - char *p = NULL, *arg, arg_temp[MAX_SETTING_SIZE], *temp, temp2[MAX_SETTING_SIZE] = "", *temp3; - int j; - GList *l; + if(!strchr(uri, ':')) + return FALSE; - p = strchr(uri, ':'); - if (p) { - if (dynamic_uri_handlers != NULL) { - for (l = dynamic_uri_handlers; l; l = g_list_next(l)) { - URIHandler *s = (URIHandler *)l->data; - if (strlen(uri) >= strlen(s->handle) && strncmp(s->handle, uri, strlen(s->handle)) == 0) { - if (strlen(s->handler) > 0) { - arg = (uri + strlen(s->handle)); - strncpy(temp2, s->handler, MAX_SETTING_SIZE); - temp = strtok(temp2, " "); - j = 0; - while (temp != NULL) { - if (strstr(temp, "%s")) { - temp3 = temp; - memset(arg_temp, 0, MAX_SETTING_SIZE); - while (strncmp(temp3, "%s", 2) != 0) { - strncat(arg_temp, temp3, 1); - temp3++; - } - strcat(arg_temp, arg); - temp3++; - temp3++; - strcat(arg_temp, temp3); - argv[j] = arg_temp; - } else { - argv[j] = temp; - } - temp = strtok(NULL, " "); - j++; - } - argv[j] = NULL; - g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL); - } - return TRUE; - } - } - } + if(dynamic_uri_handlers) { + GList *l; + for (l = dynamic_uri_handlers; l; l = g_list_next(l)) { + URIHandler *s = (URIHandler *)l->data; + if(is_prefix_of(s->handle, uri)) { + if (strlen(s->handler) > 0) + spawn_command_on(s->handler, uri + strlen(s->handle)); + return TRUE; + } + } } return FALSE; } diff --git a/utilities.h b/utilities.h index f9ac1ba..8cfd7b9 100644 --- a/utilities.h +++ b/utilities.h @@ -34,5 +34,7 @@ void free_list(Listelement *elementlist); char *find_uri_for_searchengine(const char *handle); void make_searchengines_list(Searchengine *searchengines, int length); void make_uri_handlers_list(URIHandler *uri_handlers, int length); +void spawn_command_on(const char* p_cmd, char* arg); gboolean open_handler(char *uri); +gboolean is_prefix_of(char* s, char* t); -- 1.7.9.1 |
From: Steffen S. <ste...@gm...> - 2012-03-03 17:35:53
|
Hey Guys, I just implemented a feature that will e.g. automatically open your pdf viewer when you click on a pdf file. Also refactored the external URI handlers to be able to reuse most of their code. Cheers, Steffen Steffen Schuldenzucker (3): utilities: add spawn_command_on; add is_prefix_of; refactor open_handler external file handlers by MIME type. (e.g. auto-open a file when download is complete) fix compiler warnings: add some 'const'. config.h | 11 ++++++ main.c | 18 +++++++++ utilities.c | 112 +++++++++++++++++++++++++++++++++++--------------------- utilities.h | 5 +++ vimprobable.h | 5 +++ 5 files changed, 109 insertions(+), 42 deletions(-) -- 1.7.9.1 |
From: Matthew C. <je...@gm...> - 2012-02-29 05:46:55
|
Hi Hannes, Looks good! Time to try out the new updates! -Matt On Tue, Feb 28, 2012 at 02:26:17PM +0100, Hannes Schüller wrote: > Not strictly related to the new software releases, but this seems to be > a good place to announce this nevertheless: > > Jason Ryan was so kind to make a Vimprobable logo set available in the > wiki: > > http://sourceforge.net/apps/trac/vimprobable/wiki/Screenshots > > The logo is available in various standard sizes as well as in a > scalable vector format. So if your window manager or application > launcher is icon-based, feel free to grab and use them! > > Thanks again, Jason! > > Hannes > ------------------------------------------------------------------------------ > Keep Your Developer Skills Current with LearnDevNow! > The most comprehensive online learning library for Microsoft developers > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, > Metro Style Apps, more. Free future releases when you subscribe now! > http://p.sf.net/sfu/learndevnow-d2d > _______________________________________________ > Vimprobable-users mailing list > Vim...@li... > https://lists.sourceforge.net/lists/listinfo/vimprobable-users -- Matthew Carter je...@gm... |
From: Hannes S. <ha...@yl...> - 2012-02-28 15:16:31
|
As a followup to the new "escapeinput" setting, here is what I hope to be a little improvement. The logic is basically in the second hunk of the attached patch. Even if "escapeinput" is set, there are a few new checks performed before simply snatching focus away from whereever it is: 1. If Javascript is not active, do nothing (rationale: the problem for which this setting is meant cannot occur). 2. If some website element has been focused manually in the meantime by the user, do nothing. 3. If the input box has been activated, do nothing. The second one could still be a source of problems. For example, if the user manually focused an element while loading the page and *then*, some javascript grabbed focus, the desired effect of "escapeinput" will not occur. That, however, would again only be possible to prevent if we could detect focus stealing events defined on the website, and if we managed to do that, we wouldn't need this logic anyway. Let me know what you think and whether you can think of any cases which aren't covered by the new logic yet (i.e. when the browser does not behave as it should - taking focus away or focusing something when it shouldn't). Hannes |
From: Hannes S. <ha...@yl...> - 2012-02-28 14:07:44
|
By the way, not that it really concerns me (having Javascript disabled anyway), but these focus events are still quite annoying. For example: - Open a website with such a focus event - While the site is still loading, launch a command (e.g. / or :) - Wait for the site to finish loading With the current code, the browser will first focus the input bar (due to the user command), then the site will grab focus for its prefered input element and then, the browser will take focus away from that again. However, then, nothing is focused when it really *should* be the input bar. The much cleaner (and, to be honest, only really sane) solution would be to prevent the site from executing its malicious focus stealing in the first place. No idea how to achieve this, though. Hannes |
From: Hannes S. <ha...@yl...> - 2012-02-28 13:26:05
|
Not strictly related to the new software releases, but this seems to be a good place to announce this nevertheless: Jason Ryan was so kind to make a Vimprobable logo set available in the wiki: http://sourceforge.net/apps/trac/vimprobable/wiki/Screenshots The logo is available in various standard sizes as well as in a scalable vector format. So if your window manager or application launcher is icon-based, feel free to grab and use them! Thanks again, Jason! Hannes |
From: Hannes S. <ha...@yl...> - 2012-02-28 12:16:32
|
New features: - RC file consolidation (Hannes Schueller; Vimprobable2) Custom search engines now have to be defined in vimprobablerc. *The searchengines file will not be read by the browser anymore!* To move your definitions, simply copy the contents of the searchengines file to vimprobablerc and add 'searchengine ' (without quotes) as a prefix to each line. - External URI handlers (Hannes Schueller) Protocol links which cannot be handled by Webkit internally can now be sent to external applications (e.g. FTP or Mailto). Compile-time definition can be done in config.h, runtime definition (Vimprobable2 only) in vimprobablerc. - New setting to escape automatically focused form elements (Matt Carter) This is on by default as the related behaviour of some sites makes them unusable. Deactivation possible through config.h and as a :set command (Vimprobable2 only). Fixes: - Nagging proxy message removed (Daniel Carl) - Proxy memory leak fix (Daniel Carl) - Disabling hinting mode correctly after new page load (Hannes Schueller) - Man page correction concerning image hinting (Hans-Peter Deifel) Configuration changes: - Scroogle has been removed from the list of search engines as it has been shut down. - DuckDuckGo has been added to the list of search engines instead. Unfortunately, that search engine does not follow the concept of graceful degradation. Their default site is unusable when Javascript is disabled. Therefore, there are two shortcuts: 'd' (JS) and 'dd' (non-JS). Hannes |
From: Hannes S. <ha...@yl...> - 2012-02-28 11:39:49
|
Merged this version (minus the configuration changes) and added man page documentation. Matthew Carter <je...@gm...> wrote: > Also how do I get my name added to LICENSE? :) Done :) Hannes |
From: Hannes S. <ha...@yl...> - 2012-02-28 11:08:18
|
Merged this #3. #1 and #2 still seem to be subject to that bug which Daniel reported. |
From: Hannes S. <ha...@yl...> - 2012-02-28 11:00:22
|
Merged |
From: Hannes S. <ha...@yl...> - 2012-02-28 10:57:34
|
Merged |
From: Hannes S. <ha...@yl...> - 2012-02-28 10:54:24
|
Merged |
From: Hannes S. <ha...@yl...> - 2012-02-28 10:51:53
|
Merged (with adaption to not use a dedicated config file, but vimprobablerc) |
From: Hannes S. <ha...@yl...> - 2012-02-28 09:59:41
|
This is now merged |
From: Daniel C. <dan...@gm...> - 2012-02-11 21:59:18
|
Hi! On Fri, Jan 20, 2012 at 11:06:54PM +0100, Hannes Schüller wrote: > Matt Carter <je...@gm...> wrote: > > I personally hate the auto focus of input fields [...] > > > > Would adding focus watchers be more or less resource intensive than > > escaping all inputs on page load? > > It would give control to the website (as other browsers do it), i.e. > focus the specified input field and enter INPUT mode. Personally, I > agree that this is intrusive and annoying, but again, this is how the > website intended it and how other browsers handle it. > > Your patch, on the other hand, gives control to the user. Might be > preferable since we generally *do* strive to give as much power to the > user as possible. > > Hannes I also don't like the auto focus of input fields and would like to give the user the control about it. At work I'm forced to use a proprietary tracking system which make intensive use of frames and javascript. Sometimes I got pages that force vimprobable to insert mode and also <ESC> doesn't help because some scripts force vimprobable back to insert mode so that no navigation shortcut or 'q' works. I know that this is more a mistake of the used page, but it shows also that the auto focus feature can make vimprobable unusable in some cases. Daniel |
From: Hans-Peter D. <hpd...@gm...> - 2012-02-04 21:44:44
|
Hi, Daniel Carl <dan...@gm...> writes: > this is a feature I waited for a long time. But I found a small bug. If I save > a page into a none existing path, vimprobable says 'Download > file:///home/daniel/foo/foo.html finished' but the foo directory was not > created and the file was not downloaded. I think we should test if the > download was really done, if not echo a error message in vimprobable. Well spotted! I think this is a bug in Webkit. We already check the status of the download in download_process() and print the "finished" message only if it is WEBKIT_DOWNLOAD_STATUS_FINISHED. I also get strange messages like (vimprobable2:5547): GLib-GIO-CRITICAL **: g_output_stream_write_all: assertion `G_IS_OUTPUT_STREAM (stream)' failed if I try to save a page to a nonexistent path. We could work around this by calling access(2) before starting the download. That's a little ugly, but I will prepare a new patch with it. HP |
From: Daniel C. <dan...@gm...> - 2012-02-04 10:58:16
|
Hi Hans-Peter, this is a feature I waited for a long time. But I found a small bug. If I save a page into a none existing path, vimprobable says 'Download file:///home/daniel/foo/foo.html finished' but the foo directory was not created and the file was not downloaded. I think we should test if the download was really done, if not echo a error message in vimprobable. Daniel |
From: Hans-Peter D. <Han...@in...> - 2012-02-02 11:40:04
|
--- config.h | 2 ++ main.c | 25 ++++++++++++++++++++++++- vimprobable2.1 | 4 ++++ 3 files changed, 30 insertions(+), 1 deletions(-) diff --git a/config.h b/config.h index b2f8e78..c0c618b 100644 --- a/config.h +++ b/config.h @@ -120,6 +120,8 @@ Command commands[COMMANDSIZE] = { { "bma", bookmark, {0} }, { "bookmark", bookmark, {0} }, { "source", view_source, {0} }, + { "w", save_page, {0} }, + { "write", save_page, {0} }, { "set", browser_settings, {0} }, { "map", mappings, {0} }, { "jumpleft", scroll, {ScrollJumpTo | DirectionLeft} }, diff --git a/main.c b/main.c index f106245..99ccad7 100644 --- a/main.c +++ b/main.c @@ -77,6 +77,7 @@ static gboolean yank(const Arg *arg); static gboolean view_source(const Arg * arg); static gboolean zoom(const Arg *arg); static gboolean fake_key_event(const Arg *arg); +static gboolean save_page(const Arg *arg); static void update_url(const char *uri); static void setup_modkeys(void); @@ -280,7 +281,9 @@ webview_download_cb(WebKitWebView *webview, WebKitDownload *download, gpointer u WebKitDownloadStatus status; filename = webkit_download_get_suggested_filename(download); - if (filename == NULL || strlen(filename) == 0) { + if (user_data) { + filename = (const char*)user_data; + } else if (filename == NULL || strlen(filename) == 0) { filename = "vimprobable_download"; } path = g_build_filename(g_strdup_printf(DOWNLOADS_PATH), filename, NULL); @@ -1637,6 +1640,26 @@ fake_key_event(const Arg *a) { return TRUE; } +gboolean +save_page(const Arg *arg) { + WebKitNetworkRequest *request; + WebKitDownload *download; + const char *uri = webkit_web_view_get_uri(webview); + const char *destination = NULL; + + if (uri == NULL || *uri == '\0') { + set_error("No URI found to save."); + return FALSE; + } + + request = webkit_network_request_new(uri); + download = webkit_download_new(request); + if (arg->s && *arg->s) { + destination = arg->s; + } + webview_download_cb(webview, download, (gpointer *)destination); + return TRUE; +} gboolean commandhistoryfetch(const Arg *arg) { diff --git a/vimprobable2.1 b/vimprobable2.1 index a780e6a..0a8cb79 100644 --- a/vimprobable2.1 +++ b/vimprobable2.1 @@ -254,6 +254,10 @@ Shortcut: d Print the current URL +.IP ":w[rite] [filename]" + +Save the current document. + .SH MODES Vimprobable is a modal browser. By default, it is in command mode, meaning that -- 1.7.2.5 |
From: Hans-Peter D. <Han...@in...> - 2012-02-02 11:40:03
|
--- vimprobable2.1 | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vimprobable2.1 b/vimprobable2.1 index 0a8cb79..b578447 100644 --- a/vimprobable2.1 +++ b/vimprobable2.1 @@ -174,10 +174,10 @@ Generate an :open command with the link's URL (like O) .I " " ;T or ;W Generate an :tabopen command with the link's URL (like T) -.I " " ;s +.I " " ;i Open image in current window -.I " " ;S +.I " " ;I Open image in new window .I " " gi -- 1.7.2.5 |
From: Hans-Peter D. <Han...@in...> - 2012-02-02 11:39:59
|
The suggested filename doesn't have to be the actual destination, e.g. for 'vimprobable_download' downloads or when the user gives a custom filename to :write. There is a downside though: webkit_download_get_destination_uri() returns an absolute path with 'file://' prefix, which is quite verbose. --- main.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 99ccad7..c377085 100644 --- a/main.c +++ b/main.c @@ -321,11 +321,11 @@ download_progress(WebKitDownload *d, GParamSpec *pspec) { if (status != WEBKIT_DOWNLOAD_STATUS_STARTED && status != WEBKIT_DOWNLOAD_STATUS_CREATED) { if (status != WEBKIT_DOWNLOAD_STATUS_FINISHED) { a.i = Error; - a.s = g_strdup_printf("Error while downloading %s", webkit_download_get_suggested_filename(d)); + a.s = g_strdup_printf("Error while downloading %s", webkit_download_get_destination_uri(d)); echo(&a); } else { a.i = Info; - a.s = g_strdup_printf("Download %s finished", webkit_download_get_suggested_filename(d)); + a.s = g_strdup_printf("Download %s finished", webkit_download_get_destination_uri(d)); echo(&a); } g_free(a.s); -- 1.7.2.5 |