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 */
|
||||
else if (strcmp(key, "separator") == 0) {
|
||||
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) {
|
||||
Separator *separator = get_or_create_last_separator();
|
||||
extract_values(value, &value1, &value2, &value3);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
Separator *create_separator()
|
||||
{
|
||||
Separator *separator = calloc(1, sizeof(Separator));
|
||||
Separator *separator = (Separator *)calloc(1, sizeof(Separator));
|
||||
return separator;
|
||||
}
|
||||
|
||||
|
@ -61,13 +61,12 @@ void init_separator_panel(void *p)
|
|||
if (panel->separator_list)
|
||||
return;
|
||||
|
||||
|
||||
// panel->separator_list is now a copy of the pointer panel_config.separator_list
|
||||
// We make it a deep copy
|
||||
panel->separator_list = g_list_copy_deep(panel_config.separator_list, NULL, NULL);
|
||||
|
||||
for (GList *l = panel->separator_list; l; l = l->next) {
|
||||
Separator *separator = l->data;
|
||||
Separator *separator = (Separator *)l->data;
|
||||
if (!separator->area.bg)
|
||||
separator->area.bg = &g_array_index(backgrounds, Background, 0);
|
||||
separator->area.parent = p;
|
||||
|
@ -96,7 +95,7 @@ void cleanup_separator()
|
|||
|
||||
gboolean resize_separator(void *obj)
|
||||
{
|
||||
Separator *separator = obj;
|
||||
Separator *separator = (Separator *)obj;
|
||||
// Panel *panel = separator->area.panel;
|
||||
if (!separator->area.on_screen)
|
||||
return FALSE;
|
||||
|
@ -147,7 +146,7 @@ gboolean resize_separator(void *obj)
|
|||
|
||||
void draw_separator(void *obj, cairo_t *c)
|
||||
{
|
||||
Separator *separator = obj;
|
||||
Separator *separator = (Separator *)obj;
|
||||
|
||||
if (separator->style == 0)
|
||||
return;
|
||||
|
@ -165,9 +164,17 @@ void draw_separator(void *obj, cairo_t *c)
|
|||
if (separator->style == 2) {
|
||||
if (!panel_horizontal)
|
||||
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_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_fill(c);
|
||||
return;
|
||||
|
@ -200,7 +207,11 @@ void draw_separator(void *obj, cairo_t *c)
|
|||
|
||||
double separator_pattern[] = {len, len};
|
||||
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);
|
||||
if (separator->style == 6)
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
@ -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;
|
||||
|
|
|
@ -208,3 +208,5 @@ themes/vertical-light-opaque.tint2rc
|
|||
themes/vertical-light-transparent.tint2rc
|
||||
themes/vertical-neutral-icons.tint2rc
|
||||
doc/tint2.md
|
||||
src/separator/separator.c
|
||||
src/separator/separator.h
|
||||
|
|
Loading…
Reference in a new issue