Tint2conf: support border sides (issue #580, thanks @stophe)
@@ -147,7 +147,11 @@ *background_border_color_over,
*background_fill_color_press, *background_border_color_press, *background_border_width, - *background_corner_radius; + *background_corner_radius, + *background_border_sides_top, + *background_border_sides_bottom, + *background_border_sides_left, + *background_border_sides_right; GtkWidget *addScrollBarToWidget(GtkWidget *widget);@@ -503,7 +507,11 @@ GTK_TYPE_INT,
GDK_TYPE_COLOR, GTK_TYPE_INT, GDK_TYPE_COLOR, - GTK_TYPE_INT); + GTK_TYPE_INT, + GTK_TYPE_INT, + GTK_TYPE_INT, + GTK_TYPE_INT, + GTK_TYPE_INT); GtkWidget *table, *label, *button; int row, col;@@ -659,6 +667,38 @@ gtk_table_attach(GTK_TABLE(table), background_corner_radius, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
col++; gtk_tooltips_set_tip(tooltips, background_corner_radius, _("The corner radius of the current background"), NULL); + row++; + col = 2; + label = gtk_label_new(_("Border sides")); + 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++; + + background_border_sides_top = gtk_check_button_new_with_label("Top"); + gtk_widget_show(background_border_sides_top); + gtk_table_attach(GTK_TABLE(table), background_border_sides_top, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, background_border_sides_top, _("Draw a line at top of task button."), NULL); + + background_border_sides_bottom = gtk_check_button_new_with_label("Bottom"); + gtk_widget_show(background_border_sides_bottom); + gtk_table_attach(GTK_TABLE(table), background_border_sides_bottom, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, background_border_sides_top, _("Draw a line at bottom of task button."), NULL); + + background_border_sides_left = gtk_check_button_new_with_label("Left"); + gtk_widget_show(background_border_sides_left); + gtk_table_attach(GTK_TABLE(table), background_border_sides_left, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, background_border_sides_left, _("Draw a line at left of task button."), NULL); + + background_border_sides_right = gtk_check_button_new_with_label("Right"); + gtk_widget_show(background_border_sides_right); + gtk_table_attach(GTK_TABLE(table), background_border_sides_right, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, background_border_sides_right, _("Draw a line at right of task button."), NULL); + g_signal_connect(G_OBJECT(current_background), "changed", G_CALLBACK(current_background_changed), NULL); g_signal_connect(G_OBJECT(background_fill_color), "color-set", G_CALLBACK(background_update), NULL); g_signal_connect(G_OBJECT(background_border_color), "color-set", G_CALLBACK(background_update), NULL);@@ -668,6 +708,10 @@ g_signal_connect(G_OBJECT(background_fill_color_press), "color-set", G_CALLBACK(background_update), NULL);
g_signal_connect(G_OBJECT(background_border_color_press), "color-set", G_CALLBACK(background_update), NULL); g_signal_connect(G_OBJECT(background_border_width), "value-changed", G_CALLBACK(background_update), NULL); g_signal_connect(G_OBJECT(background_corner_radius), "value-changed", G_CALLBACK(background_update), NULL); + g_signal_connect(G_OBJECT(background_border_sides_top), "toggled", G_CALLBACK(background_update), NULL); + g_signal_connect(G_OBJECT(background_border_sides_bottom), "toggled", G_CALLBACK(background_update), NULL); + g_signal_connect(G_OBJECT(background_border_sides_left), "toggled", G_CALLBACK(background_update), NULL); + g_signal_connect(G_OBJECT(background_border_sides_right), "toggled", G_CALLBACK(background_update), NULL); change_paragraph(parent); }@@ -702,6 +746,10 @@ void background_create_new()
{ int r = 0; int b = 0; + int sideTop = 0; + int sideBottom = 0; + int sideLeft = 0; + int sideRight = 0; GdkColor fillColor; cairoColor2GdkColor(0, 0, 0, &fillColor); int fillOpacity = 0;@@ -744,6 +792,10 @@ bgColFillColorPress, &fillColorPress,
bgColFillOpacityPress, fillOpacityPress, bgColBorderColorPress, &borderColorPress, bgColBorderOpacityPress, borderOpacityPress, + bgColBorderSidesTop, sideTop, + bgColBorderSidesBottom, sideBottom, + bgColBorderSidesLeft, sideLeft, + bgColBorderSidesRight, sideRight, -1); background_update_image(index);@@ -768,6 +820,10 @@ gtk_tree_path_free(path);
int r; int b; + int sideTop; + int sideBottom; + int sideLeft; + int sideRight; GdkColor *fillColor; int fillOpacity; GdkColor *borderColor;@@ -796,6 +852,10 @@ bgColBorderColorPress, &borderColorPress,
bgColBorderOpacityPress, &borderOpacityPress, bgColBorderWidth, &b, bgColCornerRadius, &r, + bgColBorderSidesTop, &sideTop, + bgColBorderSidesBottom, &sideBottom, + bgColBorderSidesLeft, &sideLeft, + bgColBorderSidesRight, &sideRight, -1); gtk_list_store_append(backgrounds, &iter);@@ -816,6 +876,10 @@ bgColBorderColorPress, borderColorPress,
bgColBorderOpacityPress, borderOpacityPress, bgColBorderWidth, b, bgColCornerRadius, r, + bgColBorderSidesTop, sideTop, + bgColBorderSidesBottom, sideBottom, + bgColBorderSidesLeft, sideLeft, + bgColBorderSidesRight, sideRight, -1); g_boxed_free(GDK_TYPE_COLOR, fillColor); g_boxed_free(GDK_TYPE_COLOR, borderColor);@@ -945,9 +1009,15 @@ gtk_tree_path_free(path);
int r; int b; + r = gtk_spin_button_get_value(GTK_SPIN_BUTTON(background_corner_radius)); b = gtk_spin_button_get_value(GTK_SPIN_BUTTON(background_border_width)); + int sideTop = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(background_border_sides_top)); + int sideBottom = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(background_border_sides_bottom)); + int sideLeft = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(background_border_sides_left)); + int sideRight = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(background_border_sides_right)); + GdkColor fillColor; int fillOpacity; GdkColor borderColor;@@ -991,6 +1061,10 @@ bgColBorderColorPress, &borderColorPress,
bgColBorderOpacityPress, borderOpacityPress, bgColBorderWidth, b, bgColCornerRadius, r, + bgColBorderSidesTop, sideTop, + bgColBorderSidesBottom, sideBottom, + bgColBorderSidesLeft, sideLeft, + bgColBorderSidesRight, sideRight, -1); background_update_image(index); }@@ -1010,6 +1084,12 @@ gtk_tree_path_free(path);
int r; int b; + + int sideTop; + int sideBottom; + int sideLeft; + int sideRight; + GdkColor *fillColor; int fillOpacity; GdkColor *borderColor;@@ -1039,7 +1119,16 @@ bgColBorderColorPress, &borderColorPress,
bgColBorderOpacityPress, &borderOpacityPress, bgColBorderWidth, &b, bgColCornerRadius, &r, + bgColBorderSidesTop, &sideTop, + bgColBorderSidesBottom, &sideBottom, + bgColBorderSidesLeft, &sideLeft, + bgColBorderSidesRight, &sideRight, -1); + + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_top), sideTop); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_bottom), sideBottom); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_left), sideLeft); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_right), sideRight); gtk_color_button_set_color(GTK_COLOR_BUTTON(background_fill_color), fillColor); gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_fill_color), (fillOpacity*0xffff)/100);@@ -5289,7 +5378,7 @@ gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
col++; change_paragraph(parent); - + label = gtk_label_new(_("<b>Appearance</b>")); gtk_misc_set_alignment(GTK_MISC(label), 0, 0); gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
@@ -179,6 +179,10 @@ bgColFillColorPress,
bgColFillOpacityPress, bgColBorderColorPress, bgColBorderOpacityPress, + bgColBorderSidesTop, + bgColBorderSidesBottom, + bgColBorderSidesLeft, + bgColBorderSidesRight, bgNumCols };@@ -191,6 +195,10 @@ *background_border_color_over,
*background_fill_color_press, *background_border_color_press, *background_border_width, + *background_border_sides_top, + *background_border_sides_bottom, + *background_border_sides_left, + *background_border_sides_right, *background_corner_radius; void background_create_new();
@@ -115,6 +115,10 @@ }
int r; int b; + int sideTop; + int sideBottom; + int sideLeft; + int sideRight; GdkColor *fillColor; int fillOpacity; GdkColor *borderColor;@@ -145,10 +149,26 @@ bgColBorderOpacityPress, &borderOpacityPress,
bgColBorderWidth, &b, bgColCornerRadius, &r, bgColText, &text, + bgColBorderSidesTop, &sideTop, + bgColBorderSidesBottom, &sideBottom, + bgColBorderSidesLeft, &sideLeft, + bgColBorderSidesRight, &sideRight, -1); fprintf(fp, "# Background %d: %s\n", index, text ? text : ""); fprintf(fp, "rounded = %d\n", r); fprintf(fp, "border_width = %d\n", b); + + char *sides = "\0"; + if (sideTop) + sides = append(sides, 'T'); + if (sideBottom) + sides = append(sides, 'B'); + if (sideLeft) + sides = append(sides, 'L'); + if (sideRight) + sides = append(sides, 'R'); + fprintf(fp, "border_sides = %s\n", sides); + config_write_color(fp, "background_color", *fillColor, fillOpacity); config_write_color(fp, "border_color", *borderColor, borderOpacity); config_write_color(fp, "background_color_hover", *fillColorOver, fillOpacityOver);@@ -922,7 +942,17 @@ gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_border_color_press), (alpha*65535)/100);
background_force_update(); read_border_color_press = 1; } - + else if (strcmp(key, "border_sides") == 0) { + if (strchr(value, 't') || strchr(value, 'T')) + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_top), 1); + if (strchr(value, 'b') || strchr(value, 'B')) + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_bottom), 1); + if (strchr(value, 'l') || strchr(value, 'L')) + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_left), 1); + if (strchr(value, 'r') || strchr(value, 'R')) + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_right), 1); + background_force_update(); + } /* Panel */ else if (strcmp(key, "panel_size") == 0) { extract_values(value, &value1, &value2, &value3);@@ -1086,7 +1116,7 @@ }
else if (strcmp(key, "primary_monitor_first") == 0) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_primary_monitor_first), atoi(value)); } - + /* autohide options */ else if (strcmp(key, "autohide") == 0) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_autohide), atoi(value));
@@ -44,6 +44,17 @@ #ifdef HAVE_RSVG
#include <librsvg/rsvg.h> #endif +char *append(char *s, char c) { + int len = strlen(s); + char buf[len+2]; + + strcpy(buf, s); + buf[len] = c; + buf[len + 1] = 0; + + return strdup(buf); +} + void copy_file(const char *path_src, const char *path_dest) { if (g_str_equal(path_src, path_dest))
@@ -41,6 +41,9 @@ } MouseAction;
#define ALL_DESKTOPS 0xFFFFFFFF +// add c to s +char *append(char *s, char c); + // Copies a file to another path void copy_file(const char *path_src, const char *path_dest);