diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2012-09-13 15:41:00 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2012-09-13 15:41:00 +0200 |
commit | 4e7ddbbe5994297f383149cb85c949b670c697c9 (patch) | |
tree | 0dfe70909b15643a54122c21faba70f9d8fdf508 | |
parent | d6af7727d1defbc0b7a44b704deeeae4965c4409 (diff) | |
download | vconsole-4e7ddbbe5994297f383149cb85c949b670c697c9.tar.gz |
colorize domain list a bit
-rw-r--r-- | connect.c | 8 | ||||
-rw-r--r-- | domain.c | 23 | ||||
-rw-r--r-- | vconsole.c | 16 | ||||
-rw-r--r-- | vconsole.h | 6 |
4 files changed, 40 insertions, 13 deletions
@@ -105,9 +105,11 @@ struct vconsole_connect *connect_init(struct vconsole_window *win, gtk_tree_store_append(win->store, &iter, NULL); gtk_tree_store_set(win->store, &iter, - CPTR_COL, conn, - NAME_COL, name, - URI_COL, uri, + CPTR_COL, conn, + NAME_COL, name, + URI_COL, uri, + FOREGROUND_COL, "black", + WEIGHT_COL, PANGO_WEIGHT_NORMAL, -1); if (debug) @@ -398,7 +398,8 @@ void domain_update(struct vconsole_connect *conn, struct vconsole_domain *dom = NULL; void *ptr; gboolean rc; - const char *name; + const char *name, *foreground; + PangoWeight weight; char uuid[VIR_UUID_STRING_BUFLEN]; char idstr[16]; int id; @@ -461,11 +462,25 @@ void domain_update(struct vconsole_connect *conn, strcpy(idstr, "-"); else snprintf(idstr, sizeof(idstr), "%d", id); + domain_update_info(dom, d); + switch (dom->info.state) { + case VIR_DOMAIN_RUNNING: + foreground = "darkgreen"; + weight = PANGO_WEIGHT_BOLD; + break; + default: + foreground = "black"; + weight = PANGO_WEIGHT_NORMAL; + break; + } + gtk_tree_store_set(conn->win->store, &guest, - NAME_COL, name, - ID_COL, idstr, - STATE_COL, domain_state_name(dom), + NAME_COL, name, + ID_COL, idstr, + STATE_COL, domain_state_name(dom), + FOREGROUND_COL, foreground, + WEIGHT_COL, weight, -1); } @@ -761,12 +761,14 @@ static void vconsole_tab_list_create(struct vconsole_window *win) /* store & view */ win->store = gtk_tree_store_new(N_COLUMNS, - G_TYPE_STRING, // NAME_COL - G_TYPE_POINTER, // CPTR_COL - G_TYPE_STRING, // URI_COL - G_TYPE_POINTER, // DPTR_COL - G_TYPE_STRING, // ID_COL - G_TYPE_STRING); // STATE_COL + G_TYPE_STRING, // NAME_COL + G_TYPE_POINTER, // CPTR_COL + G_TYPE_STRING, // URI_COL + G_TYPE_POINTER, // DPTR_COL + G_TYPE_STRING, // ID_COL + G_TYPE_STRING, // STATE_COL + G_TYPE_STRING, // FOREGROUND_COL + G_TYPE_INT); // WEIGHT_COL sortable = GTK_TREE_SORTABLE(win->store); win->tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(win->store)); @@ -779,6 +781,8 @@ static void vconsole_tab_list_create(struct vconsole_window *win) column = gtk_tree_view_column_new_with_attributes("Name", renderer, "text", NAME_COL, + "weight", WEIGHT_COL, + "foreground", FOREGROUND_COL, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(win->tree), column); gtk_tree_sortable_set_sort_func(sortable, NAME_COL, @@ -27,6 +27,12 @@ enum vconsole_cols { DPTR_COL, // vconsole_domain ID_COL, STATE_COL, + + /* beautify */ + FOREGROUND_COL, + WEIGHT_COL, + + /* end of list */ N_COLUMNS }; |