The time now is Sun 24 Jan 2021, 15:26
All times are UTC - 4 |
Page 1 of 2 [28 Posts] |
Goto page: 1, 2 Next |
Author |
Message |
BarryK
Puppy Master

Joined: 09 May 2005 Posts: 9400 Location: Perth, Western Australia
|
Posted: Mon 31 Jul 2017, 10:33 Post subject:
Surfer html viewer, want to improve it Subject description: Want to embed link to external browser |
|
Some pups, including Quirky, not sure about latest Xenialpup and Slacko, use 'surfer' for the internal html help viewer.
This is a very small web page browser, written in C and uses GTK and libgtkhtml.
It has a couple of dependencies from the same guy who created surfer, 'gnet' and 'libsystem', for pups that use surfer, these should already be in the devx.
All sources are here:
http://distro.ibiblio.org/quirky/quirky6/sources/t2/april/Surfer-0.0.7-patched_libgtkhtml.tar.bz2
http://distro.ibiblio.org/quirky/quirky6/sources/t2/april/gnet-2.0.8.tar.bz2
http://distro.ibiblio.org/quirky/quirky6/sources/t2/april/libSystem-0.1.6-patched1.tar.bz2
Compiling is simple Makefile, from memory, need to edit PREFIX, change from /usr/local to /usr
libgtkhtml is there also:
http://distro.ibiblio.org/quirky/quirky6/sources/t2/april/libgtkhtml-2.11.1.tar.bz2
Surfer is a great little viewer for local html files, however, there is one big problem. libgtkhtml supports html4 and some css, no javascript.
If surfer is used to view a local help file, which has links to the internet, then surfer will attempt to open those links, and in many cases will crash.
What would be really great is to hack the C source of surfer somehow, so that two kinds of hyperlinks can be specified in a web page, local, suitable to be opened by surfer, and remote (the internet) and opened by 'defaultbrowser' (which will be SeaMonkey, Firefox, etc).
I have been staring at the source code, but can't see how to do it. So, thought that I would throw the problem out there, see if someone with gtk coding skills can think of how to do it. Or maybe not even gtk, just C skills.
There might not be any takers, but you never know...
Edit
Note, there is one little foible of surfer, it does not like "file://" prefix on local links. So open a file like this:
# surfer /usr/share/doc/home.htm
_________________ https://bkhome.org/news/
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 1802
|
Posted: Mon 31 Jul 2017, 19:25 Post subject:
|
|
Hey Barry, maybe something like this?
Code: | diff -Naur Surfer-0.0.7-patched_libgtkhtml_old/src/ghtml-gtkhtml.c Surfer-0.0.7-patched_libgtkhtml_new/src/ghtml-gtkhtml.c
--- Surfer-0.0.7-patched_libgtkhtml_old/src/ghtml-gtkhtml.c 2009-08-14 18:54:05.000000000 +0200
+++ Surfer-0.0.7-patched_libgtkhtml_new/src/ghtml-gtkhtml.c 2017-08-01 00:59:41.118965319 +0200
@@ -1067,7 +1067,15 @@
fprintf(stderr, "DEBUG: %s(\"%s\") base=\"%s\" => \"%s\"\n", __func__,
url, _ghtml_get_base(ghtml), link);
#endif
- _ghtml_document_load(ghtml, link, NULL);
+ if (g_str_has_prefix(link, "http://") ||
+ g_str_has_prefix(link, "https://") ||
+ g_str_has_prefix(link, "ftp://")) /* maybe more prefixes are needed */
+ {
+ system(g_strdup_printf("%s %s %s", "defaultbrowser", link, "&")); /* & to send it to background */
+ }
+ else
+ _ghtml_document_load(ghtml, link, NULL);
+
g_free(link);
} |
(Also attached, because copying from browser may append spaces to each line.)
I'm just a beginner in C and that's the best I could come up with, but works just fine down here.
Greetings!
Description |
|

Download |
Filename |
surfer-remote_links.patch.tar.gz |
Filesize |
543 Bytes |
Downloaded |
410 Time(s) |
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
Back to top
|
|
 |
disciple
Joined: 20 May 2006 Posts: 7024 Location: Auckland, New Zealand
|
Posted: Mon 31 Jul 2017, 21:00 Post subject:
|
|
Using xdg-open is more portable - is it included in all puppies these days?
_________________ Do you know a good gtkdialog program? Please post a link here
Classic Puppy quotes
ROOT FOREVER
GTK2 FOREVER
|
Back to top
|
|
 |
BarryK
Puppy Master

Joined: 09 May 2005 Posts: 9400 Location: Perth, Western Australia
|
Posted: Tue 01 Aug 2017, 04:40 Post subject:
|
|
SFR,
I tested your patch, it works great. I appreciate the help, it makes Surfer so much more useful.
I have applied SFR's patch and assigned it as HelpSurfer version 0.1, source here:
http://barryk.org/news/?viewDetailed=00632
_________________ https://bkhome.org/news/
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 1802
|
Posted: Tue 01 Aug 2017, 05:30 Post subject:
|
|
Alright, glad it works!
However, here's a small revision, because I just realized that URLs that contain an amphersand won't be working properly without quotes.
Also, replaced all calls to g_str_has_prefix with one g_regex_match_simple and since g_strdup_printf allocates memory, I had to use a transient variable to free it afterwards.
Code: | diff -Naur Surfer-0.0.7-patched_libgtkhtml_old/src/ghtml-gtkhtml.c Surfer-0.0.7-patched_libgtkhtml_new/src/ghtml-gtkhtml.c
--- Surfer-0.0.7-patched_libgtkhtml_old/src/ghtml-gtkhtml.c 2009-08-14 18:54:05.000000000 +0200
+++ Surfer-0.0.7-patched_libgtkhtml_new/src/ghtml-gtkhtml.c 2017-08-01 11:17:41.846580886 +0200
@@ -1059,6 +1059,7 @@
{
GHtml * ghtml;
gchar * link;
+ gchar * syscmd;
ghtml = g_object_get_data(G_OBJECT(document), "ghtml");
if((link = _ghtml_make_url(_ghtml_get_base(ghtml), url)) == NULL)
@@ -1067,7 +1068,14 @@
fprintf(stderr, "DEBUG: %s(\"%s\") base=\"%s\" => \"%s\"\n", __func__,
url, _ghtml_get_base(ghtml), link);
#endif
- _ghtml_document_load(ghtml, link, NULL);
+ if (g_regex_match_simple("^http://|^https://|^ftp://", link, 0, 0))
+ {
+ syscmd = g_strdup_printf("%s '%s' %s", "defaultbrowser", link, "&");
+ system(syscmd);
+ g_free(syscmd);
+ }
+ else
+ _ghtml_document_load(ghtml, link, NULL);
g_free(link);
} |
___________
@Disciple: yeah, xdg-open works, too (at least here in Fatdog).
Greetings!
Description |
|

Download |
Filename |
surfer-remote_links_v2.patch.tar.gz |
Filesize |
622 Bytes |
Downloaded |
383 Time(s) |
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
Back to top
|
|
 |
gyro
Joined: 28 Oct 2008 Posts: 1799 Location: Brisbane, Australia
|
Posted: Tue 01 Aug 2017, 08:43 Post subject:
|
|
It might be a bit rude of me to comment since you already have a working patch;
But would it not be better to turn the test around: Code: | + if (g_str_has_prefix(link, "file:///")
+ _ghtml_document_load(ghtml, link, NULL);
+ else
+ {
+ syscmd = g_strdup_printf("%s '%s' %s", "defaultbrowser", link, "&");
+ system(syscmd);
+ g_free(syscmd);
+ } |
gyro
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 1802
|
Posted: Tue 01 Aug 2017, 09:29 Post subject:
|
|
Not at all, better_code > one's_feelings.
However, I ditched this approach at the very beginning, because of:
BarryK in the first post wrote: | Note, there is one little foible of surfer, it does not like "file://" prefix on local links. |
Local links in Fatdog docs (that I used for testing) don't contain this prefix and are relative:
Code: | <a href="tray.html">Tray icons</a> |
so it wouldn't work anyway...
Btw, I think ^mailto: could also be added. Surfer does not even recognize this protocol.
Greetings!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
Back to top
|
|
 |
BarryK
Puppy Master

Joined: 09 May 2005 Posts: 9400 Location: Perth, Western Australia
|
Posted: Wed 02 Aug 2017, 05:15 Post subject:
|
|
SFR,
That's great, I will apply your latest patch.
While I am putting in requests
If you look at helpsurfer-0.1, src/Makefile has "-D NOURLBAR, because as a simple help viewer I didn't think it needed the url entry box.
Also there is "-D EMBEDDED", which removes the drop-down menu bar.
The icon bar still displays, but it would be nice with an "exit" icon. Currently, the only way to close the app is by the close-box top-right of window.
_________________ https://bkhome.org/news/
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 1802
|
Posted: Wed 02 Aug 2017, 07:42 Post subject:
|
|
Here you go:
Code: | diff -Naur helpsurfer-0.1_old/src/callbacks.c helpsurfer-0.1_new/src/callbacks.c
--- helpsurfer-0.1_old/src/callbacks.c 2009-08-14 18:55:18.000000000 +0200
+++ helpsurfer-0.1_new/src/callbacks.c 2017-08-02 12:17:50.366562155 +0200
@@ -47,6 +47,12 @@
return FALSE;
}
+/* quit button */
+void on_button_close(GtkWidget * widget, gpointer data)
+{
+ on_closex(widget, NULL, data);
+}
+
#ifndef EMBEDDED
/* file menu */
diff -Naur helpsurfer-0.1_old/src/callbacks.h helpsurfer-0.1_new/src/callbacks.h
--- helpsurfer-0.1_old/src/callbacks.h 2009-08-14 18:55:18.000000000 +0200
+++ helpsurfer-0.1_new/src/callbacks.h 2017-08-02 12:17:27.103229126 +0200
@@ -24,6 +24,8 @@
/* window */
gboolean on_closex(GtkWidget * widget, GdkEvent * event, gpointer data);
+void on_button_close(GtkWidget * widget, gpointer data);
+
#ifndef EMBEDDED
/* file menu */
void on_file_close(GtkWidget * widget, gpointer data);
diff -Naur helpsurfer-0.1_old/src/surfer.c helpsurfer-0.1_new/src/surfer.c
--- helpsurfer-0.1_old/src/surfer.c 2017-08-01 09:10:39.000000000 +0200
+++ helpsurfer-0.1_new/src/surfer.c 2017-08-02 12:18:58.289894600 +0200
@@ -205,6 +205,9 @@
g_signal_connect(G_OBJECT(toolitem), "toggled", G_CALLBACK(
on_fullscreen), surfer);
gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
+ toolitem = gtk_tool_button_new_from_stock(GTK_STOCK_QUIT);
+ g_signal_connect(G_OBJECT(toolitem), "clicked", G_CALLBACK(on_button_close), surfer);
+ gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
/* toolbar */
//#ifndef NOURLBAR |
Just note that this patch is against helpsurfer-0.1.
Greetings!
Description |
|

Download |
Filename |
helpsurfer-quit_button.patch.tar.gz |
Filesize |
729 Bytes |
Downloaded |
375 Time(s) |
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
Back to top
|
|
 |
BarryK
Puppy Master

Joined: 09 May 2005 Posts: 9400 Location: Perth, Western Australia
|
Posted: Wed 02 Aug 2017, 20:44 Post subject:
|
|
That's great!
I have bumped HelpSurfer to version 0.2, see blog post:
http://barryk.org/news/?viewDetailed=00635
_________________ https://bkhome.org/news/
|
Back to top
|
|
 |
mavrothal

Joined: 24 Aug 2009 Posts: 3108
|
Posted: Fri 04 Aug 2017, 05:12 Post subject:
|
|
ignor...
_________________ == Here is how to solve your Linux problems fast ==
|
Back to top
|
|
 |
BarryK
Puppy Master

Joined: 09 May 2005 Posts: 9400 Location: Perth, Western Australia
|
Posted: Sun 06 Aug 2017, 21:09 Post subject:
|
|
Have now bumped HelpSurfer to version 0.3.
Source:
http://distro.ibiblio.org/quirky/quirky6/sources/alphabetical/h/helpsurfer-0.3.tar.gz
PET:
http://distro.ibiblio.org/quirky/quirky6/amd64/packages/pet_packages-xerus/helpsurfer-0.3-xerus64.pet
There was something else that I wanted HelpSurfer to be able to do: execute local executables.
This is not a web browser, it is a local help viewer, and although it is not legitimate html, HelpSurfer now supports hyperlinks to
"exec:<executable> <parameters>"
For example:
Code: | <a href="exec:leafpad /usr/share/doc/home.htm">EXECUTE LEAFPAD</a> |
I have a requirement for this feature.
Patch for 0.2 is attached, with a false ".gz" appended.
Thanks to SFR, 'coz I was able to easily see how to extend what he has already done.
Description |
|

Download |
Filename |
helpsurfer-link-executable.patch.gz |
Filesize |
845 Bytes |
Downloaded |
393 Time(s) |
_________________ https://bkhome.org/news/
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 4878 Location: Blue Springs, MO
|
Posted: Mon 07 Aug 2017, 15:05 Post subject:
|
|
I love to see people working on projects like this, but netsurf-framebuffer or even the gtk version is better and smaller... and still actively developed.
The big advantage to the framebuffer version though is that puppy's man pages work in the console. I put together a patch a while back that automatically detected linux framebuffer vs X11(actually xcb) backends... it even works in wayland and any platform with SDL support. Not mention that netsurf now uses duktape for JavaScript support.
If you want something really lite, check out goingnuts Chimera patches.
Regarding the exec "feature", this can be done more securely using cgi scripts on localhost like slitaz does for a lot of their apps (things we typically use gtkdialog for)
#EDIT: added links
_________________ Check out my github repositories. I may eventually get around to updating my blogspot.
Last edited by technosaurus on Tue 08 Aug 2017, 15:51; edited 1 time in total
|
Back to top
|
|
 |
don570

Joined: 10 Mar 2010 Posts: 5524 Location: Ontario
|
Posted: Tue 08 Aug 2017, 12:28 Post subject:
|
|
I don't know how to program but I did make the following observation...
If error messages are removed then more downloaded web pages will open up correctly. For example downloaded murga forum web pages
open nicely (except for images) and plain text files and XML.
What I did was simplify following
Code: | /* surfer_error */
int surfer_error(Surfer * surfer, char const * message, int ret)
{
GtkWidget * dialog;
dialog = gtk_message_dialog_new((surfer != NULL)
? GTK_WINDOW(surfer->window) : NULL,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", message);
gtk_window_set_title(GTK_WINDOW(dialog), "Error");
g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(
gtk_widget_destroy), NULL);
gtk_widget_show(dialog);
return ret;
}
|
to
Code: |
/* surfer_error */
int surfer_error(Surfer * surfer, char const * message, int ret)
{
return ret;
}
|
This gets rid of error message, however I must run 'killall surfer'
in terminal to stop memory filling up when a incompatible page is loaded.
__________________________________________________
|
Back to top
|
|
 |
BarryK
Puppy Master

Joined: 09 May 2005 Posts: 9400 Location: Perth, Western Australia
|
Posted: Tue 08 Aug 2017, 21:28 Post subject:
|
|
A quick post: yesterday I bumped the version to 0.5.
Source:
http://distro.ibiblio.org/quirky/quirky6/sources/alphabetical/h/helpsurfer-0.5.tar.gz
Blog post:
http://barryk.org/news/?viewDetailed=00641
don570,
I will take a look at your suggestion.
_________________ https://bkhome.org/news/
|
Back to top
|
|
 |
|
Page 1 of 2 [28 Posts] |
Goto page: 1, 2 Next |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|