]> Dogcows Code - chaz/tint2/commitdiff
desktop name
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Mon, 15 Nov 2010 21:56:41 +0000 (21:56 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Mon, 15 Nov 2010 21:56:41 +0000 (21:56 +0000)
src/taskbar/taskbarname.c

index ce4d294733adea16d84ea1bfd8db37f4a97d2c4e..2cde28b1e7b92b7af04d7d2fc21b3defafa9770d 100644 (file)
@@ -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;
 }
 
-
-
-
This page took 0.024641 seconds and 4 git commands to generate.