#include "CFV.h"
#include "Drawing.h"
#include "Process_List.h"
+#include "Event_Hooks.h"
+#include "CFV-private.h"
-extern GSList *gControl_Flow_Data_List;
+#define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
+#define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
+
+extern GSList *g_control_flow_data_list;
/*****************************************************************************
* Control Flow Viewer class implementation *
*****************************************************************************/
-
-
-struct _ControlFlowData {
-
- GtkWidget *Drawing_Area_V;
- GtkWidget *Scrolled_Window_VC;
-
- ProcessList *Process_List;
- Drawing_t *Drawing;
-
- //GtkWidget *HBox_V;
- GtkWidget *Inside_HBox_V;
-
- GtkAdjustment *VAdjust_C ;
-
- /* Trace information */
- //TraceSet *Trace_Set;
- //TraceStatistics *Trace_Statistics;
-
- /* Shown events information */
- guint First_Event, Last_Event;
- ltt_time Begin_Time, End_Time;
-
-
- /* TEST DATA, TO BE READ FROM THE TRACE */
- gint Number_Of_Events ;
- guint Currently_Selected_Event ;
- gboolean Selected_Event ;
- guint Number_Of_Process;
-
-} ;
-
-
/**
* Control Flow Viewer's constructor
*
* @return The widget created.
*/
ControlFlowData *
-GuiControlFlow(void)
+guicontrolflow(void)
{
- GtkWidget *Process_List_Widget;
-
- ControlFlowData* Control_Flow_Data = g_new(ControlFlowData,1) ;
-
- /* Create the Drawing */
- //Control_Flow_Data->Drawing = Drawing();
-
- /* TEST DATA, TO BE READ FROM THE TRACE */
- Control_Flow_Data->Number_Of_Events = 1000 ;
- Control_Flow_Data->Currently_Selected_Event = FALSE ;
- Control_Flow_Data->Selected_Event = 0;
- Control_Flow_Data->Number_Of_Process = 10;
-
- /* FIXME register Event_Selected_Hook */
-
-
-
- /* Create the Process list */
- //Control_Flow_Data->Process_List = ProcessList_contruct();
-
- //Process_List_Widget =
- // ProcessList_getWidget(Control_Flow_Data->Process_List);
-
- Control_Flow_Data->Inside_HBox_V = gtk_hbox_new(0, 0);
-
- //gtk_box_pack_start(
- // GTK_BOX(Control_Flow_Data->Inside_HBox_V),
- // Process_List_Widget, FALSE, TRUE, 0);
- //gtk_box_pack_start(
- // GTK_BOX(Control_Flow_Data->Inside_HBox_V),
- // Control_Flow_Data->Drawing_Area_V, TRUE, TRUE, 0);
-
-
- Control_Flow_Data->VAdjust_C =
- GTK_ADJUSTMENT(gtk_adjustment_new( 0.0, /* Value */
- 0.0, /* Lower */
- 0.0, /* Upper */
- 0.0, /* Step inc. */
- 0.0, /* Page inc. */
- 0.0)); /* page size */
-
- Control_Flow_Data->Scrolled_Window_VC =
- gtk_scrolled_window_new (NULL,
- Control_Flow_Data->VAdjust_C);
-
- gtk_scrolled_window_set_policy(
- GTK_SCROLLED_WINDOW(Control_Flow_Data->Scrolled_Window_VC) ,
- GTK_POLICY_NEVER,
- GTK_POLICY_AUTOMATIC);
-
- gtk_scrolled_window_add_with_viewport(
- GTK_SCROLLED_WINDOW(Control_Flow_Data->Scrolled_Window_VC),
- Control_Flow_Data->Inside_HBox_V);
-
-
- //g_signal_connect (G_OBJECT (Control_Flow_Data->Drawing_Area_V),
- // "expose_event",
- // G_CALLBACK (expose_event_cb),
- // Control_Flow_Data);
-
-
-
- //g_signal_connect (G_OBJECT (Control_Flow_Data->VAdjust_C),
- // "value-changed",
- // G_CALLBACK (v_scroll_cb),
- // Control_Flow_Data);
-
-
- /* Set the size of the drawing area */
- //Drawing_Resize(Drawing, h, w);
-
- /* Get trace statistics */
- //Control_Flow_Data->Trace_Statistics = get_trace_statistics(Trace);
-
-
- //gtk_widget_show(Control_Flow_Data->Drawing_Area_V);
- //gtk_widget_show(Process_List_Widget);
- gtk_widget_show(Control_Flow_Data->Inside_HBox_V);
- gtk_widget_show(Control_Flow_Data->Scrolled_Window_VC);
-
- g_object_set_data_full(
- G_OBJECT(Control_Flow_Data->Scrolled_Window_VC),
- "Control_Flow_Data",
- Control_Flow_Data,
- (GDestroyNotify)GuiControlFlow_Destructor);
-
- g_slist_append(gControl_Flow_Data_List,Control_Flow_Data);
-
- return Control_Flow_Data;
+ GtkWidget *process_list_widget, *drawing_widget;
+
+ ControlFlowData* control_flow_data = g_new(ControlFlowData,1) ;
+
+ /* Create the drawing */
+ control_flow_data->drawing = drawing_construct(control_flow_data);
+
+ drawing_widget =
+ drawing_get_widget(control_flow_data->drawing);
+
+ control_flow_data->number_of_process = 0;
+
+ /* Create the Process list */
+ control_flow_data->process_list = processlist_construct();
+
+ process_list_widget =
+ processlist_get_widget(control_flow_data->process_list);
+
+ //control_flow_data->Inside_HBox_V = gtk_hbox_new(0, 0);
+ control_flow_data->h_paned = gtk_hpaned_new();
+
+ gtk_paned_pack1(GTK_PANED(control_flow_data->h_paned), process_list_widget, FALSE, TRUE);
+ gtk_paned_pack2(GTK_PANED(control_flow_data->h_paned), drawing_widget, TRUE, TRUE);
+
+ control_flow_data->v_adjust =
+ GTK_ADJUSTMENT(gtk_adjustment_new( 0.0, /* Value */
+ 0.0, /* Lower */
+ 0.0, /* Upper */
+ 0.0, /* Step inc. */
+ 0.0, /* Page inc. */
+ 0.0)); /* page size */
+
+ control_flow_data->scrolled_window =
+ gtk_scrolled_window_new (NULL,
+ control_flow_data->v_adjust);
+
+ gtk_scrolled_window_set_policy(
+ GTK_SCROLLED_WINDOW(control_flow_data->scrolled_window) ,
+ GTK_POLICY_NEVER,
+ GTK_POLICY_AUTOMATIC);
+
+ gtk_scrolled_window_add_with_viewport(
+ GTK_SCROLLED_WINDOW(control_flow_data->scrolled_window),
+ control_flow_data->h_paned);
+
+ /* Set the size of the drawing area */
+ //drawing_Resize(drawing, h, w);
+
+ /* Get trace statistics */
+ //control_flow_data->Trace_Statistics = get_trace_statistics(Trace);
+
+
+ gtk_widget_show(drawing_widget);
+ gtk_widget_show(process_list_widget);
+ gtk_widget_show(control_flow_data->h_paned);
+ gtk_widget_show(control_flow_data->scrolled_window);
+
+ g_object_set_data_full(
+ G_OBJECT(control_flow_data->scrolled_window),
+ "control_flow_data",
+ control_flow_data,
+ (GDestroyNotify)guicontrolflow_destructor);
+
+ g_object_set_data(
+ G_OBJECT(drawing_widget),
+ "control_flow_data",
+ control_flow_data);
+
+ g_control_flow_data_list = g_slist_append(
+ g_control_flow_data_list,
+ control_flow_data);
+
+ //WARNING : The widget must be
+ //inserted in the main window before the drawing area
+ //can be configured (and this must happend bedore sending
+ //data)
+
+ return control_flow_data;
}
/* Destroys widget also */
void
-GuiControlFlow_Destructor_Full(ControlFlowData *Control_Flow_Data)
+guicontrolflow_destructor_full(ControlFlowData *control_flow_data)
{
- /* May already have been done by GTK window closing */
- if(GTK_IS_WIDGET(Control_Flow_Data->Scrolled_Window_VC))
- gtk_widget_destroy(Control_Flow_Data->Scrolled_Window_VC);
-
- GuiControlFlow_Destructor(Control_Flow_Data);
+ g_info("CFV.c : guicontrolflow_destructor_full, %p", control_flow_data);
+ /* May already have been done by GTK window closing */
+ if(GTK_IS_WIDGET(control_flow_data->scrolled_window))
+ gtk_widget_destroy(control_flow_data->scrolled_window);
+ //control_flow_data->mw = NULL;
+ //FIXME guicontrolflow_destructor(control_flow_data);
}
+/* When this destructor is called, the widgets are already disconnected */
void
-GuiControlFlow_Destructor(ControlFlowData *Control_Flow_Data)
+guicontrolflow_destructor(ControlFlowData *control_flow_data)
{
- guint index;
+ guint index;
+
+ g_info("CFV.c : guicontrolflow_destructor, %p", control_flow_data);
+ g_info("%p, %p, %p", update_time_window_hook, control_flow_data, control_flow_data->mw);
+ if(GTK_IS_WIDGET(control_flow_data->scrolled_window))
+ g_info("widget still exists");
+
+ /* Process List is removed with it's widget */
+ //ProcessList_destroy(control_flow_data->process_list);
+ if(control_flow_data->mw != NULL)
+ {
+ unreg_update_time_window(update_time_window_hook,
+ control_flow_data,
+ control_flow_data->mw);
+
+ unreg_update_current_time(update_current_time_hook,
+ control_flow_data,
+ control_flow_data->mw);
+ }
+ g_info("CFV.c : guicontrolflow_destructor, %p", control_flow_data);
+ g_slist_remove(g_control_flow_data_list,control_flow_data);
+ g_free(control_flow_data);
+}
- //ProcessList_destroy(Control_Flow_Data->Process_List);
-
- g_slist_remove(gControl_Flow_Data_List,Control_Flow_Data);
- g_free(Control_Flow_Data);
+GtkWidget *guicontrolflow_get_widget(ControlFlowData *control_flow_data)
+{
+ return control_flow_data->scrolled_window ;
}
-GtkWidget *GuiControlFlow_get_Widget(ControlFlowData *Control_Flow_Data)
+ProcessList *guicontrolflow_get_process_list
+ (ControlFlowData *control_flow_data)
{
- return Control_Flow_Data->Scrolled_Window_VC ;
+ return control_flow_data->process_list ;
}
+TimeWindow *guicontrolflow_get_time_window(ControlFlowData *control_flow_data)
+{
+ return &control_flow_data->time_window;
+}
+LttTime *guicontrolflow_get_current_time(ControlFlowData *control_flow_data)
+{
+ return &control_flow_data->current_time;
+}
+
+