desktop name : last step git-svn-id: http://tint2.googlecode.com/svn/trunk@601 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
4 files changed,
56 insertions(+),
20 deletions(-)
M
src/taskbar/taskbarname.c
→
src/taskbar/taskbarname.c
@@ -49,25 +49,11 @@ void init_taskbarname_panel(void *p)
{ Panel *panel =(Panel*)p; Taskbar *tskbar; - int j, count; + int j; if (!taskbarname_enabled) return; - 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; + GSList *l, *list = server_get_name_of_desktop(); 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));@@ -77,18 +63,21 @@ 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]; + // use desktop number if name is missing if (l) { tskbar->bar_name.name = g_strdup(l->data); l = l->next; } - else { - // use desktop number if name is missing + else 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); } + + for (l=list ; l ; l = l->next) + g_free(l->data); + g_slist_free(list); }
M
src/tint.c
→
src/tint.c
@@ -492,7 +492,32 @@ }
// Change name of desktops else if (at == server.atom._NET_DESKTOP_NAMES) { - printf("_NET_DESKTOP_NAMES\n"); + if (!taskbarname_enabled) return; + GSList *l, *list = server_get_name_of_desktop(); + int j; + gchar *name; + Taskbar *tskbar; + for (i=0 ; i < nb_panel ; i++) { + for (j=0, l=list ; j < panel1[i].nb_desktop ; j++) { + if (l) { + name = g_strdup(l->data); + l = l->next; + } + else + name = g_strdup_printf("%d", j+1); + tskbar = &panel1[i].taskbar[j]; + if (strcmp(name, tskbar->bar_name.name) != 0) { + g_free(tskbar->bar_name.name); + tskbar->bar_name.name = name; + tskbar->bar_name.area.resize = 1; + } + else + g_free(name); + } + } + for (l=list ; l ; l = l->next) + g_free(l->data); + g_slist_free(list); panel_refresh = 1; } // Change number of desktops
M
src/util/window.c
→
src/util/window.c
@@ -203,6 +203,26 @@ return get_property32(server.root_win, server.atom._NET_NUMBER_OF_DESKTOPS, XA_CARDINAL);
} +GSList *server_get_name_of_desktop () +{ + int count, j; + GSList *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_slist_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_slist_append(list, g_strdup(ptr)); + } + } + XFree(data_ptr); + } + return list; +} + + int server_get_current_desktop () { return get_property32(server.root_win, server.atom._NET_CURRENT_DESKTOP, XA_CARDINAL);
M
src/util/window.h
→
src/util/window.h
@@ -9,6 +9,7 @@
#ifndef WINDOW_H #define WINDOW_H +#include <glib.h> #include <pango/pangocairo.h>@@ -17,6 +18,7 @@ void set_desktop (int desktop);
void set_close (Window win); int server_get_current_desktop (); int server_get_number_of_desktop (); +GSList *server_get_name_of_desktop (); int window_is_iconified (Window win); int window_is_urgent (Window win); int window_is_hidden (Window win);