show text : running state
[lttv.git] / ltt / branches / poly / lttv / modules / guiControlFlow / Process_List.c
index 2e416d078352334274cd5d59a426b33746d9ef38..93298c5e5a921c18bf5d40c918b5cdc8ecff672e 100644 (file)
@@ -2,33 +2,12 @@
 #include <gtk/gtk.h>
 #include <glib.h>
 #include "Process_List.h"
-
+#include "Draw_Item.h"
 
 /*****************************************************************************
  *                       Methods to synchronize process list                 *
  *****************************************************************************/
 
-typedef struct _ProcessInfo {
-       
-       guint pid;
-       LttTime birth;
-
-} ProcessInfo;
-
-
-struct _ProcessList {
-       
-       GtkWidget *Process_List_VC;
-       GtkListStore *Store_M;
-
-       /* A hash table by PID to speed up process position find in the list */
-       GHashTable *Process_Hash;
-       
-       guint Number_Of_Process;
-
-};
-
-
 /* Enumeration of the columns */
 enum
 {
@@ -153,93 +132,6 @@ gint process_sort_func     (       GtkTreeModel *model,
 
 }
 
-void send_test_data(ProcessList *Process_List)
-{
-       guint height;
-       int i;
-       ProcessInfo Process_Info = {10000, 12000, 55600};
-       //ProcessInfo Process_Info = {156, 14000, 55500};
-       GtkTreeRowReference *got_RowRef;
-
-       LttTime birth;
-       birth.tv_sec = 12000;
-       birth.tv_nsec = 55500;
-
-       ProcessList_add(Process_List,
-                       1,
-                       &birth,
-                       &height);
-
-       g_critical("height : %u", height);
-       
-       birth.tv_sec = 14000;
-       birth.tv_nsec = 55500;
-
-       ProcessList_add(Process_List,
-                       156,
-                       &birth,
-                       &height);
-
-       g_critical("height : %u", height);
-
-       birth.tv_sec = 12000;
-       birth.tv_nsec = 55700;
-
-       ProcessList_add(Process_List,
-                       10,
-                       &birth,
-                       &height);
-
-       for(i=0; i<10; i++)
-       {
-               birth.tv_sec = i*12000;
-               birth.tv_nsec = i*55700;
-
-               ProcessList_add(Process_List,
-                               i,
-                               &birth,
-                               &height);
-
-       }
-       g_critical("height : %u", height);
-
-       birth.tv_sec = 12000;
-       birth.tv_nsec = 55600;
-
-       ProcessList_add(Process_List,
-                       10,
-                       &birth,
-                       &height);
-       g_critical("height : %u", height);
-
-       ProcessList_add(Process_List,
-                       10000,
-                       &birth,
-                       &height);
-       g_critical("height : %u", height);
-
-
-       ProcessList_remove(     Process_List,
-                               10000,
-                               &birth);
-       
-       if(got_RowRef = 
-               (GtkTreeRowReference*)g_hash_table_lookup(
-                                       Process_List->Process_Hash,
-                                       &Process_Info))
-       {
-               g_critical("key found");
-               g_critical("position in the list : %s",
-                       gtk_tree_path_to_string (
-                       gtk_tree_row_reference_get_path(
-                               (GtkTreeRowReference*)got_RowRef)
-                       ));
-               
-       }
-
-}
-
-
 guint hash_fct(gconstpointer key)
 {
        return ((ProcessInfo*)key)->pid;
@@ -249,26 +141,26 @@ gboolean equ_fct(gconstpointer a, gconstpointer b)
 {
        if(((ProcessInfo*)a)->pid != ((ProcessInfo*)b)->pid)
                return 0;
-       g_critical("compare %u and %u",((ProcessInfo*)a)->pid,((ProcessInfo*)b)->pid);
+//     g_critical("compare %u and %u",((ProcessInfo*)a)->pid,((ProcessInfo*)b)->pid);
        if(((ProcessInfo*)a)->birth.tv_sec != ((ProcessInfo*)b)->birth.tv_sec)
                return 0;
-       g_critical("compare %u and %u",((ProcessInfo*)a)->birth.tv_sec,((ProcessInfo*)b)->birth.tv_sec);
+//     g_critical("compare %u and %u",((ProcessInfo*)a)->birth.tv_sec,((ProcessInfo*)b)->birth.tv_sec);
 
        if(((ProcessInfo*)a)->birth.tv_nsec != ((ProcessInfo*)b)->birth.tv_nsec)
                return 0;
-       g_critical("compare %u and %u",((ProcessInfo*)a)->birth.tv_nsec,((ProcessInfo*)b)->birth.tv_nsec);
+//     g_critical("compare %u and %u",((ProcessInfo*)a)->birth.tv_nsec,((ProcessInfo*)b)->birth.tv_nsec);
 
        return 1;
 }
 
-void Destroy_hash_key(gpointer key);
+void destroy_hash_key(gpointer key);
 
-void Destroy_hash_data(gpointer data);
+void destroy_hash_data(gpointer data);
 
 
 
 
-ProcessList *ProcessList_construct(void)
+ProcessList *processlist_construct(void)
 {
        GtkTreeViewColumn *column;
        GtkCellRenderer *renderer;
@@ -305,7 +197,7 @@ ProcessList *ProcessList_construct(void)
        
        Process_List->Process_Hash = g_hash_table_new_full(
                        hash_fct, equ_fct,
-                       Destroy_hash_key, Destroy_hash_data
+                       destroy_hash_key, destroy_hash_data
                        );
        
        
@@ -359,13 +251,13 @@ ProcessList *ProcessList_construct(void)
                        G_OBJECT(Process_List->Process_List_VC),
                        "Process_List_Data",
                        Process_List,
-                       (GDestroyNotify)ProcessList_destroy);
-                       
-       send_test_data(Process_List);
+                       (GDestroyNotify)processlist_destroy);
 
+       Process_List->Test_Process_Sent = 0;
+       
        return Process_List;
 }
-void ProcessList_destroy(ProcessList *Process_List)
+void processlist_destroy(ProcessList *Process_List)
 {
        g_hash_table_destroy(Process_List->Process_Hash);
        Process_List->Process_Hash = NULL;
@@ -373,7 +265,7 @@ void ProcessList_destroy(ProcessList *Process_List)
        g_free(Process_List);
 }
 
-GtkWidget *ProcessList_getWidget(ProcessList *Process_List)
+GtkWidget *processlist_get_widget(ProcessList *Process_List)
 {
        return Process_List->Process_List_VC;
 }
@@ -384,63 +276,113 @@ gint get_cell_height(GtkTreeView *TreeView)
 {
        gint height;
        GtkTreeViewColumn *Column = gtk_tree_view_get_column(TreeView, 0);
-       GList *Render_List = gtk_tree_view_column_get_cell_renderers(Column);
-       GtkCellRenderer *Renderer = g_list_first(Render_List)->data;
+       //GList *Render_List = gtk_tree_view_column_get_cell_renderers(Column);
+       //GtkCellRenderer *Renderer = g_list_first(Render_List)->data;
        
+       //g_list_free(Render_List);
        gtk_tree_view_column_cell_get_size(Column, NULL, NULL, NULL, NULL, &height);
-       g_critical("cell 0 height : %u",height);
+       //g_critical("cell 0 height : %u",height);
        
        return height;
 }
 
-void Destroy_hash_key(gpointer key)
+void destroy_hash_key(gpointer key)
 {
        g_free(key);
 }
 
-void Destroy_hash_data(gpointer data)
+void destroy_hash_data(gpointer data)
 {
        g_free(data);
 }
 
-int ProcessList_add(   ProcessList *Process_List,
+int processlist_add(   ProcessList *Process_List,
                        guint pid,
                        LttTime *birth,
-                       guint *height)
+                       gchar *name,
+                       guint *height,
+                       HashedProcessData **pmHashed_Process_Data)
 {
        GtkTreeIter iter ;
        ProcessInfo *Process_Info = g_new(ProcessInfo, 1);
-       GtkTreeRowReference *RowRef;
-
+       HashedProcessData *Hashed_Process_Data = g_new(HashedProcessData, 1);
+       *pmHashed_Process_Data = Hashed_Process_Data;
+       
        Process_Info->pid = pid;
        Process_Info->birth = *birth;
        
+       Hashed_Process_Data->draw_context = g_new(DrawContext, 1);
+       Hashed_Process_Data->draw_context->drawable = NULL;
+       Hashed_Process_Data->draw_context->gc = NULL;
+       Hashed_Process_Data->draw_context->pango_layout = NULL;
+       Hashed_Process_Data->draw_context->Current = g_new(DrawInfo,1);
+       Hashed_Process_Data->draw_context->Current->over = g_new(ItemInfo,1);
+       Hashed_Process_Data->draw_context->Current->over->x = -1;
+       Hashed_Process_Data->draw_context->Current->over->y = -1;
+       Hashed_Process_Data->draw_context->Current->middle = g_new(ItemInfo,1);
+       Hashed_Process_Data->draw_context->Current->middle->x = -1;
+       Hashed_Process_Data->draw_context->Current->middle->y = -1;
+       Hashed_Process_Data->draw_context->Current->under = g_new(ItemInfo,1);
+       Hashed_Process_Data->draw_context->Current->under->x = -1;
+       Hashed_Process_Data->draw_context->Current->under->y = -1;
+       Hashed_Process_Data->draw_context->Current->modify_over = g_new(ItemInfo,1);
+       Hashed_Process_Data->draw_context->Current->modify_over->x = -1;
+       Hashed_Process_Data->draw_context->Current->modify_over->y = -1;
+       Hashed_Process_Data->draw_context->Current->modify_middle = g_new(ItemInfo,1);
+       Hashed_Process_Data->draw_context->Current->modify_middle->x = -1;
+       Hashed_Process_Data->draw_context->Current->modify_middle->y = -1;
+       Hashed_Process_Data->draw_context->Current->modify_under = g_new(ItemInfo,1);
+       Hashed_Process_Data->draw_context->Current->modify_under->x = -1;
+       Hashed_Process_Data->draw_context->Current->modify_under->y = -1;
+       Hashed_Process_Data->draw_context->Current->ts = NULL;
+       Hashed_Process_Data->draw_context->Current->tfs = NULL;
+       Hashed_Process_Data->draw_context->Previous = g_new(DrawInfo,1);
+       Hashed_Process_Data->draw_context->Previous->over = g_new(ItemInfo,1);
+       Hashed_Process_Data->draw_context->Previous->over->x = -1;
+       Hashed_Process_Data->draw_context->Previous->over->y = -1;
+       Hashed_Process_Data->draw_context->Previous->middle = g_new(ItemInfo,1);
+       Hashed_Process_Data->draw_context->Previous->middle->x = -1;
+       Hashed_Process_Data->draw_context->Previous->middle->y = -1;
+       Hashed_Process_Data->draw_context->Previous->under = g_new(ItemInfo,1);
+       Hashed_Process_Data->draw_context->Previous->under->x = -1;
+       Hashed_Process_Data->draw_context->Previous->under->y = -1;
+       Hashed_Process_Data->draw_context->Previous->modify_over = g_new(ItemInfo,1);
+       Hashed_Process_Data->draw_context->Previous->modify_over->x = -1;
+       Hashed_Process_Data->draw_context->Previous->modify_over->y = -1;
+       Hashed_Process_Data->draw_context->Previous->modify_middle = g_new(ItemInfo,1);
+       Hashed_Process_Data->draw_context->Previous->modify_middle->x = -1;
+       Hashed_Process_Data->draw_context->Previous->modify_middle->y = -1;
+       Hashed_Process_Data->draw_context->Previous->modify_under = g_new(ItemInfo,1);
+       Hashed_Process_Data->draw_context->Previous->modify_under->x = -1;
+       Hashed_Process_Data->draw_context->Previous->modify_under->y = -1;
+       Hashed_Process_Data->draw_context->Previous->ts = NULL;
+       Hashed_Process_Data->draw_context->Previous->tfs = NULL;
+       
        /* Add a new row to the model */
        gtk_list_store_append ( Process_List->Store_M, &iter);
-       g_critical ( "iter before : %s", gtk_tree_path_to_string (
-                       gtk_tree_model_get_path (
-                                       GTK_TREE_MODEL(Process_List->Store_M),
-                                       &iter)));
+       //g_critical ( "iter before : %s", gtk_tree_path_to_string (
+       //              gtk_tree_model_get_path (
+       //                              GTK_TREE_MODEL(Process_List->Store_M),
+       //                              &iter)));
        gtk_list_store_set (    Process_List->Store_M, &iter,
-                               PROCESS_COLUMN, "name",
+                               PROCESS_COLUMN, name,
                                PID_COLUMN, pid,
                                BIRTH_S_COLUMN, birth->tv_sec,
                                BIRTH_NS_COLUMN, birth->tv_nsec,
                                -1);
-       RowRef = gtk_tree_row_reference_new (
+       Hashed_Process_Data->RowRef = gtk_tree_row_reference_new (
                        GTK_TREE_MODEL(Process_List->Store_M),
                        gtk_tree_model_get_path(
                                GTK_TREE_MODEL(Process_List->Store_M),
                                &iter));
-                       
        g_hash_table_insert(    Process_List->Process_Hash,
                                (gpointer)Process_Info,
-                               (gpointer)RowRef);
+                               (gpointer)Hashed_Process_Data);
        
-       g_critical ( "iter after : %s", gtk_tree_path_to_string (
-                       gtk_tree_model_get_path (
-                                       GTK_TREE_MODEL(Process_List->Store_M),
-                                       &iter)));
+       //g_critical ( "iter after : %s", gtk_tree_path_to_string (
+       //              gtk_tree_model_get_path (
+       //                              GTK_TREE_MODEL(Process_List->Store_M),
+       //                              &iter)));
        Process_List->Number_Of_Process++;
 
        *height = get_cell_height(GTK_TREE_VIEW(Process_List->Process_List_VC))
@@ -451,20 +393,21 @@ int ProcessList_add(      ProcessList *Process_List,
        
 }
 
-int ProcessList_remove(        ProcessList *Process_List,
+int processlist_remove(        ProcessList *Process_List,
                        guint pid,
                        LttTime *birth)
 {
        ProcessInfo Process_Info;
        gint *path_indices;
-       GtkTreeRowReference *got_RowRef;
+       HashedProcessData *Hashed_Process_Data;
        GtkTreeIter iter;
        
        Process_Info.pid = pid;
        Process_Info.birth = *birth;
 
-       if(got_RowRef = 
-               (GtkTreeRowReference*)g_hash_table_lookup(
+
+       if(Hashed_Process_Data = 
+               (HashedProcessData*)g_hash_table_lookup(
                                        Process_List->Process_Hash,
                                        &Process_Info))
        {
@@ -472,11 +415,28 @@ int ProcessList_remove(   ProcessList *Process_List,
                                GTK_TREE_MODEL(Process_List->Store_M),
                                &iter,
                                gtk_tree_row_reference_get_path(
-                                       (GtkTreeRowReference*)got_RowRef)
+                                       (GtkTreeRowReference*)Hashed_Process_Data->RowRef)
                                );
 
                gtk_list_store_remove (Process_List->Store_M, &iter);
-                       
+               
+               g_free(Hashed_Process_Data->draw_context->Previous->modify_under);
+               g_free(Hashed_Process_Data->draw_context->Previous->modify_middle);
+               g_free(Hashed_Process_Data->draw_context->Previous->modify_over);
+               g_free(Hashed_Process_Data->draw_context->Previous->under);
+               g_free(Hashed_Process_Data->draw_context->Previous->middle);
+               g_free(Hashed_Process_Data->draw_context->Previous->over);
+               g_free(Hashed_Process_Data->draw_context->Previous);
+               g_free(Hashed_Process_Data->draw_context->Current->modify_under);
+               g_free(Hashed_Process_Data->draw_context->Current->modify_middle);
+               g_free(Hashed_Process_Data->draw_context->Current->modify_over);
+               g_free(Hashed_Process_Data->draw_context->Current->under);
+               g_free(Hashed_Process_Data->draw_context->Current->middle);
+               g_free(Hashed_Process_Data->draw_context->Current->over);
+               g_free(Hashed_Process_Data->draw_context->Current);
+               g_free(Hashed_Process_Data->draw_context);
+               g_free(Hashed_Process_Data);
+
                g_hash_table_remove(Process_List->Process_Hash,
                                &Process_Info);
                
@@ -489,44 +449,44 @@ int ProcessList_remove(   ProcessList *Process_List,
 }
 
 
-guint ProcessList_get_height(ProcessList *Process_List)
+guint processlist_get_height(ProcessList *Process_List)
 {
        return get_cell_height(GTK_TREE_VIEW(Process_List->Process_List_VC))
                                * Process_List->Number_Of_Process ;
 }
 
 
-gint ProcessList_get_process_pixels(   ProcessList *Process_List,
+gint processlist_get_process_pixels(   ProcessList *Process_List,
                                        guint pid, LttTime *birth,
-                                       guint *x,
-                                       guint *height)
+                                       guint *y,
+                                       guint *height,
+                                       HashedProcessData **pmHashed_Process_Data)
 {
        ProcessInfo Process_Info;
        gint *path_indices;
-       GtkTreeRowReference *got_RowRef;
+       GtkTreePath *tree_path;
+       HashedProcessData *Hashed_Process_Data = NULL;
 
        Process_Info.pid = pid;
        Process_Info.birth = *birth;
 
-       if(got_RowRef = 
-               (GtkTreeRowReference*)g_hash_table_lookup(
+       if(Hashed_Process_Data = 
+               (HashedProcessData*)g_hash_table_lookup(
                                        Process_List->Process_Hash,
                                        &Process_Info))
        {
-               path_indices =  gtk_tree_path_get_indices (
-                               gtk_tree_row_reference_get_path(
-                                       (GtkTreeRowReference*)got_RowRef)
-                               );
+               tree_path = gtk_tree_row_reference_get_path(
+                                                                               Hashed_Process_Data->RowRef);
+               path_indices =  gtk_tree_path_get_indices (tree_path);
 
                *height = get_cell_height(
                                GTK_TREE_VIEW(Process_List->Process_List_VC));
-               *x = *height * path_indices[0];
-               
+               *y = *height * path_indices[0];
+               *pmHashed_Process_Data = Hashed_Process_Data;
                return 0;       
        } else {
+               *pmHashed_Process_Data = Hashed_Process_Data;
                return 1;
        }
 
-
-
 }
This page took 0.028608 seconds and 4 git commands to generate.