aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2012-09-13 15:41:00 +0200
committerGerd Hoffmann <kraxel@redhat.com>2012-09-13 15:41:00 +0200
commit4e7ddbbe5994297f383149cb85c949b670c697c9 (patch)
tree0dfe70909b15643a54122c21faba70f9d8fdf508
parentd6af7727d1defbc0b7a44b704deeeae4965c4409 (diff)
downloadvconsole-4e7ddbbe5994297f383149cb85c949b670c697c9.tar.gz
colorize domain list a bit
-rw-r--r--connect.c8
-rw-r--r--domain.c23
-rw-r--r--vconsole.c16
-rw-r--r--vconsole.h6
4 files changed, 40 insertions, 13 deletions
diff --git a/connect.c b/connect.c
index 293af66..44eea8c 100644
--- a/connect.c
+++ b/connect.c
@@ -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)
diff --git a/domain.c b/domain.c
index 755468d..cafd5ce 100644
--- a/domain.c
+++ b/domain.c
@@ -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);
}
diff --git a/vconsole.c b/vconsole.c
index e187814..8fac4f4 100644
--- a/vconsole.c
+++ b/vconsole.c
@@ -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,
diff --git a/vconsole.h b/vconsole.h
index f0870a2..54741fe 100644
--- a/vconsole.h
+++ b/vconsole.h
@@ -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
};