moved the about dialog from main.c to it's own new about_dlg.c,
authorulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 20 May 2004 12:01:13 +0000 (12:01 +0000)
committerulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 20 May 2004 12:01:13 +0000 (12:01 +0000)
added a notebook tab with some directory infos (still incomplete and ugly)
cleaned up #includes in main.c (hoping this didn't break the build on unix)

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@10925 f5534014-38df-0310-8fa8-9805f1628bb7

gtk/Makefile.common
gtk/about_dlg.c [new file with mode: 0644]
gtk/main.c
gtk/main.h
gtk/menu.c

index 1d57d131a25b23c7702143eae8cc61d46731294a..33a42584def4a240ad5ce77e28ed8a25529384dd 100644 (file)
@@ -3,7 +3,7 @@
 #     a) common to both files and
 #     b) portable between both files
 #
-# $Id: Makefile.common,v 1.12 2004/04/29 17:03:27 ulfl Exp $
+# $Id: Makefile.common,v 1.13 2004/05/20 12:01:13 ulfl Exp $
 #
 # Ethereal - Network traffic analyzer
 # By Gerald Combs <gerald@ethereal.com>
@@ -29,6 +29,7 @@
 # code, while the DLL for GTK+ on Windows is gtk+-1.3.
 #
 ETHEREAL_GTK_SRC = \
+       about_dlg.c     \
        capture_combo_utils.c   \
        capture_dlg.c   \
        capture_info_dlg.c      \
diff --git a/gtk/about_dlg.c b/gtk/about_dlg.c
new file mode 100644 (file)
index 0000000..9e94389
--- /dev/null
@@ -0,0 +1,215 @@
+/* about_dlg.c
+ *
+ * $Id: about_dlg.c,v 1.1 2004/05/20 12:01:12 ulfl Exp $
+ *
+ * Ulf Lamping <ulf.lamping@web.de>
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@ethereal.com>
+ * Copyright 2000 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <gtk/gtk.h>
+
+#include <epan/filesystem.h>
+#include "ui_util.h"
+#include "dlg_utils.h"
+#include "compat_macros.h"
+
+extern GString *comp_info_str, *runtime_info_str;
+
+static void about_ethereal_destroy_cb(GtkWidget *, gpointer);
+
+
+/*
+ * Keep a static pointer to the current "About Ethereal" window, if any, so
+ * that if somebody tries to do "About Ethereal" while there's already an
+ * "About Ethereal" window up, we just pop up the existing one, rather than
+ * creating a new one.
+ */
+static GtkWidget *about_ethereal_w;
+
+
+static GtkWidget *
+about_ethereal_new(void)
+{
+  GtkWidget   *main_vb, *top_hb, *msg_label;
+  gchar       *message;
+
+  /* Container for our rows */
+  main_vb = gtk_vbox_new(FALSE, 5);
+  gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
+
+  /* Top row: Message text */
+  top_hb = gtk_hbox_new(FALSE, 10);
+  gtk_container_add(GTK_CONTAINER(main_vb), top_hb);
+
+  /* Construct the message string */
+  message = g_strdup_printf(
+          "Ethereal - Network Protocol Analyzer\n\n"
+          
+          "Version " VERSION
+#ifdef CVSVERSION
+          " (" CVSVERSION ")"
+#endif
+          " (C) 1998-2004 Gerald Combs <gerald@ethereal.com>\n\n"
+
+       "%s\n"
+       "%s\n\n"
+
+       "Ethereal is Open Source software released under the GNU General Public License.\n\n"
+
+          "Check the man page for complete documentation and\n"
+          "for the list of contributors.\n\n"
+
+          "See http://www.ethereal.com for more information.",
+           comp_info_str->str, runtime_info_str->str);
+
+  msg_label = gtk_label_new(message);
+  g_free(message);
+  gtk_label_set_justify(GTK_LABEL(msg_label), GTK_JUSTIFY_FILL);
+  gtk_container_add(GTK_CONTAINER(top_hb), msg_label);
+
+  return main_vb;
+}
+
+
+static void
+about_dirs_row(GtkWidget *table, guint row, const char *label, const char *dir, const char *tip)
+{
+  GtkWidget   *prefs_lb;
+
+  prefs_lb = gtk_label_new(label);
+  gtk_table_attach_defaults(GTK_TABLE(table), prefs_lb, 0, 1, row, row+1);
+  gtk_misc_set_alignment(GTK_MISC(prefs_lb), 1.0, 0.5);
+
+  prefs_lb = gtk_label_new(dir);
+  gtk_table_attach_defaults(GTK_TABLE(table), prefs_lb, 1, 2, row, row+1);
+  gtk_misc_set_alignment(GTK_MISC(prefs_lb), 0.0, 0.5);
+
+  prefs_lb = gtk_label_new(tip);
+  gtk_table_attach_defaults(GTK_TABLE(table), prefs_lb, 2, 3, row, row+1);
+  gtk_misc_set_alignment(GTK_MISC(prefs_lb), 0.0, 0.5);
+}
+
+
+static GtkWidget *
+about_dirs_new(void)
+{
+  GtkWidget   *table;
+  guint row;
+  const char *path;
+
+  /* Container for our rows */
+  table = gtk_table_new(4, 3, FALSE);
+  gtk_table_set_col_spacings(GTK_TABLE(table), 6);
+  row = 0;
+
+  path = get_persconffile_path("", FALSE);
+  about_dirs_row(table, row, "Personal configuration:", path, 
+      "\"dfilters\", \"preferences\", ...");
+  g_free((void *) path);
+  row++;
+
+  path = get_datafile_dir();
+  about_dirs_row(table, row, "Global configuration and data:", path,
+      "same as in personal conf.");
+  /*g_free(path);*/
+  row++;
+
+  path = get_systemfile_dir();
+  about_dirs_row(table, row, "System:", path,
+      "\"ethers\", ...");
+  /*g_free(path);*/
+  row++;
+
+  path = get_tempfile_path("");
+  about_dirs_row(table, row, "Temp:", path,
+      "untitled capture files");
+  g_free((void *) path);
+  row++;
+
+  return table;
+}
+
+
+void
+about_ethereal_cb( GtkWidget *w _U_, gpointer data _U_ )
+{
+  GtkWidget   *main_vb, *main_nb, *bbox, *ok_btn;
+
+  GtkWidget   *about, *about_lb, *dirs, *dirs_lb;
+
+  if (about_ethereal_w != NULL) {
+    /* There's already an "About Ethereal" dialog box; reactivate it. */
+    reactivate_window(about_ethereal_w);
+    return;
+  }
+
+  /*
+   * XXX - use GtkDialog?  The GNOME 2.x GnomeAbout widget does.
+   * Should we use GtkDialog for simple_dialog() as well?  Or
+   * is the GTK+ 2.x GtkDialog appropriate but the 1.2[.x] one
+   * not?  (The GNOME 1.x GnomeAbout widget uses GnomeDialog.)
+   */
+  about_ethereal_w = dlg_window_new("About Ethereal");
+  SIGNAL_CONNECT(about_ethereal_w, "destroy", about_ethereal_destroy_cb, NULL);
+  gtk_container_border_width(GTK_CONTAINER(about_ethereal_w), 7);
+
+  main_vb = gtk_vbox_new(FALSE, 5);
+  gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
+  gtk_container_add(GTK_CONTAINER(about_ethereal_w), main_vb);
+
+  main_nb = gtk_notebook_new();
+  gtk_container_add(GTK_CONTAINER(main_vb), main_nb);
+
+  about = about_ethereal_new();
+  about_lb = gtk_label_new("Ethereal");
+  gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), about, about_lb);
+
+  dirs = about_dirs_new();
+  dirs_lb = gtk_label_new("Directories");
+  gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), dirs, dirs_lb);
+
+  /* Button row */
+  bbox = dlg_button_row_new(GTK_STOCK_OK, NULL);
+  gtk_container_add(GTK_CONTAINER(main_vb), bbox);
+
+  ok_btn = OBJECT_GET_DATA(bbox, GTK_STOCK_OK);
+  SIGNAL_CONNECT_OBJECT(ok_btn, "clicked", gtk_widget_destroy,
+                        about_ethereal_w);
+  gtk_widget_grab_default(ok_btn);
+
+  /* Catch the "key_press_event" signal in the window, so that we can catch
+     the ESC key being pressed and act as if the "Cancel" button had
+     been selected. */
+  dlg_set_cancel(about_ethereal_w, ok_btn);
+
+  gtk_widget_show_all(about_ethereal_w);
+}
+
+static void
+about_ethereal_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
+{
+  /* Note that we no longer have an "About Ethereal" dialog box. */
+  about_ethereal_w = NULL;
+}
+
index f46ac853be94d27d79321014546fa8d7173a5360..318358ead727c99931e93699d6dd44cb1ea12a45 100644 (file)
@@ -1,6 +1,6 @@
 /* main.c
  *
- * $Id: main.c,v 1.435 2004/05/17 21:15:28 ulfl Exp $
+ * $Id: main.c,v 1.436 2004/05/20 12:01:12 ulfl Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
 #include <epan/epan.h>
 #include <epan/filesystem.h>
 #include <epan/epan_dissect.h>
-
-#include "cvsversion.h"
-#include "main.h"
 #include <epan/timestamp.h>
 #include <epan/packet.h>
-#include "capture.h"
-#include "summary.h"
+#include <epan/plugins.h>
+#include <epan/dfilter/dfilter.h>
+#include <epan/strutil.h>
+#include <epan/resolv.h>
+
+/* general (not GTK specific) */
+#include "cvsversion.h"
 #include "file.h"
+#include "summary.h"
 #include "filters.h"
 #include "disabled_protos.h"
 #include "prefs.h"
-#include "menu.h"
-#include "../menu.h"
+#include "filter_prefs.h"
+#include "layout_prefs.h"
 #include "color.h"
 #include "color_filters.h"
 #include "color_utils.h"
-#include "filter_prefs.h"
-#include "layout_prefs.h"
-#include "file_dlg.h"
-#include "column.h"
 #include "print.h"
-#include <epan/resolv.h>
+#include "simple_dialog.h"
+#include "register.h"
+#include "prefs-int.h"
+#include "ringbuffer.h"
+#include "../ui_util.h"     /* beware: ui_util.h exists twice! */
+#include "tap.h"
+#include "util.h"
+#include "version_info.h"
+#include "capture.h"
 #ifdef HAVE_LIBPCAP
 #include "pcap-util.h"
 #endif
+#ifdef WIN32
+#include "capture-wpcap.h"
+#endif
+
+/* GTK related */
 #include "statusbar.h"
 #include "alert_box.h"
-#include "simple_dialog.h"
 #include "dlg_utils.h"
+#include "gtkglobals.h"
+#include "colors.h"
+#include "ui_util.h"        /* beware: ui_util.h exists twice! */
+#include "compat_macros.h"
+
+#include "main.h"
+#include "menu.h"
+#include "../menu.h"
+#include "file_dlg.h"
+#include "column.h"
 #include "proto_draw.h"
-#include <epan/dfilter/dfilter.h>
 #include "keys.h"
 #include "packet_win.h"
-#include "gtkglobals.h"
-#include <epan/plugins.h>
-#include "colors.h"
-#include <epan/strutil.h>
-#include "register.h"
-#include <prefs-int.h>
-#include "ringbuffer.h"
-#include "../ui_util.h"
-#include "ui_util.h"
 #include "toolbar.h"
-#include "../tap.h"
-#include "../util.h"
-#include "../version_info.h"
-#include "compat_macros.h"
 #include "find_dlg.h"
 #include "packet_list.h"
 #include "recent.h"
 #include "follow_dlg.h"
-#include <epan/timestamp.h>
 
-#ifdef WIN32
-#include "capture-wpcap.h"
-#endif
 
 capture_file cfile;
 GtkWidget   *main_display_filter_widget=NULL;
 GtkWidget   *top_level = NULL, *tree_view, *byte_nb_ptr, *tv_scrollw;
-GtkWidget   *none_lb, *main_pane_v1, *main_pane_v2, *main_pane_h1, *main_pane_h2;
-GtkWidget   *main_first_pane, *main_second_pane;
-GtkWidget   *status_pane;
-GtkWidget   *menubar, *main_vbox, *main_tb, *pkt_scrollw, *stat_hbox, *filter_tb;
+static GtkWidget   *none_lb, *main_pane_v1, *main_pane_v2, *main_pane_h1, *main_pane_h2;
+static GtkWidget   *main_first_pane, *main_second_pane;
+static GtkWidget   *status_pane;
+static GtkWidget   *menubar, *main_vbox, *main_tb, *pkt_scrollw, *stat_hbox, *filter_tb;
 static GtkWidget       *info_bar;
 static GtkWidget    *packets_bar = NULL;
 #if GTK_MAJOR_VERSION < 2
@@ -147,7 +150,7 @@ PangoFontDescription *m_r_font, *m_b_font;
 static guint    main_ctx, file_ctx, help_ctx;
 static guint        packets_ctx;
 static gchar        *packets_str = NULL;
-static GString *comp_info_str, *runtime_info_str;
+GString *comp_info_str, *runtime_info_str;
 gchar       *ethereal_path = NULL;
 gchar       *last_open_dir = NULL;
 static gboolean updated_last_open_dir = FALSE;
@@ -168,7 +171,6 @@ static void console_log_handler(const char *log_domain,
 static gboolean list_link_layer_types;
 #endif
 
-static void about_ethereal_destroy_cb(GtkWidget *, gpointer);
 static void create_main_window(gint, gint, gint, e_prefs*);
 static void file_quit_answered_cb(gpointer dialog _U_, gint btn, gpointer data _U_);
 static void main_save_window_geometry(GtkWidget *widget);
@@ -181,100 +183,7 @@ static void try_to_get_windows_font_gtk2 (void);
 #define E_DFILTER_CM_KEY          "display_filter_combo"
 #define E_DFILTER_FL_KEY          "display_filter_list"
 
-/* About Ethereal window */
-#define MAX_ABOUT_MSG_LEN 2048
-
-/*
- * Keep a static pointer to the current "About Ethereal" window, if any, so
- * that if somebody tries to do "About Ethereal" while there's already an
- * "About Ethereal" window up, we just pop up the existing one, rather than
- * creating a new one.
- */
-static GtkWidget *about_ethereal_w;
-
-void
-about_ethereal( GtkWidget *w _U_, gpointer data _U_ )
-{
-  GtkWidget   *main_vb, *top_hb, *msg_label, *bbox, *ok_btn;
-  gchar        message[MAX_ABOUT_MSG_LEN];
 
-  if (about_ethereal_w != NULL) {
-    /* There's already an "About Ethereal" dialog box; reactivate it. */
-    reactivate_window(about_ethereal_w);
-    return;
-  }
-
-  /*
-   * XXX - use GtkDialog?  The GNOME 2.x GnomeAbout widget does.
-   * Should we use GtkDialog for simple_dialog() as well?  Or
-   * is the GTK+ 2.x GtkDialog appropriate but the 1.2[.x] one
-   * not?  (The GNOME 1.x GnomeAbout widget uses GnomeDialog.)
-   */
-  about_ethereal_w = dlg_window_new("About Ethereal");
-  SIGNAL_CONNECT(about_ethereal_w, "destroy", about_ethereal_destroy_cb, NULL);
-  gtk_container_border_width(GTK_CONTAINER(about_ethereal_w), 7);
-
-  /* Container for our rows */
-  main_vb = gtk_vbox_new(FALSE, 5);
-  gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
-  gtk_container_add(GTK_CONTAINER(about_ethereal_w), main_vb);
-  gtk_widget_show(main_vb);
-
-  /* Top row: Message text */
-  top_hb = gtk_hbox_new(FALSE, 10);
-  gtk_container_add(GTK_CONTAINER(main_vb), top_hb);
-  gtk_widget_show(top_hb);
-
-  /* Construct the message string */
-  g_snprintf(message, MAX_ABOUT_MSG_LEN,
-          "Ethereal - Network Protocol Analyzer\n\n"
-          
-          "Version " VERSION
-#ifdef CVSVERSION
-          " (" CVSVERSION ")"
-#endif
-          " (C) 1998-2004 Gerald Combs <gerald@ethereal.com>\n\n"
-
-       "%s\n"
-       "%s\n\n"
-
-       "Ethereal is Open Source software released under the GNU General Public License.\n\n"
-
-          "Check the man page for complete documentation and\n"
-          "for the list of contributors.\n\n"
-
-          "See http://www.ethereal.com for more information.",
-           comp_info_str->str, runtime_info_str->str);
-
-  msg_label = gtk_label_new(message);
-  gtk_label_set_justify(GTK_LABEL(msg_label), GTK_JUSTIFY_FILL);
-  gtk_container_add(GTK_CONTAINER(top_hb), msg_label);
-  gtk_widget_show(msg_label);
-
-  /* Button row */
-  bbox = dlg_button_row_new(GTK_STOCK_OK, NULL);
-  gtk_container_add(GTK_CONTAINER(main_vb), bbox);
-  gtk_widget_show(bbox);
-
-  ok_btn = OBJECT_GET_DATA(bbox, GTK_STOCK_OK);
-  SIGNAL_CONNECT_OBJECT(ok_btn, "clicked", gtk_widget_destroy,
-                        about_ethereal_w);
-  gtk_widget_grab_default(ok_btn);
-
-  /* Catch the "key_press_event" signal in the window, so that we can catch
-     the ESC key being pressed and act as if the "Cancel" button had
-     been selected. */
-  dlg_set_cancel(about_ethereal_w, ok_btn);
-
-  gtk_widget_show(about_ethereal_w);
-}
-
-static void
-about_ethereal_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
-{
-  /* Note that we no longer have an "About Ethereal" dialog box. */
-  about_ethereal_w = NULL;
-}
 
 #if GTK_MAJOR_VERSION < 2
 void
index 11e8f0d49f69acf735b6c9cc2707deb37eb480c9..138b22fee35c987fb055c99bc51b635712af5c35 100644 (file)
@@ -1,7 +1,7 @@
 /* main.h
  * Global defines, etc.
  *
- * $Id: main.h,v 1.47 2004/05/13 15:28:02 ulfl Exp $
+ * $Id: main.h,v 1.48 2004/05/20 12:01:13 ulfl Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -62,7 +62,7 @@ typedef struct _selection_info {
 extern GtkStyle *item_style;
 #endif
 
-void about_ethereal( GtkWidget *, gpointer);
+void about_ethereal_cb( GtkWidget *, gpointer);
 void goto_framenum_cb(GtkWidget *, gpointer);
 void goto_top_frame_cb(GtkWidget *w _U_, gpointer d _U_);
 void goto_bottom_frame_cb(GtkWidget *w _U_, gpointer d _U_);
index 3b79f83f4284a0d067647b671fe492f98591ccc7..2638ff7389559f009aaca2bd41a3f4e91a7f40b9 100644 (file)
@@ -1,7 +1,7 @@
 /* menu.c
  * Menu routines
  *
- * $Id: menu.c,v 1.194 2004/05/20 10:37:40 ulfl Exp $
+ * $Id: menu.c,v 1.195 2004/05/20 12:01:13 ulfl Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -326,7 +326,7 @@ static GtkItemFactoryEntry menu_items[] =
     ITEM_FACTORY_ENTRY("/Help/About _Plugins", NULL, tools_plugins_cmd_cb,
                        0, NULL, NULL),
 #endif /* HAVE_PLUGINS */
-    ITEM_FACTORY_ENTRY("/Help/_About Ethereal", NULL, about_ethereal,
+    ITEM_FACTORY_ENTRY("/Help/_About Ethereal", NULL, about_ethereal_cb,
                        0, NULL, NULL)
 };