desktop name : last step
git-svn-id: http://tint2.googlecode.com/svn/trunk@601 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
parent
d32b4ed908
commit
2ab0d33ae5
4 changed files with 56 additions and 20 deletions
|
@ -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 @@ void init_taskbarname_panel(void *p)
|
|||
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);
|
||||
}
|
||||
|
||||
|
||||
|
|
27
src/tint.c
27
src/tint.c
|
@ -492,7 +492,32 @@ void event_property_notify (XEvent *e)
|
|||
|
||||
// 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
|
||||
|
|
|
@ -203,6 +203,26 @@ int server_get_number_of_desktop ()
|
|||
}
|
||||
|
||||
|
||||
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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue