f0d936c0 |
1 | |
2 | #include <glib.h> |
3 | #include <gtk/gtk.h> |
4 | #include <gdk/gdk.h> |
5 | |
6 | #include "CFV.h" |
7 | #include "Drawing.h" |
8 | #include "Process_List.h" |
9 | |
f0d936c0 |
10 | |
558aa013 |
11 | extern GSList *gControl_Flow_Data_List; |
f0d936c0 |
12 | |
13 | /***************************************************************************** |
14 | * Control Flow Viewer class implementation * |
15 | *****************************************************************************/ |
16 | |
17 | |
558aa013 |
18 | struct _ControlFlowData { |
f0d936c0 |
19 | |
f0d936c0 |
20 | GtkWidget *Scrolled_Window_VC; |
21 | |
22 | ProcessList *Process_List; |
23 | Drawing_t *Drawing; |
24 | |
1ab818de |
25 | //GtkWidget *HBox_V; |
f0d936c0 |
26 | GtkWidget *Inside_HBox_V; |
27 | |
28 | GtkAdjustment *VAdjust_C ; |
29 | |
30 | /* Trace information */ |
558aa013 |
31 | //TraceSet *Trace_Set; |
32 | //TraceStatistics *Trace_Statistics; |
f0d936c0 |
33 | |
34 | /* Shown events information */ |
35 | guint First_Event, Last_Event; |
fa2c4dbe |
36 | LttTime Begin_Time, End_Time; |
f0d936c0 |
37 | |
38 | |
39 | /* TEST DATA, TO BE READ FROM THE TRACE */ |
40 | gint Number_Of_Events ; |
41 | guint Currently_Selected_Event ; |
42 | gboolean Selected_Event ; |
43 | guint Number_Of_Process; |
44 | |
558aa013 |
45 | } ; |
f0d936c0 |
46 | |
47 | |
48 | /** |
49 | * Control Flow Viewer's constructor |
50 | * |
51 | * This constructor is given as a parameter to the menuitem and toolbar button |
52 | * registration. It creates the drawing widget. |
53 | * @param ParentWindow A pointer to the parent window. |
54 | * @return The widget created. |
55 | */ |
56 | ControlFlowData * |
57 | GuiControlFlow(void) |
58 | { |
76a67e8a |
59 | GtkWidget *Process_List_Widget, *Drawing_Widget; |
f0d936c0 |
60 | |
61 | ControlFlowData* Control_Flow_Data = g_new(ControlFlowData,1) ; |
62 | |
63 | /* Create the Drawing */ |
76a67e8a |
64 | Control_Flow_Data->Drawing = Drawing_construct(); |
65 | |
66 | Drawing_Widget = |
67 | Drawing_getWidget(Control_Flow_Data->Drawing); |
f0d936c0 |
68 | |
69 | /* TEST DATA, TO BE READ FROM THE TRACE */ |
70 | Control_Flow_Data->Number_Of_Events = 1000 ; |
71 | Control_Flow_Data->Currently_Selected_Event = FALSE ; |
72 | Control_Flow_Data->Selected_Event = 0; |
73 | Control_Flow_Data->Number_Of_Process = 10; |
74 | |
75 | /* FIXME register Event_Selected_Hook */ |
76 | |
77 | |
78 | |
79 | /* Create the Process list */ |
fa2c4dbe |
80 | Control_Flow_Data->Process_List = ProcessList_construct(); |
f0d936c0 |
81 | |
fa2c4dbe |
82 | Process_List_Widget = |
83 | ProcessList_getWidget(Control_Flow_Data->Process_List); |
f0d936c0 |
84 | |
85 | Control_Flow_Data->Inside_HBox_V = gtk_hbox_new(0, 0); |
86 | |
fa2c4dbe |
87 | gtk_box_pack_start( |
88 | GTK_BOX(Control_Flow_Data->Inside_HBox_V), |
76a67e8a |
89 | Process_List_Widget, FALSE, TRUE, 0); // FALSE TRUE |
90 | gtk_box_pack_start( |
91 | GTK_BOX(Control_Flow_Data->Inside_HBox_V), |
92 | Drawing_Widget, TRUE, TRUE, 0); |
f0d936c0 |
93 | |
94 | |
95 | Control_Flow_Data->VAdjust_C = |
96 | GTK_ADJUSTMENT(gtk_adjustment_new( 0.0, /* Value */ |
97 | 0.0, /* Lower */ |
98 | 0.0, /* Upper */ |
99 | 0.0, /* Step inc. */ |
100 | 0.0, /* Page inc. */ |
101 | 0.0)); /* page size */ |
102 | |
f0d936c0 |
103 | Control_Flow_Data->Scrolled_Window_VC = |
104 | gtk_scrolled_window_new (NULL, |
105 | Control_Flow_Data->VAdjust_C); |
106 | |
107 | gtk_scrolled_window_set_policy( |
108 | GTK_SCROLLED_WINDOW(Control_Flow_Data->Scrolled_Window_VC) , |
109 | GTK_POLICY_NEVER, |
110 | GTK_POLICY_AUTOMATIC); |
111 | |
112 | gtk_scrolled_window_add_with_viewport( |
113 | GTK_SCROLLED_WINDOW(Control_Flow_Data->Scrolled_Window_VC), |
114 | Control_Flow_Data->Inside_HBox_V); |
115 | |
116 | |
117 | //g_signal_connect (G_OBJECT (Control_Flow_Data->Drawing_Area_V), |
118 | // "expose_event", |
119 | // G_CALLBACK (expose_event_cb), |
120 | // Control_Flow_Data); |
121 | |
122 | |
123 | |
124 | //g_signal_connect (G_OBJECT (Control_Flow_Data->VAdjust_C), |
125 | // "value-changed", |
126 | // G_CALLBACK (v_scroll_cb), |
127 | // Control_Flow_Data); |
128 | |
129 | |
130 | /* Set the size of the drawing area */ |
131 | //Drawing_Resize(Drawing, h, w); |
132 | |
133 | /* Get trace statistics */ |
134 | //Control_Flow_Data->Trace_Statistics = get_trace_statistics(Trace); |
135 | |
136 | |
76a67e8a |
137 | gtk_widget_show(Drawing_Widget); |
fa2c4dbe |
138 | gtk_widget_show(Process_List_Widget); |
f0d936c0 |
139 | gtk_widget_show(Control_Flow_Data->Inside_HBox_V); |
140 | gtk_widget_show(Control_Flow_Data->Scrolled_Window_VC); |
1ab818de |
141 | |
f0d936c0 |
142 | g_object_set_data_full( |
1ab818de |
143 | G_OBJECT(Control_Flow_Data->Scrolled_Window_VC), |
f0d936c0 |
144 | "Control_Flow_Data", |
145 | Control_Flow_Data, |
558aa013 |
146 | (GDestroyNotify)GuiControlFlow_Destructor); |
f0d936c0 |
147 | |
558aa013 |
148 | g_slist_append(gControl_Flow_Data_List,Control_Flow_Data); |
f0d936c0 |
149 | |
5f16133f |
150 | send_test_data(Control_Flow_Data->Process_List); |
151 | |
f0d936c0 |
152 | return Control_Flow_Data; |
153 | |
154 | } |
155 | |
78417791 |
156 | /* Destroys widget also */ |
157 | void |
158 | GuiControlFlow_Destructor_Full(ControlFlowData *Control_Flow_Data) |
159 | { |
160 | /* May already have been done by GTK window closing */ |
161 | if(GTK_IS_WIDGET(Control_Flow_Data->Scrolled_Window_VC)) |
162 | gtk_widget_destroy(Control_Flow_Data->Scrolled_Window_VC); |
163 | |
164 | GuiControlFlow_Destructor(Control_Flow_Data); |
165 | } |
166 | |
f0d936c0 |
167 | void |
168 | GuiControlFlow_Destructor(ControlFlowData *Control_Flow_Data) |
169 | { |
170 | guint index; |
fa2c4dbe |
171 | |
172 | /* Process List is removed with it's widget */ |
1ab818de |
173 | //ProcessList_destroy(Control_Flow_Data->Process_List); |
f0d936c0 |
174 | |
558aa013 |
175 | g_slist_remove(gControl_Flow_Data_List,Control_Flow_Data); |
78417791 |
176 | g_free(Control_Flow_Data); |
f0d936c0 |
177 | } |
178 | |
558aa013 |
179 | GtkWidget *GuiControlFlow_get_Widget(ControlFlowData *Control_Flow_Data) |
180 | { |
1ab818de |
181 | return Control_Flow_Data->Scrolled_Window_VC ; |
558aa013 |
182 | } |
f0d936c0 |
183 | |