Merge taskbar_alignment from branch

This commit is contained in:
o9000 2015-06-12 00:52:10 +02:00
parent 18b0ef2d1b
commit df1f2d4e4b
13 changed files with 409 additions and 276 deletions

View file

@ -544,6 +544,15 @@ void add_entry (char *key, char *value)
taskbar_sort_method = TASKBAR_NOSORT; taskbar_sort_method = TASKBAR_NOSORT;
} }
} }
else if (strcmp (key, "task_align") == 0) {
if (strcmp(value, "center") == 0) {
taskbar_alignment = ALIGN_CENTER;
} else if (strcmp(value, "right") == 0) {
taskbar_alignment = ALIGN_RIGHT;
} else {
taskbar_alignment = ALIGN_LEFT;
}
}
/* Task */ /* Task */
else if (strcmp (key, "task_text") == 0) else if (strcmp (key, "task_text") == 0)

View file

@ -354,7 +354,7 @@ int resize_panel(void *obj)
} }
Taskbar *taskbar = &panel->taskbar[i]; Taskbar *taskbar = &panel->taskbar[i];
GSList *l; GList *l;
for (l = taskbar->area.list; l; l = l->next) { for (l = taskbar->area.list; l; l = l->next) {
Area *child = l->data; Area *child = l->data;
if (!child->on_screen) if (!child->on_screen)
@ -389,7 +389,7 @@ int resize_panel(void *obj)
int requested_size = (2 * taskbar->area.bg->border.width) + (2 * taskbar->area.paddingxlr); int requested_size = (2 * taskbar->area.bg->border.width) + (2 * taskbar->area.paddingxlr);
int items = 0; int items = 0;
GSList *l = taskbar->area.list; GList *l = taskbar->area.list;
if (taskbarname_enabled) if (taskbarname_enabled)
l = l->next; l = l->next;
for (; l; l = l->next) { for (; l; l = l->next) {
@ -482,29 +482,29 @@ void set_panel_items_order(Panel *p)
int k, j; int k, j;
if (p->area.list) { if (p->area.list) {
g_slist_free(p->area.list); g_list_free(p->area.list);
p->area.list = 0; p->area.list = 0;
} }
for (k=0 ; k < strlen(panel_items_order) ; k++) { for (k=0 ; k < strlen(panel_items_order) ; k++) {
if (panel_items_order[k] == 'L') { if (panel_items_order[k] == 'L') {
p->area.list = g_slist_append(p->area.list, &p->launcher); p->area.list = g_list_append(p->area.list, &p->launcher);
p->launcher.area.resize = 1; p->launcher.area.resize = 1;
} }
if (panel_items_order[k] == 'T') { if (panel_items_order[k] == 'T') {
for (j=0 ; j < p->nb_desktop ; j++) for (j=0 ; j < p->nb_desktop ; j++)
p->area.list = g_slist_append(p->area.list, &p->taskbar[j]); p->area.list = g_list_append(p->area.list, &p->taskbar[j]);
} }
#ifdef ENABLE_BATTERY #ifdef ENABLE_BATTERY
if (panel_items_order[k] == 'B') if (panel_items_order[k] == 'B')
p->area.list = g_slist_append(p->area.list, &p->battery); p->area.list = g_list_append(p->area.list, &p->battery);
#endif #endif
int i = p - panel1; int i = p - panel1;
if (panel_items_order[k] == 'S' && systray_on_monitor(i, nb_panel)) { if (panel_items_order[k] == 'S' && systray_on_monitor(i, nb_panel)) {
p->area.list = g_slist_append(p->area.list, &systray); p->area.list = g_list_append(p->area.list, &systray);
} }
if (panel_items_order[k] == 'C') if (panel_items_order[k] == 'C')
p->area.list = g_slist_append(p->area.list, &p->clock); p->area.list = g_list_append(p->area.list, &p->clock);
} }
init_rendering(&p->area, 0); init_rendering(&p->area, 0);
} }
@ -629,7 +629,7 @@ void set_panel_background(Panel *p)
} }
// redraw panel's object // redraw panel's object
GSList *l0; GList *l0;
Area *a; Area *a;
for (l0 = p->area.list; l0 ; l0 = l0->next) { for (l0 = p->area.list; l0 ; l0 = l0->next) {
a = l0->data; a = l0->data;
@ -695,7 +695,7 @@ Taskbar *click_taskbar (Panel *panel, int x, int y)
Task *click_task (Panel *panel, int x, int y) Task *click_task (Panel *panel, int x, int y)
{ {
GSList *l0; GList *l0;
Taskbar *tskbar; Taskbar *tskbar;
if ( (tskbar = click_taskbar(panel, x, y)) ) { if ( (tskbar = click_taskbar(panel, x, y)) ) {
@ -797,7 +797,7 @@ Area* click_area(Panel *panel, int x, int y)
Area* new_result = result; Area* new_result = result;
do { do {
result = new_result; result = new_result;
GSList* it = result->list; GList* it = result->list;
while (it) { while (it) {
Area* a = it->data; Area* a = it->data;
if (a->on_screen && x >= a->posx && x <= (a->posx + a->width) if (a->on_screen && x >= a->posx && x <= (a->posx + a->width)

View file

@ -111,7 +111,7 @@ Task *add_task (Window win)
} }
new_tsk2->icon_width = new_tsk.icon_width; new_tsk2->icon_width = new_tsk.icon_width;
new_tsk2->icon_height = new_tsk.icon_height; new_tsk2->icon_height = new_tsk.icon_height;
tskbar->area.list = g_slist_append(tskbar->area.list, new_tsk2); tskbar->area.list = g_list_append(tskbar->area.list, new_tsk2);
tskbar->area.resize = 1; tskbar->area.resize = 1;
g_ptr_array_add(task_group, new_tsk2); g_ptr_array_add(task_group, new_tsk2);
//printf("add_task panel %d, desktop %d, task %s\n", i, j, new_tsk2->title); //printf("add_task panel %d, desktop %d, task %s\n", i, j, new_tsk2->title);
@ -169,7 +169,7 @@ void remove_task (Task *tsk)
for (i=0; i<task_group->len; ++i) { for (i=0; i<task_group->len; ++i) {
tsk2 = g_ptr_array_index(task_group, i); tsk2 = g_ptr_array_index(task_group, i);
tskbar = tsk2->area.parent; tskbar = tsk2->area.parent;
tskbar->area.list = g_slist_remove(tskbar->area.list, tsk2); tskbar->area.list = g_list_remove(tskbar->area.list, tsk2);
tskbar->area.resize = 1; tskbar->area.resize = 1;
if (tsk2 == task_active) task_active = 0; if (tsk2 == task_active) task_active = 0;
if (tsk2 == task_drag) task_drag = 0; if (tsk2 == task_drag) task_drag = 0;
@ -424,15 +424,13 @@ Task *find_active_task(Task *current_task, Task *active_task)
if (active_task == NULL) if (active_task == NULL)
return current_task; return current_task;
GSList *l0;
Task *tsk;
Taskbar* tskbar = current_task->area.parent; Taskbar* tskbar = current_task->area.parent;
l0 = tskbar->area.list; GList *l0 = tskbar->area.list;
if (taskbarname_enabled) if (taskbarname_enabled)
l0 = l0->next; l0 = l0->next;
for (; l0 ; l0 = l0->next) { for (; l0 ; l0 = l0->next) {
tsk = l0->data; Task *tsk = l0->data;
if (tsk->win == active_task->win) if (tsk->win == active_task->win)
return tsk; return tsk;
} }
@ -445,15 +443,13 @@ Task *next_task(Task *tsk)
if (tsk == 0) if (tsk == 0)
return 0; return 0;
GSList *l0, *lfirst_tsk;
Task *tsk1;
Taskbar* tskbar = tsk->area.parent; Taskbar* tskbar = tsk->area.parent;
l0 = tskbar->area.list; GList *l0 = tskbar->area.list;
if (taskbarname_enabled) l0 = l0->next; if (taskbarname_enabled) l0 = l0->next;
lfirst_tsk = l0; GList *lfirst_tsk = l0;
for (; l0 ; l0 = l0->next) { for (; l0 ; l0 = l0->next) {
tsk1 = l0->data; Task *tsk1 = l0->data;
if (tsk1 == tsk) { if (tsk1 == tsk) {
if (l0->next == 0) l0 = lfirst_tsk; if (l0->next == 0) l0 = lfirst_tsk;
else l0 = l0->next; else l0 = l0->next;
@ -469,19 +465,18 @@ Task *prev_task(Task *tsk)
if (tsk == 0) if (tsk == 0)
return 0; return 0;
GSList *l0, *lfirst_tsk;
Task *tsk1, *tsk2; Task *tsk1, *tsk2;
Taskbar* tskbar = tsk->area.parent; Taskbar* tskbar = tsk->area.parent;
tsk2 = 0; tsk2 = 0;
l0 = tskbar->area.list; GList *l0 = tskbar->area.list;
if (taskbarname_enabled) l0 = l0->next; if (taskbarname_enabled) l0 = l0->next;
lfirst_tsk = l0; GList *lfirst_tsk = l0;
for (; l0 ; l0 = l0->next) { for (; l0 ; l0 = l0->next) {
tsk1 = l0->data; tsk1 = l0->data;
if (tsk1 == tsk) { if (tsk1 == tsk) {
if (l0 == lfirst_tsk) { if (l0 == lfirst_tsk) {
l0 = g_slist_last ( l0 ); l0 = g_list_last ( l0 );
tsk2 = l0->data; tsk2 = l0->data;
} }
return tsk2; return tsk2;

View file

@ -47,6 +47,7 @@ int taskbar_distribute_size;
int hide_inactive_tasks; int hide_inactive_tasks;
int hide_task_diff_monitor; int hide_task_diff_monitor;
int taskbar_sort_method; int taskbar_sort_method;
int taskbar_alignment;
guint win_hash(gconstpointer key) { return (guint)*((Window*)key); } guint win_hash(gconstpointer key) { return (guint)*((Window*)key); }
gboolean win_compare(gconstpointer a, gconstpointer b) { return (*((Window*)a) == *((Window*)b)); } gboolean win_compare(gconstpointer a, gconstpointer b) { return (*((Window*)a) == *((Window*)b)); }
@ -63,6 +64,7 @@ void default_taskbar()
hide_inactive_tasks = 0; hide_inactive_tasks = 0;
hide_task_diff_monitor = 0; hide_task_diff_monitor = 0;
taskbar_sort_method = TASKBAR_NOSORT; taskbar_sort_method = TASKBAR_NOSORT;
taskbar_alignment = ALIGN_LEFT;
default_taskbarname(); default_taskbarname();
} }
@ -97,7 +99,7 @@ void cleanup_taskbar()
} }
free_area(&tskbar->area); free_area(&tskbar->area);
// remove taskbar from the panel // remove taskbar from the panel
panel->area.list = g_slist_remove(panel->area.list, tskbar); panel->area.list = g_list_remove(panel->area.list, tskbar);
} }
if (panel->taskbar) { if (panel->taskbar) {
free(panel->taskbar); free(panel->taskbar);
@ -153,6 +155,7 @@ void init_taskbar_panel(void *p)
panel->g_taskbar.area.parent = panel; panel->g_taskbar.area.parent = panel;
panel->g_taskbar.area.panel = panel; panel->g_taskbar.area.panel = panel;
panel->g_taskbar.area.size_mode = SIZE_BY_LAYOUT; panel->g_taskbar.area.size_mode = SIZE_BY_LAYOUT;
panel->g_taskbar.area.alignment = taskbar_alignment;
panel->g_taskbar.area._resize = resize_taskbar; panel->g_taskbar.area._resize = resize_taskbar;
panel->g_taskbar.area._draw_foreground = draw_taskbar; panel->g_taskbar.area._draw_foreground = draw_taskbar;
panel->g_taskbar.area._on_change_layout = on_change_taskbar; panel->g_taskbar.area._on_change_layout = on_change_taskbar;
@ -334,7 +337,7 @@ int resize_taskbar(void *obj)
resize_by_layout(obj, panel->g_task.maximum_width); resize_by_layout(obj, panel->g_task.maximum_width);
text_width = panel->g_task.maximum_width; text_width = panel->g_task.maximum_width;
GSList *l = taskbar->area.list; GList *l = taskbar->area.list;
if (taskbarname_enabled) l = l->next; if (taskbarname_enabled) l = l->next;
for (; l != NULL; l = l->next) { for (; l != NULL; l = l->next) {
if (((Task *)l->data)->area.on_screen) { if (((Task *)l->data)->area.on_screen) {
@ -388,7 +391,7 @@ void set_taskbar_state(Taskbar *tskbar, int state)
if (taskbarname_enabled && tskbar->bar_name.state_pix[state] == 0) if (taskbarname_enabled && tskbar->bar_name.state_pix[state] == 0)
tskbar->bar_name.area.redraw = 1; tskbar->bar_name.area.redraw = 1;
if (panel_mode == MULTI_DESKTOP && panel1[0].g_taskbar.background[TASKBAR_NORMAL] != panel1[0].g_taskbar.background[TASKBAR_ACTIVE]) { if (panel_mode == MULTI_DESKTOP && panel1[0].g_taskbar.background[TASKBAR_NORMAL] != panel1[0].g_taskbar.background[TASKBAR_ACTIVE]) {
GSList *l = tskbar->area.list; GList *l = tskbar->area.list;
if (taskbarname_enabled) l = l->next; if (taskbarname_enabled) l = l->next;
for ( ; l ; l = l->next) for ( ; l ; l = l->next)
set_task_redraw(l->data); set_task_redraw(l->data);
@ -511,7 +514,7 @@ int taskbar_needs_sort(Taskbar *taskbar)
if (taskbar_sort_method == TASKBAR_NOSORT) if (taskbar_sort_method == TASKBAR_NOSORT)
return 0; return 0;
GSList *i, *j; GList *i, *j;
for (i = taskbar->area.list, j = i ? i->next : NULL; i && j; i = i->next, j = j->next) { for (i = taskbar->area.list, j = i ? i->next : NULL; i && j; i = i->next, j = j->next) {
if (compare_tasks(i->data, j->data, taskbar) > 0) { if (compare_tasks(i->data, j->data, taskbar) > 0) {
return 1; return 1;
@ -528,7 +531,7 @@ void sort_tasks(Taskbar *taskbar)
if (!taskbar_needs_sort(taskbar)) { if (!taskbar_needs_sort(taskbar)) {
return; return;
} }
taskbar->area.list = g_slist_sort_with_data(taskbar->area.list, (GCompareDataFunc)compare_tasks, taskbar); taskbar->area.list = g_list_sort_with_data(taskbar->area.list, (GCompareDataFunc)compare_tasks, taskbar);
taskbar->area.resize = 1; taskbar->area.resize = 1;
panel_refresh = 1; panel_refresh = 1;
((Panel*)taskbar->area.panel)->area.resize = 1; ((Panel*)taskbar->area.panel)->area.resize = 1;

View file

@ -21,6 +21,7 @@ extern int hide_inactive_tasks;
extern int hide_task_diff_monitor; extern int hide_task_diff_monitor;
enum { TASKBAR_NOSORT, TASKBAR_SORT_CENTER, TASKBAR_SORT_TITLE }; enum { TASKBAR_NOSORT, TASKBAR_SORT_CENTER, TASKBAR_SORT_TITLE };
extern int taskbar_sort_method; extern int taskbar_sort_method;
extern int taskbar_alignment;
typedef struct { typedef struct {
// always start with area // always start with area

View file

@ -76,7 +76,7 @@ void init_taskbarname_panel(void *p)
tskbar->bar_name.name = g_strdup_printf("%d", j+1); tskbar->bar_name.name = g_strdup_printf("%d", j+1);
// append the name at the beginning of taskbar // append the name at the beginning of taskbar
tskbar->area.list = g_slist_append(tskbar->area.list, &tskbar->bar_name); tskbar->area.list = g_list_append(tskbar->area.list, &tskbar->bar_name);
} }
for (l=list ; l ; l = l->next) for (l=list ; l ; l = l->next)
@ -103,7 +103,7 @@ void cleanup_taskbarname()
XFreePixmap(server.dsp, tskbar->bar_name.state_pix[k]); XFreePixmap(server.dsp, tskbar->bar_name.state_pix[k]);
tskbar->bar_name.state_pix[k] = 0; tskbar->bar_name.state_pix[k] = 0;
} }
tskbar->area.list = g_slist_remove(tskbar->area.list, &tskbar->bar_name); tskbar->area.list = g_list_remove(tskbar->area.list, &tskbar->bar_name);
} }
} }

View file

@ -470,8 +470,8 @@ void event_button_motion_notify (XEvent *e)
} else { } else {
// Swap the task_drag with the task on the event's location (if they differ) // Swap the task_drag with the task on the event's location (if they differ)
if(event_task && event_task != task_drag) { if(event_task && event_task != task_drag) {
GSList * drag_iter = g_slist_find(event_taskbar->area.list, task_drag); GList * drag_iter = g_list_find(event_taskbar->area.list, task_drag);
GSList * task_iter = g_slist_find(event_taskbar->area.list, event_task); GList * task_iter = g_list_find(event_taskbar->area.list, event_task);
if(drag_iter && task_iter) { if(drag_iter && task_iter) {
gpointer temp = task_iter->data; gpointer temp = task_iter->data;
task_iter->data = drag_iter->data; task_iter->data = drag_iter->data;
@ -488,14 +488,14 @@ void event_button_motion_notify (XEvent *e)
return; return;
Taskbar * drag_taskbar = (Taskbar*)task_drag->area.parent; Taskbar * drag_taskbar = (Taskbar*)task_drag->area.parent;
drag_taskbar->area.list = g_slist_remove(drag_taskbar->area.list, task_drag); drag_taskbar->area.list = g_list_remove(drag_taskbar->area.list, task_drag);
if(event_taskbar->area.posx > drag_taskbar->area.posx || event_taskbar->area.posy > drag_taskbar->area.posy) { if(event_taskbar->area.posx > drag_taskbar->area.posx || event_taskbar->area.posy > drag_taskbar->area.posy) {
int i = (taskbarname_enabled) ? 1 : 0; int i = (taskbarname_enabled) ? 1 : 0;
event_taskbar->area.list = g_slist_insert(event_taskbar->area.list, task_drag, i); event_taskbar->area.list = g_list_insert(event_taskbar->area.list, task_drag, i);
} }
else else
event_taskbar->area.list = g_slist_append(event_taskbar->area.list, task_drag); event_taskbar->area.list = g_list_append(event_taskbar->area.list, task_drag);
// Move task to other desktop (but avoid the 'Window desktop changed' code in 'event_property_notify') // Move task to other desktop (but avoid the 'Window desktop changed' code in 'event_property_notify')
task_drag->area.parent = event_taskbar; task_drag->area.parent = event_taskbar;
@ -677,10 +677,9 @@ void event_property_notify (XEvent *e)
// check ALLDESKTOP task => resize taskbar // check ALLDESKTOP task => resize taskbar
Taskbar *tskbar; Taskbar *tskbar;
Task *tsk; Task *tsk;
GSList *l;
if (server.nb_desktop > old_desktop) { if (server.nb_desktop > old_desktop) {
tskbar = &panel->taskbar[old_desktop]; tskbar = &panel->taskbar[old_desktop];
l = tskbar->area.list; GList *l = tskbar->area.list;
if (taskbarname_enabled) l = l->next; if (taskbarname_enabled) l = l->next;
for (; l ; l = l->next) { for (; l ; l = l->next) {
tsk = l->data; tsk = l->data;
@ -694,7 +693,7 @@ void event_property_notify (XEvent *e)
} }
} }
tskbar = &panel->taskbar[server.desktop]; tskbar = &panel->taskbar[server.desktop];
l = tskbar->area.list; GList *l = tskbar->area.list;
if (taskbarname_enabled) l = l->next; if (taskbarname_enabled) l = l->next;
for (; l ; l = l->next) { for (; l ; l = l->next) {
tsk = l->data; tsk = l->data;

File diff suppressed because it is too large Load diff

View file

@ -47,7 +47,7 @@ GtkWidget *taskbar_hide_inactive_tasks, *taskbar_hide_diff_monitor;
GtkWidget *taskbar_name_padding_x, *taskbar_name_padding_y, *taskbar_name_inactive_color, *taskbar_name_active_color, *taskbar_name_font; GtkWidget *taskbar_name_padding_x, *taskbar_name_padding_y, *taskbar_name_inactive_color, *taskbar_name_active_color, *taskbar_name_font;
GtkWidget *taskbar_active_background, *taskbar_inactive_background; GtkWidget *taskbar_active_background, *taskbar_inactive_background;
GtkWidget *taskbar_name_active_background, *taskbar_name_inactive_background; GtkWidget *taskbar_name_active_background, *taskbar_name_inactive_background;
GtkWidget *taskbar_distribute_size, *taskbar_sort_order; GtkWidget *taskbar_distribute_size, *taskbar_sort_order, *taskbar_alignment;
// task // task
GtkWidget *task_mouse_left, *task_mouse_middle, *task_mouse_right, *task_mouse_scroll_up, *task_mouse_scroll_down; GtkWidget *task_mouse_left, *task_mouse_middle, *task_mouse_right, *task_mouse_scroll_up, *task_mouse_scroll_down;
@ -2317,6 +2317,24 @@ void create_taskbar(GtkWidget *parent)
"'By title' means that tasks are sorted by their window titles. \n" "'By title' means that tasks are sorted by their window titles. \n"
"'By center' means that tasks are sorted geometrically by their window centers."), NULL); "'By center' means that tasks are sorted geometrically by their window centers."), NULL);
row++;
col = 2;
label = gtk_label_new(_("Task alignment"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
gtk_widget_show(label);
gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
col++;
taskbar_alignment = gtk_combo_box_new_text();
gtk_widget_show(taskbar_alignment);
gtk_table_attach(GTK_TABLE(table), taskbar_alignment, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
col++;
gtk_combo_box_append_text(GTK_COMBO_BOX(taskbar_alignment), _("Left"));
gtk_combo_box_append_text(GTK_COMBO_BOX(taskbar_alignment), _("Center"));
gtk_combo_box_append_text(GTK_COMBO_BOX(taskbar_alignment), _("Right"));
gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_alignment), 0);
gtk_tooltips_set_tip(tooltips, taskbar_alignment, _("Specifies how tasks should be positioned on the taskbar."), NULL);
change_paragraph(parent); change_paragraph(parent);
label = gtk_label_new(_("<b>Appearance</b>")); label = gtk_label_new(_("<b>Appearance</b>"));

View file

@ -51,7 +51,7 @@ extern GtkWidget *taskbar_hide_inactive_tasks, *taskbar_hide_diff_monitor;
extern GtkWidget *taskbar_name_padding_x, *taskbar_name_padding_y, *taskbar_name_inactive_color, *taskbar_name_active_color, *taskbar_name_font; extern GtkWidget *taskbar_name_padding_x, *taskbar_name_padding_y, *taskbar_name_inactive_color, *taskbar_name_active_color, *taskbar_name_font;
extern GtkWidget *taskbar_active_background, *taskbar_inactive_background; extern GtkWidget *taskbar_active_background, *taskbar_inactive_background;
extern GtkWidget *taskbar_name_active_background, *taskbar_name_inactive_background; extern GtkWidget *taskbar_name_active_background, *taskbar_name_inactive_background;
extern GtkWidget *taskbar_distribute_size, *taskbar_sort_order; extern GtkWidget *taskbar_distribute_size, *taskbar_sort_order, *taskbar_alignment;
// task // task
extern GtkWidget *task_mouse_left, *task_mouse_middle, *task_mouse_right, *task_mouse_scroll_up, *task_mouse_scroll_down; extern GtkWidget *task_mouse_left, *task_mouse_middle, *task_mouse_right, *task_mouse_scroll_up, *task_mouse_scroll_down;

View file

@ -272,6 +272,16 @@ void config_write_taskbar(FILE *fp)
} }
fprintf(fp, "\n"); fprintf(fp, "\n");
fprintf(fp, "task_align = ");
if (gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_alignment)) <= 0) {
fprintf(fp, "left");
} else if (gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_alignment)) == 1) {
fprintf(fp, "center");
} else {
fprintf(fp, "right");
}
fprintf(fp, "\n");
fprintf(fp, "\n"); fprintf(fp, "\n");
} }
@ -998,6 +1008,16 @@ void add_entry(char *key, char *value)
else else
gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_sort_order), 0); gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_sort_order), 0);
} }
else if (strcmp(key, "task_align") == 0) {
if (strcmp(value, "left") == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_sort_order), 0);
else if (strcmp(value, "center") == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_sort_order), 1);
else if (strcmp(value, "right") == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_sort_order), 2);
else
gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_sort_order), 0);
}
else if (strcmp(key, "taskbar_padding") == 0) { else if (strcmp(key, "taskbar_padding") == 0) {
extract_values(value, &value1, &value2, &value3); extract_values(value, &value1, &value2, &value3);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_padding_x), atoi(value1)); gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_padding_x), atoi(value1));

View file

@ -76,7 +76,7 @@ void init_rendering(void *obj, int pos)
Area *a = (Area*)obj; Area *a = (Area*)obj;
// initialize fixed position/size // initialize fixed position/size
GSList *l; GList *l;
for (l = a->list; l ; l = l->next) { for (l = a->list; l ; l = l->next) {
Area *child = ((Area*)l->data); Area *child = ((Area*)l->data);
if (panel_horizontal) { if (panel_horizontal) {
@ -102,7 +102,7 @@ void rendering(void *obj)
Panel *panel = (Panel*)obj; Panel *panel = (Panel*)obj;
size_by_content(&panel->area); size_by_content(&panel->area);
size_by_layout(&panel->area, 0, 1); size_by_layout(&panel->area, 1);
refresh(&panel->area); refresh(&panel->area);
} }
@ -111,10 +111,11 @@ void rendering(void *obj)
void size_by_content (Area *a) void size_by_content (Area *a)
{ {
// don't resize hiden objects // don't resize hiden objects
if (!a->on_screen) return; if (!a->on_screen)
return;
// children node are resized before its parent // children node are resized before its parent
GSList *l; GList *l;
for (l = a->list; l ; l = l->next) for (l = a->list; l ; l = l->next)
size_by_content(l->data); size_by_content(l->data);
@ -134,14 +135,15 @@ void size_by_content (Area *a)
} }
void size_by_layout (Area *a, int pos, int level) void size_by_layout (Area *a, int level)
{ {
// don't resize hiden objects // don't resize hiden objects
if (!a->on_screen) return; if (!a->on_screen)
return;
// parent node is resized before its children // parent node is resized before its children
// calculate area's size // calculate area's size
GSList *l; GList *l;
if (a->resize && a->size_mode == SIZE_BY_LAYOUT) { if (a->resize && a->size_mode == SIZE_BY_LAYOUT) {
a->resize = 0; a->resize = 0;
@ -156,40 +158,103 @@ void size_by_layout (Area *a, int pos, int level)
} }
} }
// update position of childs // update position of children
pos += a->paddingxlr + a->bg->border.width; if (a->list) {
int i=0; if (a->alignment == ALIGN_LEFT) {
for (l = a->list; l ; l = l->next) { int pos = (panel_horizontal ? a->posx : a->posy) + a->bg->border.width + a->paddingxlr;
Area *child = ((Area*)l->data);
if (!child->on_screen) continue; for (l = a->list; l ; l = l->next) {
i++; Area *child = ((Area*)l->data);
if (!child->on_screen)
if (panel_horizontal) { continue;
if (pos != child->posx) {
// pos changed => redraw if (panel_horizontal) {
child->posx = pos; if (pos != child->posx) {
child->on_changed = 1; // pos changed => redraw
child->posx = pos;
child->on_changed = 1;
}
} else {
if (pos != child->posy) {
// pos changed => redraw
child->posy = pos;
child->on_changed = 1;
}
}
size_by_layout(child, level+1);
pos += panel_horizontal ? child->width + a->paddingx : child->height + a->paddingx;
}
} else if (a->alignment == ALIGN_RIGHT) {
int pos = (panel_horizontal ? a->posx + a->width : a->posy + a->height) - a->bg->border.width - a->paddingxlr;
for (l = g_list_last(a->list); l ; l = l->prev) {
Area *child = ((Area*)l->data);
if (!child->on_screen)
continue;
pos -= panel_horizontal ? child->width : child->height;
if (panel_horizontal) {
if (pos != child->posx) {
// pos changed => redraw
child->posx = pos;
child->on_changed = 1;
}
} else {
if (pos != child->posy) {
// pos changed => redraw
child->posy = pos;
child->on_changed = 1;
}
}
size_by_layout(child, level+1);
pos -= a->paddingx;
}
} else if (a->alignment == ALIGN_CENTER) {
int children_size = 0;
for (l = a->list; l ; l = l->next) {
Area *child = ((Area*)l->data);
if (!child->on_screen)
continue;
children_size += panel_horizontal ? child->width : child->height;
children_size += (l == a->list) ? 0 : a->paddingx;
}
int pos = (panel_horizontal ? a->posx : a->posy) + a->bg->border.width + a->paddingxlr;
pos += ((panel_horizontal ? a->width : a->height) - children_size) / 2;
for (l = a->list; l ; l = l->next) {
Area *child = ((Area*)l->data);
if (!child->on_screen)
continue;
if (panel_horizontal) {
if (pos != child->posx) {
// pos changed => redraw
child->posx = pos;
child->on_changed = 1;
}
} else {
if (pos != child->posy) {
// pos changed => redraw
child->posy = pos;
child->on_changed = 1;
}
}
size_by_layout(child, level+1);
pos += panel_horizontal ? child->width + a->paddingx : child->height + a->paddingx;
} }
} }
else { }
if (pos != child->posy) {
// pos changed => redraw
child->posy = pos;
child->on_changed = 1;
}
}
/*// position of each visible object
int k;
for (k=0 ; k < level ; k++) printf(" ");
printf("tree level %d, object %d, pos %d, %s\n", level, i, pos, (child->size_mode == SIZE_BY_LAYOUT) ? "SIZE_BY_LAYOUT" : "SIZE_BY_CONTENT");*/
size_by_layout(child, pos, level+1);
if (panel_horizontal)
pos += child->width + a->paddingx;
else
pos += child->height + a->paddingx;
}
if (a->on_changed) { if (a->on_changed) {
// pos/size changed // pos/size changed
@ -209,7 +274,7 @@ void refresh (Area *a)
if (a->redraw) { if (a->redraw) {
a->redraw = 0; a->redraw = 0;
// force redraw of child // force redraw of child
//GSList *l; //GList *l;
//for (l = a->list ; l ; l = l->next) //for (l = a->list ; l ; l = l->next)
//((Area*)l->data)->redraw = 1; //((Area*)l->data)->redraw = 1;
@ -222,7 +287,7 @@ void refresh (Area *a)
XCopyArea (server.dsp, a->pix, ((Panel *)a->panel)->temp_pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy); XCopyArea (server.dsp, a->pix, ((Panel *)a->panel)->temp_pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy);
// and then refresh child object // and then refresh child object
GSList *l; GList *l;
for (l = a->list; l ; l = l->next) for (l = a->list; l ; l = l->next)
refresh(l->data); refresh(l->data);
} }
@ -236,7 +301,7 @@ int resize_by_layout(void *obj, int maximum_size)
if (panel_horizontal) { if (panel_horizontal) {
// detect free size for SIZE_BY_LAYOUT's Area // detect free size for SIZE_BY_LAYOUT's Area
size = a->width - (2 * (a->paddingxlr + a->bg->border.width)); size = a->width - (2 * (a->paddingxlr + a->bg->border.width));
GSList *l; GList *l;
for (l = a->list ; l ; l = l->next) { for (l = a->list ; l ; l = l->next) {
child = (Area*)l->data; child = (Area*)l->data;
if (child->on_screen && child->size_mode == SIZE_BY_CONTENT) { if (child->on_screen && child->size_mode == SIZE_BY_CONTENT) {
@ -278,7 +343,7 @@ int resize_by_layout(void *obj, int maximum_size)
else { else {
// detect free size for SIZE_BY_LAYOUT's Area // detect free size for SIZE_BY_LAYOUT's Area
size = a->height - (2 * (a->paddingxlr + a->bg->border.width)); size = a->height - (2 * (a->paddingxlr + a->bg->border.width));
GSList *l; GList *l;
for (l = a->list ; l ; l = l->next) { for (l = a->list ; l ; l = l->next) {
child = (Area*)l->data; child = (Area*)l->data;
if (child->on_screen && child->size_mode == SIZE_BY_CONTENT) { if (child->on_screen && child->size_mode == SIZE_BY_CONTENT) {
@ -291,7 +356,7 @@ int resize_by_layout(void *obj, int maximum_size)
if (nb_by_content+nb_by_layout) if (nb_by_content+nb_by_layout)
size -= ((nb_by_content+nb_by_layout-1) * a->paddingx); size -= ((nb_by_content+nb_by_layout-1) * a->paddingx);
int height=0, modulo=0, old_height; int height=0, modulo=0;
if (nb_by_layout) { if (nb_by_layout) {
height = size / nb_by_layout; height = size / nb_by_layout;
modulo = size % nb_by_layout; modulo = size % nb_by_layout;
@ -305,7 +370,7 @@ int resize_by_layout(void *obj, int maximum_size)
for (l = a->list ; l ; l = l->next) { for (l = a->list ; l ; l = l->next) {
child = (Area*)l->data; child = (Area*)l->data;
if (child->on_screen && child->size_mode == SIZE_BY_LAYOUT) { if (child->on_screen && child->size_mode == SIZE_BY_LAYOUT) {
old_height = child->height; int old_height = child->height;
child->height = height; child->height = height;
if (modulo) { if (modulo) {
child->height++; child->height++;
@ -324,7 +389,7 @@ void set_redraw (Area *a)
{ {
a->redraw = 1; a->redraw = 1;
GSList *l; GList *l;
for (l = a->list ; l ; l = l->next) for (l = a->list ; l ; l = l->next)
set_redraw(l->data); set_redraw(l->data);
} }
@ -438,7 +503,7 @@ void remove_area (Area *a)
{ {
Area *parent = (Area*)a->parent; Area *parent = (Area*)a->parent;
parent->list = g_slist_remove(parent->list, a); parent->list = g_list_remove(parent->list, a);
set_redraw (parent); set_redraw (parent);
} }
@ -448,7 +513,7 @@ void add_area (Area *a)
{ {
Area *parent = (Area*)a->parent; Area *parent = (Area*)a->parent;
parent->list = g_slist_append(parent->list, a); parent->list = g_list_append(parent->list, a);
set_redraw (parent); set_redraw (parent);
} }
@ -459,12 +524,12 @@ void free_area (Area *a)
if (!a) if (!a)
return; return;
GSList *l0; GList *l0;
for (l0 = a->list; l0 ; l0 = l0->next) for (l0 = a->list; l0 ; l0 = l0->next)
free_area (l0->data); free_area (l0->data);
if (a->list) { if (a->list) {
g_slist_free(a->list); g_list_free(a->list);
a->list = 0; a->list = 0;
} }
if (a->pix) { if (a->pix) {

View file

@ -51,6 +51,7 @@ typedef struct
// SIZE_BY_LAYOUT objects : taskbar and task // SIZE_BY_LAYOUT objects : taskbar and task
// SIZE_BY_CONTENT objects : clock, battery, launcher, systray // SIZE_BY_CONTENT objects : clock, battery, launcher, systray
enum { SIZE_BY_LAYOUT, SIZE_BY_CONTENT }; enum { SIZE_BY_LAYOUT, SIZE_BY_CONTENT };
enum { ALIGN_LEFT = 0, ALIGN_CENTER = 1, ALIGN_RIGHT = 2 };
typedef struct { typedef struct {
// coordinate relative to panel window // coordinate relative to panel window
@ -61,13 +62,15 @@ typedef struct {
Background *bg; Background *bg;
// list of child : Area object // list of child : Area object
GSList *list; GList *list;
// object visible on screen. // object visible on screen.
// An object (like systray) could be enabled but hidden (because no tray icon). // An object (like systray) could be enabled but hidden (because no tray icon).
int on_screen; int on_screen;
// way to calculate the size (SIZE_BY_CONTENT or SIZE_BY_LAYOUT) // way to calculate the size (SIZE_BY_CONTENT or SIZE_BY_LAYOUT)
int size_mode; int size_mode;
int alignment;
// need to calculate position and width // need to calculate position and width
int resize; int resize;
// need redraw Pixmap // need redraw Pixmap
@ -96,7 +99,7 @@ void init_rendering(void *obj, int pos);
void rendering(void *obj); void rendering(void *obj);
void size_by_content (Area *a); void size_by_content (Area *a);
void size_by_layout (Area *a, int pos, int level); void size_by_layout (Area *a, int level);
// draw background and foreground // draw background and foreground
void refresh (Area *a); void refresh (Area *a);