From df1f2d4e4bc6eb9eb4af3f551e06b6cf49d38815 Mon Sep 17 00:00:00 2001 From: o9000 Date: Fri, 12 Jun 2015 00:52:10 +0200 Subject: [PATCH] Merge taskbar_alignment from branch --- src/config.c | 9 + src/panel.c | 22 +- src/taskbar/task.c | 25 +-- src/taskbar/taskbar.c | 13 +- src/taskbar/taskbar.h | 1 + src/taskbar/taskbarname.c | 4 +- src/tint.c | 15 +- src/tint2conf/po/tint2conf.pot | 382 +++++++++++++++++---------------- src/tint2conf/properties.c | 20 +- src/tint2conf/properties.h | 2 +- src/tint2conf/properties_rw.c | 20 ++ src/util/area.c | 165 +++++++++----- src/util/area.h | 7 +- 13 files changed, 409 insertions(+), 276 deletions(-) diff --git a/src/config.c b/src/config.c index ba2c265..51cbb65 100644 --- a/src/config.c +++ b/src/config.c @@ -544,6 +544,15 @@ void add_entry (char *key, char *value) 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 */ else if (strcmp (key, "task_text") == 0) diff --git a/src/panel.c b/src/panel.c index cb2210e..8c0d61f 100644 --- a/src/panel.c +++ b/src/panel.c @@ -354,7 +354,7 @@ int resize_panel(void *obj) } Taskbar *taskbar = &panel->taskbar[i]; - GSList *l; + GList *l; for (l = taskbar->area.list; l; l = l->next) { Area *child = l->data; 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 items = 0; - GSList *l = taskbar->area.list; + GList *l = taskbar->area.list; if (taskbarname_enabled) l = l->next; for (; l; l = l->next) { @@ -482,29 +482,29 @@ void set_panel_items_order(Panel *p) int k, j; if (p->area.list) { - g_slist_free(p->area.list); + g_list_free(p->area.list); p->area.list = 0; } for (k=0 ; k < strlen(panel_items_order) ; k++) { 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; } if (panel_items_order[k] == 'T') { 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 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 int i = p - panel1; 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') - 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); } @@ -629,7 +629,7 @@ void set_panel_background(Panel *p) } // redraw panel's object - GSList *l0; + GList *l0; Area *a; for (l0 = p->area.list; l0 ; l0 = l0->next) { 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) { - GSList *l0; + GList *l0; Taskbar *tskbar; if ( (tskbar = click_taskbar(panel, x, y)) ) { @@ -797,7 +797,7 @@ Area* click_area(Panel *panel, int x, int y) Area* new_result = result; do { result = new_result; - GSList* it = result->list; + GList* it = result->list; while (it) { Area* a = it->data; if (a->on_screen && x >= a->posx && x <= (a->posx + a->width) diff --git a/src/taskbar/task.c b/src/taskbar/task.c index b75466e..a2fcca1 100644 --- a/src/taskbar/task.c +++ b/src/taskbar/task.c @@ -111,7 +111,7 @@ Task *add_task (Window win) } new_tsk2->icon_width = new_tsk.icon_width; 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; g_ptr_array_add(task_group, new_tsk2); //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; ilen; ++i) { tsk2 = g_ptr_array_index(task_group, i); 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; if (tsk2 == task_active) task_active = 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) return current_task; - GSList *l0; - Task *tsk; Taskbar* tskbar = current_task->area.parent; - l0 = tskbar->area.list; + GList *l0 = tskbar->area.list; if (taskbarname_enabled) l0 = l0->next; for (; l0 ; l0 = l0->next) { - tsk = l0->data; + Task *tsk = l0->data; if (tsk->win == active_task->win) return tsk; } @@ -445,15 +443,13 @@ Task *next_task(Task *tsk) if (tsk == 0) return 0; - GSList *l0, *lfirst_tsk; - Task *tsk1; Taskbar* tskbar = tsk->area.parent; - l0 = tskbar->area.list; + GList *l0 = tskbar->area.list; if (taskbarname_enabled) l0 = l0->next; - lfirst_tsk = l0; + GList *lfirst_tsk = l0; for (; l0 ; l0 = l0->next) { - tsk1 = l0->data; + Task *tsk1 = l0->data; if (tsk1 == tsk) { if (l0->next == 0) l0 = lfirst_tsk; else l0 = l0->next; @@ -469,19 +465,18 @@ Task *prev_task(Task *tsk) if (tsk == 0) return 0; - GSList *l0, *lfirst_tsk; Task *tsk1, *tsk2; Taskbar* tskbar = tsk->area.parent; tsk2 = 0; - l0 = tskbar->area.list; + GList *l0 = tskbar->area.list; if (taskbarname_enabled) l0 = l0->next; - lfirst_tsk = l0; + GList *lfirst_tsk = l0; for (; l0 ; l0 = l0->next) { tsk1 = l0->data; if (tsk1 == tsk) { if (l0 == lfirst_tsk) { - l0 = g_slist_last ( l0 ); + l0 = g_list_last ( l0 ); tsk2 = l0->data; } return tsk2; diff --git a/src/taskbar/taskbar.c b/src/taskbar/taskbar.c index 742e783..9be17f2 100644 --- a/src/taskbar/taskbar.c +++ b/src/taskbar/taskbar.c @@ -47,6 +47,7 @@ int taskbar_distribute_size; int hide_inactive_tasks; int hide_task_diff_monitor; int taskbar_sort_method; +int taskbar_alignment; guint win_hash(gconstpointer key) { return (guint)*((Window*)key); } gboolean win_compare(gconstpointer a, gconstpointer b) { return (*((Window*)a) == *((Window*)b)); } @@ -63,6 +64,7 @@ void default_taskbar() hide_inactive_tasks = 0; hide_task_diff_monitor = 0; taskbar_sort_method = TASKBAR_NOSORT; + taskbar_alignment = ALIGN_LEFT; default_taskbarname(); } @@ -97,7 +99,7 @@ void cleanup_taskbar() } free_area(&tskbar->area); // 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) { free(panel->taskbar); @@ -153,6 +155,7 @@ void init_taskbar_panel(void *p) panel->g_taskbar.area.parent = panel; panel->g_taskbar.area.panel = panel; 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._draw_foreground = draw_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); text_width = panel->g_task.maximum_width; - GSList *l = taskbar->area.list; + GList *l = taskbar->area.list; if (taskbarname_enabled) l = l->next; for (; l != NULL; l = l->next) { 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) 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]) { - GSList *l = tskbar->area.list; + GList *l = tskbar->area.list; if (taskbarname_enabled) l = l->next; for ( ; l ; l = l->next) set_task_redraw(l->data); @@ -511,7 +514,7 @@ int taskbar_needs_sort(Taskbar *taskbar) if (taskbar_sort_method == TASKBAR_NOSORT) 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) { if (compare_tasks(i->data, j->data, taskbar) > 0) { return 1; @@ -528,7 +531,7 @@ void sort_tasks(Taskbar *taskbar) if (!taskbar_needs_sort(taskbar)) { 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; panel_refresh = 1; ((Panel*)taskbar->area.panel)->area.resize = 1; diff --git a/src/taskbar/taskbar.h b/src/taskbar/taskbar.h index 30093fa..ca76314 100644 --- a/src/taskbar/taskbar.h +++ b/src/taskbar/taskbar.h @@ -21,6 +21,7 @@ extern int hide_inactive_tasks; extern int hide_task_diff_monitor; enum { TASKBAR_NOSORT, TASKBAR_SORT_CENTER, TASKBAR_SORT_TITLE }; extern int taskbar_sort_method; +extern int taskbar_alignment; typedef struct { // always start with area diff --git a/src/taskbar/taskbarname.c b/src/taskbar/taskbarname.c index e112779..f7a8821 100644 --- a/src/taskbar/taskbarname.c +++ b/src/taskbar/taskbarname.c @@ -76,7 +76,7 @@ void init_taskbarname_panel(void *p) 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); + tskbar->area.list = g_list_append(tskbar->area.list, &tskbar->bar_name); } for (l=list ; l ; l = l->next) @@ -103,7 +103,7 @@ void cleanup_taskbarname() XFreePixmap(server.dsp, tskbar->bar_name.state_pix[k]); 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); } } diff --git a/src/tint.c b/src/tint.c index e9ca2bb..f8c4dfe 100644 --- a/src/tint.c +++ b/src/tint.c @@ -470,8 +470,8 @@ void event_button_motion_notify (XEvent *e) } else { // Swap the task_drag with the task on the event's location (if they differ) if(event_task && event_task != task_drag) { - GSList * drag_iter = g_slist_find(event_taskbar->area.list, task_drag); - GSList * task_iter = g_slist_find(event_taskbar->area.list, event_task); + GList * drag_iter = g_list_find(event_taskbar->area.list, task_drag); + GList * task_iter = g_list_find(event_taskbar->area.list, event_task); if(drag_iter && task_iter) { gpointer temp = task_iter->data; task_iter->data = drag_iter->data; @@ -488,14 +488,14 @@ void event_button_motion_notify (XEvent *e) return; 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) { 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 - 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') task_drag->area.parent = event_taskbar; @@ -677,10 +677,9 @@ void event_property_notify (XEvent *e) // check ALLDESKTOP task => resize taskbar Taskbar *tskbar; Task *tsk; - GSList *l; if (server.nb_desktop > old_desktop) { tskbar = &panel->taskbar[old_desktop]; - l = tskbar->area.list; + GList *l = tskbar->area.list; if (taskbarname_enabled) l = l->next; for (; l ; l = l->next) { tsk = l->data; @@ -694,7 +693,7 @@ void event_property_notify (XEvent *e) } } tskbar = &panel->taskbar[server.desktop]; - l = tskbar->area.list; + GList *l = tskbar->area.list; if (taskbarname_enabled) l = l->next; for (; l ; l = l->next) { tsk = l->data; diff --git a/src/tint2conf/po/tint2conf.pot b/src/tint2conf/po/tint2conf.pot index 44f5c27..6a175ec 100644 --- a/src/tint2conf/po/tint2conf.pot +++ b/src/tint2conf/po/tint2conf.pot @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: tint2conf 0.12\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-05-21 11:45+0200\n" -"PO-Revision-Date: 2015-05-21 11:45+0200\n" +"PO-Revision-Date: 2015-06-12 00:48+0200\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" @@ -280,7 +280,7 @@ msgstr "" msgid "Position on screen: bottom-right, horizontal panel" msgstr "" -#: ../properties.c:834 ../properties.c:3446 +#: ../properties.c:834 ../properties.c:3464 msgid "Monitor" msgstr "" @@ -288,27 +288,27 @@ msgstr "" msgid "All" msgstr "" -#: ../properties.c:845 ../properties.c:3456 +#: ../properties.c:845 ../properties.c:3474 msgid "1" msgstr "" -#: ../properties.c:846 ../properties.c:3457 +#: ../properties.c:846 ../properties.c:3475 msgid "2" msgstr "" -#: ../properties.c:847 ../properties.c:3458 +#: ../properties.c:847 ../properties.c:3476 msgid "3" msgstr "" -#: ../properties.c:848 ../properties.c:3459 +#: ../properties.c:848 ../properties.c:3477 msgid "4" msgstr "" -#: ../properties.c:849 ../properties.c:3460 +#: ../properties.c:849 ../properties.c:3478 msgid "5" msgstr "" -#: ../properties.c:850 ../properties.c:3461 +#: ../properties.c:850 ../properties.c:3479 msgid "6" msgstr "" @@ -380,15 +380,15 @@ msgid "" "distributed on both sides of the panel." msgstr "" -#: ../properties.c:936 ../properties.c:2019 ../properties.c:2322 -#: ../properties.c:2745 ../properties.c:3259 ../properties.c:3468 -#: ../properties.c:3674 ../properties.c:3832 +#: ../properties.c:936 ../properties.c:2019 ../properties.c:2340 +#: ../properties.c:2763 ../properties.c:3277 ../properties.c:3486 +#: ../properties.c:3692 ../properties.c:3850 msgid "Appearance" msgstr "" -#: ../properties.c:950 ../properties.c:2032 ../properties.c:3096 -#: ../properties.c:3272 ../properties.c:3481 ../properties.c:3687 -#: ../properties.c:3845 +#: ../properties.c:950 ../properties.c:2032 ../properties.c:3114 +#: ../properties.c:3290 ../properties.c:3499 ../properties.c:3705 +#: ../properties.c:3863 msgid "Background" msgstr "" @@ -398,9 +398,9 @@ msgid "" "in the Backgrounds tab." msgstr "" -#: ../properties.c:965 ../properties.c:2046 ../properties.c:2336 -#: ../properties.c:2439 ../properties.c:2836 ../properties.c:3286 -#: ../properties.c:3496 ../properties.c:3701 ../properties.c:3859 +#: ../properties.c:965 ../properties.c:2046 ../properties.c:2354 +#: ../properties.c:2457 ../properties.c:2854 ../properties.c:3304 +#: ../properties.c:3514 ../properties.c:3719 ../properties.c:3877 msgid "Horizontal padding" msgstr "" @@ -410,9 +410,9 @@ msgid "" "border of the panel and the elements inside." msgstr "" -#: ../properties.c:980 ../properties.c:2060 ../properties.c:2351 -#: ../properties.c:2454 ../properties.c:2850 ../properties.c:3300 -#: ../properties.c:3511 ../properties.c:3715 ../properties.c:3873 +#: ../properties.c:980 ../properties.c:2060 ../properties.c:2369 +#: ../properties.c:2472 ../properties.c:2868 ../properties.c:3318 +#: ../properties.c:3529 ../properties.c:3733 ../properties.c:3891 msgid "Vertical padding" msgstr "" @@ -422,8 +422,8 @@ msgid "" "border of the panel and the elements inside." msgstr "" -#: ../properties.c:995 ../properties.c:2074 ../properties.c:2366 -#: ../properties.c:2864 ../properties.c:3526 +#: ../properties.c:995 ../properties.c:2074 ../properties.c:2384 +#: ../properties.c:2882 ../properties.c:3544 msgid "Spacing" msgstr "" @@ -473,8 +473,8 @@ msgid "" "enters the panel." msgstr "" -#: ../properties.c:1078 ../properties.c:1112 ../properties.c:3805 -#: ../properties.c:3824 +#: ../properties.c:1078 ../properties.c:1112 ../properties.c:3823 +#: ../properties.c:3842 msgid "seconds" msgstr "" @@ -710,7 +710,7 @@ msgstr "" msgid "Specifies the spacing between the elements inside the launcher." msgstr "" -#: ../properties.c:2087 ../properties.c:3540 +#: ../properties.c:2087 ../properties.c:3558 msgid "Icon size" msgstr "" @@ -718,7 +718,7 @@ msgstr "" msgid "Specifies the size of the launcher icons, in pixels." msgstr "" -#: ../properties.c:2101 ../properties.c:3060 ../properties.c:3554 +#: ../properties.c:2101 ../properties.c:3078 ../properties.c:3572 msgid "Icon opacity" msgstr "" @@ -726,7 +726,7 @@ msgstr "" msgid "Specifies the opacity of the launcher icons, in percent." msgstr "" -#: ../properties.c:2115 ../properties.c:3070 ../properties.c:3568 +#: ../properties.c:2115 ../properties.c:3088 ../properties.c:3586 msgid "Icon saturation" msgstr "" @@ -734,7 +734,7 @@ msgstr "" msgid "Specifies the saturation adjustment of the launcher icons, in percent." msgstr "" -#: ../properties.c:2129 ../properties.c:3080 ../properties.c:3582 +#: ../properties.c:2129 ../properties.c:3098 ../properties.c:3600 msgid "Icon brightness" msgstr "" @@ -785,7 +785,7 @@ msgid "" "moved over an application launcher." msgstr "" -#: ../properties.c:2228 ../properties.c:3409 +#: ../properties.c:2228 ../properties.c:3427 msgid "Options" msgstr "" @@ -833,8 +833,8 @@ msgstr "" msgid "Task sorting" msgstr "" -#: ../properties.c:2311 ../properties.c:2574 ../properties.c:2610 -#: ../properties.c:2646 ../properties.c:2682 ../properties.c:2718 +#: ../properties.c:2311 ../properties.c:2592 ../properties.c:2628 +#: ../properties.c:2664 ../properties.c:2700 ../properties.c:2736 msgid "None" msgstr "" @@ -856,165 +856,185 @@ msgid "" "centers." msgstr "" -#: ../properties.c:2346 +#: ../properties.c:2322 +msgid "Task alignment" +msgstr "" + +#: ../properties.c:2332 +msgid "Left" +msgstr "" + +#: ../properties.c:2333 +msgid "Center" +msgstr "" + +#: ../properties.c:2334 +msgid "Right" +msgstr "" + +#: ../properties.c:2336 +msgid "Specifies how tasks should be positioned on the taskbar." +msgstr "" + +#: ../properties.c:2364 msgid "" "Specifies the horizontal padding of the taskbar. This is the space between " "the border and the elements inside." msgstr "" -#: ../properties.c:2361 +#: ../properties.c:2379 msgid "" "Specifies the vertical padding of the taskbar. This is the space between the " "border and the elements inside." msgstr "" -#: ../properties.c:2376 +#: ../properties.c:2394 msgid "Specifies the spacing between the elements inside the taskbar." msgstr "" -#: ../properties.c:2380 ../properties.c:2514 +#: ../properties.c:2398 ../properties.c:2532 msgid "Active background" msgstr "" -#: ../properties.c:2390 +#: ../properties.c:2408 msgid "" "Selects the background used to display the taskbar of the current desktop. " "Backgrounds can be edited in the Backgrounds tab." msgstr "" -#: ../properties.c:2394 ../properties.c:2529 +#: ../properties.c:2412 ../properties.c:2547 msgid "Inactive background" msgstr "" -#: ../properties.c:2404 +#: ../properties.c:2422 msgid "" "Selects the background used to display taskbars of inactive desktops. " "Backgrounds can be edited in the Backgrounds tab." msgstr "" -#: ../properties.c:2409 +#: ../properties.c:2427 msgid "Desktop name" msgstr "" -#: ../properties.c:2424 +#: ../properties.c:2442 msgid "Show desktop name" msgstr "" -#: ../properties.c:2434 +#: ../properties.c:2452 msgid "" "If enabled, displays the name of the desktop at the top/left of the taskbar. " "The name is set by your window manager; you might be able to configure it " "there." msgstr "" -#: ../properties.c:2449 +#: ../properties.c:2467 msgid "" "Specifies the horizontal padding of the desktop name. This is the space " "between the border and the text inside." msgstr "" -#: ../properties.c:2464 +#: ../properties.c:2482 msgid "" "Specifies the vertical padding of the desktop name. This is the space " "between the border and the text inside." msgstr "" -#: ../properties.c:2469 +#: ../properties.c:2487 msgid "Active font color" msgstr "" -#: ../properties.c:2480 +#: ../properties.c:2498 msgid "" "Specifies the font color used to display the name of the current desktop." msgstr "" -#: ../properties.c:2484 +#: ../properties.c:2502 msgid "Inactive font color" msgstr "" -#: ../properties.c:2495 +#: ../properties.c:2513 msgid "Specifies the font color used to display the name of inactive desktops." msgstr "" -#: ../properties.c:2499 ../properties.c:2877 ../properties.c:3887 +#: ../properties.c:2517 ../properties.c:2895 ../properties.c:3905 msgid "Font" msgstr "" -#: ../properties.c:2510 +#: ../properties.c:2528 msgid "Specifies the font used to display the desktop name." msgstr "" -#: ../properties.c:2524 +#: ../properties.c:2542 msgid "" "Selects the background used to display the name of the current desktop. " "Backgrounds can be edited in the Backgrounds tab." msgstr "" -#: ../properties.c:2539 +#: ../properties.c:2557 msgid "" "Selects the background used to display the name of inactive desktops. " "Backgrounds can be edited in the Backgrounds tab." msgstr "" -#: ../properties.c:2551 ../properties.c:3215 +#: ../properties.c:2569 ../properties.c:3233 msgid "Mouse events" msgstr "" -#: ../properties.c:2564 +#: ../properties.c:2582 msgid "Left click" msgstr "" -#: ../properties.c:2575 ../properties.c:2611 ../properties.c:2647 -#: ../properties.c:2683 ../properties.c:2719 +#: ../properties.c:2593 ../properties.c:2629 ../properties.c:2665 +#: ../properties.c:2701 ../properties.c:2737 msgid "Close" msgstr "" -#: ../properties.c:2576 ../properties.c:2612 ../properties.c:2648 -#: ../properties.c:2684 ../properties.c:2720 +#: ../properties.c:2594 ../properties.c:2630 ../properties.c:2666 +#: ../properties.c:2702 ../properties.c:2738 msgid "Toggle" msgstr "" -#: ../properties.c:2577 ../properties.c:2613 ../properties.c:2649 -#: ../properties.c:2685 ../properties.c:2721 +#: ../properties.c:2595 ../properties.c:2631 ../properties.c:2667 +#: ../properties.c:2703 ../properties.c:2739 msgid "Iconify" msgstr "" -#: ../properties.c:2578 ../properties.c:2614 ../properties.c:2686 -#: ../properties.c:2722 +#: ../properties.c:2596 ../properties.c:2632 ../properties.c:2704 +#: ../properties.c:2740 msgid "Shade" msgstr "" -#: ../properties.c:2579 ../properties.c:2615 ../properties.c:2651 -#: ../properties.c:2687 ../properties.c:2723 +#: ../properties.c:2597 ../properties.c:2633 ../properties.c:2669 +#: ../properties.c:2705 ../properties.c:2741 msgid "Toggle or iconify" msgstr "" -#: ../properties.c:2580 ../properties.c:2616 ../properties.c:2652 -#: ../properties.c:2688 ../properties.c:2724 +#: ../properties.c:2598 ../properties.c:2634 ../properties.c:2670 +#: ../properties.c:2706 ../properties.c:2742 msgid "Maximize or restore" msgstr "" -#: ../properties.c:2581 ../properties.c:2617 ../properties.c:2653 -#: ../properties.c:2689 ../properties.c:2725 +#: ../properties.c:2599 ../properties.c:2635 ../properties.c:2671 +#: ../properties.c:2707 ../properties.c:2743 msgid "Desktop left" msgstr "" -#: ../properties.c:2582 ../properties.c:2618 ../properties.c:2654 -#: ../properties.c:2690 ../properties.c:2726 +#: ../properties.c:2600 ../properties.c:2636 ../properties.c:2672 +#: ../properties.c:2708 ../properties.c:2744 msgid "Desktop right" msgstr "" -#: ../properties.c:2583 ../properties.c:2619 ../properties.c:2655 -#: ../properties.c:2691 ../properties.c:2727 +#: ../properties.c:2601 ../properties.c:2637 ../properties.c:2673 +#: ../properties.c:2709 ../properties.c:2745 msgid "Next task" msgstr "" -#: ../properties.c:2584 ../properties.c:2620 ../properties.c:2656 -#: ../properties.c:2692 ../properties.c:2728 +#: ../properties.c:2602 ../properties.c:2638 ../properties.c:2674 +#: ../properties.c:2710 ../properties.c:2746 msgid "Previous task" msgstr "" -#: ../properties.c:2586 +#: ../properties.c:2604 msgid "" "Specifies the action performed when task buttons receive a left click " "event: \n" @@ -1031,11 +1051,11 @@ msgid "" "'Previous task' sends the focus to the previous task." msgstr "" -#: ../properties.c:2600 +#: ../properties.c:2618 msgid "Wheel scroll up" msgstr "" -#: ../properties.c:2622 +#: ../properties.c:2640 msgid "" "Specifies the action performed when task buttons receive a scroll up " "event: \n" @@ -1052,15 +1072,15 @@ msgid "" "'Previous task' sends the focus to the previous task." msgstr "" -#: ../properties.c:2636 +#: ../properties.c:2654 msgid "Middle click" msgstr "" -#: ../properties.c:2650 +#: ../properties.c:2668 msgid "sShade" msgstr "" -#: ../properties.c:2658 +#: ../properties.c:2676 msgid "" "Specifies the action performed when task buttons receive a middle click " "event: \n" @@ -1077,11 +1097,11 @@ msgid "" "'Previous task' sends the focus to the previous task." msgstr "" -#: ../properties.c:2672 +#: ../properties.c:2690 msgid "Wheel scroll down" msgstr "" -#: ../properties.c:2694 +#: ../properties.c:2712 msgid "" "Specifies the action performed when task buttons receive a scroll down " "event: \n" @@ -1098,11 +1118,11 @@ msgid "" "'Previous task' sends the focus to the previous task." msgstr "" -#: ../properties.c:2708 +#: ../properties.c:2726 msgid "Right click" msgstr "" -#: ../properties.c:2730 +#: ../properties.c:2748 msgid "" "Specifies the action performed when task buttons receive a right click " "event: \n" @@ -1119,299 +1139,299 @@ msgid "" "'Previous task' sends the focus to the previous task." msgstr "" -#: ../properties.c:2758 +#: ../properties.c:2776 msgid "Show icon" msgstr "" -#: ../properties.c:2768 +#: ../properties.c:2786 msgid "If enabled, the window icon is shown on task buttons." msgstr "" -#: ../properties.c:2771 +#: ../properties.c:2789 msgid "Show text" msgstr "" -#: ../properties.c:2781 +#: ../properties.c:2799 msgid "If enabled, the window title is shown on task buttons." msgstr "" -#: ../properties.c:2784 +#: ../properties.c:2802 msgid "Center text" msgstr "" -#: ../properties.c:2794 +#: ../properties.c:2812 msgid "" "If enabled, the text is centered on task buttons. Otherwise, it is left-" "aligned." msgstr "" -#: ../properties.c:2797 +#: ../properties.c:2815 msgid "Show tooltips" msgstr "" -#: ../properties.c:2807 +#: ../properties.c:2825 msgid "" "If enabled, a tooltip showing the window title is displayed when the mouse " "cursor moves over task buttons." msgstr "" -#: ../properties.c:2810 +#: ../properties.c:2828 msgid "Maximum width" msgstr "" -#: ../properties.c:2820 +#: ../properties.c:2838 msgid "Specifies the maximum width of the task buttons." msgstr "" -#: ../properties.c:2823 +#: ../properties.c:2841 msgid "Maximum height" msgstr "" -#: ../properties.c:2833 +#: ../properties.c:2851 msgid "Specifies the maximum height of the task buttons." msgstr "" -#: ../properties.c:2846 +#: ../properties.c:2864 msgid "" "Specifies the horizontal padding of the task buttons. This is the space " "between the border and the content inside." msgstr "" -#: ../properties.c:2860 +#: ../properties.c:2878 msgid "" "Specifies the vertical padding of the task buttons. This is the space " "between the border and the content inside." msgstr "" -#: ../properties.c:2874 +#: ../properties.c:2892 msgid "Specifies the spacing between the icon and the text." msgstr "" -#: ../properties.c:2888 +#: ../properties.c:2906 msgid "Specifies the font used to display the task button text." msgstr "" -#: ../properties.c:2898 +#: ../properties.c:2916 msgid "Default style" msgstr "" -#: ../properties.c:2908 +#: ../properties.c:2926 msgid "Normal task" msgstr "" -#: ../properties.c:2918 +#: ../properties.c:2936 msgid "Active task" msgstr "" -#: ../properties.c:2928 +#: ../properties.c:2946 msgid "Urgent task" msgstr "" -#: ../properties.c:2938 +#: ../properties.c:2956 msgid "Iconified task" msgstr "" -#: ../properties.c:3041 +#: ../properties.c:3059 msgid "If enabled, a custom font color is used to display the task text." msgstr "" -#: ../properties.c:3043 ../properties.c:3342 ../properties.c:3757 -#: ../properties.c:3901 +#: ../properties.c:3061 ../properties.c:3360 ../properties.c:3775 +#: ../properties.c:3919 msgid "Font color" msgstr "" -#: ../properties.c:3052 +#: ../properties.c:3070 msgid "Specifies the font color used to display the task text." msgstr "" -#: ../properties.c:3058 +#: ../properties.c:3076 msgid "" "If enabled, a custom opacity/saturation/brightness is used to display the " "task icon." msgstr "" -#: ../properties.c:3068 +#: ../properties.c:3086 msgid "Specifies the opacity (in %) used to display the task icon." msgstr "" -#: ../properties.c:3078 +#: ../properties.c:3096 msgid "" "Specifies the saturation adjustment (in %) used to display the task icon." msgstr "" -#: ../properties.c:3088 +#: ../properties.c:3106 msgid "" "Specifies the brightness adjustment (in %) used to display the task icon." msgstr "" -#: ../properties.c:3094 +#: ../properties.c:3112 msgid "If enabled, a custom background is used to display the task." msgstr "" -#: ../properties.c:3104 +#: ../properties.c:3122 msgid "" "Selects the background used to display the task. Backgrounds can be edited " "in the Backgrounds tab." msgstr "" -#: ../properties.c:3108 +#: ../properties.c:3126 msgid "Blinks" msgstr "" -#: ../properties.c:3116 +#: ../properties.c:3134 msgid "Specifies how many times urgent tasks blink." msgstr "" -#: ../properties.c:3138 +#: ../properties.c:3156 msgid "Format" msgstr "" -#: ../properties.c:3150 +#: ../properties.c:3168 msgid "First line format" msgstr "" -#: ../properties.c:3162 +#: ../properties.c:3180 msgid "" "Specifies the format used to display the first line of the clock text. See " "'man strftime' for all the available options." msgstr "" -#: ../properties.c:3166 +#: ../properties.c:3184 msgid "Second line format" msgstr "" -#: ../properties.c:3178 +#: ../properties.c:3196 msgid "" "Specifies the format used to display the second line of the clock text. See " "'man strftime' for all the available options." msgstr "" -#: ../properties.c:3182 +#: ../properties.c:3200 msgid "First line timezone" msgstr "" -#: ../properties.c:3194 +#: ../properties.c:3212 msgid "" "Specifies the timezone used to display the first line of the clock text. If " "empty, the current timezone is used. Otherwise, it must be set to a valid " "value of the TZ environment variable." msgstr "" -#: ../properties.c:3198 +#: ../properties.c:3216 msgid "Second line timezone" msgstr "" -#: ../properties.c:3210 +#: ../properties.c:3228 msgid "" "Specifies the timezone used to display the second line of the clock text. If " "empty, the current timezone is used. Otherwise, it must be set to a valid " "value of the TZ environment variable." msgstr "" -#: ../properties.c:3228 +#: ../properties.c:3246 msgid "Left click command" msgstr "" -#: ../properties.c:3240 +#: ../properties.c:3258 msgid "" "Specifies a command that will be executed when the clock receives a left " "click." msgstr "" -#: ../properties.c:3243 +#: ../properties.c:3261 msgid "Right click command" msgstr "" -#: ../properties.c:3255 +#: ../properties.c:3273 msgid "" "Specifies a command that will be executed when the clock receives a right " "click." msgstr "" -#: ../properties.c:3282 +#: ../properties.c:3300 msgid "" "Selects the background used to display the clock. Backgrounds can be edited " "in the Backgrounds tab." msgstr "" -#: ../properties.c:3296 +#: ../properties.c:3314 msgid "" "Specifies the horizontal padding of the clock. This is the space between the " "border and the content inside." msgstr "" -#: ../properties.c:3310 +#: ../properties.c:3328 msgid "" "Specifies the vertical padding of the clock. This is the space between the " "border and the content inside." msgstr "" -#: ../properties.c:3314 ../properties.c:3729 +#: ../properties.c:3332 ../properties.c:3747 msgid "Font first line" msgstr "" -#: ../properties.c:3325 +#: ../properties.c:3343 msgid "Specifies the font used to display the first line of the clock." msgstr "" -#: ../properties.c:3328 ../properties.c:3743 +#: ../properties.c:3346 ../properties.c:3761 msgid "Font second line" msgstr "" -#: ../properties.c:3339 +#: ../properties.c:3357 msgid "Specifies the font used to display the second line of the clock." msgstr "" -#: ../properties.c:3353 +#: ../properties.c:3371 msgid "Specifies the font color used to display the clock." msgstr "" -#: ../properties.c:3357 +#: ../properties.c:3375 msgid "Tooltip" msgstr "" -#: ../properties.c:3370 +#: ../properties.c:3388 msgid "Format" msgstr "" -#: ../properties.c:3381 +#: ../properties.c:3399 msgid "" "Specifies the format used to display the clock tooltip. See 'man strftime' " "for the available options." msgstr "" -#: ../properties.c:3385 +#: ../properties.c:3403 msgid "Timezone" msgstr "" -#: ../properties.c:3396 +#: ../properties.c:3414 msgid "" "Specifies the timezone used to display the clock tooltip. If empty, the " "current timezone is used. Otherwise, it must be set to a valid value of the " "TZ environment variable." msgstr "" -#: ../properties.c:3423 +#: ../properties.c:3441 msgid "Icon ordering" msgstr "" -#: ../properties.c:3433 +#: ../properties.c:3451 msgid "Ascending" msgstr "" -#: ../properties.c:3434 +#: ../properties.c:3452 msgid "Descending" msgstr "" -#: ../properties.c:3435 +#: ../properties.c:3453 msgid "Left to right" msgstr "" -#: ../properties.c:3436 +#: ../properties.c:3454 msgid "Right to left" msgstr "" -#: ../properties.c:3438 +#: ../properties.c:3456 msgid "" "Specifies the order used to arrange the system tray icons. \n" "'Ascending' means that icons are sorted in ascending order of their window " @@ -1422,162 +1442,162 @@ msgid "" "'Right to left' means that icons are always added to the right." msgstr "" -#: ../properties.c:3463 +#: ../properties.c:3481 msgid "" "Specifies the monitor on which to place the system tray. Due to technical " "limitations, the system tray cannot be displayed on multiple monitors." msgstr "" -#: ../properties.c:3491 +#: ../properties.c:3509 msgid "" "Selects the background used to display the system tray. Backgrounds can be " "edited in the Backgrounds tab." msgstr "" -#: ../properties.c:3506 +#: ../properties.c:3524 msgid "" "Specifies the horizontal padding of the system tray. This is the space " "between the border and the content inside." msgstr "" -#: ../properties.c:3521 +#: ../properties.c:3539 msgid "" "Specifies the vertical padding of the system tray. This is the space between " "the border and the content inside." msgstr "" -#: ../properties.c:3536 +#: ../properties.c:3554 msgid "Specifies the spacing between system tray icons." msgstr "" -#: ../properties.c:3550 +#: ../properties.c:3568 msgid "Specifies the size of the system tray icons, in pixels." msgstr "" -#: ../properties.c:3564 +#: ../properties.c:3582 msgid "Specifies the opacity of the system tray icons, in percent." msgstr "" -#: ../properties.c:3578 +#: ../properties.c:3596 msgid "" "Specifies the saturation adjustment of the system tray icons, in percent." msgstr "" -#: ../properties.c:3592 +#: ../properties.c:3610 msgid "" "Specifies the brightness adjustment of the system tray icons, in percent." msgstr "" -#: ../properties.c:3608 +#: ../properties.c:3626 msgid "Thresholds" msgstr "" -#: ../properties.c:3621 +#: ../properties.c:3639 msgid "Hide if charge higher than" msgstr "" -#: ../properties.c:3631 +#: ../properties.c:3649 msgid "" "Minimum battery level for which to hide the batter applet. Use 101 to always " "show the batter applet." msgstr "" -#: ../properties.c:3633 ../properties.c:3652 +#: ../properties.c:3651 ../properties.c:3670 msgid "%" msgstr "" -#: ../properties.c:3640 +#: ../properties.c:3658 msgid "Alert if charge lower than" msgstr "" -#: ../properties.c:3650 +#: ../properties.c:3668 msgid "Battery level for which to display an alert." msgstr "" -#: ../properties.c:3659 +#: ../properties.c:3677 msgid "Alert command" msgstr "" -#: ../properties.c:3670 +#: ../properties.c:3688 msgid "Command to be executed when the alert threshold is reached." msgstr "" -#: ../properties.c:3697 +#: ../properties.c:3715 msgid "" "Selects the background used to display the battery. Backgrounds can be " "edited in the Backgrounds tab." msgstr "" -#: ../properties.c:3711 +#: ../properties.c:3729 msgid "" "Specifies the horizontal padding of the battery. This is the space between " "the border and the content inside." msgstr "" -#: ../properties.c:3725 +#: ../properties.c:3743 msgid "" "Specifies the vertical padding of the battery. This is the space between the " "border and the content inside." msgstr "" -#: ../properties.c:3740 +#: ../properties.c:3758 msgid "Specifies the font used to display the first line of the battery text." msgstr "" -#: ../properties.c:3754 +#: ../properties.c:3772 msgid "Specifies the font used to display the second line of the battery text." msgstr "" -#: ../properties.c:3768 +#: ../properties.c:3786 msgid "Specifies the font clor used to display the battery text." msgstr "" -#: ../properties.c:3780 +#: ../properties.c:3798 msgid "Timing" msgstr "" -#: ../properties.c:3793 +#: ../properties.c:3811 msgid "Show delay" msgstr "" -#: ../properties.c:3803 +#: ../properties.c:3821 msgid "" "Specifies a delay after which to show the tooltip when moving the mouse over " "an element." msgstr "" -#: ../properties.c:3812 +#: ../properties.c:3830 msgid "Hide delay" msgstr "" -#: ../properties.c:3821 +#: ../properties.c:3839 msgid "" "Specifies a delay after which to hide the tooltip when moving the mouse " "outside an element." msgstr "" -#: ../properties.c:3855 +#: ../properties.c:3873 msgid "" "Selects the background used to display the tooltip. Backgrounds can be " "edited in the Backgrounds tab." msgstr "" -#: ../properties.c:3869 +#: ../properties.c:3887 msgid "" "Specifies the horizontal padding of the tooltip. This is the space between " "the border and the content inside." msgstr "" -#: ../properties.c:3883 +#: ../properties.c:3901 msgid "" "Specifies the vertical padding of the tooltip. This is the space between the " "border and the content inside." msgstr "" -#: ../properties.c:3898 +#: ../properties.c:3916 msgid "Specifies the font used to display the text of the tooltip." msgstr "" -#: ../properties.c:3912 +#: ../properties.c:3930 msgid "Specifies the font color used to display the text of the tooltip." msgstr "" diff --git a/src/tint2conf/properties.c b/src/tint2conf/properties.c index d2d79a1..ab47b73 100644 --- a/src/tint2conf/properties.c +++ b/src/tint2conf/properties.c @@ -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_active_background, *taskbar_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 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 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); label = gtk_label_new(_("Appearance")); diff --git a/src/tint2conf/properties.h b/src/tint2conf/properties.h index 16bb553..c299abe 100644 --- a/src/tint2conf/properties.h +++ b/src/tint2conf/properties.h @@ -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_active_background, *taskbar_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 extern GtkWidget *task_mouse_left, *task_mouse_middle, *task_mouse_right, *task_mouse_scroll_up, *task_mouse_scroll_down; diff --git a/src/tint2conf/properties_rw.c b/src/tint2conf/properties_rw.c index ec72ebe..ee01652 100644 --- a/src/tint2conf/properties_rw.c +++ b/src/tint2conf/properties_rw.c @@ -272,6 +272,16 @@ void config_write_taskbar(FILE *fp) } 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"); } @@ -998,6 +1008,16 @@ void add_entry(char *key, char *value) else 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) { extract_values(value, &value1, &value2, &value3); gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_padding_x), atoi(value1)); diff --git a/src/util/area.c b/src/util/area.c index 20af792..d37960f 100644 --- a/src/util/area.c +++ b/src/util/area.c @@ -76,7 +76,7 @@ void init_rendering(void *obj, int pos) Area *a = (Area*)obj; // initialize fixed position/size - GSList *l; + GList *l; for (l = a->list; l ; l = l->next) { Area *child = ((Area*)l->data); if (panel_horizontal) { @@ -102,7 +102,7 @@ void rendering(void *obj) Panel *panel = (Panel*)obj; size_by_content(&panel->area); - size_by_layout(&panel->area, 0, 1); + size_by_layout(&panel->area, 1); refresh(&panel->area); } @@ -111,10 +111,11 @@ void rendering(void *obj) void size_by_content (Area *a) { // don't resize hiden objects - if (!a->on_screen) return; + if (!a->on_screen) + return; // children node are resized before its parent - GSList *l; + GList *l; for (l = a->list; l ; l = l->next) 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 - if (!a->on_screen) return; + if (!a->on_screen) + return; // parent node is resized before its children // calculate area's size - GSList *l; + GList *l; if (a->resize && a->size_mode == SIZE_BY_LAYOUT) { a->resize = 0; @@ -156,40 +158,103 @@ void size_by_layout (Area *a, int pos, int level) } } - // update position of childs - pos += a->paddingxlr + a->bg->border.width; - int i=0; - for (l = a->list; l ; l = l->next) { - Area *child = ((Area*)l->data); - if (!child->on_screen) continue; - i++; - - if (panel_horizontal) { - if (pos != child->posx) { - // pos changed => redraw - child->posx = pos; - child->on_changed = 1; + // update position of children + if (a->list) { + if (a->alignment == ALIGN_LEFT) { + int pos = (panel_horizontal ? a->posx : a->posy) + a->bg->border.width + a->paddingxlr; + + 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 (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) { // pos/size changed @@ -209,7 +274,7 @@ void refresh (Area *a) if (a->redraw) { a->redraw = 0; // force redraw of child - //GSList *l; + //GList *l; //for (l = a->list ; l ; l = l->next) //((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); // and then refresh child object - GSList *l; + GList *l; for (l = a->list; l ; l = l->next) refresh(l->data); } @@ -236,7 +301,7 @@ int resize_by_layout(void *obj, int maximum_size) if (panel_horizontal) { // detect free size for SIZE_BY_LAYOUT's Area size = a->width - (2 * (a->paddingxlr + a->bg->border.width)); - GSList *l; + GList *l; for (l = a->list ; l ; l = l->next) { child = (Area*)l->data; if (child->on_screen && child->size_mode == SIZE_BY_CONTENT) { @@ -278,7 +343,7 @@ int resize_by_layout(void *obj, int maximum_size) else { // detect free size for SIZE_BY_LAYOUT's Area size = a->height - (2 * (a->paddingxlr + a->bg->border.width)); - GSList *l; + GList *l; for (l = a->list ; l ; l = l->next) { child = (Area*)l->data; 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) 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) { height = 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) { child = (Area*)l->data; if (child->on_screen && child->size_mode == SIZE_BY_LAYOUT) { - old_height = child->height; + int old_height = child->height; child->height = height; if (modulo) { child->height++; @@ -324,7 +389,7 @@ void set_redraw (Area *a) { a->redraw = 1; - GSList *l; + GList *l; for (l = a->list ; l ; l = l->next) set_redraw(l->data); } @@ -438,7 +503,7 @@ void remove_area (Area *a) { Area *parent = (Area*)a->parent; - parent->list = g_slist_remove(parent->list, a); + parent->list = g_list_remove(parent->list, a); set_redraw (parent); } @@ -448,7 +513,7 @@ void add_area (Area *a) { Area *parent = (Area*)a->parent; - parent->list = g_slist_append(parent->list, a); + parent->list = g_list_append(parent->list, a); set_redraw (parent); } @@ -459,12 +524,12 @@ void free_area (Area *a) if (!a) return; - GSList *l0; + GList *l0; for (l0 = a->list; l0 ; l0 = l0->next) free_area (l0->data); if (a->list) { - g_slist_free(a->list); + g_list_free(a->list); a->list = 0; } if (a->pix) { diff --git a/src/util/area.h b/src/util/area.h index da437aa..1907586 100644 --- a/src/util/area.h +++ b/src/util/area.h @@ -51,6 +51,7 @@ typedef struct // SIZE_BY_LAYOUT objects : taskbar and task // SIZE_BY_CONTENT objects : clock, battery, launcher, systray enum { SIZE_BY_LAYOUT, SIZE_BY_CONTENT }; +enum { ALIGN_LEFT = 0, ALIGN_CENTER = 1, ALIGN_RIGHT = 2 }; typedef struct { // coordinate relative to panel window @@ -61,13 +62,15 @@ typedef struct { Background *bg; // list of child : Area object - GSList *list; + GList *list; // object visible on screen. // An object (like systray) could be enabled but hidden (because no tray icon). int on_screen; // way to calculate the size (SIZE_BY_CONTENT or SIZE_BY_LAYOUT) int size_mode; + + int alignment; // need to calculate position and width int resize; // need redraw Pixmap @@ -96,7 +99,7 @@ void init_rendering(void *obj, int pos); void rendering(void *obj); 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 void refresh (Area *a);