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