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