From Dustin Johnson: If "Update list of packets in real time" and

"Automatic scrolling in live capture" are both enabled, make the scroll
bar behavior more natural.  If the packet list is scrolled to the
bottom, scroll automatically.  If the user scrolls back, keep the packet
list scrolled at that point instead of jumping back to the end.

svn path=/trunk/; revision=22277
This commit is contained in:
Gerald Combs 2007-07-09 16:31:39 +00:00
parent afb016cc87
commit cc0f2c6efe
4 changed files with 28 additions and 3 deletions

8
file.c
View File

@ -627,6 +627,7 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
gchar *err_info;
volatile int newly_displayed_packets = 0;
dfilter_t *dfcode;
gboolean at_end;
/* Compile the current display filter.
* We assume this will not fail since cf->dfilter is only set in
@ -639,6 +640,7 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
*err = 0;
at_end = packet_list_at_end();
packet_list_freeze();
/*g_log(NULL, G_LOG_LEVEL_MESSAGE, "cf_continue_tail: %u new: %u", cf->count, to_read);*/
@ -700,7 +702,7 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
packet_list_thaw() is done, see bugzilla 1188 */
/* XXX - this cheats and looks inside the packet list to find the final
row number. */
if (newly_displayed_packets && auto_scroll_live && cf->plist_end != NULL)
if (newly_displayed_packets && auto_scroll_live && cf->plist_end != NULL && at_end)
packet_list_moveto_end();
if (cf->state == FILE_READ_ABORTED) {
@ -727,6 +729,7 @@ cf_finish_tail(capture_file *cf, int *err)
gchar *err_info;
gint64 data_offset;
dfilter_t *dfcode;
gboolean at_end;
/* Compile the current display filter.
* We assume this will not fail since cf->dfilter is only set in
@ -742,6 +745,7 @@ cf_finish_tail(capture_file *cf, int *err)
return CF_READ_ERROR;
}
at_end = packet_list_at_end();
packet_list_freeze();
while ((wtap_read(cf->wth, err, &err_info, &data_offset))) {
@ -771,7 +775,7 @@ cf_finish_tail(capture_file *cf, int *err)
return CF_READ_ABORTED;
}
if (auto_scroll_live && cf->plist_end != NULL)
if (auto_scroll_live && cf->plist_end != NULL && at_end)
/* XXX - this cheats and looks inside the packet list to find the final
row number. */
packet_list_moveto_end();

View File

@ -76,6 +76,7 @@
#define eth_clist_get_row_data gtk_clist_get_row_data
#define eth_clist_get_text gtk_clist_get_text
#define eth_clist_get_selection_info gtk_clist_get_selection_info
#define eth_clist_get_vadjustment gtk_clist_get_vadjustment
#define eth_clist_moveto gtk_clist_moveto
#define eth_clist_new gtk_clist_new
#define eth_clist_row_is_visible gtk_clist_row_is_visible
@ -583,7 +584,7 @@ packet_list_recreate(void)
packet_list_set_sel_browse(prefs.gui_plist_sel_browse, TRUE);
main_widgets_rearrange();
if(cfile.state != FILE_CLOSED)
cf_reload(&cfile);
}
@ -774,6 +775,19 @@ packet_list_moveto_end(void)
ETH_CLIST(packet_list)->rows - 1, -1, 1.0, 1.0);
}
gboolean
packet_list_at_end(void)
{
g_return_val_if_fail (packet_list != NULL, FALSE);
g_return_val_if_fail (ETH_CLIST(packet_list) != NULL, FALSE);
if (gtk_clist_row_is_visible(ETH_CLIST(packet_list), ETH_CLIST(packet_list)->rows - 1) == GTK_VISIBILITY_NONE){
return FALSE;
} else {
return TRUE;
}
}
gint
packet_list_append(const gchar *text[], gpointer data)
{

View File

@ -111,6 +111,12 @@ extern void packet_list_next(void);
*/
extern void packet_list_prev(void);
/** Get if the packet list is at its end.
*
* @return TRUE if packet list is scrolled to greater than 90% of its total length.
*/
extern gboolean packet_list_at_end(void);
/* Different modes of copying summary data */
typedef enum {
CS_TEXT, /* Packet summary data (tab separated) */

View File

@ -69,6 +69,7 @@ gpointer packet_list_get_row_data(gint);
void packet_list_set_selected_row(gint);
gint packet_list_get_sort_column(void);
void packet_list_set_sort_column(void);
gboolean packet_list_at_end(void);
#ifdef __cplusplus