Tint2conf: support border sides (issue #580, thanks @stophe)

This commit is contained in:
o9000 2016-05-18 23:13:28 +02:00
parent 42d95f2930
commit 50c2f72a66
5 changed files with 146 additions and 5 deletions

View file

@ -147,7 +147,11 @@ GtkWidget *current_background,
*background_fill_color_press, *background_fill_color_press,
*background_border_color_press, *background_border_color_press,
*background_border_width, *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); GtkWidget *addScrollBarToWidget(GtkWidget *widget);
@ -503,7 +507,11 @@ void create_background(GtkWidget *parent)
GDK_TYPE_COLOR, GDK_TYPE_COLOR,
GTK_TYPE_INT, GTK_TYPE_INT,
GDK_TYPE_COLOR, 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; GtkWidget *table, *label, *button;
int row, col; int row, col;
@ -659,6 +667,38 @@ void create_background(GtkWidget *parent)
col++; col++;
gtk_tooltips_set_tip(tooltips, background_corner_radius, _("The corner radius of the current background"), NULL); 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(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_fill_color), "color-set", G_CALLBACK(background_update), NULL);
g_signal_connect(G_OBJECT(background_border_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_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_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_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); change_paragraph(parent);
} }
@ -702,6 +746,10 @@ void background_create_new()
{ {
int r = 0; int r = 0;
int b = 0; int b = 0;
int sideTop = 0;
int sideBottom = 0;
int sideLeft = 0;
int sideRight = 0;
GdkColor fillColor; GdkColor fillColor;
cairoColor2GdkColor(0, 0, 0, &fillColor); cairoColor2GdkColor(0, 0, 0, &fillColor);
int fillOpacity = 0; int fillOpacity = 0;
@ -744,6 +792,10 @@ void background_create_new()
bgColFillOpacityPress, fillOpacityPress, bgColFillOpacityPress, fillOpacityPress,
bgColBorderColorPress, &borderColorPress, bgColBorderColorPress, &borderColorPress,
bgColBorderOpacityPress, borderOpacityPress, bgColBorderOpacityPress, borderOpacityPress,
bgColBorderSidesTop, sideTop,
bgColBorderSidesBottom, sideBottom,
bgColBorderSidesLeft, sideLeft,
bgColBorderSidesRight, sideRight,
-1); -1);
background_update_image(index); background_update_image(index);
@ -768,6 +820,10 @@ void background_duplicate(GtkWidget *widget, gpointer data)
int r; int r;
int b; int b;
int sideTop;
int sideBottom;
int sideLeft;
int sideRight;
GdkColor *fillColor; GdkColor *fillColor;
int fillOpacity; int fillOpacity;
GdkColor *borderColor; GdkColor *borderColor;
@ -796,6 +852,10 @@ void background_duplicate(GtkWidget *widget, gpointer data)
bgColBorderOpacityPress, &borderOpacityPress, bgColBorderOpacityPress, &borderOpacityPress,
bgColBorderWidth, &b, bgColBorderWidth, &b,
bgColCornerRadius, &r, bgColCornerRadius, &r,
bgColBorderSidesTop, &sideTop,
bgColBorderSidesBottom, &sideBottom,
bgColBorderSidesLeft, &sideLeft,
bgColBorderSidesRight, &sideRight,
-1); -1);
gtk_list_store_append(backgrounds, &iter); gtk_list_store_append(backgrounds, &iter);
@ -816,6 +876,10 @@ void background_duplicate(GtkWidget *widget, gpointer data)
bgColBorderOpacityPress, borderOpacityPress, bgColBorderOpacityPress, borderOpacityPress,
bgColBorderWidth, b, bgColBorderWidth, b,
bgColCornerRadius, r, bgColCornerRadius, r,
bgColBorderSidesTop, sideTop,
bgColBorderSidesBottom, sideBottom,
bgColBorderSidesLeft, sideLeft,
bgColBorderSidesRight, sideRight,
-1); -1);
g_boxed_free(GDK_TYPE_COLOR, fillColor); g_boxed_free(GDK_TYPE_COLOR, fillColor);
g_boxed_free(GDK_TYPE_COLOR, borderColor); g_boxed_free(GDK_TYPE_COLOR, borderColor);
@ -945,9 +1009,15 @@ void background_update(GtkWidget *widget, gpointer data)
int r; int r;
int b; int b;
r = gtk_spin_button_get_value(GTK_SPIN_BUTTON(background_corner_radius)); r = gtk_spin_button_get_value(GTK_SPIN_BUTTON(background_corner_radius));
b = gtk_spin_button_get_value(GTK_SPIN_BUTTON(background_border_width)); 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; GdkColor fillColor;
int fillOpacity; int fillOpacity;
GdkColor borderColor; GdkColor borderColor;
@ -991,6 +1061,10 @@ void background_update(GtkWidget *widget, gpointer data)
bgColBorderOpacityPress, borderOpacityPress, bgColBorderOpacityPress, borderOpacityPress,
bgColBorderWidth, b, bgColBorderWidth, b,
bgColCornerRadius, r, bgColCornerRadius, r,
bgColBorderSidesTop, sideTop,
bgColBorderSidesBottom, sideBottom,
bgColBorderSidesLeft, sideLeft,
bgColBorderSidesRight, sideRight,
-1); -1);
background_update_image(index); background_update_image(index);
} }
@ -1010,6 +1084,12 @@ void current_background_changed(GtkWidget *widget, gpointer data)
int r; int r;
int b; int b;
int sideTop;
int sideBottom;
int sideLeft;
int sideRight;
GdkColor *fillColor; GdkColor *fillColor;
int fillOpacity; int fillOpacity;
GdkColor *borderColor; GdkColor *borderColor;
@ -1039,8 +1119,17 @@ void current_background_changed(GtkWidget *widget, gpointer data)
bgColBorderOpacityPress, &borderOpacityPress, bgColBorderOpacityPress, &borderOpacityPress,
bgColBorderWidth, &b, bgColBorderWidth, &b,
bgColCornerRadius, &r, bgColCornerRadius, &r,
bgColBorderSidesTop, &sideTop,
bgColBorderSidesBottom, &sideBottom,
bgColBorderSidesLeft, &sideLeft,
bgColBorderSidesRight, &sideRight,
-1); -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_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_alpha(GTK_COLOR_BUTTON(background_fill_color), (fillOpacity*0xffff)/100);
gtk_color_button_set_color(GTK_COLOR_BUTTON(background_border_color), borderColor); gtk_color_button_set_color(GTK_COLOR_BUTTON(background_border_color), borderColor);
@ -5289,7 +5378,7 @@ void create_tooltip(GtkWidget *parent)
col++; col++;
change_paragraph(parent); change_paragraph(parent);
label = gtk_label_new(_("<b>Appearance</b>")); label = gtk_label_new(_("<b>Appearance</b>"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0); gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
gtk_label_set_use_markup(GTK_LABEL(label), TRUE); gtk_label_set_use_markup(GTK_LABEL(label), TRUE);

View file

@ -179,6 +179,10 @@ enum {
bgColFillOpacityPress, bgColFillOpacityPress,
bgColBorderColorPress, bgColBorderColorPress,
bgColBorderOpacityPress, bgColBorderOpacityPress,
bgColBorderSidesTop,
bgColBorderSidesBottom,
bgColBorderSidesLeft,
bgColBorderSidesRight,
bgNumCols bgNumCols
}; };
@ -191,6 +195,10 @@ extern GtkWidget *current_background,
*background_fill_color_press, *background_fill_color_press,
*background_border_color_press, *background_border_color_press,
*background_border_width, *background_border_width,
*background_border_sides_top,
*background_border_sides_bottom,
*background_border_sides_left,
*background_border_sides_right,
*background_corner_radius; *background_corner_radius;
void background_create_new(); void background_create_new();

View file

@ -115,6 +115,10 @@ void config_write_backgrounds(FILE *fp)
int r; int r;
int b; int b;
int sideTop;
int sideBottom;
int sideLeft;
int sideRight;
GdkColor *fillColor; GdkColor *fillColor;
int fillOpacity; int fillOpacity;
GdkColor *borderColor; GdkColor *borderColor;
@ -145,10 +149,26 @@ void config_write_backgrounds(FILE *fp)
bgColBorderWidth, &b, bgColBorderWidth, &b,
bgColCornerRadius, &r, bgColCornerRadius, &r,
bgColText, &text, bgColText, &text,
bgColBorderSidesTop, &sideTop,
bgColBorderSidesBottom, &sideBottom,
bgColBorderSidesLeft, &sideLeft,
bgColBorderSidesRight, &sideRight,
-1); -1);
fprintf(fp, "# Background %d: %s\n", index, text ? text : ""); fprintf(fp, "# Background %d: %s\n", index, text ? text : "");
fprintf(fp, "rounded = %d\n", r); fprintf(fp, "rounded = %d\n", r);
fprintf(fp, "border_width = %d\n", b); 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, "background_color", *fillColor, fillOpacity);
config_write_color(fp, "border_color", *borderColor, borderOpacity); config_write_color(fp, "border_color", *borderColor, borderOpacity);
config_write_color(fp, "background_color_hover", *fillColorOver, fillOpacityOver); config_write_color(fp, "background_color_hover", *fillColorOver, fillOpacityOver);
@ -922,7 +942,17 @@ void add_entry(char *key, char *value)
background_force_update(); background_force_update();
read_border_color_press = 1; 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 */ /* Panel */
else if (strcmp(key, "panel_size") == 0) { else if (strcmp(key, "panel_size") == 0) {
extract_values(value, &value1, &value2, &value3); 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) { else if (strcmp(key, "primary_monitor_first") == 0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_primary_monitor_first), atoi(value)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_primary_monitor_first), atoi(value));
} }
/* autohide options */ /* autohide options */
else if (strcmp(key, "autohide") == 0) { else if (strcmp(key, "autohide") == 0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_autohide), atoi(value)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_autohide), atoi(value));

View file

@ -44,6 +44,17 @@
#include <librsvg/rsvg.h> #include <librsvg/rsvg.h>
#endif #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) void copy_file(const char *path_src, const char *path_dest)
{ {
if (g_str_equal(path_src, path_dest)) if (g_str_equal(path_src, path_dest))

View file

@ -41,6 +41,9 @@ typedef enum MouseAction {
#define ALL_DESKTOPS 0xFFFFFFFF #define ALL_DESKTOPS 0xFFFFFFFF
// add c to s
char *append(char *s, char c);
// Copies a file to another path // Copies a file to another path
void copy_file(const char *path_src, const char *path_dest); void copy_file(const char *path_src, const char *path_dest);