Separator: add background option

This commit is contained in:
o9000
2016-10-02 12:17:07 +02:00
parent 6304715df3
commit 62e0ee6a3a
5 changed files with 87 additions and 54 deletions

View File

@@ -4452,7 +4452,7 @@ void create_separator(GtkWidget *notebook, int i)
gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING);
row = 0, col = 2;
label = gtk_label_new(_("<b>Format</b>"));
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);
gtk_widget_show(label);
@@ -4465,6 +4465,18 @@ void create_separator(GtkWidget *notebook, int i)
gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING);
row = 0, col = 2;
label = gtk_label_new(_("Background"));
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++;
separator->separator_background = create_background_combo(_("Separator"));
gtk_widget_show(separator->separator_background);
gtk_table_attach(GTK_TABLE(table), separator->separator_background, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
col++;
row++, col = 2;
label = gtk_label_new(_("Foreground color"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
gtk_widget_show(label);
@@ -4476,7 +4488,6 @@ void create_separator(GtkWidget *notebook, int i)
gtk_widget_show(separator->separator_color);
gtk_table_attach(GTK_TABLE(table), separator->separator_color, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
col++;
gtk_tooltips_set_tip(tooltips, separator->separator_color, _("Specifies separator's color."), NULL);
row++, col = 2;
label = gtk_label_new(_("Separator style"));
@@ -4489,7 +4500,6 @@ void create_separator(GtkWidget *notebook, int i)
gtk_widget_show(separator->separator_style);
gtk_table_attach(GTK_TABLE(table), separator->separator_style, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
col++;
gtk_tooltips_set_tip(tooltips, separator->separator_style, _("Specifies separator's appearance. 0 is empty/invisible separator."), NULL);
change_paragraph(parent);
}

View File

@@ -115,10 +115,10 @@ void config_write_backgrounds(FILE *fp)
int r;
int b;
gboolean sideTop;
gboolean sideBottom;
gboolean sideLeft;
gboolean sideRight;
gboolean sideTop;
gboolean sideBottom;
gboolean sideLeft;
gboolean sideRight;
GdkColor *fillColor;
int fillOpacity;
GdkColor *borderColor;
@@ -149,26 +149,26 @@ void config_write_backgrounds(FILE *fp)
bgColBorderWidth, &b,
bgColCornerRadius, &r,
bgColText, &text,
bgColBorderSidesTop, &sideTop,
bgColBorderSidesBottom, &sideBottom,
bgColBorderSidesLeft, &sideLeft,
bgColBorderSidesRight, &sideRight,
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[10];
sides[0] = '\0';
if (sideTop)
strcat(sides, "T");
if (sideBottom)
strcat(sides, "B");
if (sideLeft)
strcat(sides, "L");
if (sideRight)
strcat(sides, "R");
fprintf(fp, "border_sides = %s\n", sides);
char sides[10];
sides[0] = '\0';
if (sideTop)
strcat(sides, "T");
if (sideBottom)
strcat(sides, "B");
if (sideLeft)
strcat(sides, "L");
if (sideRight)
strcat(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);
@@ -679,6 +679,7 @@ void config_write_separator(FILE *fp)
Separator *separator = &g_array_index(separators, Separator, i);
fprintf(fp, "separator = new\n");
fprintf(fp, "separator_background_id = %d\n", gtk_combo_box_get_active(GTK_COMBO_BOX(separator->separator_background)));
GdkColor color;
gtk_color_button_get_color(GTK_COLOR_BUTTON(separator->separator_color), &color);
config_write_color(fp,
@@ -769,7 +770,7 @@ void config_write_tooltip(FILE *fp)
// Similar to BSD checksum, except we skip the first line (metadata)
unsigned short checksum_txt(FILE *f)
{
unsigned int checksum = 0;
unsigned int checksum = 0;
fseek(f, 0, SEEK_SET);
// Skip the first line
@@ -780,13 +781,13 @@ unsigned short checksum_txt(FILE *f)
while ((c = getc(f)) != EOF) {
// Rotate right
checksum = (checksum >> 1) + ((checksum & 1) << 15);
// Update checksum
checksum = (checksum >> 1) + ((checksum & 1) << 15);
// Update checksum
checksum += c;
// Truncate to 16 bits
checksum &= 0xffff;
}
return checksum;
checksum &= 0xffff;
}
return checksum;
}
void config_save_file(const char *path) {
@@ -966,16 +967,16 @@ void add_entry(char *key, char *value)
read_border_color_press = 1;
}
else if (strcmp(key, "border_sides") == 0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_top),
strchr(value, 't') || strchr(value, 'T'));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_bottom),
strchr(value, 'b') || strchr(value, 'B'));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_left),
strchr(value, 'l') || strchr(value, 'L'));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_right),
strchr(value, 'r') || strchr(value, 'R'));
background_force_update();
}
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_top),
strchr(value, 't') || strchr(value, 'T'));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_bottom),
strchr(value, 'b') || strchr(value, 'B'));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_left),
strchr(value, 'l') || strchr(value, 'L'));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_right),
strchr(value, 'r') || strchr(value, 'R'));
background_force_update();
}
/* Panel */
else if (strcmp(key, "panel_size") == 0) {
extract_values(value, &value1, &value2, &value3);
@@ -1700,6 +1701,10 @@ void add_entry(char *key, char *value)
else if (strcmp(key, "separator") == 0) {
separator_create_new();
}
else if (strcmp(key, "separator_background_id") == 0) {
int id = background_index_safe(atoi(value));
gtk_combo_box_set_active(GTK_COMBO_BOX(separator_get_last()->separator_background), id);
}
else if (strcmp(key, "separator_color") == 0) {
extract_values(value, &value1, &value2, &value3);
GdkColor col;