ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: Re: [Wireshark-dev] [Wireshark-commits] rev 38772: /trunk/gtk/ /trunk/gtk/: main

From: Joerg Mayer <jmayer@xxxxxxxxx>
Date: Mon, 29 Aug 2011 15:42:25 +0200
and the patch I forgot to attach....
-- 
Joerg Mayer                                           <jmayer@xxxxxxxxx>
We are stuck with technology when what we really want is just stuff that
works. Some say that should read Microsoft instead of technology.
Index: print.c
===================================================================
--- print.c	(revision 38773)
+++ print.c	(working copy)
@@ -254,7 +254,7 @@
 
 	fputs("<?xml version=\"1.0\"?>\n", fh);
 	fputs("<?xml-stylesheet type=\"text/xsl\" href=\"" PDML2HTML_XSL "\"?>\n", fh);
-	fprintf(fh, "<!-- You can find " PDML2HTML_XSL " in %s or at http://anonsvn.wireshark.org/trunk/wireshark/"; PDML2HTML_XSL ". -->\n", get_datafile_dir());
+	fprintf(fh, "<!-- You can find " PDML2HTML_XSL " in %s or at http://anonsvn.wireshark.org/trunk/wireshark/"; PDML2HTML_XSL ". -->\n", get_datafile_dir(NULL));
 	fputs("<pdml version=\"" PDML_VERSION "\" ", fh);
 	fprintf(fh, "creator=\"%s/%s\" time=\"%s\" capture_file=\"%s\">\n", PACKAGE, VERSION, ts, filename ? filename : "");
 }
Index: gtk/main_menubar.c
===================================================================
--- gtk/main_menubar.c	(revision 38773)
+++ gtk/main_menubar.c	(working copy)
@@ -948,6 +948,7 @@
  	topic_menu_cb( NULL/* widget_U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(ONLINEPAGE_SAMPLE_FILES));
 }
 
+#ifndef NEW_MENU_CODE
 static const char *ui_desc_menubar =
 "<ui>\n"
 "  <menubar name ='Menubar'>\n"
@@ -1329,6 +1330,7 @@
 "    </menu>\n"
 "  </menubar>\n"
 "</ui>\n";
+#endif
 
 
 /*
@@ -2827,6 +2829,7 @@
 
 };
 
+#ifndef NEW_MENU_CODE
 static const char *ui_desc_tree_view_menu_popup =
 "<ui>\n"
 "  <popup name='TreeViewPopup' action='PopupAction'>\n"
@@ -2898,6 +2901,7 @@
 "     <menuitem name='GotoCorrespondingPacket' action='/GotoCorrespondingPacket'/>\n"
 "  </popup>\n"
 "</ui>\n";
+#endif
 
 static const GtkActionEntry tree_view_menu_popup_action_entries[] = {
   { "/ExpandSubtrees",					NULL,							"Expand Subtrees",		NULL,					NULL,			G_CALLBACK(expand_tree_cb) },
@@ -2965,6 +2969,7 @@
   { "/GotoCorrespondingPacket",						NULL,		"_Go to Corresponding Packet",			NULL, NULL, G_CALLBACK(goto_framenum_cb) },
 };
 
+#ifndef NEW_MENU_CODE
 static const char *ui_desc_bytes_menu_popup =
 "<ui>\n"
 "  <popup name='BytesMenuPopup' action='PopupAction'>\n"
@@ -2972,6 +2977,8 @@
 "     <menuitem name='BitsView' action='/BitsView'/>\n"
 "  </popup>\n"
 "</ui>\n";
+#endif
+
 static const GtkRadioActionEntry bytes_menu_radio_action_entries [] =
 {
 	/* name,	stock id,	label,		accel,	tooltip,  value */
@@ -3212,7 +3219,9 @@
         *statusbar_profiles_action_group;
     GError *error = NULL;
     guint merge_id;
-	/*char *gui_desc_file_name;*/
+#ifdef NEW_MENU_CODE
+    char *gui_desc_file_name;
+#endif
 
     if (initialize) {
         initialize = FALSE;
@@ -3293,10 +3302,12 @@
         gtk_ui_manager_insert_action_group (ui_manager_tree_view_menu,
             packet_list_details_action_group,
             0); /* the position at which the group will be inserted.  */
-
+#ifndef NEW_MENU_CODE
         gtk_ui_manager_add_ui_from_string (ui_manager_tree_view_menu, ui_desc_tree_view_menu_popup, -1, &error);
-		/*gui_desc_file_name = g_strdup_printf("%s" G_DIR_SEPARATOR_S "ui" G_DIR_SEPARATOR_S "tree-view-ui.xml", get_datafile_dir());
-		gtk_ui_manager_add_ui_from_file ( ui_manager_tree_view_menu, gui_desc_file_name, &error);*/
+#else
+        gui_desc_file_name = g_strdup_printf("%s" G_DIR_SEPARATOR_S "ui" G_DIR_SEPARATOR_S "tree-view-ui.xml", get_datafile_dir("gtk"));
+        gtk_ui_manager_add_ui_from_file ( ui_manager_tree_view_menu, gui_desc_file_name, &error);
+#endif
         if (error != NULL)
         {
             fprintf (stderr, "Warning: building TreeWiew Pop-Up menu failed: %s\n",
@@ -3304,7 +3315,9 @@
             g_error_free (error);
             error = NULL;
         }
-		/*g_free (gui_desc_file_name);*/
+#ifdef NEW_MENU_CODE
+        g_free (gui_desc_file_name);
+#endif
 
         g_object_set_data(G_OBJECT(popup_menu_object), PM_TREE_VIEW_KEY,
                          gtk_ui_manager_get_widget(ui_manager_tree_view_menu, "/TreeViewPopup"));
@@ -3331,10 +3344,12 @@
         gtk_ui_manager_insert_action_group (ui_manager_bytes_menu,
             packet_list_byte_menu_action_group,
             0); /* the position at which the group will be inserted.  */
-
+#ifndef NEW_MENU_CODE
         gtk_ui_manager_add_ui_from_string (ui_manager_bytes_menu, ui_desc_bytes_menu_popup, -1, &error);
-		/*gui_desc_file_name = g_strdup_printf("%s" G_DIR_SEPARATOR_S "ui" G_DIR_SEPARATOR_S "bytes-view-ui.xml", get_datafile_dir());
-		gtk_ui_manager_add_ui_from_file ( ui_manager_bytes_menu, gui_desc_file_name, &error);*/
+#else
+        gui_desc_file_name = g_strdup_printf("%s" G_DIR_SEPARATOR_S "ui" G_DIR_SEPARATOR_S "bytes-view-ui.xml", get_datafile_dir("gtk"));
+        gtk_ui_manager_add_ui_from_file ( ui_manager_bytes_menu, gui_desc_file_name, &error);
+#endif
         if (error != NULL)
         {
             fprintf (stderr, "Warning: building Bytes Pop-Up menu failed: %s\n",
@@ -3342,8 +3357,9 @@
             g_error_free (error);
             error = NULL;
         }
-		/*g_free (gui_desc_file_name);*/
-
+#ifdef NEW_MENU_CODE
+        g_free (gui_desc_file_name);
+#endif
         g_object_unref(packet_list_byte_menu_action_group);
 
         g_object_set_data(G_OBJECT(popup_menu_object), PM_BYTES_VIEW_KEY,
@@ -3381,10 +3397,12 @@
 
         ui_manager_main_menubar = gtk_ui_manager_new ();
         gtk_ui_manager_insert_action_group (ui_manager_main_menubar, main_menu_bar_action_group, 0);
+#ifndef NEW_MENU_CODE
         gtk_ui_manager_add_ui_from_string (ui_manager_main_menubar,ui_desc_menubar, -1, &error);
-		/*gui_desc_file_name = g_strdup_printf("%s" G_DIR_SEPARATOR_S "ui" G_DIR_SEPARATOR_S "main-menubar-ui.xml", get_datafile_dir());
-		gtk_ui_manager_add_ui_from_file ( ui_manager_main_menubar, gui_desc_file_name, &error);*/
-
+#else
+		gui_desc_file_name = g_strdup_printf("%s" G_DIR_SEPARATOR_S "ui" G_DIR_SEPARATOR_S "main-menubar-ui.xml", get_datafile_dir("gtk"));
+		gtk_ui_manager_add_ui_from_file ( ui_manager_main_menubar, gui_desc_file_name, &error);
+#endif
         if (error != NULL)
         {
             fprintf (stderr, "Warning: building main menubar failed: %s\n",
@@ -3392,7 +3410,9 @@
             g_error_free (error);
             error = NULL;
         }
-		/*g_free (gui_desc_file_name);*/
+#ifdef NEW_MENU_CODE
+        g_free (gui_desc_file_name);
+#endif
         g_object_unref(main_menu_bar_action_group);
         gtk_window_add_accel_group (GTK_WINDOW(top_level),
                                 gtk_ui_manager_get_accel_group(ui_manager_main_menubar));
Index: gtk/about_dlg.c
===================================================================
--- gtk/about_dlg.c	(revision 38773)
+++ gtk/about_dlg.c	(working copy)
@@ -403,7 +403,7 @@
   g_free(path);
 
   /* global conf */
-  constpath = get_datafile_dir();
+  constpath = get_datafile_dir(NULL);
   if (constpath != NULL) {
     about_folders_row(table, "Global configuration", constpath,
         "\"dfilters\", \"preferences\", \"manuf\", ...");
Index: gtk/webbrowser.c
===================================================================
--- gtk/webbrowser.c	(revision 38773)
+++ gtk/webbrowser.c	(working copy)
@@ -505,7 +505,7 @@
 #endif 
     else
 
-    file_path = g_strdup_printf("%s/%s", get_datafile_dir(), filename);
+    file_path = g_strdup_printf("%s/%s", get_datafile_dir(NULL), filename);
 
     /* XXX - check, if the file is really existing, otherwise display a simple_dialog about the problem */
 
Index: plugins/mate/mate_setup.c
===================================================================
--- plugins/mate/mate_setup.c	(revision 38773)
+++ plugins/mate/mate_setup.c	(working copy)
@@ -584,7 +584,7 @@
 
 	matecfg->dbg_facility = NULL;
 
-	matecfg->mate_lib_path = g_strdup_printf("%s%c%s%c",get_datafile_dir(),DIR_SEP,DEFAULT_MATE_LIB_PATH,DIR_SEP);;
+	matecfg->mate_lib_path = g_strdup_printf("%s%c%s%c",get_datafile_dir(NULL),DIR_SEP,DEFAULT_MATE_LIB_PATH,DIR_SEP);;
 
 	matecfg->pducfgs = g_hash_table_new(g_str_hash,g_str_equal);
 	matecfg->gopcfgs = g_hash_table_new(g_str_hash,g_str_equal);
Index: plugins/wimaxasncp/packet-wimaxasncp.c
===================================================================
--- plugins/wimaxasncp/packet-wimaxasncp.c	(revision 38773)
+++ plugins/wimaxasncp/packet-wimaxasncp.c	(working copy)
@@ -3298,7 +3298,7 @@
 
     dir = ep_strdup_printf(
         "%s" G_DIR_SEPARATOR_S "wimaxasncp",
-        get_datafile_dir());
+        get_datafile_dir(NULL));
 
     wimaxasncp_dict =
         wimaxasncp_dict_scan(dir, "dictionary.xml", debug_parser, &dict_error);
Index: epan/dissectors/packet-diameter.c
===================================================================
--- epan/dissectors/packet-diameter.c	(revision 38773)
+++ epan/dissectors/packet-diameter.c	(working copy)
@@ -1365,7 +1365,7 @@
 	ddict_avp_t* a;
 	gboolean do_debug_parser = getenv("WIRESHARK_DEBUG_DIAM_DICT_PARSER") ? TRUE : FALSE;
 	gboolean do_dump_dict = getenv("WIRESHARK_DUMP_DIAM_DICT") ? TRUE : FALSE;
-	char* dir = ep_strdup_printf("%s" G_DIR_SEPARATOR_S "diameter" G_DIR_SEPARATOR_S, get_datafile_dir());
+	char* dir = ep_strdup_printf("%s" G_DIR_SEPARATOR_S "diameter" G_DIR_SEPARATOR_S, get_datafile_dir(NULL));
 	const avp_type_t* type;
 	const avp_type_t* octetstring = &basic_types[0];
 	diam_avp_t* avp;
Index: epan/dissectors/packet-tpncp.c
===================================================================
--- epan/dissectors/packet-tpncp.c	(revision 38773)
+++ epan/dissectors/packet-tpncp.c	(working copy)
@@ -689,7 +689,7 @@
     gchar *tpncp_dat_file_path;
     FILE *file;
 
-    tpncp_dat_file_path = ep_strdup_printf("%s" G_DIR_SEPARATOR_S"tpncp" G_DIR_SEPARATOR_S "tpncp.dat", get_datafile_dir());
+    tpncp_dat_file_path = ep_strdup_printf("%s" G_DIR_SEPARATOR_S"tpncp" G_DIR_SEPARATOR_S "tpncp.dat", get_datafile_dir(NULL));
 
     /* Open file with TPNCP data. */
     if ((file = ws_fopen(tpncp_dat_file_path, "r")) == NULL)
Index: epan/filesystem.c
===================================================================
--- epan/filesystem.c	(revision 38773)
+++ epan/filesystem.c	(working copy)
@@ -575,16 +575,13 @@
  * example).
  */
 const char *
-get_datafile_dir(void)
+get_datafile_dir(const char *fallback_path)
 {
 #ifdef _WIN32
 	char *u3deviceexecpath;
 #endif
 	static const char *datafile_dir = NULL;
 
-	if (datafile_dir != NULL)
-		return datafile_dir;
-
 #ifdef _WIN32
 	/*
 	 * See if we are running in a U3 environment.
@@ -629,7 +626,11 @@
 		 * able to determine the directory in which the program
 		 * was found, so use that.
 		 */
-		datafile_dir = progfile_dir;
+		if (fallback_path != NULL && getenv("WIRESHARK_SRC_DIR")) {
+			datafile_dir = g_strdup_printf("%s%s%s", getenv("WIRESHARK_SRC_DIR"), G_DIR_SEPARATOR_S, fallback_path);
+		} else {
+			datafile_dir = progfile_dir;
+		}
 	} else {
 		/*
 		 * Return the directory specified when the build was
@@ -684,7 +685,7 @@
 	 * on Windows, the data file directory is the directory
 	 * in which the Wireshark binary resides.
 	 */
-        wspython_dir = g_strdup_printf("%s\\python\\%s", get_datafile_dir(),
+        wspython_dir = g_strdup_printf("%s\\python\\%s", get_datafile_dir(NULL),
                                         VERSION);
 
 	/*
@@ -705,7 +706,7 @@
 		 * directory for python dissectors.
 		 */
 		g_free( (gpointer) wspython_dir);
-		wspython_dir = g_strdup_printf("%s\\python", get_datafile_dir());
+		wspython_dir = g_strdup_printf("%s\\python", get_datafile_dir(NULL));
 		running_in_build_directory_flag = TRUE;
 	}
 #else
@@ -716,7 +717,7 @@
 		 * the "python" subdirectory of the datafile directory
 		 * (the datafile directory is the build directory).
 		 */
-		wspython_dir = g_strdup_printf("%s/epan/wspython/", get_datafile_dir());
+		wspython_dir = g_strdup_printf("%s/epan/wspython/", get_datafile_dir(NULL));
 	} else {
 		if (getenv("WIRESHARK_PYTHON_DIR") && !started_with_special_privs()) {
 			/*
@@ -780,7 +781,7 @@
 	 * on Windows, the data file directory is the directory
 	 * in which the Wireshark binary resides.
 	 */
-	plugin_dir = g_strdup_printf("%s\\plugins\\%s", get_datafile_dir(),
+	plugin_dir = g_strdup_printf("%s\\plugins\\%s", get_datafile_dir(NULL),
 				     VERSION);
 
 	/*
@@ -801,7 +802,7 @@
 		 * directory for plugins.
 		 */
 		g_free( (gpointer) plugin_dir);
-		plugin_dir = g_strdup_printf("%s\\plugins", get_datafile_dir());
+		plugin_dir = g_strdup_printf("%s\\plugins", get_datafile_dir(NULL));
 		running_in_build_directory_flag = TRUE;
 	}
 #else
@@ -812,7 +813,7 @@
 		 * the "plugins" subdirectory of the datafile directory
 		 * (the datafile directory is the build directory).
 		 */
-		plugin_dir = g_strdup_printf("%s/plugins", get_datafile_dir());
+		plugin_dir = g_strdup_printf("%s/plugins", get_datafile_dir(NULL));
 	} else {
 		if (getenv("WIRESHARK_PLUGIN_DIR") && !started_with_special_privs()) {
 			/*
@@ -862,7 +863,7 @@
 get_systemfile_dir(void)
 {
 #ifdef _WIN32
-	return get_datafile_dir();
+	return get_datafile_dir(NULL);
 #else
 	return "/etc";
 #endif
@@ -1061,7 +1062,7 @@
 	static char *global_profiles_dir = NULL;
 
 	if (!global_profiles_dir) {
-		global_profiles_dir = g_strdup_printf ("%s%s%s", get_datafile_dir(),
+		global_profiles_dir = g_strdup_printf ("%s%s%s", get_datafile_dir(NULL),
 						       G_DIR_SEPARATOR_S, PROFILES_DIR);
 	}
 
@@ -1560,7 +1561,7 @@
 get_datafile_path(const char *filename)
 {
 
-	return g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", get_datafile_dir(), filename);
+	return g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", get_datafile_dir(NULL), filename);
 }
 
 /* Get the personal plugin dir */
Index: epan/filesystem.h
===================================================================
--- epan/filesystem.h	(revision 38773)
+++ epan/filesystem.h	(working copy)
@@ -71,7 +71,7 @@
  * Get the directory in which global configuration files are
  * stored.
  */
-extern const char *get_datafile_dir(void);
+extern const char *get_datafile_dir(const char *);
 
 /*
  * Construct the path name of a global configuration file, given the