From d7a80ff58208e10490b3b2e1c7514f901931062d Mon Sep 17 00:00:00 2001 From: Thierry Lorthiois Date: Mon, 15 Nov 2010 21:56:41 +0000 Subject: [PATCH] desktop name --- src/taskbar/taskbarname.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/taskbar/taskbarname.c b/src/taskbar/taskbarname.c index ce4d294..2cde28b 100644 --- a/src/taskbar/taskbarname.c +++ b/src/taskbar/taskbarname.c @@ -49,11 +49,26 @@ void init_taskbarname_panel(void *p) { Panel *panel =(Panel*)p; Taskbar *tskbar; - int j; + int j, count; if (!taskbarname_enabled) return; - for (j=0 ; j < panel->nb_desktop ; j++) { + GList *list = NULL; + gchar *data_ptr, *ptr; + data_ptr = server_get_property (server.root_win, server.atom._NET_DESKTOP_NAMES, server.atom.UTF8_STRING, &count); + if (data_ptr) { + list = g_list_append(list, g_strdup(data_ptr)); + for (j = 0; j < count-1; j++) { + if (*(data_ptr + j) == '\0') { + ptr = (gchar*)data_ptr + j + 1; + list = g_list_append(list, g_strdup(ptr)); + } + } + XFree(data_ptr); + } + + GList *l; + for (j=0, l=list ; j < panel->nb_desktop ; j++) { tskbar = &panel->taskbar[j]; memcpy(&tskbar->bar_name.area, &panel->g_taskbar.area_name, sizeof(Area)); tskbar->bar_name.area.parent = tskbar; @@ -61,7 +76,15 @@ void init_taskbarname_panel(void *p) tskbar->bar_name.area.bg = panel->g_taskbar.background_name[TASKBAR_ACTIVE]; else tskbar->bar_name.area.bg = panel->g_taskbar.background_name[TASKBAR_NORMAL]; - tskbar->bar_name.name = g_strdup_printf("%d", j+1); + + if (l) { + tskbar->bar_name.name = g_strdup(l->data); + l = l->next; + } + else { + // use desktop number if name is missing + tskbar->bar_name.name = g_strdup_printf("%d", j+1); + } // append the name at the beginning of taskbar tskbar->area.list = g_slist_append(tskbar->area.list, &tskbar->bar_name); @@ -147,6 +170,3 @@ int resize_taskbarname(void *obj) return ret; } - - - -- 2.45.2