Implement new_packet_list_find_row_from_data()

Goto frame should work now.

svn path=/trunk/; revision=29147
This commit is contained in:
Anders Broman 2009-07-20 16:09:50 +00:00
parent f900d9c3a5
commit 7c0fb707a5
3 changed files with 73 additions and 15 deletions

36
file.c
View File

@ -2775,7 +2775,9 @@ cf_change_time_formats(capture_file *cf)
/* Find what row this packet is in. */
if (!sorted_by_frame_column) {
/* This function is O(N), so we try to avoid using it... */
#ifndef NEW_PACKET_LIST
#ifdef NEW_PACKET_LIST
row = new_packet_list_find_row_from_data(fdata, FALSE);
#else
row = packet_list_find_row_from_data(fdata);
#endif
} else {
@ -2799,7 +2801,8 @@ cf_change_time_formats(capture_file *cf)
"command-line-specified" format; update it. */
cf->cinfo.col_buf[i][0] = '\0';
col_set_fmt_time(fdata, &cf->cinfo, cf->cinfo.col_fmt[i], i);
#ifndef NEW_PACKET_LIST
#ifdef NEW_PACKET_LIST
#else
packet_list_set_text(row, i, cf->cinfo.col_data[i]);
#endif
}
@ -3173,9 +3176,7 @@ find_packet(capture_file *cf,
int count;
int err;
gchar *err_info;
#ifndef NEW_PACKET_LIST
int row;
#endif
float progbar_val;
GTimeVal start_time;
gchar status_str[100];
@ -3332,9 +3333,13 @@ find_packet(capture_file *cf,
}
if (new_fd != NULL) {
#ifndef NEW_PACKET_LIST
#ifdef NEW_PACKET_LIST
/* Find and select */
row = new_packet_list_find_row_from_data(fdata, TRUE);
#else
/* We found a frame. Find what row it's in. */
row = packet_list_find_row_from_data(new_fd);
#endif /* NEW_PACKET_LIST */
if (row == -1) {
/* We didn't find a row even though we know that a frame
* exists that satifies the search criteria. This means that the
@ -3346,6 +3351,7 @@ find_packet(capture_file *cf,
return FALSE;
}
#ifndef NEW_PACKET_LIST
/* Select that row, make it the focus row, and make it visible. */
packet_list_set_selected_row(row);
#endif /* NEW_PACKET_LIST */
@ -3358,9 +3364,7 @@ gboolean
cf_goto_frame(capture_file *cf, guint fnumber)
{
frame_data *fdata;
#ifndef NEW_PACKET_LIST
int row;
#endif
for (fdata = cf->plist; fdata != NULL && fdata->num < fnumber; fdata = fdata->next)
;
@ -3379,7 +3383,9 @@ cf_goto_frame(capture_file *cf, guint fnumber)
return FALSE; /* we failed to go to that packet */
}
#ifndef NEW_PACKET_LIST
#ifdef NEW_PACKET_LIST
row = new_packet_list_find_row_from_data(fdata, TRUE);
#else
/* We found that packet, and it's currently being displayed.
Find what row it's in. */
row = packet_list_find_row_from_data(fdata);
@ -3395,9 +3401,7 @@ gboolean
cf_goto_top_frame(capture_file *cf)
{
frame_data *fdata;
#ifndef NEW_PACKET_LIST
int row;
#endif
frame_data *lowest_fdata = NULL;
for (fdata = cf->plist; fdata != NULL; fdata = fdata->next) {
@ -3411,7 +3415,10 @@ cf_goto_top_frame(capture_file *cf)
return FALSE;
}
#ifndef NEW_PACKET_LIST
#ifdef NEW_PACKET_LIST
/* Find and select */
row = new_packet_list_find_row_from_data(fdata, TRUE);
#else
/* We found that packet, and it's currently being displayed.
Find what row it's in. */
row = packet_list_find_row_from_data(lowest_fdata);
@ -3427,9 +3434,7 @@ gboolean
cf_goto_bottom_frame(capture_file *cf)
{
frame_data *fdata;
#ifndef NEW_PACKET_LIST
int row;
#endif
frame_data *highest_fdata = NULL;
for (fdata = cf->plist; fdata != NULL; fdata = fdata->next) {
@ -3442,7 +3447,10 @@ cf_goto_bottom_frame(capture_file *cf)
return FALSE;
}
#ifndef NEW_PACKET_LIST
#ifdef NEW_PACKET_LIST
/* Find and select */
row = new_packet_list_find_row_from_data(fdata, TRUE);
#else
/* We found that packet, and it's currently being displayed.
Find what row it's in. */
row = packet_list_find_row_from_data(highest_fdata);

View File

@ -140,7 +140,7 @@ create_view_and_model(void)
g_object_set(renderer,
"ypad", 0,
"font-desc", user_font_get_regular(),
NULL);
NULL);
for(i = 0; i < cfile.cinfo.num_cols; i++) {
col = gtk_tree_view_column_new();
@ -208,6 +208,55 @@ new_packet_list_prev(void)
g_warning("*** new_packet_list_prev() not yet implemented.");
}
gint
new_packet_list_find_row_from_data(gpointer data, gboolean select)
{
GtkTreeModel *model = GTK_TREE_MODEL(packetlist);
GtkTreeSelection *selection;
GtkTreePath *path;
GtkTreeIter iter;
frame_data *fdata;
gint row;
/* Initializes iter with the first iterator in the tree (the one at the path "0")
* and returns TRUE. Returns FALSE if the tree is empty
*/
if(!gtk_tree_model_get_iter_first(model, &iter))
return -1;
row = row_from_iter(&iter);
fdata = new_packet_list_get_row_data(row);
if(fdata == (frame_data*)data)
return row;
while (gtk_tree_model_iter_next (model,&iter)) {
row = row_from_iter(&iter);
fdata = new_packet_list_get_row_data(row);
if(fdata == (frame_data*)data){
if(select){
/* Select the row */
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(packetlist->view));
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 */
0); /* The horizontal alignment of the column */
/* Needed to get the middle and bottom panes updated? */
new_packet_list_select_cb(GTK_TREE_VIEW(packetlist->view),data);
return row;
}
}
}
return -1;
}
static void
new_packet_list_select_cb(GtkTreeView *tree_view, gpointer data _U_)
{

View File

@ -62,6 +62,7 @@ void new_packet_list_prev(void);
guint new_packet_list_append(column_info cinfo, frame_data *fdata);
frame_data * new_packet_list_get_row_data(gint row);
void new_packet_list_enable_color(gboolean enable);
gint new_packet_list_find_row_from_data(gpointer data, gboolean select);
#else
/* packet list related functions */
void packet_list_clear(void);