2009-06-30 18:05:04 +00:00
|
|
|
/* new_packet_list.c
|
|
|
|
* Routines to implement a new GTK2 packet list using our custom model
|
2009-07-25 03:23:37 +00:00
|
|
|
* Copyright 2008-2009, Stephen Fisher (see AUTHORS file)
|
2009-09-20 09:12:56 +00:00
|
|
|
* Co-authors Anders Broman and Kovarththanan Rajaratnam.
|
2009-06-30 18:05:04 +00:00
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
|
|
|
* USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2009-07-01 14:37:02 +00:00
|
|
|
#ifdef NEW_PACKET_LIST
|
|
|
|
|
2009-06-30 18:05:04 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
#include "string.h"
|
|
|
|
#endif
|
|
|
|
|
2009-08-27 03:54:57 +00:00
|
|
|
#include <stdio.h>
|
2009-06-30 18:05:04 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
#include "gui_utils.h"
|
|
|
|
#include "packet_list_store.h"
|
2009-08-18 14:40:51 +00:00
|
|
|
#include "gtk/new_packet_list.h"
|
2009-06-30 18:05:04 +00:00
|
|
|
#include "epan/column_info.h"
|
2009-07-28 16:20:05 +00:00
|
|
|
#include "epan/prefs.h"
|
2009-07-29 20:58:47 +00:00
|
|
|
#include <epan/packet.h>
|
2009-08-13 20:00:36 +00:00
|
|
|
#include <epan/epan_dissect.h>
|
2009-07-01 17:39:19 +00:00
|
|
|
#include "../ui_util.h"
|
2009-09-07 12:04:59 +00:00
|
|
|
#include "../progress_dlg.h"
|
2009-08-10 20:52:56 +00:00
|
|
|
#include "../simple_dialog.h"
|
2009-06-30 18:05:04 +00:00
|
|
|
#include "epan/emem.h"
|
|
|
|
#include "globals.h"
|
|
|
|
#include "gtk/gtkglobals.h"
|
|
|
|
#include "gtk/font_utils.h"
|
2009-07-24 21:25:21 +00:00
|
|
|
#include "gtk/packet_history.h"
|
2009-06-30 18:05:04 +00:00
|
|
|
#include "epan/column.h"
|
|
|
|
#include "gtk/recent.h"
|
|
|
|
#include "gtk/keys.h"
|
|
|
|
#include "gtk/menus.h"
|
2009-07-20 06:21:35 +00:00
|
|
|
#include "color.h"
|
|
|
|
#include "color_filters.h"
|
|
|
|
#include "gtk/color_utils.h"
|
2009-07-28 22:18:19 +00:00
|
|
|
#include "gtk/capture_file_dlg.h"
|
|
|
|
#include "gtk/main_statusbar.h"
|
2009-09-19 22:51:42 +00:00
|
|
|
#include "gtk/packet_win.h"
|
2009-06-30 18:05:04 +00:00
|
|
|
|
|
|
|
static PacketList *packetlist;
|
2009-09-03 14:32:11 +00:00
|
|
|
static gboolean last_at_end = FALSE;
|
2009-07-20 06:21:35 +00:00
|
|
|
static gboolean enable_color;
|
|
|
|
|
2009-06-30 18:05:04 +00:00
|
|
|
static GtkWidget *create_view_and_model(void);
|
2009-09-21 09:25:48 +00:00
|
|
|
static void scroll_to_and_select_iter(GtkTreeModel *model, GtkTreeSelection *selection, GtkTreeIter *iter);
|
2009-06-30 18:05:04 +00:00
|
|
|
static void new_packet_list_select_cb(GtkTreeView *tree_view, gpointer data _U_);
|
2009-09-19 22:51:42 +00:00
|
|
|
static void new_packet_list_double_click_cb(GtkTreeView *treeview,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeViewColumn *col _U_,
|
|
|
|
gpointer userdata _U_);
|
2009-07-13 05:27:25 +00:00
|
|
|
static void show_cell_data_func(GtkTreeViewColumn *col,
|
|
|
|
GtkCellRenderer *renderer,
|
|
|
|
GtkTreeModel *model,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gpointer data);
|
2009-09-21 09:25:48 +00:00
|
|
|
static guint row_number_from_iter(GtkTreeIter *iter);
|
2009-06-30 18:05:04 +00:00
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
new_packet_list_create(void)
|
|
|
|
{
|
|
|
|
GtkWidget *view, *scrollwin;
|
|
|
|
|
|
|
|
scrollwin = scrolled_window_new(NULL, NULL);
|
|
|
|
|
|
|
|
view = create_view_and_model();
|
|
|
|
|
|
|
|
gtk_container_add(GTK_CONTAINER(scrollwin), view);
|
|
|
|
|
|
|
|
g_object_set_data(G_OBJECT(popup_menu_object), E_MPACKET_LIST_KEY, view);
|
|
|
|
|
|
|
|
return scrollwin;
|
|
|
|
}
|
2009-08-17 15:05:43 +00:00
|
|
|
|
2009-06-30 18:05:04 +00:00
|
|
|
guint
|
2009-09-02 19:15:02 +00:00
|
|
|
new_packet_list_append(column_info *cinfo _U_, frame_data *fdata, packet_info *pinfo _U_)
|
2009-06-30 18:05:04 +00:00
|
|
|
{
|
2009-09-01 18:29:11 +00:00
|
|
|
/* fdata should be filled with the stuff we need
|
|
|
|
* strings are built at display time.
|
|
|
|
*/
|
2009-06-30 18:05:04 +00:00
|
|
|
|
2009-09-05 10:36:29 +00:00
|
|
|
/* Return the _visible_ position */
|
2009-09-05 13:27:34 +00:00
|
|
|
return packet_list_append_record(packetlist, fdata);
|
2009-06-30 18:05:04 +00:00
|
|
|
}
|
|
|
|
|
2009-09-03 10:40:06 +00:00
|
|
|
static gboolean
|
|
|
|
right_justify_column (gint col)
|
|
|
|
{
|
|
|
|
header_field_info *hfi;
|
|
|
|
gboolean right_justify = FALSE;
|
|
|
|
|
|
|
|
switch (cfile.cinfo.col_fmt[col]) {
|
|
|
|
|
|
|
|
case COL_NUMBER:
|
|
|
|
case COL_PACKET_LENGTH:
|
|
|
|
case COL_CUMULATIVE_BYTES:
|
|
|
|
right_justify = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COL_CUSTOM:
|
|
|
|
hfi = proto_registrar_get_byname(cfile.cinfo.col_custom_field[col]);
|
2009-09-03 10:50:30 +00:00
|
|
|
/* Check if this is a valid field and we have no strings lookup table */
|
2009-09-03 10:40:06 +00:00
|
|
|
if ((hfi != NULL) && (hfi->strings == NULL)) {
|
|
|
|
/* Check for bool, framenum and decimal/octal integer types */
|
|
|
|
if ((hfi->type == FT_BOOLEAN) || (hfi->type == FT_FRAMENUM) ||
|
2009-09-04 17:42:03 +00:00
|
|
|
(((hfi->display == BASE_DEC) || (hfi->display == BASE_OCT)) &&
|
|
|
|
(IS_FT_INT(hfi->type) || IS_FT_UINT(hfi->type)))) {
|
2009-09-03 10:40:06 +00:00
|
|
|
right_justify = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return right_justify;
|
|
|
|
}
|
|
|
|
|
2009-06-30 18:05:04 +00:00
|
|
|
static GtkWidget *
|
|
|
|
create_view_and_model(void)
|
|
|
|
{
|
|
|
|
GtkTreeViewColumn *col;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
PangoLayout *layout;
|
|
|
|
gint i, col_width;
|
|
|
|
|
|
|
|
packetlist = new_packet_list_new();
|
|
|
|
|
|
|
|
packetlist->view = tree_view_new(GTK_TREE_MODEL(packetlist));
|
|
|
|
|
2009-07-05 16:22:20 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,6,0)
|
2009-06-30 18:05:04 +00:00
|
|
|
gtk_tree_view_set_fixed_height_mode(GTK_TREE_VIEW(packetlist->view),
|
2009-09-01 16:00:56 +00:00
|
|
|
TRUE);
|
2009-07-05 16:22:20 +00:00
|
|
|
#endif
|
2009-06-30 18:05:04 +00:00
|
|
|
g_signal_connect(packetlist->view, "cursor-changed",
|
|
|
|
G_CALLBACK(new_packet_list_select_cb), NULL);
|
2009-09-19 22:51:42 +00:00
|
|
|
g_signal_connect(packetlist->view, "row-activated",
|
|
|
|
G_CALLBACK(new_packet_list_double_click_cb),
|
|
|
|
g_object_get_data(G_OBJECT(popup_menu_object),
|
|
|
|
PM_PACKET_LIST_KEY));
|
2009-07-28 20:46:23 +00:00
|
|
|
g_signal_connect(packetlist->view, "button_press_event", G_CALLBACK(popup_menu_handler),
|
|
|
|
g_object_get_data(G_OBJECT(popup_menu_object), PM_PACKET_LIST_KEY));
|
|
|
|
g_object_set_data(G_OBJECT(popup_menu_object), E_MPACKET_LIST_KEY, packetlist);
|
2009-06-30 18:05:04 +00:00
|
|
|
|
2009-09-01 16:00:56 +00:00
|
|
|
/* g_object_unref(packetlist); */ /* Destroy automatically with view for now */ /* XXX - Messes up freezing & thawing */
|
2009-06-30 18:05:04 +00:00
|
|
|
|
2009-08-06 22:06:37 +00:00
|
|
|
gtk_widget_modify_font(packetlist->view, user_font_get_regular());
|
2009-06-30 18:05:04 +00:00
|
|
|
|
2009-09-11 19:13:39 +00:00
|
|
|
|
2009-09-03 17:56:57 +00:00
|
|
|
/* We need one extra column to store the entire PacketListRecord */
|
2009-06-30 18:05:04 +00:00
|
|
|
for(i = 0; i < cfile.cinfo.num_cols; i++) {
|
2009-09-03 05:35:21 +00:00
|
|
|
renderer = gtk_cell_renderer_text_new();
|
2009-09-03 10:40:06 +00:00
|
|
|
if (right_justify_column (i)) {
|
2009-09-06 05:49:00 +00:00
|
|
|
g_object_set(G_OBJECT(renderer),
|
|
|
|
"xalign",
|
|
|
|
1.0,
|
2009-09-03 05:35:21 +00:00
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
g_object_set(renderer,
|
|
|
|
"ypad", 0,
|
2009-09-06 05:49:00 +00:00
|
|
|
NULL);
|
2009-06-30 18:05:04 +00:00
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
2009-07-13 05:27:25 +00:00
|
|
|
gtk_tree_view_column_set_cell_data_func(col, renderer,
|
|
|
|
show_cell_data_func,
|
|
|
|
GINT_TO_POINTER(i),
|
|
|
|
NULL);
|
2009-06-30 18:05:04 +00:00
|
|
|
gtk_tree_view_column_set_title(col, cfile.cinfo.col_title[i]);
|
|
|
|
gtk_tree_view_column_set_sort_column_id(col, i);
|
|
|
|
gtk_tree_view_column_set_resizable(col, TRUE);
|
|
|
|
gtk_tree_view_column_set_sizing(col,GTK_TREE_VIEW_COLUMN_FIXED);
|
2009-07-02 21:06:24 +00:00
|
|
|
gtk_tree_view_column_set_reorderable(col, TRUE); /* XXX - Should this be saved in the prefs? */
|
2009-06-30 18:05:04 +00:00
|
|
|
|
2009-09-06 05:49:00 +00:00
|
|
|
/* The column can't be adjusted to a size smaller than this
|
2009-09-03 05:03:57 +00:00
|
|
|
* XXX Should we use a different value for different column formats?
|
|
|
|
*/
|
|
|
|
gtk_tree_view_column_set_min_width(col, 40);
|
|
|
|
|
|
|
|
/* Set the size the column will be displayed with */
|
2009-06-30 18:05:04 +00:00
|
|
|
col_width = recent_get_column_width(i);
|
2009-09-20 21:41:02 +00:00
|
|
|
if(col_width < 1) {
|
2009-09-21 09:25:48 +00:00
|
|
|
gint fmt;
|
|
|
|
const gchar *long_str;
|
|
|
|
|
|
|
|
fmt = get_column_format(i);
|
|
|
|
long_str = get_column_width_string(fmt, i);
|
|
|
|
layout = gtk_widget_create_pango_layout(packetlist->view, long_str);
|
|
|
|
/* the logical width and height of a PangoLayout in device units */
|
|
|
|
pango_layout_get_pixel_size(layout,
|
|
|
|
&col_width, /* width */
|
|
|
|
NULL); /* height */
|
|
|
|
if (col_width < 1){
|
|
|
|
g_warning("*** Error: A column width of %u passed to gtk_tree_view_column_set_fixed_width()\n"
|
|
|
|
"column %u Long string %s format %u",col_width,i,long_str, fmt );
|
|
|
|
}
|
2009-09-03 05:03:57 +00:00
|
|
|
gtk_tree_view_column_set_fixed_width(col, col_width);
|
2009-06-30 18:05:04 +00:00
|
|
|
g_object_unref(G_OBJECT(layout));
|
2009-09-03 05:03:57 +00:00
|
|
|
}else{
|
|
|
|
gtk_tree_view_column_set_fixed_width(col, col_width);
|
2009-06-30 18:05:04 +00:00
|
|
|
}
|
|
|
|
gtk_tree_view_append_column(GTK_TREE_VIEW(packetlist->view), col);
|
|
|
|
}
|
|
|
|
|
|
|
|
return packetlist->view;
|
|
|
|
}
|
|
|
|
|
2009-08-14 15:44:57 +00:00
|
|
|
static PacketListRecord *
|
|
|
|
new_packet_list_get_record(GtkTreeModel *model, GtkTreeIter *iter)
|
|
|
|
{
|
|
|
|
PacketListRecord *record;
|
2009-09-03 17:00:17 +00:00
|
|
|
/* The last column is reserved for the entire PacketListRecord */
|
2009-09-03 17:56:57 +00:00
|
|
|
gint record_column = gtk_tree_model_get_n_columns(model)-1;
|
2009-08-14 15:44:57 +00:00
|
|
|
|
|
|
|
gtk_tree_model_get(model, iter,
|
2009-09-03 17:00:17 +00:00
|
|
|
record_column,
|
2009-09-17 16:52:42 +00:00
|
|
|
&record,
|
2009-08-14 15:44:57 +00:00
|
|
|
-1);
|
|
|
|
|
|
|
|
return record;
|
|
|
|
}
|
|
|
|
|
2009-07-26 10:34:07 +00:00
|
|
|
void
|
|
|
|
new_packet_list_clear(void)
|
|
|
|
{
|
|
|
|
packet_history_clear();
|
|
|
|
|
|
|
|
new_packet_list_store_clear(packetlist);
|
|
|
|
gtk_widget_queue_draw(packetlist->view);
|
|
|
|
}
|
|
|
|
|
2009-06-30 18:05:04 +00:00
|
|
|
void
|
|
|
|
new_packet_list_freeze(void)
|
|
|
|
{
|
|
|
|
/* So we don't lose the model by the time we want to thaw it */
|
|
|
|
g_object_ref(packetlist);
|
|
|
|
|
|
|
|
/* Detach view from model */
|
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(packetlist->view), NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
new_packet_list_thaw(void)
|
|
|
|
{
|
2009-09-05 10:36:29 +00:00
|
|
|
/* Apply model */
|
|
|
|
gtk_tree_view_set_model( GTK_TREE_VIEW(packetlist->view), GTK_TREE_MODEL(packetlist));
|
2009-08-14 13:33:17 +00:00
|
|
|
|
2009-06-30 18:05:04 +00:00
|
|
|
/* Remove extra reference added by new_packet_list_freeze() */
|
|
|
|
g_object_unref(packetlist);
|
2009-08-16 15:33:05 +00:00
|
|
|
|
|
|
|
packets_bar_update();
|
2009-06-30 18:05:04 +00:00
|
|
|
}
|
|
|
|
|
2009-09-05 10:36:29 +00:00
|
|
|
void
|
|
|
|
new_packet_list_recreate_visible_rows(void)
|
|
|
|
{
|
2009-09-21 09:25:48 +00:00
|
|
|
|
2009-09-05 12:42:44 +00:00
|
|
|
packet_list_recreate_visible_rows(packetlist);
|
2009-09-21 09:25:48 +00:00
|
|
|
|
2009-09-05 10:36:29 +00:00
|
|
|
}
|
|
|
|
|
2009-09-07 20:45:32 +00:00
|
|
|
void new_packet_list_resize_column(gint col)
|
|
|
|
{
|
|
|
|
PangoLayout *layout;
|
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
gint col_width;
|
|
|
|
|
|
|
|
column = gtk_tree_view_get_column (GTK_TREE_VIEW(packetlist->view), col);
|
|
|
|
layout = gtk_widget_create_pango_layout(packetlist->view,
|
|
|
|
packet_list_get_widest_column_string(packetlist, col));
|
|
|
|
pango_layout_get_pixel_size(layout, &col_width, NULL);
|
|
|
|
gtk_tree_view_column_set_fixed_width(column, col_width);
|
|
|
|
g_object_unref(G_OBJECT(layout));
|
|
|
|
}
|
|
|
|
|
2009-09-07 12:04:59 +00:00
|
|
|
static void
|
|
|
|
new_packet_list_resize_columns(void)
|
|
|
|
{
|
2009-09-07 20:45:32 +00:00
|
|
|
gint progbar_loop_max;
|
|
|
|
gint progbar_loop_var;
|
2009-09-07 17:45:37 +00:00
|
|
|
|
2009-09-07 20:45:32 +00:00
|
|
|
progbar_loop_max = cfile.cinfo.num_cols;
|
2009-09-07 13:10:59 +00:00
|
|
|
|
2009-09-07 20:45:32 +00:00
|
|
|
for (progbar_loop_var = 0; progbar_loop_var < progbar_loop_max; ++progbar_loop_var)
|
|
|
|
new_packet_list_resize_column(progbar_loop_var);
|
2009-09-07 12:04:59 +00:00
|
|
|
}
|
|
|
|
|
2009-06-30 18:05:04 +00:00
|
|
|
void
|
|
|
|
new_packet_list_resize_columns_cb(GtkWidget *widget _U_, gpointer data _U_)
|
|
|
|
{
|
2009-09-07 12:04:59 +00:00
|
|
|
new_packet_list_resize_columns();
|
2009-06-30 18:05:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
new_packet_list_next(void)
|
|
|
|
{
|
2009-07-25 09:45:35 +00:00
|
|
|
GtkTreeSelection *selection;
|
|
|
|
GtkTreeIter iter;
|
2009-08-14 15:44:57 +00:00
|
|
|
GtkTreeModel *model;
|
2009-09-20 19:39:54 +00:00
|
|
|
GtkWidget *focus = gtk_window_get_focus(GTK_WINDOW(top_level));
|
2009-07-25 09:45:35 +00:00
|
|
|
|
|
|
|
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(packetlist->view));
|
2009-09-21 09:25:48 +00:00
|
|
|
/* model is filled with the current model as a convenience. */
|
|
|
|
if (!gtk_tree_selection_get_selected(selection, &model, &iter))
|
2009-07-25 09:45:35 +00:00
|
|
|
return;
|
|
|
|
|
2009-08-14 15:44:57 +00:00
|
|
|
if (!gtk_tree_model_iter_next(model, &iter))
|
2009-07-25 09:45:35 +00:00
|
|
|
return;
|
|
|
|
|
2009-09-21 09:25:48 +00:00
|
|
|
scroll_to_and_select_iter(model, selection, &iter);
|
2009-09-20 19:39:54 +00:00
|
|
|
|
|
|
|
/* Set the focus back where it was */
|
|
|
|
if (focus)
|
|
|
|
gtk_window_set_focus(GTK_WINDOW(top_level), focus);
|
2009-06-30 18:05:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
new_packet_list_prev(void)
|
|
|
|
{
|
2009-07-25 09:45:35 +00:00
|
|
|
GtkTreeSelection *selection;
|
|
|
|
GtkTreeIter iter;
|
2009-08-14 15:44:57 +00:00
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreePath *path;
|
2009-09-20 19:39:54 +00:00
|
|
|
GtkWidget *focus = gtk_window_get_focus(GTK_WINDOW(top_level));
|
2009-07-25 09:45:35 +00:00
|
|
|
|
|
|
|
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(packetlist->view));
|
2009-09-21 09:25:48 +00:00
|
|
|
/* model is filled with the current model as a convenience. */
|
|
|
|
if (!gtk_tree_selection_get_selected(selection, &model, &iter))
|
2009-07-25 09:45:35 +00:00
|
|
|
return;
|
|
|
|
|
2009-08-14 15:44:57 +00:00
|
|
|
path = gtk_tree_model_get_path(model, &iter);
|
|
|
|
|
|
|
|
if (!gtk_tree_path_prev(path))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!gtk_tree_model_get_iter(model, &iter, path))
|
2009-07-25 09:45:35 +00:00
|
|
|
return;
|
|
|
|
|
2009-09-21 09:25:48 +00:00
|
|
|
scroll_to_and_select_iter(model, selection, &iter);
|
2009-08-14 15:44:57 +00:00
|
|
|
|
|
|
|
gtk_tree_path_free(path);
|
2009-09-20 19:39:54 +00:00
|
|
|
|
|
|
|
/* Set the focus back where it was */
|
|
|
|
if (focus)
|
|
|
|
gtk_window_set_focus(GTK_WINDOW(top_level), focus);
|
2009-06-30 18:05:04 +00:00
|
|
|
}
|
2009-07-25 07:50:53 +00:00
|
|
|
|
2009-07-25 09:45:35 +00:00
|
|
|
static void
|
2009-09-21 09:25:48 +00:00
|
|
|
scroll_to_and_select_iter(GtkTreeModel *model, GtkTreeSelection *selection, GtkTreeIter *iter)
|
2009-07-25 07:50:53 +00:00
|
|
|
{
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
2009-08-14 15:44:57 +00:00
|
|
|
g_assert(model);
|
|
|
|
|
2009-07-25 07:50:53 +00:00
|
|
|
/* Select the row */
|
2009-09-21 09:25:48 +00:00
|
|
|
if(!selection)
|
|
|
|
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(packetlist->view));
|
2009-07-25 07:50:53 +00:00
|
|
|
gtk_tree_selection_select_iter (selection, iter);
|
|
|
|
path = gtk_tree_model_get_path(model, iter);
|
|
|
|
gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(packetlist->view),
|
|
|
|
path,
|
|
|
|
NULL,
|
|
|
|
TRUE, /* use_align */
|
|
|
|
0.5, /* row_align determines where the row is placed, 0.5 means center */
|
2009-09-05 12:42:44 +00:00
|
|
|
0); /* The horizontal alignment of the column */
|
2009-07-25 07:50:53 +00:00
|
|
|
gtk_tree_view_set_cursor(GTK_TREE_VIEW(packetlist->view),
|
|
|
|
path,
|
|
|
|
NULL,
|
|
|
|
FALSE); /* start_editing */
|
|
|
|
|
|
|
|
/* Needed to get the middle and bottom panes updated */
|
|
|
|
new_packet_list_select_cb(GTK_TREE_VIEW(packetlist->view), NULL);
|
2009-09-02 17:29:52 +00:00
|
|
|
|
|
|
|
gtk_tree_path_free(path);
|
2009-07-25 07:50:53 +00:00
|
|
|
}
|
|
|
|
|
2009-07-24 08:10:33 +00:00
|
|
|
void
|
|
|
|
new_packet_list_select_first_row(void)
|
|
|
|
{
|
2009-08-14 15:56:23 +00:00
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(packetlist->view));
|
2009-07-24 08:10:33 +00:00
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
if(!gtk_tree_model_get_iter_first(model, &iter))
|
|
|
|
return;
|
|
|
|
|
2009-09-21 09:25:48 +00:00
|
|
|
scroll_to_and_select_iter(model, NULL, &iter);
|
2009-07-25 07:50:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
new_packet_list_select_last_row(void)
|
|
|
|
{
|
2009-08-14 15:56:23 +00:00
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(packetlist->view));
|
2009-07-25 07:50:53 +00:00
|
|
|
GtkTreeIter iter;
|
|
|
|
gint children;
|
2009-08-14 15:56:23 +00:00
|
|
|
guint last_row;
|
2009-07-25 07:50:53 +00:00
|
|
|
|
|
|
|
if((children = gtk_tree_model_iter_n_children(model, NULL)) == 0)
|
|
|
|
return;
|
|
|
|
|
2009-08-14 15:56:23 +00:00
|
|
|
last_row = children-1;
|
|
|
|
if(!gtk_tree_model_iter_nth_child(model, &iter, NULL, last_row))
|
2009-07-25 07:50:53 +00:00
|
|
|
return;
|
|
|
|
|
2009-09-21 09:25:48 +00:00
|
|
|
scroll_to_and_select_iter(model, NULL, &iter);
|
2009-07-24 08:10:33 +00:00
|
|
|
}
|
2009-06-30 18:05:04 +00:00
|
|
|
|
2009-09-02 17:29:52 +00:00
|
|
|
void
|
|
|
|
new_packet_list_moveto_end(void)
|
|
|
|
{
|
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(packetlist->view));
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
GtkTreePath *path;
|
|
|
|
gint children;
|
|
|
|
guint last_row;
|
|
|
|
|
|
|
|
if((children = gtk_tree_model_iter_n_children(model, NULL)) == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
last_row = children-1;
|
|
|
|
if(!gtk_tree_model_iter_nth_child(model, &iter, NULL, last_row))
|
|
|
|
return;
|
|
|
|
|
|
|
|
path = gtk_tree_model_get_path(model, &iter);
|
2009-09-02 19:31:56 +00:00
|
|
|
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(packetlist->view));
|
|
|
|
|
|
|
|
if (!gtk_tree_selection_path_is_selected(selection, path)) {
|
|
|
|
/* XXX - this doesn't seem to work, i.e. gtk_tree_selection_path_is_selected() is always false? */
|
|
|
|
gtk_tree_selection_select_path(selection, path);
|
|
|
|
gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(packetlist->view),
|
|
|
|
path,
|
|
|
|
NULL,
|
|
|
|
TRUE, /* use_align */
|
|
|
|
0.5, /* row_align determines where the row is placed, 0.5 means center */
|
2009-09-05 12:42:44 +00:00
|
|
|
0); /* The horizontal alignment of the column */
|
2009-09-02 19:31:56 +00:00
|
|
|
}
|
2009-09-02 17:29:52 +00:00
|
|
|
|
|
|
|
gtk_tree_path_free(path);
|
|
|
|
}
|
|
|
|
|
2009-09-03 14:32:11 +00:00
|
|
|
gboolean
|
|
|
|
new_packet_list_check_end(void)
|
|
|
|
{
|
|
|
|
gboolean at_end = FALSE;
|
|
|
|
GtkAdjustment *adj;
|
|
|
|
|
|
|
|
adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(packetlist->view));
|
|
|
|
g_return_val_if_fail(adj != NULL, FALSE);
|
|
|
|
|
|
|
|
if (adj->value >= adj->upper - adj->page_size) {
|
|
|
|
at_end = TRUE;
|
|
|
|
}
|
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
if (adj->value > 0 && at_end != last_at_end && at_end != auto_scroll_live) {
|
|
|
|
menu_auto_scroll_live_changed(at_end);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
last_at_end = at_end;
|
|
|
|
return at_end;
|
|
|
|
}
|
|
|
|
|
2009-07-20 16:09:50 +00:00
|
|
|
gint
|
|
|
|
new_packet_list_find_row_from_data(gpointer data, gboolean select)
|
|
|
|
{
|
2009-08-14 15:44:57 +00:00
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(packetlist->view));
|
2009-07-20 16:09:50 +00:00
|
|
|
GtkTreeIter iter;
|
2009-08-14 15:44:57 +00:00
|
|
|
frame_data *fdata_needle = data;
|
2009-07-20 16:09:50 +00:00
|
|
|
|
2009-09-06 05:49:00 +00:00
|
|
|
/* Initializes iter with the first iterator in the tree (the one at the path "0")
|
2009-07-20 16:09:50 +00:00
|
|
|
* and returns TRUE. Returns FALSE if the tree is empty
|
|
|
|
*/
|
|
|
|
if(!gtk_tree_model_get_iter_first(model, &iter))
|
|
|
|
return -1;
|
|
|
|
|
2009-07-24 21:25:21 +00:00
|
|
|
do {
|
2009-08-14 15:44:57 +00:00
|
|
|
PacketListRecord *record;
|
|
|
|
frame_data *fdata;
|
2009-07-25 07:50:53 +00:00
|
|
|
|
2009-08-14 15:44:57 +00:00
|
|
|
record = new_packet_list_get_record(model, &iter);
|
|
|
|
fdata = record->fdata;
|
|
|
|
|
|
|
|
if(fdata == fdata_needle) {
|
2009-07-25 07:50:53 +00:00
|
|
|
if(select)
|
2009-09-21 09:25:48 +00:00
|
|
|
scroll_to_and_select_iter(model, NULL, &iter);
|
2009-07-25 07:50:53 +00:00
|
|
|
|
2009-08-14 15:44:57 +00:00
|
|
|
return fdata->num;
|
2009-07-20 16:09:50 +00:00
|
|
|
}
|
2009-08-14 15:44:57 +00:00
|
|
|
} while (gtk_tree_model_iter_next(model, &iter));
|
2009-07-20 16:09:50 +00:00
|
|
|
|
2009-09-01 16:00:56 +00:00
|
|
|
return -1;
|
2009-07-20 16:09:50 +00:00
|
|
|
}
|
|
|
|
|
2009-07-28 20:46:23 +00:00
|
|
|
void
|
|
|
|
new_packet_list_set_selected_row(gint row)
|
|
|
|
{
|
2009-08-14 18:29:32 +00:00
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(packetlist->view));
|
2009-07-28 20:46:23 +00:00
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
2009-08-14 18:29:32 +00:00
|
|
|
path = gtk_tree_path_new_from_indices(row-1, -1);
|
|
|
|
|
|
|
|
if (!gtk_tree_model_get_iter(model, &iter, path))
|
2009-07-28 20:46:23 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* Select the row */
|
|
|
|
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(packetlist->view));
|
|
|
|
gtk_tree_selection_select_iter (selection, &iter);
|
|
|
|
gtk_tree_view_set_cursor(GTK_TREE_VIEW(packetlist->view),
|
|
|
|
path,
|
|
|
|
NULL,
|
|
|
|
FALSE); /* start_editing */
|
|
|
|
|
|
|
|
/* Needed to get the middle and bottom panes updated */
|
|
|
|
new_packet_list_select_cb(GTK_TREE_VIEW(packetlist->view), NULL);
|
2009-08-14 18:29:32 +00:00
|
|
|
|
|
|
|
gtk_tree_path_free(path);
|
2009-07-28 20:46:23 +00:00
|
|
|
}
|
|
|
|
|
2009-09-05 12:42:44 +00:00
|
|
|
static guint
|
|
|
|
row_number_from_iter(GtkTreeIter *iter)
|
|
|
|
{
|
|
|
|
guint row;
|
|
|
|
gint *indices;
|
|
|
|
GtkTreePath *path;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
|
|
|
model = gtk_tree_view_get_model(GTK_TREE_VIEW(packetlist->view));
|
|
|
|
path = gtk_tree_model_get_path(model, iter);
|
|
|
|
indices = gtk_tree_path_get_indices(path);
|
|
|
|
g_assert(indices);
|
|
|
|
/* Indices start from 0, but rows start from 1. Hence +1 */
|
|
|
|
row = indices[0] + 1;
|
|
|
|
|
2009-09-06 05:49:00 +00:00
|
|
|
gtk_tree_path_free(path);
|
2009-09-05 12:42:44 +00:00
|
|
|
|
|
|
|
return row;
|
|
|
|
}
|
|
|
|
|
2009-06-30 18:05:04 +00:00
|
|
|
static void
|
|
|
|
new_packet_list_select_cb(GtkTreeView *tree_view, gpointer data _U_)
|
|
|
|
{
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
guint row;
|
|
|
|
|
|
|
|
selection = gtk_tree_view_get_selection(tree_view);
|
2009-08-14 15:44:57 +00:00
|
|
|
if (!gtk_tree_selection_get_selected(selection, NULL, &iter))
|
|
|
|
return;
|
2009-06-30 18:05:04 +00:00
|
|
|
|
|
|
|
/* Remove the hex display tab pages */
|
|
|
|
while(gtk_notebook_get_nth_page(GTK_NOTEBOOK(byte_nb_ptr), 0))
|
|
|
|
gtk_notebook_remove_page(GTK_NOTEBOOK(byte_nb_ptr), 0);
|
|
|
|
|
2009-09-05 12:42:44 +00:00
|
|
|
row = row_number_from_iter(&iter);
|
2009-06-30 18:05:04 +00:00
|
|
|
|
|
|
|
cf_select_packet(&cfile, row);
|
2009-09-18 14:01:10 +00:00
|
|
|
gtk_widget_grab_focus(packetlist->view);
|
2009-07-24 21:25:21 +00:00
|
|
|
|
|
|
|
/* Add newly selected frame to packet history (breadcrumbs) */
|
2009-08-14 15:44:57 +00:00
|
|
|
packet_history_add(row);
|
2009-06-30 18:05:04 +00:00
|
|
|
}
|
|
|
|
|
2009-09-19 22:51:42 +00:00
|
|
|
static void
|
|
|
|
new_packet_list_double_click_cb(GtkTreeView *treeview, GtkTreePath *path _U_,
|
|
|
|
GtkTreeViewColumn *col _U_, gpointer userdata _U_)
|
|
|
|
{
|
|
|
|
new_window_cb(GTK_WIDGET(treeview));
|
|
|
|
}
|
|
|
|
|
2009-07-28 20:46:23 +00:00
|
|
|
gboolean
|
2009-08-14 19:35:01 +00:00
|
|
|
new_packet_list_get_event_row_column(GdkEventButton *event_button,
|
|
|
|
gint *physical_row, gint *row, gint *column)
|
2009-07-28 20:46:23 +00:00
|
|
|
{
|
2009-08-14 18:29:32 +00:00
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(packetlist->view));
|
|
|
|
GtkTreePath *path;
|
|
|
|
GtkTreeViewColumn *view_column;
|
|
|
|
|
|
|
|
if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(packetlist->view),
|
|
|
|
(gint) event_button->x,
|
|
|
|
(gint) event_button->y,
|
|
|
|
&path, &view_column, NULL, NULL)) {
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GList *cols;
|
|
|
|
gint *indices;
|
2009-08-14 19:35:01 +00:00
|
|
|
PacketListRecord *record;
|
2009-08-14 18:29:32 +00:00
|
|
|
|
|
|
|
/* Fetch indices */
|
|
|
|
gtk_tree_model_get_iter(model, &iter, path);
|
|
|
|
indices = gtk_tree_path_get_indices(path);
|
|
|
|
g_assert(indices);
|
|
|
|
/* Indices start from 0. Hence +1 */
|
|
|
|
*row = indices[0] + 1;
|
|
|
|
gtk_tree_path_free(path);
|
|
|
|
|
2009-08-14 19:35:01 +00:00
|
|
|
/* Fetch physical row */
|
|
|
|
record = new_packet_list_get_record(model, &iter);
|
|
|
|
*physical_row = record->fdata->num;
|
|
|
|
|
2009-08-14 18:29:32 +00:00
|
|
|
/* Fetch column */
|
|
|
|
/* XXX -doesn't work if columns are re-arranged? */
|
|
|
|
cols = gtk_tree_view_get_columns(GTK_TREE_VIEW(packetlist->view));
|
|
|
|
*column = g_list_index(cols, (gpointer) view_column);
|
|
|
|
g_list_free(cols);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
2009-07-28 20:46:23 +00:00
|
|
|
}
|
|
|
|
|
2009-06-30 18:05:04 +00:00
|
|
|
frame_data *
|
|
|
|
new_packet_list_get_row_data(gint row)
|
|
|
|
{
|
2009-09-05 12:42:44 +00:00
|
|
|
GtkTreePath *path = gtk_tree_path_new();
|
|
|
|
GtkTreeIter iter;
|
2009-06-30 18:05:04 +00:00
|
|
|
PacketListRecord *record;
|
|
|
|
|
2009-09-05 12:42:44 +00:00
|
|
|
gtk_tree_path_append_index(path, row-1);
|
|
|
|
gtk_tree_model_get_iter(GTK_TREE_MODEL(packetlist), &iter, path);
|
|
|
|
|
|
|
|
record = new_packet_list_get_record(GTK_TREE_MODEL(packetlist), &iter);
|
|
|
|
|
|
|
|
gtk_tree_path_free(path);
|
2009-06-30 18:05:04 +00:00
|
|
|
|
|
|
|
return record->fdata;
|
|
|
|
}
|
|
|
|
|
2009-07-13 05:27:25 +00:00
|
|
|
static void
|
|
|
|
show_cell_data_func(GtkTreeViewColumn *col _U_, GtkCellRenderer *renderer,
|
2009-09-01 16:00:56 +00:00
|
|
|
GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
|
2009-07-13 05:27:25 +00:00
|
|
|
{
|
2009-07-20 06:21:35 +00:00
|
|
|
guint col_num = GPOINTER_TO_INT(data);
|
2009-08-13 21:36:01 +00:00
|
|
|
frame_data *fdata;
|
2009-08-15 05:06:27 +00:00
|
|
|
const gchar *cell_text;
|
2009-08-13 21:36:01 +00:00
|
|
|
PacketListRecord *record;
|
2009-07-13 05:27:25 +00:00
|
|
|
|
2009-08-14 15:44:57 +00:00
|
|
|
record = new_packet_list_get_record(model, iter);
|
2009-09-06 05:49:00 +00:00
|
|
|
fdata = record->fdata;
|
|
|
|
|
|
|
|
if (!record->columnized || !record->colorized) {
|
2009-09-07 19:50:19 +00:00
|
|
|
packet_list_dissect_and_cache_iter(packetlist, iter,
|
2009-09-06 05:49:00 +00:00
|
|
|
!record->columnized,
|
|
|
|
!record->colorized);
|
2009-08-10 20:52:56 +00:00
|
|
|
}
|
|
|
|
|
2009-09-01 16:00:56 +00:00
|
|
|
g_assert(fdata->col_text);
|
|
|
|
|
2009-07-27 03:34:57 +00:00
|
|
|
if (col_based_on_frame_data(&cfile.cinfo, col_num)) {
|
2009-09-08 19:00:54 +00:00
|
|
|
col_fill_in_frame_data(fdata, &cfile.cinfo, col_num, FALSE);
|
2009-08-15 05:06:27 +00:00
|
|
|
cell_text = cfile.cinfo.col_data[col_num];
|
|
|
|
}else
|
2009-08-21 10:12:47 +00:00
|
|
|
cell_text = fdata->col_text[col_num];
|
2009-07-13 05:27:25 +00:00
|
|
|
|
2009-09-20 07:46:12 +00:00
|
|
|
g_assert(cell_text);
|
|
|
|
|
2009-07-28 16:20:05 +00:00
|
|
|
if((fdata->color_filter)||(fdata->flags.marked)){
|
2009-07-28 22:18:19 +00:00
|
|
|
gboolean color_on = enable_color;
|
2009-09-06 05:49:00 +00:00
|
|
|
GdkColor fg_gdk;
|
|
|
|
GdkColor bg_gdk;
|
2009-07-28 22:18:19 +00:00
|
|
|
if(fdata->flags.marked){
|
|
|
|
color_t_to_gdkcolor(&fg_gdk, &prefs.gui_marked_fg);
|
|
|
|
color_t_to_gdkcolor(&bg_gdk, &prefs.gui_marked_bg);
|
|
|
|
color_on = TRUE;
|
|
|
|
}else{
|
2009-09-06 05:49:00 +00:00
|
|
|
color_t fg_color_t;
|
|
|
|
color_t bg_color_t;
|
|
|
|
color_filter_t *color_filter = fdata->color_filter;
|
|
|
|
|
2009-07-28 16:20:05 +00:00
|
|
|
fg_color_t = color_filter->fg_color;
|
|
|
|
bg_color_t = color_filter->bg_color;
|
|
|
|
color_t_to_gdkcolor(&fg_gdk, &fg_color_t);
|
|
|
|
color_t_to_gdkcolor(&bg_gdk, &bg_color_t);
|
|
|
|
}
|
2009-07-20 09:06:47 +00:00
|
|
|
g_object_set(renderer,
|
2009-09-01 16:00:56 +00:00
|
|
|
"text", cell_text,
|
|
|
|
"foreground-gdk", &fg_gdk,
|
|
|
|
"foreground-set", color_on,
|
|
|
|
"background-gdk", &bg_gdk,
|
|
|
|
"background-set", color_on,
|
|
|
|
NULL);
|
2009-07-20 09:06:47 +00:00
|
|
|
}else{
|
|
|
|
g_object_set(renderer,
|
2009-09-01 16:00:56 +00:00
|
|
|
"text", cell_text,
|
2009-09-02 17:59:56 +00:00
|
|
|
"foreground-set", FALSE,
|
|
|
|
"background-set", FALSE,
|
2009-09-01 16:00:56 +00:00
|
|
|
NULL);
|
2009-07-20 09:06:47 +00:00
|
|
|
}
|
2009-07-13 05:27:25 +00:00
|
|
|
}
|
|
|
|
|
2009-07-20 06:21:35 +00:00
|
|
|
void
|
|
|
|
new_packet_list_enable_color(gboolean enable)
|
|
|
|
{
|
|
|
|
enable_color = enable;
|
2009-07-20 11:33:02 +00:00
|
|
|
gtk_widget_queue_draw (packetlist->view);
|
2009-07-20 06:21:35 +00:00
|
|
|
}
|
|
|
|
|
2009-07-28 10:53:57 +00:00
|
|
|
void
|
|
|
|
new_packet_list_queue_draw(void)
|
|
|
|
{
|
|
|
|
gtk_widget_queue_draw (packetlist->view);
|
|
|
|
}
|
|
|
|
|
2009-07-28 22:18:19 +00:00
|
|
|
/* call this after last set_frame_mark is done */
|
2009-09-06 05:49:00 +00:00
|
|
|
static void mark_frames_ready(void)
|
2009-07-28 22:18:19 +00:00
|
|
|
{
|
2009-08-15 04:19:45 +00:00
|
|
|
file_save_update_dynamics();
|
|
|
|
packets_bar_update();
|
2009-07-28 22:18:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-15 04:19:45 +00:00
|
|
|
set_frame_mark(gboolean set, frame_data *fdata)
|
2009-07-28 22:18:19 +00:00
|
|
|
{
|
2009-08-14 18:49:48 +00:00
|
|
|
if (set)
|
2009-08-15 04:19:45 +00:00
|
|
|
cf_mark_frame(&cfile, fdata);
|
2009-08-14 18:49:48 +00:00
|
|
|
else
|
2009-08-15 04:19:45 +00:00
|
|
|
cf_unmark_frame(&cfile, fdata);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mark_all_frames(gboolean set)
|
|
|
|
{
|
|
|
|
frame_data *fdata;
|
|
|
|
|
|
|
|
/* XXX: we might need a progressbar here */
|
|
|
|
for (fdata = cfile.plist; fdata != NULL; fdata = fdata->next) {
|
|
|
|
set_frame_mark(set, fdata);
|
|
|
|
}
|
|
|
|
mark_frames_ready();
|
|
|
|
new_packet_list_queue_draw();
|
|
|
|
}
|
|
|
|
|
|
|
|
void new_packet_list_mark_all_frames_cb(GtkWidget *w _U_, gpointer data _U_)
|
|
|
|
{
|
|
|
|
mark_all_frames(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void new_packet_list_unmark_all_frames_cb(GtkWidget *w _U_, gpointer data _U_)
|
|
|
|
{
|
|
|
|
mark_all_frames(FALSE);
|
2009-07-28 22:18:19 +00:00
|
|
|
}
|
|
|
|
|
2009-08-06 22:06:37 +00:00
|
|
|
void
|
|
|
|
new_packet_list_set_font(PangoFontDescription *font)
|
|
|
|
{
|
|
|
|
gtk_widget_modify_font(packetlist->view, font);
|
|
|
|
}
|
|
|
|
|
2009-09-06 05:49:00 +00:00
|
|
|
void new_packet_list_mark_frame_cb(GtkWidget *w _U_, gpointer data _U_)
|
2009-07-28 22:18:19 +00:00
|
|
|
{
|
2009-09-21 09:25:48 +00:00
|
|
|
GtkTreeModel *model;
|
2009-07-28 22:18:19 +00:00
|
|
|
GtkTreeSelection *selection;
|
|
|
|
GtkTreeIter iter;
|
2009-08-14 18:49:48 +00:00
|
|
|
PacketListRecord *record;
|
2009-07-28 22:18:19 +00:00
|
|
|
|
|
|
|
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(packetlist->view));
|
2009-09-21 09:25:48 +00:00
|
|
|
/* model is filled with the current model as a convenience. */
|
|
|
|
gtk_tree_selection_get_selected(selection, &model, &iter);
|
2009-08-14 18:49:48 +00:00
|
|
|
record = new_packet_list_get_record(model, &iter);
|
|
|
|
|
|
|
|
set_frame_mark(!record->fdata->flags.marked, record->fdata);
|
2009-09-01 16:00:56 +00:00
|
|
|
mark_frames_ready();
|
2009-07-28 22:18:19 +00:00
|
|
|
}
|
|
|
|
|
2009-08-18 14:40:51 +00:00
|
|
|
static gboolean
|
|
|
|
get_col_text_from_record( PacketListRecord *record, gint col_num, gchar** cell_text){
|
2009-08-13 21:46:00 +00:00
|
|
|
|
2009-08-18 14:40:51 +00:00
|
|
|
if (col_based_on_frame_data(&cfile.cinfo, col_num)) {
|
2009-09-08 19:00:54 +00:00
|
|
|
col_fill_in_frame_data(record->fdata, &cfile.cinfo, col_num, FALSE);
|
2009-08-18 14:40:51 +00:00
|
|
|
*cell_text = g_strdup(cfile.cinfo.col_data[col_num]);
|
|
|
|
}else
|
2009-08-21 10:12:47 +00:00
|
|
|
*cell_text = g_strdup(record->fdata->col_text[col_num]);
|
2009-08-18 14:40:51 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
/* XXX fore some reason this does not work in th .h file XXX*/
|
|
|
|
/* Different modes of copying summary data */
|
|
|
|
typedef enum {
|
2009-09-01 16:00:56 +00:00
|
|
|
CS_TEXT, /* Packet summary data (tab separated) */
|
|
|
|
CS_CSV /* Packet summary data (comma separated) */
|
2009-08-18 14:40:51 +00:00
|
|
|
} copy_summary_type;
|
|
|
|
|
2009-09-06 05:49:00 +00:00
|
|
|
void
|
2009-08-18 14:40:51 +00:00
|
|
|
new_packet_list_copy_summary_cb(GtkWidget * w _U_, gpointer data _U_, gint copy_type)
|
|
|
|
{
|
2009-09-01 16:00:56 +00:00
|
|
|
gint col;
|
|
|
|
gchar *celltext;
|
|
|
|
GString* text;
|
2009-09-21 09:25:48 +00:00
|
|
|
GtkTreeModel *model;
|
2009-08-18 14:40:51 +00:00
|
|
|
GtkTreeSelection *selection;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
PacketListRecord *record;
|
|
|
|
|
2009-09-01 16:00:56 +00:00
|
|
|
if(CS_CSV == copy_type) {
|
|
|
|
text = g_string_new("\"");
|
|
|
|
} else {
|
|
|
|
text = g_string_new("");
|
|
|
|
}
|
2009-08-18 14:40:51 +00:00
|
|
|
|
2009-09-01 16:00:56 +00:00
|
|
|
if (cfile.current_frame) {
|
2009-08-18 14:40:51 +00:00
|
|
|
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(packetlist->view));
|
2009-09-21 09:25:48 +00:00
|
|
|
/* model is filled with the current model as a convenience. */
|
|
|
|
gtk_tree_selection_get_selected(selection, &model, &iter);
|
2009-08-18 14:40:51 +00:00
|
|
|
record = new_packet_list_get_record(model, &iter);
|
2009-09-01 16:00:56 +00:00
|
|
|
for(col = 0; col < cfile.cinfo.num_cols; ++col) {
|
|
|
|
if(col != 0) {
|
|
|
|
if(CS_CSV == copy_type) {
|
|
|
|
g_string_append(text,"\",\"");
|
|
|
|
} else {
|
|
|
|
g_string_append_c(text, '\t');
|
|
|
|
}
|
|
|
|
}
|
2009-08-19 06:04:30 +00:00
|
|
|
if(get_col_text_from_record( record, col, &celltext)){
|
2009-08-18 14:40:51 +00:00
|
|
|
g_string_append(text,celltext);
|
2009-08-19 06:04:30 +00:00
|
|
|
g_free(celltext);
|
|
|
|
}
|
2009-09-01 16:00:56 +00:00
|
|
|
}
|
|
|
|
if(CS_CSV == copy_type) {
|
|
|
|
g_string_append_c(text,'"');
|
|
|
|
}
|
|
|
|
copy_to_clipboard(text);
|
|
|
|
}
|
|
|
|
g_string_free(text,TRUE);
|
2009-08-18 14:40:51 +00:00
|
|
|
}
|
2009-08-18 23:00:42 +00:00
|
|
|
|
2009-08-27 03:54:57 +00:00
|
|
|
/* XXX for some reason this does not work in the .h file XXX*/
|
2009-09-01 16:00:56 +00:00
|
|
|
#define RECENT_KEY_COL_WIDTH "column.width"
|
2009-08-18 23:00:42 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
new_packet_list_recent_write_all(FILE *rf)
|
|
|
|
{
|
2009-09-05 14:37:02 +00:00
|
|
|
gint col, width;
|
2009-09-04 17:42:03 +00:00
|
|
|
GtkTreeViewColumn *tree_column;
|
|
|
|
|
|
|
|
fprintf (rf, "%s:", RECENT_KEY_COL_WIDTH);
|
|
|
|
for (col = 0; col < cfile.cinfo.num_cols; col++) {
|
|
|
|
if (cfile.cinfo.col_fmt[col] == COL_CUSTOM) {
|
|
|
|
fprintf (rf, " %%Cus:%s,", get_column_custom_field(col));
|
|
|
|
} else {
|
|
|
|
fprintf (rf, " %s,", col_format_to_string(cfile.cinfo.col_fmt[col]));
|
|
|
|
}
|
|
|
|
tree_column = gtk_tree_view_get_column(GTK_TREE_VIEW(GTK_TREE_VIEW(packetlist->view)), col);
|
2009-09-05 14:37:02 +00:00
|
|
|
width = gtk_tree_view_column_get_width(tree_column);
|
|
|
|
if (width == 0) {
|
|
|
|
/* We have not initialized the packet list yet, use old values */
|
|
|
|
width = recent_get_column_width (col);
|
|
|
|
}
|
|
|
|
fprintf (rf, " %d", width);
|
2009-09-04 17:42:03 +00:00
|
|
|
if (col != cfile.cinfo.num_cols-1) {
|
|
|
|
fprintf (rf, ",");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fprintf (rf, "\n");
|
2009-08-18 23:00:42 +00:00
|
|
|
}
|
|
|
|
|
2009-09-06 05:49:00 +00:00
|
|
|
GtkWidget *
|
|
|
|
new_packet_list_get_widget(void)
|
|
|
|
{
|
|
|
|
g_assert(packetlist);
|
|
|
|
g_assert(packetlist->view);
|
|
|
|
return packetlist->view;
|
|
|
|
}
|
2009-09-02 15:07:03 +00:00
|
|
|
|
2009-09-02 17:51:48 +00:00
|
|
|
void new_packet_list_colorize_packets(void)
|
|
|
|
{
|
2009-09-06 05:49:00 +00:00
|
|
|
packet_list_reset_colorized(packetlist);
|
2009-09-02 17:51:48 +00:00
|
|
|
gtk_widget_queue_draw (packetlist->view);
|
|
|
|
}
|
2009-09-07 10:03:55 +00:00
|
|
|
|
2009-06-30 18:05:04 +00:00
|
|
|
#endif /* NEW_PACKET_LIST */
|
2009-08-14 13:33:17 +00:00
|
|
|
|