summaryrefslogtreecommitdiff
path: root/community/tint2/src-task-align.patch
diff options
context:
space:
mode:
Diffstat (limited to 'community/tint2/src-task-align.patch')
-rw-r--r--community/tint2/src-task-align.patch115
1 files changed, 115 insertions, 0 deletions
diff --git a/community/tint2/src-task-align.patch b/community/tint2/src-task-align.patch
new file mode 100644
index 000000000..937725b67
--- /dev/null
+++ b/community/tint2/src-task-align.patch
@@ -0,0 +1,115 @@
+Index: trunk/src/panel.h
+===================================================================
+--- trunk/src/panel.h (revision 639)
++++ trunk/src/panel.h (working copy)
+@@ -61,6 +61,9 @@
+ extern int panel_strut_policy;
+ extern char *panel_items_order;
+
++// tasks alignment
++enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT };
++
+ extern int max_tick_urgent;
+
+ extern GArray* backgrounds;
+Index: src/config.c
+===================================================================
+--- trunk/src/config.c (revision 639)
++++ trunk/src/config.c (working copy)
+@@ -484,6 +484,14 @@
+ if (value2) panel_config.g_task.area.paddingy = atoi (value2);
+ if (value3) panel_config.g_task.area.paddingx = atoi (value3);
+ }
++ else if (strcmp (key, "task_align") == 0) {
++ extract_values(value, &value1, &value2, &value3);
++ printf("task_align: %s\n", value1);
++ if (strcmp (value1, "left") == 0) panel_config.g_task.align = ALIGN_LEFT;
++ else if (strcmp (value1, "center") == 0) panel_config.g_task.align = ALIGN_CENTER;
++ else if (strcmp (value1, "right") == 0) panel_config.g_task.align = ALIGN_RIGHT;
++ else fprintf(stderr, "Unknown value for task_align: %s\n", value1);
++ }
+ else if (strcmp (key, "task_font") == 0) {
+ panel_config.g_task.font_desc = pango_font_description_from_string (value);
+ }
+Index: trunk/src/taskbar/task.h
+===================================================================
+--- trunk/src/taskbar/task.h (revision 639)
++++ trunk/src/taskbar/task.h (working copy)
+@@ -26,6 +26,7 @@
+ int text;
+ int icon;
+ int centered;
++ int align;
+
+ int icon_posy;
+ int icon_size1;
+Index: trunk/src/util/area.c
+===================================================================
+--- trunk/src/util/area.c (revision 639)
++++ trunk/src/util/area.c (working copy)
+@@ -130,6 +130,54 @@
+ }
+
+
++// calculate total size of all children including
++// parent's padding
++int children_size(Area *a, int horizontal)
++{
++ int size = 0;
++ GSList *l;
++
++ for (l = a->list; l; l = l->next) {
++ Area *child = ((Area*)l->data);
++ if (!child->on_screen) continue;
++
++ if (horizontal)
++ size += child->width + a->paddingx;
++ else
++ size += child->height + a->paddingy;
++ }
++
++ return size;
++}
++
++
++// calculate chilren's align offset depending on the align type
++int align_offset(Area *a, int align, int horizontal)
++{
++ int size = 0;
++ int child_size = children_size(a, horizontal);
++
++ if (horizontal)
++ size = a->width;
++ else
++ size = a->height;
++
++ switch (align) {
++ case ALIGN_LEFT:
++ return 0;
++
++ case ALIGN_CENTER:
++ return (size - child_size) / 2;
++
++ case ALIGN_RIGHT:
++ return size - child_size;
++
++ default:
++ return 0;
++ }
++}
++
++
+ void size_by_layout (Area *a, int pos, int level)
+ {
+ // don't resize hiden objects
+@@ -179,7 +227,9 @@
+ 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);
++
++ int offset = align_offset(child, panel_config.g_task.align, panel_horizontal);
++ size_by_layout(child, pos + offset, level + 1);
+
+ if (panel_horizontal)
+ pos += child->width + a->paddingx;