diff --git a/src/tint2conf/properties.c b/src/tint2conf/properties.c index a7fa5c4..085c5d5 100644 --- a/src/tint2conf/properties.c +++ b/src/tint2conf/properties.c @@ -147,7 +147,11 @@ GtkWidget *current_background, *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 @@ void create_background(GtkWidget *parent) 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 @@ void create_background(GtkWidget *parent) 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 @@ void create_background(GtkWidget *parent) 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 @@ void background_create_new() bgColFillOpacityPress, fillOpacityPress, bgColBorderColorPress, &borderColorPress, bgColBorderOpacityPress, borderOpacityPress, + bgColBorderSidesTop, sideTop, + bgColBorderSidesBottom, sideBottom, + bgColBorderSidesLeft, sideLeft, + bgColBorderSidesRight, sideRight, -1); background_update_image(index); @@ -768,6 +820,10 @@ void background_duplicate(GtkWidget *widget, gpointer data) int r; int b; + int sideTop; + int sideBottom; + int sideLeft; + int sideRight; GdkColor *fillColor; int fillOpacity; GdkColor *borderColor; @@ -796,6 +852,10 @@ void background_duplicate(GtkWidget *widget, gpointer data) 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 @@ void background_duplicate(GtkWidget *widget, gpointer data) 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 @@ void background_update(GtkWidget *widget, gpointer data) 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 @@ void background_update(GtkWidget *widget, gpointer data) bgColBorderOpacityPress, borderOpacityPress, bgColBorderWidth, b, bgColCornerRadius, r, + bgColBorderSidesTop, sideTop, + bgColBorderSidesBottom, sideBottom, + bgColBorderSidesLeft, sideLeft, + bgColBorderSidesRight, sideRight, -1); background_update_image(index); } @@ -1010,6 +1084,12 @@ void current_background_changed(GtkWidget *widget, gpointer data) int r; int b; + + int sideTop; + int sideBottom; + int sideLeft; + int sideRight; + GdkColor *fillColor; int fillOpacity; GdkColor *borderColor; @@ -1039,8 +1119,17 @@ void current_background_changed(GtkWidget *widget, gpointer data) 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); gtk_color_button_set_color(GTK_COLOR_BUTTON(background_border_color), borderColor); @@ -5289,7 +5378,7 @@ void create_tooltip(GtkWidget *parent) col++; change_paragraph(parent); - + label = gtk_label_new(_("Appearance")); gtk_misc_set_alignment(GTK_MISC(label), 0, 0); gtk_label_set_use_markup(GTK_LABEL(label), TRUE); diff --git a/src/tint2conf/properties.h b/src/tint2conf/properties.h index deee9e2..685d380 100644 --- a/src/tint2conf/properties.h +++ b/src/tint2conf/properties.h @@ -179,6 +179,10 @@ enum { bgColFillOpacityPress, bgColBorderColorPress, bgColBorderOpacityPress, + bgColBorderSidesTop, + bgColBorderSidesBottom, + bgColBorderSidesLeft, + bgColBorderSidesRight, bgNumCols }; @@ -191,6 +195,10 @@ extern GtkWidget *current_background, *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(); diff --git a/src/tint2conf/properties_rw.c b/src/tint2conf/properties_rw.c index 58a9646..3021135 100644 --- a/src/tint2conf/properties_rw.c +++ b/src/tint2conf/properties_rw.c @@ -115,6 +115,10 @@ void config_write_backgrounds(FILE *fp) int r; int b; + int sideTop; + int sideBottom; + int sideLeft; + int sideRight; GdkColor *fillColor; int fillOpacity; GdkColor *borderColor; @@ -145,10 +149,26 @@ void config_write_backgrounds(FILE *fp) 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 @@ void add_entry(char *key, char *value) 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 @@ void add_entry(char *key, char *value) 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)); diff --git a/src/util/common.c b/src/util/common.c index 4a50e03..09e01eb 100644 --- a/src/util/common.c +++ b/src/util/common.c @@ -44,6 +44,17 @@ #include #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)) diff --git a/src/util/common.h b/src/util/common.h index c2a907f..bbb4e02 100644 --- a/src/util/common.h +++ b/src/util/common.h @@ -41,6 +41,9 @@ typedef enum 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);