diff options
author | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2004-06-23 01:38:39 +0000 |
---|---|---|
committer | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2004-06-23 01:38:39 +0000 |
commit | a6bf4adb74ab589d98d6441349727507cbc2c1b1 (patch) | |
tree | 41a3cbc1a0804036bf87b13d832dce33a54ae543 /gtk/webbrowser.c | |
parent | 24dec3c04e07dcf374a78b930511dca0877641fc (diff) |
Add "gtk/webbrowser.h" to declare functions from "gtk/webbrowser.c".
Rename "browser_open_program_file()" to "browser_open_data_file()", and
make it open files relative to the application's data directory, as
that's where data files such as HTMLized man pages would be put. (That
happens to be the program directory on Windows, but it's a different
directory on UN*X - and you aren't guaranteed to be able to find the
program directory on UN*X by looking at argv[0] in any case.) Move it
to "gtk/webbrowser.c".
Fix "filename2url()" to put "file://", not just "file:", in front of
pathnames on UN*X.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@11216 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'gtk/webbrowser.c')
-rw-r--r-- | gtk/webbrowser.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/gtk/webbrowser.c b/gtk/webbrowser.c index 21f26dd6a8..bad106a388 100644 --- a/gtk/webbrowser.c +++ b/gtk/webbrowser.c @@ -32,6 +32,10 @@ #include <glib.h> +#include <epan/filesystem.h> + +#include "webbrowser.h" + #if defined(G_OS_WIN32) /* Win32 - use Windows shell services to start a browser */ #include <windows.h> @@ -77,7 +81,7 @@ browser_open_url (const gchar *url) * XXX - this is a Launch Services result code, and we should probably * display a dialog box if it's not 0, describing what the error was. * Then again, we should probably do the same for the ShellExecute call, - * unless that call itself happens to pop up a dialog box. + * unless that call itself happens to pop up a dialog box for all errors. */ status = LSOpenCFURLRef(url_CFURL, NULL); CFRelease(url_CFURL); @@ -175,7 +179,7 @@ strreplace (const gchar *string, * @param filename to (absolute pathed) filename to convert * @return a newly allocated uri, you must g_free it later */ -gchar * +static gchar * filename2uri(gchar *filename) { int i = 0; @@ -209,7 +213,7 @@ filename2uri(gchar *filename) /* XXX - how do we handle UNC names (e.g. //servername/sharename/dir1/dir2/capture-file.cap) */ g_string_prepend(filestr, "file:///"); #else - g_string_prepend(filestr, "file:"); + g_string_prepend(filestr, "file://"); #endif file_tmp = filestr->str; @@ -217,4 +221,24 @@ filename2uri(gchar *filename) g_string_free(filestr, FALSE /* don't free segment data */); return file_tmp; -}
\ No newline at end of file +} + +/* browse a file relative to the data dir */ +void +browser_open_data_file(const gchar *filename) +{ + gchar *file_path; + gchar *uri; + + /* build filename */ + file_path = g_strdup_printf("%s/%s", get_datafile_dir(), filename); + + /* convert filename to uri */ + uri = filename2uri(file_path); + + /* show the uri */ + browser_open_url (uri); + + g_free(file_path); + g_free(uri); +} |