2000-01-10 01:44:00 +00:00
|
|
|
/* column_prefs.c
|
|
|
|
* Dialog box for column preferences
|
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
2000-01-10 01:44:00 +00:00
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
2002-01-11 07:40:32 +00:00
|
|
|
* By Gerald Combs <gerald@ethereal.com>
|
2000-01-10 01:44:00 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2000-01-10 01:44:00 +00:00
|
|
|
* 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.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2000-01-10 01:44:00 +00:00
|
|
|
* 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.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2000-01-10 01:44:00 +00:00
|
|
|
* 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
|
|
|
|
|
2000-10-20 04:26:40 +00:00
|
|
|
#include <gtk/gtk.h>
|
2000-01-10 01:44:00 +00:00
|
|
|
|
|
|
|
#include "globals.h"
|
|
|
|
#include "column_prefs.h"
|
|
|
|
#include "gtkglobals.h"
|
2004-09-27 22:55:15 +00:00
|
|
|
#include <epan/prefs.h>
|
2004-09-29 02:54:22 +00:00
|
|
|
#include <epan/column.h>
|
2002-11-09 20:52:39 +00:00
|
|
|
#include "compat_macros.h"
|
2004-02-06 19:19:12 +00:00
|
|
|
#include "ui_util.h"
|
2000-01-10 01:44:00 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION >= 2
|
|
|
|
#include "ui_util.h"
|
|
|
|
#endif
|
|
|
|
|
2002-04-22 09:50:54 +00:00
|
|
|
static GtkWidget *column_l, *del_bt, *title_te, *fmt_m, *up_bt, *dn_bt;
|
2002-04-22 02:03:53 +00:00
|
|
|
static gint cur_fmt, cur_row;
|
2000-01-10 01:44:00 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2002-04-22 02:03:53 +00:00
|
|
|
static void column_list_select_cb(GtkCList *clist, gint row, gint column,
|
2002-11-03 17:38:45 +00:00
|
|
|
GdkEvent *event, gpointer user_data);
|
2002-04-22 02:03:53 +00:00
|
|
|
static void column_list_unselect_cb(GtkCList *clist, gint row, gint column,
|
2002-11-03 17:38:45 +00:00
|
|
|
GdkEvent *event, gpointer user_data);
|
|
|
|
#else
|
|
|
|
static void column_list_select_cb(GtkTreeSelection *, gpointer);
|
|
|
|
#endif
|
2002-04-22 02:03:53 +00:00
|
|
|
static void column_list_new_cb(GtkWidget *, gpointer);
|
|
|
|
static void column_entry_changed_cb(GtkEditable *, gpointer);
|
|
|
|
static void column_menu_changed_cb(GtkWidget *, gpointer);
|
|
|
|
static void column_list_delete_cb(GtkWidget *, gpointer);
|
|
|
|
static void column_arrow_cb(GtkWidget *, gpointer);
|
|
|
|
void column_set_arrow_button_sensitivity(GList *);
|
2000-01-10 01:44:00 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION >= 2
|
|
|
|
#define E_COL_NAME_KEY "column_name"
|
|
|
|
#define E_COL_LBL_KEY "column_label"
|
|
|
|
#endif
|
2000-01-10 01:44:00 +00:00
|
|
|
#define E_COL_CM_KEY "in_col_cancel_mode"
|
|
|
|
|
|
|
|
/* Create and display the column selection widgets. */
|
|
|
|
/* Called when the 'Columns' preference notebook page is selected. */
|
|
|
|
GtkWidget *
|
|
|
|
column_prefs_show() {
|
2004-01-16 21:25:21 +00:00
|
|
|
GtkWidget *main_vb, *top_hb, *new_bt,
|
|
|
|
*tb, *lb, *menu, *mitem;
|
|
|
|
GtkWidget *order_fr, *order_vb, *order_lb;
|
|
|
|
GtkWidget *list_fr, *list_vb, *list_lb, *list_sc;
|
2004-01-18 00:53:57 +00:00
|
|
|
GtkWidget *edit_fr, *edit_vb;
|
|
|
|
GtkWidget *props_fr, *props_hb;
|
2002-11-03 17:38:45 +00:00
|
|
|
GList *clp = NULL;
|
|
|
|
fmt_data *cfmt;
|
|
|
|
gint i;
|
|
|
|
gchar *column_titles[] = {"Title", "Format"};
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
gchar *col_ent[2];
|
|
|
|
gint row;
|
|
|
|
#else
|
|
|
|
GtkListStore *store;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
GtkTreeSelection *sel;
|
|
|
|
GtkTreeIter iter;
|
2004-01-17 12:12:57 +00:00
|
|
|
GtkTreeIter first_iter;
|
|
|
|
gint first_row = TRUE;
|
2002-11-03 17:38:45 +00:00
|
|
|
#endif
|
2000-01-10 01:44:00 +00:00
|
|
|
|
|
|
|
/* Container for each row of widgets */
|
|
|
|
main_vb = gtk_vbox_new(FALSE, 5);
|
|
|
|
gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
|
|
|
|
gtk_widget_show(main_vb);
|
2002-11-09 20:52:39 +00:00
|
|
|
OBJECT_SET_DATA(GTK_OBJECT(main_vb), E_COL_CM_KEY, (gpointer)FALSE);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-01-10 01:44:00 +00:00
|
|
|
/* Top row: Column list and buttons */
|
|
|
|
top_hb = gtk_hbox_new(FALSE, 5);
|
|
|
|
gtk_container_add(GTK_CONTAINER(main_vb), top_hb);
|
|
|
|
gtk_widget_show(top_hb);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-01-10 01:44:00 +00:00
|
|
|
|
2004-01-18 00:53:57 +00:00
|
|
|
/* edit frame */
|
|
|
|
edit_fr = gtk_frame_new("Edit");
|
|
|
|
gtk_box_pack_start (GTK_BOX (top_hb), edit_fr, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(edit_fr);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2004-01-18 00:53:57 +00:00
|
|
|
edit_vb = gtk_vbox_new (TRUE, 0);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (edit_vb), 5);
|
|
|
|
gtk_container_add(GTK_CONTAINER(edit_fr), edit_vb);
|
|
|
|
gtk_widget_show(edit_vb);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2004-01-18 00:53:57 +00:00
|
|
|
new_bt = BUTTON_NEW_FROM_STOCK(GTK_STOCK_NEW);
|
|
|
|
SIGNAL_CONNECT(new_bt, "clicked", column_list_new_cb, NULL);
|
|
|
|
gtk_box_pack_start (GTK_BOX (edit_vb), new_bt, FALSE, FALSE, 5);
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
WIDGET_SET_SIZE(new_bt, 50, 20);
|
|
|
|
#endif
|
|
|
|
gtk_widget_show(new_bt);
|
2004-01-16 21:25:21 +00:00
|
|
|
|
2004-01-18 00:53:57 +00:00
|
|
|
del_bt = BUTTON_NEW_FROM_STOCK(GTK_STOCK_DELETE);
|
|
|
|
gtk_widget_set_sensitive(del_bt, FALSE);
|
|
|
|
SIGNAL_CONNECT(del_bt, "clicked", column_list_delete_cb, NULL);
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
WIDGET_SET_SIZE(del_bt, 50, 20);
|
|
|
|
#endif
|
|
|
|
gtk_box_pack_start (GTK_BOX (edit_vb), del_bt, FALSE, FALSE, 5);
|
|
|
|
gtk_widget_show(del_bt);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2004-01-16 21:25:21 +00:00
|
|
|
|
|
|
|
/* columns list frame */
|
|
|
|
list_fr = gtk_frame_new("Columns");
|
|
|
|
gtk_box_pack_start (GTK_BOX (top_hb), list_fr, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show(list_fr);
|
|
|
|
|
|
|
|
list_vb = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (list_vb), 5);
|
|
|
|
gtk_widget_show (list_vb);
|
|
|
|
gtk_container_add(GTK_CONTAINER(list_fr), list_vb);
|
|
|
|
|
|
|
|
list_lb = gtk_label_new (("[First list entry will be displayed left]"));
|
|
|
|
gtk_widget_show (list_lb);
|
|
|
|
gtk_box_pack_start (GTK_BOX (list_vb), list_lb, FALSE, FALSE, 0);
|
|
|
|
|
2004-02-06 19:19:12 +00:00
|
|
|
list_sc = scrolled_window_new(NULL, NULL);
|
|
|
|
#if GTK_MAJOR_VERSION >= 2
|
|
|
|
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(list_sc),
|
|
|
|
GTK_SHADOW_IN);
|
|
|
|
#endif
|
2004-01-16 21:25:21 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(list_vb), list_sc);
|
|
|
|
gtk_widget_show(list_sc);
|
2000-01-10 01:44:00 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2002-04-22 02:03:53 +00:00
|
|
|
column_l = gtk_clist_new_with_titles(2, column_titles);
|
|
|
|
/* XXX - make this match the packet list prefs? */
|
|
|
|
gtk_clist_set_selection_mode(GTK_CLIST(column_l), GTK_SELECTION_SINGLE);
|
|
|
|
gtk_clist_column_titles_passive(GTK_CLIST(column_l));
|
|
|
|
gtk_clist_column_titles_show(GTK_CLIST(column_l));
|
|
|
|
gtk_clist_set_column_auto_resize(GTK_CLIST(column_l), 0, TRUE);
|
|
|
|
gtk_clist_set_column_auto_resize(GTK_CLIST(column_l), 1, TRUE);
|
|
|
|
|
2002-11-09 20:52:39 +00:00
|
|
|
SIGNAL_CONNECT(column_l, "select-row", column_list_select_cb, NULL);
|
|
|
|
SIGNAL_CONNECT(column_l, "unselect-row", column_list_unselect_cb, NULL);
|
2004-01-16 21:25:21 +00:00
|
|
|
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(list_sc),
|
2002-11-03 17:38:45 +00:00
|
|
|
column_l);
|
|
|
|
#else
|
|
|
|
store = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER);
|
|
|
|
column_l = tree_view_new(GTK_TREE_MODEL(store));
|
|
|
|
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(column_l), TRUE);
|
|
|
|
gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(column_l), FALSE);
|
|
|
|
renderer = gtk_cell_renderer_text_new();
|
|
|
|
column = gtk_tree_view_column_new_with_attributes(column_titles[0], renderer,
|
|
|
|
"text", 0, NULL);
|
|
|
|
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
|
|
|
|
gtk_tree_view_append_column(GTK_TREE_VIEW(column_l), column);
|
|
|
|
renderer = gtk_cell_renderer_text_new();
|
|
|
|
column = gtk_tree_view_column_new_with_attributes(column_titles[1], renderer,
|
|
|
|
"text", 1, NULL);
|
|
|
|
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
|
|
|
|
gtk_tree_view_append_column(GTK_TREE_VIEW(column_l), column);
|
|
|
|
/* XXX - make this match the packet list prefs? */
|
|
|
|
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(column_l));
|
|
|
|
gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
|
|
|
|
|
2002-11-09 20:52:39 +00:00
|
|
|
SIGNAL_CONNECT(sel, "changed", column_list_select_cb, NULL);
|
2004-01-16 21:25:21 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(list_sc), column_l);
|
2002-11-03 17:38:45 +00:00
|
|
|
#endif
|
2000-01-10 01:44:00 +00:00
|
|
|
gtk_widget_show(column_l);
|
|
|
|
|
|
|
|
clp = g_list_first(prefs.col_list);
|
|
|
|
while (clp) {
|
|
|
|
cfmt = (fmt_data *) clp->data;
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2002-04-22 02:03:53 +00:00
|
|
|
col_ent[0] = cfmt->title;
|
2002-08-28 21:04:11 +00:00
|
|
|
col_ent[1] = col_format_desc(get_column_format_from_str(cfmt->fmt));
|
2002-04-22 02:03:53 +00:00
|
|
|
row = gtk_clist_append(GTK_CLIST(column_l), col_ent);
|
|
|
|
gtk_clist_set_row_data(GTK_CLIST(column_l), row, clp);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
gtk_list_store_append(store, &iter);
|
|
|
|
gtk_list_store_set(store, &iter, 0, cfmt->title, 1,
|
|
|
|
col_format_desc(get_column_format_from_str(cfmt->fmt)),
|
|
|
|
2, clp, -1);
|
2004-01-17 12:12:57 +00:00
|
|
|
if (first_row) {
|
|
|
|
first_iter = iter;
|
|
|
|
first_row = FALSE;
|
|
|
|
}
|
2002-11-03 17:38:45 +00:00
|
|
|
#endif
|
2000-01-10 01:44:00 +00:00
|
|
|
clp = clp->next;
|
|
|
|
}
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION >= 2
|
|
|
|
g_object_unref(G_OBJECT(store));
|
|
|
|
#endif
|
2004-01-16 21:25:21 +00:00
|
|
|
|
|
|
|
|
2004-01-18 00:53:57 +00:00
|
|
|
/* order frame */
|
|
|
|
order_fr = gtk_frame_new("Order");
|
|
|
|
gtk_box_pack_start (GTK_BOX (top_hb), order_fr, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(order_fr);
|
2004-01-16 21:25:21 +00:00
|
|
|
|
2004-01-18 00:53:57 +00:00
|
|
|
order_vb = gtk_vbox_new (TRUE, 0);
|
|
|
|
gtk_container_add(GTK_CONTAINER(order_fr), order_vb);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (order_vb), 5);
|
|
|
|
gtk_widget_show(order_vb);
|
2004-01-16 21:25:21 +00:00
|
|
|
|
2004-01-18 00:53:57 +00:00
|
|
|
up_bt = BUTTON_NEW_FROM_STOCK(GTK_STOCK_GO_UP);
|
|
|
|
gtk_widget_set_sensitive(up_bt, FALSE);
|
|
|
|
SIGNAL_CONNECT(up_bt, "clicked", column_arrow_cb, NULL);
|
|
|
|
gtk_box_pack_start(GTK_BOX(order_vb), up_bt, FALSE, FALSE, 0);
|
2004-01-25 12:10:27 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2004-01-18 00:53:57 +00:00
|
|
|
WIDGET_SET_SIZE(up_bt, 50, 20);
|
2004-01-25 12:10:27 +00:00
|
|
|
#endif
|
2004-01-18 00:53:57 +00:00
|
|
|
gtk_widget_show(up_bt);
|
2004-01-16 21:25:21 +00:00
|
|
|
|
2004-01-18 00:53:57 +00:00
|
|
|
order_lb = gtk_label_new (("Move\nselected\ncolumn\nup or down"));
|
|
|
|
gtk_widget_show (order_lb);
|
|
|
|
gtk_box_pack_start (GTK_BOX (order_vb), order_lb, FALSE, FALSE, 0);
|
2004-01-16 21:25:21 +00:00
|
|
|
|
2004-01-18 00:53:57 +00:00
|
|
|
dn_bt = BUTTON_NEW_FROM_STOCK(GTK_STOCK_GO_DOWN);
|
|
|
|
gtk_widget_set_sensitive(dn_bt, FALSE);
|
|
|
|
SIGNAL_CONNECT(dn_bt, "clicked", column_arrow_cb, NULL);
|
|
|
|
gtk_box_pack_start(GTK_BOX(order_vb), dn_bt, FALSE, FALSE, 0);
|
2004-01-25 12:10:27 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2004-01-18 00:53:57 +00:00
|
|
|
WIDGET_SET_SIZE(dn_bt, 50, 20);
|
2004-01-25 12:10:27 +00:00
|
|
|
#endif
|
2004-01-18 00:53:57 +00:00
|
|
|
gtk_widget_show(dn_bt);
|
|
|
|
|
|
|
|
|
|
|
|
/* properties frame */
|
|
|
|
props_fr = gtk_frame_new("Properties");
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vb), props_fr, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(props_fr);
|
2004-01-16 21:25:21 +00:00
|
|
|
|
2000-01-10 01:44:00 +00:00
|
|
|
/* Colunm name entry and format selection */
|
|
|
|
tb = gtk_table_new(2, 2, FALSE);
|
2004-01-16 21:25:21 +00:00
|
|
|
gtk_container_border_width(GTK_CONTAINER(tb), 5);
|
2004-01-18 00:53:57 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(props_fr), tb);
|
2000-01-10 01:44:00 +00:00
|
|
|
gtk_table_set_row_spacings(GTK_TABLE(tb), 10);
|
|
|
|
gtk_table_set_col_spacings(GTK_TABLE(tb), 15);
|
|
|
|
gtk_widget_show(tb);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2004-01-18 00:53:57 +00:00
|
|
|
lb = gtk_label_new("Title:");
|
2000-01-10 01:44:00 +00:00
|
|
|
gtk_misc_set_alignment(GTK_MISC(lb), 1.0, 0.5);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(tb), lb, 0, 1, 0, 1);
|
|
|
|
gtk_widget_show(lb);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-01-10 01:44:00 +00:00
|
|
|
title_te = gtk_entry_new();
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(tb), title_te, 1, 2, 0, 1);
|
2002-11-09 20:52:39 +00:00
|
|
|
SIGNAL_CONNECT(title_te, "changed", column_entry_changed_cb, column_l);
|
2002-04-22 02:03:53 +00:00
|
|
|
gtk_widget_set_sensitive(title_te, FALSE);
|
2000-01-10 01:44:00 +00:00
|
|
|
gtk_widget_show(title_te);
|
|
|
|
|
2004-01-18 00:53:57 +00:00
|
|
|
lb = gtk_label_new("Format:");
|
2000-01-10 01:44:00 +00:00
|
|
|
gtk_misc_set_alignment(GTK_MISC(lb), 1.0, 0.5);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(tb), lb, 0, 1, 1, 2);
|
|
|
|
gtk_widget_show(lb);
|
|
|
|
|
2004-01-18 00:53:57 +00:00
|
|
|
props_hb = gtk_hbox_new(FALSE, 5);
|
|
|
|
gtk_table_attach(GTK_TABLE(tb), props_hb, 1, 2, 1, 2, GTK_FILL,
|
2002-11-03 17:38:45 +00:00
|
|
|
GTK_SHRINK, 0, 0);
|
2004-01-18 00:53:57 +00:00
|
|
|
gtk_widget_show(props_hb);
|
2002-04-22 02:03:53 +00:00
|
|
|
|
2000-01-10 01:44:00 +00:00
|
|
|
fmt_m = gtk_option_menu_new();
|
|
|
|
menu = gtk_menu_new();
|
|
|
|
for (i = 0; i < NUM_COL_FMTS; i++) {
|
|
|
|
mitem = gtk_menu_item_new_with_label(col_format_desc(i));
|
|
|
|
gtk_menu_append(GTK_MENU(menu), mitem);
|
2003-03-10 02:06:33 +00:00
|
|
|
SIGNAL_CONNECT(mitem, "activate", column_menu_changed_cb, GINT_TO_POINTER(i));
|
2000-01-10 01:44:00 +00:00
|
|
|
gtk_widget_show(mitem);
|
|
|
|
}
|
|
|
|
gtk_option_menu_set_menu(GTK_OPTION_MENU(fmt_m), menu);
|
|
|
|
cur_fmt = 0;
|
|
|
|
gtk_option_menu_set_history(GTK_OPTION_MENU(fmt_m), cur_fmt);
|
2002-04-22 02:03:53 +00:00
|
|
|
gtk_widget_set_sensitive(fmt_m, FALSE);
|
2004-01-18 00:53:57 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(props_hb), fmt_m, FALSE, FALSE, 0);
|
2002-08-28 21:04:11 +00:00
|
|
|
gtk_widget_show(fmt_m);
|
|
|
|
|
2004-07-31 07:04:32 +00:00
|
|
|
lb = gtk_label_new("Unlike all other preferences, you have to \"Save\" "
|
|
|
|
"and restart Ethereal to let column changes take effect!");
|
|
|
|
gtk_misc_set_alignment(GTK_MISC(lb), 0.5, 0.5);
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vb), lb, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(lb);
|
|
|
|
|
2004-01-17 12:12:57 +00:00
|
|
|
/* select the first row */
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
gtk_clist_select_row(GTK_CLIST(column_l), 0, 0);
|
|
|
|
#else
|
|
|
|
gtk_tree_selection_select_iter(sel, &first_iter);
|
|
|
|
#endif
|
|
|
|
|
2000-01-10 01:44:00 +00:00
|
|
|
return(main_vb);
|
|
|
|
}
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/* For each selection, set the entry and option menu widgets to match
|
2002-04-22 02:03:53 +00:00
|
|
|
the currently selected item. Set the up/down button sensitivity.
|
|
|
|
Draw focus to the entry widget. */
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2000-01-10 01:44:00 +00:00
|
|
|
static void
|
2002-04-22 02:03:53 +00:00
|
|
|
column_list_select_cb(GtkCList *clist,
|
|
|
|
gint row,
|
|
|
|
gint column _U_,
|
|
|
|
GdkEvent *event _U_,
|
|
|
|
gpointer user_data _U_) {
|
2000-01-10 01:44:00 +00:00
|
|
|
fmt_data *cfmt;
|
2002-04-22 02:03:53 +00:00
|
|
|
GList *clp;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2002-04-22 02:03:53 +00:00
|
|
|
clp = gtk_clist_get_row_data(clist, row);
|
|
|
|
g_assert(clp != NULL);
|
|
|
|
cfmt = (fmt_data *) clp->data;
|
|
|
|
cur_fmt = get_column_format_from_str(cfmt->fmt);
|
|
|
|
g_assert(cur_fmt != -1); /* It should always be valid */
|
|
|
|
cur_row = row;
|
2000-01-10 01:44:00 +00:00
|
|
|
|
2002-04-22 02:03:53 +00:00
|
|
|
gtk_entry_set_text(GTK_ENTRY(title_te), cfmt->title);
|
|
|
|
gtk_editable_select_region(GTK_EDITABLE(title_te), 0, -1);
|
|
|
|
gtk_widget_grab_focus(title_te);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2002-04-22 02:03:53 +00:00
|
|
|
gtk_widget_set_sensitive(del_bt, TRUE);
|
|
|
|
gtk_widget_set_sensitive(title_te, TRUE);
|
|
|
|
gtk_widget_set_sensitive(fmt_m, TRUE);
|
|
|
|
column_set_arrow_button_sensitivity(clp);
|
2004-01-17 12:12:57 +00:00
|
|
|
|
|
|
|
/* do this *after* set_sensitive(fmt_m), to have the correct "sensitive" effect */
|
|
|
|
gtk_option_menu_set_history(GTK_OPTION_MENU(fmt_m), cur_fmt);
|
2002-04-22 02:03:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* A row was deselected. Clear the text entry box and disable various widgets. */
|
|
|
|
static void
|
|
|
|
column_list_unselect_cb(GtkCList *clist _U_,
|
2002-04-23 06:25:37 +00:00
|
|
|
gint row _U_,
|
2002-04-22 02:03:53 +00:00
|
|
|
gint column _U_,
|
|
|
|
GdkEvent *event _U_,
|
|
|
|
gpointer user_data _U_) {
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2002-04-22 02:03:53 +00:00
|
|
|
cur_row = -1;
|
|
|
|
gtk_editable_delete_text(GTK_EDITABLE(title_te), 0, -1);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2002-04-22 02:03:53 +00:00
|
|
|
gtk_widget_set_sensitive(del_bt, FALSE);
|
|
|
|
gtk_widget_set_sensitive(title_te, FALSE);
|
|
|
|
gtk_widget_set_sensitive(fmt_m, FALSE);
|
|
|
|
gtk_widget_set_sensitive(up_bt, FALSE);
|
|
|
|
gtk_widget_set_sensitive(dn_bt, FALSE);
|
2000-01-10 01:44:00 +00:00
|
|
|
}
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
static void
|
|
|
|
column_list_select_cb(GtkTreeSelection *sel, gpointer user_data _U_)
|
|
|
|
{
|
|
|
|
fmt_data *cfmt;
|
|
|
|
GList *clp;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreePath *path;
|
|
|
|
gchar *str_path;
|
|
|
|
gchar *title;
|
|
|
|
|
|
|
|
/* if something was selected */
|
|
|
|
if (gtk_tree_selection_get_selected(sel, &model, &iter))
|
|
|
|
{
|
|
|
|
gtk_tree_model_get(model, &iter, 2, &clp, -1);
|
|
|
|
g_assert(clp != NULL);
|
|
|
|
cfmt = (fmt_data *) clp->data;
|
|
|
|
cur_fmt = get_column_format_from_str(cfmt->fmt);
|
|
|
|
g_assert(cur_fmt != -1); /* It should always be valid */
|
|
|
|
|
|
|
|
path = gtk_tree_model_get_path(model, &iter);
|
|
|
|
str_path = gtk_tree_path_to_string(path);
|
|
|
|
cur_row = atoi(str_path);
|
|
|
|
g_free(str_path);
|
|
|
|
gtk_tree_path_free(path);
|
|
|
|
|
|
|
|
title = g_strdup(cfmt->title);
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(title_te), title);
|
|
|
|
g_free(title);
|
|
|
|
|
|
|
|
gtk_editable_select_region(GTK_EDITABLE(title_te), 0, -1);
|
|
|
|
gtk_widget_grab_focus(title_te);
|
|
|
|
|
|
|
|
gtk_option_menu_set_history(GTK_OPTION_MENU(fmt_m), cur_fmt);
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive(del_bt, TRUE);
|
|
|
|
gtk_widget_set_sensitive(title_te, TRUE);
|
|
|
|
gtk_widget_set_sensitive(fmt_m, TRUE);
|
|
|
|
column_set_arrow_button_sensitivity(clp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cur_row = -1;
|
|
|
|
gtk_editable_delete_text(GTK_EDITABLE(title_te), 0, -1);
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive(del_bt, FALSE);
|
|
|
|
gtk_widget_set_sensitive(title_te, FALSE);
|
|
|
|
gtk_widget_set_sensitive(fmt_m, FALSE);
|
|
|
|
gtk_widget_set_sensitive(up_bt, FALSE);
|
|
|
|
gtk_widget_set_sensitive(dn_bt, FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2000-01-10 01:44:00 +00:00
|
|
|
|
|
|
|
/* To do: add input checking to each of these callbacks */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-01-10 01:44:00 +00:00
|
|
|
static void
|
2002-04-22 02:03:53 +00:00
|
|
|
column_list_new_cb(GtkWidget *w _U_, gpointer data _U_) {
|
2002-11-03 17:38:45 +00:00
|
|
|
fmt_data *cfmt;
|
|
|
|
gchar *title = "New Column";
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
gchar *col_ent[2];
|
|
|
|
#else
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreePath *path;
|
|
|
|
gchar *str_path;
|
|
|
|
#endif
|
2002-04-22 02:03:53 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
cur_fmt = 0;
|
|
|
|
cfmt = (fmt_data *) g_malloc(sizeof(fmt_data));
|
|
|
|
cfmt->title = g_strdup(title);
|
|
|
|
cfmt->fmt = g_strdup(col_format_to_string(cur_fmt));
|
|
|
|
prefs.col_list = g_list_append(prefs.col_list, cfmt);
|
|
|
|
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
col_ent[0] = title;
|
|
|
|
col_ent[1] = col_format_desc(cur_fmt);
|
|
|
|
cur_row = gtk_clist_append(GTK_CLIST(column_l), col_ent);
|
|
|
|
gtk_clist_set_row_data(GTK_CLIST(column_l), cur_row,
|
|
|
|
g_list_last(prefs.col_list));
|
|
|
|
|
|
|
|
gtk_clist_select_row(GTK_CLIST(column_l), cur_row, 0);
|
|
|
|
#else
|
|
|
|
model = gtk_tree_view_get_model(GTK_TREE_VIEW(column_l));
|
|
|
|
gtk_list_store_append(GTK_LIST_STORE(model), &iter);
|
|
|
|
gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, title, 1,
|
|
|
|
col_format_desc(cur_fmt), 2, g_list_last(prefs.col_list),
|
|
|
|
-1);
|
|
|
|
|
|
|
|
path = gtk_tree_model_get_path(model, &iter);
|
|
|
|
str_path = gtk_tree_path_to_string(path);
|
|
|
|
cur_row = atoi(str_path);
|
|
|
|
g_free(str_path);
|
|
|
|
gtk_tree_path_free(path);
|
|
|
|
|
|
|
|
gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(column_l)),
|
|
|
|
&iter);
|
|
|
|
#endif
|
2000-01-10 01:44:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-04-22 02:03:53 +00:00
|
|
|
column_list_delete_cb(GtkWidget *w _U_, gpointer data _U_) {
|
2002-11-03 17:38:45 +00:00
|
|
|
GList *clp;
|
|
|
|
fmt_data *cfmt;
|
|
|
|
#if GTK_MAJOR_VERSION >= 2
|
|
|
|
GtkTreeSelection *sel;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(column_l));
|
|
|
|
if (gtk_tree_selection_get_selected(sel, &model, &iter))
|
|
|
|
{
|
|
|
|
gtk_tree_model_get(model, &iter, 2, &clp, -1);
|
|
|
|
|
|
|
|
cfmt = (fmt_data *) clp->data;
|
|
|
|
g_free(cfmt->title);
|
|
|
|
g_free(cfmt->fmt);
|
|
|
|
g_free(cfmt);
|
|
|
|
prefs.col_list = g_list_remove_link(prefs.col_list, clp);
|
|
|
|
|
|
|
|
gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
g_assert(cur_row >= 0);
|
|
|
|
clp = gtk_clist_get_row_data(GTK_CLIST(column_l), cur_row);
|
|
|
|
|
|
|
|
cfmt = (fmt_data *) clp->data;
|
|
|
|
g_free(cfmt->title);
|
|
|
|
g_free(cfmt->fmt);
|
|
|
|
g_free(cfmt);
|
|
|
|
prefs.col_list = g_list_remove_link(prefs.col_list, clp);
|
2002-04-22 02:03:53 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_clist_remove(GTK_CLIST(column_l), cur_row);
|
|
|
|
#endif
|
2002-04-22 02:03:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The user changed the column title entry box. */
|
|
|
|
static void
|
|
|
|
column_entry_changed_cb(GtkEditable *te, gpointer data) {
|
2002-11-03 17:38:45 +00:00
|
|
|
fmt_data *cfmt;
|
|
|
|
GList *clp;
|
|
|
|
gchar *title;
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
GtkCList *cl = data;
|
|
|
|
|
|
|
|
if (cur_row >= 0) {
|
|
|
|
title = gtk_editable_get_chars(te, 0, -1);
|
|
|
|
clp = gtk_clist_get_row_data(cl, cur_row);
|
|
|
|
cfmt = (fmt_data *) clp->data;
|
|
|
|
|
|
|
|
gtk_clist_set_text(cl, cur_row, 0, title);
|
|
|
|
g_free(cfmt->title);
|
|
|
|
cfmt->title = title;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
GtkTreeView *tree = (GtkTreeView *)data;
|
|
|
|
GtkTreeSelection *sel;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
sel = gtk_tree_view_get_selection(tree);
|
|
|
|
if (gtk_tree_selection_get_selected(sel, &model, &iter))
|
|
|
|
{
|
|
|
|
title = gtk_editable_get_chars(te, 0, -1);
|
|
|
|
gtk_tree_model_get(model, &iter, 2, &clp, -1);
|
|
|
|
cfmt = (fmt_data *) clp->data;
|
|
|
|
|
|
|
|
gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, title, -1);
|
|
|
|
g_free(cfmt->title);
|
|
|
|
cfmt->title = title;
|
|
|
|
}
|
|
|
|
#endif
|
2000-01-10 01:44:00 +00:00
|
|
|
}
|
|
|
|
|
2002-04-22 02:03:53 +00:00
|
|
|
/* The user changed the format menu. */
|
2000-01-10 01:44:00 +00:00
|
|
|
static void
|
2002-04-22 02:03:53 +00:00
|
|
|
column_menu_changed_cb(GtkWidget *w _U_, gpointer data) {
|
2002-11-03 17:38:45 +00:00
|
|
|
fmt_data *cfmt;
|
|
|
|
GList *clp;
|
|
|
|
#if GTK_MAJOR_VERSION >= 2
|
|
|
|
GtkTreeSelection *sel;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(column_l));
|
|
|
|
if (gtk_tree_selection_get_selected(sel, &model, &iter))
|
|
|
|
{
|
|
|
|
cur_fmt = (gint) data;
|
|
|
|
gtk_tree_model_get(model, &iter, 2, &clp, -1);
|
|
|
|
cfmt = (fmt_data *) clp->data;
|
|
|
|
|
|
|
|
gtk_list_store_set(GTK_LIST_STORE(model), &iter, 1,
|
|
|
|
col_format_desc(cur_fmt), -1);
|
|
|
|
g_free(cfmt->fmt);
|
|
|
|
cfmt->fmt = g_strdup(col_format_to_string(cur_fmt));
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
|
|
|
|
if (cur_row >= 0) {
|
|
|
|
cur_fmt = (gint) data;
|
|
|
|
clp = gtk_clist_get_row_data(GTK_CLIST(column_l), cur_row);
|
|
|
|
cfmt = (fmt_data *) clp->data;
|
|
|
|
|
|
|
|
gtk_clist_set_text(GTK_CLIST(column_l), cur_row, 1,
|
|
|
|
col_format_desc(cur_fmt));
|
|
|
|
g_free(cfmt->fmt);
|
|
|
|
cfmt->fmt = g_strdup(col_format_to_string(cur_fmt));
|
|
|
|
}
|
|
|
|
#endif
|
2000-01-10 01:44:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-04-22 02:03:53 +00:00
|
|
|
column_arrow_cb(GtkWidget *w, gpointer data _U_) {
|
2002-11-03 17:38:45 +00:00
|
|
|
fmt_data *cfmt;
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
GList *clp;
|
|
|
|
gint inc = 1;
|
|
|
|
|
|
|
|
g_assert(cur_row >= 0);
|
|
|
|
|
|
|
|
if (w == up_bt)
|
|
|
|
inc = -1;
|
|
|
|
|
|
|
|
/* This would end up appending to the list. We shouldn't have to check for
|
|
|
|
appending past the end of the list. */
|
|
|
|
g_assert((cur_row + inc) >= 0);
|
|
|
|
|
|
|
|
clp = gtk_clist_get_row_data(GTK_CLIST(column_l), cur_row);
|
|
|
|
cfmt = (fmt_data *) clp->data;
|
|
|
|
prefs.col_list = g_list_remove(prefs.col_list, cfmt);
|
|
|
|
prefs.col_list = g_list_insert(prefs.col_list, cfmt, cur_row + inc);
|
|
|
|
|
|
|
|
gtk_clist_row_move(GTK_CLIST(column_l), cur_row, cur_row + inc);
|
|
|
|
clp = g_list_find(prefs.col_list, cfmt);
|
|
|
|
cur_row += inc;
|
|
|
|
gtk_clist_set_row_data(GTK_CLIST(column_l), cur_row, clp);
|
|
|
|
|
|
|
|
column_set_arrow_button_sensitivity(clp);
|
|
|
|
#else
|
|
|
|
GList *clp1, *clp2;
|
|
|
|
GtkTreeSelection *sel;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter1, iter2;
|
|
|
|
GtkTreePath *path;
|
|
|
|
gchar *title1, *format1, *title2, *format2;
|
|
|
|
|
|
|
|
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(column_l));
|
|
|
|
if (gtk_tree_selection_get_selected(sel, &model, &iter1))
|
|
|
|
{
|
|
|
|
gtk_tree_model_get(model, &iter1, 0, &title1,
|
|
|
|
1, &format1, 2, &clp1, -1);
|
|
|
|
cfmt = (fmt_data *)clp1->data;
|
|
|
|
prefs.col_list = g_list_remove(prefs.col_list, cfmt);
|
|
|
|
|
|
|
|
if (w == up_bt)
|
|
|
|
{
|
|
|
|
cur_row--;
|
|
|
|
prefs.col_list = g_list_insert(prefs.col_list, cfmt, cur_row);
|
|
|
|
path = gtk_tree_model_get_path(model, &iter1);
|
|
|
|
gtk_tree_path_prev(path);
|
|
|
|
if (!gtk_tree_model_get_iter(model, &iter2, path))
|
|
|
|
{
|
|
|
|
gtk_tree_path_free(path);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gtk_tree_path_free(path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cur_row++;
|
|
|
|
prefs.col_list = g_list_insert(prefs.col_list, cfmt, cur_row);
|
|
|
|
iter2 = iter1;
|
|
|
|
if (!gtk_tree_model_iter_next(model, &iter2))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gtk_tree_model_get(model, &iter2, 0, &title2, 1, &format2, 2,
|
|
|
|
&clp2, -1);
|
|
|
|
gtk_list_store_set(GTK_LIST_STORE(model), &iter2, 0, title1, 1,
|
|
|
|
format1, 2, clp1, -1);
|
|
|
|
gtk_list_store_set(GTK_LIST_STORE(model), &iter1, 0, title2, 1,
|
|
|
|
format2, 2, clp2, -1);
|
|
|
|
gtk_tree_selection_select_iter(sel, &iter2);
|
|
|
|
/* clp1 = g_list_find(prefs.col_list, cfmt); */
|
|
|
|
column_set_arrow_button_sensitivity(clp1);
|
|
|
|
|
|
|
|
/* free strings read from the TreeModel */
|
|
|
|
g_free(title1);
|
|
|
|
g_free(format1);
|
|
|
|
g_free(title2);
|
|
|
|
g_free(format2);
|
|
|
|
}
|
|
|
|
#endif
|
2000-01-10 01:44:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-04-22 02:03:53 +00:00
|
|
|
column_set_arrow_button_sensitivity(GList *clp) {
|
2002-11-03 17:38:45 +00:00
|
|
|
gint up_sens = FALSE, dn_sens = FALSE;
|
2002-04-22 02:03:53 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
if (clp != g_list_first(prefs.col_list))
|
|
|
|
up_sens = TRUE;
|
|
|
|
if (clp != g_list_last(prefs.col_list))
|
|
|
|
dn_sens = TRUE;
|
2002-04-22 02:03:53 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_widget_set_sensitive(up_bt, up_sens);
|
|
|
|
gtk_widget_set_sensitive(dn_bt, dn_sens);
|
2000-01-10 01:44:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-03-05 11:56:00 +00:00
|
|
|
column_prefs_fetch(GtkWidget *w _U_) {
|
2000-01-10 01:44:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-03-05 11:56:00 +00:00
|
|
|
column_prefs_apply(GtkWidget *w _U_) {
|
2000-01-10 01:44:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
Instead of each set of built-in preferences having "ok", "save",
"cancel", and "delete" methods, give them:
"fetch" - fetch from the notebook tab any values not already
stored in "prefs", and store them there, but doesn't apply them;
"apply" - apply the settings in "prefs";
"destroy" - clean up any windows created from the tab.
As we no longer have "cancel" methods, we don't have per-preference code
to revert preference values; instead, we have the common preference
dialog box code make a copy of all the current preferences, and, when
the "Cancel" button is clicked, free the current preferences and copy
the saved preferences to it, and apply the preferences.
Add an "Apply" button to the preference dialog box, which applies the
current preferences without closing the dialog box.
Treat a request to delete the preferences dialog box as equivalent to
clicking "Cancel".
Have a "remember_ptree_widget()" routine to remember all protocol tree
widgets, and use the list of those widgets when we set GUI preferences
for the protocol tree widgets, rather than setting the main protocol
tree widget and then using the list of packet windows. Move that code
out of "main.c" to "proto_draw.c", as it's not used by anything in
"main.c", but is used by stuff in "proto_draw.c".
Make the font one of the preferences we can set on the fly for protocol
tree widgets. Also make it something we can set on the fly for the
packet list widget.
svn path=/trunk/; revision=2316
2000-08-21 08:09:17 +00:00
|
|
|
column_prefs_destroy(GtkWidget *w) {
|
2002-11-03 17:38:45 +00:00
|
|
|
/* Let the list cb know we're about to destroy the widget tree, so it */
|
|
|
|
/* doesn't operate on widgets that don't exist. */
|
2002-11-09 20:52:39 +00:00
|
|
|
OBJECT_SET_DATA(w, E_COL_CM_KEY, (gpointer)TRUE);
|
2002-08-28 21:04:11 +00:00
|
|
|
}
|