2 * Dialog box for column preferences
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33 #include <epan/prefs.h>
34 #include <epan/column_info.h>
35 #include <epan/column.h>
37 #include "../globals.h"
39 #include "gtk/prefs_column.h"
40 #include "gtk/gtkglobals.h"
41 #include "gtk/gui_utils.h"
42 #ifdef NEW_PACKET_LIST
43 #include "gtk/new_packet_list.h"
45 #include "gtk/main_packet_list.h"
47 #include "gtk/filter_dlg.h"
48 #include "gtk/filter_autocomplete.h"
51 static GtkWidget *remove_bt, *field_te, *field_lb, *fmt_cmb;
52 static gulong column_menu_changed_handler_id;
53 static gulong column_field_changed_handler_id;
54 static gulong column_row_deleted_handler_id;
56 static void column_list_new_cb(GtkWidget *, gpointer);
57 static void column_list_delete_cb(GtkWidget *, gpointer);
58 static void column_list_select_cb(GtkTreeSelection *, gpointer);
59 static void column_menu_changed_cb(GtkWidget *, gpointer);
60 static void column_field_changed_cb(GtkEditable *, gpointer);
61 static void column_dnd_row_deleted_cb(GtkTreeModel *, GtkTreePath *, gpointer);
62 static gboolean column_title_changed_cb(GtkCellRendererText *, const gchar *, const gchar *, gpointer);
65 * Create and display the column selection widgets.
66 * Called as part of the creation of the Preferences notebook ( Edit ! Preferences )
69 column_prefs_show(GtkWidget *prefs_window) {
70 GtkWidget *main_vb, *bottom_hb, *column_l, *add_bt, *tb, *lb;
71 GtkWidget *list_vb, *list_lb, *list_sc;
72 GtkWidget *add_remove_vb;
73 GtkWidget *props_fr, *props_hb;
79 const gchar *column_titles[] = {"Title", "Field type"};
81 GtkCellRenderer *renderer;
82 GtkTreeViewColumn *column;
83 GtkTreeSelection *sel;
85 GtkTreeIter first_iter;
86 gint first_row = TRUE;
88 GtkTooltips *tooltips = gtk_tooltips_new();
90 /* Container for each row of widgets */
91 main_vb = gtk_vbox_new(FALSE, 5);
92 gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
93 gtk_widget_show(main_vb);
95 list_vb = gtk_vbox_new (FALSE, 0);
96 gtk_container_set_border_width (GTK_CONTAINER (list_vb), 5);
97 gtk_widget_show (list_vb);
98 gtk_box_pack_start (GTK_BOX (main_vb), list_vb, TRUE, TRUE, 0);
100 list_lb = gtk_label_new (("[The first list entry will be displayed as the leftmost column - Drag and drop entries to change column order]"));
101 gtk_widget_show (list_lb);
102 gtk_box_pack_start (GTK_BOX (list_vb), list_lb, FALSE, FALSE, 0);
104 list_sc = scrolled_window_new(NULL, NULL);
105 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(list_sc), GTK_SHADOW_IN);
106 gtk_container_add(GTK_CONTAINER(list_vb), list_sc);
107 gtk_widget_show(list_sc);
109 store = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER);
110 column_row_deleted_handler_id =
111 g_signal_connect(GTK_TREE_MODEL(store), "row-deleted", G_CALLBACK(column_dnd_row_deleted_cb), NULL);
113 column_l = tree_view_new(GTK_TREE_MODEL(store));
114 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(column_l), TRUE);
115 gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(column_l), FALSE);
116 gtk_tree_view_set_reorderable(GTK_TREE_VIEW(column_l), TRUE);
117 gtk_tooltips_set_tip (tooltips, column_l,
118 "Click on a title to change its name.\nDrag an item to change its order.", NULL);
120 renderer = gtk_cell_renderer_text_new();
121 g_object_set(G_OBJECT(renderer), "editable", TRUE, NULL);
122 g_signal_connect (renderer, "edited", G_CALLBACK(column_title_changed_cb), GTK_TREE_MODEL(store));
123 column = gtk_tree_view_column_new_with_attributes(column_titles[0], renderer, "text", 0, NULL);
124 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
125 gtk_tree_view_append_column(GTK_TREE_VIEW(column_l), column);
127 renderer = gtk_cell_renderer_text_new();
128 column = gtk_tree_view_column_new_with_attributes(column_titles[1], renderer, "text", 1, NULL);
129 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
130 gtk_tree_view_append_column(GTK_TREE_VIEW(column_l), column);
132 /* XXX - make this match the packet list prefs? */
133 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(column_l));
134 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
135 g_signal_connect(sel, "changed", G_CALLBACK(column_list_select_cb), NULL);
137 gtk_container_add(GTK_CONTAINER(list_sc), column_l);
138 gtk_widget_show(column_l);
140 clp = g_list_first(prefs.col_list);
142 cfmt = (fmt_data *) clp->data;
143 cur_fmt = get_column_format_from_str(cfmt->fmt);
144 if (cur_fmt == COL_CUSTOM) {
145 fmt = g_strdup_printf("%s (%s)", col_format_desc(cur_fmt), cfmt->custom_field);
147 if (cfmt->custom_field) {
148 /* Delete custom_field from previous changes */
149 g_free (cfmt->custom_field);
150 cfmt->custom_field = NULL;
152 fmt = g_strdup_printf("%s", col_format_desc(cur_fmt));
154 gtk_list_store_append(store, &iter);
155 gtk_list_store_set(store, &iter, 0, cfmt->title, 1, fmt, 2, clp, -1);
163 g_object_unref(G_OBJECT(store));
165 /* Bottom row: Add/remove buttons and properties */
166 bottom_hb = gtk_hbox_new(FALSE, 5);
167 gtk_box_pack_start (GTK_BOX (main_vb), bottom_hb, FALSE, TRUE, 0);
168 gtk_widget_show(bottom_hb);
170 /* Add / remove buttons */
171 add_remove_vb = gtk_vbox_new (TRUE, 0);
172 gtk_container_set_border_width (GTK_CONTAINER (add_remove_vb), 5);
173 gtk_box_pack_start (GTK_BOX (bottom_hb), add_remove_vb, FALSE, FALSE, 0);
174 gtk_widget_show(add_remove_vb);
176 add_bt = gtk_button_new_from_stock(GTK_STOCK_ADD);
177 g_signal_connect(add_bt, "clicked", G_CALLBACK(column_list_new_cb), column_l);
178 gtk_box_pack_start (GTK_BOX (add_remove_vb), add_bt, FALSE, FALSE, 0);
179 gtk_tooltips_set_tip (tooltips, add_bt,
180 "Add a new column at the end of the list.", NULL);
181 gtk_widget_show(add_bt);
183 remove_bt = gtk_button_new_from_stock(GTK_STOCK_REMOVE);
184 gtk_widget_set_sensitive(remove_bt, FALSE);
185 g_signal_connect(remove_bt, "clicked", G_CALLBACK(column_list_delete_cb), column_l);
186 gtk_box_pack_start (GTK_BOX (add_remove_vb), remove_bt, FALSE, FALSE, 0);
187 gtk_tooltips_set_tip (tooltips, remove_bt,
188 "Remove the selected column.", NULL);
189 gtk_widget_show(remove_bt);
191 /* properties frame */
192 props_fr = gtk_frame_new("Properties");
193 gtk_box_pack_start (GTK_BOX (bottom_hb), props_fr, TRUE, TRUE, 0);
194 gtk_widget_show(props_fr);
196 /* Column name entry and format selection */
197 tb = gtk_table_new(2, 2, FALSE);
198 gtk_container_set_border_width(GTK_CONTAINER(tb), 5);
199 gtk_container_add(GTK_CONTAINER(props_fr), tb);
200 gtk_table_set_row_spacings(GTK_TABLE(tb), 10);
201 gtk_table_set_col_spacings(GTK_TABLE(tb), 15);
204 lb = gtk_label_new("Field type:");
205 gtk_misc_set_alignment(GTK_MISC(lb), 1.0f, 0.5f);
206 gtk_table_attach_defaults(GTK_TABLE(tb), lb, 0, 1, 0, 1);
207 gtk_tooltips_set_tip (tooltips, lb,
208 "Select which packet information to present in the column.", NULL);
211 props_hb = gtk_hbox_new(FALSE, 5);
212 gtk_table_attach(GTK_TABLE(tb), props_hb, 1, 2, 0, 1, GTK_FILL, GTK_SHRINK, 0, 0);
213 gtk_tooltips_set_tip (tooltips, props_hb,
214 "Select which packet information to present in the column.", NULL);
215 gtk_widget_show(props_hb);
217 field_lb = gtk_label_new("Field name:");
218 gtk_misc_set_alignment(GTK_MISC(field_lb), 1.0f, 0.5f);
219 gtk_table_attach_defaults(GTK_TABLE(tb), field_lb, 0, 1, 1, 2);
220 gtk_widget_set_sensitive(field_lb, FALSE);
221 gtk_tooltips_set_tip (tooltips, field_lb,
222 "Field name used when field type is \"Custom\". "
223 "This string has the same syntax as a display filter string.", NULL);
224 gtk_widget_show(field_lb);
226 field_te = gtk_entry_new();
227 g_object_set_data (G_OBJECT(field_te), E_FILT_FIELD_NAME_ONLY_KEY, "");
228 g_signal_connect(field_te, "changed", G_CALLBACK(filter_te_syntax_check_cb), NULL);
230 /* XXX: column_field_changed_cb will be called for every character entered in the entry box. */
231 /* Consider Changing logic so that the field is "accepted" only when a return is entered ?? */
232 /* Also: entry shouldn't be accepted if it's not a valid filter ? */
233 column_field_changed_handler_id =
234 g_signal_connect(field_te, "changed", G_CALLBACK(column_field_changed_cb), column_l);
236 g_object_set_data(G_OBJECT(main_vb), E_FILT_AUTOCOMP_PTR_KEY, NULL);
237 g_signal_connect(field_te, "key-press-event", G_CALLBACK (filter_string_te_key_pressed_cb), NULL);
238 g_signal_connect(prefs_window, "key-press-event", G_CALLBACK (filter_parent_dlg_key_pressed_cb), NULL);
239 colorize_filter_te_as_empty(field_te);
240 gtk_table_attach_defaults(GTK_TABLE(tb), field_te, 1, 2, 1, 2);
241 gtk_widget_set_sensitive(field_te, FALSE);
242 gtk_tooltips_set_tip (tooltips, field_te,
243 "Field name used when field type is \"Custom\". "
244 "This string has the same syntax as a display filter string.", NULL);
245 gtk_widget_show(field_te);
247 fmt_cmb = gtk_combo_box_new_text();
249 for (i = 0; i < NUM_COL_FMTS; i++)
250 gtk_combo_box_append_text(GTK_COMBO_BOX(fmt_cmb), col_format_desc(i));
252 column_menu_changed_handler_id = g_signal_connect(fmt_cmb, "changed", G_CALLBACK(column_menu_changed_cb), column_l);
254 gtk_widget_set_sensitive(fmt_cmb, FALSE);
255 gtk_box_pack_start(GTK_BOX(props_hb), fmt_cmb, FALSE, FALSE, 0);
256 gtk_widget_show(fmt_cmb);
258 /* select the first menu list row. */
259 /* Triggers call to column_list_select_cb(). */
260 gtk_tree_selection_select_iter(sel, &first_iter);
267 column_prefs_add_custom(gint fmt, const gchar *title, const gchar *custom_field)
270 fmt_data *cfmt, *last_cfmt;
272 cfmt = (fmt_data *) g_malloc(sizeof(fmt_data));
273 cfmt->title = g_strdup(title);
274 cfmt->fmt = g_strdup(col_format_to_string(fmt));
275 cfmt->custom_field = g_strdup(custom_field);
277 clp = g_list_last(prefs.col_list);
278 last_cfmt = (fmt_data *) clp->data;
279 if (strcmp(last_cfmt->fmt, "%i") == 0) {
280 /* Last column is COL_INFO, add custom column before this */
281 prefs.col_list = g_list_insert(prefs.col_list, cfmt, g_list_length(prefs.col_list)-1);
283 prefs.col_list = g_list_append(prefs.col_list, cfmt);
288 column_prefs_rename(gint col, const gchar *title)
290 GList *clp = g_list_nth(prefs.col_list, col);
291 fmt_data *cfmt = (fmt_data *) clp->data;
293 g_free (cfmt->title);
294 cfmt->title = g_strdup(title);
298 column_prefs_remove(gint col)
300 GList *clp = g_list_nth(prefs.col_list, col);
301 fmt_data *cfmt = (fmt_data *) clp->data;
305 g_free(cfmt->custom_field);
307 prefs.col_list = g_list_remove_link(prefs.col_list, clp);
310 /* To do: add input checking to each of these callbacks */
313 column_list_new_cb(GtkWidget *w _U_, gpointer data) {
315 const gchar *title = "New Column";
316 GtkTreeView *column_l = GTK_TREE_VIEW(data);
320 GtkTreeViewColumn *title_column;
322 cur_fmt = COL_NUMBER; /* Set the default new column type */
323 column_prefs_add_custom (cur_fmt, title, NULL);
325 model = gtk_tree_view_get_model(column_l);
326 gtk_list_store_append(GTK_LIST_STORE(model), &iter);
327 gtk_list_store_set(GTK_LIST_STORE(model), &iter,
329 1, col_format_desc(cur_fmt),
330 2, g_list_last(prefs.col_list),
333 /* Triggers call to column_list_select_cb() */
334 gtk_tree_selection_select_iter(gtk_tree_view_get_selection(column_l), &iter);
336 /* Set the cursor to the 'Title' column of the newly added row and enable editing */
337 /* XXX: If displaying the new title ["New column"] widens the title column of the */
338 /* treeview, then the set_cursor below doesn't properly generate an entry */
339 /* box around the title text. The width of the box appears to be the column */
340 /* width before the treeview title column was widened. Seems like a bug... */
341 /* I haven't found a work-around. */
342 path = gtk_tree_model_get_path(model, &iter);
343 title_column = gtk_tree_view_get_column(column_l, 0);
344 gtk_tree_view_set_cursor(column_l, path, title_column, TRUE);
345 gtk_tree_path_free(path);
347 cfile.cinfo.columns_changed = TRUE;
352 column_list_delete_cb(GtkWidget *w _U_, gpointer data) {
353 GtkTreeView *column_l = GTK_TREE_VIEW(data);
356 GtkTreeSelection *sel;
359 GtkTreeIter new_iter;
361 sel = gtk_tree_view_get_selection(column_l);
362 if (gtk_tree_selection_get_selected(sel, &model, &iter))
364 gtk_tree_model_get(model, &iter, 2, &clp, -1);
366 cfmt = (fmt_data *) clp->data;
369 g_free(cfmt->custom_field);
371 prefs.col_list = g_list_remove_link(prefs.col_list, clp);
373 /* Change the row selection to the next row (if available) or */
374 /* the previous row (if available). If there's only one row */
375 /* in the store (no previous and no next), then the selection */
376 /* will not be changed. */
378 /* Note that gtk_tree_selection_select_iter() will trigger a */
379 /* call to column_list_select_cb(). */
382 if ( gtk_tree_model_iter_next(model, &new_iter)) {
383 gtk_tree_selection_select_iter(sel, &new_iter);
384 } else { /* "gtk_tree_model_iter_prev" */
385 GtkTreePath *path = gtk_tree_model_get_path(model, &iter);
386 if (gtk_tree_path_prev(path)) {
387 gtk_tree_model_get_iter(model, &new_iter, path);
388 gtk_tree_selection_select_iter(sel, &new_iter);
390 gtk_tree_path_free(path);
393 /* Remove the row from the list store. */
394 /* We prevent triggering call to column_row_deleted_cb() since */
395 /* the entry has already been removed from prefs.col_list and */
396 /* since rebuilding the list is not needed because the order */
397 /* of the list hasn't changed. */
399 g_signal_handler_block(model, column_row_deleted_handler_id);
401 /* list_store_remove below will trigger a call to */
402 /* column_list_select_cb() only when deleting the last entry in */
403 /* the column list. */
404 /* (This is because the selection in this case changes to */
405 /* "nothing selected" when the last row is removed. */
407 gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
409 g_signal_handler_unblock (model, column_row_deleted_handler_id);
411 cfile.cinfo.columns_changed = TRUE;
417 column_title_changed_cb(GtkCellRendererText *cell _U_, const gchar *str_path, const gchar *new_title, gpointer data) {
420 GtkTreeModel *model = (GtkTreeModel *)data;
421 GtkTreePath *path = gtk_tree_path_new_from_string (str_path);
424 gtk_tree_model_get_iter(model, &iter, path);
426 gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, new_title, -1);
428 gtk_tree_model_get(model, &iter, 2, &clp, -1);
430 cfmt = (fmt_data *) clp->data;
432 cfmt->title = g_strdup(new_title);
435 gtk_tree_path_free (path);
436 cfile.cinfo.columns_changed = TRUE;
441 * column list row selection changed.
442 * Set the "Properties" widgets to match the currently selected column row item.
446 column_list_select_cb(GtkTreeSelection *sel, gpointer data _U_)
454 /* if something was selected */
455 if (gtk_tree_selection_get_selected(sel, &model, &iter))
457 gtk_tree_model_get(model, &iter, 2, &clp, -1);
458 g_assert(clp != NULL);
459 cfmt = (fmt_data *) clp->data;
460 cur_fmt = get_column_format_from_str(cfmt->fmt);
461 g_assert(cur_fmt != -1); /* It should always be valid */
463 g_signal_handler_block (fmt_cmb, column_menu_changed_handler_id);
464 gtk_combo_box_set_active(GTK_COMBO_BOX(fmt_cmb), cur_fmt);
465 g_signal_handler_unblock(fmt_cmb, column_menu_changed_handler_id);
467 g_signal_handler_block (field_te, column_field_changed_handler_id);
468 if (cur_fmt == COL_CUSTOM) {
469 gtk_entry_set_text(GTK_ENTRY(field_te), cfmt->custom_field);
470 gtk_widget_set_sensitive(field_lb, TRUE);
471 gtk_widget_set_sensitive(field_te, TRUE);
473 gtk_editable_delete_text(GTK_EDITABLE(field_te), 0, -1);
474 gtk_widget_set_sensitive(field_lb, FALSE);
475 gtk_widget_set_sensitive(field_te, FALSE);
477 g_signal_handler_unblock(field_te, column_field_changed_handler_id);
479 gtk_widget_set_sensitive(remove_bt, TRUE);
480 gtk_widget_set_sensitive(fmt_cmb, TRUE);
484 gtk_editable_delete_text(GTK_EDITABLE(field_te), 0, -1);
486 gtk_widget_set_sensitive(remove_bt, FALSE);
487 gtk_widget_set_sensitive(field_te, FALSE);
488 gtk_widget_set_sensitive(fmt_cmb, FALSE);
494 * The user selected a new entry in the format combo-box;
495 * Note: column_menu_changed_cb is expected to be called only
496 * when the user changes the format combo-box.
498 * If no selection active in the column list:
499 * Hide 'field"; desensitize buttons.
500 * XXX: Can this happen ?
501 * If a column list selection is active:
502 * 1. Update the display of "field" as req'd (depending upon
503 * whether the active combo-box entry is the "custom"
505 * 2. Update the column_list and prefs.col_formats.
506 * Set columns_changed = TRUE.
510 column_menu_changed_cb(GtkWidget *w, gpointer data) {
511 GtkTreeView *column_l = GTK_TREE_VIEW(data);
517 GtkTreeSelection *sel;
521 sel = gtk_tree_view_get_selection(column_l);
522 if (! (gtk_tree_selection_get_selected(sel, &model, &iter)))
523 return; /* no column list selection [Can this happen ?]: ignore callback */
525 cur_cb_fmt = gtk_combo_box_get_active(GTK_COMBO_BOX(w));
526 gtk_tree_model_get(model, &iter, 2, &clp, -1);
527 cfmt = (fmt_data *) clp->data;
528 cur_fmt = get_column_format_from_str(cfmt->fmt);
530 g_assert(cur_cb_fmt != cur_fmt);
532 /* The User has selected a new format in the combo-box */
533 /* (IE: combo-box format != current selected row format) */
534 /* Update field widgets, list_store, column format array */
535 /* entry as appropriate. */
536 g_signal_handler_block (field_te, column_field_changed_handler_id);
537 if (cur_fmt == COL_CUSTOM) {
538 /* Changing from custom to non-custom */
539 gtk_editable_delete_text(GTK_EDITABLE(field_te), 0, -1);
540 fmt = g_strdup_printf("%s", col_format_desc(cur_cb_fmt));
541 gtk_widget_set_sensitive(field_lb, FALSE);
542 gtk_widget_set_sensitive(field_te, FALSE);
544 } else if (cur_cb_fmt == COL_CUSTOM) {
545 /* Changing from non-custom to custom */
546 if (cfmt->custom_field == NULL)
547 cfmt->custom_field = g_strdup("");
548 /* The following doesn't trigger a call to menu_field_changed_cb() */
549 gtk_entry_set_text(GTK_ENTRY(field_te), cfmt->custom_field);
550 fmt = g_strdup_printf("%s (%s)", col_format_desc(cur_cb_fmt), cfmt->custom_field);
551 gtk_widget_set_sensitive(field_lb, TRUE);
552 gtk_widget_set_sensitive(field_te, TRUE);
555 /* Changing from non-custom to non-custom */
556 fmt = g_strdup_printf("%s", col_format_desc(cur_cb_fmt));
558 g_signal_handler_unblock(field_te, column_field_changed_handler_id);
560 gtk_list_store_set(GTK_LIST_STORE(model), &iter, 1, fmt, -1);
563 cfmt->fmt = g_strdup(col_format_to_string(cur_cb_fmt));
564 cfile.cinfo.columns_changed = TRUE;
569 * The user changed the custom field entry box or
570 * the field entry box has been updated because a new
571 * column row with custom format has been selected.
572 * If the current field entry matches that of the current
573 * column row, this is just an update because a new
574 * column row has been selected. Do nothing.
575 * If the two are different, then update the column row & etc.
578 column_field_changed_cb(GtkEditable *te, gpointer data) {
583 GtkTreeView *tree = (GtkTreeView *)data;
584 GtkTreeSelection *sel;
588 sel = gtk_tree_view_get_selection(tree);
589 if ( ! (gtk_tree_selection_get_selected(sel, &model, &iter))) {
593 field = gtk_editable_get_chars(te, 0, -1);
594 gtk_tree_model_get(model, &iter, 2, &clp, -1);
595 cfmt = (fmt_data *) clp->data;
596 if (strcmp(cfmt->custom_field, field) == 0) {
597 return; /* no action req'd */
600 /* The user has entered a new value in the field entry box: make the req'd changes */
601 cur_fmt = get_column_format_from_str(cfmt->fmt);
602 fmt = g_strdup_printf("%s (%s)", col_format_desc(cur_fmt), field);
604 gtk_list_store_set(GTK_LIST_STORE(model), &iter, 1, fmt, -1);
606 g_free(cfmt->custom_field);
607 cfmt->custom_field = field;
608 cfile.cinfo.columns_changed = TRUE;
613 * Callback for the "row-deleted" signal emitted when a list item is dragged.
614 * http://library.gnome.org/devel/gtk/stable/GtkTreeModel.html#GtkTreeModel-rows-reordered
615 * says that DND deletes, THEN inserts the row.
617 * XXX: For the record: For Gtk+ 2.16.0 testing shows the actual sequence for drag-and-drop to be as follows:
618 * 1. Insert a new, empty row at the destination;
619 * 2. Emit a "row-inserted" signal on the model; invoke any row-inserted callbacks & etc;
620 * 3. Copy the source row data to the new (empty) destination row;
621 * 4. Delete the source row;
622 * 5. Emit a "row-deleted" signal; invoke any row-deleted callbacks & etc.
624 * The code below (invoked as a consequence of a "row-deleted" signal) rebuilds
625 * prefs.col_list by iterating over the (re-ordered) tree model.
628 column_dnd_row_deleted_cb(GtkTreeModel *model, GtkTreePath *path _U_, gpointer data _U_) {
630 GList *clp, *new_col_list = NULL;
634 * XXX - This rebuilds prefs.col_list based on the current model. We
635 * might just want to do this when the prefs are applied
637 for (items_left = gtk_tree_model_get_iter_first (model, &iter);
639 items_left = gtk_tree_model_iter_next (model, &iter)) {
641 gtk_tree_model_get(model, &iter, 2, &clp, -1);
643 prefs.col_list = g_list_remove_link(prefs.col_list, clp);
644 new_col_list = g_list_concat(new_col_list, clp);
647 if (prefs.col_list) {
648 g_warning("column_dnd_row_deleted_cb: prefs.col_list has %d leftover data",
649 g_list_length(prefs.col_list));
650 g_list_free(prefs.col_list);
653 prefs.col_list = new_col_list;
654 cfile.cinfo.columns_changed = TRUE;
659 column_prefs_fetch(GtkWidget *w _U_) {
664 column_prefs_apply(GtkWidget *w _U_)
666 /* Redraw the packet list if the columns were changed */
667 if(cfile.cinfo.columns_changed) {
668 #ifdef NEW_PACKET_LIST
669 new_packet_list_recreate();
671 packet_list_recreate();
673 cfile.cinfo.columns_changed = FALSE; /* Reset value */
679 column_prefs_destroy(GtkWidget *w _U_) {