Commit e3e81505 authored by o9000's avatar o9000

tint2conf: gradient config

parent d2c36cb8
......@@ -149,15 +149,19 @@ First the user must define one or more gradients in the config file,
each starting with `gradient = TYPE`. These must be added before backgrounds.
Then gradients can be added by index to backgrounds,
using the `gradient_id = INDEX`, `hover_gradient_id = INDEX` and
`pressed_gradient_id = INDEX`, where `INDEX` is
using the `gradient_id = INDEX`, `gradient_id_hover = INDEX` and
`gradient_id_pressed = INDEX`, where `INDEX` is
the gradient index, starting from 1.
#### Simple gradients
#### Gradient types
These are gradients that vary from fixed control points (top-to-bottom, left-to-right
or center-to-corners). The user must specify the start and end colors,
and can optionally add extra color stops in between.
Gradients vary the color between fixed control points:
* vertical gradients: top-to-bottom;
* horizontal gradients: left-to-right;
* radial gradients: center-to-corners.
The user must specify the start and end colors, and can optionally add extra color stops in between
using the `color_stop` option, as explained below.
##### Vertical gradient, with color varying from the top edge to the bottom edge, two colors
......@@ -175,10 +179,10 @@ start_color = #rrggbb opacity
end_color = #rrggbb opacity
```
##### Centered radial gradient, with color varying from the center to the corner, two colors:
##### Radial gradient, with color varying from the center to the corner, two colors:
```
gradient = centered
gradient = radial
start_color = #rrggbb opacity
end_color = #rrggbb opacity
```
......@@ -189,57 +193,6 @@ end_color = #rrggbb opacity
color_stop = percentage #rrggbb opacity
```
#### Advanced gradients
These gradient types allow specifying the control points. This permits, for example,
adding off-center radial glow effects, linear gradients with arbitrary angles,
or using another element's edge as a control point.
Note: updates are currently a little buggy for task buttons.
##### Linear or radial gradients, with arbitrary control points (and orientation)
```
gradient = linear | radial
# Geometry
from_offset_x = SIZE_EXPRESSION
from_offset_y = SIZE_EXPRESSION
# from_offset_r for radial only
from_offset_r = SIZE_EXPRESSION
to_offset_x = SIZE_EXPRESSION
to_offset_y = SIZE_EXPRESSION
# to_offset_r for radial only
to_offset_r = SIZE_EXPRESSION
# Colors
start_color = #rrggbb opacity
end_color = #rrggbb opacity
# Optional: more color stops
color_stop = percentage #rrggbb opacity
color_stop = percentage #rrggbb opacity
```
`SIZE_EXPRESSION` is an expression that encodes an offset,
following the grammar:
```
SIZE_EXPRESSION = number |
SIZE |
SIZE * number |
SIZE * number%
SIZE = width | height | radius | left | right | top | bottom | centerx | centery |
ELEMENT width | ELEMENT height | ELEMENT radius | ELEMENT left | ELEMENT right | ELEMENT top | ELEMENT bottom | ELEMENT centerx | ELEMENT centery
ELEMENT = self | parent | panel
```
All coordinates are computed in the drawn element's coordinate system,
with origin in the top-left corner and the vertical axis growing down.
Numbers are any real numbers. Negative numbers must not have spaces between
the minus sign and the first digit, for example `-1.234` is correct,
while `- 1.234` is not.
Multiple `*_offset_*` can be given, in which case they are added together.
#### Gradient examples
```
......@@ -249,60 +202,17 @@ start_color = #111122 30
end_color = #112211 30
color_stop = 60 #221111 30
# Gradient 2: center glow
gradient = centered
start_color = #ffffff 20
end_color = #ffffff 0
# Gradient 3: glow
# Gradient 2: radial glow
gradient = radial
start_color = #ffffff 20
end_color = #ffffff 0
from_offset_x = width * 0.28
from_offset_y = height * 0.28
from_offset_r = 0
to_offset_x = width * 0.28
to_offset_y = height * 0.28
to_offset_r = radius * 2
# Gradient 4: aurora
gradient = linear
start_color = #ffffff 0
end_color = #ffffff 0
from_offset_x = panel left
from_offset_y = panel top
to_offset_x = panel width * 3
to_offset_x = panel height * 3
to_offset_y = panel width
to_offset_y = panel height
color_stop = 0.1 #ffffff 30
color_stop = 0.8 #ffffff 30
color_stop = 2.1 #7777aa 30
color_stop = 3.1 #7777aa 30
color_stop = 4.0 #ffffaa 30
color_stop = 4.8 #aa7733 30
color_stop = 5.1 #ff7733 30
color_stop = 6.5 #337788 30
color_stop = 9.2 #ffffaa 30
color_stop = 10.1 #777777 30
color_stop = 12.1 #aaaaff 30
color_stop = 14.0 #77ff77 30
color_stop = 18.0 #ffff77 30
color_stop = 19.8 #77ffaa 30
color_stop = 21.1 #ffffaa 20
color_stop = 23.5 #337733 30
color_stop = 25.5 #337733 30
color_stop = 29.2 #77ffff 30
color_stop = 30.1 #77ffaa 30
color_stop = 31.0 #ffffaa 30
color_stop = 34.8 #aa7733 30
# Gradient 5: elegant black
# Gradient 3: elegant black
gradient = vertical
start_color = #444444 100
end_color = #222222 100
# Gradient 6: elegant black
# Gradient 4: elegant black
gradient = horizontal
start_color = #111111 100
end_color = #222222 100
......@@ -318,8 +228,8 @@ border_color_hover = #ffffff 60
background_color_pressed = #555555 10
border_color_pressed = #ffffff 60
gradient_id = 3
hover_gradient_id = 4
pressed_gradient_id = 2
gradient_id_hover = 4
gradient_id_pressed = 2
[...]
```
......
......@@ -319,13 +319,13 @@ void add_entry(char *key, char *value)
id = (id < gradients->len && id >= 0) ? id : -1;
if (id >= 0)
bg->gradients[MOUSE_NORMAL] = &g_array_index(gradients, GradientClass, id);
} else if (strcmp(key, "hover_gradient_id") == 0) {
} else if (strcmp(key, "gradient_id_hover") == 0 || strcmp(key, "hover_gradient_id") == 0) {
Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1);
int id = atoi(value);
id = (id < gradients->len && id >= 0) ? id : -1;
if (id >= 0)
bg->gradients[MOUSE_OVER] = &g_array_index(gradients, GradientClass, id);
} else if (strcmp(key, "pressed_gradient_id") == 0) {
} else if (strcmp(key, "gradient_id_pressed") == 0 || strcmp(key, "pressed_gradient_id") == 0) {
Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1);
int id = atoi(value);
id = (id < gradients->len && id >= 0) ? id : -1;
......@@ -366,82 +366,6 @@ void add_entry(char *key, char *value)
else
color_stop->color.alpha = 0.5;
g->extra_color_stops = g_list_append(g->extra_color_stops, color_stop);
} else if (strcmp(key, "from_offset_x") == 0) {
GradientClass *g = &g_array_index(gradients, GradientClass, gradients->len - 1);
if (g->type == GRADIENT_HORIZONTAL || g->type == GRADIENT_VERTICAL || g->type == GRADIENT_CENTERED) {
fprintf(stderr, RED "Control points can only be specified for linear and radial gradients: line %s = %s" RESET "\n", key, value);
} else {
Offset *offset = offset_from_string(value);
if (!offset) {
fprintf(stderr, RED "Invalid value: line %s = %s" RESET "\n", key, value);
} else {
g->from.offsets_x = g_list_append(g->from.offsets_x, offset);
}
}
} else if (strcmp(key, "from_offset_y") == 0) {
GradientClass *g = &g_array_index(gradients, GradientClass, gradients->len - 1);
if (g->type == GRADIENT_HORIZONTAL || g->type == GRADIENT_VERTICAL || g->type == GRADIENT_CENTERED) {
fprintf(stderr, RED "Control points can only be specified for linear and radial gradients: line %s = %s" RESET "\n", key, value);
} else {
Offset *offset = offset_from_string(value);
if (!offset) {
fprintf(stderr, RED "Invalid value: line %s = %s" RESET "\n", key, value);
} else {
g->from.offsets_y = g_list_append(g->from.offsets_y, offset);
}
}
} else if (strcmp(key, "from_offset_r") == 0) {
GradientClass *g = &g_array_index(gradients, GradientClass, gradients->len - 1);
if (g->type == GRADIENT_HORIZONTAL || g->type == GRADIENT_VERTICAL || g->type == GRADIENT_CENTERED) {
fprintf(stderr, RED "Control points can only be specified for linear and radial gradients: line %s = %s" RESET "\n", key, value);
} else if (g->type == GRADIENT_LINEAR) {
fprintf(stderr, RED "Invalid parameter for linear gradient: line %s = %s" RESET "\n", key, value);
} else {
Offset *offset = offset_from_string(value);
if (!offset) {
fprintf(stderr, RED "Invalid value: line %s = %s" RESET "\n", key, value);
} else {
g->from.offsets_r = g_list_append(g->from.offsets_r, offset);
}
}
} else if (strcmp(key, "to_offset_x") == 0) {
GradientClass *g = &g_array_index(gradients, GradientClass, gradients->len - 1);
if (g->type == GRADIENT_HORIZONTAL || g->type == GRADIENT_VERTICAL || g->type == GRADIENT_CENTERED) {
fprintf(stderr, RED "Control points can only be specified for linear and radial gradients: line %s = %s" RESET "\n", key, value);
} else {
Offset *offset = offset_from_string(value);
if (!offset) {
fprintf(stderr, RED "Invalid value: line %s = %s" RESET "\n", key, value);
} else {
g->to.offsets_x = g_list_append(g->to.offsets_x, offset);
}
}
} else if (strcmp(key, "to_offset_y") == 0) {
GradientClass *g = &g_array_index(gradients, GradientClass, gradients->len - 1);
if (g->type == GRADIENT_HORIZONTAL || g->type == GRADIENT_VERTICAL || g->type == GRADIENT_CENTERED) {
fprintf(stderr, RED "Control points can only be specified for linear and radial gradients: line %s = %s" RESET "\n", key, value);
} else {
Offset *offset = offset_from_string(value);
if (!offset) {
fprintf(stderr, RED "Invalid value: line %s = %s" RESET "\n", key, value);
} else {
g->to.offsets_y = g_list_append(g->to.offsets_y, offset);
}
}
} else if (strcmp(key, "to_offset_r") == 0) {
GradientClass *g = &g_array_index(gradients, GradientClass, gradients->len - 1);
if (g->type == GRADIENT_HORIZONTAL || g->type == GRADIENT_VERTICAL || g->type == GRADIENT_CENTERED) {
fprintf(stderr, RED "Control points can only be specified for linear and radial gradients: line %s = %s" RESET "\n", key, value);
} else if (g->type == GRADIENT_LINEAR) {
fprintf(stderr, RED "Invalid parameter for linear gradient: line %s = %s" RESET "\n", key, value);
} else {
Offset *offset = offset_from_string(value);
if (!offset) {
fprintf(stderr, RED "Invalid value: line %s = %s" RESET "\n", key, value);
} else {
g->to.offsets_r = g_list_append(g->to.offsets_r, offset);
}
}
}
/* Panel */
......
......@@ -30,7 +30,8 @@ set(SOURCES ../util/common.c
properties.c
properties_rw.c
theme_view.c
background_gui.c )
background_gui.c
gradient_gui.c )
add_definitions( -DTINT2CONF )
......
This diff is collapsed.
#ifndef BACKGROUND_GUI_H
#define BACKGROUND_GUI_H
#include "gui.h"
void create_background(GtkWidget *parent);
......@@ -8,3 +11,5 @@ void background_update(GtkWidget *widget, gpointer data);
void current_background_changed(GtkWidget *widget, gpointer data);
void background_combo_changed(GtkWidget *widget, gpointer data);
GtkWidget *create_background_combo(const char *label);
#endif
This diff is collapsed.
#ifndef GRADIENT_GUI_H
#define GRADIENT_GUI_H
#include "gui.h"
int gradient_index_safe(int index);
void create_gradient(GtkWidget *parent);
GtkWidget *create_gradient_combo();
void gradient_duplicate(GtkWidget *widget, gpointer data);
void gradient_delete(GtkWidget *widget, gpointer data);
void gradient_update_image(int index);
void gradient_update(GtkWidget *widget, gpointer data);
void gradient_force_update();
void current_gradient_changed(GtkWidget *widget, gpointer data);
typedef enum GradientConfigType {
GRADIENT_CONFIG_VERTICAL = 0,
GRADIENT_CONFIG_HORIZONTAL,
GRADIENT_CONFIG_RADIAL
} GradientConfigType;
typedef struct GradientConfigColorStop {
Color color;
// offset in 0-1
double offset;
} GradientConfigColorStop;
typedef struct GradientConfig {
GradientConfigType type;
GradientConfigColorStop start_color;
GradientConfigColorStop end_color;
// Each element is a GradientConfigColorStop
GList *extra_color_stops;
} GradientConfig;
void gradient_create_new(GradientConfigType t);
void gradient_draw(cairo_t *c, GradientConfig *g, int w, int h, gboolean preserve);
#endif
......@@ -19,6 +19,7 @@
#include "gui.h"
#include "background_gui.h"
#include "gradient_gui.h"
GtkWidget *panel_width, *panel_height, *panel_margin_x, *panel_margin_y, *panel_padding_x, *panel_padding_y, *panel_spacing;
GtkWidget *panel_wm_menu, *panel_dock, *panel_autohide, *panel_autohide_show_time, *panel_autohide_hide_time, *panel_autohide_size;
......@@ -129,8 +130,6 @@ IconThemeWrapper *icon_theme;
GtkWidget *launcher_tooltip;
GtkWidget *launcher_icon_theme_override;
GtkListStore *gradients_lists;
GtkWidget *addScrollBarToWidget(GtkWidget *widget);
gboolean gtk_tree_model_iter_prev_tint2(GtkTreeModel *model, GtkTreeIter *iter);
......@@ -220,7 +219,7 @@ GtkWidget *create_properties()
GtkWidget *view, *dialog_vbox3, *button;
GtkTooltips *tooltips;
GtkWidget *page_panel, *page_panel_items, *page_launcher, *page_taskbar, *page_battery, *page_clock,
*page_tooltip, *page_systemtray, *page_task, *page_background;
*page_tooltip, *page_systemtray, *page_task, *page_background, *page_gradient;
GtkWidget *label;
tooltips = gtk_tooltips_new();
......@@ -265,6 +264,14 @@ GtkWidget *create_properties()
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
// notebook
label = gtk_label_new(_("Gradients"));
gtk_widget_show(label);
page_gradient = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING);
gtk_container_set_border_width(GTK_CONTAINER(page_gradient), 10);
gtk_widget_show(page_gradient);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), addScrollBarToWidget(page_gradient), label);
create_gradient(page_gradient);
label = gtk_label_new(_("Backgrounds"));
gtk_widget_show(label);
page_background = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING);
......
......@@ -185,6 +185,7 @@ enum {
bgColFillOpacity,
bgColBorderColor,
bgColBorderOpacity,
bgColGradientId,
bgColBorderWidth,
bgColCornerRadius,
bgColText,
......@@ -192,10 +193,12 @@ enum {
bgColFillOpacityOver,
bgColBorderColorOver,
bgColBorderOpacityOver,
bgColGradientIdOver,
bgColFillColorPress,
bgColFillOpacityPress,
bgColBorderColorPress,
bgColBorderOpacityPress,
bgColGradientIdPress,
bgColBorderSidesTop,
bgColBorderSidesBottom,
bgColBorderSidesLeft,
......@@ -207,10 +210,13 @@ extern GtkListStore *backgrounds;
extern GtkWidget *current_background,
*background_fill_color,
*background_border_color,
*background_gradient,
*background_fill_color_over,
*background_border_color_over,
*background_gradient_over,
*background_fill_color_press,
*background_border_color_press,
*background_gradient_press,
*background_border_width,
*background_border_sides_top,
*background_border_sides_bottom,
......@@ -218,7 +224,21 @@ extern GtkWidget *current_background,
*background_border_sides_right,
*background_corner_radius;
extern GtkListStore *gradients_list;
// gradients
enum {
grColPixbuf = 0,
grColId,
grColText,
grNumCols
};
extern GtkListStore *gradient_ids;
extern GList *gradients;
extern GtkWidget *current_gradient,
*gradient_combo_type,
*gradient_start_color,
*gradient_end_color,
*gradient_color_stops;
void background_create_new();
void background_force_update();
......
......@@ -6,7 +6,9 @@
#include "common.h"
#include "properties.h"
#include "properties_rw.h"
#include "gradient_gui.h"
void finalize_gradient();
void finalize_bg();
void add_entry(char *key, char *value);
void hex2gdk(char *hex, GdkColor *color);
......@@ -28,10 +30,13 @@ static int read_border_color_hover;
static int read_bg_color_press;
static int read_border_color_press;
static int num_gr;
void config_read_file(const char *path)
{
num_bg = 0;
background_create_new();
gradient_create_new(GRADIENT_CONFIG_VERTICAL);
FILE *fp;
char line[512];
......@@ -58,6 +63,7 @@ void config_read_file(const char *path)
}
fclose(fp);
finalize_gradient();
finalize_bg();
if (!config_has_panel_items) {
......@@ -89,6 +95,40 @@ void config_write_color(FILE *fp, const char *name, GdkColor color, int opacity)
fprintf(fp, "%s = #%02x%02x%02x %d\n", name, color.red >> 8, color.green >> 8, color.blue >> 8, opacity);
}
void config_write_gradients(FILE *fp)
{
fprintf(fp, "#-------------------------------------\n");
fprintf(fp, "# Gradients\n");
int index = 1;
for (GList *gl = gradients ? gradients->next : NULL; gl; gl = gl->next, index++) {
GradientConfig *g = (GradientConfig *)gl->data;
GdkColor color;
int opacity;
fprintf(fp, "# Gradient %d\n", index);
fprintf(fp, "gradient = %s\n", g->type == GRADIENT_CONFIG_HORIZONTAL ? "horizontal" : g->type == GRADIENT_CONFIG_VERTICAL ? "vertical" : "radial");
cairoColor2GdkColor(g->start_color.color.rgb[0], g->start_color.color.rgb[1], g->start_color.color.rgb[2], &color);
opacity = g->start_color.color.alpha * 100;
config_write_color(fp, "start_color", color, opacity);
cairoColor2GdkColor(g->end_color.color.rgb[0], g->end_color.color.rgb[1], g->end_color.color.rgb[2], &color);
opacity = g->end_color.color.alpha * 100;
config_write_color(fp, "end_color", color, opacity);
for (GList *l = g->extra_color_stops; l; l = l->next) {
GradientConfigColorStop *stop = (GradientConfigColorStop *)l->data;
// color_stop = percentage #rrggbb opacity
cairoColor2GdkColor(stop->color.rgb[0], stop->color.rgb[1], stop->color.rgb[2], &color);
opacity = stop->color.alpha * 100;
fprintf(fp, "color_stop = %f #%02x%02x%02x %d\n", stop->offset * 100, color.red >> 8, color.green >> 8, color.blue >> 8, opacity);
}
fprintf(fp, "\n");
}
}
void config_write_backgrounds(FILE *fp)
{
fprintf(fp, "#-------------------------------------\n");
......@@ -117,14 +157,17 @@ void config_write_backgrounds(FILE *fp)
int fillOpacity;
GdkColor *borderColor;
int borderOpacity;
int gradient_id;
GdkColor *fillColorOver;
int fillOpacityOver;
GdkColor *borderColorOver;
int borderOpacityOver;
int gradient_id_over;
GdkColor *fillColorPress;
int fillOpacityPress;
GdkColor *borderColorPress;
int borderOpacityPress;
int gradient_id_press;
gchar *text;
gtk_tree_model_get(GTK_TREE_MODEL(backgrounds),
......@@ -137,6 +180,8 @@ void config_write_backgrounds(FILE *fp)
&borderColor,
bgColBorderOpacity,
&borderOpacity,
bgColGradientId,
&gradient_id,
bgColFillColorOver,
&fillColorOver,
bgColFillOpacityOver,
......@@ -145,6 +190,8 @@ void config_write_backgrounds(FILE *fp)
&borderColorOver,
bgColBorderOpacityOver,
&borderOpacityOver,
bgColGradientIdOver,
&gradient_id_over,
bgColFillColorPress,
&fillColorPress,
bgColFillOpacityPress,
......@@ -153,6 +200,8 @@ void config_write_backgrounds(FILE *fp)
&borderColorPress,
bgColBorderOpacityPress,
&borderOpacityPress,
bgColGradientIdPress,
&gradient_id_press,
bgColBorderWidth,
&b,
bgColCornerRadius,
......@@ -186,10 +235,13 @@ void config_write_backgrounds(FILE *fp)
config_write_color(fp, "background_color", *fillColor, fillOpacity);
config_write_color(fp, "border_color", *borderColor, borderOpacity);
fprintf(fp, "gradient_id = %d\n", gradient_id);
config_write_color(fp, "background_color_hover", *fillColorOver, fillOpacityOver);
config_write_color(fp, "border_color_hover", *borderColorOver, borderOpacityOver);
fprintf(fp, "gradient_id_hover = %d\n", gradient_id_over);
config_write_color(fp, "background_color_pressed", *fillColorPress, fillOpacityPress);
config_write_color(fp, "border_color_pressed", *borderColorPress, borderOpacityPress);
fprintf(fp, "gradient_id_pressed = %d\n", gradient_id_press);
fprintf(fp, "\n");
}
}
......@@ -871,6 +923,7 @@ void config_save_file(const char *path)
fprintf(fp, "# See https://gitlab.com/o9000/tint2/wikis/Configure for \n");
fprintf(fp, "# full documentation of the configuration options.\n");
config_write_gradients(fp);
config_write_backgrounds(fp);
config_write_panel(fp);
config_write_taskbar(fp);
......@@ -959,10 +1012,60 @@ void finalize_bg()
}
}
void finalize_gradient()
{
if (num_gr > 0) {
gradient_force_update();
}
}
void add_entry(char *key, char *value)
{
char *value1 = 0, *value2 = 0, *value3 = 0;
/* Gradients */
if (strcmp(key, "gradient") == 0) {
finalize_gradient();
GradientConfigType t;
if (g_str_equal(value, "horizontal"))
t = GRADIENT_CONFIG_HORIZONTAL;
else if (g_str_equal(value, "vertical"))
t = GRADIENT_CONFIG_VERTICAL;
else
t = GRADIENT_CONFIG_RADIAL;
gradient_create_new(t);
num_gr++;
gradient_force_update();
} else if (strcmp(key, "start_color") == 0) {
extract_values(value, &value1, &value2, &value3);
GdkColor col;
hex2gdk(value1, &col);
gtk_color_button_set_color(GTK_COLOR_BUTTON(gradient_start_color), &col);
int alpha = value2 ? atoi(value2) : 50;
gtk_color_button_set_alpha(GTK_COLOR_BUTTON(gradient_start_color), (alpha * 65535) / 100);
gradient_force_update();
} else if (strcmp(key, "end_color") == 0) {
extract_values(value, &value1, &value2, &value3);
GdkColor col;
hex2gdk(value1, &col);
gtk_color_button_set_color(GTK_COLOR_BUTTON(gradient_end_color), &col);
int alpha = value2 ? atoi(value2) : 50;
gtk_color_button_set_alpha(GTK_COLOR_BUTTON(gradient_end_color), (alpha * 65535) / 100);
gradient_force_update();
} else if (strcmp(key, "color_stop") == 0) {
GradientConfig *g = (GradientConfig *)g_list_last(gradients)->data;
extract_values(value, &value1, &value2, &value3);
GradientConfigColorStop *color_stop = (GradientConfigColorStop *) calloc(1, sizeof(GradientConfigColorStop));
color_stop->offset = atof(value1) / 100.0;
get_color(value2, color_stop->color.rgb);
if (value3)
color_stop->color.alpha = (atoi(value3) / 100.0);
else
color_stop->color.alpha = 0.5;
g->extra_color_stops = g_list_append(g->extra_color_stops, color_stop);
current_gradient_changed(NULL, NULL);
} else
/* Background and border */
if (strcmp(key, "rounded") == 0) {
// 'rounded' is the first parameter => alloc a new background
......@@ -1040,7 +1143,20 @@ void add_entry(char *key, char *value)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_right),
strchr(value, 'r') || strchr(value, 'R'));
background_force_update();
} else if (strcmp(key, "gradient_id") == 0) {
int id = gradient_index_safe(atoi(value));
gtk_combo_box_set_active(GTK_COMBO_BOX(background_gradient), id);
background_force_update();
} else if (strcmp(key, "gradient_id_hover") == 0 || strcmp(key, "hover_gradient_id") == 0) {
int id = gradient_index_safe(atoi(value));
gtk_combo_box_set_active(GTK_COMBO_BOX(background_gradient_over), id);
background_force_update();
} else if (strcmp(key, "gradient_id_pressed") == 0 || strcmp(key, "pressed_gradient_id") == 0) {
int id = gradient_index_safe(atoi(value));
gtk_combo_box_set_active(GTK_COMBO_BOX(background_gradient_press), id);
background_force_update();
}
/* Panel */
else if (strcmp(key, "panel_size") == 0) {
extract_values(value, &value1, &value2, &value3);
......
......@@ -1061,8 +1061,7 @@ void update_gradient(GradientInstance *gi)
compute_control_point(gi, &gi->gradient_class->from, &from_x, &from_y, &from_r);
double to_x, to_y, to_r;
compute_control_point(gi, &gi->gradient_class->to, &to_x, &to_y, &to_r);
if (gi->gradient_class->type == GRADIENT_VERTICAL || gi->gradient_class->type == GRADIENT_HORIZONTAL ||
gi->gradient_class->type == GRADIENT_LINEAR) {
if (gi->gradient_class->type == GRADIENT_VERTICAL || gi->gradient_class->type == GRADIENT_HORIZONTAL) {
gi->pattern = cairo_pattern_create_linear(from_x, from_y, to_x, to_y);
if (debug_gradients)
fprintf(stderr,
......@@ -1072,7 +1071,7 @@ void update_gradient(GradientInstance *gi)
from_y,
to_x,
to_y);
} else if (gi->gradient_class->type == GRADIENT_CENTERED || gi->gradient_class->type == GRADIENT_RADIAL) {
} else if (gi->gradient_class->type == GRADIENT_CENTERED) {
gi->pattern = cairo_pattern_create_radial(from_x, from_y, from_r, to_x, to_y, to_r);
if (debug_gradients)
fprintf(stderr,
......
......@@ -38,191 +38,12 @@ GradientType gradient_type_from_string(const char *str)
return GRADIENT_HORIZONTAL;
if (g_str_equal(str, "vertical"))
return GRADIENT_VERTICAL;
if (g_str_equal(str, "centered"))
return GRADIENT_CENTERED;
if (g_str_equal(str, "linear"))
return GRADIENT_LINEAR;
if (g_str_equal(str, "radial"))
return GRADIENT_RADIAL;
return GRADIENT_CENTERED;
fprintf(stderr, RED "Invalid gradient type: %s" RESET "\n", str);
return GRADIENT_VERTICAL;
}
gboolean read_element_from_string(const char *str, Element *element)
{
if (g_str_equal(str, "self")) {
*element = ELEMENT_SELF;
return TRUE;
}
if (g_str_equal(str, "parent")) {
*element = ELEMENT_PARENT;
return TRUE;
}
if (g_str_equal(str, "panel")) {
*element = ELEMENT_PANEL;
return TRUE;
}
return FALSE;
}
Element element_from_string(const char *str)
{
Element result;
if (read_element_from_string(str, &result))
return result;
fprintf(stderr, RED "Invalid origin type: %s" RESET "\n", str);
return ELEMENT_SELF;
}
gboolean read_size_from_string(const char *str, SizeVariable *variable)
{
if (g_str_equal(str, "width")) {
*variable = SIZE_WIDTH;
return TRUE;
}
if (g_str_equal(str, "height")) {
*variable = SIZE_HEIGHT;
return TRUE;</