| 1 | |
| 2 | #include "Process_List.h" |
| 3 | |
| 4 | /***************************************************************************** |
| 5 | * Methods to synchronize process list * |
| 6 | *****************************************************************************/ |
| 7 | |
| 8 | typedef struct _ProcessList { |
| 9 | |
| 10 | GtkWidget *Process_List_VC; |
| 11 | GtkListStore *Store_M; |
| 12 | |
| 13 | guint Number_Of_Process; |
| 14 | |
| 15 | } ProcessList ; |
| 16 | |
| 17 | |
| 18 | /* Enumeration of the columns */ |
| 19 | enum |
| 20 | { |
| 21 | PROCESS_COLUMN, |
| 22 | N_COLUMNS |
| 23 | }; |
| 24 | |
| 25 | |
| 26 | ProcessList *ProcessList_construct(void) |
| 27 | { |
| 28 | GtkTreeViewColumn *column; |
| 29 | GtkCellRenderer *renderer; |
| 30 | |
| 31 | ProcessList* Process_List = g_new(ProcessList,1); |
| 32 | |
| 33 | /* Create the Process list */ |
| 34 | Process_List->Store_M = gtk_list_store_new ( N_COLUMNS, |
| 35 | G_TYPE_STRING); |
| 36 | |
| 37 | |
| 38 | Process_List->Process_List_VC = |
| 39 | gtk_tree_view_new_with_model |
| 40 | (GTK_TREE_MODEL (Process_List->Store_M)); |
| 41 | |
| 42 | g_object_unref (G_OBJECT (Process_List->Store_M)); |
| 43 | |
| 44 | gtk_tree_view_set_headers_visible( |
| 45 | GTK_TREE_VIEW(Process_List->Process_List_VC), FALSE); |
| 46 | |
| 47 | /* Create a column, associating the "text" attribute of the |
| 48 | * cell_renderer to the first column of the model */ |
| 49 | /* Columns alignment : 0.0 : Left 0.5 : Center 1.0 : Right */ |
| 50 | renderer = gtk_cell_renderer_text_new (); |
| 51 | column = gtk_tree_view_column_new_with_attributes ( "Process", |
| 52 | renderer, |
| 53 | "text", |
| 54 | PROCESS_COLUMN, |
| 55 | NULL); |
| 56 | gtk_tree_view_column_set_alignment (column, 0.0); |
| 57 | gtk_tree_view_column_set_fixed_width (column, 45); |
| 58 | gtk_tree_view_append_column ( |
| 59 | GTK_TREE_VIEW (Process_List->Process_List_VC), column); |
| 60 | |
| 61 | g_object_set_data_full( |
| 62 | G_OBJECT(Process_List->Process_List_VC), |
| 63 | "Process_List_Data", |
| 64 | Process_List, |
| 65 | ProcessList_destroy); |
| 66 | |
| 67 | |
| 68 | return Process_List; |
| 69 | } |
| 70 | |
| 71 | void ProcessList_destroy(ProcessList *Process_List) |
| 72 | { |
| 73 | g_object_unref (G_OBJECT (Process_List->Process_List_VC)); |
| 74 | |
| 75 | g_free(Process_List); |
| 76 | } |
| 77 | |
| 78 | GtkWidget *ProcessList_getWidget(ProcessList *Process_List) |
| 79 | { |
| 80 | return Process_List->Process_List_VC; |
| 81 | } |
| 82 | |
| 83 | |
| 84 | |
| 85 | gint get_cell_height(GtkTreeView *TreeView) |
| 86 | { |
| 87 | gint height, width; |
| 88 | GtkTreeViewColumn *Column = gtk_tree_view_get_column(TreeView, 0); |
| 89 | GList *Render_List = gtk_tree_view_column_get_cell_renderers(Column); |
| 90 | GtkCellRenderer *Renderer = g_list_first(Render_List)->data; |
| 91 | |
| 92 | gtk_tree_view_column_cell_get_size(Column, NULL, NULL, NULL, NULL, &height); |
| 93 | g_critical("cell 0 height : %u",height); |
| 94 | |
| 95 | return height; |
| 96 | } |
| 97 | |
| 98 | #ifdef 0 |
| 99 | int ProcessList_add(Process *myproc, ProcessList *Process_List, guint *height) |
| 100 | { |
| 101 | // add proc to container |
| 102 | |
| 103 | height = get_cell_height(GTK_TREE_VIEW(Process_List->Process_List_VC)) |
| 104 | * Process_List->Number_Of_Process ; |
| 105 | |
| 106 | return 0; |
| 107 | |
| 108 | } |
| 109 | |
| 110 | int ProcessList_remove(Process *myproc, ProcessList *Process_List) |
| 111 | { |
| 112 | // remove proc from container |
| 113 | |
| 114 | get_cell_height(GTK_TREE_VIEW(Process_List->Process_List_VC)) |
| 115 | * Process_List->Number_Of_Process ; |
| 116 | |
| 117 | return 0; |
| 118 | } |
| 119 | #endif |