- event lEvent; /* Event used for searching */
- guint32 lPosition; /* The position to scroll to */
- systemView* pSysView; /* The system being displayed */
-
- /* Do we have anything meaningfull */
- if((pSysView = (systemView*) pmData) == NULL)
- return;
-
- /* Is there an event database? */
- if(pSysView->EventDB == NULL)
- return;
-
- /* Set the pointer to the first event */
- if(pSysView->EventDB->TraceStart == NULL)
- return;
-
- /* Are we closer to the beginning? */
- if((pmVAdjust->value - (pmVAdjust->upper / 2)) < 0)
- {
- /* Set the navigation pointer to the beginning of the list */
- lEvent = pSysView->EventDB->FirstEvent;
-
- /* Calculate distance from beginning */
- lPosition = (guint32) pmVAdjust->value;
-
- /* Find the event in the event database */
- while(lPosition > 0)
- {
- lPosition--;
- if(DBEventNext(pSysView->EventDB, &lEvent) != TRUE)
+ GtkTreeIter iter;
+ int i;
+ GtkTreeModel *model = GTK_TREE_MODEL(event_viewer_data->store_m);
+ GtkTreePath *tree_path;
+ RawTraceData * raw_data;
+ ScrollDirection direction = SCROLL_NONE;
+ GList * first;
+ int event_number;
+ double value = event_viewer_data->previous_value - time_value;
+ LttTime start, end, time;
+ LttEvent * ev;
+ unsigned backward_num, minNum, maxNum;
+ LttTracefile * tf;
+ unsigned block_num, event_num;
+ unsigned size = 1, count = 0;
+ gboolean need_backward_again, backward;
+ GdkWindow * win;
+ GdkCursor * new;
+ GtkWidget* widget = gtk_widget_get_parent(event_viewer_data->hbox_v);
+
+ if(widget){
+ new = gdk_cursor_new(GDK_X_CURSOR);
+ win = gtk_widget_get_parent_window(widget);
+ gdk_window_set_cursor(win, new);
+ gdk_cursor_unref(new);
+ gdk_window_stick(win);
+ gdk_window_unstick(win);
+ }
+
+
+ // if(event_number > event_viewer_data->last_event ||
+ // event_number + list_height-1 < event_viewer_data->first_event ||
+ // event_viewer_data->first_event == -1)
+ {
+ /* no event can be reused, clear and start from nothing */
+ if(value == -1.0) direction = SCROLL_STEP_DOWN;
+ else if(value == 1.0 ) direction = SCROLL_STEP_UP;
+ else if(value == -2.0) direction = SCROLL_PAGE_DOWN;
+ else if(value == 2.0 ) direction = SCROLL_PAGE_UP;
+ else if(value == 0.0 ) direction = SCROLL_NONE;
+ else direction = SCROLL_JUMP;
+
+ switch(direction){
+ case SCROLL_STEP_UP:
+ case SCROLL_PAGE_UP:
+ if(direction == SCROLL_PAGE_UP){
+ backward = list_height>event_viewer_data->start_event_index ? TRUE : FALSE;
+ }else{
+ backward = event_viewer_data->start_event_index == 0 ? TRUE : FALSE;
+ }
+ if(backward){
+ event_viewer_data->append = FALSE;
+ do{
+ if(direction == SCROLL_PAGE_UP){
+ minNum = list_height - event_viewer_data->start_event_index ;
+ }else{
+ minNum = 1;
+ }
+
+ first = event_viewer_data->raw_trace_data_queue->head;
+ raw_data = (RawTraceData*)g_list_nth_data(first,0);
+ end = raw_data->time;
+ end.tv_nsec--;
+ ltt_event_position_get(raw_data->ep, &block_num, &event_num, &tf);
+ if(size !=0){
+ if(event_num > minNum){
+ backward_num = event_num > RESERVE_SMALL_SIZE
+ ? event_num - RESERVE_SMALL_SIZE : 1;
+ ltt_event_position_set(raw_data->ep, block_num, backward_num);
+ ltt_tracefile_seek_position(tf, raw_data->ep);
+ ev = ltt_tracefile_read(tf);
+ start = ltt_event_time(ev);
+ maxNum = G_MAXULONG;
+ }else{
+ if(block_num > 1){
+ ltt_event_position_set(raw_data->ep, block_num-1, 1);
+ ltt_tracefile_seek_position(tf, raw_data->ep);
+ ev = ltt_tracefile_read(tf);
+ start = ltt_event_time(ev);
+ }else{
+ start.tv_sec = 0;
+ start.tv_nsec = 0;
+ }
+ maxNum = G_MAXULONG;
+ }
+ }else{
+ if(block_num > count){
+ ltt_event_position_set(raw_data->ep, block_num-count, 1);
+ ltt_tracefile_seek_position(tf, raw_data->ep);
+ ev = ltt_tracefile_read(tf);
+ start = ltt_event_time(ev);
+ }else{
+ start.tv_sec = 0;
+ start.tv_nsec = 0;
+ }
+ maxNum = G_MAXULONG;
+ }
+
+ event_viewer_data->current_event_index = event_viewer_data->start_event_index;
+ get_events(event_viewer_data, start, end, maxNum, &size);
+ event_viewer_data->start_event_index = event_viewer_data->current_event_index;
+
+ if(size < minNum && (start.tv_sec !=0 || start.tv_nsec !=0))
+ need_backward_again = TRUE;
+ else need_backward_again = FALSE;
+ if(size == 0){
+ count++;
+ }else{
+ count = 0;
+ }
+ }while(need_backward_again);
+ }
+ if(direction == SCROLL_STEP_UP)
+ event_number = event_viewer_data->start_event_index - 1;
+ else
+ event_number = event_viewer_data->start_event_index - list_height;