X-Git-Url: http://git.samba.org/samba.git/?a=blobdiff_plain;f=gtk%2Fhelp_dlg.c;h=8a7a302af59c7a08613ae1a85fc77100f817d97c;hb=fcaf4af1e3dc77c14898842a36f86b8441446303;hp=8327b3a69453a1759a7fea0c2f352f444019d26f;hpb=36079958eb884b5b0618bd171c36e89295c58c5a;p=obnox%2Fwireshark%2Fwip.git diff --git a/gtk/help_dlg.c b/gtk/help_dlg.c index 8327b3a694..8a7a302af5 100644 --- a/gtk/help_dlg.c +++ b/gtk/help_dlg.c @@ -4,8 +4,8 @@ * * Laurent Deniel * - * Ethereal - Network traffic analyzer - * By Gerald Combs + * Wireshark - Network traffic analyzer + * By Gerald Combs * Copyright 2000 Gerald Combs * * This program is free software; you can redistribute it and/or @@ -37,19 +37,25 @@ #include "text_page.h" #include #include "gtkglobals.h" -#include "ui_util.h" +#include "gui_utils.h" #include "compat_macros.h" #include "dlg_utils.h" #include "simple_dialog.h" #include "webbrowser.h" +#include "file_util.h" + +#ifdef HHC_DIR +#include +#include +#include "epan/unicode-utils.h" +#endif + #define HELP_DIR "help" #define NOTEBOOK_KEY "notebook_key" -static void help_destroy_cb(GtkWidget *w, gpointer data); - /* * Keep a static pointer to the current "Help" window, if any, so that * if somebody tries to do "Help->Help" while there's already a @@ -71,6 +77,84 @@ typedef struct { static GSList *help_text_pages = NULL; + +gboolean topic_available(topic_action_e action) { + +#if (GLIB_MAJOR_VERSION >= 2) + if(action == HELP_CAPTURE_INTERFACES_DETAILS_DIALOG) { + /* XXX - add the page HELP_CAPTURE_INTERFACES_DETAILS_DIALOG and remove this if */ + /* page currently not existing in user's guide */ + return FALSE; + } + /* online: we have almost all possible pages available */ + return TRUE; +#else + /* offline: we have only some pages available */ + switch(action) { + case(HELP_CONTENT): + return TRUE; + break; + case(HELP_GETTING_STARTED): + return TRUE; + break; + case(HELP_CAPTURE_OPTIONS_DIALOG): + return TRUE; + break; + case(HELP_CAPTURE_FILTERS_DIALOG): + return TRUE; + break; + case(HELP_DISPLAY_FILTERS_DIALOG): + return TRUE; + break; + default: + return FALSE; + } +#endif +} + + +#if (GLIB_MAJOR_VERSION >= 2) +/* + * 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(""); + + /* 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); + + browser_open_url(url->str); + + g_string_free(url, TRUE /* free_segment */); +} +#endif + + +#if (GLIB_MAJOR_VERSION < 2) /* * Helper function to show a simple help text page. */ @@ -96,6 +180,30 @@ static GtkWidget * help_page(const char *topic, const char *filename) } +/* + * Help dialog is closed now. + */ +static void help_destroy_cb(GtkWidget *w _U_, gpointer data _U_) +{ + GSList *help_page_ent; + help_page_t *page; + + /* Free up the list of help pages. */ + for (help_page_ent = help_text_pages; help_page_ent != NULL; + help_page_ent = g_slist_next(help_page_ent)) { + page = (help_page_t *)help_page_ent->data; + g_free(page->topic); + g_free(page->pathname); + g_free(page); + } + g_slist_free(help_text_pages); + help_text_pages = NULL; + + /* Note that we no longer have a Help window. */ + help_w = NULL; +} + + /* * Create and show help dialog. */ @@ -116,7 +224,7 @@ void help_dialog(void) } help_toc_file_path = get_datafile_path(HELP_DIR G_DIR_SEPARATOR_S "toc"); - help_toc_file = fopen(help_toc_file_path, "r"); + help_toc_file = eth_fopen(help_toc_file_path, "r"); if (help_toc_file == NULL) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Could not open file \"%s\": %s", help_toc_file_path, strerror(errno)); @@ -124,7 +232,7 @@ void help_dialog(void) return; } - help_w = window_new_with_geom(GTK_WINDOW_TOPLEVEL, "Ethereal: Help", "help"); + help_w = window_new_with_geom(GTK_WINDOW_TOPLEVEL, "Wireshark: Help", "help"); gtk_window_set_default_size(GTK_WINDOW(help_w), DEF_WIDTH, DEF_HEIGHT); gtk_container_border_width(GTK_CONTAINER(help_w), 2); @@ -184,39 +292,10 @@ void help_dialog(void) } /* help_dialog */ -gboolean topic_available(topic_action_e action) { - -#ifdef ETHEREAL_EUG_DIR - /* online: we have all pages available */ - return TRUE; -#else - /* offline: we have only some pages available */ - switch(action) { - case(HELP_CONTENT): - return TRUE; - break; - case(HELP_GETTING_STARTED): - return TRUE; - break; - case(HELP_CAPTURE_OPTIONS_DIALOG): - return TRUE; - break; - case(HELP_CAPTURE_FILTERS_DIALOG): - return TRUE; - break; - case(HELP_DISPLAY_FILTERS_DIALOG): - return TRUE; - break; - default: - return FALSE; - } -#endif -} - /* - * Open the help dialog and show a specific help page. + * Open the help dialog and show a specific GTK help page. */ -void help_topic(gchar *topic) { +static void help_topic_gtk(const gchar *topic) { gchar *page_topic; GtkWidget *help_nb; GSList *help_page_ent; @@ -245,30 +324,7 @@ void help_topic(gchar *topic) { /* topic page not found, default (first page) will be shown */ } - - -/* - * Help dialog is closed now. - */ -static void help_destroy_cb(GtkWidget *w _U_, gpointer data _U_) -{ - GSList *help_page_ent; - help_page_t *page; - - /* Free up the list of help pages. */ - for (help_page_ent = help_text_pages; help_page_ent != NULL; - help_page_ent = g_slist_next(help_page_ent)) { - page = (help_page_t *)help_page_ent->data; - g_free(page->topic); - g_free(page->pathname); - g_free(page); - } - g_slist_free(help_text_pages); - help_text_pages = NULL; - - /* Note that we no longer have a Help window. */ - help_w = NULL; -} +#endif /* GLIB_MAJOR_VERSION < 2 */ /** @@ -293,36 +349,42 @@ void help_redraw(void) static void topic_action(topic_action_e action) { - /* pages online at www.ethereal.com */ + /* pages online at www.wireshark.org */ switch(action) { case(ONLINEPAGE_HOME): - browser_open_url ("http://www.ethereal.com"); + browser_open_url ("http://www.wireshark.org"); break; case(ONLINEPAGE_WIKI): - browser_open_url ("http://wiki.ethereal.com"); + browser_open_url ("http://wiki.wireshark.org"); break; case(ONLINEPAGE_DOWNLOAD): - browser_open_url ("http://www.ethereal.com/download.html"); + browser_open_url ("http://www.wireshark.org/download/"); break; case(ONLINEPAGE_USERGUIDE): - browser_open_url ("http://www.ethereal.com/docs/user-guide"); + browser_open_url ("http://www.wireshark.org/docs/wsug_html_chunked/"); break; case(ONLINEPAGE_FAQ): - browser_open_url ("http://www.ethereal.com/faq.html"); + browser_open_url ("http://www.wireshark.org/faq.html"); break; case(ONLINEPAGE_SAMPLE_FILES): - browser_open_url ("http://wiki.ethereal.com/SampleCaptures"); + browser_open_url ("http://wiki.wireshark.org/SampleCaptures"); break; /* local manual pages */ - case(LOCALPAGE_MAN_ETHEREAL): - browser_open_data_file("ethereal.html"); + 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_ETHEREAL_FILTER): - browser_open_data_file("ethereal-filter.html"); + case(LOCALPAGE_MAN_TSHARK): + browser_open_data_file("tshark.html"); break; - case(LOCALPAGE_MAN_TETHEREAL): - browser_open_data_file("tethereal.html"); + 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"); @@ -334,80 +396,124 @@ topic_action(topic_action_e action) browser_open_data_file("text2pcap.html"); break; -#ifdef ETHEREAL_EUG_DIR +#if (GLIB_MAJOR_VERSION >= 2) /* local help pages (User's Guide) */ case(HELP_CONTENT): - browser_open_data_file("eug_html_chunked/index.html"); + help_topic_html( "index.html"); break; case(HELP_CAPTURE_OPTIONS_DIALOG): - browser_open_data_file("eug_html_chunked/ChCapCaptureOptions.html"); + help_topic_html("ChCapCaptureOptions.html"); break; case(HELP_CAPTURE_FILTERS_DIALOG): - browser_open_data_file("eug_html_chunked/ChWorkDefineFilterSection.html"); + help_topic_html("ChWorkDefineFilterSection.html"); break; case(HELP_DISPLAY_FILTERS_DIALOG): - browser_open_data_file("eug_html_chunked/ChWorkDefineFilterSection.html"); + help_topic_html("ChWorkDefineFilterSection.html"); break; case(HELP_COLORING_RULES_DIALOG): - browser_open_data_file("eug_html_chunked/ChCustColorizationSection.html"); + help_topic_html("ChCustColorizationSection.html"); + break; + case(HELP_CONFIG_PROFILES_DIALOG): + help_topic_html("ChCustConfigProfilesSection.html"); break; case(HELP_PRINT_DIALOG): - browser_open_data_file("eug_html_chunked/ChIOPrintSection.html"); + help_topic_html("ChIOPrintSection.html"); break; case(HELP_FIND_DIALOG): - browser_open_data_file("eug_html_chunked/ChWorkFindPacketSection.html"); + help_topic_html("ChWorkFindPacketSection.html"); break; case(HELP_GOTO_DIALOG): - browser_open_data_file("eug_html_chunked/ChWorkGoToPacketSection.html"); + help_topic_html("ChWorkGoToPacketSection.html"); break; case(HELP_CAPTURE_INTERFACES_DIALOG): - browser_open_data_file("eug_html_chunked/ChCapInterfaceSection.html"); + help_topic_html("ChCapInterfaceSection.html"); + break; + case(HELP_CAPTURE_INFO_DIALOG): + help_topic_html("ChCapRunningSection.html"); break; case(HELP_ENABLED_PROTOCOLS_DIALOG): - browser_open_data_file("eug_html_chunked/ChCustProtocolDissectionSection.html"); + help_topic_html("ChCustProtocolDissectionSection.html"); break; case(HELP_DECODE_AS_DIALOG): - browser_open_data_file("eug_html_chunked/ChCustProtocolDissectionSection.html"); + help_topic_html("ChCustProtocolDissectionSection.html"); break; case(HELP_DECODE_AS_SHOW_DIALOG): - browser_open_data_file("eug_html_chunked/ChCustProtocolDissectionSection.html"); + help_topic_html("ChCustProtocolDissectionSection.html"); break; case(HELP_FOLLOW_TCP_STREAM_DIALOG): - browser_open_data_file("eug_html_chunked/ChAdvFollowTCPSection.html"); + help_topic_html("ChAdvFollowTCPSection.html"); + break; + case(HELP_EXPERT_INFO_DIALOG): + help_topic_html("ChAdvExpert.html"); break; case(HELP_STATS_SUMMARY_DIALOG): - browser_open_data_file("eug_html_chunked/ChStatSummary.html"); + help_topic_html("ChStatSummary.html"); break; case(HELP_STATS_PROTO_HIERARCHY_DIALOG): - browser_open_data_file("eug_html_chunked/ChStatHierarchy.html"); + help_topic_html("ChStatHierarchy.html"); break; case(HELP_STATS_ENDPOINTS_DIALOG): - browser_open_data_file("eug_html_chunked/ChStatEndpoints.html"); + help_topic_html("ChStatEndpoints.html"); break; case(HELP_STATS_CONVERSATIONS_DIALOG): - browser_open_data_file("eug_html_chunked/ChStatConversations.html"); + help_topic_html("ChStatConversations.html"); break; case(HELP_STATS_IO_GRAPH_DIALOG): - browser_open_data_file("eug_html_chunked/ChStatIOGraphs.html"); + help_topic_html("ChStatIOGraphs.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_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_SAVE_DIALOG): + case(HELP_SAVE_WIN32_DIALOG): + help_topic_html("ChIOSaveSection.html"); break; #else /* only some help pages are available for offline reading */ case(HELP_CONTENT): - help_topic("Overview"); + help_topic_gtk("Overview"); break; case(HELP_GETTING_STARTED): - help_topic("Getting Started"); + help_topic_gtk("Getting Started"); break; case(HELP_CAPTURE_OPTIONS_DIALOG): - help_topic("Capturing"); + help_topic_gtk("Capturing"); break; case(HELP_CAPTURE_FILTERS_DIALOG): - help_topic("Capture Filters"); + help_topic_gtk("Capture Filters"); break; case(HELP_DISPLAY_FILTERS_DIALOG): - help_topic("Display Filters"); + help_topic_gtk("Display Filters"); break; -#endif +#endif /* GLIB_MAJOR_VERSION */ default: g_assert_not_reached(); @@ -415,13 +521,13 @@ topic_action(topic_action_e action) } -void +void topic_cb(GtkWidget *w _U_, topic_action_e action) { topic_action(action); } -void +void topic_menu_cb(GtkWidget *w _U_, gpointer data _U_, topic_action_e action) { topic_action(action); }