main window with default tab
[lttv.git] / ltt / branches / poly / lttv / modules / gui / mainWin / src / callbacks.c
CommitLineData
561eba2a 1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <gtk/gtk.h>
6#include <gmodule.h>
7
8#include "callbacks.h"
9#include "interface.h"
10#include "support.h"
95cd67ef 11#include <lttv/mainWindow.h>
37d0eca6 12#include <lttv/menu.h>
13#include <lttv/toolbar.h>
58960b51 14#include <lttv/gtkTraceSet.h>
6b1d3120 15#include <lttv/module.h>
fc188b78 16#include <lttv/gtkdirsel.h>
6b1d3120 17
18#define PATH_LENGTH 256
561eba2a 19
ec25ff5e 20extern LttvTracesetContext * gTracesetContext;
21
22/** Array containing instanced objects. */
23extern GSList * Main_Window_List;
561eba2a 24
561eba2a 25mainWindow * get_window_data_struct(GtkWidget * widget);
36b3c068 26char * get_unload_module(char ** loaded_module_name, int nb_module);
5723fa24 27void * create_tab(GtkWidget* parent, GtkNotebook * notebook, char * label);
561eba2a 28
29/* test part */
30void insertView(GtkWidget* widget, view_constructor constructor);
31
36b3c068 32enum
33{
34 MODULE_COLUMN,
35 N_COLUMNS
36};
37
561eba2a 38void
39on_textview1_grab_focus (GtkTextView *text_view,
40 gpointer user_data)
41{
42 GtkWidget * widget;
43 GtkCustom * custom = (GtkCustom*)user_data;
44 widget = gtk_widget_get_parent((GtkWidget*)text_view);
45 widget = gtk_widget_get_parent(widget);
46 gtk_custom_set_focus((GtkWidget*)custom, (gpointer)widget);
47}
48
49void
50insertViewTest(GtkMenuItem *menuitem, gpointer user_data)
51{
52 guint val = 20;
37d0eca6 53 insertView((GtkWidget*)menuitem, (view_constructor)user_data);
54 // selected_hook(&val);
561eba2a 55}
56
57void
58on_insert_viewer_test_activate (GtkMenuItem *menuitem,
59 gpointer user_data)
60{
61 GtkWidget *scrolledwindow1, *textview1, *label;
62 static int count = 0;
63 char str[64];
64 GtkCustom * custom;
65 GtkTextBuffer* buf;
66
67 mainWindow * mwData;
68 mwData = get_window_data_struct((GtkWidget*)menuitem);
69 if(!mwData->CurrentTab) return;
70 custom = mwData->CurrentTab->custom;
71
72 sprintf(str,"label : %d",++count);
73 scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
74 gtk_widget_show (scrolledwindow1);
75 label = gtk_label_new(str);
76 gtk_widget_show(label);
77
78 gtk_custom_widget_add(custom, scrolledwindow1);
79 gtk_widget_set_size_request ((GtkWidget*)scrolledwindow1, 800, 100);
80
81 textview1 = gtk_text_view_new ();
82 gtk_widget_show (textview1);
83 gtk_container_add (GTK_CONTAINER (scrolledwindow1), textview1);
84 buf = gtk_text_view_get_buffer((GtkTextView*)textview1);
85 sprintf(str,"text view : %d",count);
86 gtk_text_buffer_set_text(buf,str, -1);
87
88 g_signal_connect ((gpointer) textview1, "grab_focus",
89 G_CALLBACK (on_textview1_grab_focus), custom);
90}
91
92/* end of test part */
93
94
95/* internal functions */
96void insertView(GtkWidget* widget, view_constructor constructor)
97{
98 GtkCustom * custom;
99 mainWindow * mwData;
f9334f6f 100 GtkWidget * viewer;
561eba2a 101
102 mwData = get_window_data_struct(widget);
103 if(!mwData->CurrentTab) return;
104 custom = mwData->CurrentTab->custom;
105
f9334f6f 106 viewer = (GtkWidget*)constructor(mwData);
107 if(viewer)
f0d936c0 108 {
109 gtk_custom_widget_add(custom, viewer);
110 // Added by MD
8af8e4c5 111 // g_object_unref(G_OBJECT(viewer));
f0d936c0 112 }
561eba2a 113}
114
115void get_label_string (GtkWidget * text, gchar * label)
116{
117 GtkEntry * entry = (GtkEntry*)text;
118 if(strlen(gtk_entry_get_text(entry))!=0)
119 strcpy(label,gtk_entry_get_text(entry));
120}
121
6b1d3120 122void get_label(GtkWindow * mw, gchar * str, gchar* dialogue_title, gchar * label_str)
561eba2a 123{
124 GtkWidget * dialogue;
125 GtkWidget * text;
126 GtkWidget * label;
127 gint id;
128
5723fa24 129 dialogue = gtk_dialog_new_with_buttons(dialogue_title,NULL,
561eba2a 130 GTK_DIALOG_MODAL,
131 GTK_STOCK_OK,GTK_RESPONSE_ACCEPT,
132 GTK_STOCK_CANCEL,GTK_RESPONSE_REJECT,
133 NULL);
134
6b1d3120 135 label = gtk_label_new(label_str);
561eba2a 136 gtk_widget_show(label);
137
138 text = gtk_entry_new();
139 gtk_widget_show(text);
140
141 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialogue)->vbox), label,TRUE, TRUE,0);
142 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialogue)->vbox), text,FALSE, FALSE,0);
143
144 id = gtk_dialog_run(GTK_DIALOG(dialogue));
145 switch(id){
146 case GTK_RESPONSE_ACCEPT:
147 get_label_string(text,str);
148 gtk_widget_destroy(dialogue);
149 break;
150 case GTK_RESPONSE_REJECT:
151 default:
152 gtk_widget_destroy(dialogue);
153 break;
154 }
155}
156
157mainWindow * get_window_data_struct(GtkWidget * widget)
158{
159 GtkWidget * mw;
160 mainWindow * mwData;
161
162 mw = lookup_widget(widget, "MWindow");
163 if(mw == NULL){
164 g_printf("Main window does not exist\n");
165 return;
166 }
167
168 mwData = (mainWindow *) g_object_get_data(G_OBJECT(mw),"mainWindow");
169 if(mwData == NULL){
170 g_printf("Main window data does not exist\n");
171 return;
172 }
173 return mwData;
174}
175
176void createNewWindow(GtkWidget* widget, gpointer user_data, gboolean clone)
177{
5723fa24 178 mainWindow * parent = get_window_data_struct(widget);
561eba2a 179
5723fa24 180 constructMainWin(parent, NULL);
561eba2a 181
182 if(clone){
183 g_printf("Clone : use the same traceset\n");
184 }else{
185 g_printf("Empty : traceset is set to NULL\n");
186 }
187}
188
189void move_up_viewer(GtkWidget * widget, gpointer user_data)
190{
191 mainWindow * mw = get_window_data_struct(widget);
192 if(!mw->CurrentTab) return;
193 gtk_custom_widget_move_up(mw->CurrentTab->custom);
194}
195
196void move_down_viewer(GtkWidget * widget, gpointer user_data)
197{
198 mainWindow * mw = get_window_data_struct(widget);
199 if(!mw->CurrentTab) return;
200 gtk_custom_widget_move_down(mw->CurrentTab->custom);
201}
202
203void delete_viewer(GtkWidget * widget, gpointer user_data)
204{
205 mainWindow * mw = get_window_data_struct(widget);
206 if(!mw->CurrentTab) return;
207 gtk_custom_widget_delete(mw->CurrentTab->custom);
208}
209
210void open_traceset(GtkWidget * widget, gpointer user_data)
211{
212 g_printf("Open a trace set\n");
213}
214
215void add_trace(GtkWidget * widget, gpointer user_data)
216{
217 g_printf("add a trace to a trace set\n");
218}
219
220void remove_trace(GtkWidget * widget, gpointer user_data)
221{
222 g_printf("remove a trace from a trace set\n");
223}
224
225void save(GtkWidget * widget, gpointer user_data)
226{
227 g_printf("Save\n");
228}
229
230void save_as(GtkWidget * widget, gpointer user_data)
231{
232 g_printf("Save as\n");
233}
234
235void zoom_in(GtkWidget * widget, gpointer user_data)
236{
237 g_printf("Zoom in\n");
238}
239
240void zoom_out(GtkWidget * widget, gpointer user_data)
241{
242 g_printf("Zoom out\n");
243}
244
245void zoom_extended(GtkWidget * widget, gpointer user_data)
246{
247 g_printf("Zoom extended\n");
248}
249
250void go_to_time(GtkWidget * widget, gpointer user_data)
251{
252 g_printf("Go to time\n");
253}
254
255void show_time_frame(GtkWidget * widget, gpointer user_data)
256{
257 g_printf("Show time frame\n");
258}
259
260
261/* callback function */
262
263void
264on_empty_traceset_activate (GtkMenuItem *menuitem,
265 gpointer user_data)
266{
267 createNewWindow((GtkWidget*)menuitem, user_data, FALSE);
268}
269
270
271void
272on_clone_traceset_activate (GtkMenuItem *menuitem,
273 gpointer user_data)
274{
275 createNewWindow((GtkWidget*)menuitem, user_data, TRUE);
276}
277
278
279void
280on_tab_activate (GtkMenuItem *menuitem,
281 gpointer user_data)
282{
6b1d3120 283 gchar label[PATH_LENGTH];
561eba2a 284 GtkNotebook * notebook = (GtkNotebook *)lookup_widget((GtkWidget*)menuitem, "MNotebook");
285 if(notebook == NULL){
286 g_printf("Notebook does not exist\n");
287 return;
288 }
289
6b1d3120 290 strcpy(label,"Page");
5723fa24 291 get_label(NULL, label,"Get the name of the tab","Please input tab's name");
561eba2a 292
5723fa24 293 create_tab ((GtkWidget*)menuitem, notebook, label);
561eba2a 294}
295
296
297void
298on_open_activate (GtkMenuItem *menuitem,
299 gpointer user_data)
300{
301 open_traceset((GtkWidget*)menuitem, user_data);
302}
303
304
305void
306on_close_activate (GtkMenuItem *menuitem,
307 gpointer user_data)
308{
309 g_printf("Close\n");
310}
311
312
313void
314on_close_tab_activate (GtkMenuItem *menuitem,
315 gpointer user_data)
316{
317 g_printf("Close tab\n");
318}
319
320
321void
322on_add_trace_activate (GtkMenuItem *menuitem,
323 gpointer user_data)
324{
325 add_trace((GtkWidget*)menuitem, user_data);
326}
327
328
329void
330on_remove_trace_activate (GtkMenuItem *menuitem,
331 gpointer user_data)
332{
333 remove_trace((GtkWidget*)menuitem, user_data);
334}
335
336
337void
338on_save_activate (GtkMenuItem *menuitem,
339 gpointer user_data)
340{
341 save((GtkWidget*)menuitem, user_data);
342}
343
344
345void
346on_save_as_activate (GtkMenuItem *menuitem,
347 gpointer user_data)
348{
349 save_as((GtkWidget*)menuitem, user_data);
350}
351
352
353void
354on_quit_activate (GtkMenuItem *menuitem,
355 gpointer user_data)
356{
357 on_MWindow_destroy(GTK_OBJECT(menuitem), user_data);
358}
359
360
361void
362on_cut_activate (GtkMenuItem *menuitem,
363 gpointer user_data)
364{
365 g_printf("Cut\n");
366}
367
368
369void
370on_copy_activate (GtkMenuItem *menuitem,
371 gpointer user_data)
372{
373 g_printf("Copye\n");
374}
375
376
377void
378on_paste_activate (GtkMenuItem *menuitem,
379 gpointer user_data)
380{
381 g_printf("Paste\n");
382}
383
384
385void
386on_delete_activate (GtkMenuItem *menuitem,
387 gpointer user_data)
388{
389 g_printf("Delete\n");
390}
391
392
393void
394on_zoom_in_activate (GtkMenuItem *menuitem,
395 gpointer user_data)
396{
397 zoom_in((GtkWidget*)menuitem, user_data);
398}
399
400
401void
402on_zoom_out_activate (GtkMenuItem *menuitem,
403 gpointer user_data)
404{
405 zoom_out((GtkWidget*)menuitem, user_data);
406}
407
408
409void
410on_zoom_extended_activate (GtkMenuItem *menuitem,
411 gpointer user_data)
412{
413 zoom_extended((GtkWidget*)menuitem, user_data);
414}
415
416
417void
418on_go_to_time_activate (GtkMenuItem *menuitem,
419 gpointer user_data)
420{
421 go_to_time((GtkWidget*)menuitem, user_data);
422}
423
424
425void
426on_show_time_frame_activate (GtkMenuItem *menuitem,
427 gpointer user_data)
428{
429 show_time_frame((GtkWidget*)menuitem, user_data);
430}
431
432
433void
434on_move_viewer_up_activate (GtkMenuItem *menuitem,
435 gpointer user_data)
436{
437 move_up_viewer((GtkWidget*)menuitem, user_data);
438}
439
440
441void
442on_move_viewer_down_activate (GtkMenuItem *menuitem,
443 gpointer user_data)
444{
445 move_down_viewer((GtkWidget*)menuitem, user_data);
446}
447
448
449void
450on_remove_viewer_activate (GtkMenuItem *menuitem,
451 gpointer user_data)
452{
453 delete_viewer((GtkWidget*)menuitem, user_data);
454}
455
456
457void
458on_load_module_activate (GtkMenuItem *menuitem,
459 gpointer user_data)
460{
36b3c068 461 char ** dir;
462 gint id;
463 char str[PATH_LENGTH];
464 mainWindow * mwData = get_window_data_struct((GtkWidget*)menuitem);
465 GtkFileSelection * fileSelector = (GtkFileSelection *)gtk_file_selection_new("Select a module");
466 gtk_file_selection_hide_fileop_buttons(fileSelector);
467
468 str[0] = '\0';
469 id = gtk_dialog_run(GTK_DIALOG(fileSelector));
470 switch(id){
471 case GTK_RESPONSE_ACCEPT:
472 case GTK_RESPONSE_OK:
473 dir = gtk_file_selection_get_selections (fileSelector);
474 sprintf(str,dir[0]);
475 if(mwData->winCreationData)
476 lttv_module_load(str, mwData->winCreationData->argc,mwData->winCreationData->argv);
477 else
478 lttv_module_load(str, 0,NULL);
479 g_strfreev(dir);
480 case GTK_RESPONSE_REJECT:
481 case GTK_RESPONSE_CANCEL:
482 default:
483 gtk_widget_destroy((GtkWidget*)fileSelector);
484 break;
485 }
486 g_printf("Load module: %s\n", str);
561eba2a 487}
488
489
490void
491on_unload_module_activate (GtkMenuItem *menuitem,
492 gpointer user_data)
493{
36b3c068 494 int i;
495 char **name, *unload_module_name;
496 guint nb;
497 LttvModule ** modules, *module;
498 mainWindow * mwData = get_window_data_struct((GtkWidget*)menuitem);
499
500 modules = lttv_module_list(&nb);
501 name = g_new(char*, nb);
502 for(i=0;i<nb;i++){
503 module = modules[i];
504 name[i] = lttv_module_name(module);
505 }
506
507 unload_module_name =get_unload_module(name,nb);
508
509 if(unload_module_name){
510 for(i=0;i<nb;i++){
511 if(strcmp(unload_module_name, name[i]) == 0){
512 lttv_module_unload(modules[i]);
513 break;
514 }
515 }
516 }
517
518 g_free(name);
561eba2a 519}
520
521
522void
523on_add_module_search_path_activate (GtkMenuItem *menuitem,
524 gpointer user_data)
525{
fc188b78 526 GtkDirSelection * fileSelector = (GtkDirSelection *)gtk_dir_selection_new("Select module path");
527 char * dir;
528 gint id;
529
6b1d3120 530 mainWindow * mwData = get_window_data_struct((GtkWidget*)menuitem);
fc188b78 531
532 id = gtk_dialog_run(GTK_DIALOG(fileSelector));
533 switch(id){
534 case GTK_RESPONSE_ACCEPT:
535 case GTK_RESPONSE_OK:
536 dir = gtk_dir_selection_get_dir (fileSelector);
537 lttv_module_path_add(dir);
538 case GTK_RESPONSE_REJECT:
539 case GTK_RESPONSE_CANCEL:
540 default:
541 gtk_widget_destroy((GtkWidget*)fileSelector);
542 break;
6b1d3120 543 }
561eba2a 544}
545
546
547void
548on_color_activate (GtkMenuItem *menuitem,
549 gpointer user_data)
550{
551 g_printf("Color\n");
552}
553
554
555void
556on_filter_activate (GtkMenuItem *menuitem,
557 gpointer user_data)
558{
559 g_printf("Filter\n");
560}
561
562
563void
564on_save_configuration_activate (GtkMenuItem *menuitem,
565 gpointer user_data)
566{
567 g_printf("Save configuration\n");
568}
569
570
571void
572on_content_activate (GtkMenuItem *menuitem,
573 gpointer user_data)
574{
575 g_printf("Content\n");
576}
577
578
579void
580on_about_activate (GtkMenuItem *menuitem,
581 gpointer user_data)
582{
583 g_printf("About...\n");
584}
585
586
587void
588on_button_new_clicked (GtkButton *button,
589 gpointer user_data)
590{
591 createNewWindow((GtkWidget*)button, user_data, FALSE);
592}
593
594
595void
596on_button_open_clicked (GtkButton *button,
597 gpointer user_data)
598{
599 open_traceset((GtkWidget*)button, user_data);
600}
601
602
603void
604on_button_add_trace_clicked (GtkButton *button,
605 gpointer user_data)
606{
607 add_trace((GtkWidget*)button, user_data);
608}
609
610
611void
612on_button_remove_trace_clicked (GtkButton *button,
613 gpointer user_data)
614{
615 remove_trace((GtkWidget*)button, user_data);
616}
617
618
619void
620on_button_save_clicked (GtkButton *button,
621 gpointer user_data)
622{
623 save((GtkWidget*)button, user_data);
624}
625
626
627void
628on_button_save_as_clicked (GtkButton *button,
629 gpointer user_data)
630{
631 save_as((GtkWidget*)button, user_data);
632}
633
634
635void
636on_button_zoom_in_clicked (GtkButton *button,
637 gpointer user_data)
638{
639 zoom_in((GtkWidget*)button, user_data);
640}
641
642
643void
644on_button_zoom_out_clicked (GtkButton *button,
645 gpointer user_data)
646{
647 zoom_out((GtkWidget*)button, user_data);
648}
649
650
651void
652on_button_zoom_extended_clicked (GtkButton *button,
653 gpointer user_data)
654{
655 zoom_extended((GtkWidget*)button, user_data);
656}
657
658
659void
660on_button_go_to_time_clicked (GtkButton *button,
661 gpointer user_data)
662{
663 go_to_time((GtkWidget*)button, user_data);
664}
665
666
667void
668on_button_show_time_frame_clicked (GtkButton *button,
669 gpointer user_data)
670{
671 show_time_frame((GtkWidget*)button, user_data);
672}
673
674
675void
676on_button_move_up_clicked (GtkButton *button,
677 gpointer user_data)
678{
679 move_up_viewer((GtkWidget*)button, user_data);
680}
681
682
683void
684on_button_move_down_clicked (GtkButton *button,
685 gpointer user_data)
686{
687 move_down_viewer((GtkWidget*)button, user_data);
688}
689
690
691void
692on_button_delete_viewer_clicked (GtkButton *button,
693 gpointer user_data)
694{
695 delete_viewer((GtkWidget*)button, user_data);
696}
697
698void
699on_MWindow_destroy (GtkObject *object,
700 gpointer user_data)
701{
5723fa24 702 g_printf("There are : %d windows\n",g_slist_length(Main_Window_List));
561eba2a 703
704 gtk_main_quit ();
705
706}
707
708
709void
710on_MNotebook_switch_page (GtkNotebook *notebook,
711 GtkNotebookPage *page,
712 guint page_num,
713 gpointer user_data)
714{
715 mainWindow * mw = get_window_data_struct((GtkWidget*)notebook);
716 tab * Tab = mw->Tab;
717
718 while(page_num){
719 Tab = Tab->Next;
720 page_num--;
721 }
722 mw->CurrentTab = Tab;
723}
724
36b3c068 725char * get_unload_module(char ** loaded_module_name, int nb_module)
726{
727 GtkWidget * dialogue;
728 GtkWidget * scroll_win;
729 GtkWidget * tree;
730 GtkListStore * store;
731 GtkTreeViewColumn * column;
732 GtkCellRenderer * renderer;
733 GtkTreeSelection * select;
734 GtkTreeIter iter;
735 gint id, i;
736 char * unload_module_name = NULL;
737
738 dialogue = gtk_dialog_new_with_buttons("Select an unload module",
739 NULL,
740 GTK_DIALOG_MODAL,
741 GTK_STOCK_OK,GTK_RESPONSE_ACCEPT,
742 GTK_STOCK_CANCEL,GTK_RESPONSE_REJECT,
743 NULL);
744 gtk_window_set_default_size((GtkWindow*)dialogue, 500, 200);
745
746 scroll_win = gtk_scrolled_window_new (NULL, NULL);
747 gtk_widget_show ( scroll_win);
748 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win),
749 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
750
751 store = gtk_list_store_new (N_COLUMNS,G_TYPE_STRING);
752 tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL (store));
753 gtk_widget_show ( tree);
754 g_object_unref (G_OBJECT (store));
755
756 renderer = gtk_cell_renderer_text_new ();
757 column = gtk_tree_view_column_new_with_attributes ("MODULE NAME",
758 renderer,
759 "text", MODULE_COLUMN,
760 NULL);
761 gtk_tree_view_column_set_alignment (column, 0.5);
762 gtk_tree_view_column_set_fixed_width (column, 150);
763 gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
764
765 select = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
766 gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);
767
768 gtk_container_add (GTK_CONTAINER (scroll_win), tree);
769
770 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialogue)->vbox), scroll_win,TRUE, TRUE,0);
771
772 for(i=0;i<nb_module;i++){
773 gtk_list_store_append (store, &iter);
774 gtk_list_store_set (store, &iter, MODULE_COLUMN,loaded_module_name[i],-1);
775 }
776
777 id = gtk_dialog_run(GTK_DIALOG(dialogue));
778 switch(id){
779 case GTK_RESPONSE_ACCEPT:
780 case GTK_RESPONSE_OK:
781 if (gtk_tree_selection_get_selected (select, (GtkTreeModel**)&store, &iter)){
782 gtk_tree_model_get ((GtkTreeModel*)store, &iter, MODULE_COLUMN, &unload_module_name, -1);
783 }
784 case GTK_RESPONSE_REJECT:
785 case GTK_RESPONSE_CANCEL:
786 default:
787 gtk_widget_destroy(dialogue);
788 break;
789 }
790
791 return unload_module_name;
792}
5723fa24 793
794void insertMenuToolbarItem(mainWindow * mw)
795{
796 int i;
797 GdkPixbuf *pixbuf;
798 view_constructor constructor;
799 LttvMenus * menu;
800 LttvToolbars * toolbar;
801 lttv_menu_closure *menuItem;
802 lttv_toolbar_closure *toolbarItem;
803 LttvAttributeValue value;
804 LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes());
805 GtkWidget * ToolMenuTitle_menu, *insert_view, *pixmap;
806
807 g_assert(lttv_iattribute_find_by_path(attributes,
808 "viewers/menu", LTTV_POINTER, &value));
809 menu = (LttvMenus*)*(value.v_pointer);
810
811 if(menu){
812 for(i=0;i<menu->len;i++){
813 menuItem = &g_array_index(menu, lttv_menu_closure, i);
814 constructor = menuItem->con;
815 ToolMenuTitle_menu = lookup_widget(mw->MWindow,"ToolMenuTitle_menu");
816 insert_view = gtk_menu_item_new_with_mnemonic (menuItem->menuText);
817 gtk_widget_show (insert_view);
818 gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), insert_view);
819 g_signal_connect ((gpointer) insert_view, "activate",
820 G_CALLBACK (insertViewTest),
821 constructor);
822 }
823 }
824
825 g_assert(lttv_iattribute_find_by_path(attributes,
826 "viewers/toolbar", LTTV_POINTER, &value));
827 toolbar = (LttvToolbars*)*(value.v_pointer);
828
829 if(toolbar){
830 for(i=0;i<toolbar->len;i++){
831 toolbarItem = &g_array_index(toolbar, lttv_toolbar_closure, i);
832 constructor = toolbarItem->con;
833 ToolMenuTitle_menu = lookup_widget(mw->MWindow,"MToolbar2");
834 pixbuf = gdk_pixbuf_new_from_xpm_data ((const char**)toolbarItem->pixmap);
835 pixmap = gtk_image_new_from_pixbuf(pixbuf);
836 insert_view = gtk_toolbar_append_element (GTK_TOOLBAR (ToolMenuTitle_menu),
837 GTK_TOOLBAR_CHILD_BUTTON,
838 NULL,
839 "",
840 toolbarItem->tooltip, NULL,
841 pixmap, NULL, NULL);
842 gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (ToolMenuTitle_menu)->children)->data))->label), TRUE);
843 gtk_widget_show (insert_view);
844 gtk_container_set_border_width (GTK_CONTAINER (insert_view), 1);
845 g_signal_connect ((gpointer) insert_view, "clicked",G_CALLBACK (insertViewTest),constructor);
846 }
847 }
848}
849
850void constructMainWin(mainWindow * parent, WindowCreationData * win_creation_data)
851{
852 systemView * sv = NULL; /* System view */
853 systemView * newSv; /* New system view displayed in the new window */
854 GtkWidget * newWindow; /* New generated main window */
855 mainWindow * newMWindow;/* New main window structure */
856 GtkNotebook * notebook;
857
858 if(parent) sv = parent->SystemView;
859
860 newMWindow = g_new(mainWindow, 1);
861
862 // Add the object's information to the module's array
863 Main_Window_List = g_slist_append(Main_Window_List, newMWindow);
864
865 newWindow = create_MWindow();
866 gtk_widget_show (newWindow);
867
868 newSv = g_new(systemView, 1);
869 if(sv){
870 while(sv->Next) sv = sv->Next;
871 sv->Next = newSv;
872 }
873
874 newSv->EventDB = NULL;
875 newSv->SystemInfo = NULL;
876 newSv->Options = NULL;
877 newSv->Next = NULL;
878 newSv->Window = newMWindow;
879
880 newMWindow->MWindow = newWindow;
881 newMWindow->Tab = NULL;
882 newMWindow->CurrentTab = NULL;
883 newMWindow->SystemView = newSv;
884 newMWindow->Attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL));
885 if(parent){
886 newMWindow->traceset_context = parent->traceset_context;
887 newMWindow->traceset = parent->traceset;
888 newMWindow->winCreationData = parent->winCreationData;
889 }else{
890 newMWindow->traceset_context = LTTV_TRACESET_CONTEXT(gTracesetContext);
891 newMWindow->traceset = (LTTV_TRACESET_CONTEXT(gTracesetContext))->ts;
892 newMWindow->winCreationData = win_creation_data;
893 }
894
895 insertMenuToolbarItem(newMWindow);
896
897 g_object_set_data(G_OBJECT(newWindow), "systemView", (gpointer)newSv);
898 g_object_set_data(G_OBJECT(newWindow), "mainWindow", (gpointer)newMWindow);
899
900 //create a default tab
901 notebook = (GtkNotebook *)lookup_widget(newMWindow->MWindow, "MNotebook");
902 if(notebook == NULL){
903 g_printf("Notebook does not exist\n");
904 return;
905 }
906 //for now there is no name field in LttvTraceset structure
907 //Use "Traceset" as the label for the default tab
908 create_tab(newMWindow->MWindow, notebook,"Traceset");
909
910}
911
912void * create_tab(GtkWidget* parent, GtkNotebook * notebook, char * label)
913{
914 GList * list;
915 tab * tmpTab;
916 mainWindow * mwData;
917
918 mwData = get_window_data_struct(parent);
919
920 tmpTab = mwData->Tab;
921 while(tmpTab && tmpTab->Next) tmpTab = tmpTab->Next;
922 if(!tmpTab){
923 mwData->CurrentTab = NULL;
924 tmpTab = g_new(tab,1);
925 mwData->Tab = tmpTab;
926 }else{
927 tmpTab->Next = g_new(tab,1);
928 tmpTab = tmpTab->Next;
929 }
930 if(mwData->CurrentTab){
931 tmpTab->traceStartTime = mwData->CurrentTab->traceStartTime;
932 tmpTab->traceEndTime = mwData->CurrentTab->traceEndTime;
933 tmpTab->startTime = mwData->CurrentTab->startTime;
934 tmpTab->endTime = mwData->CurrentTab->endTime;
935 tmpTab->currentTime = mwData->CurrentTab->currentTime;
936 }else{
937 getTracesetTimeSpan(mwData,&tmpTab->traceStartTime, &tmpTab->traceEndTime);
938 tmpTab->startTime = tmpTab->traceStartTime;
939 tmpTab->endTime = tmpTab->traceEndTime;
940 tmpTab->currentTime = tmpTab->traceStartTime;
941 }
942 tmpTab->Attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL));
943 // mwData->CurrentTab = tmpTab;
944 tmpTab->custom = (GtkCustom*)gtk_custom_new();
945 tmpTab->custom->mw = mwData;
946 gtk_widget_show((GtkWidget*)tmpTab->custom);
947 tmpTab->Next = NULL;
948
949 tmpTab->label = gtk_label_new (label);
950 gtk_widget_show (tmpTab->label);
951
952 gtk_notebook_append_page(notebook, (GtkWidget*)tmpTab->custom, tmpTab->label);
953
954 list = gtk_container_get_children(GTK_CONTAINER(notebook));
955 gtk_notebook_set_current_page(notebook,g_list_length(list)-1);
956}
This page took 0.062057 seconds and 4 git commands to generate.