Separator: add background option
This commit is contained in:
parent
6304715df3
commit
62e0ee6a3a
5 changed files with 87 additions and 54 deletions
|
@ -539,6 +539,11 @@ void add_entry(char *key, char *value)
|
||||||
/* Separator */
|
/* Separator */
|
||||||
else if (strcmp(key, "separator") == 0) {
|
else if (strcmp(key, "separator") == 0) {
|
||||||
panel_config.separator_list = g_list_append(panel_config.separator_list, create_separator());
|
panel_config.separator_list = g_list_append(panel_config.separator_list, create_separator());
|
||||||
|
} else if (strcmp(key, "separator_background_id") == 0) {
|
||||||
|
Separator *separator = get_or_create_last_separator();
|
||||||
|
int id = atoi(value);
|
||||||
|
id = (id < backgrounds->len && id >= 0) ? id : 0;
|
||||||
|
separator->area.bg = &g_array_index(backgrounds, Background, id);
|
||||||
} else if (strcmp(key, "separator_color") == 0) {
|
} else if (strcmp(key, "separator_color") == 0) {
|
||||||
Separator *separator = get_or_create_last_separator();
|
Separator *separator = get_or_create_last_separator();
|
||||||
extract_values(value, &value1, &value2, &value3);
|
extract_values(value, &value1, &value2, &value3);
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
Separator *create_separator()
|
Separator *create_separator()
|
||||||
{
|
{
|
||||||
Separator *separator = calloc(1, sizeof(Separator));
|
Separator *separator = (Separator *)calloc(1, sizeof(Separator));
|
||||||
return separator;
|
return separator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,13 +61,12 @@ void init_separator_panel(void *p)
|
||||||
if (panel->separator_list)
|
if (panel->separator_list)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
// panel->separator_list is now a copy of the pointer panel_config.separator_list
|
// panel->separator_list is now a copy of the pointer panel_config.separator_list
|
||||||
// We make it a deep copy
|
// We make it a deep copy
|
||||||
panel->separator_list = g_list_copy_deep(panel_config.separator_list, NULL, NULL);
|
panel->separator_list = g_list_copy_deep(panel_config.separator_list, NULL, NULL);
|
||||||
|
|
||||||
for (GList *l = panel->separator_list; l; l = l->next) {
|
for (GList *l = panel->separator_list; l; l = l->next) {
|
||||||
Separator *separator = l->data;
|
Separator *separator = (Separator *)l->data;
|
||||||
if (!separator->area.bg)
|
if (!separator->area.bg)
|
||||||
separator->area.bg = &g_array_index(backgrounds, Background, 0);
|
separator->area.bg = &g_array_index(backgrounds, Background, 0);
|
||||||
separator->area.parent = p;
|
separator->area.parent = p;
|
||||||
|
@ -96,7 +95,7 @@ void cleanup_separator()
|
||||||
|
|
||||||
gboolean resize_separator(void *obj)
|
gboolean resize_separator(void *obj)
|
||||||
{
|
{
|
||||||
Separator *separator = obj;
|
Separator *separator = (Separator *)obj;
|
||||||
// Panel *panel = separator->area.panel;
|
// Panel *panel = separator->area.panel;
|
||||||
if (!separator->area.on_screen)
|
if (!separator->area.on_screen)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -147,15 +146,15 @@ gboolean resize_separator(void *obj)
|
||||||
|
|
||||||
void draw_separator(void *obj, cairo_t *c)
|
void draw_separator(void *obj, cairo_t *c)
|
||||||
{
|
{
|
||||||
Separator *separator = obj;
|
Separator *separator = (Separator *)obj;
|
||||||
|
|
||||||
if (separator->style == 0 )
|
if (separator->style == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
double start_point = 0 + ( separator->thickness * 2 );
|
double start_point = 0 + (separator->thickness * 2);
|
||||||
double end_point = separator->area.height - ( separator->thickness * 2 );
|
double end_point = separator->area.height - (separator->thickness * 2);
|
||||||
if (!panel_horizontal)
|
if (!panel_horizontal)
|
||||||
end_point = separator->area.width - ( separator->thickness * 2 );
|
end_point = separator->area.width - (separator->thickness * 2);
|
||||||
double count = end_point - start_point;
|
double count = end_point - start_point;
|
||||||
double thickness = separator->thickness;
|
double thickness = separator->thickness;
|
||||||
double len = separator->len;
|
double len = separator->len;
|
||||||
|
@ -164,10 +163,18 @@ void draw_separator(void *obj, cairo_t *c)
|
||||||
|
|
||||||
if (separator->style == 2) {
|
if (separator->style == 2) {
|
||||||
if (!panel_horizontal)
|
if (!panel_horizontal)
|
||||||
start_point=start_point + 2;
|
start_point = start_point + 2;
|
||||||
cairo_set_source_rgba(c, separator->color.rgb[0], separator->color.rgb[1], separator->color.rgb[2], separator->color.alpha);
|
cairo_set_source_rgba(c,
|
||||||
|
separator->color.rgb[0],
|
||||||
|
separator->color.rgb[1],
|
||||||
|
separator->color.rgb[2],
|
||||||
|
separator->color.alpha);
|
||||||
cairo_set_line_width(c, 1);
|
cairo_set_line_width(c, 1);
|
||||||
cairo_rectangle(c, start_point - 2, start_point - (panel_horizontal ? 0 : 4), end_point - thickness - 3, end_point - thickness - ( panel_horizontal ? 3 : 3));
|
cairo_rectangle(c,
|
||||||
|
start_point - 2,
|
||||||
|
start_point - (panel_horizontal ? 0 : 4),
|
||||||
|
end_point - thickness - 3,
|
||||||
|
end_point - thickness - (panel_horizontal ? 3 : 3));
|
||||||
cairo_stroke_preserve(c);
|
cairo_stroke_preserve(c);
|
||||||
cairo_fill(c);
|
cairo_fill(c);
|
||||||
return;
|
return;
|
||||||
|
@ -176,7 +183,7 @@ void draw_separator(void *obj, cairo_t *c)
|
||||||
if (count < thickness)
|
if (count < thickness)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while (((int) count) % 2) {
|
while (((int)count) % 2) {
|
||||||
if (alt) {
|
if (alt) {
|
||||||
start_point++;
|
start_point++;
|
||||||
alt = 0;
|
alt = 0;
|
||||||
|
@ -198,9 +205,13 @@ void draw_separator(void *obj, cairo_t *c)
|
||||||
end_point--;
|
end_point--;
|
||||||
}
|
}
|
||||||
|
|
||||||
double separator_pattern[] = { len, len };
|
double separator_pattern[] = {len, len};
|
||||||
double separator_style6_pattern[] = { 1.0 };
|
double separator_style6_pattern[] = {1.0};
|
||||||
cairo_set_source_rgba(c, separator->color.rgb[0], separator->color.rgb[1], separator->color.rgb[2], separator->color.alpha);
|
cairo_set_source_rgba(c,
|
||||||
|
separator->color.rgb[0],
|
||||||
|
separator->color.rgb[1],
|
||||||
|
separator->color.rgb[2],
|
||||||
|
separator->color.alpha);
|
||||||
cairo_set_line_width(c, thickness);
|
cairo_set_line_width(c, thickness);
|
||||||
if (separator->style == 6)
|
if (separator->style == 6)
|
||||||
cairo_set_dash(c, separator_style6_pattern, 1, 0);
|
cairo_set_dash(c, separator_style6_pattern, 1, 0);
|
||||||
|
|
|
@ -4452,7 +4452,7 @@ void create_separator(GtkWidget *notebook, int i)
|
||||||
gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING);
|
gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING);
|
||||||
row = 0, col = 2;
|
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_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);
|
||||||
gtk_widget_show(label);
|
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);
|
gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING);
|
||||||
row = 0, col = 2;
|
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"));
|
label = gtk_label_new(_("Foreground color"));
|
||||||
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
|
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
|
||||||
gtk_widget_show(label);
|
gtk_widget_show(label);
|
||||||
|
@ -4476,7 +4488,6 @@ void create_separator(GtkWidget *notebook, int i)
|
||||||
gtk_widget_show(separator->separator_color);
|
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);
|
gtk_table_attach(GTK_TABLE(table), separator->separator_color, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
|
||||||
col++;
|
col++;
|
||||||
gtk_tooltips_set_tip(tooltips, separator->separator_color, _("Specifies separator's color."), NULL);
|
|
||||||
|
|
||||||
row++, col = 2;
|
row++, col = 2;
|
||||||
label = gtk_label_new(_("Separator style"));
|
label = gtk_label_new(_("Separator style"));
|
||||||
|
@ -4489,7 +4500,6 @@ void create_separator(GtkWidget *notebook, int i)
|
||||||
gtk_widget_show(separator->separator_style);
|
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);
|
gtk_table_attach(GTK_TABLE(table), separator->separator_style, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
|
||||||
col++;
|
col++;
|
||||||
gtk_tooltips_set_tip(tooltips, separator->separator_style, _("Specifies separator's appearance. 0 is empty/invisible separator."), NULL);
|
|
||||||
|
|
||||||
change_paragraph(parent);
|
change_paragraph(parent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,10 +115,10 @@ void config_write_backgrounds(FILE *fp)
|
||||||
|
|
||||||
int r;
|
int r;
|
||||||
int b;
|
int b;
|
||||||
gboolean sideTop;
|
gboolean sideTop;
|
||||||
gboolean sideBottom;
|
gboolean sideBottom;
|
||||||
gboolean sideLeft;
|
gboolean sideLeft;
|
||||||
gboolean sideRight;
|
gboolean sideRight;
|
||||||
GdkColor *fillColor;
|
GdkColor *fillColor;
|
||||||
int fillOpacity;
|
int fillOpacity;
|
||||||
GdkColor *borderColor;
|
GdkColor *borderColor;
|
||||||
|
@ -149,26 +149,26 @@ void config_write_backgrounds(FILE *fp)
|
||||||
bgColBorderWidth, &b,
|
bgColBorderWidth, &b,
|
||||||
bgColCornerRadius, &r,
|
bgColCornerRadius, &r,
|
||||||
bgColText, &text,
|
bgColText, &text,
|
||||||
bgColBorderSidesTop, &sideTop,
|
bgColBorderSidesTop, &sideTop,
|
||||||
bgColBorderSidesBottom, &sideBottom,
|
bgColBorderSidesBottom, &sideBottom,
|
||||||
bgColBorderSidesLeft, &sideLeft,
|
bgColBorderSidesLeft, &sideLeft,
|
||||||
bgColBorderSidesRight, &sideRight,
|
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[10];
|
char sides[10];
|
||||||
sides[0] = '\0';
|
sides[0] = '\0';
|
||||||
if (sideTop)
|
if (sideTop)
|
||||||
strcat(sides, "T");
|
strcat(sides, "T");
|
||||||
if (sideBottom)
|
if (sideBottom)
|
||||||
strcat(sides, "B");
|
strcat(sides, "B");
|
||||||
if (sideLeft)
|
if (sideLeft)
|
||||||
strcat(sides, "L");
|
strcat(sides, "L");
|
||||||
if (sideRight)
|
if (sideRight)
|
||||||
strcat(sides, "R");
|
strcat(sides, "R");
|
||||||
fprintf(fp, "border_sides = %s\n", sides);
|
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);
|
||||||
|
@ -679,6 +679,7 @@ void config_write_separator(FILE *fp)
|
||||||
Separator *separator = &g_array_index(separators, Separator, i);
|
Separator *separator = &g_array_index(separators, Separator, i);
|
||||||
|
|
||||||
fprintf(fp, "separator = new\n");
|
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;
|
GdkColor color;
|
||||||
gtk_color_button_get_color(GTK_COLOR_BUTTON(separator->separator_color), &color);
|
gtk_color_button_get_color(GTK_COLOR_BUTTON(separator->separator_color), &color);
|
||||||
config_write_color(fp,
|
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)
|
// Similar to BSD checksum, except we skip the first line (metadata)
|
||||||
unsigned short checksum_txt(FILE *f)
|
unsigned short checksum_txt(FILE *f)
|
||||||
{
|
{
|
||||||
unsigned int checksum = 0;
|
unsigned int checksum = 0;
|
||||||
fseek(f, 0, SEEK_SET);
|
fseek(f, 0, SEEK_SET);
|
||||||
|
|
||||||
// Skip the first line
|
// Skip the first line
|
||||||
|
@ -780,13 +781,13 @@ unsigned short checksum_txt(FILE *f)
|
||||||
|
|
||||||
while ((c = getc(f)) != EOF) {
|
while ((c = getc(f)) != EOF) {
|
||||||
// Rotate right
|
// Rotate right
|
||||||
checksum = (checksum >> 1) + ((checksum & 1) << 15);
|
checksum = (checksum >> 1) + ((checksum & 1) << 15);
|
||||||
// Update checksum
|
// Update checksum
|
||||||
checksum += c;
|
checksum += c;
|
||||||
// Truncate to 16 bits
|
// Truncate to 16 bits
|
||||||
checksum &= 0xffff;
|
checksum &= 0xffff;
|
||||||
}
|
}
|
||||||
return checksum;
|
return checksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void config_save_file(const char *path) {
|
void config_save_file(const char *path) {
|
||||||
|
@ -966,16 +967,16 @@ void add_entry(char *key, char *value)
|
||||||
read_border_color_press = 1;
|
read_border_color_press = 1;
|
||||||
}
|
}
|
||||||
else if (strcmp(key, "border_sides") == 0) {
|
else if (strcmp(key, "border_sides") == 0) {
|
||||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_top),
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_top),
|
||||||
strchr(value, 't') || strchr(value, 'T'));
|
strchr(value, 't') || strchr(value, 'T'));
|
||||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_bottom),
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_bottom),
|
||||||
strchr(value, 'b') || strchr(value, 'B'));
|
strchr(value, 'b') || strchr(value, 'B'));
|
||||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_left),
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_left),
|
||||||
strchr(value, 'l') || strchr(value, 'L'));
|
strchr(value, 'l') || strchr(value, 'L'));
|
||||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_right),
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_right),
|
||||||
strchr(value, 'r') || strchr(value, 'R'));
|
strchr(value, 'r') || strchr(value, 'R'));
|
||||||
background_force_update();
|
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);
|
||||||
|
@ -1700,6 +1701,10 @@ void add_entry(char *key, char *value)
|
||||||
else if (strcmp(key, "separator") == 0) {
|
else if (strcmp(key, "separator") == 0) {
|
||||||
separator_create_new();
|
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) {
|
else if (strcmp(key, "separator_color") == 0) {
|
||||||
extract_values(value, &value1, &value2, &value3);
|
extract_values(value, &value1, &value2, &value3);
|
||||||
GdkColor col;
|
GdkColor col;
|
||||||
|
|
|
@ -208,3 +208,5 @@ themes/vertical-light-opaque.tint2rc
|
||||||
themes/vertical-light-transparent.tint2rc
|
themes/vertical-light-transparent.tint2rc
|
||||||
themes/vertical-neutral-icons.tint2rc
|
themes/vertical-neutral-icons.tint2rc
|
||||||
doc/tint2.md
|
doc/tint2.md
|
||||||
|
src/separator/separator.c
|
||||||
|
src/separator/separator.h
|
||||||
|
|
Loading…
Reference in a new issue