aboutsummaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2004-06-23 01:38:39 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2004-06-23 01:38:39 +0000
commita6bf4adb74ab589d98d6441349727507cbc2c1b1 (patch)
tree41a3cbc1a0804036bf87b13d832dce33a54ae543 /gtk
parent24dec3c04e07dcf374a78b930511dca0877641fc (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')
-rw-r--r--gtk/Makefile.am5
-rw-r--r--gtk/about_dlg.c46
-rw-r--r--gtk/main.h4
-rw-r--r--gtk/webbrowser.c32
-rw-r--r--gtk/webbrowser.h33
5 files changed, 73 insertions, 47 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 96225e31da..727a8eae17 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -1,7 +1,7 @@
# Makefile.am
# Automake file for the GTK interface routines for Ethereal
#
-# $Id: Makefile.am,v 1.103 2004/06/17 16:35:25 ulfl Exp $
+# $Id: Makefile.am,v 1.104 2004/06/23 01:38:39 guy Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@ethereal.com>
@@ -87,7 +87,8 @@ noinst_HEADERS = \
tap_menu.h \
text_page.h \
toolbar.h \
- ui_util.h
+ ui_util.h \
+ webbrowser.h
if USE_GTK2
libui_a_SOURCES = \
diff --git a/gtk/about_dlg.c b/gtk/about_dlg.c
index bdaea2b2ce..bc686f51f5 100644
--- a/gtk/about_dlg.c
+++ b/gtk/about_dlg.c
@@ -1,6 +1,6 @@
/* about_dlg.c
*
- * $Id: about_dlg.c,v 1.16 2004/06/22 21:51:55 guy Exp $
+ * $Id: about_dlg.c,v 1.17 2004/06/23 01:38:39 guy Exp $
*
* Ulf Lamping <ulf.lamping@web.de>
*
@@ -39,7 +39,7 @@
#if GTK_MAJOR_VERSION >= 2 || GTK_MINOR_VERSION >= 3
#include "text_page.h"
#endif
-#include "main.h"
+#include "webbrowser.h"
#include "cvsversion.h"
@@ -311,57 +311,27 @@ url_onlinepage_cb( GtkWidget *widget _U_, gpointer data _U_, onlinepage_action_e
}
}
-extern gchar *
-filename2uri(gchar *filename);
-
-/* browse a file relative to the program dir */
-void
-browser_open_program_file(gchar *filename)
-{
- gchar *uri;
- gchar *prog_path;
- gchar *file_path;
-
-
- /* get ethereal program base dir */
- prog_path = g_strdup(ethereal_path);
- prog_path = get_dirname((char *) prog_path);
-
- /* build filename */
- file_path = g_strdup_printf("%s/%s", prog_path, filename);
-
- /* convert filename to uri */
- uri = filename2uri(file_path);
-
- /* show the uri */
- browser_open_url (uri);
-
- g_free(prog_path);
- g_free(file_path);
- g_free(uri);
-}
-
void
url_localpage_cb( GtkWidget *w _U_, gpointer data _U_, localpage_action_e action)
{
switch(action) {
case(LOCALPAGE_MAN_ETHEREAL):
- browser_open_program_file("ethereal.html");
+ browser_open_data_file("ethereal.html");
break;
case(LOCALPAGE_MAN_ETHEREAL_FILTER):
- browser_open_program_file("ethereal-filter.html");
+ browser_open_data_file("ethereal-filter.html");
break;
case(LOCALPAGE_MAN_TETHEREAL):
- browser_open_program_file("tethereal.html");
+ browser_open_data_file("tethereal.html");
break;
case(LOCALPAGE_MAN_MERGECAP):
- browser_open_program_file("mergecap.html");
+ browser_open_data_file("mergecap.html");
break;
case(LOCALPAGE_MAN_EDITCAP):
- browser_open_program_file("editcap.html");
+ browser_open_data_file("editcap.html");
break;
case(LOCALPAGE_MAN_TEXT2PCAP):
- browser_open_program_file("text2pcap.html");
+ browser_open_data_file("text2pcap.html");
break;
default:
g_assert_not_reached();
diff --git a/gtk/main.h b/gtk/main.h
index 1940fd7eea..205a5fcd8d 100644
--- a/gtk/main.h
+++ b/gtk/main.h
@@ -1,7 +1,7 @@
/* main.h
* Global defines, etc.
*
- * $Id: main.h,v 1.55 2004/06/21 20:12:45 tuexen Exp $
+ * $Id: main.h,v 1.56 2004/06/23 01:38:39 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -250,6 +250,4 @@ extern void packets_bar_update(void);
extern void create_console(void);
#endif
-extern gboolean browser_open_url (const gchar *url);
-
#endif /* __MAIN_H__ */
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);
+}
diff --git a/gtk/webbrowser.h b/gtk/webbrowser.h
new file mode 100644
index 0000000000..e747aa28d9
--- /dev/null
+++ b/gtk/webbrowser.h
@@ -0,0 +1,33 @@
+/* webbrowser.h
+ * Web browser activation functions
+ *
+ * $Id: webbrowser.h,v 1.1 2004/06/23 01:38:39 guy Exp $
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@ethereal.com>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __WEBBROWSER_H__
+#define __WEBBROWSER_H__
+
+extern gboolean browser_open_url (const gchar *url);
+
+/* browse a file relative to the data dir */
+extern void browser_open_data_file (const gchar *filename);
+
+#endif /* __WEBBROWSER_H__ */