| 1 | #ifndef _PROCESS_LIST_H |
| 2 | #define _PROCESS_LIST_H |
| 3 | |
| 4 | #include <gtk/gtk.h> |
| 5 | #include <lttv/state.h> |
| 6 | #include <ltt/ltt.h> |
| 7 | #include "Draw_Item.h" |
| 8 | |
| 9 | /* The process list |
| 10 | * |
| 11 | * Tasks : |
| 12 | * Create a process list |
| 13 | * contains the data for the process list |
| 14 | * tells the height of the process list widget |
| 15 | * provides methods to add/remove process from the list |
| 16 | * note : the sync with drawing is left to the caller. |
| 17 | * provides helper function to convert a process unique identifier to |
| 18 | * pixels (in height). |
| 19 | * |
| 20 | * //FIXME : connect the scrolled window adjustment with the list. |
| 21 | */ |
| 22 | |
| 23 | typedef struct _ProcessInfo { |
| 24 | |
| 25 | guint pid; |
| 26 | LttTime birth; |
| 27 | |
| 28 | } ProcessInfo; |
| 29 | |
| 30 | typedef struct _HashedProcessData { |
| 31 | |
| 32 | GtkTreeRowReference *RowRef; |
| 33 | DrawContext *draw_context; |
| 34 | |
| 35 | } HashedProcessData; |
| 36 | |
| 37 | struct _ProcessList { |
| 38 | |
| 39 | GtkWidget *process_list_VC; |
| 40 | GtkListStore *Store_M; |
| 41 | |
| 42 | /* A hash table by PID to speed up process position find in the list */ |
| 43 | GHashTable *Process_Hash; |
| 44 | |
| 45 | guint number_of_process; |
| 46 | gboolean Test_Process_Sent; |
| 47 | |
| 48 | }; |
| 49 | |
| 50 | |
| 51 | typedef struct _ProcessList ProcessList; |
| 52 | |
| 53 | ProcessList *processlist_construct(void); |
| 54 | void processlist_destroy(ProcessList *process_list); |
| 55 | GtkWidget *processlist_get_widget(ProcessList *process_list); |
| 56 | |
| 57 | // out : success (0) and height |
| 58 | int processlist_add(ProcessList *process_list, guint pid, LttTime *birth, |
| 59 | gchar *name, |
| 60 | guint *height, HashedProcessData **Hashed_Process_Data); |
| 61 | // out : success (0) and height |
| 62 | int processlist_remove(ProcessList *process_list, guint pid, LttTime *birth); |
| 63 | |
| 64 | guint processlist_get_height(ProcessList *process_list); |
| 65 | |
| 66 | // Returns 0 on success |
| 67 | gint processlist_get_process_pixels(ProcessList *process_list, |
| 68 | guint pid, LttTime *birth, |
| 69 | guint *y, guint *height, |
| 70 | HashedProcessData **Hashed_Process_Data); |
| 71 | |
| 72 | gint processlist_get_pixels_from_data( ProcessList *process_list, |
| 73 | ProcessInfo *process_info, |
| 74 | HashedProcessData *Hashed_Process_Data, |
| 75 | guint *y, |
| 76 | guint *height); |
| 77 | |
| 78 | #endif // _PROCESS_LIST_H |