| 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 | |
| 10 | |
| 11 | extern GSList *gControl_Flow_Data_List; |
| 12 | |
| 13 | /***************************************************************************** |
| 14 | * Control Flow Viewer class implementation * |
| 15 | *****************************************************************************/ |
| 16 | |
| 17 | |
| 18 | struct _ControlFlowData { |
| 19 | |
| 20 | GtkWidget *Scrolled_Window_VC; |
| 21 | |
| 22 | ProcessList *Process_List; |
| 23 | Drawing_t *Drawing; |
| 24 | |
| 25 | //GtkWidget *HBox_V; |
| 26 | GtkWidget *Inside_HBox_V; |
| 27 | |
| 28 | GtkAdjustment *VAdjust_C ; |
| 29 | |
| 30 | /* Trace information */ |
| 31 | //TraceSet *Trace_Set; |
| 32 | //TraceStatistics *Trace_Statistics; |
| 33 | |
| 34 | /* Shown events information */ |
| 35 | guint First_Event, Last_Event; |
| 36 | LttTime Begin_Time, End_Time; |
| 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 | |
| 45 | } ; |
| 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 | { |
| 59 | GtkWidget *Process_List_Widget, *Drawing_Widget; |
| 60 | |
| 61 | ControlFlowData* Control_Flow_Data = g_new(ControlFlowData,1) ; |
| 62 | |
| 63 | /* Create the Drawing */ |
| 64 | Control_Flow_Data->Drawing = Drawing_construct(); |
| 65 | |
| 66 | Drawing_Widget = |
| 67 | Drawing_getWidget(Control_Flow_Data->Drawing); |
| 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 */ |
| 80 | Control_Flow_Data->Process_List = ProcessList_construct(); |
| 81 | |
| 82 | Process_List_Widget = |
| 83 | ProcessList_getWidget(Control_Flow_Data->Process_List); |
| 84 | |
| 85 | Control_Flow_Data->Inside_HBox_V = gtk_hbox_new(0, 0); |
| 86 | |
| 87 | gtk_box_pack_start( |
| 88 | GTK_BOX(Control_Flow_Data->Inside_HBox_V), |
| 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); |
| 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 | |
| 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 | |
| 137 | gtk_widget_show(Drawing_Widget); |
| 138 | gtk_widget_show(Process_List_Widget); |
| 139 | gtk_widget_show(Control_Flow_Data->Inside_HBox_V); |
| 140 | gtk_widget_show(Control_Flow_Data->Scrolled_Window_VC); |
| 141 | |
| 142 | g_object_set_data_full( |
| 143 | G_OBJECT(Control_Flow_Data->Scrolled_Window_VC), |
| 144 | "Control_Flow_Data", |
| 145 | Control_Flow_Data, |
| 146 | (GDestroyNotify)GuiControlFlow_Destructor); |
| 147 | |
| 148 | g_slist_append(gControl_Flow_Data_List,Control_Flow_Data); |
| 149 | |
| 150 | //FIXME : data sent too fast. The widget must be |
| 151 | //inserted in the main window before the Drawing area |
| 152 | //can be configured (and this must happend bedore sending |
| 153 | //data) |
| 154 | send_test_data(Control_Flow_Data->Process_List, |
| 155 | Control_Flow_Data->Drawing); |
| 156 | |
| 157 | return Control_Flow_Data; |
| 158 | |
| 159 | } |
| 160 | |
| 161 | /* Destroys widget also */ |
| 162 | void |
| 163 | GuiControlFlow_Destructor_Full(ControlFlowData *Control_Flow_Data) |
| 164 | { |
| 165 | /* May already have been done by GTK window closing */ |
| 166 | if(GTK_IS_WIDGET(Control_Flow_Data->Scrolled_Window_VC)) |
| 167 | gtk_widget_destroy(Control_Flow_Data->Scrolled_Window_VC); |
| 168 | |
| 169 | GuiControlFlow_Destructor(Control_Flow_Data); |
| 170 | } |
| 171 | |
| 172 | void |
| 173 | GuiControlFlow_Destructor(ControlFlowData *Control_Flow_Data) |
| 174 | { |
| 175 | guint index; |
| 176 | |
| 177 | /* Process List is removed with it's widget */ |
| 178 | //ProcessList_destroy(Control_Flow_Data->Process_List); |
| 179 | |
| 180 | g_slist_remove(gControl_Flow_Data_List,Control_Flow_Data); |
| 181 | g_free(Control_Flow_Data); |
| 182 | } |
| 183 | |
| 184 | GtkWidget *GuiControlFlow_get_Widget(ControlFlowData *Control_Flow_Data) |
| 185 | { |
| 186 | return Control_Flow_Data->Scrolled_Window_VC ; |
| 187 | } |
| 188 | |