From 95fa0bbf83deebda1b3e36d92d7c12eaaffebd3b Mon Sep 17 00:00:00 2001 From: o9000 Date: Sun, 26 Apr 2015 15:16:24 +0200 Subject: [PATCH] tint2 & tint2conf: Use spacing in task_padding --- src/taskbar/task.c | 14 +++++--------- src/taskbar/taskbar.c | 6 +++--- src/tint2conf/properties.c | 15 ++++++++++++++- src/tint2conf/properties.h | 2 +- src/tint2conf/properties_rw.c | 7 +++++-- 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/taskbar/task.c b/src/taskbar/task.c index b69fa5e..e16d725 100644 --- a/src/taskbar/task.c +++ b/src/taskbar/task.c @@ -193,18 +193,14 @@ int get_title(Task *tsk) name = server_get_property (tsk->win, server.atom._NET_WM_NAME, server.atom.UTF8_STRING, 0); if (!name || !strlen(name)) { name = server_get_property (tsk->win, server.atom.WM_NAME, XA_STRING, 0); - if (!name || !strlen(name)) { - name = calloc(10, 1); - strcpy(name, "Untitled"); - } } } - // add space before title - title = calloc(strlen(name)+2, 1); - if (panel->g_task.icon) strcpy(title, " "); - else title[0] = 0; - strcat(title, name); + if (name && strlen(name)) { + title = strdup(name); + } else { + title = strdup("Untitled"); + } if (name) XFree (name); if (tsk->title) { diff --git a/src/taskbar/taskbar.c b/src/taskbar/taskbar.c index 5b0f510..742e783 100644 --- a/src/taskbar/taskbar.c +++ b/src/taskbar/taskbar.c @@ -239,7 +239,7 @@ void init_taskbar_panel(void *p) panel->g_task.text_height = panel->g_task.area.height - (2 * panel->g_task.area.paddingy); if (panel->g_task.icon) { panel->g_task.icon_size1 = panel->g_task.area.height - (2 * panel->g_task.area.paddingy); - panel->g_task.text_posx += panel->g_task.icon_size1; + panel->g_task.text_posx += panel->g_task.icon_size1 + panel->g_task.area.paddingx; panel->g_task.icon_posy = (panel->g_task.area.height - panel->g_task.icon_size1) / 2; } //printf("monitor %d, task_maximum_width %d\n", panel->monitor, panel->g_task.maximum_width); @@ -342,12 +342,12 @@ int resize_taskbar(void *obj) break; } } - taskbar->text_width = text_width - panel->g_task.text_posx - panel->g_task.area.bg->border.width - panel->g_task.area.paddingx; + taskbar->text_width = text_width - panel->g_task.text_posx - panel->g_task.area.bg->border.width - panel->g_task.area.paddingxlr; } else { resize_by_layout(obj, panel->g_task.maximum_height); - taskbar->text_width = taskbar->area.width - (2 * panel->g_taskbar.area.paddingy) - panel->g_task.text_posx - panel->g_task.area.bg->border.width - panel->g_task.area.paddingx; + taskbar->text_width = taskbar->area.width - (2 * panel->g_taskbar.area.paddingy) - panel->g_task.text_posx - panel->g_task.area.bg->border.width - panel->g_task.area.paddingxlr; } return 0; } diff --git a/src/tint2conf/properties.c b/src/tint2conf/properties.c index da51d81..790fad4 100644 --- a/src/tint2conf/properties.c +++ b/src/tint2conf/properties.c @@ -52,7 +52,7 @@ GtkWidget *taskbar_distribute_size, *taskbar_sort_order; // task GtkWidget *task_mouse_left, *task_mouse_middle, *task_mouse_right, *task_mouse_scroll_up, *task_mouse_scroll_down; GtkWidget *task_show_icon, *task_show_text, *task_align_center, *font_shadow; -GtkWidget *task_maximum_width, *task_maximum_height, *task_padding_x, *task_padding_y, *task_font; +GtkWidget *task_maximum_width, *task_maximum_height, *task_padding_x, *task_padding_y, *task_spacing, *task_font; GtkWidget *task_default_color, *task_default_color_set, *task_default_icon_opacity, *task_default_icon_osb_set, *task_default_icon_saturation, @@ -2849,6 +2849,19 @@ void create_task(GtkWidget *parent) gtk_tooltips_set_tip(tooltips, task_padding_y, "Specifies the vertical padding of the task buttons. " "This is the space between the border and the content inside.", NULL); + row++, col = 2; + label = gtk_label_new(_("Spacing")); + 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++; + + task_spacing = gtk_spin_button_new_with_range(0, 9000, 1); + gtk_widget_show(task_spacing); + gtk_table_attach(GTK_TABLE(table), task_spacing, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, task_spacing, "Specifies the spacing between the icon and the text.", NULL); + row++, col = 2; label = gtk_label_new(_("Font")); gtk_misc_set_alignment(GTK_MISC(label), 0, 0); diff --git a/src/tint2conf/properties.h b/src/tint2conf/properties.h index ed60541..c75daf7 100644 --- a/src/tint2conf/properties.h +++ b/src/tint2conf/properties.h @@ -56,7 +56,7 @@ extern GtkWidget *taskbar_distribute_size, *taskbar_sort_order; // task extern GtkWidget *task_mouse_left, *task_mouse_middle, *task_mouse_right, *task_mouse_scroll_up, *task_mouse_scroll_down; extern GtkWidget *task_show_icon, *task_show_text, *task_align_center, *font_shadow; -extern GtkWidget *task_maximum_width, *task_maximum_height, *task_padding_x, *task_padding_y, *task_font; +extern GtkWidget *task_maximum_width, *task_maximum_height, *task_padding_x, *task_padding_y, *task_spacing, *task_font; extern GtkWidget *task_default_color, *task_default_color_set, *task_default_icon_opacity, *task_default_icon_osb_set, *task_default_icon_saturation, diff --git a/src/tint2conf/properties_rw.c b/src/tint2conf/properties_rw.c index 2d49fd2..26e0db7 100644 --- a/src/tint2conf/properties_rw.c +++ b/src/tint2conf/properties_rw.c @@ -325,9 +325,10 @@ void config_write_task(FILE *fp) (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(task_maximum_width)), (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(task_maximum_height))); fprintf(fp, - "task_padding = %d %d\n", + "task_padding = %d %d %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(task_padding_x)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(task_padding_y))); + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(task_padding_y)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(task_spacing))); fprintf(fp, "task_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(task_font))); fprintf(fp, "task_tooltip = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tooltip_task_show)) ? 1 : 0); @@ -1088,7 +1089,9 @@ void add_entry(char *key, char *value) else if (strcmp(key, "task_padding") == 0) { extract_values(value, &value1, &value2, &value3); gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_padding_x), atoi(value1)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_spacing), atoi(value1)); if (value2) gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_padding_y), atoi(value2)); + if (value3) gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_spacing), atoi(value3)); } else if (strcmp(key, "task_font") == 0) { gtk_font_button_set_font_name(GTK_FONT_BUTTON(task_font), value);