]> Dogcows Code - chaz/tint2/commitdiff
sample-task-align.patch, src-task-align.patch
authorYuri Bochkarev <baltazar.bz@gmail.com>
Wed, 27 Mar 2013 17:26:53 +0000 (11:26 -0600)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Wed, 27 Mar 2013 17:35:15 +0000 (11:35 -0600)
http://code.google.com/p/tint2/issues/detail?id=359

13 files changed:
sample/icon_and_text_1.tint2rc
sample/icon_and_text_2.tint2rc
sample/icon_and_text_4.tint2rc
sample/icon_only_1.tint2rc
sample/icon_only_2.tint2rc
sample/icon_only_3.tint2rc
sample/icon_only_4.tint2rc
sample/icon_only_6.tint2rc
sample/icon_only_7.tint2rc
src/config.c
src/panel.h
src/taskbar/task.h
src/util/area.c

index e866de4657712b96f00008e729ef678a79da24d9..6368136b45de6297483f0fb96b66b28075087719 100644 (file)
@@ -23,7 +23,8 @@ border_color = #FFFFFF 69
 
 # Panel
 panel_monitor = all
-panel_position = bottom center horizontal
+#panel_position = bottom center horizontal
+panel_position = top center horizontal
 panel_size = 94% 30
 panel_margin = 0 0
 panel_padding = 7 0 7
@@ -57,6 +58,7 @@ task_active_background_id = 2
 task_urgent_background_id = 2
 task_iconified_background_id = 3
 task_tooltip = 0
+task_align = right
 
 # Task Icons
 task_icon_asb = 70 0 0
@@ -115,4 +117,4 @@ battery_font_color = #FFFFFF 75
 battery_padding = 1 0
 battery_background_id = 0
 
-# End of config
\ No newline at end of file
+# End of config
index c30f43d1d592e3e572d5627019135c2bd4d20d57..8b522e6065d564a94147fb96ca618fb761bff92e 100644 (file)
@@ -23,7 +23,8 @@ border_color = #FFFFFF 69
 
 # Panel
 panel_monitor = all
-panel_position = bottom center horizontal
+#panel_position = bottom center horizontal
+panel_position = top center horizontal
 panel_size = 98% 28
 panel_margin = 0 5
 panel_padding = 3 0 3
@@ -57,6 +58,7 @@ task_active_background_id = 2
 task_urgent_background_id = 2
 task_iconified_background_id = 3
 task_tooltip = 0
+task_align = right
 
 # Task Icons
 task_icon_asb = 80 0 0
@@ -114,4 +116,4 @@ battery_font_color = #FFFFFF 75
 battery_padding = 1 0
 battery_background_id = 0
 
-# End of config
\ No newline at end of file
+# End of config
index 0dcabd76c092a0d9abda39df2696a5b0d251a1c6..95c054eb7d080ff6eecded8da0c5a234b30766d1 100644 (file)
@@ -29,7 +29,8 @@ border_color = #FFFFFF 20
 
 # Panel
 panel_monitor = all
-panel_position = bottom center horizontal
+#panel_position = bottom center horizontal
+panel_position = top center horizontal
 panel_size = 92% 28
 panel_margin = 0 0
 panel_padding = 7 0 7
@@ -120,4 +121,4 @@ battery_font_color = #FFFFFF 75
 battery_padding = 1 0
 battery_background_id = 1
 
-# End of config
\ No newline at end of file
+# End of config
index 7708b5892919fa0a0972d138f48498c466c19510..6d7bcd5f9b916c5469cda14a890dc78354ac035e 100644 (file)
@@ -75,6 +75,8 @@ task_active_background_id = 5
 task_urgent_background_id = 6
 task_iconified_background_id = 0
 task_tooltip = 1
+#task_align = center
+task_align = right
 
 # Task Icons
 task_icon_asb = 100 -25 -8
@@ -134,4 +136,4 @@ battery_font_color = #FFFFFF 75
 battery_padding = 2 0
 battery_background_id = 0
 
-# End of config
\ No newline at end of file
+# End of config
index 4d1c41fa6ed9badc8a232aa5feddc3ba396a9ca8..7eac6db3815d0734ce2515a7a7eb4bdb6c8ea255 100644 (file)
@@ -63,6 +63,8 @@ task_active_background_id = 3
 task_urgent_background_id = 3
 task_iconified_background_id = 0
 task_tooltip = 1
+#task_align = center
+task_align = right
 
 # Task Icons
 task_icon_asb = 90 -100 -20
@@ -122,4 +124,4 @@ battery_font_color = #FFFFFF 75
 battery_padding = 1 0
 battery_background_id = 0
 
-# End of config
\ No newline at end of file
+# End of config
index 0069fbe1adb8837e6c253357108efb349e3cf824..13f441a5ed257efb67533577ca15250d25405438 100644 (file)
@@ -29,7 +29,8 @@ border_color = #FFFFFF 60
 
 # Panel
 panel_monitor = all
-panel_position = bottom left horizontal
+#panel_position = bottom left horizontal
+panel_position = top left horizontal
 panel_size = 100% 38
 panel_margin = 0 0
 panel_padding = 7 3 7
@@ -63,6 +64,7 @@ task_active_background_id = 2
 task_urgent_background_id = 4
 task_iconified_background_id = 0
 task_tooltip = 0
+task_align = right
 
 # Task Icons
 task_icon_asb = 70 0 0
@@ -111,4 +113,4 @@ battery_font_color = #FFFFFF 75
 battery_padding = 1 0
 battery_background_id = 0
 
-# End of config
\ No newline at end of file
+# End of config
index fbbc76071ab538ccdb43408f5d86ee918a894a16..1d8bf82f637e57e0e7b6b6d7f6a7f09fabaa7729 100644 (file)
@@ -29,7 +29,8 @@ border_color = #ED2323 60
 
 # Panel
 panel_monitor = all
-panel_position = bottom center horizontal
+#panel_position = bottom center horizontal
+panel_position = top center horizontal
 panel_size = 100% 40
 panel_margin = 0 0
 panel_padding = 0 0 0
@@ -63,6 +64,7 @@ task_active_background_id = 2
 task_urgent_background_id = 4
 task_iconified_background_id = 3
 task_tooltip = 1
+task_align = right
 
 # Task Icons
 task_icon_asb = 90 0 0
@@ -111,4 +113,4 @@ battery_font_color = #FFFFFF 100
 battery_padding = 0 0
 battery_background_id = 0
 
-# End of config
\ No newline at end of file
+# End of config
index 75a59d7a1308fb44b7b24cf507650d107ec71b90..061389892e06c773abe9e787db0647bd221a1004 100644 (file)
@@ -63,6 +63,8 @@ task_active_background_id = 2
 task_urgent_background_id = 2
 task_iconified_background_id = 3
 task_tooltip = 1
+task_align = center
+#task_align = right
 
 # Task Icons
 task_icon_asb = 100 0 0
@@ -122,4 +124,4 @@ battery_font_color = #FFFFFF 75
 battery_padding = 4 2
 battery_background_id = 1
 
-# End of config
\ No newline at end of file
+# End of config
index f60de10d8285c2b33c98f211cbd52325383357bd..aca7047d8822b127c71261fcf35dd74f2785a65b 100644 (file)
@@ -23,7 +23,9 @@ border_color = #CCCCCC 40
 
 # Panel
 panel_monitor = all
-panel_position = bottom center horizontal
+#panel_position = bottom center horizontal
+#panel_position = top center horizontal
+panel_position = top center vertical
 panel_size = 95% 30
 panel_margin = 0 0
 panel_padding = 7 3 7
@@ -41,6 +43,7 @@ strut_policy = follow_size
 
 # Taskbar
 taskbar_mode = multi_desktop
+#taskbar_mode = single_desktop
 taskbar_padding = 0 0 0
 taskbar_background_id = 2
 taskbar_active_background_id = 2
@@ -57,6 +60,9 @@ task_active_background_id = 3
 task_urgent_background_id = 0
 task_iconified_background_id = 0
 task_tooltip = 1
+#task_align = left
+#task_align = center
+task_align = right
 
 # Task Icons
 task_icon_asb = 100 0 0
@@ -118,4 +124,4 @@ battery_font_color = #FFFFFF 100
 battery_padding = 1 0
 battery_background_id = 0
 
-# End of config
\ No newline at end of file
+# End of config
index bf86b10e4b942328186ae325c701c8665b1998ff..e38e087475e5091ea4223721fcfb50a94f8a1793 100644 (file)
@@ -484,6 +484,14 @@ void add_entry (char *key, char *value)
                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 a2b7f14231c333dbc0df4d224b94344e72fe9199..86e7e1adbe48be4b7a55cb1812288760cd6d6a34 100644 (file)
@@ -61,6 +61,9 @@ extern int panel_autohide_height;  // for vertical panels this is of course the
 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 50eed31d5d1df77f4f0a4b0ddf75f30c70c4df07..1dbaa97cb8291de9737cf29205a8607967fd5650 100644 (file)
@@ -26,6 +26,7 @@ typedef struct {
        int text;
        int icon;
        int centered;
+       int align;
 
        int icon_posy;
        int icon_size1;
index 22dbe716cb758ebec961945758ef72293faf8cef..f6e1a1bdefd54ba400de1a27237595d9482e3ddc 100644 (file)
@@ -130,6 +130,54 @@ void size_by_content (Area *a)
 }
 
 
+// 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 @@ void size_by_layout (Area *a, int pos, int level)
                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;
This page took 0.036376 seconds and 4 git commands to generate.