summaryrefslogtreecommitdiff
path: root/ui/gtk
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2012-09-18 21:51:22 +0000
committerGerald Combs <gerald@wireshark.org>2012-09-18 21:51:22 +0000
commit8967d312aded15f7cd68f6802b9a5b49549e5e93 (patch)
tree97f7a2d978bf68ecf2902df8a21da90b62938292 /ui/gtk
parent5ee932193f8d420cb1839347769841e82f3d8185 (diff)
downloadwireshark-8967d312aded15f7cd68f6802b9a5b49549e5e93.tar.gz
Move the UI-independent help URL code to ui/help_url.[ch].
svn path=/trunk/; revision=44987
Diffstat (limited to 'ui/gtk')
-rw-r--r--ui/gtk/help_dlg.c272
-rw-r--r--ui/gtk/help_dlg.h84
-rw-r--r--ui/gtk/hostlist_table.c2
-rw-r--r--ui/gtk/uat_gui.c50
-rw-r--r--ui/gtk/webbrowser.c70
-rw-r--r--ui/gtk/webbrowser.h7
6 files changed, 40 insertions, 445 deletions
diff --git a/ui/gtk/help_dlg.c b/ui/gtk/help_dlg.c
index bcb0376f86..262905e794 100644
--- a/ui/gtk/help_dlg.c
+++ b/ui/gtk/help_dlg.c
@@ -26,13 +26,11 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
-#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <gtk/gtk.h>
-#include "epan/filesystem.h"
#include <epan/prefs.h>
#include "ui/simple_dialog.h"
@@ -44,16 +42,8 @@
#include "ui/gtk/dlg_utils.h"
#include "ui/gtk/webbrowser.h"
-#ifdef HHC_DIR
-#include <windows.h>
-#include <htmlhelp.h>
-#include <wsutil/unicode-utils.h>
-#endif
-
#define HELP_DIR "help"
-
-
#define NOTEBOOK_KEY "notebook_key"
/*
@@ -77,52 +67,6 @@ typedef struct {
static GSList *help_text_pages = NULL;
-/*
- * Open the help dialog and show a specific HTML help page.
- */
-void help_topic_html(const gchar *topic) {
- GString *url;
-
- /* try to open local .chm file */
-#ifdef HHC_DIR
- HWND hw;
-
- url = g_string_new("");
-
- g_string_append_printf(url, "%s\\user-guide.chm::/wsug_chm/%s>Wireshark Help",
- get_datafile_dir(), topic);
-
- hw = HtmlHelpW(NULL,
- utf_8to16(url->str),
- HH_DISPLAY_TOPIC, 0);
-
- g_string_free(url, TRUE /* free_segment */);
-
- /* if the .chm file could be opened, stop here */
- if(hw != NULL) {
- return;
- }
-#endif /* HHC_DIR */
-
- url = g_string_new("");
-
-#ifdef DOC_DIR
- if (g_file_test(DOC_DIR "/guides/wsug_html_chunked", G_FILE_TEST_IS_DIR)) {
- /* try to open the HTML page from wireshark.org instead */
- g_string_append_printf(url, "file://" DOC_DIR "/guides/wsug_html_chunked/%s", topic);
- } else {
-#endif /* ifdef DOC_DIR */
- /* try to open the HTML page from wireshark.org instead */
- g_string_append_printf(url, "http://www.wireshark.org/docs/wsug_html_chunked/%s", topic);
-#ifdef DOC_DIR
- }
-#endif /* ifdef DOC_DIR */
-
- browser_open_url(url->str);
-
- g_string_free(url, TRUE /* free_segment */);
-}
-
/**
* Redraw all help pages, to use a new font.
@@ -143,221 +87,16 @@ void help_redraw(void)
}
-const char *
-topic_online_url(topic_action_e action)
-{
- switch(action) {
- case(ONLINEPAGE_HOME):
- return "http://www.wireshark.org";
- break;
- case(ONLINEPAGE_WIKI):
- return "http://wiki.wireshark.org";
- break;
- case(ONLINEPAGE_DOWNLOAD):
- return "http://www.wireshark.org/download.html";
- break;
- case(ONLINEPAGE_USERGUIDE):
- return "http://www.wireshark.org/docs/wsug_html_chunked/";
- break;
- case(ONLINEPAGE_FAQ):
- return "http://www.wireshark.org/faq.html";
- break;
- case(ONLINEPAGE_ASK):
- return "http://ask.wireshark.org";
- break;
- case(ONLINEPAGE_SAMPLE_FILES):
- return "http://wiki.wireshark.org/SampleCaptures";
- break;
- case(ONLINEPAGE_CAPTURE_SETUP):
- return "http://wiki.wireshark.org/CaptureSetup";
- break;
- case(ONLINEPAGE_NETWORK_MEDIA):
- return "http://wiki.wireshark.org/CaptureSetup/NetworkMedia";
- break;
- case(ONLINEPAGE_SAMPLE_CAPTURES):
- return "http://wiki.wireshark.org/SampleCaptures";
- break;
- case(ONLINEPAGE_SECURITY):
- return "http://wiki.wireshark.org/Security";
- break;
- case(ONLINEPAGE_CHIMNEY):
- return "http://wiki.wireshark.org/CaptureSetup/Offloading#chimney";
- break;
- default:
- return NULL;
- }
-}
-
-
static void
topic_action(topic_action_e action)
{
- const char *online_url;
+ char *url;
+ url = topic_action_url(action);
- /* pages online at www.wireshark.org */
- online_url = topic_online_url(action);
- if(online_url != NULL) {
- browser_open_url (online_url);
- return;
- }
-
- switch(action) {
- /* local manual pages */
- case(LOCALPAGE_MAN_WIRESHARK):
- browser_open_data_file("wireshark.html");
- break;
- case(LOCALPAGE_MAN_WIRESHARK_FILTER):
- browser_open_data_file("wireshark-filter.html");
- break;
- case(LOCALPAGE_MAN_TSHARK):
- browser_open_data_file("tshark.html");
- break;
- case(LOCALPAGE_MAN_RAWSHARK):
- browser_open_data_file("rawshark.html");
- break;
- case(LOCALPAGE_MAN_DUMPCAP):
- browser_open_data_file("dumpcap.html");
- break;
- case(LOCALPAGE_MAN_MERGECAP):
- browser_open_data_file("mergecap.html");
- break;
- case(LOCALPAGE_MAN_EDITCAP):
- browser_open_data_file("editcap.html");
- break;
- case(LOCALPAGE_MAN_TEXT2PCAP):
- browser_open_data_file("text2pcap.html");
- break;
-
- /* local help pages (User's Guide) */
- case(HELP_CONTENT):
- help_topic_html( "index.html");
- break;
- case(HELP_CAPTURE_OPTIONS_DIALOG):
- help_topic_html("ChCapCaptureOptions.html");
- break;
- case(HELP_CAPTURE_FILTERS_DIALOG):
- help_topic_html("ChWorkDefineFilterSection.html");
- break;
- case(HELP_DISPLAY_FILTERS_DIALOG):
- help_topic_html("ChWorkDefineFilterSection.html");
- break;
- case(HELP_COLORING_RULES_DIALOG):
- help_topic_html("ChCustColorizationSection.html");
- break;
- case(HELP_CONFIG_PROFILES_DIALOG):
- help_topic_html("ChCustConfigProfilesSection.html");
- break;
- case (HELP_MANUAL_ADDR_RESOLVE_DIALOG):
- help_topic_html("ChManualAddressResolveSection.html");
- break;
- case(HELP_PRINT_DIALOG):
- help_topic_html("ChIOPrintSection.html");
- break;
- case(HELP_FIND_DIALOG):
- help_topic_html("ChWorkFindPacketSection.html");
- break;
- case(HELP_FIREWALL_DIALOG):
- help_topic_html("ChUseToolsMenuSection.html");
- break;
- case(HELP_GOTO_DIALOG):
- help_topic_html("ChWorkGoToPacketSection.html");
- break;
- case(HELP_CAPTURE_INTERFACES_DIALOG):
- help_topic_html("ChCapInterfaceSection.html");
- break;
- case(HELP_CAPTURE_INFO_DIALOG):
- help_topic_html("ChCapRunningSection.html");
- break;
- case(HELP_ENABLED_PROTOCOLS_DIALOG):
- help_topic_html("ChCustProtocolDissectionSection.html");
- break;
- case(HELP_DECODE_AS_DIALOG):
- help_topic_html("ChCustProtocolDissectionSection.html");
- break;
- case(HELP_DECODE_AS_SHOW_DIALOG):
- help_topic_html("ChCustProtocolDissectionSection.html");
- break;
- case(HELP_FOLLOW_STREAM_DIALOG):
- help_topic_html("ChAdvFollowTCPSection.html");
- break;
- case(HELP_EXPERT_INFO_DIALOG):
- help_topic_html("ChAdvExpert.html");
- break;
- case(HELP_STATS_SUMMARY_DIALOG):
- help_topic_html("ChStatSummary.html");
- break;
- case(HELP_STATS_PROTO_HIERARCHY_DIALOG):
- help_topic_html("ChStatHierarchy.html");
- break;
- case(HELP_STATS_ENDPOINTS_DIALOG):
- help_topic_html("ChStatEndpoints.html");
- break;
- case(HELP_STATS_CONVERSATIONS_DIALOG):
- help_topic_html("ChStatConversations.html");
- break;
- case(HELP_STATS_IO_GRAPH_DIALOG):
- help_topic_html("ChStatIOGraphs.html");
- break;
- case(HELP_STATS_COMPARE_FILES_DIALOG):
- help_topic_html("ChStatCompareCaptureFiles.html");
- break;
- case(HELP_STATS_LTE_MAC_TRAFFIC_DIALOG):
- help_topic_html("ChTelLTEMACTraffic.html");
- break;
- case(HELP_STATS_LTE_RLC_TRAFFIC_DIALOG):
- help_topic_html("ChTelLTERLCTraffic.html");
- break;
- case(HELP_STATS_WLAN_TRAFFIC_DIALOG):
- help_topic_html("ChStatWLANTraffic.html");
- break;
- case(HELP_FILESET_DIALOG):
- help_topic_html("ChIOFileSetSection.html");
- break;
- case(HELP_CAPTURE_INTERFACE_OPTIONS_DIALOG):
- help_topic_html("ChCustPreferencesSection.html#ChCustInterfaceOptionsSection");
- break;
- case(HELP_CAPTURE_INTERFACES_DETAILS_DIALOG):
- help_topic_html("ChCapInterfaceDetailsSection.html");
- break;
- case(HELP_PREFERENCES_DIALOG):
- help_topic_html("ChCustPreferencesSection.html");
- break;
- case(HELP_EXPORT_FILE_DIALOG):
- case(HELP_EXPORT_FILE_WIN32_DIALOG):
- help_topic_html("ChIOExportSection.html");
- break;
- case(HELP_EXPORT_BYTES_DIALOG):
- case(HELP_EXPORT_BYTES_WIN32_DIALOG):
- help_topic_html("ChIOExportSection.html#ChIOExportSelectedDialog");
- break;
- case(HELP_EXPORT_OBJECT_LIST):
- help_topic_html("ChIOExportSection.html#ChIOExportObjectsDialog");
- break;
- case(HELP_OPEN_DIALOG):
- case(HELP_OPEN_WIN32_DIALOG):
- help_topic_html("ChIOOpenSection.html");
- break;
- case(HELP_MERGE_DIALOG):
- case(HELP_MERGE_WIN32_DIALOG):
- help_topic_html("ChIOMergeSection.html");
- break;
- case(HELP_IMPORT_DIALOG):
- help_topic_html("ChIOImportSection.html");
- break;
- case(HELP_SAVE_DIALOG):
- case(HELP_SAVE_WIN32_DIALOG):
- help_topic_html("ChIOSaveSection.html");
- break;
- case(HELP_TIME_SHIFT_DIALOG):
- help_topic_html("ChWorkShiftTimePacketSection.html");
- break;
- case(HELP_FILTER_SAVE_DIALOG):
- help_topic_html("ChWorkFilterSaveSection.html");
- break;
-
- default:
- g_assert_not_reached();
+ if(url != NULL) {
+ browser_open_url(url);
+ g_free(url);
}
}
@@ -375,4 +114,3 @@ topic_menu_cb(GtkWidget *w _U_, GdkEventButton *event _U_, gpointer user_data)
topic_action((topic_action_e)GPOINTER_TO_INT(user_data));
return TRUE;
}
-
diff --git a/ui/gtk/help_dlg.h b/ui/gtk/help_dlg.h
index ed8ddd0355..955c7b83f5 100644
--- a/ui/gtk/help_dlg.h
+++ b/ui/gtk/help_dlg.h
@@ -27,85 +27,13 @@
#ifndef __HELP_DLG_H__
#define __HELP_DLG_H__
+#include "ui/help_url.h"
+
/** @file
* "Help" dialog box.
* @ingroup dialog_group
*/
-typedef enum {
- /* pages online at www.wireshark.org */
- ONLINEPAGE_HOME,
- ONLINEPAGE_WIKI,
- ONLINEPAGE_USERGUIDE,
- ONLINEPAGE_FAQ,
- ONLINEPAGE_DOWNLOAD,
- ONLINEPAGE_SAMPLE_FILES,
- ONLINEPAGE_CAPTURE_SETUP,
- ONLINEPAGE_NETWORK_MEDIA,
- ONLINEPAGE_SAMPLE_CAPTURES,
- ONLINEPAGE_SECURITY,
- ONLINEPAGE_CHIMNEY,
- ONLINEPAGE_ASK,
-
- /* local manual pages */
- LOCALPAGE_MAN_WIRESHARK = 100,
- LOCALPAGE_MAN_WIRESHARK_FILTER,
- LOCALPAGE_MAN_TSHARK,
- LOCALPAGE_MAN_RAWSHARK,
- LOCALPAGE_MAN_DUMPCAP,
- LOCALPAGE_MAN_MERGECAP,
- LOCALPAGE_MAN_EDITCAP,
- LOCALPAGE_MAN_TEXT2PCAP,
-
- /* help pages (textfiles or local HTML User's Guide) */
- HELP_CONTENT = 200,
- HELP_GETTING_STARTED, /* currently unused */
- HELP_CAPTURE_OPTIONS_DIALOG,
- HELP_CAPTURE_FILTERS_DIALOG,
- HELP_DISPLAY_FILTERS_DIALOG,
- HELP_COLORING_RULES_DIALOG,
- HELP_CONFIG_PROFILES_DIALOG,
- HELP_MANUAL_ADDR_RESOLVE_DIALOG,
- HELP_PRINT_DIALOG,
- HELP_FIND_DIALOG,
- HELP_FILESET_DIALOG,
- HELP_FIREWALL_DIALOG,
- HELP_GOTO_DIALOG,
- HELP_CAPTURE_INTERFACES_DIALOG,
- HELP_ENABLED_PROTOCOLS_DIALOG,
- HELP_DECODE_AS_DIALOG,
- HELP_DECODE_AS_SHOW_DIALOG,
- HELP_FOLLOW_STREAM_DIALOG,
- HELP_EXPERT_INFO_DIALOG,
- HELP_STATS_SUMMARY_DIALOG,
- HELP_STATS_PROTO_HIERARCHY_DIALOG,
- HELP_STATS_ENDPOINTS_DIALOG,
- HELP_STATS_CONVERSATIONS_DIALOG,
- HELP_STATS_IO_GRAPH_DIALOG,
- HELP_STATS_COMPARE_FILES_DIALOG,
- HELP_STATS_LTE_MAC_TRAFFIC_DIALOG,
- HELP_STATS_LTE_RLC_TRAFFIC_DIALOG,
- HELP_STATS_WLAN_TRAFFIC_DIALOG,
- HELP_CAPTURE_INTERFACE_OPTIONS_DIALOG,
- HELP_CAPTURE_INTERFACES_DETAILS_DIALOG,
- HELP_PREFERENCES_DIALOG,
- HELP_CAPTURE_INFO_DIALOG,
- HELP_EXPORT_FILE_DIALOG,
- HELP_EXPORT_BYTES_DIALOG,
- HELP_EXPORT_OBJECT_LIST,
- HELP_OPEN_DIALOG,
- HELP_MERGE_DIALOG,
- HELP_IMPORT_DIALOG,
- HELP_SAVE_DIALOG,
- HELP_EXPORT_FILE_WIN32_DIALOG,
- HELP_EXPORT_BYTES_WIN32_DIALOG,
- HELP_OPEN_WIN32_DIALOG,
- HELP_MERGE_WIN32_DIALOG,
- HELP_SAVE_WIN32_DIALOG,
- HELP_TIME_SHIFT_DIALOG,
- HELP_FILTER_SAVE_DIALOG
-} topic_action_e;
-
/** Open a specific topic (create a "Help" dialog box or open a webpage).
*
@@ -126,12 +54,4 @@ gboolean topic_menu_cb(GtkWidget *widget _U_, GdkEventButton *event _U_, gpointe
/** Redraw all the help dialog text widgets, to use a new font. */
void help_redraw(void);
-
-/** Open the help dialog and show a specific HTML help page. */
-void help_topic_html(const gchar *topic);
-
-/** get the url string of one of the ONLINEPAGE_xxx values */
-const char *topic_online_url(topic_action_e action);
-
-
#endif
diff --git a/ui/gtk/hostlist_table.c b/ui/gtk/hostlist_table.c
index bfe8d5ff7c..907f8a1305 100644
--- a/ui/gtk/hostlist_table.c
+++ b/ui/gtk/hostlist_table.c
@@ -1156,7 +1156,7 @@ open_as_map_cb(GtkWindow *copy_bt, gpointer data _U_)
}
/* open the webbrowser */
- file_uri = filename2uri(map_filename);
+ file_uri = g_filename_to_uri(map_filename, NULL, NULL);
g_free(map_filename);
uri_open = browser_open_url (file_uri);
if(!uri_open) {
diff --git a/ui/gtk/uat_gui.c b/ui/gtk/uat_gui.c
index 3cfee08015..5b7816965a 100644
--- a/ui/gtk/uat_gui.c
+++ b/ui/gtk/uat_gui.c
@@ -5,23 +5,23 @@
*
* User Accessible Tables GUI
* Mantain an array of user accessible data strucures
- *
+ *
* (c) 2007, Luis E. Garcia Ontanon <luis@ontanon.org>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 2001 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
@@ -61,15 +61,16 @@
#include "../stat_menu.h"
+#include "ui/help_url.h"
#include "ui/gtk/gtkglobals.h"
#include "ui/gtk/gui_utils.h"
#include "ui/gtk/dlg_utils.h"
-#include "ui/gtk/help_dlg.h"
#include "ui/gtk/stock_icons.h"
#include "ui/gtk/gui_stat_menu.h"
#include "ui/gtk/main.h"
#include "ui/gtk/uat_gui.h"
#include "ui/gtk/packet_list.h"
+#include "ui/gtk/webbrowser.h"
#include "ui/gtk/old-gtk-compat.h"
# define BUTTON_SIZE_X -1
@@ -167,14 +168,14 @@ static char* fld_tostr(void* rec, uat_field_t* f) {
case PT_TXTMOD_HEXBYTES: {
GString* s = g_string_sized_new( len*2 + 1 );
guint i;
-
+
for (i=0; i<len;i++) g_string_append_printf(s,"%.2X",((guint8*)ptr)[i]);
-
+
out = ep_strdup(s->str);
-
+
g_string_free(s,TRUE);
break;
- }
+ }
default:
g_assert_not_reached();
out = NULL;
@@ -276,7 +277,7 @@ static guint8* unhexbytes(const char* si, guint len, guint* len_p, const char**
*err = NULL;
return buf;
-
+
on_error:
*err = "Error parsing hex string";
return NULL;
@@ -366,7 +367,7 @@ static gboolean uat_dlg_cb(GtkWidget *win _U_, gpointer user_data) {
g_free(rec_tmp);
}
-
+
dd->uat->changed = TRUE;
set_buttons(dd->uat, dd->uat->rep ? dd->uat->rep->selected : -1);
@@ -421,7 +422,7 @@ static void uat_edit_dialog(uat_t* uat, gint row, gboolean copy) {
struct _uat_dlg_data* dd = g_malloc(sizeof(struct _uat_dlg_data));
uat_field_t* f = uat->fields;
guint colnum;
-
+
dd->entries = g_ptr_array_new();
dd->win = dlg_conf_window_new(ep_strdup_printf("%s: %s", uat->name, (row == -1 ? "New" : "Edit")));
dd->uat = uat;
@@ -514,7 +515,7 @@ static void uat_edit_dialog(uat_t* uat, gint row, gboolean copy) {
for (idx = 0; enum_vals[idx].strptr != NULL; idx++) {
const char* str = enum_vals[idx].strptr;
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(combo_box), str);
-
+
if ( g_str_equal(str, text) ) {
*valptr = idx;
}
@@ -536,7 +537,7 @@ static void uat_edit_dialog(uat_t* uat, gint row, gboolean copy) {
return;
}
}
-
+
gtk_widget_grab_default(bt_ok);
gtk_widget_show_all(win);
}
@@ -591,7 +592,7 @@ static void uat_del_dlg(uat_t* uat, int idx) {
ud->uat = uat;
ud->idx = idx;
ud->win = win = dlg_conf_window_new(ep_strdup_printf("%s: Confirm Delete", uat->name));
-
+
gtk_window_set_resizable(GTK_WINDOW(win),FALSE);
gtk_window_resize(GTK_WINDOW(win),400,25*(uat->ncols+2));
@@ -611,7 +612,7 @@ static void uat_del_dlg(uat_t* uat, int idx) {
label = gtk_label_new(ep_strdup_printf("%s:", f[colnum].title));
gtk_misc_set_alignment(GTK_MISC(label), 1.0f, 0.5f);
gtk_table_attach_defaults(GTK_TABLE(main_tb), label, 0, 1, colnum+1, colnum + 2);
-
+
label = gtk_label_new(text);
gtk_misc_set_alignment(GTK_MISC(label), 1.0f, 0.5f);
gtk_table_attach_defaults(GTK_TABLE(main_tb), label, 1, 2, colnum+1, colnum + 2);
@@ -668,7 +669,7 @@ static void uat_delete_cb(GtkButton *button _U_, gpointer u) {
static gboolean uat_window_delete_event_cb(GtkWindow *w _U_, GdkEvent* e _U_, gpointer u) {
uat_t* uat = u;
-
+
if (uat->rep) {
void* rep = uat->rep;
@@ -900,7 +901,15 @@ static gboolean unsaved_dialog(GtkWindow *w _U_, GdkEvent* e _U_, gpointer u) {
}
static void uat_help_cb(GtkWidget* w _U_, gpointer u) {
- help_topic_html(ep_strdup_printf("%s.html",((uat_t*)u)->help));
+ gchar *help_page, *url;
+
+ help_page = g_strdup_printf("%s.html",((uat_t*)u)->help);
+ url = user_guide_url(help_page);
+ if (url) {
+ browser_open_url(url);
+ }
+ g_free(help_page);
+ g_free(url);
}
static GtkWidget* uat_window(void* u) {
@@ -988,7 +997,7 @@ static GtkWidget* uat_window(void* u) {
} else {
rep->bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_APPLY, GTK_STOCK_CANCEL, NULL);
- }
+ }
move_hbox = gtk_button_box_new(GTK_ORIENTATION_VERTICAL);
gtk_box_pack_start(GTK_BOX(vbox), move_hbox, TRUE, FALSE, 0);
@@ -1078,7 +1087,7 @@ static GtkWidget* uat_window(void* u) {
g_signal_connect(GTK_WINDOW(rep->window), "delete_event", G_CALLBACK(uat_window_delete_event_cb), uat);
g_signal_connect(GTK_WINDOW(rep->window), "destroy", G_CALLBACK(uat_window_delete_event_cb), uat);
}
-
+
gtk_widget_grab_focus(GTK_WIDGET(rep->list));
gtk_widget_show_all(rep->window);
@@ -1090,4 +1099,3 @@ static GtkWidget* uat_window(void* u) {
void uat_window_cb(GtkWidget* u _U_, void* uat) {
uat_window(uat);
}
-
diff --git a/ui/gtk/webbrowser.c b/ui/gtk/webbrowser.c
index 196efdf04d..06514c2ddc 100644
--- a/ui/gtk/webbrowser.c
+++ b/ui/gtk/webbrowser.c
@@ -76,6 +76,7 @@
#include <epan/prefs.h>
#include "ui/simple_dialog.h"
+#include "ui/help_url.h"
#include "ui/gtk/webbrowser.h"
@@ -262,55 +263,6 @@ browser_open_url (const gchar *url)
#endif
}
-/** Convert local absolute path to uri.
- *
- * @param filename to (absolute pathed) filename to convert
- * @return a newly allocated uri, you must g_free it later
- */
-gchar *
-filename2uri(const gchar *filename)
-{
- int i = 0;
- gchar *file_tmp;
- GString *filestr;
-
-
- filestr = g_string_sized_new(200);
-
- /* this escaping is somewhat slow but should working fine */
- for(i=0; filename[i]; i++) {
- switch(filename[i]) {
- case(' '):
- g_string_append(filestr, "%20");
- break;
- case('%'):
- g_string_append(filestr, "%%");
- break;
- case('\\'):
- g_string_append_c(filestr, '/');
- break;
- /* XXX - which other chars need to be escaped? */
- default:
- g_string_append_c(filestr, filename[i]);
- }
- }
-
-
- /* prepend URI header "file:" appropriate for the system */
-#ifdef G_OS_WIN32
- /* 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://");
-#endif
-
- file_tmp = filestr->str;
-
- g_string_free(filestr, FALSE /* don't free segment data */);
-
- return file_tmp;
-}
-
gboolean
filemanager_open_directory (const gchar *path)
{
@@ -414,7 +366,7 @@ filemanager_open_directory (const gchar *path)
}
/* conver the path to a URI */
- argument = filename2uri (path);
+ argument = g_filename_to_uri(path);
/* replace %s with URL */
if (strstr (browser, "%s"))
@@ -491,30 +443,14 @@ strreplace (const gchar *string,
void
browser_open_data_file(const gchar *filename)
{
- gchar *file_path;
gchar *uri;
- /* build filename */
-#ifdef G_OS_WIN32
- if((strlen(filename) > 2) && (filename[1] == ':'))
- file_path = g_strdup(filename);
-#else
- /* XXX: is this correct for MacOS/Linux ? */
- if((strlen(filename) > 1) && (filename[0] == '/'))
- file_path = g_strdup(filename);
-#endif
- else
-
- file_path = g_strdup_printf("%s/%s", get_datafile_dir(), filename);
-
/* XXX - check, if the file is really existing, otherwise display a simple_dialog about the problem */
- /* convert filename to uri */
- uri = filename2uri(file_path);
+ uri = data_file_url(filename);
/* show the uri */
browser_open_url (uri);
- g_free(file_path);
g_free(uri);
}
diff --git a/ui/gtk/webbrowser.h b/ui/gtk/webbrowser.h
index 1436f84aab..7e4b1c0ef7 100644
--- a/ui/gtk/webbrowser.h
+++ b/ui/gtk/webbrowser.h
@@ -34,11 +34,4 @@ extern gboolean filemanager_open_directory (const gchar *path);
/* browse a file relative to the data dir */
extern void browser_open_data_file (const gchar *filename);
-/** Convert local absolute path to uri.
- *
- * @param filename to (absolute pathed) filename to convert
- * @return a newly allocated uri, you must g_free it later
- */
-extern gchar *filename2uri(const gchar *filename);
-
#endif /* __WEBBROWSER_H__ */