f0d936c0 |
1 | #ifndef _PROCESS_LIST_H |
2 | #define _PROCESS_LIST_H |
3 | |
fa2c4dbe |
4 | #include <gtk/gtk.h> |
5 | #include <lttv/state.h> |
6 | #include <ltt/ltt.h> |
80a52ff8 |
7 | #include "Draw_Item.h" |
fa2c4dbe |
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 |
a56a1ba4 |
16 | * note : the sync with drawing is left to the caller. |
fa2c4dbe |
17 | * provides helper function to convert a process unique identifier to |
a56a1ba4 |
18 | * pixels (in height). |
5f16133f |
19 | * |
20 | * //FIXME : connect the scrolled window adjustment with the list. |
fa2c4dbe |
21 | */ |
22 | |
5f16133f |
23 | typedef struct _ProcessInfo { |
a56a1ba4 |
24 | |
25 | guint pid; |
26 | LttTime birth; |
5f16133f |
27 | |
28 | } ProcessInfo; |
29 | |
80a52ff8 |
30 | typedef struct _HashedProcessData { |
a56a1ba4 |
31 | |
f5d980bf |
32 | GtkTreeRowReference *row_ref; |
a56a1ba4 |
33 | DrawContext *draw_context; |
5f16133f |
34 | |
80a52ff8 |
35 | } HashedProcessData; |
a56a1ba4 |
36 | |
5f16133f |
37 | struct _ProcessList { |
a56a1ba4 |
38 | |
f5d980bf |
39 | GtkWidget *process_list_widget; |
40 | GtkListStore *list_store; |
5f16133f |
41 | |
a56a1ba4 |
42 | /* A hash table by PID to speed up process position find in the list */ |
14963be0 |
43 | GHashTable *process_hash; |
a56a1ba4 |
44 | |
ba90bc77 |
45 | guint number_of_process; |
5f16133f |
46 | }; |
47 | |
48 | |
f0d936c0 |
49 | typedef struct _ProcessList ProcessList; |
50 | |
4c69e0cc |
51 | ProcessList *processlist_construct(void); |
ba90bc77 |
52 | void processlist_destroy(ProcessList *process_list); |
53 | GtkWidget *processlist_get_widget(ProcessList *process_list); |
f0d936c0 |
54 | |
fa2c4dbe |
55 | // out : success (0) and height |
ba90bc77 |
56 | int processlist_add(ProcessList *process_list, guint pid, LttTime *birth, |
f5d980bf |
57 | gchar *name, guint *height, HashedProcessData **hashed_process_data); |
fa2c4dbe |
58 | // out : success (0) and height |
ba90bc77 |
59 | int processlist_remove(ProcessList *process_list, guint pid, LttTime *birth); |
fa2c4dbe |
60 | |
ba90bc77 |
61 | guint processlist_get_height(ProcessList *process_list); |
fa2c4dbe |
62 | |
63 | // Returns 0 on success |
ba90bc77 |
64 | gint processlist_get_process_pixels(ProcessList *process_list, |
a56a1ba4 |
65 | guint pid, LttTime *birth, |
66 | guint *y, guint *height, |
14963be0 |
67 | HashedProcessData **hashed_process_data); |
a56a1ba4 |
68 | |
ba90bc77 |
69 | gint processlist_get_pixels_from_data( ProcessList *process_list, |
a56a1ba4 |
70 | ProcessInfo *process_info, |
14963be0 |
71 | HashedProcessData *hashed_process_data, |
a56a1ba4 |
72 | guint *y, |
73 | guint *height); |
8b90e648 |
74 | |
f0d936c0 |
75 | #endif // _PROCESS_LIST_H |