e076699e |
1 | /* This file is part of the Linux Trace Toolkit viewer |
b052368a |
2 | * Copyright (C) 2003-2004 XangXiu Yang, Mathieu Desnoyers |
e076699e |
3 | * |
4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License Version 2 as |
6 | * published by the Free Software Foundation; |
7 | * |
8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU General Public License |
14 | * along with this program; if not, write to the Free Software |
15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
16 | * MA 02111-1307, USA. |
17 | */ |
18 | |
561eba2a |
19 | #ifdef HAVE_CONFIG_H |
20 | # include <config.h> |
21 | #endif |
22 | |
a1a2b649 |
23 | #include <limits.h> // for PATH_MAX |
24 | #include <stdlib.h> |
f02b5e22 |
25 | #include <ctype.h> |
26 | #include <string.h> |
27 | #include <stdlib.h> |
a1a2b649 |
28 | |
561eba2a |
29 | #include <gtk/gtk.h> |
561eba2a |
30 | |
31 | #include "callbacks.h" |
32 | #include "interface.h" |
33 | #include "support.h" |
a43d67ba |
34 | #include <ltt/trace.h> |
35 | #include <ltt/facility.h> |
36 | #include <ltt/time.h> |
37 | #include <ltt/event.h> |
2a2fa4f0 |
38 | #include <lttv/lttv.h> |
a43d67ba |
39 | #include <lttv/module.h> |
40 | #include <lttv/iattribute.h> |
41 | #include <lttv/stats.h> |
962e2228 |
42 | #include <lttv/filter.h> |
13f86ce2 |
43 | #include <lttvwindow/mainwindow.h> |
2d262115 |
44 | #include <lttvwindow/mainwindow-private.h> |
13f86ce2 |
45 | #include <lttvwindow/menu.h> |
46 | #include <lttvwindow/toolbar.h> |
501e4e70 |
47 | #include <lttvwindow/lttvwindow.h> |
a1a2b649 |
48 | #include <lttvwindow/lttvwindowtraces.h> |
e433e6d6 |
49 | #include <lttvwindow/lttv_plugin_tab.h> |
a1a2b649 |
50 | |
6c35c853 |
51 | static LttTime lttvwindow_default_time_width = { 1, 0 }; |
f02b5e22 |
52 | #define CLIP_BUF 256 // size of clipboard buffer |
f7afe191 |
53 | |
49bf71b5 |
54 | extern LttvTrace *g_init_trace ; |
561eba2a |
55 | |
ec25ff5e |
56 | |
57 | /** Array containing instanced objects. */ |
68b48a45 |
58 | extern GSList * g_main_window_list; |
561eba2a |
59 | |
a43d67ba |
60 | /** MD : keep old directory. */ |
a1a2b649 |
61 | static char remember_plugins_dir[PATH_MAX] = ""; |
62 | static char remember_trace_dir[PATH_MAX] = ""; |
6fbb1ddf |
63 | |
e433e6d6 |
64 | void tab_destructor(LttvPluginTab * ptab); |
6fbb1ddf |
65 | |
bca3b81f |
66 | MainWindow * get_window_data_struct(GtkWidget * widget); |
93ac601b |
67 | char * get_load_module(MainWindow *mw, |
68 | char ** load_module_name, int nb_module); |
69 | char * get_unload_module(MainWindow *mw, |
70 | char ** loaded_module_name, int nb_module); |
71 | char * get_remove_trace(MainWindow *mw, char ** all_trace_name, int nb_trace); |
72 | char * get_selection(MainWindow *mw, |
73 | char ** all_name, int nb, char *title, char * column_title); |
e433e6d6 |
74 | void init_tab(Tab *tab, MainWindow * mw, Tab *copy_tab, |
716e4367 |
75 | GtkNotebook * notebook, char * label); |
561eba2a |
76 | |
2d262115 |
77 | static void insert_viewer(GtkWidget* widget, lttvwindow_viewer_constructor constructor); |
49bf71b5 |
78 | |
e433e6d6 |
79 | LttvPluginTab *create_new_tab(GtkWidget* widget, gpointer user_data); |
49bf71b5 |
80 | |
501e4e70 |
81 | static gboolean lttvwindow_process_pending_requests(Tab *tab); |
202f6c8f |
82 | |
49bf71b5 |
83 | enum { |
84 | CHECKBOX_COLUMN, |
85 | NAME_COLUMN, |
86 | TOTAL_COLUMNS |
87 | }; |
561eba2a |
88 | |
36b3c068 |
89 | enum |
90 | { |
91 | MODULE_COLUMN, |
92 | N_COLUMNS |
93 | }; |
94 | |
f02b5e22 |
95 | /* Pasting routines */ |
96 | |
97 | static void MEventBox1a_receive(GtkClipboard *clipboard, |
98 | const gchar *text, |
99 | gpointer data) |
100 | { |
101 | if(text == NULL) return; |
102 | Tab *tab = (Tab *)data; |
103 | gchar buffer[CLIP_BUF]; |
104 | gchar *ptr = buffer, *ptr_ssec, *ptr_snsec, *ptr_esec, *ptr_ensec; |
105 | |
106 | strncpy(buffer, text, CLIP_BUF); |
107 | |
108 | /* start */ |
109 | while(!isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++; |
110 | /* remove leading junk */ |
111 | ptr_ssec = ptr; |
112 | while(isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++; |
113 | /* read all the first number */ |
114 | *ptr = '\0'; |
115 | ptr++; |
116 | |
117 | while(!isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++; |
118 | /* remove leading junk */ |
119 | ptr_snsec = ptr; |
120 | while(isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++; |
121 | /* read all the first number */ |
122 | *ptr = '\0'; |
123 | |
124 | /* end */ |
125 | while(!isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++; |
126 | /* remove leading junk */ |
127 | ptr_esec = ptr; |
128 | while(isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++; |
129 | /* read all the first number */ |
130 | *ptr = '\0'; |
131 | ptr++; |
132 | |
133 | while(!isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++; |
134 | /* remove leading junk */ |
135 | ptr_ensec = ptr; |
136 | while(isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++; |
137 | /* read all the first number */ |
138 | *ptr = '\0'; |
139 | |
140 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry1), |
141 | (double)strtoul(ptr_ssec, NULL, 10)); |
142 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry2), |
143 | (double)strtoul(ptr_snsec, NULL, 10)); |
144 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry3), |
145 | (double)strtoul(ptr_esec, NULL, 10)); |
146 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry4), |
147 | (double)strtoul(ptr_ensec, NULL, 10)); |
148 | } |
149 | |
150 | static gboolean on_MEventBox1a_paste(GtkWidget *widget, GdkEventButton *event, |
151 | gpointer data) |
152 | { |
153 | Tab *tab = (Tab*)data; |
154 | |
155 | GtkClipboard *clip = gtk_clipboard_get_for_display(gdk_display_get_default(), |
156 | GDK_SELECTION_PRIMARY); |
157 | gtk_clipboard_request_text(clip, |
158 | (GtkClipboardTextReceivedFunc)MEventBox1a_receive, |
159 | (gpointer)tab); |
160 | return 0; |
161 | } |
162 | |
163 | |
164 | /* Start */ |
165 | static void MEventBox1b_receive(GtkClipboard *clipboard, |
166 | const gchar *text, |
167 | gpointer data) |
168 | { |
169 | if(text == NULL) return; |
170 | Tab *tab = (Tab *)data; |
171 | gchar buffer[CLIP_BUF]; |
172 | gchar *ptr = buffer, *ptr_sec, *ptr_nsec; |
173 | |
174 | strncpy(buffer, text, CLIP_BUF); |
175 | |
176 | while(!isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++; |
177 | /* remove leading junk */ |
178 | ptr_sec = ptr; |
179 | while(isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++; |
180 | /* read all the first number */ |
181 | *ptr = '\0'; |
182 | ptr++; |
183 | |
184 | while(!isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++; |
185 | /* remove leading junk */ |
186 | ptr_nsec = ptr; |
187 | while(isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++; |
188 | /* read all the first number */ |
189 | *ptr = '\0'; |
190 | |
191 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry1), |
192 | (double)strtoul(ptr_sec, NULL, 10)); |
193 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry2), |
194 | (double)strtoul(ptr_nsec, NULL, 10)); |
195 | } |
196 | |
197 | /* Start */ |
198 | static gboolean on_MEventBox1b_paste(GtkWidget *widget, GdkEventButton *event, |
199 | gpointer data) |
200 | { |
201 | Tab *tab = (Tab*)data; |
202 | |
203 | GtkClipboard *clip = gtk_clipboard_get_for_display(gdk_display_get_default(), |
204 | GDK_SELECTION_PRIMARY); |
205 | gtk_clipboard_request_text(clip, |
206 | (GtkClipboardTextReceivedFunc)MEventBox1b_receive, |
207 | (gpointer)tab); |
208 | return 0; |
209 | } |
210 | |
211 | /* End */ |
212 | static void MEventBox3b_receive(GtkClipboard *clipboard, |
213 | const gchar *text, |
214 | gpointer data) |
215 | { |
216 | if(text == NULL) return; |
217 | Tab *tab = (Tab *)data; |
218 | gchar buffer[CLIP_BUF]; |
219 | gchar *ptr = buffer, *ptr_sec, *ptr_nsec; |
220 | |
221 | strncpy(buffer, text, CLIP_BUF); |
222 | |
223 | while(!isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++; |
224 | /* remove leading junk */ |
225 | ptr_sec = ptr; |
226 | while(isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++; |
227 | /* read all the first number */ |
228 | *ptr = '\0'; |
229 | ptr++; |
230 | |
231 | while(!isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++; |
232 | /* remove leading junk */ |
233 | ptr_nsec = ptr; |
234 | while(isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++; |
235 | /* read all the first number */ |
236 | *ptr = '\0'; |
237 | |
238 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry3), |
239 | (double)strtoul(ptr_sec, NULL, 10)); |
240 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry4), |
241 | (double)strtoul(ptr_nsec, NULL, 10)); |
242 | } |
243 | |
244 | /* End */ |
245 | static gboolean on_MEventBox3b_paste(GtkWidget *widget, GdkEventButton *event, |
246 | gpointer data) |
247 | { |
248 | Tab *tab = (Tab*)data; |
249 | |
250 | GtkClipboard *clip = gtk_clipboard_get_for_display(gdk_display_get_default(), |
251 | GDK_SELECTION_PRIMARY); |
252 | gtk_clipboard_request_text(clip, |
253 | (GtkClipboardTextReceivedFunc)MEventBox3b_receive, |
254 | (gpointer)tab); |
255 | return 0; |
256 | } |
257 | |
258 | /* Current */ |
259 | static void MEventBox5b_receive(GtkClipboard *clipboard, |
260 | const gchar *text, |
261 | gpointer data) |
262 | { |
263 | if(text == NULL) return; |
264 | Tab *tab = (Tab *)data; |
265 | gchar buffer[CLIP_BUF]; |
266 | gchar *ptr = buffer, *ptr_sec, *ptr_nsec; |
267 | |
268 | strncpy(buffer, text, CLIP_BUF); |
269 | |
270 | while(!isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++; |
271 | /* remove leading junk */ |
272 | ptr_sec = ptr; |
273 | while(isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++; |
274 | /* read all the first number */ |
275 | *ptr = '\0'; |
276 | ptr++; |
277 | |
278 | while(!isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++; |
279 | /* remove leading junk */ |
280 | ptr_nsec = ptr; |
281 | while(isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++; |
282 | /* read all the first number */ |
283 | *ptr = '\0'; |
284 | |
285 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry5), |
286 | (double)strtoul(ptr_sec, NULL, 10)); |
287 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry6), |
288 | (double)strtoul(ptr_nsec, NULL, 10)); |
289 | } |
290 | |
291 | /* Current */ |
292 | static gboolean on_MEventBox5b_paste(GtkWidget *widget, GdkEventButton *event, |
293 | gpointer data) |
294 | { |
295 | Tab *tab = (Tab*)data; |
296 | |
297 | GtkClipboard *clip = gtk_clipboard_get_for_display(gdk_display_get_default(), |
298 | GDK_SELECTION_PRIMARY); |
299 | gtk_clipboard_request_text(clip, |
300 | (GtkClipboardTextReceivedFunc)MEventBox5b_receive, |
301 | (gpointer)tab); |
302 | return 0; |
303 | } |
304 | |
58de9fc1 |
305 | /* Interval */ |
306 | static void MEventBox8_receive(GtkClipboard *clipboard, |
307 | const gchar *text, |
308 | gpointer data) |
309 | { |
310 | if(text == NULL) return; |
311 | Tab *tab = (Tab *)data; |
312 | gchar buffer[CLIP_BUF]; |
313 | gchar *ptr = buffer, *ptr_sec, *ptr_nsec; |
314 | |
315 | strncpy(buffer, text, CLIP_BUF); |
316 | |
317 | while(!isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++; |
318 | /* remove leading junk */ |
319 | ptr_sec = ptr; |
320 | while(isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++; |
321 | /* read all the first number */ |
322 | *ptr = '\0'; |
323 | ptr++; |
324 | |
325 | while(!isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++; |
326 | /* remove leading junk */ |
327 | ptr_nsec = ptr; |
328 | while(isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++; |
329 | /* read all the first number */ |
330 | *ptr = '\0'; |
331 | |
332 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry7), |
333 | (double)strtoul(ptr_sec, NULL, 10)); |
334 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry8), |
335 | (double)strtoul(ptr_nsec, NULL, 10)); |
336 | } |
337 | |
338 | /* Interval */ |
339 | static gboolean on_MEventBox8_paste(GtkWidget *widget, GdkEventButton *event, |
340 | gpointer data) |
341 | { |
342 | Tab *tab = (Tab*)data; |
343 | |
344 | GtkClipboard *clip = gtk_clipboard_get_for_display(gdk_display_get_default(), |
345 | GDK_SELECTION_PRIMARY); |
346 | gtk_clipboard_request_text(clip, |
347 | (GtkClipboardTextReceivedFunc)MEventBox8_receive, |
348 | (gpointer)tab); |
349 | return 0; |
350 | } |
351 | |
e433e6d6 |
352 | #if 0 |
353 | static void on_top_notify(GObject *gobject, |
354 | GParamSpec *arg1, |
355 | gpointer user_data) |
356 | { |
357 | Tab *tab = (Tab*)user_data; |
358 | g_message("in on_top_notify.\n"); |
f02b5e22 |
359 | |
e433e6d6 |
360 | } |
361 | #endif //0 |
b052368a |
362 | static gboolean viewer_grab_focus(GtkWidget *widget, GdkEventButton *event, |
363 | gpointer data) |
364 | { |
f37a2002 |
365 | GtkWidget *viewer = GTK_WIDGET(data); |
366 | GtkWidget *viewer_container = gtk_widget_get_parent(viewer); |
b052368a |
367 | |
368 | g_debug("FOCUS GRABBED"); |
f37a2002 |
369 | g_object_set_data(G_OBJECT(viewer_container), "focused_viewer", viewer); |
370 | return 0; |
b052368a |
371 | } |
372 | |
f02b5e22 |
373 | |
f37a2002 |
374 | static void connect_focus_recursive(GtkWidget *widget, |
375 | GtkWidget *viewer) |
376 | { |
377 | if(GTK_IS_CONTAINER(widget)) { |
378 | gtk_container_forall(GTK_CONTAINER(widget), |
379 | (GtkCallback)connect_focus_recursive, |
380 | viewer); |
1818a315 |
381 | |
382 | } |
383 | if(GTK_IS_TREE_VIEW(widget)) { |
2eef04b5 |
384 | gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(widget), TRUE); |
f37a2002 |
385 | } |
386 | gtk_widget_add_events(widget, GDK_BUTTON_PRESS_MASK); |
387 | g_signal_connect (G_OBJECT(widget), |
388 | "button-press-event", |
389 | G_CALLBACK (viewer_grab_focus), |
390 | (gpointer)viewer); |
391 | } |
b052368a |
392 | |
d27948a3 |
393 | /* Stop all the processings and call gtk_main_quit() */ |
394 | static void mainwindow_quit() |
395 | { |
396 | lttvwindowtraces_unregister_requests(g_quark_from_string("stats")); |
397 | lttvwindowtraces_unregister_requests(g_quark_from_string("state")); |
398 | lttvwindowtraces_unregister_computation_hooks(g_quark_from_string("stats")); |
399 | lttvwindowtraces_unregister_computation_hooks(g_quark_from_string("state")); |
400 | |
401 | gtk_main_quit(); |
402 | } |
403 | |
404 | |
abe346a3 |
405 | /* insert_viewer function constructs an instance of a viewer first, |
406 | * then inserts the widget of the instance into the container of the |
407 | * main window |
408 | */ |
409 | |
561eba2a |
410 | void |
606309a4 |
411 | insert_viewer_wrap(GtkWidget *menuitem, gpointer user_data) |
561eba2a |
412 | { |
42fcbb71 |
413 | insert_viewer((GtkWidget*)menuitem, (lttvwindow_viewer_constructor)user_data); |
561eba2a |
414 | } |
415 | |
561eba2a |
416 | |
417 | /* internal functions */ |
2d262115 |
418 | void insert_viewer(GtkWidget* widget, lttvwindow_viewer_constructor constructor) |
561eba2a |
419 | { |
b052368a |
420 | GtkWidget * viewer_container; |
501e4e70 |
421 | MainWindow * mw_data = get_window_data_struct(widget); |
6ced96ef |
422 | GtkWidget * notebook = lookup_widget(widget, "MNotebook"); |
f9334f6f |
423 | GtkWidget * viewer; |
202f6c8f |
424 | TimeInterval * time_interval; |
6ced96ef |
425 | GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), |
426 | gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook))); |
e433e6d6 |
427 | LttvPluginTab *ptab; |
6ced96ef |
428 | Tab *tab; |
429 | |
430 | if(!page) { |
e433e6d6 |
431 | ptab = create_new_tab(widget, NULL); |
6ced96ef |
432 | } else { |
e433e6d6 |
433 | ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin"); |
47cd8a09 |
434 | } |
e433e6d6 |
435 | tab = ptab->tab; |
47cd8a09 |
436 | |
b052368a |
437 | viewer_container = tab->viewer_container; |
561eba2a |
438 | |
e433e6d6 |
439 | viewer = (GtkWidget*)constructor(ptab); |
f9334f6f |
440 | if(viewer) |
f0d936c0 |
441 | { |
b052368a |
442 | //gtk_multivpaned_widget_add(GTK_MULTIVPANED(multivpaned), viewer); |
443 | |
444 | gtk_box_pack_end(GTK_BOX(viewer_container), |
445 | viewer, |
446 | TRUE, |
447 | TRUE, |
448 | 0); |
449 | |
f37a2002 |
450 | /* We want to connect the viewer_grab_focus to EVERY |
451 | * child of this widget. The little trick is to get each child |
452 | * of each GTK_CONTAINER, even subchildren. |
453 | */ |
0f9d55ef |
454 | connect_focus_recursive(viewer, viewer); |
f0d936c0 |
455 | } |
561eba2a |
456 | } |
457 | |
313bd6fc |
458 | /** |
459 | * Function to set/update traceset for the viewers |
460 | * @param tab viewer's tab |
461 | * @param traceset traceset of the main window. |
462 | * return value : |
463 | * 0 : traceset updated |
464 | * 1 : no traceset hooks to update; not an error. |
465 | */ |
466 | |
467 | int SetTraceset(Tab * tab, LttvTraceset *traceset) |
468 | { |
b052368a |
469 | LttvTracesetContext *tsc = |
470 | LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); |
471 | TimeInterval time_span = tsc->time_span; |
4249a3e8 |
472 | TimeWindow new_time_window = tab->time_window; |
473 | LttTime new_current_time = tab->current_time; |
1ba187d3 |
474 | |
475 | /* Set the tab's time window and current time if |
476 | * out of bounds */ |
477 | if(ltt_time_compare(tab->time_window.start_time, time_span.start_time) < 0 |
6f26fc38 |
478 | || ltt_time_compare(tab->time_window.end_time, |
1ba187d3 |
479 | time_span.end_time) > 0) { |
e800cf84 |
480 | new_time_window.start_time = time_span.start_time; |
481 | |
482 | new_current_time = time_span.start_time; |
1ba187d3 |
483 | |
484 | LttTime tmp_time; |
6c35c853 |
485 | |
486 | if(ltt_time_compare(lttvwindow_default_time_width, |
4249a3e8 |
487 | ltt_time_sub(time_span.end_time, time_span.start_time)) < 0 |
488 | || |
489 | ltt_time_compare(time_span.end_time, time_span.start_time) == 0) |
6c35c853 |
490 | tmp_time = lttvwindow_default_time_width; |
1ba187d3 |
491 | else |
6c35c853 |
492 | tmp_time = time_span.end_time; |
493 | |
e800cf84 |
494 | new_time_window.time_width = tmp_time ; |
a18124ff |
495 | new_time_window.time_width_double = ltt_time_to_double(tmp_time); |
6f26fc38 |
496 | new_time_window.end_time = ltt_time_add(new_time_window.start_time, |
497 | new_time_window.time_width) ; |
1ba187d3 |
498 | } |
e800cf84 |
499 | |
4249a3e8 |
500 | |
501 | |
e800cf84 |
502 | #if 0 |
1ba187d3 |
503 | /* Set scrollbar */ |
b052368a |
504 | GtkAdjustment *adjustment = gtk_range_get_adjustment(GTK_RANGE(tab->scrollbar)); |
0c5dbe3b |
505 | LttTime upper = ltt_time_sub(time_span.end_time, time_span.start_time); |
b052368a |
506 | |
507 | g_object_set(G_OBJECT(adjustment), |
508 | "lower", |
0c5dbe3b |
509 | 0.0, /* lower */ |
b052368a |
510 | "upper", |
0c5dbe3b |
511 | ltt_time_to_double(upper) |
b052368a |
512 | * NANOSECONDS_PER_SECOND, /* upper */ |
513 | "step_increment", |
514 | ltt_time_to_double(tab->time_window.time_width) |
515 | / SCROLL_STEP_PER_PAGE |
516 | * NANOSECONDS_PER_SECOND, /* step increment */ |
517 | "page_increment", |
518 | ltt_time_to_double(tab->time_window.time_width) |
519 | * NANOSECONDS_PER_SECOND, /* page increment */ |
520 | "page_size", |
521 | ltt_time_to_double(tab->time_window.time_width) |
522 | * NANOSECONDS_PER_SECOND, /* page size */ |
523 | NULL); |
524 | gtk_adjustment_changed(adjustment); |
525 | |
526 | g_object_set(G_OBJECT(adjustment), |
527 | "value", |
b9a010a2 |
528 | ltt_time_to_double( |
529 | ltt_time_sub(tab->time_window.start_time, time_span.start_time)) |
530 | * NANOSECONDS_PER_SECOND, /* value */ |
b052368a |
531 | NULL); |
532 | gtk_adjustment_value_changed(adjustment); |
1ba187d3 |
533 | |
e800cf84 |
534 | /* set the time bar. The value callbacks will change their nsec themself */ |
535 | /* start seconds */ |
536 | gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry1), |
537 | (double)time_span.start_time.tv_sec, |
538 | (double)time_span.end_time.tv_sec); |
539 | |
540 | /* end seconds */ |
541 | gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry3), |
542 | (double)time_span.start_time.tv_sec, |
543 | (double)time_span.end_time.tv_sec); |
544 | |
545 | /* current seconds */ |
546 | gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry5), |
547 | (double)time_span.start_time.tv_sec, |
548 | (double)time_span.end_time.tv_sec); |
549 | #endif //0 |
550 | |
1ba187d3 |
551 | /* Finally, call the update hooks of the viewers */ |
552 | LttvHooks * tmp; |
553 | LttvAttributeValue value; |
554 | gint retval = 0; |
555 | |
556 | |
557 | g_assert( lttv_iattribute_find_by_path(tab->attributes, |
558 | "hooks/updatetraceset", LTTV_POINTER, &value)); |
559 | |
560 | tmp = (LttvHooks*)*(value.v_pointer); |
561 | if(tmp == NULL) retval = 1; |
562 | else lttv_hooks_call(tmp,traceset); |
563 | |
4249a3e8 |
564 | time_change_manager(tab, new_time_window); |
565 | current_time_change_manager(tab, new_current_time); |
566 | |
b052368a |
567 | return retval; |
313bd6fc |
568 | } |
569 | |
570 | /** |
571 | * Function to set/update filter for the viewers |
572 | * @param tab viewer's tab |
573 | * @param filter filter of the main window. |
574 | * return value : |
575 | * -1 : error |
576 | * 0 : filters updated |
577 | * 1 : no filter hooks to update; not an error. |
578 | */ |
a998b781 |
579 | #if 0 |
313bd6fc |
580 | int SetFilter(Tab * tab, gpointer filter) |
581 | { |
582 | LttvHooks * tmp; |
583 | LttvAttributeValue value; |
584 | |
585 | g_assert(lttv_iattribute_find_by_path(tab->attributes, |
586 | "hooks/updatefilter", LTTV_POINTER, &value)); |
587 | |
588 | tmp = (LttvHooks*)*(value.v_pointer); |
589 | |
590 | if(tmp == NULL) return 1; |
591 | lttv_hooks_call(tmp,filter); |
592 | |
593 | return 0; |
594 | } |
a998b781 |
595 | #endif //0 |
313bd6fc |
596 | |
597 | |
598 | /** |
599 | * Function to redraw each viewer belonging to the current tab |
600 | * @param tab viewer's tab |
601 | */ |
602 | |
603 | void update_traceset(Tab *tab) |
604 | { |
605 | LttvAttributeValue value; |
606 | LttvHooks * tmp; |
607 | g_assert(lttv_iattribute_find_by_path(tab->attributes, |
608 | "hooks/updatetraceset", LTTV_POINTER, &value)); |
609 | tmp = (LttvHooks*)*(value.v_pointer); |
610 | if(tmp == NULL) return; |
611 | lttv_hooks_call(tmp, NULL); |
612 | } |
613 | |
abe346a3 |
614 | |
615 | /* get_label function is used to get user input, it displays an input |
616 | * box, which allows user to input a string |
617 | */ |
618 | |
561eba2a |
619 | void get_label_string (GtkWidget * text, gchar * label) |
620 | { |
621 | GtkEntry * entry = (GtkEntry*)text; |
622 | if(strlen(gtk_entry_get_text(entry))!=0) |
623 | strcpy(label,gtk_entry_get_text(entry)); |
624 | } |
625 | |
eb38aea5 |
626 | gboolean get_label(MainWindow * mw, gchar * str, gchar* dialogue_title, gchar * label_str) |
561eba2a |
627 | { |
628 | GtkWidget * dialogue; |
629 | GtkWidget * text; |
630 | GtkWidget * label; |
631 | gint id; |
632 | |
5723fa24 |
633 | dialogue = gtk_dialog_new_with_buttons(dialogue_title,NULL, |
561eba2a |
634 | GTK_DIALOG_MODAL, |
635 | GTK_STOCK_OK,GTK_RESPONSE_ACCEPT, |
636 | GTK_STOCK_CANCEL,GTK_RESPONSE_REJECT, |
637 | NULL); |
638 | |
6b1d3120 |
639 | label = gtk_label_new(label_str); |
561eba2a |
640 | gtk_widget_show(label); |
641 | |
642 | text = gtk_entry_new(); |
643 | gtk_widget_show(text); |
644 | |
645 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialogue)->vbox), label,TRUE, TRUE,0); |
646 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialogue)->vbox), text,FALSE, FALSE,0); |
647 | |
648 | id = gtk_dialog_run(GTK_DIALOG(dialogue)); |
649 | switch(id){ |
650 | case GTK_RESPONSE_ACCEPT: |
651 | get_label_string(text,str); |
652 | gtk_widget_destroy(dialogue); |
653 | break; |
654 | case GTK_RESPONSE_REJECT: |
655 | default: |
656 | gtk_widget_destroy(dialogue); |
eb38aea5 |
657 | return FALSE; |
561eba2a |
658 | } |
eb38aea5 |
659 | return TRUE; |
561eba2a |
660 | } |
661 | |
abe346a3 |
662 | |
663 | /* get_window_data_struct function is actually a lookup function, |
664 | * given a widget which is in the tree of the main window, it will |
665 | * return the MainWindow data structure associated with main window |
666 | */ |
667 | |
bca3b81f |
668 | MainWindow * get_window_data_struct(GtkWidget * widget) |
561eba2a |
669 | { |
670 | GtkWidget * mw; |
bca3b81f |
671 | MainWindow * mw_data; |
561eba2a |
672 | |
673 | mw = lookup_widget(widget, "MWindow"); |
674 | if(mw == NULL){ |
56e5a0f7 |
675 | g_info("Main window does not exist\n"); |
2d262115 |
676 | return NULL; |
561eba2a |
677 | } |
678 | |
2d262115 |
679 | mw_data = (MainWindow *) g_object_get_data(G_OBJECT(mw),"main_window_data"); |
68b48a45 |
680 | if(mw_data == NULL){ |
2eef04b5 |
681 | g_warning("Main window data does not exist\n"); |
2d262115 |
682 | return NULL; |
561eba2a |
683 | } |
68b48a45 |
684 | return mw_data; |
561eba2a |
685 | } |
686 | |
abe346a3 |
687 | |
688 | /* create_new_window function, just constructs a new main window |
689 | */ |
690 | |
68b48a45 |
691 | void create_new_window(GtkWidget* widget, gpointer user_data, gboolean clone) |
561eba2a |
692 | { |
bca3b81f |
693 | MainWindow * parent = get_window_data_struct(widget); |
561eba2a |
694 | |
561eba2a |
695 | if(clone){ |
56e5a0f7 |
696 | g_info("Clone : use the same traceset\n"); |
08b1c66e |
697 | construct_main_window(parent); |
561eba2a |
698 | }else{ |
56e5a0f7 |
699 | g_info("Empty : traceset is set to NULL\n"); |
08b1c66e |
700 | construct_main_window(NULL); |
561eba2a |
701 | } |
702 | } |
703 | |
0f9d55ef |
704 | /* Get the currently focused viewer. |
705 | * If no viewer is focused, use the first one. |
706 | * |
707 | * If no viewer available, return NULL. |
708 | */ |
b052368a |
709 | GtkWidget *viewer_container_focus(GtkWidget *container) |
710 | { |
711 | GtkWidget *widget; |
712 | |
713 | widget = (GtkWidget*)g_object_get_data(G_OBJECT(container), |
bb574a9c |
714 | "focused_viewer"); |
b052368a |
715 | |
0f9d55ef |
716 | if(widget == NULL) { |
717 | g_debug("no widget focused"); |
718 | GList *children = gtk_container_get_children(GTK_CONTAINER(container)); |
719 | |
720 | if(children != NULL) |
721 | widget = GTK_WIDGET(children->data); |
bb574a9c |
722 | g_object_set_data(G_OBJECT(container), |
723 | "focused_viewer", |
724 | widget); |
0f9d55ef |
725 | } |
726 | |
b052368a |
727 | return widget; |
728 | |
729 | |
730 | } |
731 | |
732 | gint viewer_container_position(GtkWidget *container, GtkWidget *child) |
733 | { |
734 | |
735 | if(child == NULL) return -1; |
736 | |
737 | gint pos; |
2eef04b5 |
738 | GValue value; |
739 | memset(&value, 0, sizeof(GValue)); |
b052368a |
740 | g_value_init(&value, G_TYPE_INT); |
741 | gtk_container_child_get_property(GTK_CONTAINER(container), |
742 | child, |
743 | "position", |
744 | &value); |
745 | pos = g_value_get_int(&value); |
746 | |
747 | return pos; |
748 | } |
749 | |
abe346a3 |
750 | |
751 | /* move_*_viewer functions move the selected view up/down in |
752 | * the current tab |
753 | */ |
754 | |
b052368a |
755 | void move_down_viewer(GtkWidget * widget, gpointer user_data) |
561eba2a |
756 | { |
bca3b81f |
757 | MainWindow * mw = get_window_data_struct(widget); |
6ced96ef |
758 | GtkWidget * notebook = lookup_widget(widget, "MNotebook"); |
759 | |
760 | GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), |
761 | gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook))); |
762 | |
763 | Tab *tab; |
6ced96ef |
764 | if(!page) { |
765 | return; |
766 | } else { |
e433e6d6 |
767 | LttvPluginTab *ptab; |
768 | ptab = (Tab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin"); |
769 | tab = ptab->tab; |
6ced96ef |
770 | } |
771 | |
b052368a |
772 | //gtk_multivpaned_widget_move_up(GTK_MULTIVPANED(tab->multivpaned)); |
773 | |
774 | /* change the position in the vbox */ |
775 | GtkWidget *focus_widget; |
776 | gint position; |
777 | focus_widget = viewer_container_focus(tab->viewer_container); |
778 | position = viewer_container_position(tab->viewer_container, focus_widget); |
779 | |
780 | if(position > 0) { |
781 | /* can move up one position */ |
782 | gtk_box_reorder_child(GTK_BOX(tab->viewer_container), |
783 | focus_widget, |
784 | position-1); |
785 | } |
786 | |
561eba2a |
787 | } |
788 | |
b052368a |
789 | void move_up_viewer(GtkWidget * widget, gpointer user_data) |
561eba2a |
790 | { |
bca3b81f |
791 | MainWindow * mw = get_window_data_struct(widget); |
6ced96ef |
792 | GtkWidget * notebook = lookup_widget(widget, "MNotebook"); |
793 | |
794 | GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), |
795 | gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook))); |
796 | Tab *tab; |
797 | |
798 | if(!page) { |
799 | return; |
800 | } else { |
e433e6d6 |
801 | LttvPluginTab *ptab; |
802 | ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin"); |
803 | tab = ptab->tab; |
6ced96ef |
804 | } |
805 | |
b052368a |
806 | //gtk_multivpaned_widget_move_down(GTK_MULTIVPANED(tab->multivpaned)); |
807 | /* change the position in the vbox */ |
808 | GtkWidget *focus_widget; |
809 | gint position; |
810 | focus_widget = viewer_container_focus(tab->viewer_container); |
811 | position = viewer_container_position(tab->viewer_container, focus_widget); |
812 | |
813 | if(position != -1 && |
814 | position < |
815 | g_list_length(gtk_container_get_children( |
816 | GTK_CONTAINER(tab->viewer_container)))-1 |
817 | ) { |
818 | /* can move down one position */ |
819 | gtk_box_reorder_child(GTK_BOX(tab->viewer_container), |
820 | focus_widget, |
821 | position+1); |
822 | } |
823 | |
561eba2a |
824 | } |
825 | |
abe346a3 |
826 | |
827 | /* delete_viewer deletes the selected viewer in the current tab |
828 | */ |
829 | |
561eba2a |
830 | void delete_viewer(GtkWidget * widget, gpointer user_data) |
831 | { |
bca3b81f |
832 | MainWindow * mw = get_window_data_struct(widget); |
6ced96ef |
833 | GtkWidget * notebook = lookup_widget(widget, "MNotebook"); |
834 | |
835 | GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), |
836 | gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook))); |
837 | Tab *tab; |
838 | |
839 | if(!page) { |
840 | return; |
841 | } else { |
e433e6d6 |
842 | LttvPluginTab *ptab; |
843 | ptab = (Tab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin"); |
844 | tab = ptab->tab; |
6ced96ef |
845 | } |
846 | |
b052368a |
847 | //gtk_multivpaned_widget_delete(GTK_MULTIVPANED(tab->multivpaned)); |
848 | |
849 | GtkWidget *focus_widget = viewer_container_focus(tab->viewer_container); |
850 | |
851 | if(focus_widget != NULL) |
852 | gtk_widget_destroy(focus_widget); |
853 | |
854 | g_object_set_data(G_OBJECT(tab->viewer_container), "focused_viewer", NULL); |
561eba2a |
855 | } |
856 | |
abe346a3 |
857 | |
858 | /* open_traceset will open a traceset saved in a file |
859 | * Right now, it is not finished yet, (not working) |
a43d67ba |
860 | * FIXME |
abe346a3 |
861 | */ |
862 | |
561eba2a |
863 | void open_traceset(GtkWidget * widget, gpointer user_data) |
864 | { |
2176f952 |
865 | char ** dir; |
866 | gint id; |
867 | LttvTraceset * traceset; |
bca3b81f |
868 | MainWindow * mw_data = get_window_data_struct(widget); |
68b48a45 |
869 | GtkFileSelection * file_selector = |
2176f952 |
870 | (GtkFileSelection *)gtk_file_selection_new("Select a traceset"); |
871 | |
68b48a45 |
872 | gtk_file_selection_hide_fileop_buttons(file_selector); |
c64c7ea1 |
873 | |
93ac601b |
874 | gtk_window_set_transient_for(GTK_WINDOW(file_selector), |
875 | GTK_WINDOW(mw_data->mwindow)); |
876 | |
68b48a45 |
877 | id = gtk_dialog_run(GTK_DIALOG(file_selector)); |
2176f952 |
878 | switch(id){ |
879 | case GTK_RESPONSE_ACCEPT: |
880 | case GTK_RESPONSE_OK: |
68b48a45 |
881 | dir = gtk_file_selection_get_selections (file_selector); |
2176f952 |
882 | traceset = lttv_traceset_load(dir[0]); |
56e5a0f7 |
883 | g_info("Open a trace set %s\n", dir[0]); |
2176f952 |
884 | //Not finished yet |
885 | g_strfreev(dir); |
886 | case GTK_RESPONSE_REJECT: |
887 | case GTK_RESPONSE_CANCEL: |
888 | default: |
68b48a45 |
889 | gtk_widget_destroy((GtkWidget*)file_selector); |
2176f952 |
890 | break; |
891 | } |
c64c7ea1 |
892 | |
561eba2a |
893 | } |
894 | |
501e4e70 |
895 | /* lttvwindow_process_pending_requests |
896 | * |
897 | * This internal function gets called by g_idle, taking care of the pending |
898 | * requests. It is responsible for concatenation of time intervals and position |
899 | * requests. It does it with the following algorithm organizing process traceset |
900 | * calls. Here is the detailed description of the way it works : |
901 | * |
902 | * - Events Requests Servicing Algorithm |
903 | * |
904 | * Data structures necessary : |
905 | * |
906 | * List of requests added to context : list_in |
907 | * List of requests not added to context : list_out |
908 | * |
909 | * Initial state : |
910 | * |
911 | * list_in : empty |
912 | * list_out : many events requests |
913 | * |
914 | * FIXME : insert rest of algorithm here |
915 | * |
abe346a3 |
916 | */ |
917 | |
6ea08962 |
918 | #define list_out tab->events_requests |
a43d67ba |
919 | |
501e4e70 |
920 | gboolean lttvwindow_process_pending_requests(Tab *tab) |
a8c0f09d |
921 | { |
a8c0f09d |
922 | GtkWidget* widget; |
a43d67ba |
923 | LttvTracesetContext *tsc; |
501e4e70 |
924 | LttvTracefileContext *tfc; |
501e4e70 |
925 | GSList *list_in = NULL; |
926 | LttTime end_time; |
927 | guint end_nb_events; |
2d262115 |
928 | guint count; |
501e4e70 |
929 | LttvTracesetContextPosition *end_position; |
a43d67ba |
930 | |
b052368a |
931 | if(tab == NULL) { |
932 | g_critical("Foreground processing : tab does not exist. Processing removed."); |
501e4e70 |
933 | return FALSE; |
b052368a |
934 | } |
a43d67ba |
935 | |
501e4e70 |
936 | /* There is no events requests pending : we should never have been called! */ |
6ea08962 |
937 | g_assert(g_slist_length(list_out) != 0); |
a43d67ba |
938 | |
501e4e70 |
939 | tsc = LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); |
a8c0f09d |
940 | |
abe346a3 |
941 | //set the cursor to be X shape, indicating that the computer is busy in doing its job |
a0577796 |
942 | #if 0 |
a8c0f09d |
943 | new = gdk_cursor_new(GDK_X_CURSOR); |
2d262115 |
944 | widget = lookup_widget(tab->mw->mwindow, "MToolbar1"); |
a8c0f09d |
945 | win = gtk_widget_get_parent_window(widget); |
946 | gdk_window_set_cursor(win, new); |
947 | gdk_cursor_unref(new); |
948 | gdk_window_stick(win); |
949 | gdk_window_unstick(win); |
a0577796 |
950 | #endif //0 |
a43d67ba |
951 | |
6ea08962 |
952 | g_debug("SIZE events req len : %d", g_slist_length(list_out)); |
953 | |
954 | /* Preliminary check for no trace in traceset */ |
955 | /* Unregister the routine if empty, empty list_out too */ |
956 | if(lttv_traceset_number(tsc->ts) == 0) { |
957 | |
958 | /* - For each req in list_out */ |
959 | GSList *iter = list_out; |
960 | |
961 | while(iter != NULL) { |
962 | |
963 | gboolean remove = FALSE; |
964 | gboolean free_data = FALSE; |
965 | EventsRequest *events_request = (EventsRequest *)iter->data; |
966 | |
967 | /* - Call end request for req */ |
968 | if(events_request->servicing == TRUE) |
969 | lttv_hooks_call(events_request->after_request, (gpointer)tsc); |
970 | |
971 | /* - remove req from list_out */ |
972 | /* Destroy the request */ |
973 | remove = TRUE; |
974 | free_data = TRUE; |
975 | |
976 | /* Go to next */ |
977 | if(remove) |
978 | { |
979 | GSList *remove_iter = iter; |
980 | |
981 | iter = g_slist_next(iter); |
b052368a |
982 | if(free_data) events_request_free((EventsRequest*)remove_iter->data); |
6ea08962 |
983 | list_out = g_slist_remove_link(list_out, remove_iter); |
984 | } else { // not remove |
985 | iter = g_slist_next(iter); |
986 | } |
987 | } |
988 | } |
088f6772 |
989 | |
b052368a |
990 | /* 0.1 Lock Traces */ |
991 | { |
992 | guint iter_trace=0; |
993 | |
994 | for(iter_trace=0; |
995 | iter_trace<lttv_traceset_number(tsc->ts); |
996 | iter_trace++) { |
997 | LttvTrace *trace_v = lttv_traceset_get(tsc->ts, iter_trace); |
998 | |
999 | if(lttvwindowtraces_lock(trace_v) != 0) { |
1000 | g_critical("Foreground processing : Unable to get trace lock"); |
1001 | return TRUE; /* Cannot get lock, try later */ |
1002 | } |
1003 | } |
1004 | } |
1005 | |
1006 | /* 0.2 Seek tracefiles positions to context position */ |
088f6772 |
1007 | //g_assert(lttv_process_traceset_seek_position(tsc, sync_position) == 0); |
b052368a |
1008 | lttv_process_traceset_synchronize_tracefiles(tsc); |
088f6772 |
1009 | |
b052368a |
1010 | |
501e4e70 |
1011 | /* Events processing algorithm implementation */ |
dd316a11 |
1012 | /* Warning : the gtk_events_pending takes a LOT of cpu time. So what we do |
1013 | * instead is to leave the control to GTK and take it back. |
1014 | */ |
501e4e70 |
1015 | /* A. Servicing loop */ |
dd316a11 |
1016 | //while( (g_slist_length(list_in) != 0 || g_slist_length(list_out) != 0)) { |
3bafb436 |
1017 | if((g_slist_length(list_in) != 0 || g_slist_length(list_out) != 0)) { |
1018 | /* Servicing */ |
1019 | /* 1. If list_in is empty (need a seek) */ |
1020 | if( g_slist_length(list_in) == 0 ) { |
501e4e70 |
1021 | |
3bafb436 |
1022 | /* list in is empty, need a seek */ |
dd316a11 |
1023 | { |
3bafb436 |
1024 | /* 1.1 Add requests to list_in */ |
1025 | GSList *ltime = NULL; |
1026 | GSList *lpos = NULL; |
1027 | GSList *iter = NULL; |
501e4e70 |
1028 | |
3bafb436 |
1029 | /* 1.1.1 Find all time requests with the lowest start time in list_out |
1030 | * (ltime) |
1031 | */ |
1032 | if(g_slist_length(list_out) > 0) |
1033 | ltime = g_slist_append(ltime, g_slist_nth_data(list_out, 0)); |
1034 | for(iter=g_slist_nth(list_out,1);iter!=NULL;iter=g_slist_next(iter)) { |
1035 | /* Find all time requests with the lowest start time in list_out */ |
3bafb436 |
1036 | EventsRequest *event_request_ltime = (EventsRequest*)g_slist_nth_data(ltime, 0); |
1037 | EventsRequest *event_request_list_out = (EventsRequest*)iter->data; |
1038 | |
1039 | int comp; |
1040 | comp = ltt_time_compare(event_request_ltime->start_time, |
1041 | event_request_list_out->start_time); |
1042 | if(comp == 0) |
1043 | ltime = g_slist_append(ltime, event_request_list_out); |
1044 | else if(comp > 0) { |
1045 | /* Remove all elements from ltime, and add current */ |
1046 | while(ltime != NULL) |
1047 | ltime = g_slist_delete_link(ltime, g_slist_nth(ltime, 0)); |
1048 | ltime = g_slist_append(ltime, event_request_list_out); |
1049 | } |
501e4e70 |
1050 | } |
1051 | |
3bafb436 |
1052 | /* 1.1.2 Find all position requests with the lowest position in list_out |
1053 | * (lpos) |
1054 | */ |
1055 | if(g_slist_length(list_out) > 0) |
1056 | lpos = g_slist_append(lpos, g_slist_nth_data(list_out, 0)); |
1057 | for(iter=g_slist_nth(list_out,1);iter!=NULL;iter=g_slist_next(iter)) { |
1058 | /* Find all position requests with the lowest position in list_out */ |
1059 | EventsRequest *event_request_lpos = (EventsRequest*)g_slist_nth_data(lpos, 0); |
1060 | EventsRequest *event_request_list_out = (EventsRequest*)iter->data; |
1061 | |
1062 | int comp; |
1063 | if(event_request_lpos->start_position != NULL |
1064 | && event_request_list_out->start_position != NULL) |
1065 | { |
1066 | comp = lttv_traceset_context_pos_pos_compare |
1067 | (event_request_lpos->start_position, |
1068 | event_request_list_out->start_position); |
1069 | } else { |
1070 | comp = -1; |
553d1e7b |
1071 | } |
3bafb436 |
1072 | if(comp == 0) |
1073 | lpos = g_slist_append(lpos, event_request_list_out); |
1074 | else if(comp > 0) { |
1075 | /* Remove all elements from lpos, and add current */ |
1076 | while(lpos != NULL) |
1077 | lpos = g_slist_delete_link(lpos, g_slist_nth(lpos, 0)); |
1078 | lpos = g_slist_append(lpos, event_request_list_out); |
501e4e70 |
1079 | } |
1080 | } |
3bafb436 |
1081 | |
1082 | { |
1083 | EventsRequest *event_request_lpos = (EventsRequest*)g_slist_nth_data(lpos, 0); |
1084 | EventsRequest *event_request_ltime = (EventsRequest*)g_slist_nth_data(ltime, 0); |
1085 | LttTime lpos_start_time; |
dd316a11 |
1086 | |
3bafb436 |
1087 | if(event_request_lpos != NULL |
1088 | && event_request_lpos->start_position != NULL) { |
1089 | lpos_start_time = lttv_traceset_context_position_get_time( |
1090 | event_request_lpos->start_position); |
1091 | } |
1092 | |
1093 | /* 1.1.3 If lpos.start time < ltime */ |
1094 | if(event_request_lpos != NULL |
1095 | && event_request_lpos->start_position != NULL |
1096 | && ltt_time_compare(lpos_start_time, |
1097 | event_request_ltime->start_time)<0) { |
1098 | /* Add lpos to list_in, remove them from list_out */ |
1099 | for(iter=lpos;iter!=NULL;iter=g_slist_next(iter)) { |
1100 | /* Add to list_in */ |
1101 | EventsRequest *event_request_lpos = |
1102 | (EventsRequest*)iter->data; |
1103 | |
1104 | list_in = g_slist_append(list_in, event_request_lpos); |
1105 | /* Remove from list_out */ |
1106 | list_out = g_slist_remove(list_out, event_request_lpos); |
1107 | } |
1108 | } else { |
1109 | /* 1.1.4 (lpos.start time >= ltime) */ |
1110 | /* Add ltime to list_in, remove them from list_out */ |
1111 | |
1112 | for(iter=ltime;iter!=NULL;iter=g_slist_next(iter)) { |
1113 | /* Add to list_in */ |
1114 | EventsRequest *event_request_ltime = |
1115 | (EventsRequest*)iter->data; |
1116 | |
1117 | list_in = g_slist_append(list_in, event_request_ltime); |
1118 | /* Remove from list_out */ |
1119 | list_out = g_slist_remove(list_out, event_request_ltime); |
1120 | } |
1121 | } |
dd316a11 |
1122 | } |
3bafb436 |
1123 | g_slist_free(lpos); |
1124 | g_slist_free(ltime); |
dd316a11 |
1125 | } |
dd316a11 |
1126 | |
3bafb436 |
1127 | /* 1.2 Seek */ |
1128 | { |
1129 | tfc = lttv_traceset_context_get_current_tfc(tsc); |
1130 | g_assert(g_slist_length(list_in)>0); |
1131 | EventsRequest *events_request = g_slist_nth_data(list_in, 0); |
1132 | guint seek_count; |
1133 | |
1134 | /* 1.2.1 If first request in list_in is a time request */ |
1135 | if(events_request->start_position == NULL) { |
1136 | /* - If first req in list_in start time != current time */ |
1137 | if(tfc == NULL || ltt_time_compare(events_request->start_time, |
1138 | tfc->timestamp) != 0) |
1139 | /* - Seek to that time */ |
1140 | g_debug("SEEK TIME : %lu, %lu", events_request->start_time.tv_sec, |
1141 | events_request->start_time.tv_nsec); |
1142 | //lttv_process_traceset_seek_time(tsc, events_request->start_time); |
1143 | lttv_state_traceset_seek_time_closest(LTTV_TRACESET_STATE(tsc), |
1144 | events_request->start_time); |
1145 | |
1146 | /* Process the traceset with only state hooks */ |
1147 | seek_count = |
1148 | lttv_process_traceset_middle(tsc, |
1149 | events_request->start_time, |
1150 | G_MAXUINT, NULL); |
f4b88a7d |
1151 | #ifdef DEBUG |
1152 | g_assert(seek_count < LTTV_STATE_SAVE_INTERVAL); |
1153 | #endif //DEBUG |
6ea08962 |
1154 | |
a43d67ba |
1155 | |
3bafb436 |
1156 | } else { |
1157 | LttTime pos_time; |
2a7a425c |
1158 | LttvTracefileContext *tfc = |
1159 | lttv_traceset_context_get_current_tfc(tsc); |
3bafb436 |
1160 | /* Else, the first request in list_in is a position request */ |
1161 | /* If first req in list_in pos != current pos */ |
1162 | g_assert(events_request->start_position != NULL); |
1163 | g_debug("SEEK POS time : %lu, %lu", |
1164 | lttv_traceset_context_position_get_time( |
1165 | events_request->start_position).tv_sec, |
1166 | lttv_traceset_context_position_get_time( |
1167 | events_request->start_position).tv_nsec); |
2a7a425c |
1168 | |
1169 | if(tfc) { |
1170 | g_debug("SEEK POS context time : %lu, %lu", |
1171 | tfc->timestamp.tv_sec, |
1172 | tfc->timestamp.tv_nsec); |
1173 | } else { |
1174 | g_debug("SEEK POS context time : %lu, %lu", |
1175 | ltt_time_infinite.tv_sec, |
1176 | ltt_time_infinite.tv_nsec); |
1177 | } |
3bafb436 |
1178 | g_assert(events_request->start_position != NULL); |
1179 | if(lttv_traceset_context_ctx_pos_compare(tsc, |
1180 | events_request->start_position) != 0) { |
1181 | /* 1.2.2.1 Seek to that position */ |
1182 | g_debug("SEEK POSITION"); |
1183 | //lttv_process_traceset_seek_position(tsc, events_request->start_position); |
1184 | pos_time = lttv_traceset_context_position_get_time( |
1185 | events_request->start_position); |
1186 | |
1187 | lttv_state_traceset_seek_time_closest(LTTV_TRACESET_STATE(tsc), |
1188 | pos_time); |
1189 | |
1190 | /* Process the traceset with only state hooks */ |
1191 | seek_count = |
1192 | lttv_process_traceset_middle(tsc, |
1193 | ltt_time_infinite, |
1194 | G_MAXUINT, |
1195 | events_request->start_position); |
1196 | g_assert(lttv_traceset_context_ctx_pos_compare(tsc, |
1197 | events_request->start_position) == 0); |
dd316a11 |
1198 | |
dd316a11 |
1199 | |
3bafb436 |
1200 | } |
1201 | } |
1202 | } |
2d262115 |
1203 | |
3bafb436 |
1204 | /* 1.3 Add hooks and call before request for all list_in members */ |
1205 | { |
1206 | GSList *iter = NULL; |
dd316a11 |
1207 | |
3bafb436 |
1208 | for(iter=list_in;iter!=NULL;iter=g_slist_next(iter)) { |
1209 | EventsRequest *events_request = (EventsRequest*)iter->data; |
1210 | /* 1.3.1 If !servicing */ |
2d262115 |
1211 | if(events_request->servicing == FALSE) { |
1212 | /* - begin request hooks called |
1213 | * - servicing = TRUE |
1214 | */ |
6ea08962 |
1215 | lttv_hooks_call(events_request->before_request, (gpointer)tsc); |
2d262115 |
1216 | events_request->servicing = TRUE; |
1217 | } |
3bafb436 |
1218 | /* 1.3.2 call before chunk |
1219 | * 1.3.3 events hooks added |
2d262115 |
1220 | */ |
54d8f654 |
1221 | if(events_request->trace == -1) |
1222 | lttv_process_traceset_begin(tsc, |
1223 | events_request->before_chunk_traceset, |
1224 | events_request->before_chunk_trace, |
1225 | events_request->before_chunk_tracefile, |
1226 | events_request->event, |
1227 | events_request->event_by_id); |
1228 | else { |
1229 | guint nb_trace = lttv_traceset_number(tsc->ts); |
2eef04b5 |
1230 | g_assert((guint)events_request->trace < nb_trace && |
54d8f654 |
1231 | events_request->trace > -1); |
1232 | LttvTraceContext *tc = tsc->traces[events_request->trace]; |
1233 | |
1234 | lttv_hooks_call(events_request->before_chunk_traceset, tsc); |
1235 | |
1236 | lttv_trace_context_add_hooks(tc, |
1237 | events_request->before_chunk_trace, |
1238 | events_request->before_chunk_tracefile, |
1239 | events_request->event, |
1240 | events_request->event_by_id); |
1241 | } |
501e4e70 |
1242 | } |
3bafb436 |
1243 | } |
1244 | } else { |
1245 | /* 2. Else, list_in is not empty, we continue a read */ |
1246 | |
1247 | { |
1248 | /* 2.0 For each req of list_in */ |
1249 | GSList *iter = list_in; |
1250 | |
1251 | while(iter != NULL) { |
2d262115 |
1252 | |
3bafb436 |
1253 | EventsRequest *events_request = (EventsRequest *)iter->data; |
1254 | |
1255 | /* - Call before chunk |
1256 | * - events hooks added |
1257 | */ |
54d8f654 |
1258 | if(events_request->trace == -1) |
1259 | lttv_process_traceset_begin(tsc, |
1260 | events_request->before_chunk_traceset, |
1261 | events_request->before_chunk_trace, |
1262 | events_request->before_chunk_tracefile, |
1263 | events_request->event, |
1264 | events_request->event_by_id); |
1265 | else { |
1266 | guint nb_trace = lttv_traceset_number(tsc->ts); |
2eef04b5 |
1267 | g_assert((guint)events_request->trace < nb_trace && |
54d8f654 |
1268 | events_request->trace > -1); |
1269 | LttvTraceContext *tc = tsc->traces[events_request->trace]; |
1270 | |
1271 | lttv_hooks_call(events_request->before_chunk_traceset, tsc); |
1272 | |
1273 | lttv_trace_context_add_hooks(tc, |
3bafb436 |
1274 | events_request->before_chunk_trace, |
1275 | events_request->before_chunk_tracefile, |
1276 | events_request->event, |
1277 | events_request->event_by_id); |
54d8f654 |
1278 | } |
6ea08962 |
1279 | |
1280 | iter = g_slist_next(iter); |
1281 | } |
1282 | } |
1283 | |
3bafb436 |
1284 | { |
1285 | tfc = lttv_traceset_context_get_current_tfc(tsc); |
1286 | |
1287 | /* 2.1 For each req of list_out */ |
1288 | GSList *iter = list_out; |
553d1e7b |
1289 | |
3bafb436 |
1290 | while(iter != NULL) { |
6ea08962 |
1291 | |
3bafb436 |
1292 | gboolean remove = FALSE; |
1293 | gboolean free_data = FALSE; |
1294 | EventsRequest *events_request = (EventsRequest *)iter->data; |
1295 | |
1296 | /* if req.start time == current context time |
1297 | * or req.start position == current position*/ |
1298 | if( ltt_time_compare(events_request->start_time, |
1299 | tfc->timestamp) == 0 |
1300 | || |
1301 | (events_request->start_position != NULL |
1302 | && |
1303 | lttv_traceset_context_ctx_pos_compare(tsc, |
1304 | events_request->start_position) == 0) |
1305 | ) { |
1306 | /* - Add to list_in, remove from list_out */ |
1307 | list_in = g_slist_append(list_in, events_request); |
1308 | remove = TRUE; |
1309 | free_data = FALSE; |
1310 | |
1311 | /* - If !servicing */ |
1312 | if(events_request->servicing == FALSE) { |
1313 | /* - begin request hooks called |
1314 | * - servicing = TRUE |
1315 | */ |
1316 | lttv_hooks_call(events_request->before_request, (gpointer)tsc); |
1317 | events_request->servicing = TRUE; |
1318 | } |
1319 | /* call before chunk |
1320 | * events hooks added |
1321 | */ |
54d8f654 |
1322 | if(events_request->trace == -1) |
1323 | lttv_process_traceset_begin(tsc, |
1324 | events_request->before_chunk_traceset, |
1325 | events_request->before_chunk_trace, |
1326 | events_request->before_chunk_tracefile, |
1327 | events_request->event, |
1328 | events_request->event_by_id); |
1329 | else { |
1330 | guint nb_trace = lttv_traceset_number(tsc->ts); |
2eef04b5 |
1331 | g_assert((guint)events_request->trace < nb_trace && |
54d8f654 |
1332 | events_request->trace > -1); |
1333 | LttvTraceContext *tc = tsc->traces[events_request->trace]; |
1334 | |
1335 | lttv_hooks_call(events_request->before_chunk_traceset, tsc); |
1336 | |
1337 | lttv_trace_context_add_hooks(tc, |
1338 | events_request->before_chunk_trace, |
1339 | events_request->before_chunk_tracefile, |
1340 | events_request->event, |
1341 | events_request->event_by_id); |
1342 | } |
1343 | |
1344 | |
3bafb436 |
1345 | } |
501e4e70 |
1346 | |
3bafb436 |
1347 | /* Go to next */ |
1348 | if(remove) |
1349 | { |
1350 | GSList *remove_iter = iter; |
2d262115 |
1351 | |
3bafb436 |
1352 | iter = g_slist_next(iter); |
1353 | if(free_data) events_request_free((EventsRequest*)remove_iter->data); |
1354 | list_out = g_slist_remove_link(list_out, remove_iter); |
1355 | } else { // not remove |
1356 | iter = g_slist_next(iter); |
1357 | } |
1358 | } |
1359 | } |
1360 | } |
8f2872f4 |
1361 | |
3bafb436 |
1362 | /* 3. Find end criterions */ |
1363 | { |
1364 | /* 3.1 End time */ |
1365 | GSList *iter; |
1366 | |
1367 | /* 3.1.1 Find lowest end time in list_in */ |
1368 | g_assert(g_slist_length(list_in)>0); |
1369 | end_time = ((EventsRequest*)g_slist_nth_data(list_in,0))->end_time; |
1370 | |
1371 | for(iter=g_slist_nth(list_in,1);iter!=NULL;iter=g_slist_next(iter)) { |
1372 | EventsRequest *events_request = (EventsRequest*)iter->data; |
501e4e70 |
1373 | |
3bafb436 |
1374 | if(ltt_time_compare(events_request->end_time, |
1375 | end_time) < 0) |
1376 | end_time = events_request->end_time; |
1377 | } |
1378 | |
1379 | /* 3.1.2 Find lowest start time in list_out */ |
1380 | for(iter=list_out;iter!=NULL;iter=g_slist_next(iter)) { |
1381 | EventsRequest *events_request = (EventsRequest*)iter->data; |
2d262115 |
1382 | |
3bafb436 |
1383 | if(ltt_time_compare(events_request->start_time, |
1384 | end_time) < 0) |
1385 | end_time = events_request->start_time; |
1386 | } |
501e4e70 |
1387 | } |
1388 | |
3bafb436 |
1389 | { |
1390 | /* 3.2 Number of events */ |
dd316a11 |
1391 | |
3bafb436 |
1392 | /* 3.2.1 Find lowest number of events in list_in */ |
1393 | GSList *iter; |
501e4e70 |
1394 | |
3bafb436 |
1395 | end_nb_events = ((EventsRequest*)g_slist_nth_data(list_in,0))->num_events; |
501e4e70 |
1396 | |
3bafb436 |
1397 | for(iter=g_slist_nth(list_in,1);iter!=NULL;iter=g_slist_next(iter)) { |
1398 | EventsRequest *events_request = (EventsRequest*)iter->data; |
501e4e70 |
1399 | |
3bafb436 |
1400 | if(events_request->num_events < end_nb_events) |
1401 | end_nb_events = events_request->num_events; |
1402 | } |
501e4e70 |
1403 | |
3bafb436 |
1404 | /* 3.2.2 Use min(CHUNK_NUM_EVENTS, min num events in list_in) as |
1405 | * num_events */ |
1406 | |
1407 | end_nb_events = MIN(CHUNK_NUM_EVENTS, end_nb_events); |
501e4e70 |
1408 | } |
501e4e70 |
1409 | |
3bafb436 |
1410 | { |
1411 | /* 3.3 End position */ |
501e4e70 |
1412 | |
3bafb436 |
1413 | /* 3.3.1 Find lowest end position in list_in */ |
1414 | GSList *iter; |
6ea08962 |
1415 | |
3bafb436 |
1416 | end_position =((EventsRequest*)g_slist_nth_data(list_in,0))->end_position; |
6ea08962 |
1417 | |
3bafb436 |
1418 | for(iter=g_slist_nth(list_in,1);iter!=NULL;iter=g_slist_next(iter)) { |
1419 | EventsRequest *events_request = (EventsRequest*)iter->data; |
dd316a11 |
1420 | |
3bafb436 |
1421 | if(events_request->end_position != NULL && end_position != NULL && |
1422 | lttv_traceset_context_pos_pos_compare(events_request->end_position, |
1423 | end_position) <0) |
1424 | end_position = events_request->end_position; |
1425 | } |
1426 | } |
1427 | |
1428 | { |
1429 | /* 3.3.2 Find lowest start position in list_out */ |
1430 | GSList *iter; |
dd316a11 |
1431 | |
3bafb436 |
1432 | for(iter=list_out;iter!=NULL;iter=g_slist_next(iter)) { |
1433 | EventsRequest *events_request = (EventsRequest*)iter->data; |
dd316a11 |
1434 | |
3bafb436 |
1435 | if(events_request->end_position != NULL && end_position != NULL && |
1436 | lttv_traceset_context_pos_pos_compare(events_request->end_position, |
1437 | end_position) <0) |
1438 | end_position = events_request->end_position; |
dd316a11 |
1439 | } |
2d262115 |
1440 | } |
3bafb436 |
1441 | |
2d262115 |
1442 | { |
3bafb436 |
1443 | /* 4. Call process traceset middle */ |
2eef04b5 |
1444 | g_debug("Calling process traceset middle with %p, %lu sec %lu nsec, %u nb ev, %p end pos", tsc, end_time.tv_sec, end_time.tv_nsec, end_nb_events, end_position); |
3bafb436 |
1445 | count = lttv_process_traceset_middle(tsc, end_time, end_nb_events, end_position); |
2d262115 |
1446 | |
3bafb436 |
1447 | tfc = lttv_traceset_context_get_current_tfc(tsc); |
1448 | if(tfc != NULL) |
1449 | g_debug("Context time after middle : %lu, %lu", tfc->timestamp.tv_sec, |
1450 | tfc->timestamp.tv_nsec); |
1451 | else |
1452 | g_debug("End of trace reached after middle."); |
2d262115 |
1453 | |
3bafb436 |
1454 | } |
1455 | { |
1456 | /* 5. After process traceset middle */ |
1457 | tfc = lttv_traceset_context_get_current_tfc(tsc); |
1458 | |
1459 | /* - if current context time > traceset.end time */ |
1460 | if(tfc == NULL || ltt_time_compare(tfc->timestamp, |
1461 | tsc->time_span.end_time) > 0) { |
1462 | /* - For each req in list_in */ |
1463 | GSList *iter = list_in; |
1464 | |
1465 | while(iter != NULL) { |
1466 | |
1467 | gboolean remove = FALSE; |
1468 | gboolean free_data = FALSE; |
1469 | EventsRequest *events_request = (EventsRequest *)iter->data; |
1470 | |
1471 | /* - Remove events hooks for req |
1472 | * - Call end chunk for req |
1473 | */ |
54d8f654 |
1474 | |
1475 | if(events_request->trace == -1) |
1476 | lttv_process_traceset_end(tsc, |
1477 | events_request->after_chunk_traceset, |
3bafb436 |
1478 | events_request->after_chunk_trace, |
1479 | events_request->after_chunk_tracefile, |
1480 | events_request->event, |
1481 | events_request->event_by_id); |
54d8f654 |
1482 | |
1483 | else { |
1484 | guint nb_trace = lttv_traceset_number(tsc->ts); |
1485 | g_assert(events_request->trace < nb_trace && |
1486 | events_request->trace > -1); |
1487 | LttvTraceContext *tc = tsc->traces[events_request->trace]; |
1488 | |
1489 | lttv_trace_context_remove_hooks(tc, |
1490 | events_request->after_chunk_trace, |
1491 | events_request->after_chunk_tracefile, |
1492 | events_request->event, |
1493 | events_request->event_by_id); |
1494 | lttv_hooks_call(events_request->after_chunk_traceset, tsc); |
1495 | |
1496 | |
1497 | } |
1498 | |
3bafb436 |
1499 | /* - Call end request for req */ |
6ea08962 |
1500 | lttv_hooks_call(events_request->after_request, (gpointer)tsc); |
3bafb436 |
1501 | |
2d262115 |
1502 | /* - remove req from list_in */ |
1503 | /* Destroy the request */ |
1504 | remove = TRUE; |
1505 | free_data = TRUE; |
3bafb436 |
1506 | |
1507 | /* Go to next */ |
1508 | if(remove) |
1509 | { |
1510 | GSList *remove_iter = iter; |
1511 | |
1512 | iter = g_slist_next(iter); |
1513 | if(free_data) events_request_free((EventsRequest*)remove_iter->data); |
1514 | list_in = g_slist_remove_link(list_in, remove_iter); |
1515 | } else { // not remove |
1516 | iter = g_slist_next(iter); |
1517 | } |
2d262115 |
1518 | } |
3bafb436 |
1519 | } |
1520 | { |
1521 | /* 5.1 For each req in list_in */ |
1522 | GSList *iter = list_in; |
1523 | |
1524 | while(iter != NULL) { |
501e4e70 |
1525 | |
3bafb436 |
1526 | gboolean remove = FALSE; |
1527 | gboolean free_data = FALSE; |
1528 | EventsRequest *events_request = (EventsRequest *)iter->data; |
1529 | |
1530 | /* - Remove events hooks for req |
1531 | * - Call end chunk for req |
1532 | */ |
54d8f654 |
1533 | if(events_request->trace == -1) |
1534 | lttv_process_traceset_end(tsc, |
1535 | events_request->after_chunk_traceset, |
3bafb436 |
1536 | events_request->after_chunk_trace, |
1537 | events_request->after_chunk_tracefile, |
1538 | events_request->event, |
1539 | events_request->event_by_id); |
1540 | |
54d8f654 |
1541 | else { |
1542 | guint nb_trace = lttv_traceset_number(tsc->ts); |
1543 | g_assert(events_request->trace < nb_trace && |
1544 | events_request->trace > -1); |
1545 | LttvTraceContext *tc = tsc->traces[events_request->trace]; |
1546 | |
1547 | lttv_trace_context_remove_hooks(tc, |
1548 | events_request->after_chunk_trace, |
1549 | events_request->after_chunk_tracefile, |
1550 | events_request->event, |
1551 | events_request->event_by_id); |
1552 | |
1553 | lttv_hooks_call(events_request->after_chunk_traceset, tsc); |
1554 | } |
1555 | |
3bafb436 |
1556 | /* - req.num -= count */ |
1557 | g_assert(events_request->num_events >= count); |
1558 | events_request->num_events -= count; |
1559 | |
1560 | g_assert(tfc != NULL); |
1561 | /* - if req.num == 0 |
1562 | * or |
1563 | * current context time >= req.end time |
1564 | * or |
1565 | * req.end pos == current pos |
1566 | * or |
1567 | * req.stop_flag == TRUE |
1568 | */ |
1569 | if( events_request->num_events == 0 |
1570 | || |
1571 | events_request->stop_flag == TRUE |
1572 | || |
1573 | ltt_time_compare(tfc->timestamp, |
1574 | events_request->end_time) >= 0 |
1575 | || |
1576 | (events_request->end_position != NULL |
1577 | && |
1578 | lttv_traceset_context_ctx_pos_compare(tsc, |
1579 | events_request->end_position) == 0) |
1580 | |
1581 | ) { |
1582 | g_assert(events_request->servicing == TRUE); |
1583 | /* - Call end request for req |
1584 | * - remove req from list_in */ |
1585 | lttv_hooks_call(events_request->after_request, (gpointer)tsc); |
1586 | /* - remove req from list_in */ |
1587 | /* Destroy the request */ |
1588 | remove = TRUE; |
1589 | free_data = TRUE; |
1590 | } |
1591 | |
1592 | /* Go to next */ |
1593 | if(remove) |
1594 | { |
1595 | GSList *remove_iter = iter; |
1596 | |
1597 | iter = g_slist_next(iter); |
1598 | if(free_data) events_request_free((EventsRequest*)remove_iter->data); |
1599 | list_in = g_slist_remove_link(list_in, remove_iter); |
1600 | } else { // not remove |
1601 | iter = g_slist_next(iter); |
1602 | } |
2d262115 |
1603 | } |
1604 | } |
1605 | } |
501e4e70 |
1606 | } |
dd316a11 |
1607 | /* End of removed servicing loop : leave control to GTK instead. */ |
1608 | // if(gtk_events_pending()) break; |
1609 | //} |
1610 | |
2d262115 |
1611 | /* B. When interrupted between chunks */ |
501e4e70 |
1612 | |
501e4e70 |
1613 | { |
1614 | GSList *iter = list_in; |
1615 | |
2d262115 |
1616 | /* 1. for each request in list_in */ |
501e4e70 |
1617 | while(iter != NULL) { |
1618 | |
1619 | gboolean remove = FALSE; |
1620 | gboolean free_data = FALSE; |
2d262115 |
1621 | EventsRequest *events_request = (EventsRequest *)iter->data; |
501e4e70 |
1622 | |
1623 | /* 1.1. Use current postition as start position */ |
a1a2b649 |
1624 | if(events_request->start_position != NULL) |
1625 | lttv_traceset_context_position_destroy(events_request->start_position); |
8e680509 |
1626 | events_request->start_position = lttv_traceset_context_position_new(tsc); |
501e4e70 |
1627 | lttv_traceset_context_position_save(tsc, events_request->start_position); |
1628 | |
1629 | /* 1.2. Remove start time */ |
0aa6c3a1 |
1630 | events_request->start_time = ltt_time_infinite; |
501e4e70 |
1631 | |
2d262115 |
1632 | /* 1.3. Move from list_in to list_out */ |
501e4e70 |
1633 | remove = TRUE; |
1634 | free_data = FALSE; |
1635 | list_out = g_slist_append(list_out, events_request); |
1636 | |
501e4e70 |
1637 | /* Go to next */ |
1638 | if(remove) |
8f2872f4 |
1639 | { |
501e4e70 |
1640 | GSList *remove_iter = iter; |
1641 | |
1642 | iter = g_slist_next(iter); |
b052368a |
1643 | if(free_data) events_request_free((EventsRequest*)remove_iter->data); |
501e4e70 |
1644 | list_in = g_slist_remove_link(list_in, remove_iter); |
1645 | } else { // not remove |
1646 | iter = g_slist_next(iter); |
8f2872f4 |
1647 | } |
1648 | } |
a43d67ba |
1649 | |
501e4e70 |
1650 | |
1651 | } |
b052368a |
1652 | /* C Unlock Traces */ |
1653 | { |
088f6772 |
1654 | lttv_process_traceset_get_sync_data(tsc); |
1655 | //lttv_traceset_context_position_save(tsc, sync_position); |
b052368a |
1656 | |
1657 | guint iter_trace; |
1658 | |
1659 | for(iter_trace=0; |
1660 | iter_trace<lttv_traceset_number(tsc->ts); |
1661 | iter_trace++) { |
1662 | LttvTrace *trace_v = lttv_traceset_get(tsc->ts, iter_trace); |
1663 | |
1664 | lttvwindowtraces_unlock(trace_v); |
1665 | } |
1666 | } |
a0577796 |
1667 | #if 0 |
abe346a3 |
1668 | //set the cursor back to normal |
a8c0f09d |
1669 | gdk_window_set_cursor(win, NULL); |
a0577796 |
1670 | #endif //0 |
501e4e70 |
1671 | |
2d262115 |
1672 | g_assert(g_slist_length(list_in) == 0); |
6ea08962 |
1673 | |
2d262115 |
1674 | if( g_slist_length(list_out) == 0 ) { |
501e4e70 |
1675 | /* Put tab's request pending flag back to normal */ |
2d262115 |
1676 | tab->events_request_pending = FALSE; |
b052368a |
1677 | g_debug("remove the idle fct"); |
501e4e70 |
1678 | return FALSE; /* Remove the idle function */ |
1679 | } |
b052368a |
1680 | g_debug("leave the idle fct"); |
501e4e70 |
1681 | return TRUE; /* Leave the idle function */ |
b052368a |
1682 | |
1683 | /* We do not use simili-round-robin, it may require to read 1 meg buffers |
1684 | * again and again if many tracesets use the same tracefiles. */ |
1685 | /* Hack for round-robin idle functions */ |
1686 | /* It will put the idle function at the end of the pool */ |
1687 | /*g_idle_add_full((G_PRIORITY_HIGH_IDLE + 21), |
1688 | (GSourceFunc)execute_events_requests, |
1689 | tab, |
1690 | NULL); |
1691 | return FALSE; |
1692 | */ |
202f6c8f |
1693 | } |
1694 | |
6ea08962 |
1695 | #undef list_out |
501e4e70 |
1696 | |
abe346a3 |
1697 | |
4266dc7f |
1698 | static void lttvwindow_add_trace(Tab *tab, LttvTrace *trace_v) |
1699 | { |
1700 | LttvTraceset *traceset = tab->traceset_info->traceset; |
1701 | guint i; |
91fd6881 |
1702 | guint num_traces = lttv_traceset_number(traceset); |
4266dc7f |
1703 | |
a1a2b649 |
1704 | //Verify if trace is already present. |
91fd6881 |
1705 | for(i=0; i<num_traces; i++) |
a1a2b649 |
1706 | { |
1707 | LttvTrace * trace = lttv_traceset_get(traceset, i); |
1708 | if(trace == trace_v) |
1709 | return; |
1710 | } |
1711 | |
4266dc7f |
1712 | //Keep a reference to the traces so they are not freed. |
1713 | for(i=0; i<lttv_traceset_number(traceset); i++) |
1714 | { |
1715 | LttvTrace * trace = lttv_traceset_get(traceset, i); |
1716 | lttv_trace_ref(trace); |
1717 | } |
1718 | |
1719 | //remove state update hooks |
1720 | lttv_state_remove_event_hooks( |
1721 | (LttvTracesetState*)tab->traceset_info->traceset_context); |
1722 | |
1723 | lttv_context_fini(LTTV_TRACESET_CONTEXT( |
1724 | tab->traceset_info->traceset_context)); |
1725 | g_object_unref(tab->traceset_info->traceset_context); |
1726 | |
1727 | lttv_traceset_add(traceset, trace_v); |
a1a2b649 |
1728 | lttv_trace_ref(trace_v); /* local ref */ |
4266dc7f |
1729 | |
1730 | /* Create new context */ |
1731 | tab->traceset_info->traceset_context = |
1732 | g_object_new(LTTV_TRACESET_STATS_TYPE, NULL); |
1733 | lttv_context_init( |
1734 | LTTV_TRACESET_CONTEXT(tab->traceset_info-> |
1735 | traceset_context), |
1736 | traceset); |
6ea08962 |
1737 | |
6ea08962 |
1738 | |
4266dc7f |
1739 | //add state update hooks |
1740 | lttv_state_add_event_hooks( |
1741 | (LttvTracesetState*)tab->traceset_info->traceset_context); |
1742 | //Remove local reference to the traces. |
1743 | for(i=0; i<lttv_traceset_number(traceset); i++) |
1744 | { |
1745 | LttvTrace * trace = lttv_traceset_get(traceset, i); |
1746 | lttv_trace_unref(trace); |
1747 | } |
1748 | |
b052368a |
1749 | //FIXME |
1750 | //add_trace_into_traceset_selector(GTK_MULTIVPANED(tab->multivpaned), lttv_trace(trace_v)); |
4266dc7f |
1751 | } |
1752 | |
abe346a3 |
1753 | /* add_trace adds a trace into the current traceset. It first displays a |
1754 | * directory selection dialogue to let user choose a trace, then recreates |
1755 | * tracset_context, and redraws all the viewer of the current tab |
1756 | */ |
1757 | |
561eba2a |
1758 | void add_trace(GtkWidget * widget, gpointer user_data) |
1759 | { |
2176f952 |
1760 | LttTrace *trace; |
1761 | LttvTrace * trace_v; |
1762 | LttvTraceset * traceset; |
94dcfb9e |
1763 | const char * dir; |
a1a2b649 |
1764 | char abs_path[PATH_MAX]; |
2176f952 |
1765 | gint id; |
bca3b81f |
1766 | MainWindow * mw_data = get_window_data_struct(widget); |
6ced96ef |
1767 | GtkWidget * notebook = lookup_widget(widget, "MNotebook"); |
1768 | |
1769 | GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), |
1770 | gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook))); |
e433e6d6 |
1771 | LttvPluginTab *ptab; |
6ced96ef |
1772 | Tab *tab; |
1773 | |
1774 | if(!page) { |
e433e6d6 |
1775 | ptab = create_new_tab(widget, NULL); |
1776 | tab = ptab->tab; |
6ced96ef |
1777 | } else { |
e433e6d6 |
1778 | ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin"); |
1779 | tab = ptab->tab; |
6ced96ef |
1780 | } |
4266dc7f |
1781 | |
0a946563 |
1782 | //GtkDirSelection * file_selector = (GtkDirSelection *)gtk_dir_selection_new("Select a trace"); |
1783 | GtkFileSelection * file_selector = (GtkFileSelection *)gtk_file_selection_new("Select a trace"); |
1784 | gtk_widget_hide( (file_selector)->file_list->parent) ; |
1785 | gtk_file_selection_hide_fileop_buttons(file_selector); |
93ac601b |
1786 | gtk_window_set_transient_for(GTK_WINDOW(file_selector), |
1787 | GTK_WINDOW(mw_data->mwindow)); |
4266dc7f |
1788 | |
3658a338 |
1789 | if(remember_trace_dir[0] != '\0') |
0a946563 |
1790 | gtk_file_selection_set_filename(file_selector, remember_trace_dir); |
2176f952 |
1791 | |
68b48a45 |
1792 | id = gtk_dialog_run(GTK_DIALOG(file_selector)); |
2176f952 |
1793 | switch(id){ |
1794 | case GTK_RESPONSE_ACCEPT: |
1795 | case GTK_RESPONSE_OK: |
0a946563 |
1796 | dir = gtk_file_selection_get_filename (file_selector); |
a1a2b649 |
1797 | strncpy(remember_trace_dir, dir, PATH_MAX); |
0a946563 |
1798 | strncat(remember_trace_dir, "/", PATH_MAX); |
a43d67ba |
1799 | if(!dir || strlen(dir) == 0){ |
1800 | gtk_widget_destroy((GtkWidget*)file_selector); |
1801 | break; |
284675e3 |
1802 | } |
a1a2b649 |
1803 | get_absolute_pathname(dir, abs_path); |
d27948a3 |
1804 | trace_v = lttvwindowtraces_get_trace_by_name(abs_path); |
1805 | if(trace_v == NULL) { |
a1a2b649 |
1806 | trace = ltt_trace_open(abs_path); |
2a74fbf4 |
1807 | if(trace == NULL) { |
1808 | g_warning("cannot open trace %s", abs_path); |
be1d42f0 |
1809 | |
1810 | GtkWidget *dialogue = |
1811 | gtk_message_dialog_new( |
1812 | GTK_WINDOW(gtk_widget_get_toplevel(widget)), |
1813 | GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, |
1814 | GTK_MESSAGE_ERROR, |
1815 | GTK_BUTTONS_OK, |
e66e59ff |
1816 | "Cannot open trace : maybe you should enter in the trace " |
be1d42f0 |
1817 | "directory to select it ?"); |
1818 | gtk_dialog_run(GTK_DIALOG(dialogue)); |
1819 | gtk_widget_destroy(dialogue); |
1820 | |
2a74fbf4 |
1821 | } else { |
1822 | trace_v = lttv_trace_new(trace); |
d27948a3 |
1823 | lttvwindowtraces_add_trace(trace_v); |
2a74fbf4 |
1824 | lttvwindow_add_trace(tab, trace_v); |
1825 | } |
d27948a3 |
1826 | } else { |
1827 | lttvwindow_add_trace(tab, trace_v); |
1828 | } |
c2619a30 |
1829 | |
49bf71b5 |
1830 | gtk_widget_destroy((GtkWidget*)file_selector); |
1831 | |
1832 | //update current tab |
a43d67ba |
1833 | //update_traceset(mw_data); |
21e8c385 |
1834 | |
a43d67ba |
1835 | /* Call the updatetraceset hooks */ |
1836 | |
4266dc7f |
1837 | traceset = tab->traceset_info->traceset; |
1838 | SetTraceset(tab, traceset); |
a43d67ba |
1839 | // in expose now call_pending_read_hooks(mw_data); |
1840 | |
4266dc7f |
1841 | //lttvwindow_report_current_time(mw_data,&(tab->current_time)); |
49bf71b5 |
1842 | break; |
2176f952 |
1843 | case GTK_RESPONSE_REJECT: |
1844 | case GTK_RESPONSE_CANCEL: |
1845 | default: |
68b48a45 |
1846 | gtk_widget_destroy((GtkWidget*)file_selector); |
2176f952 |
1847 | break; |
1848 | } |
49bf71b5 |
1849 | } |
1850 | |
abe346a3 |
1851 | /* remove_trace removes a trace from the current traceset if all viewers in |
1852 | * the current tab are not interested in the trace. It first displays a |
1853 | * dialogue, which shows all traces in the current traceset, to let user choose |
1854 | * a trace, then it checks if all viewers unselect the trace, if it is true, |
1855 | * it will remove the trace, recreate the traceset_contex, |
1856 | * and redraws all the viewer of the current tab. If there is on trace in the |
1857 | * current traceset, it will delete all viewers of the current tab |
3a5f75c1 |
1858 | * |
1859 | * It destroys the filter tree. FIXME... we should request for an update |
1860 | * instead. |
abe346a3 |
1861 | */ |
1862 | |
b052368a |
1863 | void remove_trace(GtkWidget *widget, gpointer user_data) |
1864 | { |
1865 | LttTrace *trace; |
1866 | LttvTrace * trace_v; |
1867 | LttvTraceset * traceset; |
1868 | gint i, j, nb_trace, index=-1; |
1869 | char ** name, *remove_trace_name; |
1870 | MainWindow * mw_data = get_window_data_struct(widget); |
1871 | GtkWidget * notebook = lookup_widget(widget, "MNotebook"); |
1872 | |
1873 | GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), |
1874 | gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook))); |
1875 | Tab *tab; |
1876 | |
1877 | if(!page) { |
1878 | return; |
1879 | } else { |
e433e6d6 |
1880 | LttvPluginTab *ptab; |
1881 | ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin"); |
1882 | tab = ptab->tab; |
b052368a |
1883 | } |
1884 | |
1885 | nb_trace =lttv_traceset_number(tab->traceset_info->traceset); |
1886 | name = g_new(char*,nb_trace); |
1887 | for(i = 0; i < nb_trace; i++){ |
1888 | trace_v = lttv_traceset_get(tab->traceset_info->traceset, i); |
1889 | trace = lttv_trace(trace_v); |
4249a3e8 |
1890 | name[i] = g_quark_to_string(ltt_trace_name(trace)); |
b052368a |
1891 | } |
1892 | |
93ac601b |
1893 | remove_trace_name = get_remove_trace(mw_data, name, nb_trace); |
b052368a |
1894 | |
1895 | |
1896 | if(remove_trace_name){ |
1897 | |
1898 | /* yuk, cut n paste from old code.. should be better (MD)*/ |
1899 | for(i = 0; i<nb_trace; i++) { |
1900 | if(strcmp(remove_trace_name,name[i]) == 0){ |
1901 | index = i; |
1902 | } |
1903 | } |
1904 | |
1905 | traceset = tab->traceset_info->traceset; |
1906 | //Keep a reference to the traces so they are not freed. |
1907 | for(j=0; j<lttv_traceset_number(traceset); j++) |
1908 | { |
1909 | LttvTrace * trace = lttv_traceset_get(traceset, j); |
1910 | lttv_trace_ref(trace); |
1911 | } |
1912 | |
1913 | //remove state update hooks |
1914 | lttv_state_remove_event_hooks( |
1915 | (LttvTracesetState*)tab->traceset_info->traceset_context); |
1916 | lttv_context_fini(LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)); |
1917 | g_object_unref(tab->traceset_info->traceset_context); |
1918 | |
1919 | trace_v = lttv_traceset_get(traceset, index); |
1920 | |
b052368a |
1921 | lttv_traceset_remove(traceset, index); |
1922 | lttv_trace_unref(trace_v); // Remove local reference |
1923 | |
d27948a3 |
1924 | if(lttv_trace_get_ref_number(trace_v) <= 1) { |
1ba187d3 |
1925 | /* ref 1 : lttvwindowtraces only*/ |
1926 | ltt_trace_close(lttv_trace(trace_v)); |
1927 | /* lttvwindowtraces_remove_trace takes care of destroying |
1928 | * the traceset linked with the trace_v and also of destroying |
1929 | * the trace_v at the same time. |
1930 | */ |
d27948a3 |
1931 | lttvwindowtraces_remove_trace(trace_v); |
1932 | } |
b052368a |
1933 | |
1934 | tab->traceset_info->traceset_context = |
1935 | g_object_new(LTTV_TRACESET_STATS_TYPE, NULL); |
1936 | lttv_context_init( |
1937 | LTTV_TRACESET_CONTEXT(tab-> |
1938 | traceset_info->traceset_context),traceset); |
1939 | //add state update hooks |
1940 | lttv_state_add_event_hooks( |
1941 | (LttvTracesetState*)tab->traceset_info->traceset_context); |
1942 | |
1943 | //Remove local reference to the traces. |
1944 | for(j=0; j<lttv_traceset_number(traceset); j++) |
1945 | { |
1946 | LttvTrace * trace = lttv_traceset_get(traceset, j); |
1947 | lttv_trace_unref(trace); |
1948 | } |
1949 | |
1950 | SetTraceset(tab, (gpointer)traceset); |
1951 | } |
1952 | g_free(name); |
1953 | } |
1954 | |
1955 | #if 0 |
561eba2a |
1956 | void remove_trace(GtkWidget * widget, gpointer user_data) |
1957 | { |
2176f952 |
1958 | LttTrace *trace; |
1959 | LttvTrace * trace_v; |
1960 | LttvTraceset * traceset; |
a43d67ba |
1961 | gint i, j, nb_trace; |
2176f952 |
1962 | char ** name, *remove_trace_name; |
bca3b81f |
1963 | MainWindow * mw_data = get_window_data_struct(widget); |
49bf71b5 |
1964 | LttvTracesetSelector * s; |
1965 | LttvTraceSelector * t; |
1966 | GtkWidget * w; |
1967 | gboolean selected; |
6ced96ef |
1968 | GtkWidget * notebook = lookup_widget(widget, "MNotebook"); |
1969 | |
1970 | GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), |
1971 | gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook))); |
1972 | Tab *tab; |
1973 | |
1974 | if(!page) { |
1975 | return; |
1976 | } else { |
1977 | tab = (Tab *)g_object_get_data(G_OBJECT(page), "Tab_Info"); |
1978 | } |
1979 | |
4266dc7f |
1980 | nb_trace =lttv_traceset_number(tab->traceset_info->traceset); |
2176f952 |
1981 | name = g_new(char*,nb_trace); |
1982 | for(i = 0; i < nb_trace; i++){ |
4266dc7f |
1983 | trace_v = lttv_traceset_get(tab->traceset_info->traceset, i); |
2176f952 |
1984 | trace = lttv_trace(trace_v); |
a5dcde2f |
1985 | name[i] = ltt_trace_name(trace); |
2176f952 |
1986 | } |
1987 | |
1988 | remove_trace_name = get_remove_trace(name, nb_trace); |
1989 | |
1990 | if(remove_trace_name){ |
1991 | for(i=0; i<nb_trace; i++){ |
1992 | if(strcmp(remove_trace_name,name[i]) == 0){ |
6ced96ef |
1993 | //unselect the trace from the current viewer |
b052368a |
1994 | //FIXME |
1995 | w = gtk_multivpaned_get_widget(GTK_MULTIVPANED(tab->multivpaned)); |
6ced96ef |
1996 | if(w){ |
1997 | s = g_object_get_data(G_OBJECT(w), "Traceset_Selector"); |
1998 | if(s){ |
1999 | t = lttv_traceset_selector_trace_get(s,i); |
2000 | lttv_trace_selector_set_selected(t, FALSE); |
2001 | } |
2002 | |
2003 | //check if other viewers select the trace |
b052368a |
2004 | w = gtk_multivpaned_get_first_widget(GTK_MULTIVPANED(tab->multivpaned)); |
6ced96ef |
2005 | while(w){ |
2006 | s = g_object_get_data(G_OBJECT(w), "Traceset_Selector"); |
2007 | if(s){ |
2008 | t = lttv_traceset_selector_trace_get(s,i); |
2009 | selected = lttv_trace_selector_get_selected(t); |
2010 | if(selected)break; |
2011 | } |
b052368a |
2012 | w = gtk_multivpaned_get_next_widget(GTK_MULTIVPANED(tab->multivpaned)); |
6ced96ef |
2013 | } |
2014 | }else selected = FALSE; |
49bf71b5 |
2015 | |
6ced96ef |
2016 | //if no viewer selects the trace, remove it |
2017 | if(!selected){ |
b052368a |
2018 | remove_trace_from_traceset_selector(GTK_MULTIVPANED(tab->multivpaned), i); |
49bf71b5 |
2019 | |
6ced96ef |
2020 | traceset = tab->traceset_info->traceset; |
2021 | //Keep a reference to the traces so they are not freed. |
2022 | for(j=0; j<lttv_traceset_number(traceset); j++) |
2023 | { |
2024 | LttvTrace * trace = lttv_traceset_get(traceset, j); |
2025 | lttv_trace_ref(trace); |
2026 | } |
a43d67ba |
2027 | |
6ced96ef |
2028 | //remove state update hooks |
2029 | lttv_state_remove_event_hooks( |
2030 | (LttvTracesetState*)tab->traceset_info->traceset_context); |
2031 | lttv_context_fini(LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)); |
2032 | g_object_unref(tab->traceset_info->traceset_context); |
a43d67ba |
2033 | |
a43d67ba |
2034 | |
6ced96ef |
2035 | trace_v = lttv_traceset_get(traceset, i); |
a43d67ba |
2036 | |
a1a2b649 |
2037 | if(lttv_trace_get_ref_number(trace_v) <= 2) { |
2038 | /* ref 2 : traceset, local */ |
2039 | lttvwindowtraces_remove_trace(trace_v); |
6ced96ef |
2040 | ltt_trace_close(lttv_trace(trace_v)); |
a1a2b649 |
2041 | } |
6ced96ef |
2042 | |
2043 | lttv_traceset_remove(traceset, i); |
2044 | lttv_trace_unref(trace_v); // Remove local reference |
c2619a30 |
2045 | |
6ced96ef |
2046 | if(!lttv_trace_get_ref_number(trace_v)) |
2047 | lttv_trace_destroy(trace_v); |
2048 | |
2049 | tab->traceset_info->traceset_context = |
2050 | g_object_new(LTTV_TRACESET_STATS_TYPE, NULL); |
2051 | lttv_context_init( |
2052 | LTTV_TRACESET_CONTEXT(tab-> |
2053 | traceset_info->traceset_context),traceset); |
2054 | //add state update hooks |
2055 | lttv_state_add_event_hooks( |
2056 | (LttvTracesetState*)tab->traceset_info->traceset_context); |
2057 | |
2058 | //Remove local reference to the traces. |
2059 | for(j=0; j<lttv_traceset_number(traceset); j++) |
2060 | { |
2061 | LttvTrace * trace = lttv_traceset_get(traceset, j); |
2062 | lttv_trace_unref(trace); |
2063 | } |
a43d67ba |
2064 | |
a43d67ba |
2065 | |
6ced96ef |
2066 | //update current tab |
2067 | //update_traceset(mw_data); |
313bd6fc |
2068 | //if(nb_trace > 1){ |
6ced96ef |
2069 | |
313bd6fc |
2070 | SetTraceset(tab, (gpointer)traceset); |
6ced96ef |
2071 | // in expose now call_pending_read_hooks(mw_data); |
2072 | |
2073 | //lttvwindow_report_current_time(mw_data,&(tab->current_time)); |
313bd6fc |
2074 | //}else{ |
2075 | // if(tab){ |
2076 | // while(tab->multi_vpaned->num_children){ |
2077 | // gtk_multi_vpaned_widget_delete(tab->multi_vpaned); |
2078 | // } |
2079 | // } |
2080 | //} |
6ced96ef |
2081 | } |
2082 | break; |
2176f952 |
2083 | } |
2084 | } |
2085 | } |
2086 | |
2087 | g_free(name); |
561eba2a |
2088 | } |
b052368a |
2089 | #endif //0 |
abe346a3 |
2090 | |
9878c8a4 |
2091 | /* Redraw all the viewers in the current tab */ |
2092 | void redraw(GtkWidget *widget, gpointer user_data) |
2093 | { |
2094 | GtkWidget * notebook = lookup_widget(widget, "MNotebook"); |
2095 | GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), |
2096 | gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook))); |
2097 | Tab *tab; |
2098 | if(!page) { |
2099 | return; |
2100 | } else { |
e433e6d6 |
2101 | LttvPluginTab *ptab; |
2102 | ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin"); |
2103 | tab = ptab->tab; |
9878c8a4 |
2104 | } |
2105 | |
2106 | LttvHooks * tmp; |
2107 | LttvAttributeValue value; |
2108 | |
2109 | g_assert(lttv_iattribute_find_by_path(tab->attributes, "hooks/redraw", LTTV_POINTER, &value)); |
2110 | |
2111 | tmp = (LttvHooks*)*(value.v_pointer); |
c07e9b26 |
2112 | if(tmp != NULL) |
2113 | lttv_hooks_call(tmp,NULL); |
9878c8a4 |
2114 | } |
2115 | |
2116 | |
2117 | void continue_processing(GtkWidget *widget, gpointer user_data) |
2118 | { |
2119 | GtkWidget * notebook = lookup_widget(widget, "MNotebook"); |
2120 | GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), |
2121 | gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook))); |
2122 | Tab *tab; |
2123 | if(!page) { |
2124 | return; |
2125 | } else { |
e433e6d6 |
2126 | LttvPluginTab *ptab; |
2127 | ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin"); |
2128 | tab = ptab->tab; |
9878c8a4 |
2129 | } |
2130 | |
2131 | LttvHooks * tmp; |
2132 | LttvAttributeValue value; |
2133 | |
2134 | g_assert(lttv_iattribute_find_by_path(tab->attributes, |
2135 | "hooks/continue", LTTV_POINTER, &value)); |
2136 | |
2137 | tmp = (LttvHooks*)*(value.v_pointer); |
c07e9b26 |
2138 | if(tmp != NULL) |
2139 | lttv_hooks_call(tmp,NULL); |
9878c8a4 |
2140 | } |
2141 | |
2142 | /* Stop the processing for the calling main window's current tab. |
2143 | * It removes every processing requests that are in its list. It does not call |
2144 | * the end request hooks, because the request is not finished. |
2145 | */ |
2146 | |
2147 | void stop_processing(GtkWidget *widget, gpointer user_data) |
2148 | { |
2149 | GtkWidget * notebook = lookup_widget(widget, "MNotebook"); |
2150 | GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), |
2151 | gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook))); |
2152 | Tab *tab; |
2153 | if(!page) { |
2154 | return; |
2155 | } else { |
e433e6d6 |
2156 | LttvPluginTab *ptab; |
2157 | ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin"); |
2158 | tab = ptab->tab; |
9878c8a4 |
2159 | } |
a0577796 |
2160 | GSList *iter = tab->events_requests; |
9878c8a4 |
2161 | |
2162 | while(iter != NULL) { |
2163 | GSList *remove_iter = iter; |
2164 | iter = g_slist_next(iter); |
2165 | |
2166 | g_free(remove_iter->data); |
a0577796 |
2167 | tab->events_requests = |
2168 | g_slist_remove_link(tab->events_requests, remove_iter); |
9878c8a4 |
2169 | } |
a0577796 |
2170 | tab->events_request_pending = FALSE; |
2171 | g_idle_remove_by_data(tab); |
2172 | g_assert(g_slist_length(tab->events_requests) == 0); |
9878c8a4 |
2173 | } |
2174 | |
2175 | |
abe346a3 |
2176 | /* save will save the traceset to a file |
a43d67ba |
2177 | * Not implemented yet FIXME |
abe346a3 |
2178 | */ |
2179 | |
561eba2a |
2180 | void save(GtkWidget * widget, gpointer user_data) |
2181 | { |
56e5a0f7 |
2182 | g_info("Save\n"); |
561eba2a |
2183 | } |
2184 | |
2185 | void save_as(GtkWidget * widget, gpointer user_data) |
2186 | { |
56e5a0f7 |
2187 | g_info("Save as\n"); |
561eba2a |
2188 | } |
2189 | |
abe346a3 |
2190 | |
2191 | /* zoom will change the time_window of all the viewers of the |
2192 | * current tab, and redisplay them. The main functionality is to |
2193 | * determine the new time_window of the current tab |
2194 | */ |
2195 | |
1f1ae829 |
2196 | void zoom(GtkWidget * widget, double size) |
2197 | { |
b052368a |
2198 | TimeInterval time_span; |
a43d67ba |
2199 | TimeWindow new_time_window; |
2eef04b5 |
2200 | LttTime current_time, time_delta; |
1f1ae829 |
2201 | MainWindow * mw_data = get_window_data_struct(widget); |
4266dc7f |
2202 | LttvTracesetContext *tsc; |
6ced96ef |
2203 | GtkWidget * notebook = lookup_widget(widget, "MNotebook"); |
2204 | |
2205 | GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), |
2206 | gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook))); |
2207 | Tab *tab; |
2208 | |
2209 | if(!page) { |
2210 | return; |
2211 | } else { |
e433e6d6 |
2212 | LttvPluginTab *ptab; |
2213 | ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin"); |
2214 | tab = ptab->tab; |
6ced96ef |
2215 | } |
1f1ae829 |
2216 | |
fda16332 |
2217 | if(size == 1) return; |
2218 | |
4266dc7f |
2219 | tsc = LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); |
b052368a |
2220 | time_span = tsc->time_span; |
501e4e70 |
2221 | new_time_window = tab->time_window; |
2222 | current_time = tab->current_time; |
1f1ae829 |
2223 | |
b052368a |
2224 | time_delta = ltt_time_sub(time_span.end_time,time_span.start_time); |
1f1ae829 |
2225 | if(size == 0){ |
b052368a |
2226 | new_time_window.start_time = time_span.start_time; |
a43d67ba |
2227 | new_time_window.time_width = time_delta; |
a18124ff |
2228 | new_time_window.time_width_double = ltt_time_to_double(time_delta); |
6f26fc38 |
2229 | new_time_window.end_time = ltt_time_add(new_time_window.start_time, |
2230 | new_time_window.time_width) ; |
1f1ae829 |
2231 | }else{ |
a43d67ba |
2232 | new_time_window.time_width = ltt_time_div(new_time_window.time_width, size); |
a18124ff |
2233 | new_time_window.time_width_double = |
2234 | ltt_time_to_double(new_time_window.time_width); |
a43d67ba |
2235 | if(ltt_time_compare(new_time_window.time_width,time_delta) > 0) |
2236 | { /* Case where zoom out is bigger than trace length */ |
b052368a |
2237 | new_time_window.start_time = time_span.start_time; |
a43d67ba |
2238 | new_time_window.time_width = time_delta; |
a18124ff |
2239 | new_time_window.time_width_double = ltt_time_to_double(time_delta); |
6f26fc38 |
2240 | new_time_window.end_time = ltt_time_add(new_time_window.start_time, |
2241 | new_time_window.time_width) ; |
a8c0f09d |
2242 | } |
a43d67ba |
2243 | else |
2244 | { |
2245 | /* Center the image on the current time */ |
a43d67ba |
2246 | new_time_window.start_time = |
a18124ff |
2247 | ltt_time_sub(current_time, |
2248 | ltt_time_from_double(new_time_window.time_width_double/2.0)); |
6f26fc38 |
2249 | new_time_window.end_time = ltt_time_add(new_time_window.start_time, |
2250 | new_time_window.time_width) ; |
a43d67ba |
2251 | /* If on borders, don't fall off */ |
9e494e53 |
2252 | if(ltt_time_compare(new_time_window.start_time, time_span.start_time) <0 |
2253 | || ltt_time_compare(new_time_window.start_time, time_span.end_time) >0) |
a43d67ba |
2254 | { |
b052368a |
2255 | new_time_window.start_time = time_span.start_time; |
6f26fc38 |
2256 | new_time_window.end_time = ltt_time_add(new_time_window.start_time, |
2257 | new_time_window.time_width) ; |
a43d67ba |
2258 | } |
2259 | else |
2260 | { |
6f26fc38 |
2261 | if(ltt_time_compare(new_time_window.end_time, |
9e494e53 |
2262 | time_span.end_time) > 0 |
2263 | || ltt_time_compare(new_time_window.end_time, |
2264 | time_span.start_time) < 0) |
a43d67ba |
2265 | { |
2266 | new_time_window.start_time = |
b052368a |
2267 | ltt_time_sub(time_span.end_time, new_time_window.time_width); |
6f26fc38 |
2268 | |
2269 | new_time_window.end_time = ltt_time_add(new_time_window.start_time, |
2270 | new_time_window.time_width) ; |
a43d67ba |
2271 | } |
2272 | } |
2273 | |
1f1ae829 |
2274 | } |
1f1ae829 |
2275 | } |
a43d67ba |
2276 | |
f02b5e22 |
2277 | if(ltt_time_compare(new_time_window.time_width, ltt_time_zero) == 0) { |
2278 | g_warning("Zoom more than 1 ns impossible"); |
b052368a |
2279 | } else { |
e800cf84 |
2280 | time_change_manager(tab, new_time_window); |
b052368a |
2281 | } |
1f1ae829 |
2282 | } |
2283 | |
561eba2a |
2284 | void zoom_in(GtkWidget * widget, gpointer user_data) |
2285 | { |
1f1ae829 |
2286 | zoom(widget, 2); |
561eba2a |
2287 | } |
2288 | |
2289 | void zoom_out(GtkWidget * widget, gpointer user_data) |
2290 | { |
1f1ae829 |
2291 | zoom(widget, 0.5); |
561eba2a |
2292 | } |
2293 | |
2294 | void zoom_extended(GtkWidget * widget, gpointer user_data) |
2295 | { |
1f1ae829 |
2296 | zoom(widget, 0); |
561eba2a |
2297 | } |
2298 | |
2299 | void go_to_time(GtkWidget * widget, gpointer user_data) |
2300 | { |
56e5a0f7 |
2301 | g_info("Go to time\n"); |
561eba2a |
2302 | } |
2303 | |
2304 | void show_time_frame(GtkWidget * widget, gpointer user_data) |
2305 | { |
56e5a0f7 |
2306 | g_info("Show time frame\n"); |
561eba2a |
2307 | } |
2308 | |
2309 | |
2310 | /* callback function */ |
2311 | |
2312 | void |
2313 | on_empty_traceset_activate (GtkMenuItem *menuitem, |
2314 | gpointer user_data) |
2315 | { |
68b48a45 |
2316 | create_new_window((GtkWidget*)menuitem, user_data, FALSE); |
561eba2a |
2317 | } |
2318 | |
2319 | |
2320 | void |
2321 | on_clone_traceset_activate (GtkMenuItem *menuitem, |
2322 | gpointer user_data) |
2323 | { |
68b48a45 |
2324 | create_new_window((GtkWidget*)menuitem, user_data, TRUE); |
561eba2a |
2325 | } |
2326 | |
abe346a3 |
2327 | |
2328 | /* create_new_tab calls create_tab to construct a new tab in the main window |
2329 | */ |
2330 | |
e433e6d6 |
2331 | LttvPluginTab *create_new_tab(GtkWidget* widget, gpointer user_data) |
2332 | { |
a1a2b649 |
2333 | gchar label[PATH_MAX]; |
2901f314 |
2334 | MainWindow * mw_data = get_window_data_struct(widget); |
4266dc7f |
2335 | |
2901f314 |
2336 | GtkNotebook * notebook = (GtkNotebook *)lookup_widget(widget, "MNotebook"); |
561eba2a |
2337 | if(notebook == NULL){ |
56e5a0f7 |
2338 | g_info("Notebook does not exist\n"); |
6ced96ef |
2339 | return NULL; |
2340 | } |
2341 | GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), |
2342 | gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook))); |
2343 | Tab *copy_tab; |
2344 | |
2345 | if(!page) { |
2346 | copy_tab = NULL; |
2347 | } else { |
e433e6d6 |
2348 | LttvPluginTab *ptab; |
2349 | ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin"); |
2350 | copy_tab = ptab->tab; |
561eba2a |
2351 | } |
4266dc7f |
2352 | |
6b1d3120 |
2353 | strcpy(label,"Page"); |
e433e6d6 |
2354 | if(get_label(mw_data, label,"Get the name of the tab","Please input tab's name")) { |
2355 | LttvPluginTab *ptab; |
2356 | |
2357 | ptab = g_object_new(LTTV_TYPE_PLUGIN_TAB, NULL); |
2358 | init_tab (ptab->tab, mw_data, copy_tab, notebook, label); |
2359 | ptab->parent.top_widget = ptab->tab->top_widget; |
2360 | g_object_set_data_full( |
2361 | G_OBJECT(ptab->tab->vbox), |
2362 | "Tab_Plugin", |
2363 | ptab, |
2364 | (GDestroyNotify)tab_destructor); |
2365 | return ptab; |
2366 | } |
2367 | else return NULL; |
561eba2a |
2368 | } |
2369 | |
2901f314 |
2370 | void |
2371 | on_tab_activate (GtkMenuItem *menuitem, |
2372 | gpointer user_data) |
2373 | { |
2374 | create_new_tab((GtkWidget*)menuitem, user_data); |
2375 | } |
2376 | |
561eba2a |
2377 | |
2378 | void |
2379 | on_open_activate (GtkMenuItem *menuitem, |
2380 | gpointer user_data) |
2381 | { |
2382 | open_traceset((GtkWidget*)menuitem, user_data); |
2383 | } |
2384 | |
2385 | |
2386 | void |
2387 | on_close_activate (GtkMenuItem *menuitem, |
2388 | gpointer user_data) |
2389 | { |
bca3b81f |
2390 | MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem); |
68b48a45 |
2391 | main_window_destructor(mw_data); |
561eba2a |
2392 | } |
2393 | |
2394 | |
4266dc7f |
2395 | /* remove the current tab from the main window |
abe346a3 |
2396 | */ |
2397 | |
561eba2a |
2398 | void |
27a559b9 |
2399 | on_close_tab_activate (GtkWidget *widget, |
561eba2a |
2400 | gpointer user_data) |
2401 | { |
4266dc7f |
2402 | gint page_num; |
2061e03d |
2403 | GtkWidget * notebook; |
4266dc7f |
2404 | GtkWidget * page; |
27a559b9 |
2405 | MainWindow * mw_data = get_window_data_struct(widget); |
2406 | notebook = lookup_widget(widget, "MNotebook"); |
2061e03d |
2407 | if(notebook == NULL){ |
56e5a0f7 |
2408 | g_info("Notebook does not exist\n"); |
2061e03d |
2409 | return; |
2410 | } |
4266dc7f |
2411 | |
2412 | page_num = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)); |
2061e03d |
2413 | |
4266dc7f |
2414 | gtk_notebook_remove_page(GTK_NOTEBOOK(notebook), page_num); |
2061e03d |
2415 | |
561eba2a |
2416 | } |
2417 | |
27a559b9 |
2418 | void |
2419 | on_close_tab_X_clicked (GtkWidget *widget, |
2420 | gpointer user_data) |
2421 | { |
2422 | gint page_num; |
2423 | GtkWidget *notebook = lookup_widget(widget, "MNotebook"); |
2424 | if(notebook == NULL){ |
56e5a0f7 |
2425 | g_info("Notebook does not exist\n"); |
27a559b9 |
2426 | return; |
2427 | } |
2428 | |
2429 | if((page_num = gtk_notebook_page_num(GTK_NOTEBOOK(notebook), widget)) != -1) |
2430 | gtk_notebook_remove_page(GTK_NOTEBOOK(notebook), page_num); |
2431 | |
2432 | } |
2433 | |
561eba2a |
2434 | |
2435 | void |
2436 | on_add_trace_activate (GtkMenuItem *menuitem, |
2437 | gpointer user_data) |
2438 | { |
2439 | add_trace((GtkWidget*)menuitem, user_data); |
2440 | } |
2441 | |
2442 | |
2443 | void |
2444 | on_remove_trace_activate (GtkMenuItem *menuitem, |
2445 | gpointer user_data) |
2446 | { |
2447 | remove_trace((GtkWidget*)menuitem, user_data); |
2448 | } |
2449 | |
2450 | |
2451 | void |
2452 | on_save_activate (GtkMenuItem *menuitem, |
2453 | gpointer user_data) |
2454 | { |
2455 | save((GtkWidget*)menuitem, user_data); |
2456 | } |
2457 | |
2458 | |
2459 | void |
2460 | on_save_as_activate (GtkMenuItem *menuitem, |
2461 | gpointer user_data) |
2462 | { |
2463 | save_as((GtkWidget*)menuitem, user_data); |
2464 | } |
2465 | |
2466 | |
2467 | void |
2468 | on_quit_activate (GtkMenuItem *menuitem, |
2469 | gpointer user_data) |
2470 | { |
d27948a3 |
2471 | mainwindow_quit(); |
561eba2a |
2472 | } |
2473 | |
2474 | |
2475 | void |
2476 | on_cut_activate (GtkMenuItem *menuitem, |
2477 | gpointer user_data) |
2478 | { |
56e5a0f7 |
2479 | g_info("Cut\n"); |
561eba2a |
2480 | } |
2481 | |
2482 | |
2483 | void |
2484 | on_copy_activate (GtkMenuItem *menuitem, |
2485 | gpointer user_data) |
2486 | { |
56e5a0f7 |
2487 | g_info("Copye\n"); |
561eba2a |
2488 | } |
2489 | |
2490 | |
2491 | void |
2492 | on_paste_activate (GtkMenuItem *menuitem, |
2493 | gpointer user_data) |
2494 | { |
56e5a0f7 |
2495 | g_info("Paste\n"); |
561eba2a |
2496 | } |
2497 | |
2498 | |
2499 | void |
2500 | on_delete_activate (GtkMenuItem *menuitem, |
2501 | gpointer user_data) |
2502 | { |
56e5a0f7 |
2503 | g_info("Delete\n"); |
561eba2a |
2504 | } |
2505 | |
2506 | |
2507 | void |
2508 | on_zoom_in_activate (GtkMenuItem *menuitem, |
2509 | gpointer user_data) |
2510 | { |
2511 | zoom_in((GtkWidget*)menuitem, user_data); |
2512 | } |
2513 | |
2514 | |
2515 | void |
2516 | on_zoom_out_activate (GtkMenuItem *menuitem, |
2517 | gpointer user_data) |
2518 | { |
2519 | zoom_out((GtkWidget*)menuitem, user_data); |
2520 | } |
2521 | |
2522 | |
2523 | void |
2524 | on_zoom_extended_activate (GtkMenuItem *menuitem, |
2525 | gpointer user_data) |
2526 | { |
2527 | zoom_extended((GtkWidget*)menuitem, user_data); |
2528 | } |
2529 | |
2530 | |
2531 | void |
2532 | on_go_to_time_activate (GtkMenuItem *menuitem, |
2533 | gpointer user_data) |
2534 | { |
2535 | go_to_time((GtkWidget*)menuitem, user_data); |
2536 | } |
2537 | |
2538 | |
2539 | void |
2540 | on_show_time_frame_activate (GtkMenuItem *menuitem, |
2541 | gpointer user_data) |
2542 | { |
2543 | show_time_frame((GtkWidget*)menuitem, user_data); |
2544 | } |
2545 | |
2546 | |
2547 | void |
2548 | on_move_viewer_up_activate (GtkMenuItem *menuitem, |
2549 | gpointer user_data) |
2550 | { |
2551 | move_up_viewer((GtkWidget*)menuitem, user_data); |
2552 | } |
2553 | |
2554 | |
2555 | void |
2556 | on_move_viewer_down_activate (GtkMenuItem *menuitem, |
2557 | gpointer user_data) |
2558 | { |
2559 | move_down_viewer((GtkWidget*)menuitem, user_data); |
2560 | } |
2561 | |
2562 | |
2563 | void |
2564 | on_remove_viewer_activate (GtkMenuItem *menuitem, |
2565 | gpointer user_data) |
2566 | { |
2567 | delete_viewer((GtkWidget*)menuitem, user_data); |
2568 | } |
2569 | |
49bf71b5 |
2570 | void |
2571 | on_trace_facility_activate (GtkMenuItem *menuitem, |
2572 | gpointer user_data) |
2573 | { |
56e5a0f7 |
2574 | g_info("Trace facility selector: %s\n"); |
49bf71b5 |
2575 | } |
561eba2a |
2576 | |
abe346a3 |
2577 | |
b052368a |
2578 | /* Dispaly a file selection dialogue to let user select a library, then call |
2579 | * lttv_library_load(). |
2580 | */ |
2581 | |
2582 | void |
2583 | on_load_library_activate (GtkMenuItem *menuitem, |
2584 | gpointer user_data) |
2585 | { |
2586 | GError *error = NULL; |
2587 | MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem); |
2588 | |
2589 | gchar load_module_path_alter[PATH_MAX]; |
2590 | { |
2591 | GPtrArray *name; |
2592 | guint nb,i; |
2593 | gchar *load_module_path; |
2594 | name = g_ptr_array_new(); |
2595 | nb = lttv_library_path_number(); |
2596 | /* ask for the library path */ |
2597 | |
2598 | for(i=0;i<nb;i++){ |
2599 | gchar *path; |
2600 | path = lttv_library_path_get(i); |
2601 | g_ptr_array_add(name, path); |
2602 | } |
2603 | |
93ac601b |
2604 | load_module_path = get_selection(mw_data, |
2605 | (char **)(name->pdata), name->len, |
b052368a |
2606 | "Select a library path", "Library paths"); |
2607 | if(load_module_path != NULL) |
2608 | strncpy(load_module_path_alter, load_module_path, PATH_MAX-1); // -1 for / |
2609 | |
2610 | g_ptr_array_free(name, TRUE); |
2611 | |
2612 | if(load_module_path == NULL) return; |
2613 | } |
2614 | |
2615 | { |
2616 | /* Make sure the module path ends with a / */ |
2617 | gchar *ptr = load_module_path_alter; |
2618 | |
2619 | ptr = strchr(ptr, '\0'); |
2620 | |
2621 | if(*(ptr-1) != '/') { |
2622 | *ptr = '/'; |
2623 | *(ptr+1) = '\0'; |
2624 | } |
2625 | } |
2626 | |
2627 | { |
2628 | /* Ask for the library to load : list files in the previously selected |
2629 | * directory */ |
2630 | gchar str[PATH_MAX]; |
2631 | gchar ** dir; |
2632 | gint id; |
2633 | GtkFileSelection * file_selector = |
2634 | (GtkFileSelection *)gtk_file_selection_new("Select a module"); |
2635 | gtk_file_selection_set_filename(file_selector, load_module_path_alter); |
2636 | gtk_file_selection_hide_fileop_buttons(file_selector); |
2637 | |
93ac601b |
2638 | gtk_window_set_transient_for(GTK_WINDOW(file_selector), |
2639 | GTK_WINDOW(mw_data->mwindow)); |
2640 | |
b052368a |
2641 | str[0] = '\0'; |
2642 | id = gtk_dialog_run(GTK_DIALOG(file_selector)); |
2643 | switch(id){ |
2644 | case GTK_RESPONSE_ACCEPT: |
2645 | case GTK_RESPONSE_OK: |
2646 | dir = gtk_file_selection_get_selections (file_selector); |
2647 | strncpy(str,dir[0],PATH_MAX); |
2648 | strncpy(remember_plugins_dir,dir[0],PATH_MAX); |
2649 | /* only keep file name */ |
2650 | gchar *str1; |
2651 | str1 = strrchr(str,'/'); |
2652 | if(str1)str1++; |
2653 | else{ |
2654 | str1 = strrchr(str,'\\'); |
2655 | str1++; |
2656 | } |
2657 | #if 0 |
2658 | /* remove "lib" */ |
2659 | if(*str1 == 'l' && *(str1+1)== 'i' && *(str1+2)=='b') |
2660 | str1=str1+3; |
2661 | remove info after . */ |
2662 | { |
2663 | gchar *str2 = str1; |
2664 | |
2665 | str2 = strrchr(str2, '.'); |
2666 | if(str2 != NULL) *str2 = '\0'; |
2667 | } |
2668 | lttv_module_require(str1, &error); |
2669 | #endif //0 |
2670 | lttv_library_load(str1, &error); |
2eef04b5 |
2671 | if(error != NULL) g_warning("%s", error->message); |
56e5a0f7 |
2672 | else g_info("Load library: %s\n", str); |
b052368a |
2673 | g_strfreev(dir); |
2674 | case GTK_RESPONSE_REJECT: |
2675 | case GTK_RESPONSE_CANCEL: |
2676 | default: |
2677 | gtk_widget_destroy((GtkWidget*)file_selector); |
2678 | break; |
2679 | } |
2680 | |
2681 | } |
2682 | |
2683 | |
2684 | |
2685 | } |
2686 | |
2687 | |
2688 | /* Display all loaded modules, let user to select a module to unload |
2689 | * by calling lttv_module_unload |
2690 | */ |
2691 | |
2692 | void |
2693 | on_unload_library_activate (GtkMenuItem *menuitem, |
2694 | gpointer user_data) |
2695 | { |
2696 | MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem); |
2697 | |
2eef04b5 |
2698 | LttvLibrary *library = NULL; |
b052368a |
2699 | |
2eef04b5 |
2700 | GPtrArray *name; |
2701 | guint nb,i; |
2702 | gchar *lib_name; |
2703 | name = g_ptr_array_new(); |
2704 | nb = lttv_library_number(); |
2705 | LttvLibraryInfo *lib_info = g_new(LttvLibraryInfo,nb); |
2706 | /* ask for the library name */ |
2707 | |
2708 | for(i=0;i<nb;i++){ |
2709 | LttvLibrary *iter_lib = lttv_library_get(i); |
2710 | lttv_library_info(iter_lib, &lib_info[i]); |
2711 | |
2712 | gchar *path = lib_info[i].name; |
2713 | g_ptr_array_add(name, path); |
2714 | } |
93ac601b |
2715 | lib_name = get_selection(mw_data, (char **)(name->pdata), name->len, |
2eef04b5 |
2716 | "Select a library", "Libraries"); |
2717 | if(lib_name != NULL) { |
b052368a |
2718 | for(i=0;i<nb;i++){ |
2eef04b5 |
2719 | if(strcmp(lib_name, lib_info[i].name) == 0) { |
2720 | library = lttv_library_get(i); |
2721 | break; |
b052368a |
2722 | } |
2723 | } |
b052368a |
2724 | } |
2eef04b5 |
2725 | g_ptr_array_free(name, TRUE); |
2726 | g_free(lib_info); |
2727 | |
2728 | if(lib_name == NULL) return; |
2729 | |
2730 | if(library != NULL) lttv_library_unload(library); |
b052368a |
2731 | } |
2732 | |
2733 | |
abe346a3 |
2734 | /* Dispaly a file selection dialogue to let user select a module, then call |
b052368a |
2735 | * lttv_module_require(). |
abe346a3 |
2736 | */ |
2737 | |
561eba2a |
2738 | void |
2739 | on_load_module_activate (GtkMenuItem *menuitem, |
2740 | gpointer user_data) |
2741 | { |
b052368a |
2742 | GError *error = NULL; |
bca3b81f |
2743 | MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem); |
b052368a |
2744 | |
2eef04b5 |
2745 | LttvLibrary *library = NULL; |
b052368a |
2746 | { |
2747 | GPtrArray *name; |
2748 | guint nb,i; |
2749 | gchar *lib_name; |
2750 | name = g_ptr_array_new(); |
2751 | nb = lttv_library_number(); |
2752 | LttvLibraryInfo *lib_info = g_new(LttvLibraryInfo,nb); |
2753 | /* ask for the library name */ |
2754 | |
2755 | for(i=0;i<nb;i++){ |
2756 | LttvLibrary *iter_lib = lttv_library_get(i); |
2757 | lttv_library_info(iter_lib, &lib_info[i]); |
2758 | |
2759 | gchar *path = lib_info[i].name; |
2760 | g_ptr_array_add(name, path); |
2761 | } |
93ac601b |
2762 | lib_name = get_selection(mw_data,(char **)(name->pdata), name->len, |
b052368a |
2763 | "Select a library", "Libraries"); |
2764 | if(lib_name != NULL) { |
2765 | for(i=0;i<nb;i++){ |
2766 | if(strcmp(lib_name, lib_info[i].name) == 0) { |
2767 | library = lttv_library_get(i); |
2768 | break; |
2769 | } |
3872a20e |
2770 | } |
b052368a |
2771 | } |
2772 | g_ptr_array_free(name, TRUE); |
2773 | g_free(lib_info); |
2774 | |
2775 | if(lib_name == NULL) return; |
36b3c068 |
2776 | } |
b052368a |
2777 | |
2778 | //LttvModule *module; |
2779 | gchar module_name_out[PATH_MAX]; |
2780 | { |
2781 | /* Ask for the module to load : list modules in the selected lib */ |
2782 | GPtrArray *name; |
2783 | guint nb,i; |
2784 | gchar *module_name; |
bbbd6c25 |
2785 | nb = lttv_library_module_number(library); |
b052368a |
2786 | LttvModuleInfo *module_info = g_new(LttvModuleInfo,nb); |
2787 | name = g_ptr_array_new(); |
b052368a |
2788 | /* ask for the module name */ |
2789 | |
2790 | for(i=0;i<nb;i++){ |
2791 | LttvModule *iter_module = lttv_library_module_get(library, i); |
2792 | lttv_module_info(iter_module, &module_info[i]); |
2793 | |
2794 | gchar *path = module_info[i].name; |
2795 | g_ptr_array_add(name, path); |
2796 | } |
93ac601b |
2797 | module_name = get_selection(mw_data, (char **)(name->pdata), name->len, |
b052368a |
2798 | "Select a module", "Modules"); |
2799 | if(module_name != NULL) { |
2800 | for(i=0;i<nb;i++){ |
2801 | if(strcmp(module_name, module_info[i].name) == 0) { |
2802 | strncpy(module_name_out, module_name, PATH_MAX); |
2803 | //module = lttv_library_module_get(i); |
2804 | break; |
2805 | } |
2806 | } |
2807 | } |
2808 | |
2809 | g_ptr_array_free(name, TRUE); |
2810 | g_free(module_info); |
2811 | |
2812 | if(module_name == NULL) return; |
2813 | } |
2814 | |
2815 | lttv_module_require(module_name_out, &error); |
2eef04b5 |
2816 | if(error != NULL) g_warning("%s", error->message); |
56e5a0f7 |
2817 | else g_info("Load module: %s", module_name_out); |
b052368a |
2818 | |
2819 | |
2820 | #if 0 |
2821 | { |
2822 | |
2823 | |
2824 | gchar str[PATH_MAX]; |
2825 | gchar ** dir; |
2826 | gint id; |
2827 | GtkFileSelection * file_selector = |
2828 | (GtkFileSelection *)gtk_file_selection_new("Select a module"); |
2829 | gtk_file_selection_set_filename(file_selector, load_module_path_alter); |
2830 | gtk_file_selection_hide_fileop_buttons(file_selector); |
2831 | |
2832 | str[0] = '\0'; |
2833 | id = gtk_dialog_run(GTK_DIALOG(file_selector)); |
2834 | switch(id){ |
2835 | case GTK_RESPONSE_ACCEPT: |
2836 | case GTK_RESPONSE_OK: |
2837 | dir = gtk_file_selection_get_selections (file_selector); |
2838 | strncpy(str,dir[0],PATH_MAX); |
2839 | strncpy(remember_plugins_dir,dir[0],PATH_MAX); |
2840 | { |
2841 | /* only keep file name */ |
2842 | gchar *str1; |
2843 | str1 = strrchr(str,'/'); |
2844 | if(str1)str1++; |
2845 | else{ |
2846 | str1 = strrchr(str,'\\'); |
2847 | str1++; |
2848 | } |
2849 | #if 0 |
2850 | /* remove "lib" */ |
2851 | if(*str1 == 'l' && *(str1+1)== 'i' && *(str1+2)=='b') |
2852 | str1=str1+3; |
2853 | remove info after . */ |
2854 | { |
2855 | gchar *str2 = str1; |
2856 | |
2857 | str2 = strrchr(str2, '.'); |
2858 | if(str2 != NULL) *str2 = '\0'; |
2859 | } |
2860 | lttv_module_require(str1, &error); |
2861 | #endif //0 |
2862 | lttv_library_load(str1, &error); |
2863 | if(error != NULL) g_warning(error->message); |
56e5a0f7 |
2864 | else g_info("Load library: %s\n", str); |
b052368a |
2865 | g_strfreev(dir); |
2866 | case GTK_RESPONSE_REJECT: |
2867 | case GTK_RESPONSE_CANCEL: |
2868 | default: |
2869 | gtk_widget_destroy((GtkWidget*)file_selector); |
2870 | break; |
2871 | } |
2872 | |
2873 | } |
2874 | #endif //0 |
2875 | |
2876 | |
561eba2a |
2877 | } |
2878 | |
2879 | |
b052368a |
2880 | |
abe346a3 |
2881 | /* Display all loaded modules, let user to select a module to unload |
2882 | * by calling lttv_module_unload |
2883 | */ |
2884 | |
561eba2a |
2885 | void |
2886 | on_unload_module_activate (GtkMenuItem *menuitem, |
2887 | gpointer user_data) |
2888 | { |
b052368a |
2889 | GError *error = NULL; |
bca3b81f |
2890 | MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem); |
08b1c66e |
2891 | |
b052368a |
2892 | LttvLibrary *library; |
2893 | { |
2894 | GPtrArray *name; |
2895 | guint nb,i; |
2896 | gchar *lib_name; |
2897 | name = g_ptr_array_new(); |
2898 | nb = lttv_library_number(); |
2899 | LttvLibraryInfo *lib_info = g_new(LttvLibraryInfo,nb); |
2900 | /* ask for the library name */ |
36b3c068 |
2901 | |
36b3c068 |
2902 | for(i=0;i<nb;i++){ |
b052368a |
2903 | LttvLibrary *iter_lib = lttv_library_get(i); |
2904 | lttv_library_info(iter_lib, &lib_info[i]); |
2905 | |
2906 | gchar *path = lib_info[i].name; |
2907 | g_ptr_array_add(name, path); |
2908 | } |
93ac601b |
2909 | lib_name = get_selection(mw_data, (char **)(name->pdata), name->len, |
b052368a |
2910 | "Select a library", "Libraries"); |
2911 | if(lib_name != NULL) { |
2912 | for(i=0;i<nb;i++){ |
2913 | if(strcmp(lib_name, lib_info[i].name) == 0) { |
2914 | library = lttv_library_get(i); |
2915 | break; |
2916 | } |
36b3c068 |
2917 | } |
b052368a |
2918 | } |
2919 | g_ptr_array_free(name, TRUE); |
2920 | g_free(lib_info); |
2921 | |
2922 | if(lib_name == NULL) return; |
36b3c068 |
2923 | } |
2924 | |
2eef04b5 |
2925 | LttvModule *module = NULL; |
b052368a |
2926 | { |
2927 | /* Ask for the module to load : list modules in the selected lib */ |
2928 | GPtrArray *name; |
2929 | guint nb,i; |
2930 | gchar *module_name; |
6d677a86 |
2931 | nb = lttv_library_module_number(library); |
b052368a |
2932 | LttvModuleInfo *module_info = g_new(LttvModuleInfo,nb); |
2933 | name = g_ptr_array_new(); |
b052368a |
2934 | /* ask for the module name */ |
2935 | |
2936 | for(i=0;i<nb;i++){ |
2937 | LttvModule *iter_module = lttv_library_module_get(library, i); |
2938 | lttv_module_info(iter_module, &module_info[i]); |
2939 | |
2940 | gchar *path = module_info[i].name; |
2941 | if(module_info[i].use_count > 0) g_ptr_array_add(name, path); |
2942 | } |
93ac601b |
2943 | module_name = get_selection(mw_data, (char **)(name->pdata), name->len, |
b052368a |
2944 | "Select a module", "Modules"); |
2945 | if(module_name != NULL) { |
2946 | for(i=0;i<nb;i++){ |
2947 | if(strcmp(module_name, module_info[i].name) == 0) { |
2948 | module = lttv_library_module_get(library, i); |
2949 | break; |
2950 | } |
2951 | } |
2952 | } |
2953 | |
2954 | g_ptr_array_free(name, TRUE); |
2955 | g_free(module_info); |
2956 | |
2957 | if(module_name == NULL) return; |
2958 | } |
2959 | |
b052368a |
2960 | LttvModuleInfo module_info; |
2961 | lttv_module_info(module, &module_info); |
56e5a0f7 |
2962 | g_info("Release module: %s\n", module_info.name); |
fce9a2fc |
2963 | |
2964 | lttv_module_release(module); |
561eba2a |
2965 | } |
2966 | |
2967 | |
b052368a |
2968 | /* Display a directory dialogue to let user select a path for library searching |
abe346a3 |
2969 | */ |
2970 | |
561eba2a |
2971 | void |
b052368a |
2972 | on_add_library_search_path_activate (GtkMenuItem *menuitem, |
561eba2a |
2973 | gpointer user_data) |
2974 | { |
93ac601b |
2975 | MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem); |
0a946563 |
2976 | //GtkDirSelection * file_selector = (GtkDirSelection *)gtk_dir_selection_new("Select library path"); |
2977 | GtkFileSelection * file_selector = (GtkFileSelection *)gtk_file_selection_new("Select a trace"); |
2978 | gtk_widget_hide( (file_selector)->file_list->parent) ; |
93ac601b |
2979 | |
2980 | gtk_window_set_transient_for(GTK_WINDOW(file_selector), |
2981 | GTK_WINDOW(mw_data->mwindow)); |
2982 | |
67b98724 |
2983 | const char * dir; |
fc188b78 |
2984 | gint id; |
2985 | |
3658a338 |
2986 | if(remember_plugins_dir[0] != '\0') |
0a946563 |
2987 | gtk_file_selection_set_filename(file_selector, remember_plugins_dir); |
fc188b78 |
2988 | |
68b48a45 |
2989 | id = gtk_dialog_run(GTK_DIALOG(file_selector)); |
fc188b78 |
2990 | switch(id){ |
2991 | case GTK_RESPONSE_ACCEPT: |
2992 | case GTK_RESPONSE_OK: |
0a946563 |
2993 | dir = gtk_file_selection_get_filename (file_selector); |
a1a2b649 |
2994 | strncpy(remember_plugins_dir,dir,PATH_MAX); |
2995 | strncat(remember_plugins_dir,"/",PATH_MAX); |
08b1c66e |
2996 | lttv_library_path_add(dir); |
fc188b78 |
2997 | case GTK_RESPONSE_REJECT: |
2998 | case GTK_RESPONSE_CANCEL: |
2999 | default: |
68b48a45 |
3000 | gtk_widget_destroy((GtkWidget*)file_selector); |
fc188b78 |
3001 | break; |
6b1d3120 |
3002 | } |
561eba2a |
3003 | } |
3004 | |
3005 | |
b052368a |
3006 | /* Display a directory dialogue to let user select a path for library searching |
3007 | */ |
3008 | |
3009 | void |
3010 | on_remove_library_search_path_activate (GtkMenuItem *menuitem, |
3011 | gpointer user_data) |
3012 | { |
3013 | MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem); |
3014 | |
3015 | const char *lib_path; |
3016 | { |
3017 | GPtrArray *name; |
3018 | guint nb,i; |
3019 | gchar *lib_name; |
3020 | name = g_ptr_array_new(); |
3021 | nb = lttv_library_path_number(); |
3022 | /* ask for the library name */ |
3023 | |
3024 | for(i=0;i<nb;i++){ |
3025 | gchar *path = lttv_library_path_get(i); |
3026 | g_ptr_array_add(name, path); |
3027 | } |
93ac601b |
3028 | lib_path = get_selection(mw_data, (char **)(name->pdata), name->len, |
b052368a |
3029 | "Select a library path", "Library paths"); |
3030 | |
3031 | g_ptr_array_free(name, TRUE); |
3032 | |
3033 | if(lib_path == NULL) return; |
3034 | } |
3035 | |
3036 | lttv_library_path_remove(lib_path); |
3037 | } |
3038 | |
561eba2a |
3039 | void |
3040 | on_color_activate (GtkMenuItem *menuitem, |
3041 | gpointer user_data) |
3042 | { |
56e5a0f7 |
3043 | g_info("Color\n"); |
561eba2a |
3044 | } |
3045 | |
3046 | |
561eba2a |
3047 | void |
3048 | on_save_configuration_activate (GtkMenuItem *menuitem, |
3049 | gpointer user_data) |
3050 | { |
56e5a0f7 |
3051 | g_info("Save configuration\n"); |
561eba2a |
3052 | } |
3053 | |
3054 | |
3055 | void |
3056 | on_content_activate (GtkMenuItem *menuitem, |
3057 | gpointer user_data) |
3058 | { |
56e5a0f7 |
3059 | g_info("Content\n"); |
561eba2a |
3060 | } |
3061 | |
3062 | |
51ef553b |
3063 | static void |
3064 | on_about_close_activate (GtkButton *button, |
3065 | gpointer user_data) |
3066 | { |
3067 | GtkWidget *about_widget = GTK_WIDGET(user_data); |
3068 | |
3069 | gtk_widget_destroy(about_widget); |
3070 | } |
3071 | |
561eba2a |
3072 | void |
3073 | on_about_activate (GtkMenuItem *menuitem, |
3074 | gpointer user_data) |
3075 | { |
51ef553b |
3076 | MainWindow *main_window = get_window_data_struct(GTK_WIDGET(menuitem)); |
3077 | GtkWidget *window_widget = main_window->mwindow; |
3078 | GtkWidget *about_widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
3079 | GtkWindow *about_window = GTK_WINDOW(about_widget); |
3080 | gint window_width, window_height; |
3081 | |
3082 | gtk_window_set_title(about_window, "About Linux Trace Toolkit"); |
3083 | |
3084 | gtk_window_set_resizable(about_window, FALSE); |
3085 | gtk_window_set_transient_for(GTK_WINDOW(window_widget), about_window); |
3086 | gtk_window_set_destroy_with_parent(about_window, TRUE); |
3087 | gtk_window_set_modal(about_window, FALSE); |
3088 | |
3089 | /* Put the about window at the center of the screen */ |
3090 | gtk_window_get_size(about_window, &window_width, &window_height); |
3091 | gtk_window_move (about_window, |
3092 | (gdk_screen_width() - window_width)/2, |
3093 | (gdk_screen_height() - window_height)/2); |
3094 | |
3095 | GtkWidget *vbox = gtk_vbox_new(FALSE, 1); |
3096 | |
3097 | gtk_container_add(GTK_CONTAINER(about_widget), vbox); |
3098 | |
3099 | |
3100 | /* Text to show */ |
3101 | GtkWidget *label1 = gtk_label_new(""); |
c8bba5fa |
3102 | gtk_misc_set_padding(GTK_MISC(label1), 10, 20); |
51ef553b |
3103 | gtk_label_set_markup(GTK_LABEL(label1), "\ |
c8bba5fa |
3104 | <big>Linux Trace Toolkit</big>"); |
51ef553b |
3105 | gtk_label_set_justify(GTK_LABEL(label1), GTK_JUSTIFY_CENTER); |
3106 | |
3107 | GtkWidget *label2 = gtk_label_new(""); |
c8bba5fa |
3108 | gtk_misc_set_padding(GTK_MISC(label2), 10, 20); |
51ef553b |
3109 | gtk_label_set_markup(GTK_LABEL(label2), "\ |
51ef553b |
3110 | Contributors :\n\ |
3111 | \n\ |
3112 | Michel Dagenais (New trace format, lttv main)\n\ |
4b601423 |
3113 | Mathieu Desnoyers (Kernel Tracer, Directory structure, build with automake/conf,\n\ |
ef26c1ea |
3114 | lttv gui, control flow view, gui cooperative trace reading\n\ |
4b7bd7e1 |
3115 | scheduler with interruptible foreground and background\n\ |
57ca4914 |
3116 | computation, detailed event list (rewrite), trace reading\n\ |
3117 | library (rewrite))\n\ |
7d2855bf |
3118 | Benoit Des Ligneris, Eric Clement (Cluster adaptation, work in progress)\n\ |
51ef553b |
3119 | Xang-Xiu Yang (new trace reading library and converter, lttv gui, \n\ |
3120 | detailed event list and statistics view)\n\ |
e8ac6a5e |
3121 | Tom Zanussi (RelayFS)\n\ |
3122 | \n\ |
3123 | Strongly inspired from the original Linux Trace Toolkit Visualizer made by\n\ |
3124 | Karim Yaghmour"); |
c8bba5fa |
3125 | |
3126 | GtkWidget *label3 = gtk_label_new(""); |
3127 | gtk_label_set_markup(GTK_LABEL(label3), "\ |
7d2855bf |
3128 | Linux Trace Toolkit Viewer, Copyright (C) 2004\n\ |
3129 | Michel Dagenais\n\ |
e8ac6a5e |
3130 | Mathieu Desnoyers\n\ |
3131 | Xang-Xiu Yang\n\ |
c8bba5fa |
3132 | Linux Trace Toolkit comes with ABSOLUTELY NO WARRANTY.\n\ |
3133 | This is free software, and you are welcome to redistribute it\n\ |
3134 | under certain conditions. See COPYING for details."); |
3135 | gtk_misc_set_padding(GTK_MISC(label3), 10, 20); |
3136 | |
51ef553b |
3137 | gtk_box_pack_start_defaults(GTK_BOX(vbox), label1); |
3138 | gtk_box_pack_start_defaults(GTK_BOX(vbox), label2); |
c8bba5fa |
3139 | gtk_box_pack_start_defaults(GTK_BOX(vbox), label3); |
51ef553b |
3140 | |
3141 | GtkWidget *hbox = gtk_hbox_new(TRUE, 0); |
3142 | gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
3143 | GtkWidget *close_button = gtk_button_new_with_mnemonic("_Close"); |
3144 | gtk_box_pack_end(GTK_BOX(hbox), close_button, FALSE, FALSE, 0); |
3145 | gtk_container_set_border_width(GTK_CONTAINER(close_button), 20); |
3146 | |
3147 | g_signal_connect(G_OBJECT(close_button), "clicked", |
3148 | G_CALLBACK(on_about_close_activate), |
3149 | (gpointer)about_widget); |
3150 | |
3151 | gtk_widget_show_all(about_widget); |
561eba2a |
3152 | } |
3153 | |
3154 | |
3155 | void |
3156 | on_button_new_clicked (GtkButton *button, |
3157 | gpointer user_data) |
3158 | { |
6f7ad7ae |
3159 | create_new_window((GtkWidget*)button, user_data, TRUE); |
561eba2a |
3160 | } |
3161 | |
2901f314 |
3162 | void |
3163 | on_button_new_tab_clicked (GtkButton *button, |
3164 | gpointer user_data) |
3165 | { |
3166 | create_new_tab((GtkWidget*)button, user_data); |
3167 | } |
561eba2a |
3168 | |
3169 | void |
3170 | on_button_open_clicked (GtkButton *button, |
3171 | gpointer user_data) |
3172 | { |
3173 | open_traceset((GtkWidget*)button, user_data); |
3174 | } |
3175 | |
3176 | |
3177 | void |
3178 | on_button_add_trace_clicked (GtkButton *button, |
3179 | gpointer user_data) |
3180 | { |
3181 | add_trace((GtkWidget*)button, user_data); |
3182 | } |
3183 | |
3184 | |
3185 | void |
3186 | on_button_remove_trace_clicked (GtkButton *button, |
3187 | gpointer user_data) |
3188 | { |
3189 | remove_trace((GtkWidget*)button, user_data); |
3190 | } |
3191 | |
9878c8a4 |
3192 | void |
3193 | on_button_redraw_clicked (GtkButton *button, |
3194 | gpointer user_data) |
3195 | { |
3196 | redraw((GtkWidget*)button, user_data); |
3197 | } |
3198 | |
3199 | void |
3200 | on_button_continue_processing_clicked (GtkButton *button, |
3201 | gpointer user_data) |
3202 | { |
3203 | continue_processing((GtkWidget*)button, user_data); |
3204 | } |
3205 | |
3206 | void |
3207 | on_button_stop_processing_clicked (GtkButton *button, |
3208 | gpointer user_data) |
3209 | { |
3210 | stop_processing((GtkWidget*)button, user_data); |
3211 | } |
3212 | |
3213 | |
561eba2a |
3214 | |
3215 | void |
3216 | on_button_save_clicked (GtkButton *button, |
3217 | gpointer user_data) |
3218 | { |
3219 | save((GtkWidget*)button, user_data); |
3220 | } |
3221 | |
3222 | |
3223 | void |
3224 | on_button_save_as_clicked (GtkButton *button, |
3225 | gpointer user_data) |
3226 | { |
3227 | save_as((GtkWidget*)button, user_data); |
3228 | } |
3229 | |
3230 | |
3231 | void |
3232 | on_button_zoom_in_clicked (GtkButton *button, |
3233 | gpointer user_data) |
3234 | { |
3235 | zoom_in((GtkWidget*)button, user_data); |
3236 | } |
3237 | |
3238 | |
3239 | void |
3240 | on_button_zoom_out_clicked (GtkButton *button, |
3241 | gpointer user_data) |
3242 | { |
3243 | zoom_out((GtkWidget*)button, user_data); |
3244 | } |
3245 | |
3246 | |
3247 | void |
3248 | on_button_zoom_extended_clicked (GtkButton *button, |
3249 | gpointer user_data) |
3250 | { |
3251 | zoom_extended((GtkWidget*)button, user_data); |
3252 | } |
3253 | |
3254 | |
3255 | void |
3256 | on_button_go_to_time_clicked (GtkButton *button, |
3257 | gpointer user_data) |
3258 | { |
3259 | go_to_time((GtkWidget*)button, user_data); |
3260 | } |
3261 | |
3262 | |
3263 | void |
3264 | on_button_show_time_frame_clicked (GtkButton *button, |
3265 | gpointer user_data) |
3266 | { |
3267 | show_time_frame((GtkWidget*)button, user_data); |
3268 | } |
3269 | |
3270 | |
3271 | void |
3272 | on_button_move_up_clicked (GtkButton *button, |
3273 | gpointer user_data) |
3274 | { |
3275 | move_up_viewer((GtkWidget*)button, user_data); |
3276 | } |
3277 | |
3278 | |
3279 | void |
3280 | on_button_move_down_clicked (GtkButton *button, |
3281 | gpointer user_data) |
3282 | { |
3283 | move_down_viewer((GtkWidget*)button, user_data); |
3284 | } |
3285 | |
3286 | |
3287 | void |
3288 | on_button_delete_viewer_clicked (GtkButton *button, |
3289 | gpointer user_data) |
3290 | { |
3291 | delete_viewer((GtkWidget*)button, user_data); |
3292 | } |
3293 | |
3294 | void |
2d262115 |
3295 | on_MWindow_destroy (GtkWidget *widget, |
561eba2a |
3296 | gpointer user_data) |
3297 | { |
2d262115 |
3298 | MainWindow *main_window = get_window_data_struct(widget); |
ef68c3ac |
3299 | LttvIAttribute *attributes = main_window->attributes; |
3300 | LttvAttributeValue value; |
e4d09234 |
3301 | |
ef68c3ac |
3302 | //This is unnecessary, since widgets will be destroyed |
3303 | //by the main window widget anyway. |
3304 | //remove_all_menu_toolbar_constructors(main_window, NULL); |
3305 | |
3306 | g_assert(lttv_iattribute_find_by_path(attributes, |
3307 | "viewers/menu", LTTV_POINTER, &value)); |
3308 | lttv_menus_destroy((LttvMenus*)*(value.v_pointer)); |
3309 | |
501e4e70 |
3310 | g_assert(lttv_iattribute_find_by_path(attributes, |
ef68c3ac |
3311 | "viewers/toolbar", LTTV_POINTER, &value)); |
3312 | lttv_toolbars_destroy((LttvToolbars*)*(value.v_pointer)); |
2d262115 |
3313 | |
ef68c3ac |
3314 | g_object_unref(main_window->attributes); |
3315 | g_main_window_list = g_slist_remove(g_main_window_list, main_window); |
561eba2a |
3316 | |
56e5a0f7 |
3317 | g_info("There are now : %d windows\n",g_slist_length(g_main_window_list)); |
2d262115 |
3318 | if(g_slist_length(g_main_window_list) == 0) |
d27948a3 |
3319 | mainwindow_quit(); |
561eba2a |
3320 | } |
3321 | |
58eecf4a |
3322 | gboolean |
3323 | on_MWindow_configure (GtkWidget *widget, |
3324 | GdkEventConfigure *event, |
3325 | gpointer user_data) |
3326 | { |
3327 | MainWindow * mw_data = get_window_data_struct((GtkWidget*)widget); |
bd24a9af |
3328 | |
3329 | // MD : removed time width modification upon resizing of the main window. |
3330 | // The viewers will redraw themselves completely, without time interval |
3331 | // modification. |
3332 | /* while(tab){ |
58eecf4a |
3333 | if(mw_data->window_width){ |
3334 | time_span = LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)->Time_Span ; |
3335 | time_win = tab->time_window; |
3336 | ratio = width / mw_data->window_width; |
3337 | tab->time_window.time_width = ltt_time_mul(time_win.time_width,ratio); |
3338 | time = ltt_time_sub(time_span->endTime, time_win.start_time); |
3339 | if(ltt_time_compare(time, tab->time_window.time_width) < 0){ |
3340 | tab->time_window.time_width = time; |
3341 | } |
3342 | } |
3343 | tab = tab->next; |
3344 | } |
3345 | |
3346 | mw_data->window_width = (int)width; |
bd24a9af |
3347 | */ |
58eecf4a |
3348 | return FALSE; |
3349 | } |
561eba2a |
3350 | |
abe346a3 |
3351 | /* Set current tab |
3352 | */ |
3353 | |
561eba2a |
3354 | void |
3355 | on_MNotebook_switch_page (GtkNotebook *notebook, |
3356 | GtkNotebookPage *page, |
3357 | guint page_num, |
3358 | gpointer user_data) |
3359 | { |
47cd8a09 |
3360 | |
561eba2a |
3361 | } |
3362 | |
abe346a3 |
3363 | |
e800cf84 |
3364 | void time_change_manager (Tab *tab, |
3365 | TimeWindow new_time_window) |
3366 | { |
3367 | /* Only one source of time change */ |
3368 | if(tab->time_manager_lock == TRUE) return; |
3369 | |
3370 | tab->time_manager_lock = TRUE; |
3371 | |
3372 | LttvTracesetContext *tsc = LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); |
3373 | TimeInterval time_span = tsc->time_span; |
3374 | LttTime start_time = new_time_window.start_time; |
6f26fc38 |
3375 | LttTime end_time = new_time_window.end_time; |
d112868c |
3376 | LttTime time_width = new_time_window.time_width; |
e800cf84 |
3377 | |
a998b781 |
3378 | g_assert(ltt_time_compare(start_time, end_time) < 0); |
3379 | |
e800cf84 |
3380 | /* Set scrollbar */ |
3381 | GtkAdjustment *adjustment = gtk_range_get_adjustment(GTK_RANGE(tab->scrollbar)); |
3382 | LttTime upper = ltt_time_sub(time_span.end_time, time_span.start_time); |
3383 | #if 0 |
3384 | gtk_range_set_increments(GTK_RANGE(tab->scrollbar), |
3385 | ltt_time_to_double(new_time_window.time_width) |
3386 | / SCROLL_STEP_PER_PAGE |
3387 | * NANOSECONDS_PER_SECOND, /* step increment */ |
3388 | ltt_time_to_double(new_time_window.time_width) |
3389 | * NANOSECONDS_PER_SECOND); /* page increment */ |
3390 | gtk_range_set_range(GTK_RANGE(tab->scrollbar), |
3391 | 0.0, /* lower */ |
3392 | ltt_time_to_double(upper) |
3393 | * NANOSECONDS_PER_SECOND); /* upper */ |
3394 | #endif //0 |
3395 | g_object_set(G_OBJECT(adjustment), |
3396 | "lower", |
3397 | 0.0, /* lower */ |
3398 | "upper", |
c74e0cf9 |
3399 | ltt_time_to_double(upper), /* upper */ |
e800cf84 |
3400 | "step_increment", |
a18124ff |
3401 | new_time_window.time_width_double |
c74e0cf9 |
3402 | / SCROLL_STEP_PER_PAGE, /* step increment */ |
e800cf84 |
3403 | "page_increment", |
a18124ff |
3404 | new_time_window.time_width_double, |
c74e0cf9 |
3405 | /* page increment */ |
e800cf84 |
3406 | "page_size", |
a18124ff |
3407 | new_time_window.time_width_double, /* page size */ |
e800cf84 |
3408 | NULL); |
3409 | gtk_adjustment_changed(adjustment); |
3410 | |
3411 | // g_object_set(G_OBJECT(adjustment), |
3412 | // "value", |
3413 | // ltt_time_to_double( |
3414 | // ltt_time_sub(start_time, time_span.start_time)) |
c74e0cf9 |
3415 | // , /* value */ |
e800cf84 |
3416 | // NULL); |
3417 | //gtk_adjustment_value_changed(adjustment); |
3418 | gtk_range_set_value(GTK_RANGE(tab->scrollbar), |
3419 | ltt_time_to_double( |
c74e0cf9 |
3420 | ltt_time_sub(start_time, time_span.start_time)) /* value */); |
e800cf84 |
3421 | |
3422 | /* set the time bar. */ |
3423 | /* start seconds */ |
3424 | gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry1), |
3425 | (double)time_span.start_time.tv_sec, |
3426 | (double)time_span.end_time.tv_sec); |
3427 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry1), |
3428 | (double)start_time.tv_sec); |
3429 | |
3430 | /* start nanoseconds */ |
3431 | if(start_time.tv_sec == time_span.start_time.tv_sec) { |
71624cb7 |
3432 | /* can be both beginning and end at the same time. */ |
3433 | if(start_time.tv_sec == time_span.end_time.tv_sec) { |
3434 | /* If we are at the end, max nsec to end.. -1 (not zero length) */ |
3435 | gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry2), |
3436 | (double)time_span.start_time.tv_nsec, |
3437 | (double)time_span.end_time.tv_nsec-1); |
3438 | } else { |
3439 | gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry2), |
3440 | (double)time_span.start_time.tv_nsec, |
3441 | (double)NANOSECONDS_PER_SECOND-1); |
3442 | } |
3443 | } else if(start_time.tv_sec == time_span.end_time.tv_sec) { |
3444 | /* If we are at the end, max nsec to end.. -1 (not zero length) */ |
3445 | gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry2), |
3446 | 0.0, |
3447 | (double)time_span.end_time.tv_nsec-1); |
3448 | } else /* anywhere else */ |
e800cf84 |
3449 | gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry2), |
3450 | 0.0, |
3451 | (double)NANOSECONDS_PER_SECOND-1); |
3452 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry2), |
3453 | (double)start_time.tv_nsec); |
3454 | |
3455 | /* end seconds */ |
3456 | gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry3), |
3457 | (double)time_span.start_time.tv_sec, |
3458 | (double)time_span.end_time.tv_sec); |
3459 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry3), |
3460 | (double)end_time.tv_sec); |
3461 | |
3462 | /* end nanoseconds */ |
3463 | if(end_time.tv_sec == time_span.start_time.tv_sec) { |
71624cb7 |
3464 | /* can be both beginning and end at the same time. */ |
3465 | if(end_time.tv_sec == time_span.end_time.tv_sec) { |
3466 | /* If we are at the end, max nsec to end.. */ |
3467 | gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry4), |
3468 | (double)time_span.start_time.tv_nsec+1, |
3469 | (double)time_span.end_time.tv_nsec); |
3470 | } else { |
3471 | gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry4), |
3472 | (double)time_span.start_time.tv_nsec+1, |
3473 | (double)NANOSECONDS_PER_SECOND-1); |
3474 | } |
e800cf84 |
3475 | } |
3476 | else if(end_time.tv_sec == time_span.end_time.tv_sec) { |
3477 | /* If we are at the end, max nsec to end.. */ |
3478 | gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry4), |
3479 | 0.0, |
3480 | (double)time_span.end_time.tv_nsec); |
3481 | } |
3482 | else /* anywhere else */ |
3483 | gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry4), |
3484 | 0.0, |
3485 | (double)NANOSECONDS_PER_SECOND-1); |
3486 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry4), |
3487 | (double)end_time.tv_nsec); |
3488 | |
d112868c |
3489 | /* width seconds */ |
074ed5c1 |
3490 | if(time_width.tv_nsec == 0) { |
3491 | gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry7), |
3492 | (double)1, |
3493 | (double)upper.tv_sec); |
3494 | } else { |
3495 | gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry7), |
3496 | (double)0, |
3497 | (double)upper.tv_sec); |
3498 | } |
d112868c |
3499 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry7), |
3500 | (double)time_width.tv_sec); |
3501 | |
3502 | /* width nanoseconds */ |
f34733d7 |
3503 | if(time_width.tv_sec == upper.tv_sec) { |
d112868c |
3504 | if(time_width.tv_sec == 0) { |
3505 | gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry8), |
3506 | (double)1, |
f34733d7 |
3507 | (double)upper.tv_nsec); |
d112868c |
3508 | } else { |
3509 | gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry8), |
3510 | (double)0, |
f34733d7 |
3511 | (double)upper.tv_nsec); |
d112868c |
3512 | } |
3513 | } |
3514 | else if(time_width.tv_sec == 0) { |
3515 | gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry8), |
3516 | 1.0, |
f34733d7 |
3517 | (double)upper.tv_nsec); |
d112868c |
3518 | } |
3519 | else /* anywhere else */ |
3520 | gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry8), |
3521 | 0.0, |
3522 | (double)NANOSECONDS_PER_SECOND-1); |
3523 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry8), |
3524 | (double)time_width.tv_nsec); |
3525 | |
e800cf84 |
3526 | /* call viewer hooks for new time window */ |
3527 | set_time_window(tab, &new_time_window); |
3528 | |
3529 | tab->time_manager_lock = FALSE; |
3530 | } |
3531 | |
3532 | |
3533 | /* value changed for frame start s |
3534 | * |
3535 | * Check time span : if ns is out of range, clip it the nearest good value. |
3536 | */ |
3537 | void |
3538 | on_MEntry1_value_changed (GtkSpinButton *spinbutton, |
3539 | gpointer user_data) |
3540 | { |
3541 | Tab *tab =(Tab *)user_data; |
3542 | LttvTracesetContext * tsc = |
3543 | LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); |
3544 | TimeInterval time_span = tsc->time_span; |
3545 | gint value = gtk_spin_button_get_value_as_int(spinbutton); |
3546 | |
3547 | TimeWindow new_time_window = tab->time_window; |
3548 | |
6f26fc38 |
3549 | LttTime end_time = new_time_window.end_time; |
e800cf84 |
3550 | |
3551 | new_time_window.start_time.tv_sec = value; |
3552 | |
3553 | /* start nanoseconds */ |
3554 | if(new_time_window.start_time.tv_sec == time_span.start_time.tv_sec) { |
71624cb7 |
3555 | if(new_time_window.start_time.tv_sec == time_span.end_time.tv_sec) { |
3556 | if(new_time_window.start_time.tv_nsec > time_span.end_time.tv_nsec) |
3557 | new_time_window.start_time.tv_nsec = time_span.end_time.tv_nsec-1; |
3558 | if(new_time_window.start_time.tv_nsec < time_span.start_time.tv_nsec) |
3559 | new_time_window.start_time.tv_nsec = time_span.start_time.tv_nsec; |
3560 | } else { |
3561 | if(new_time_window.start_time.tv_nsec < time_span.start_time.tv_nsec) |
3562 | new_time_window.start_time.tv_nsec = time_span.start_time.tv_nsec; |
3563 | } |
e800cf84 |
3564 | } |
3565 | else if(new_time_window.start_time.tv_sec == time_span.end_time.tv_sec) { |
3566 | if(new_time_window.start_time.tv_nsec > time_span.end_time.tv_nsec) |
3567 | new_time_window.start_time.tv_nsec = time_span.end_time.tv_nsec-1; |
3568 | } |
3569 | |
e800cf84 |
3570 | if(ltt_time_compare(new_time_window.start_time, end_time) >= 0) { |
3571 | /* Then, we must push back end time : keep the same time width |
3572 | * if possible, else end traceset time */ |
6f26fc38 |
3573 | end_time = LTT_TIME_MIN(ltt_time_add(new_time_window.start_time, |
3574 | new_time_window.time_width), |
3575 | time_span.end_time); |
e800cf84 |
3576 | } |
3577 | |
3578 | /* Fix the time width to fit start time and end time */ |
3579 | new_time_window.time_width = ltt_time_sub(end_time, |
3580 | new_time_window.start_time); |
a18124ff |
3581 | new_time_window.time_width_double = |
3582 | ltt_time_to_double(new_time_window.time_width); |
3583 | |
6f26fc38 |
3584 | new_time_window.end_time = end_time; |
e800cf84 |
3585 | |
3586 | time_change_manager(tab, new_time_window); |
3587 | |
3588 | } |
3589 | |
3590 | void |
3591 | on_MEntry2_value_changed (GtkSpinButton *spinbutton, |
3592 | gpointer user_data) |
3593 | { |
3594 | Tab *tab =(Tab *)user_data; |
3595 | LttvTracesetContext * tsc = |
3596 | LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); |
3597 | TimeInterval time_span = tsc->time_span; |
3598 | gint value = gtk_spin_button_get_value_as_int(spinbutton); |
3599 | |
3600 | TimeWindow new_time_window = tab->time_window; |
3601 | |
6f26fc38 |
3602 | LttTime end_time = new_time_window.end_time; |
e800cf84 |
3603 | |
3604 | new_time_window.start_time.tv_nsec = value; |
3605 | |
e800cf84 |
3606 | if(ltt_time_compare(new_time_window.start_time, end_time) >= 0) { |
3607 | /* Then, we must push back end time : keep the same time width |
3608 | * if possible, else end traceset time */ |
6f26fc38 |
3609 | end_time = LTT_TIME_MIN(ltt_time_add(new_time_window.start_time, |
3610 | new_time_window.time_width), |
3611 | time_span.end_time); |
e800cf84 |
3612 | } |
3613 | |
3614 | /* Fix the time width to fit start time and end time */ |
3615 | new_time_window.time_width = ltt_time_sub(end_time, |
3616 | new_time_window.start_time); |
a18124ff |
3617 | new_time_window.time_width_double = |
3618 | ltt_time_to_double(new_time_window.time_width); |
e800cf84 |
3619 | |
6f26fc38 |
3620 | new_time_window.end_time = end_time; |
3621 | |
e800cf84 |
3622 | time_change_manager(tab, new_time_window); |
3623 | |
3624 | } |
3625 | |
3626 | void |
3627 | on_MEntry3_value_changed (GtkSpinButton *spinbutton, |
3628 | gpointer user_data) |
3629 | { |
3630 | Tab *tab =(Tab *)user_data; |
3631 | LttvTracesetContext * tsc = |
3632 | LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); |
3633 | TimeInterval time_span = tsc->time_span; |
3634 | gint value = gtk_spin_button_get_value_as_int(spinbutton); |
3635 | |
3636 | TimeWindow new_time_window = tab->time_window; |
3637 | |
6f26fc38 |
3638 | LttTime end_time = new_time_window.end_time; |
3639 | |
e800cf84 |
3640 | end_time.tv_sec = value; |
3641 | |
3642 | /* end nanoseconds */ |
3643 | if(end_time.tv_sec == time_span.start_time.tv_sec) { |
71624cb7 |
3644 | if(end_time.tv_sec == time_span.end_time.tv_sec) { |
3645 | if(end_time.tv_nsec > time_span.end_time.tv_nsec) |
3646 | end_time.tv_nsec = time_span.end_time.tv_nsec; |
3647 | if(end_time.tv_nsec < time_span.start_time.tv_nsec) |
3648 | end_time.tv_nsec = time_span.start_time.tv_nsec+1; |
3649 | } else { |
3650 | if(end_time.tv_nsec < time_span.start_time.tv_nsec) |
3651 | end_time.tv_nsec = time_span.start_time.tv_nsec+1; |
3652 | } |
e800cf84 |
3653 | } |
3654 | else if(end_time.tv_sec == time_span.end_time.tv_sec) { |
3655 | if(end_time.tv_nsec > time_span.end_time.tv_nsec) |
3656 | end_time.tv_nsec = time_span.end_time.tv_nsec; |
3657 | } |
3658 | |
e800cf84 |
3659 | if(ltt_time_compare(new_time_window.start_time, end_time) >= 0) { |
3660 | /* Then, we must push front start time : keep the same time width |
3661 | * if possible, else end traceset time */ |
6f26fc38 |
3662 | new_time_window.start_time = LTT_TIME_MAX( |
3663 | ltt_time_sub(end_time, |
3664 | new_time_window.time_width), |
3665 | time_span.start_time); |
e800cf84 |
3666 | } |
3667 | |
3668 | /* Fix the time width to fit start time and end time */ |
3669 | new_time_window.time_width = ltt_time_sub(end_time, |
3670 | new_time_window.start_time); |
a18124ff |
3671 | new_time_window.time_width_double = |
3672 | ltt_time_to_double(new_time_window.time_width); |
e800cf84 |
3673 | |
6f26fc38 |
3674 | new_time_window.end_time = end_time; |
3675 | |
e800cf84 |
3676 | time_change_manager(tab, new_time_window); |
3677 | |
3678 | } |
3679 | |
3680 | void |
3681 | on_MEntry4_value_changed (GtkSpinButton *spinbutton, |
3682 | gpointer user_data) |
3683 | { |
3684 | Tab *tab =(Tab *)user_data; |
3685 | LttvTracesetContext * tsc = |
3686 | LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); |
3687 | TimeInterval time_span = tsc->time_span; |
3688 | gint value = gtk_spin_button_get_value_as_int(spinbutton); |
3689 | |
3690 | TimeWindow new_time_window = tab->time_window; |
3691 | |
6f26fc38 |
3692 | LttTime end_time = new_time_window.end_time; |
3693 | |
e800cf84 |
3694 | end_time.tv_nsec = value; |
3695 | |
e800cf84 |
3696 | if(ltt_time_compare(new_time_window.start_time, end_time) >= 0) { |
3697 | /* Then, we must push front start time : keep the same time width |
3698 | * if possible, else end traceset time */ |
6f26fc38 |
3699 | new_time_window.start_time = LTT_TIME_MAX( |
3700 | ltt_time_sub(end_time, |
3701 | new_time_window.time_width), |
3702 | time_span.start_time); |
e800cf84 |
3703 | } |
3704 | |
3705 | /* Fix the time width to fit start time and end time */ |
3706 | new_time_window.time_width = ltt_time_sub(end_time, |
3707 | new_time_window.start_time); |
a18124ff |
3708 | new_time_window.time_width_double = |
3709 | ltt_time_to_double(new_time_window.time_width); |
6f26fc38 |
3710 | new_time_window.end_time = end_time; |
e800cf84 |
3711 | |
3712 | time_change_manager(tab, new_time_window); |
3713 | |
3714 | } |
3715 | |
58de9fc1 |
3716 | /* value changed for time frame interval s |
3717 | * |
3718 | * Check time span : if ns is out of range, clip it the nearest good value. |
3719 | */ |
3720 | void |
3721 | on_MEntry7_value_changed (GtkSpinButton *spinbutton, |
3722 | gpointer user_data) |
3723 | { |
3724 | Tab *tab =(Tab *)user_data; |
3725 | LttvTracesetContext * tsc = |
3726 | LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); |
3727 | TimeInterval time_span = tsc->time_span; |
3728 | gint value = gtk_spin_button_get_value_as_int(spinbutton); |
3729 | LttTime current_time, time_delta; |
3730 | TimeWindow new_time_window = tab->time_window; |
3731 | current_time = tab->current_time; |
3732 | |
3733 | time_delta = ltt_time_sub(time_span.end_time,time_span.start_time); |
3734 | new_time_window.time_width.tv_sec = value; |
3735 | new_time_window.time_width_double = |
3736 | ltt_time_to_double(new_time_window.time_width); |
3737 | if(ltt_time_compare(new_time_window.time_width,time_delta) > 0) |
3738 | { /* Case where zoom out is bigger than trace length */ |
3739 | new_time_window.start_time = time_span.start_time; |
3740 | new_time_window.time_width = time_delta; |
3741 | new_time_window.time_width_double = ltt_time_to_double(time_delta); |
3742 | new_time_window.end_time = ltt_time_add(new_time_window.start_time, |
3743 | new_time_window.time_width) ; |
3744 | } |
3745 | else |
3746 | { |
3747 | /* Center the image on the current time */ |
3748 | new_time_window.start_time = |
3749 | ltt_time_sub(current_time, |
3750 | ltt_time_from_double(new_time_window.time_width_double/2.0)); |
3751 | new_time_window.end_time = ltt_time_add(new_time_window.start_time, |
3752 | new_time_window.time_width) ; |
3753 | /* If on borders, don't fall off */ |
3754 | if(ltt_time_compare(new_time_window.start_time, time_span.start_time) <0 |
3755 | || ltt_time_compare(new_time_window.start_time, time_span.end_time) >0) |
3756 | { |
3757 | new_time_window.start_time = time_span.start_time; |
3758 | new_time_window.end_time = ltt_time_add(new_time_window.start_time, |
3759 | new_time_window.time_width) ; |
3760 | } |
3761 | else |
3762 | { |
3763 | if(ltt_time_compare(new_time_window.end_time, |
3764 | time_span.end_time) > 0 |
3765 | || ltt_time_compare(new_time_window.end_time, |
3766 | time_span.start_time) < 0) |
3767 | { |
3768 | new_time_window.start_time = |
3769 | ltt_time_sub(time_span.end_time, new_time_window.time_width); |
3770 | |
3771 | new_time_window.end_time = ltt_time_add(new_time_window.start_time, |
3772 | new_time_window.time_width) ; |
3773 | } |
3774 | } |
3775 | |
3776 | } |
3777 | |
3778 | if(ltt_time_compare(new_time_window.time_width, ltt_time_zero) == 0) { |
3779 | g_warning("Zoom more than 1 ns impossible"); |
3780 | } else { |
3781 | time_change_manager(tab, new_time_window); |
3782 | } |
3783 | } |
3784 | |
3785 | void |
3786 | on_MEntry8_value_changed (GtkSpinButton *spinbutton, |
3787 | gpointer user_data) |
3788 | { |
3789 | Tab *tab =(Tab *)user_data; |
3790 | LttvTracesetContext * tsc = |
3791 | LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); |
3792 | TimeInterval time_span = tsc->time_span; |
3793 | gint value = gtk_spin_button_get_value_as_int(spinbutton); |
3794 | LttTime current_time, time_delta; |
3795 | TimeWindow new_time_window = tab->time_window; |
3796 | current_time = tab->current_time; |
3797 | |
3798 | time_delta = ltt_time_sub(time_span.end_time,time_span.start_time); |
3799 | new_time_window.time_width.tv_nsec = value; |
3800 | new_time_window.time_width_double = |
3801 | ltt_time_to_double(new_time_window.time_width); |
3802 | if(ltt_time_compare(new_time_window.time_width,time_delta) > 0) |
3803 | { /* Case where zoom out is bigger than trace length */ |
3804 | new_time_window.start_time = time_span.start_time; |
3805 | new_time_window.time_width = time_delta; |
3806 | new_time_window.time_width_double = ltt_time_to_double(time_delta); |
3807 | new_time_window.end_time = ltt_time_add(new_time_window.start_time, |
3808 | new_time_window.time_width) ; |
3809 | } |
3810 | else |
3811 | { |
3812 | /* Center the image on the current time */ |
3813 | new_time_window.start_time = |
3814 | ltt_time_sub(current_time, |
3815 | ltt_time_from_double(new_time_window.time_width_double/2.0)); |
3816 | new_time_window.end_time = ltt_time_add(new_time_window.start_time, |
3817 | new_time_window.time_width) ; |
3818 | /* If on borders, don't fall off */ |
3819 | if(ltt_time_compare(new_time_window.start_time, time_span.start_time) <0 |
3820 | || ltt_time_compare(new_time_window.start_time, time_span.end_time) >0) |
3821 | { |
3822 | new_time_window.start_time = time_span.start_time; |
3823 | new_time_window.end_time = ltt_time_add(new_time_window.start_time, |
3824 | new_time_window.time_width) ; |
3825 | } |
3826 | else |
3827 | { |
3828 | if(ltt_time_compare(new_time_window.end_time, |
3829 | time_span.end_time) > 0 |
3830 | || ltt_time_compare(new_time_window.end_time, |
3831 | time_span.start_time) < 0) |
3832 | { |
3833 | new_time_window.start_time = |
3834 | ltt_time_sub(time_span.end_time, new_time_window.time_width); |
3835 | |
3836 | new_time_window.end_time = ltt_time_add(new_time_window.start_time, |
3837 | new_time_window.time_width) ; |
3838 | } |
3839 | } |
3840 | |
3841 | } |
3842 | |
3843 | if(ltt_time_compare(new_time_window.time_width, ltt_time_zero) == 0) { |
3844 | g_warning("Zoom more than 1 ns impossible"); |
3845 | } else { |
3846 | time_change_manager(tab, new_time_window); |
3847 | } |
3848 | } |
3849 | |
3850 | |
e800cf84 |
3851 | |
3852 | void current_time_change_manager (Tab *tab, |
3853 | LttTime new_current_time) |
3854 | { |
3855 | /* Only one source of time change */ |
3856 | if(tab->current_time_manager_lock == TRUE) return; |
3857 | |
3858 | tab->current_time_manager_lock = TRUE; |
3859 | |
3860 | LttvTracesetContext *tsc = LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); |
3861 | TimeInterval time_span = tsc->time_span; |
3862 | |
e800cf84 |
3863 | /* current seconds */ |
3864 | gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry5), |
3865 | (double)time_span.start_time.tv_sec, |
3866 | (double)time_span.end_time.tv_sec); |
db8bc917 |
3867 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry5), |
3868 | (double)new_current_time.tv_sec); |
71624cb7 |
3869 | |
3870 | |
e800cf84 |
3871 | /* start nanoseconds */ |
3872 | if(new_current_time.tv_sec == time_span.start_time.tv_sec) { |
71624cb7 |
3873 | /* can be both beginning and end at the same time. */ |
3874 | if(new_current_time.tv_sec == time_span.end_time.tv_sec) { |
3875 | /* If we are at the end, max nsec to end.. */ |
3876 | gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry6), |
3877 | (double)time_span.start_time.tv_nsec, |
3878 | (double)time_span.end_time.tv_nsec); |
3879 | } else { |
3880 | gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry6), |
3881 | (double)time_span.start_time.tv_nsec, |
3882 | (double)NANOSECONDS_PER_SECOND-1); |
3883 | } |
3884 | } else if(new_current_time.tv_sec == time_span.end_time.tv_sec) { |
3885 | /* If we are at the end, max nsec to end.. */ |
3886 | gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry6), |
3887 | 0.0, |
3888 | (double)time_span.end_time.tv_nsec); |
3889 | } else /* anywhere else */ |
e800cf84 |
3890 | gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry6), |
3891 | 0.0, |
3892 | (double)NANOSECONDS_PER_SECOND-1); |
71624cb7 |
3893 | |
e800cf84 |
3894 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry6), |
3895 | (double)new_current_time.tv_nsec); |
3896 | |
db8bc917 |
3897 | set_current_time(tab, &new_current_time); |
e800cf84 |
3898 | |
3899 | tab->current_time_manager_lock = FALSE; |
3900 | } |
3901 | |
5290ec02 |
3902 | void current_position_change_manager(Tab *tab, |
3903 | LttvTracesetContextPosition *pos) |
3904 | { |
3905 | LttvTracesetContext *tsc = |
3906 | LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); |
3907 | TimeInterval time_span = tsc->time_span; |
3908 | |
3909 | g_assert(lttv_process_traceset_seek_position(tsc, pos) == 0); |
3910 | LttTime new_time = lttv_traceset_context_position_get_time(pos); |
16e2bb34 |
3911 | /* Put the context in a state coherent position */ |
3912 | lttv_state_traceset_seek_time_closest((LttvTracesetState*)tsc, ltt_time_zero); |
5290ec02 |
3913 | |
3914 | current_time_change_manager(tab, new_time); |
3915 | |
3916 | set_current_position(tab, pos); |
3917 | } |
3918 | |
3919 | |
e800cf84 |
3920 | void |
3921 | on_MEntry5_value_changed (GtkSpinButton *spinbutton, |
3922 | gpointer user_data) |
3923 | { |
3924 | Tab *tab = (Tab*)user_data; |
3925 | LttvTracesetContext * tsc = |
3926 | LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); |
3927 | TimeInterval time_span = tsc->time_span; |
3928 | gint value = gtk_spin_button_get_value_as_int(spinbutton); |
3929 | LttTime new_current_time = tab->current_time; |
3930 | new_current_time.tv_sec = value; |
3931 | |
3932 | /* current nanoseconds */ |
3933 | if(new_current_time.tv_sec == time_span.start_time.tv_sec) { |
71624cb7 |
3934 | if(new_current_time.tv_sec == time_span.end_time.tv_sec) { |
3935 | if(new_current_time.tv_nsec > time_span.end_time.tv_nsec) |
3936 | new_current_time.tv_nsec = time_span.end_time.tv_nsec; |
3937 | if(new_current_time.tv_nsec < time_span.start_time.tv_nsec) |
3938 | new_current_time.tv_nsec = time_span.start_time.tv_nsec; |
3939 | } else { |
3940 | if(new_current_time.tv_nsec < time_span.start_time.tv_nsec) |
3941 | new_current_time.tv_nsec = time_span.start_time.tv_nsec; |
3942 | } |
e800cf84 |
3943 | } |
3944 | else if(new_current_time.tv_sec == time_span.end_time.tv_sec) { |
3945 | if(new_current_time.tv_nsec > time_span.end_time.tv_nsec) |
3946 | new_current_time.tv_nsec = time_span.end_time.tv_nsec; |
3947 | } |
3948 | |
3949 | current_time_change_manager(tab, new_current_time); |
3950 | } |
3951 | |
3952 | void |
3953 | on_MEntry6_value_changed (GtkSpinButton *spinbutton, |
3954 | gpointer user_data) |
3955 | { |
3956 | Tab *tab = (Tab*)user_data; |
3957 | gint value = gtk_spin_button_get_value_as_int(spinbutton); |
3958 | LttTime new_current_time = tab->current_time; |
3959 | new_current_time.tv_nsec = value; |
3960 | |
3961 | current_time_change_manager(tab, new_current_time); |
3962 | } |
3963 | |
3964 | |
b052368a |
3965 | void scroll_value_changed_cb(GtkWidget *scrollbar, |
3966 | gpointer user_data) |
3967 | { |
3968 | Tab *tab = (Tab *)user_data; |
e800cf84 |
3969 | TimeWindow new_time_window; |
b052368a |
3970 | LttTime time; |
3971 | GtkAdjustment *adjust = gtk_range_get_adjustment(GTK_RANGE(scrollbar)); |
3972 | gdouble value = gtk_adjustment_get_value(adjust); |
e800cf84 |
3973 | // gdouble upper, lower, ratio, page_size; |
3974 | gdouble page_size; |
b052368a |
3975 | LttvTracesetContext * tsc = |
3976 | LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); |
b9a010a2 |
3977 | TimeInterval time_span = tsc->time_span; |
b052368a |
3978 | |
c74e0cf9 |
3979 | time = ltt_time_add(ltt_time_from_double(value), |
e800cf84 |
3980 | time_span.start_time); |
3981 | |
3982 | new_time_window.start_time = time; |
3983 | |
3984 | page_size = adjust->page_size; |
3985 | |
3986 | new_time_window.time_width = |
c74e0cf9 |
3987 | ltt_time_from_double(page_size); |
e800cf84 |
3988 | |
a18124ff |
3989 | new_time_window.time_width_double = |
3990 | page_size; |
3991 | |
6f26fc38 |
3992 | new_time_window.end_time = ltt_time_add(new_time_window.start_time, |
3993 | new_time_window.time_width); |
3994 | |
e800cf84 |
3995 | |
3996 | time_change_manager(tab, new_time_window); |
3997 | #if 0 |
b052368a |
3998 | //time_window = tab->time_window; |
3999 | |
b052368a |
4000 | lower = adjust->lower; |
4001 | upper = adjust->upper; |
4002 | ratio = (value - lower) / (upper - lower); |
2b5cc5a5 |
4003 | g_info("lower %lu, upper %lu, value %lu, ratio %lu", lower, upper, value, ratio); |
b052368a |
4004 | |
4005 | //time = ltt_time_sub(time_span->end_time, time_span->start_time); |
4006 | //time = ltt_time_mul(time, (float)ratio); |
4007 | //time = ltt_time_add(time_span->start_time, time); |
c74e0cf9 |
4008 | time = ltt_time_add(ltt_time_from_double(value), |
b9a010a2 |
4009 | time_span.start_time); |
b052368a |
4010 | |
4011 | time_window.start_time = time; |
4012 | |
4013 | page_size = adjust->page_size; |
4014 | |
4015 | time_window.time_width = |
c74e0cf9 |
4016 | ltt_time_from_double(page_size); |
b9a010a2 |
4017 | //time = ltt_time_sub(time_span.end_time, time); |
b052368a |
4018 | //if(ltt_time_compare(time,time_window.time_width) < 0){ |
4019 | // time_window.time_width = time; |
4020 | //} |
4021 | |
4022 | /* call viewer hooks for new time window */ |
4023 | set_time_window(tab, &time_window); |
e800cf84 |
4024 | #endif //0 |
b052368a |
4025 | } |
4026 | |
4027 | |
abe346a3 |
4028 | /* Display a dialogue showing all eventtypes and traces, let user to select the interested |
4029 | * eventtypes, tracefiles and traces (filter) |
4030 | */ |
4031 | |
abe346a3 |
4032 | /* Select a trace which will be removed from traceset |
4033 | */ |
4034 | |
93ac601b |
4035 | char * get_remove_trace(MainWindow *mw_data, |
4036 | char ** all_trace_name, int nb_trace) |
2176f952 |
4037 | { |
93ac601b |
4038 | return get_selection(mw_data, all_trace_name, nb_trace, |
2176f952 |
4039 | "Select a trace", "Trace pathname"); |
4040 | } |
abe346a3 |
4041 | |
4042 | |
b052368a |
4043 | /* Select a module which will be loaded |
4044 | */ |
4045 | |
93ac601b |
4046 | char * get_load_module(MainWindow *mw_data, |
4047 | char ** load_module_name, int nb_module) |
b052368a |
4048 | { |
93ac601b |
4049 | return get_selection(mw_data, load_module_name, nb_module, |
b052368a |
4050 | "Select a module to load", "Module name"); |
4051 | } |
4052 | |
4053 | |
4054 | |
4055 | |
abe346a3 |
4056 | /* Select a module which will be unloaded |
4057 | */ |
4058 | |
93ac601b |
4059 | char * get_unload_module(MainWindow *mw_data, |
4060 | char ** loaded_module_name, int nb_module) |
2176f952 |
4061 | { |
93ac601b |
4062 | return get_selection(mw_data, loaded_module_name, nb_module, |
b052368a |
4063 | "Select a module to unload", "Module name"); |
2176f952 |
4064 | } |
4065 | |
abe346a3 |
4066 | |
4067 | /* Display a dialogue which shows all selectable items, let user to |
4068 | * select one of them |
4069 | */ |
4070 | |
93ac601b |
4071 | char * get_selection(MainWindow *mw_data, |
4072 | char ** loaded_module_name, int nb_module, |
4073 | char *title, char * column_title) |
36b3c068 |
4074 | { |
4075 | GtkWidget * dialogue; |
4076 | GtkWidget * scroll_win; |
4077 | GtkWidget * tree; |
4078 | GtkListStore * store; |
4079 | GtkTreeViewColumn * column; |
4080 | GtkCellRenderer * renderer; |
4081 | GtkTreeSelection * select; |
4082 | GtkTreeIter iter; |
4083 | gint id, i; |
4084 | char * unload_module_name = NULL; |
4085 | |
2176f952 |
4086 | dialogue = gtk_dialog_new_with_buttons(title, |
36b3c068 |
4087 | NULL, |
4088 | GTK_DIALOG_MODAL, |
4089 | GTK_STOCK_OK,GTK_RESPONSE_ACCEPT, |
4090 | GTK_STOCK_CANCEL,GTK_RESPONSE_REJECT, |
4091 | NULL); |
4092 | gtk_window_set_default_size((GtkWindow*)dialogue, 500, 200); |
93ac601b |
4093 | gtk_window_set_transient_for(GTK_WINDOW(dialogue), |
4094 | GTK_WINDOW(mw_data->mwindow)); |
36b3c068 |
4095 | |
4096 | scroll_win = gtk_scrolled_window_new (NULL, NULL); |
4097 | gtk_widget_show ( scroll_win); |
4098 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win), |
4099 | GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
4100 | |
4101 | store = gtk_list_store_new (N_COLUMNS,G_TYPE_STRING); |
4102 | tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL (store)); |
4103 | gtk_widget_show ( tree); |
4104 | g_object_unref (G_OBJECT (store)); |
4105 | |
4106 | renderer = gtk_cell_renderer_text_new (); |
2176f952 |
4107 | column = gtk_tree_view_column_new_with_attributes (column_title, |
36b3c068 |
4108 | renderer, |
4109 | "text", MODULE_COLUMN, |
4110 | NULL); |
4111 | gtk_tree_view_column_set_alignment (column, 0.5); |
4112 | gtk_tree_view_column_set_fixed_width (column, 150); |
4113 | gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column); |
4114 | |
4115 | select = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree)); |
4116 | gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE); |
4117 | |
4118 | gtk_container_add (GTK_CONTAINER (scroll_win), tree); |
4119 | |
4120 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialogue)->vbox), scroll_win,TRUE, TRUE,0); |
4121 | |
4122 | for(i=0;i<nb_module;i++){ |
4123 | gtk_list_store_append (store, &iter); |
4124 | gtk_list_store_set (store, &iter, MODULE_COLUMN,loaded_module_name[i],-1); |
4125 | } |
4126 | |
4127 | id = gtk_dialog_run(GTK_DIALOG(dialogue)); |
d27948a3 |
4128 | GtkTreeModel **store_model = (GtkTreeModel**)&store; |
36b3c068 |
4129 | switch(id){ |
4130 | case GTK_RESPONSE_ACCEPT: |
4131 | case GTK_RESPONSE_OK: |
2eef04b5 |
4132 | if (gtk_tree_selection_get_selected (select, store_model, &iter)){ |
36b3c068 |
4133 | gtk_tree_model_get ((GtkTreeModel*)store, &iter, MODULE_COLUMN, &unload_module_name, -1); |
4134 | } |
4135 | case GTK_RESPONSE_REJECT: |
4136 | case GTK_RESPONSE_CANCEL: |
4137 | default: |
4138 | gtk_widget_destroy(dialogue); |
4139 | break; |
4140 | } |
4141 | |
4142 | return unload_module_name; |
4143 | } |
5723fa24 |
4144 | |
abe346a3 |
4145 | |
ef68c3ac |
4146 | /* Insert all menu entry and tool buttons into this main window |
001d8606 |
4147 | * for modules. |
4148 | * |
abe346a3 |
4149 | */ |
4150 | |
6c9d86dd |
4151 | void add_all_menu_toolbar_constructors(MainWindow * mw, gpointer user_data) |
5723fa24 |
4152 | { |
2eef04b5 |
4153 | guint i; |
5723fa24 |
4154 | GdkPixbuf *pixbuf; |
42fcbb71 |
4155 | lttvwindow_viewer_constructor constructor; |
001d8606 |
4156 | LttvMenus * global_menu, * instance_menu; |
4157 | LttvToolbars * global_toolbar, * instance_toolbar; |
6c9d86dd |
4158 | LttvMenuClosure *menu_item; |
4159 | LttvToolbarClosure *toolbar_item; |
5723fa24 |
4160 | LttvAttributeValue value; |
001d8606 |
4161 | LttvIAttribute *global_attributes = LTTV_IATTRIBUTE(lttv_global_attributes()); |
501e4e70 |
4162 | LttvIAttribute *attributes = mw->attributes; |
001d8606 |
4163 | GtkWidget * tool_menu_title_menu, *new_widget, *pixmap; |
4164 | |
4165 | g_assert(lttv_iattribute_find_by_path(global_attributes, |
4166 | "viewers/menu", LTTV_POINTER, &value)); |
4167 | if(*(value.v_pointer) == NULL) |
501e4e70 |
4168 | *(value.v_pointer) = lttv_menus_new(); |
001d8606 |
4169 | global_menu = (LttvMenus*)*(value.v_pointer); |
5723fa24 |
4170 | |
4171 | g_assert(lttv_iattribute_find_by_path(attributes, |
4172 | "viewers/menu", LTTV_POINTER, &value)); |
001d8606 |
4173 | if(*(value.v_pointer) == NULL) |
501e4e70 |
4174 | *(value.v_pointer) = lttv_menus_new(); |
001d8606 |
4175 | instance_menu = (LttvMenus*)*(value.v_pointer); |
5723fa24 |
4176 | |
001d8606 |
4177 | |
4178 | |
4179 | g_assert(lttv_iattribute_find_by_path(global_attributes, |
4180 | "viewers/toolbar", LTTV_POINTER, &value)); |
4181 | if(*(value.v_pointer) == NULL) |
501e4e70 |
4182 | *(value.v_pointer) = lttv_toolbars_new(); |
001d8606 |
4183 | global_toolbar = (LttvToolbars*)*(value.v_pointer); |
4184 | |
4185 | g_assert(lttv_iattribute_find_by_path(attributes, |
4186 | "viewers/toolbar", LTTV_POINTER, &value)); |
4187 | if(*(value.v_pointer) == NULL) |
501e4e70 |
4188 | *(value.v_pointer) = lttv_toolbars_new(); |
001d8606 |
4189 | instance_toolbar = (LttvToolbars*)*(value.v_pointer); |
4190 | |
4191 | /* Add missing menu entries to window instance */ |
4192 | for(i=0;i<global_menu->len;i++) { |
6c9d86dd |
4193 | menu_item = &g_array_index(global_menu, LttvMenuClosure, i); |
4194 | |
4195 | //add menu_item to window instance; |
4196 | constructor = menu_item->con; |
4197 | tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu"); |
4198 | new_widget = |
501e4e70 |
4199 | gtk_menu_item_new_with_mnemonic (menu_item->menu_text); |
6c9d86dd |
4200 | gtk_container_add (GTK_CONTAINER (tool_menu_title_menu), |
4201 | new_widget); |
4202 | g_signal_connect ((gpointer) new_widget, "activate", |
4203 | G_CALLBACK (insert_viewer_wrap), |
4204 | constructor); |
4205 | gtk_widget_show (new_widget); |
4206 | lttv_menus_add(instance_menu, menu_item->con, |
4207 | menu_item->menu_path, |
4208 | menu_item->menu_text, |
4209 | new_widget); |
001d8606 |
4210 | |
001d8606 |
4211 | } |
4212 | |
4213 | /* Add missing toolbar entries to window instance */ |
4214 | for(i=0;i<global_toolbar->len;i++) { |
6c9d86dd |
4215 | toolbar_item = &g_array_index(global_toolbar, LttvToolbarClosure, i); |
4216 | |
4217 | //add toolbar_item to window instance; |
4218 | constructor = toolbar_item->con; |
4219 | tool_menu_title_menu = lookup_widget(mw->mwindow,"MToolbar1"); |
4220 | pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)toolbar_item->pixmap); |
4221 | pixmap = gtk_image_new_from_pixbuf(pixbuf); |
4222 | new_widget = |
4223 | gtk_toolbar_append_element (GTK_TOOLBAR (tool_menu_title_menu), |
4224 | GTK_TOOLBAR_CHILD_BUTTON, |
4225 | NULL, |
4226 | "", |
4227 | toolbar_item->tooltip, NULL, |
4228 | pixmap, NULL, NULL); |
4229 | gtk_label_set_use_underline( |
4230 | GTK_LABEL (((GtkToolbarChild*) ( |
4231 | g_list_last (GTK_TOOLBAR |
4232 | (tool_menu_title_menu)->children)->data))->label), |
4233 | TRUE); |
4234 | gtk_container_set_border_width (GTK_CONTAINER (new_widget), 1); |
4235 | g_signal_connect ((gpointer) new_widget, |
4236 | "clicked", |
4237 | G_CALLBACK (insert_viewer_wrap), |
4238 | constructor); |
4239 | gtk_widget_show (new_widget); |
001d8606 |
4240 | |
6c9d86dd |
4241 | lttv_toolbars_add(instance_toolbar, toolbar_item->con, |
4242 | toolbar_item->tooltip, |
4243 | toolbar_item->pixmap, |
4244 | new_widget); |
001d8606 |
4245 | |
5723fa24 |
4246 | } |
6c9d86dd |
4247 | |
5723fa24 |
4248 | } |
4249 | |
abe346a3 |
4250 | |
4251 | /* Create a main window |
4252 | */ |
4253 | |
8321ae6a |
4254 | MainWindow *construct_main_window(MainWindow * parent) |
5723fa24 |
4255 | { |
2a2fa4f0 |
4256 | g_debug("construct_main_window()"); |
68b48a45 |
4257 | GtkWidget * new_window; /* New generated main window */ |
bca3b81f |
4258 | MainWindow * new_m_window;/* New main window structure */ |
5723fa24 |
4259 | GtkNotebook * notebook; |
f7afe191 |
4260 | LttvIAttribute *attributes = |
4261 | LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL)); |
4262 | LttvAttributeValue value; |
6ced96ef |
4263 | Tab *new_tab; |
2061e03d |
4264 | |
bca3b81f |
4265 | new_m_window = g_new(MainWindow, 1); |
5723fa24 |
4266 | |
4267 | // Add the object's information to the module's array |
68b48a45 |
4268 | g_main_window_list = g_slist_append(g_main_window_list, new_m_window); |
5723fa24 |
4269 | |
68b48a45 |
4270 | new_window = create_MWindow(); |
4271 | gtk_widget_show (new_window); |
5723fa24 |
4272 | |
bca3b81f |
4273 | new_m_window->mwindow = new_window; |
a43d67ba |
4274 | new_m_window->attributes = attributes; |
5723fa24 |
4275 | |
001d8606 |
4276 | g_assert(lttv_iattribute_find_by_path(attributes, |
4277 | "viewers/menu", LTTV_POINTER, &value)); |
501e4e70 |
4278 | *(value.v_pointer) = lttv_menus_new(); |
001d8606 |
4279 | |
501e4e70 |
4280 | g_assert(lttv_iattribute_find_by_path(attributes, |
001d8606 |
4281 | "viewers/toolbar", LTTV_POINTER, &value)); |
501e4e70 |
4282 | *(value.v_pointer) = lttv_toolbars_new(); |
2061e03d |
4283 | |
6c9d86dd |
4284 | add_all_menu_toolbar_constructors(new_m_window, NULL); |
5723fa24 |
4285 | |
2d262115 |
4286 | g_object_set_data_full(G_OBJECT(new_window), |
4287 | "main_window_data", |
4288 | (gpointer)new_m_window, |
4289 | (GDestroyNotify)g_free); |
5723fa24 |
4290 | //create a default tab |
bca3b81f |
4291 | notebook = (GtkNotebook *)lookup_widget(new_m_window->mwindow, "MNotebook"); |
5723fa24 |
4292 | if(notebook == NULL){ |
56e5a0f7 |
4293 | g_info("Notebook does not exist\n"); |
8321ae6a |
4294 | /* FIXME : destroy partially created widgets */ |
4295 | g_free(new_m_window); |
4296 | return NULL; |
5723fa24 |
4297 | } |
e800cf84 |
4298 | //gtk_notebook_popup_enable (GTK_NOTEBOOK(notebook)); |
5723fa24 |
4299 | //for now there is no name field in LttvTraceset structure |
4300 | //Use "Traceset" as the label for the default tab |
6ced96ef |
4301 | if(parent) { |
4302 | GtkWidget * parent_notebook = lookup_widget(parent->mwindow, "MNotebook"); |
4303 | GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(parent_notebook), |
4304 | gtk_notebook_get_current_page(GTK_NOTEBOOK(parent_notebook))); |
4305 | Tab *parent_tab; |
4306 | |
4307 | if(!page) { |
4308 | parent_tab = NULL; |
4309 | } else { |
e433e6d6 |
4310 | LttvPluginTab *ptab; |
4311 | ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin"); |
4312 | parent_tab = ptab->tab; |
6ced96ef |
4313 | } |
e433e6d6 |
4314 | LttvPluginTab *ptab = g_object_new(LTTV_TYPE_PLUGIN_TAB, NULL); |
4315 | init_tab(ptab->tab, |
4316 | new_m_window, parent_tab, notebook, "Traceset"); |
4317 | ptab->parent.top_widget = ptab->tab->top_widget; |
4318 | g_object_set_data_full( |
4319 | G_OBJECT(ptab->tab->vbox), |
4320 | "Tab_Plugin", |
4321 | ptab, |
4322 | (GDestroyNotify)tab_destructor); |
4323 | new_tab = ptab->tab; |
6ced96ef |
4324 | } else { |
e433e6d6 |
4325 | LttvPluginTab *ptab = g_object_new(LTTV_TYPE_PLUGIN_TAB, NULL); |
4326 | init_tab(ptab->tab, new_m_window, NULL, notebook, "Traceset"); |
4327 | ptab->parent.top_widget = ptab->tab->top_widget; |
4328 | g_object_set_data_full( |
4329 | G_OBJECT(ptab->tab->vbox), |
4330 | "Tab_Plugin", |
4331 | ptab, |
4332 | (GDestroyNotify)tab_destructor); |
4333 | new_tab = ptab->tab; |
6cec4cd2 |
4334 | } |
91fd6881 |
4335 | |
6cec4cd2 |
4336 | /* Insert default viewers */ |
4337 | { |
4338 | LttvAttributeType type; |
4339 | LttvAttributeName name; |
4340 | LttvAttributeValue value; |
4341 | LttvAttribute *attribute; |
4342 | |
4343 | LttvIAttribute *attributes_global = |
4344 | LTTV_IATTRIBUTE(lttv_global_attributes()); |
4345 | |
4346 | g_assert(attribute = |
4347 | LTTV_ATTRIBUTE(lttv_iattribute_find_subdir( |
4348 | LTTV_IATTRIBUTE(attributes_global), |
4349 | LTTV_VIEWER_CONSTRUCTORS))); |
4350 | |
4351 | name = g_quark_from_string("guievents"); |
4352 | type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute), |
4353 | name, &value); |
4354 | if(type == LTTV_POINTER) { |
4355 | lttvwindow_viewer_constructor viewer_constructor = |
4356 | (lttvwindow_viewer_constructor)*value.v_pointer; |
4357 | insert_viewer(new_window, viewer_constructor); |
4266dc7f |
4358 | } |
e025a729 |
4359 | |
6cec4cd2 |
4360 | name = g_quark_from_string("guicontrolflow"); |
4361 | type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute), |
4362 | name, &value); |
4363 | if(type == LTTV_POINTER) { |
4364 | lttvwindow_viewer_constructor viewer_constructor = |
4365 | (lttvwindow_viewer_constructor)*value.v_pointer; |
4366 | insert_viewer(new_window, viewer_constructor); |
4367 | } |
e025a729 |
4368 | |
6cec4cd2 |
4369 | name = g_quark_from_string("guistatistics"); |
4370 | type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute), |
4371 | name, &value); |
4372 | if(type == LTTV_POINTER) { |
4373 | lttvwindow_viewer_constructor viewer_constructor = |
4374 | (lttvwindow_viewer_constructor)*value.v_pointer; |
4375 | insert_viewer(new_window, viewer_constructor); |
e025a729 |
4376 | } |
4266dc7f |
4377 | } |
5723fa24 |
4378 | |
56e5a0f7 |
4379 | g_info("There are now : %d windows\n",g_slist_length(g_main_window_list)); |
8321ae6a |
4380 | |
4381 | return new_m_window; |
5723fa24 |
4382 | } |
4383 | |
abe346a3 |
4384 | |
4385 | /* Free the memory occupied by a tab structure |
4386 | * destroy the tab |
4387 | */ |
4388 | |
e433e6d6 |
4389 | void tab_destructor(LttvPluginTab * ptab) |
f7afe191 |
4390 | { |
716e4367 |
4391 | int i, nb, ref_count; |
4392 | LttvTrace * trace; |
e433e6d6 |
4393 | Tab *tab = ptab->tab; |
716e4367 |
4394 | |
6ebb6ad0 |
4395 | gtk_object_destroy(GTK_OBJECT(tab->tooltips)); |
3234f094 |
4396 | |
4397 | if(tab->attributes) |
4398 | g_object_unref(tab->attributes); |
501e4e70 |
4399 | |
3234f094 |
4400 | if(tab->interrupted_state) |
4401 | g_object_unref(tab->interrupted_state); |
501e4e70 |
4402 | |
2061e03d |
4403 | |
3234f094 |
4404 | if(tab->traceset_info->traceset_context != NULL){ |
784705cc |
4405 | //remove state update hooks |
4406 | lttv_state_remove_event_hooks( |
3234f094 |
4407 | (LttvTracesetState*)tab->traceset_info-> |
784705cc |
4408 | traceset_context); |
3234f094 |
4409 | lttv_context_fini(LTTV_TRACESET_CONTEXT(tab->traceset_info-> |
716e4367 |
4410 | traceset_context)); |
3234f094 |
4411 | g_object_unref(tab->traceset_info->traceset_context); |
716e4367 |
4412 | } |
3234f094 |
4413 | if(tab->traceset_info->traceset != NULL) { |
4414 | nb = lttv_traceset_number(tab->traceset_info->traceset); |
716e4367 |
4415 | for(i = 0 ; i < nb ; i++) { |
3234f094 |
4416 | trace = lttv_traceset_get(tab->traceset_info->traceset, i); |
716e4367 |
4417 | ref_count = lttv_trace_get_ref_number(trace); |
49bf71b5 |
4418 | if(ref_count <= 1){ |
a1a2b649 |
4419 | ltt_trace_close(lttv_trace(trace)); |
49bf71b5 |
4420 | } |
716e4367 |
4421 | } |
dc5e5266 |
4422 | } |
3234f094 |
4423 | lttv_traceset_destroy(tab->traceset_info->traceset); |
501e4e70 |
4424 | /* Remove the idle events requests processing function of the tab */ |
3234f094 |
4425 | g_idle_remove_by_data(tab); |
501e4e70 |
4426 | |
3234f094 |
4427 | g_slist_free(tab->events_requests); |
4428 | g_free(tab->traceset_info); |
e433e6d6 |
4429 | //g_free(tab); |
4430 | g_object_unref(ptab); |
f7afe191 |
4431 | } |
4432 | |
abe346a3 |
4433 | |
4434 | /* Create a tab and insert it into the current main window |
4435 | */ |
4436 | |
e433e6d6 |
4437 | void init_tab(Tab *tab, MainWindow * mw, Tab *copy_tab, |
716e4367 |
4438 | GtkNotebook * notebook, char * label) |
5723fa24 |
4439 | { |
4440 | GList * list; |
e433e6d6 |
4441 | //Tab * tab; |
4442 | //LttvFilter *filter = NULL; |
a43d67ba |
4443 | |
abe346a3 |
4444 | //create a new tab data structure |
e433e6d6 |
4445 | //tab = g_new(Tab,1); |
716e4367 |
4446 | |
abe346a3 |
4447 | //construct and initialize the traceset_info |
6ced96ef |
4448 | tab->traceset_info = g_new(TracesetInfo,1); |
a43d67ba |
4449 | |
4266dc7f |
4450 | if(copy_tab) { |
6ced96ef |
4451 | tab->traceset_info->traceset = |
4266dc7f |
4452 | lttv_traceset_copy(copy_tab->traceset_info->traceset); |
dc5e5266 |
4453 | |
4454 | /* Copy the previous tab's filter */ |
4455 | /* We can clone the filter, as we copy the trace set also */ |
4456 | /* The filter must always be in sync with the trace set */ |
ebcead4a |
4457 | tab->filter = lttv_filter_clone(copy_tab->filter); |
4266dc7f |
4458 | } else { |
6ced96ef |
4459 | tab->traceset_info->traceset = lttv_traceset_new(); |
dc5e5266 |
4460 | tab->filter = NULL; |
716e4367 |
4461 | } |
84ddf5c9 |
4462 | #ifdef DEBUG |
20fde85f |
4463 | lttv_attribute_write_xml( |
6ced96ef |
4464 | lttv_traceset_attribute(tab->traceset_info->traceset), |
20fde85f |
4465 | stdout, |
4466 | 0, 4); |
4467 | fflush(stdout); |
84ddf5c9 |
4468 | #endif //DEBUG |
20fde85f |
4469 | |
e800cf84 |
4470 | tab->time_manager_lock = FALSE; |
4471 | tab->current_time_manager_lock = FALSE; |
20fde85f |
4472 | |
716e4367 |
4473 | //FIXME copy not implemented in lower level |
6ced96ef |
4474 | tab->traceset_info->traceset_context = |
716e4367 |
4475 | g_object_new(LTTV_TRACESET_STATS_TYPE, NULL); |
6ced96ef |
4476 | g_assert(tab->traceset_info->traceset_context != NULL); |
716e4367 |
4477 | lttv_context_init( |
6ced96ef |
4478 | LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context), |
4479 | tab->traceset_info->traceset); |
784705cc |
4480 | //add state update hooks |
4481 | lttv_state_add_event_hooks( |
6ced96ef |
4482 | (LttvTracesetState*)tab->traceset_info->traceset_context); |
784705cc |
4483 | |
abe346a3 |
4484 | //determine the current_time and time_window of the tab |
e800cf84 |
4485 | #if 0 |
6ced96ef |
4486 | if(copy_tab != NULL){ |
4487 | tab->time_window = copy_tab->time_window; |
4488 | tab->current_time = copy_tab->current_time; |
5723fa24 |
4489 | }else{ |
6ced96ef |
4490 | tab->time_window.start_time = |
4491 | LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)-> |
4492 | time_span.start_time; |
f7afe191 |
4493 | if(DEFAULT_TIME_WIDTH_S < |
6ced96ef |
4494 | LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)-> |
4495 | time_span.end_time.tv_sec) |
68b48a45 |
4496 | tmp_time.tv_sec = DEFAULT_TIME_WIDTH_S; |
f7afe191 |
4497 | else |
68b48a45 |
4498 | tmp_time.tv_sec = |
6ced96ef |
4499 | LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)-> |
4500 | time_span.end_time.tv_sec; |
68b48a45 |
4501 | tmp_time.tv_nsec = 0; |
6ced96ef |
4502 | tab->time_window.time_width = tmp_time ; |
4503 | tab->current_time.tv_sec = |
4504 | LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)-> |
4505 | time_span.start_time.tv_sec; |
4506 | tab->current_time.tv_nsec = |
4507 | LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)-> |
4508 | time_span.start_time.tv_nsec; |
5723fa24 |
4509 | } |
e800cf84 |
4510 | #endif //0 |
6ced96ef |
4511 | tab->attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL)); |
4512 | tab->interrupted_state = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL); |
b052368a |
4513 | |
58f6c2a4 |
4514 | tab->vbox = gtk_vbox_new(FALSE, 2); |
e433e6d6 |
4515 | tab->top_widget = tab->vbox; |
4516 | //g_object_set_data_full(G_OBJECT(tab->top_widget), "filter", |
4517 | // filter, (GDestroyNotify)lttv_filter_destroy); |
4518 | |
4519 | // g_signal_connect (G_OBJECT(tab->top_widget), |
4520 | // "notify", |
4521 | // G_CALLBACK (on_top_notify), |
4522 | // (gpointer)tab); |
4523 | |
58f6c2a4 |
4524 | tab->viewer_container = gtk_vbox_new(TRUE, 2); |
b052368a |
4525 | tab->scrollbar = gtk_hscrollbar_new(NULL); |
4526 | //tab->multivpaned = gtk_multi_vpaned_new(); |
6c35c853 |
4527 | |
b052368a |
4528 | gtk_box_pack_start(GTK_BOX(tab->vbox), |
4529 | tab->viewer_container, |
4530 | TRUE, /* expand */ |
4531 | TRUE, /* Give the extra space to the child */ |
4532 | 0); /* No padding */ |
4249a3e8 |
4533 | |
4534 | // if(copy_tab) { |
4535 | // tab->time_window = copy_tab->time_window; |
4536 | // tab->current_time = copy_tab->current_time; |
4537 | // } |
e800cf84 |
4538 | |
4539 | /* Create the timebar */ |
4540 | { |
4541 | tab->MTimebar = gtk_hbox_new(FALSE, 2); |
4542 | gtk_widget_show(tab->MTimebar); |
3234f094 |
4543 | tab->tooltips = gtk_tooltips_new(); |
f02b5e22 |
4544 | |
4545 | tab->MEventBox1a = gtk_event_box_new(); |
4546 | gtk_widget_show(tab->MEventBox1a); |
3234f094 |
4547 | gtk_tooltips_set_tip(tab->tooltips, tab->MEventBox1a, |
f02b5e22 |
4548 | "Paste Start and End Times Here", ""); |
4549 | tab->MText1a = gtk_label_new("Time Frame "); |
4550 | gtk_widget_show(tab->MText1a); |
4551 | gtk_container_add(GTK_CONTAINER(tab->MEventBox1a), tab->MText1a); |
4552 | tab->MEventBox1b = gtk_event_box_new(); |
4553 | gtk_widget_show(tab->MEventBox1b); |
3234f094 |
4554 | gtk_tooltips_set_tip(tab->tooltips, tab->MEventBox1b, |
f02b5e22 |
4555 | "Paste Start Time Here", ""); |
4556 | tab->MText1b = gtk_label_new("start: "); |
4557 | gtk_widget_show(tab->MText1b); |
4558 | gtk_container_add(GTK_CONTAINER(tab->MEventBox1b), tab->MText1b); |
e800cf84 |
4559 | tab->MText2 = gtk_label_new("s"); |
4560 | gtk_widget_show(tab->MText2); |
4561 | tab->MText3a = gtk_label_new("ns"); |
4562 | gtk_widget_show(tab->MText3a); |
58de9fc1 |
4563 | |
f02b5e22 |
4564 | tab->MEventBox3b = gtk_event_box_new(); |
4565 | gtk_widget_show(tab->MEventBox3b); |
3234f094 |
4566 | gtk_tooltips_set_tip(tab->tooltips, tab->MEventBox3b, |
f02b5e22 |
4567 | "Paste End Time Here", ""); |
e800cf84 |
4568 | tab->MText3b = gtk_label_new("end:"); |
4569 | gtk_widget_show(tab->MText3b); |
f02b5e22 |
4570 | gtk_container_add(GTK_CONTAINER(tab->MEventBox3b), tab->MText3b); |
e800cf84 |
4571 | tab->MText4 = gtk_label_new("s"); |
4572 | gtk_widget_show(tab->MText4); |
4573 | tab->MText5a = gtk_label_new("ns"); |
4574 | gtk_widget_show(tab->MText5a); |
58de9fc1 |
4575 | |
4576 | tab->MEventBox8 = gtk_event_box_new(); |
4577 | gtk_widget_show(tab->MEventBox8); |
4578 | gtk_tooltips_set_tip(tab->tooltips, tab->MEventBox8, |
4579 | "Paste Time Interval here", ""); |
4580 | tab->MText8 = gtk_label_new("Time Interval:"); |
4581 | gtk_widget_show(tab->MText8); |
4582 | gtk_container_add(GTK_CONTAINER(tab->MEventBox8), tab->MText8); |
4583 | tab->MText9 = gtk_label_new("s"); |
4584 | gtk_widget_show(tab->MText9); |
4585 | tab->MText10 = gtk_label_new("ns"); |
4586 | gtk_widget_show(tab->MText10); |
4587 | |
f02b5e22 |
4588 | tab->MEventBox5b = gtk_event_box_new(); |
4589 | gtk_widget_show(tab->MEventBox5b); |
3234f094 |
4590 | gtk_tooltips_set_tip(tab->tooltips, tab->MEventBox5b, |
f02b5e22 |
4591 | "Paste Current Time Here", ""); |
e800cf84 |
4592 | tab->MText5b = gtk_label_new("Current Time:"); |
4593 | gtk_widget_show(tab->MText5b); |
f02b5e22 |
4594 | gtk_container_add(GTK_CONTAINER(tab->MEventBox5b), tab->MText5b); |
e800cf84 |
4595 | tab->MText6 = gtk_label_new("s"); |
4596 | gtk_widget_show(tab->MText6); |
4597 | tab->MText7 = gtk_label_new("ns"); |
4598 | gtk_widget_show(tab->MText7); |
4599 | |
4600 | tab->MEntry1 = gtk_spin_button_new_with_range(0.0, 1.0, 1.0); |
4601 | gtk_spin_button_set_digits(GTK_SPIN_BUTTON(tab->MEntry1),0); |
4602 | gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(tab->MEntry1),TRUE); |
4603 | gtk_widget_show(tab->MEntry1); |
4604 | tab->MEntry2 = gtk_spin_button_new_with_range(0.0, 1.0, 1.0); |
4605 | gtk_spin_button_set_digits(GTK_SPIN_BUTTON(tab->MEntry2),0); |
4606 | gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(tab->MEntry2),TRUE); |
4607 | gtk_widget_show(tab->MEntry2); |
4608 | tab->MEntry3 = gtk_spin_button_new_with_range(0.0, 1.0, 1.0); |
4609 | gtk_spin_button_set_digits(GTK_SPIN_BUTTON(tab->MEntry3),0); |
4610 | gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(tab->MEntry3),TRUE); |
4611 | gtk_widget_show(tab->MEntry3); |
4612 | tab->MEntry4 = gtk_spin_button_new_with_range(0.0, 1.0, 1.0); |
4613 | gtk_spin_button_set_digits(GTK_SPIN_BUTTON(tab->MEntry4),0); |
4614 | gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(tab->MEntry4),TRUE); |
4615 | gtk_widget_show(tab->MEntry4); |
4616 | tab->MEntry5 = gtk_spin_button_new_with_range(0.0, 1.0, 1.0); |
4617 | gtk_spin_button_set_digits(GTK_SPIN_BUTTON(tab->MEntry5),0); |
4618 | gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(tab->MEntry5),TRUE); |
4619 | gtk_widget_show(tab->MEntry5); |
4620 | tab->MEntry6 = gtk_spin_button_new_with_range(0.0, 1.0, 1.0); |
4621 | gtk_spin_button_set_digits(GTK_SPIN_BUTTON(tab->MEntry6),0); |
4622 | gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(tab->MEntry6),TRUE); |
4623 | gtk_widget_show(tab->MEntry6); |
58de9fc1 |
4624 | tab->MEntry7 = gtk_spin_button_new_with_range(0.0, 1.0, 1.0); |
4625 | gtk_spin_button_set_digits(GTK_SPIN_BUTTON(tab->MEntry7),0); |
4626 | gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(tab->MEntry7),TRUE); |
4627 | gtk_widget_show(tab->MEntry7); |
4628 | tab->MEntry8 = gtk_spin_button_new_with_range(0.0, 1.0, 1.0); |
4629 | gtk_spin_button_set_digits(GTK_SPIN_BUTTON(tab->MEntry8),0); |
4630 | gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(tab->MEntry8),TRUE); |
4631 | gtk_widget_show(tab->MEntry8); |
e800cf84 |
4632 | |
4633 | GtkWidget *temp_widget; |
4634 | |
f02b5e22 |
4635 | gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MEventBox1a, FALSE, |
4636 | FALSE, 0); |
4637 | gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MEventBox1b, FALSE, |
4638 | FALSE, 0); |
e800cf84 |
4639 | gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MEntry1, FALSE, FALSE, 0); |
4640 | gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MText2, FALSE, FALSE, 0); |
4641 | gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MEntry2, FALSE, FALSE, 0); |
4642 | gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MText3a, FALSE, FALSE, 0); |
4643 | temp_widget = gtk_vseparator_new(); |
4644 | gtk_widget_show(temp_widget); |
4645 | gtk_box_pack_start (GTK_BOX (tab->MTimebar), temp_widget, FALSE, FALSE, 0); |
f02b5e22 |
4646 | gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MEventBox3b, FALSE, |
4647 | FALSE, 0); |
e800cf84 |
4648 | gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MEntry3, FALSE, FALSE, 0); |
4649 | gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MText4, FALSE, FALSE, 0); |
4650 | gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MEntry4, FALSE, FALSE, 0); |
4651 | gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MText5a, FALSE, FALSE, 0); |
bb1d9440 |
4652 | temp_widget = gtk_vseparator_new(); |
4653 | gtk_widget_show(temp_widget); |
c75dd04e |
4654 | gtk_box_pack_start (GTK_BOX (tab->MTimebar), temp_widget, FALSE, FALSE, 0); |
58de9fc1 |
4655 | gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MEventBox8, FALSE, |
4656 | FALSE, 0); |
4657 | gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MEntry7, FALSE, FALSE, 0); |
4658 | gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MText9, FALSE, FALSE, 0); |
4659 | gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MEntry8, FALSE, FALSE, 0); |
4660 | gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MText10, FALSE, FALSE, 0); |
4661 | |
e800cf84 |
4662 | temp_widget = gtk_vseparator_new(); |
4663 | gtk_widget_show(temp_widget); |
4664 | gtk_box_pack_end (GTK_BOX (tab->MTimebar), tab->MText7, FALSE, FALSE, 0); |
4665 | gtk_box_pack_end (GTK_BOX (tab->MTimebar), tab->MEntry6, FALSE, FALSE, 0); |
4666 | gtk_box_pack_end (GTK_BOX (tab->MTimebar), tab->MText6, FALSE, FALSE, 0); |
4667 | gtk_box_pack_end (GTK_BOX (tab->MTimebar), tab->MEntry5, FALSE, FALSE, 0); |
f02b5e22 |
4668 | gtk_box_pack_end (GTK_BOX (tab->MTimebar), tab->MEventBox5b, FALSE, |
4669 | FALSE, 0); |
e800cf84 |
4670 | gtk_box_pack_end (GTK_BOX (tab->MTimebar), temp_widget, FALSE, FALSE, 0); |
f02b5e22 |
4671 | |
4672 | |
4673 | //GtkWidget *test = gtk_button_new_with_label("drop"); |
4674 | //gtk_button_set_relief(GTK_BUTTON(test), GTK_RELIEF_NONE); |
4675 | //gtk_widget_show(test); |
4676 | //gtk_box_pack_end(GTK_BOX (tab->MTimebar), test, FALSE, FALSE, 0); |
4677 | //gtk_widget_add_events(tab->MText1, GDK_ALL_EVENTS_MASK);//GDK_BUTTON_PRESS_MASK); |
4678 | /*GtkWidget *event_box = gtk_event_box_new(); |
4679 | gtk_widget_show(event_box); |
4680 | gtk_tooltips_set_tip(tooltips, event_box, |
4681 | "Paste Current Time Here", ""); |
4682 | gtk_box_pack_end(GTK_BOX (tab->MTimebar), event_box, FALSE, FALSE, 0); |
4683 | GtkWidget *test = gtk_label_new("drop"); |
4684 | gtk_container_add(GTK_CONTAINER(event_box), test); |
4685 | gtk_widget_show(test); |
4686 | g_signal_connect (G_OBJECT(event_box), |
4687 | "button-press-event", |
4688 | G_CALLBACK (on_MText1_paste), |
4689 | (gpointer)tab); |
4690 | */ |
4691 | |
4692 | g_signal_connect (G_OBJECT(tab->MEventBox1a), |
4693 | "button-press-event", |
4694 | G_CALLBACK (on_MEventBox1a_paste), |
4695 | (gpointer)tab); |
4696 | |
4697 | g_signal_connect (G_OBJECT(tab->MEventBox1b), |
4698 | "button-press-event", |
4699 | G_CALLBACK (on_MEventBox1b_paste), |
4700 | (gpointer)tab); |
4701 | g_signal_connect (G_OBJECT(tab->MEventBox3b), |
4702 | "button-press-event", |
4703 | G_CALLBACK (on_MEventBox3b_paste), |
4704 | (gpointer)tab); |
4705 | g_signal_connect (G_OBJECT(tab->MEventBox5b), |
4706 | "button-press-event", |
4707 | G_CALLBACK (on_MEventBox5b_paste), |
4708 | (gpointer)tab); |
58de9fc1 |
4709 | g_signal_connect (G_OBJECT(tab->MEventBox8), |
4710 | "button-press-event", |
4711 | G_CALLBACK (on_MEventBox8_paste), |
4712 | (gpointer)tab); |
e800cf84 |
4713 | } |
4714 | |
b052368a |
4715 | gtk_box_pack_end(GTK_BOX(tab->vbox), |
4716 | tab->scrollbar, |
4717 | FALSE, /* Do not expand */ |
4718 | FALSE, /* Fill has no effect here (expand false) */ |
4719 | 0); /* No padding */ |
e800cf84 |
4720 | |
4721 | gtk_box_pack_end(GTK_BOX(tab->vbox), |
4722 | tab->MTimebar, |
4723 | FALSE, /* Do not expand */ |
4724 | FALSE, /* Fill has no effect here (expand false) */ |
4725 | 0); /* No padding */ |
4726 | |
b052368a |
4727 | g_object_set_data(G_OBJECT(tab->viewer_container), "focused_viewer", NULL); |
4728 | |
4729 | |
6ced96ef |
4730 | tab->mw = mw; |
27a559b9 |
4731 | |
3c031040 |
4732 | /*{ |
4733 | // Display a label with a X |
27a559b9 |
4734 | GtkWidget *w_hbox = gtk_hbox_new(FALSE, 4); |
4735 | GtkWidget *w_label = gtk_label_new (label); |
4736 | GtkWidget *pixmap = create_pixmap(GTK_WIDGET(notebook), "close.png"); |
4737 | GtkWidget *w_button = gtk_button_new (); |
4738 | gtk_container_add(GTK_CONTAINER(w_button), pixmap); |
4739 | //GtkWidget *w_button = gtk_button_new_with_label("x"); |
4740 | |
4741 | gtk_button_set_relief(GTK_BUTTON(w_button), GTK_RELIEF_NONE); |
4742 | |
4743 | gtk_box_pack_start(GTK_BOX(w_hbox), w_label, TRUE, TRUE, 0); |
4744 | gtk_box_pack_end(GTK_BOX(w_hbox), w_button, FALSE, |
4745 | FALSE, 0); |
a43d67ba |
4746 | |
27a559b9 |
4747 | g_signal_connect_swapped (w_button, "clicked", |
4748 | G_CALLBACK (on_close_tab_X_clicked), |
4749 | tab->multi_vpaned); |
5723fa24 |
4750 | |
3c031040 |
4751 | gtk_widget_set_state(w_button, GTK_STATE_ACTIVE); |
4752 | |
27a559b9 |
4753 | gtk_widget_show (w_label); |
4754 | gtk_widget_show (pixmap); |
4755 | gtk_widget_show (w_button); |
4756 | gtk_widget_show (w_hbox); |
4757 | |
4758 | tab->label = w_hbox; |
3c031040 |
4759 | }*/ |
4760 | |
4761 | |
4762 | tab->label = gtk_label_new (label); |
b052368a |
4763 | |
4764 | gtk_widget_show(tab->label); |
4765 | gtk_widget_show(tab->scrollbar); |
4766 | gtk_widget_show(tab->viewer_container); |
4767 | gtk_widget_show(tab->vbox); |
4768 | //gtk_widget_show(tab->multivpaned); |
3c031040 |
4769 | |
4770 | |
501e4e70 |
4771 | /* Start with empty events requests list */ |
6ced96ef |
4772 | tab->events_requests = NULL; |
4773 | tab->events_request_pending = FALSE; |
a43d67ba |
4774 | |
540edb40 |
4775 | |
b052368a |
4776 | g_signal_connect(G_OBJECT(tab->scrollbar), "value-changed", |
4777 | G_CALLBACK(scroll_value_changed_cb), tab); |
e800cf84 |
4778 | |
4779 | g_signal_connect ((gpointer) tab->MEntry1, "value-changed", |
4780 | G_CALLBACK (on_MEntry1_value_changed), |
4781 | tab); |
4782 | g_signal_connect ((gpointer) tab->MEntry2, "value-changed", |
4783 | G_CALLBACK (on_MEntry2_value_changed), |
4784 | tab); |
4785 | g_signal_connect ((gpointer) tab->MEntry3, "value-changed", |
4786 | G_CALLBACK (on_MEntry3_value_changed), |
4787 | tab); |
4788 | g_signal_connect ((gpointer) tab->MEntry4, "value-changed", |
4789 | G_CALLBACK (on_MEntry4_value_changed), |
4790 | tab); |
4791 | g_signal_connect ((gpointer) tab->MEntry5, "value-changed", |
4792 | G_CALLBACK (on_MEntry5_value_changed), |
4793 | tab); |
4794 | g_signal_connect ((gpointer) tab->MEntry6, "value-changed", |
4795 | G_CALLBACK (on_MEntry6_value_changed), |
58de9fc1 |
4796 | tab); |
4797 | g_signal_connect ((gpointer) tab->MEntry7, "value-changed", |
4798 | G_CALLBACK (on_MEntry7_value_changed), |
4799 | tab); |
4800 | g_signal_connect ((gpointer) tab->MEntry8, "value-changed", |
4801 | G_CALLBACK (on_MEntry8_value_changed), |
e800cf84 |
4802 | tab); |
4803 | |
b052368a |
4804 | //g_signal_connect(G_OBJECT(tab->scrollbar), "changed", |
4805 | // G_CALLBACK(scroll_value_changed_cb), tab); |
4806 | |
4807 | |
784705cc |
4808 | //insert tab into notebook |
6ced96ef |
4809 | gtk_notebook_append_page(notebook, |
b052368a |
4810 | tab->vbox, |
4811 | tab->label); |
5723fa24 |
4812 | list = gtk_container_get_children(GTK_CONTAINER(notebook)); |
4813 | gtk_notebook_set_current_page(notebook,g_list_length(list)-1); |
a43d67ba |
4814 | // always show : not if(g_list_length(list)>1) |
4815 | gtk_notebook_set_show_tabs(notebook, TRUE); |
4816 | |
4249a3e8 |
4817 | if(copy_tab) { |
4818 | lttvwindow_report_time_window(tab, copy_tab->time_window); |
4819 | lttvwindow_report_current_time(tab, copy_tab->current_time); |
4820 | } else { |
4821 | TimeWindow time_window; |
4822 | |
4823 | time_window.start_time = ltt_time_zero; |
4824 | time_window.end_time = ltt_time_add(time_window.start_time, |
4825 | lttvwindow_default_time_width); |
4826 | time_window.time_width = lttvwindow_default_time_width; |
4827 | time_window.time_width_double = ltt_time_to_double(time_window.time_width); |
4828 | |
4829 | lttvwindow_report_time_window(tab, time_window); |
4830 | lttvwindow_report_current_time(tab, ltt_time_zero); |
4831 | } |
4832 | |
4833 | LttvTraceset *traceset = tab->traceset_info->traceset; |
4834 | SetTraceset(tab, traceset); |
a43d67ba |
4835 | } |
4836 | |
501e4e70 |
4837 | /* |
4838 | * execute_events_requests |
4839 | * |
4840 | * Idle function that executes the pending requests for a tab. |
4841 | * |
4842 | * @return return value : TRUE : keep the idle function, FALSE : remove it. |
4843 | */ |
4844 | gboolean execute_events_requests(Tab *tab) |
a43d67ba |
4845 | { |
501e4e70 |
4846 | return ( lttvwindow_process_pending_requests(tab) ); |
a43d67ba |
4847 | } |
4848 | |
8321ae6a |
4849 | |
8e3a7c75 |
4850 | void create_main_window_with_trace_list(GSList *traces) |
8321ae6a |
4851 | { |
8e3a7c75 |
4852 | GSList *iter = NULL; |
8321ae6a |
4853 | |
4854 | /* Create window */ |
4855 | MainWindow *mw = construct_main_window(NULL); |
4856 | GtkWidget *widget = mw->mwindow; |
4857 | |
4858 | GtkWidget * notebook = lookup_widget(widget, "MNotebook"); |
4859 | GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), |
4860 | gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook))); |
e433e6d6 |
4861 | LttvPluginTab *ptab; |
8321ae6a |
4862 | Tab *tab; |
4863 | |
4864 | if(!page) { |
e433e6d6 |
4865 | ptab = create_new_tab(widget, NULL); |
4866 | tab = ptab->tab; |
8321ae6a |
4867 | } else { |
e433e6d6 |
4868 | ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin"); |
4869 | tab = ptab->tab; |
8321ae6a |
4870 | } |
4871 | |
8e3a7c75 |
4872 | for(iter=traces; iter!=NULL; iter=g_slist_next(iter)) { |
4873 | gchar *path = (gchar*)iter->data; |
4874 | /* Add trace */ |
4875 | gchar abs_path[PATH_MAX]; |
4876 | LttvTrace *trace_v; |
4877 | LttTrace *trace; |
4878 | |
4879 | get_absolute_pathname(path, abs_path); |
4880 | trace_v = lttvwindowtraces_get_trace_by_name(abs_path); |
4881 | if(trace_v == NULL) { |
4882 | trace = ltt_trace_open(abs_path); |
4883 | if(trace == NULL) { |
4884 | g_warning("cannot open trace %s", abs_path); |
4885 | |
4886 | GtkWidget *dialogue = |
4887 | gtk_message_dialog_new( |
4888 | GTK_WINDOW(gtk_widget_get_toplevel(widget)), |
4889 | GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, |
4890 | GTK_MESSAGE_ERROR, |
4891 | GTK_BUTTONS_OK, |
4892 | "Cannot open trace : maybe you should enter in the directory" |
4893 | "to select it ?"); |
4894 | gtk_dialog_run(GTK_DIALOG(dialogue)); |
4895 | gtk_widget_destroy(dialogue); |
4896 | } else { |
4897 | trace_v = lttv_trace_new(trace); |
4898 | lttvwindowtraces_add_trace(trace_v); |
4899 | lttvwindow_add_trace(tab, trace_v); |
4900 | } |
8321ae6a |
4901 | } else { |
8321ae6a |
4902 | lttvwindow_add_trace(tab, trace_v); |
4903 | } |
8321ae6a |
4904 | } |
8e3a7c75 |
4905 | |
8321ae6a |
4906 | LttvTraceset *traceset; |
4907 | |
4908 | traceset = tab->traceset_info->traceset; |
4909 | SetTraceset(tab, traceset); |
4910 | } |
4911 | |