diff --git a/src/tint2conf/CMakeLists.txt b/src/tint2conf/CMakeLists.txt
index f5a937a..3623dc7 100644
--- a/src/tint2conf/CMakeLists.txt
+++ b/src/tint2conf/CMakeLists.txt
@@ -29,7 +29,8 @@ set(SOURCES ../util/common.c
main.c
properties.c
properties_rw.c
- theme_view.c )
+ theme_view.c
+ background_gui.c )
add_definitions( -DTINT2CONF )
diff --git a/src/tint2conf/background_gui.c b/src/tint2conf/background_gui.c
new file mode 100644
index 0000000..2d67806
--- /dev/null
+++ b/src/tint2conf/background_gui.c
@@ -0,0 +1,771 @@
+#include "background_gui.h"
+
+GtkListStore *backgrounds;
+GtkWidget *current_background,
+ *background_fill_color,
+ *background_border_color,
+ *background_fill_color_over,
+ *background_border_color_over,
+ *background_fill_color_press,
+ *background_border_color_press,
+ *background_border_width,
+ *background_corner_radius,
+ *background_border_sides_top,
+ *background_border_sides_bottom,
+ *background_border_sides_left,
+ *background_border_sides_right;
+
+GtkWidget *create_background_combo(const char *label)
+{
+ GtkWidget *combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(backgrounds));
+ GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new();
+ gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, FALSE);
+ gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "pixbuf", bgColPixbuf, NULL);
+ renderer = gtk_cell_renderer_text_new();
+ g_object_set(renderer, "wrap-mode", PANGO_WRAP_WORD, NULL);
+ g_object_set(renderer, "wrap-width", 300, NULL);
+ gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, FALSE);
+ gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "text", bgColText, NULL);
+ g_signal_connect(G_OBJECT(combo), "changed", G_CALLBACK(background_combo_changed), (void*)label);
+ return combo;
+}
+
+void background_combo_changed(GtkWidget *widget, gpointer data)
+{
+ gchar *combo_text = (gchar*)data;
+ if (!combo_text || g_str_equal(combo_text, ""))
+ return;
+ int selected_index = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+
+ int index;
+ for (index = 0; ; index++) {
+ GtkTreePath *path;
+ GtkTreeIter iter;
+
+ path = gtk_tree_path_new_from_indices(index, -1);
+ gboolean found = gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path);
+ gtk_tree_path_free(path);
+
+ if (!found) {
+ break;
+ }
+
+ gchar *text;
+ gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), &iter,
+ bgColText, &text,
+ -1);
+ gchar **parts = g_strsplit(text, ", ", -1);
+ int ifound;
+ for (ifound = 0; parts[ifound]; ifound++) {
+ if (g_str_equal(parts[ifound], combo_text))
+ break;
+ }
+ if (parts[ifound] && index != selected_index) {
+ for (; parts[ifound+1]; ifound++) {
+ gchar *tmp = parts[ifound];
+ parts[ifound] = parts[ifound+1];
+ parts[ifound+1] = tmp;
+ }
+ g_free(parts[ifound]);
+ parts[ifound] = NULL;
+ text = g_strjoinv(", ", parts);
+ g_strfreev(parts);
+ gtk_list_store_set(backgrounds, &iter,
+ bgColText, text,
+ -1);
+ g_free(text);
+ } else if (!parts[ifound] && index == selected_index) {
+ if (!ifound) {
+ text = g_strdup(combo_text);
+ } else {
+ for (ifound = 0; parts[ifound]; ifound++) {
+ if (compare_strings(combo_text, parts[ifound]) < 0)
+ break;
+ }
+ if (parts[ifound]) {
+ gchar *tmp = parts[ifound];
+ parts[ifound] = g_strconcat(combo_text, ", ", tmp, NULL);
+ g_free(tmp);
+ } else {
+ ifound--;
+ gchar *tmp = parts[ifound];
+ parts[ifound] = g_strconcat(tmp, ", ", combo_text, NULL);
+ g_free(tmp);
+ }
+ text = g_strjoinv(", ", parts);
+ g_strfreev(parts);
+ }
+ gtk_list_store_set(backgrounds, &iter,
+ bgColText, text,
+ -1);
+ g_free(text);
+ }
+ }
+}
+
+void create_background(GtkWidget *parent)
+{
+ backgrounds = gtk_list_store_new(bgNumCols,
+ GDK_TYPE_PIXBUF,
+ GDK_TYPE_COLOR,
+ GTK_TYPE_INT,
+ GDK_TYPE_COLOR,
+ GTK_TYPE_INT,
+ GTK_TYPE_INT,
+ GTK_TYPE_INT,
+ GTK_TYPE_STRING,
+ GDK_TYPE_COLOR,
+ GTK_TYPE_INT,
+ GDK_TYPE_COLOR,
+ GTK_TYPE_INT,
+ GDK_TYPE_COLOR,
+ GTK_TYPE_INT,
+ GDK_TYPE_COLOR,
+ GTK_TYPE_INT,
+ GTK_TYPE_BOOL,
+ GTK_TYPE_BOOL,
+ GTK_TYPE_BOOL,
+ GTK_TYPE_BOOL);
+
+ GtkWidget *table, *label, *button;
+ int row, col;
+ GtkTooltips *tooltips = gtk_tooltips_new();
+
+ table = gtk_table_new(1, 4, FALSE);
+ gtk_widget_show(table);
+ gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0);
+ gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING);
+ gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING);
+
+ row = 0, col = 0;
+ label = gtk_label_new(_("Background"));
+ gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
+ gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
+ gtk_widget_show(label);
+ gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
+ col++;
+
+ current_background = create_background_combo(NULL);
+ gtk_widget_show(current_background);
+ gtk_table_attach(GTK_TABLE(table), current_background, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
+ col++;
+ gtk_tooltips_set_tip(tooltips, current_background, _("Selects the background you would like to modify"), NULL);
+
+ button = gtk_button_new_from_stock("gtk-add");
+ gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(background_duplicate), NULL);
+ gtk_widget_show(button);
+ gtk_table_attach(GTK_TABLE(table), button, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
+ col++;
+ gtk_tooltips_set_tip(tooltips, button, _("Creates a copy of the current background"), NULL);
+
+ button = gtk_button_new_from_stock("gtk-remove");
+ gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(background_delete), NULL);
+ gtk_widget_show(button);
+ gtk_table_attach(GTK_TABLE(table), button, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
+ col++;
+ gtk_tooltips_set_tip(tooltips, button, _("Deletes the current background"), NULL);
+
+ table = gtk_table_new(4, 4, FALSE);
+ gtk_widget_show(table);
+ gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0);
+ gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING);
+ gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING);
+
+ row++, col = 2;
+ label = gtk_label_new(_("Fill color"));
+ 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_fill_color = gtk_color_button_new();
+ gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_fill_color), TRUE);
+ gtk_widget_show(background_fill_color);
+ gtk_table_attach(GTK_TABLE(table), background_fill_color, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
+ col++;
+ gtk_tooltips_set_tip(tooltips, background_fill_color, _("The fill color of the current background"), NULL);
+
+ row++, col = 2;
+ label = gtk_label_new(_("Border color"));
+ 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_color = gtk_color_button_new();
+ gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_border_color), TRUE);
+ gtk_widget_show(background_border_color);
+ gtk_table_attach(GTK_TABLE(table), background_border_color, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
+ col++;
+ gtk_tooltips_set_tip(tooltips, background_border_color, _("The border color of the current background"), NULL);
+
+ row++, col = 2;
+ label = gtk_label_new(_("Fill color (mouse over)"));
+ 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_fill_color_over = gtk_color_button_new();
+ gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_fill_color_over), TRUE);
+ gtk_widget_show(background_fill_color_over);
+ gtk_table_attach(GTK_TABLE(table), background_fill_color_over, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
+ col++;
+ gtk_tooltips_set_tip(tooltips, background_fill_color_over, _("The fill color of the current background on mouse over"), NULL);
+
+ row++, col = 2;
+ label = gtk_label_new(_("Border color (mouse over)"));
+ 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_color_over = gtk_color_button_new();
+ gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_border_color_over), TRUE);
+ gtk_widget_show(background_border_color_over);
+ gtk_table_attach(GTK_TABLE(table), background_border_color_over, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
+ col++;
+ gtk_tooltips_set_tip(tooltips, background_border_color_over, _("The border color of the current background on mouse over"), NULL);
+
+ row++, col = 2;
+ label = gtk_label_new(_("Fill color (pressed)"));
+ 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_fill_color_press = gtk_color_button_new();
+ gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_fill_color_press), TRUE);
+ gtk_widget_show(background_fill_color_press);
+ gtk_table_attach(GTK_TABLE(table), background_fill_color_press, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
+ col++;
+ gtk_tooltips_set_tip(tooltips, background_fill_color_press, _("The fill color of the current background on mouse button press"), NULL);
+
+ row++, col = 2;
+ label = gtk_label_new(_("Border color (pressed)"));
+ 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_color_press = gtk_color_button_new();
+ gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_border_color_press), TRUE);
+ gtk_widget_show(background_border_color_press);
+ gtk_table_attach(GTK_TABLE(table), background_border_color_press, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
+ col++;
+ gtk_tooltips_set_tip(tooltips, background_border_color_press, _("The border color of the current background on mouse button press"), NULL);
+
+ row++, col = 2;
+ label = gtk_label_new(_("Border width"));
+ 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_width = gtk_spin_button_new_with_range(0, 100, 1);
+ gtk_widget_show(background_border_width);
+ gtk_table_attach(GTK_TABLE(table), background_border_width, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
+ col++;
+ gtk_tooltips_set_tip(tooltips, background_border_width, _("The width of the border of the current background, in pixels"), NULL);
+
+ row++, col = 2;
+ label = gtk_label_new(_("Corner radius"));
+ 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_corner_radius = gtk_spin_button_new_with_range(0, 100, 1);
+ gtk_widget_show(background_corner_radius);
+ gtk_table_attach(GTK_TABLE(table), background_corner_radius, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
+ col++;
+ 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++;
+
+ 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++;
+
+ 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++;
+
+ 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++;
+
+ 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_border_color), "color-set", G_CALLBACK(background_update), NULL);
+ g_signal_connect(G_OBJECT(background_fill_color_over), "color-set", G_CALLBACK(background_update), NULL);
+ g_signal_connect(G_OBJECT(background_border_color_over), "color-set", G_CALLBACK(background_update), NULL);
+ g_signal_connect(G_OBJECT(background_fill_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_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);
+}
+
+int background_index_safe(int index)
+{
+ if (index <= 0)
+ index = 0;
+ if (index >= get_model_length(GTK_TREE_MODEL(backgrounds)))
+ index = 0;
+ return index;
+}
+
+void background_create_new()
+{
+ int r = 0;
+ int b = 0;
+ gboolean sideTop = TRUE;
+ gboolean sideBottom = TRUE;
+ gboolean sideLeft = TRUE;
+ gboolean sideRight = TRUE;
+ GdkColor fillColor;
+ cairoColor2GdkColor(0, 0, 0, &fillColor);
+ int fillOpacity = 0;
+ GdkColor fillColor2;
+ cairoColor2GdkColor(0, 0, 0, &fillColor2);
+ GdkColor borderColor;
+ cairoColor2GdkColor(0, 0, 0, &borderColor);
+ int borderOpacity = 0;
+
+ GdkColor fillColorOver;
+ cairoColor2GdkColor(0, 0, 0, &fillColorOver);
+ int fillOpacityOver = 0;
+ GdkColor borderColorOver;
+ cairoColor2GdkColor(0, 0, 0, &borderColorOver);
+ int borderOpacityOver = 0;
+
+ GdkColor fillColorPress;
+ cairoColor2GdkColor(0, 0, 0, &fillColorPress);
+ int fillOpacityPress = 0;
+ GdkColor borderColorPress;
+ cairoColor2GdkColor(0, 0, 0, &borderColorPress);
+ int borderOpacityPress = 0;
+
+ int index = 0;
+ GtkTreeIter iter;
+
+ gtk_list_store_append(backgrounds, &iter);
+ gtk_list_store_set(backgrounds, &iter,
+ bgColPixbuf, NULL,
+ bgColFillColor, &fillColor,
+ bgColFillOpacity, fillOpacity,
+ bgColBorderColor, &borderColor,
+ bgColBorderOpacity, borderOpacity,
+ bgColBorderWidth, b,
+ bgColCornerRadius, r,
+ bgColText, "",
+ bgColFillColorOver, &fillColorOver,
+ bgColFillOpacityOver, fillOpacityOver,
+ bgColBorderColorOver, &borderColorOver,
+ bgColBorderOpacityOver, borderOpacityOver,
+ bgColFillColorPress, &fillColorPress,
+ bgColFillOpacityPress, fillOpacityPress,
+ bgColBorderColorPress, &borderColorPress,
+ bgColBorderOpacityPress, borderOpacityPress,
+ bgColBorderSidesTop, sideTop,
+ bgColBorderSidesBottom, sideBottom,
+ bgColBorderSidesLeft, sideLeft,
+ bgColBorderSidesRight, sideRight,
+ -1);
+
+ background_update_image(index);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(current_background), get_model_length(GTK_TREE_MODEL(backgrounds)) - 1);
+ current_background_changed(0, 0);
+}
+
+void background_duplicate(GtkWidget *widget, gpointer data)
+{
+ int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_background));
+ if (index < 0) {
+ background_create_new();
+ return;
+ }
+
+ GtkTreePath *path;
+ GtkTreeIter iter;
+
+ path = gtk_tree_path_new_from_indices(index, -1);
+ gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path);
+ gtk_tree_path_free(path);
+
+ int r;
+ int b;
+ gboolean sideTop;
+ gboolean sideBottom;
+ gboolean sideLeft;
+ gboolean sideRight;
+ GdkColor *fillColor;
+ int fillOpacity;
+ GdkColor *borderColor;
+ int borderOpacity;
+ GdkColor *fillColorOver;
+ int fillOpacityOver;
+ GdkColor *borderColorOver;
+ int borderOpacityOver;
+ GdkColor *fillColorPress;
+ int fillOpacityPress;
+ GdkColor *borderColorPress;
+ int borderOpacityPress;
+
+ gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), &iter,
+ bgColFillColor, &fillColor,
+ bgColFillOpacity, &fillOpacity,
+ bgColBorderColor, &borderColor,
+ bgColBorderOpacity, &borderOpacity,
+ bgColFillColorOver, &fillColorOver,
+ bgColFillOpacityOver, &fillOpacityOver,
+ bgColBorderColorOver, &borderColorOver,
+ bgColBorderOpacityOver, &borderOpacityOver,
+ bgColFillColorPress, &fillColorPress,
+ bgColFillOpacityPress, &fillOpacityPress,
+ bgColBorderColorPress, &borderColorPress,
+ bgColBorderOpacityPress, &borderOpacityPress,
+ bgColBorderWidth, &b,
+ bgColCornerRadius, &r,
+ bgColBorderSidesTop, &sideTop,
+ bgColBorderSidesBottom, &sideBottom,
+ bgColBorderSidesLeft, &sideLeft,
+ bgColBorderSidesRight, &sideRight,
+ -1);
+
+ gtk_list_store_append(backgrounds, &iter);
+ gtk_list_store_set(backgrounds, &iter,
+ bgColPixbuf, NULL,
+ bgColFillColor, fillColor,
+ bgColFillOpacity, fillOpacity,
+ bgColBorderColor, borderColor,
+ bgColBorderOpacity, borderOpacity,
+ bgColText, "",
+ bgColFillColorOver, fillColorOver,
+ bgColFillOpacityOver, fillOpacityOver,
+ bgColBorderColorOver, borderColorOver,
+ bgColBorderOpacityOver, borderOpacityOver,
+ bgColFillColorPress, fillColorPress,
+ bgColFillOpacityPress, fillOpacityPress,
+ bgColBorderColorPress, borderColorPress,
+ bgColBorderOpacityPress, borderOpacityPress,
+ bgColBorderWidth, b,
+ bgColCornerRadius, r,
+ bgColBorderSidesTop, sideTop,
+ bgColBorderSidesBottom, sideBottom,
+ bgColBorderSidesLeft, sideLeft,
+ bgColBorderSidesRight, sideRight,
+ -1);
+ g_boxed_free(GDK_TYPE_COLOR, fillColor);
+ g_boxed_free(GDK_TYPE_COLOR, borderColor);
+ g_boxed_free(GDK_TYPE_COLOR, fillColorOver);
+ g_boxed_free(GDK_TYPE_COLOR, borderColorOver);
+ g_boxed_free(GDK_TYPE_COLOR, fillColorPress);
+ g_boxed_free(GDK_TYPE_COLOR, borderColorPress);
+ background_update_image(get_model_length(GTK_TREE_MODEL(backgrounds)) - 1);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(current_background), get_model_length(GTK_TREE_MODEL(backgrounds)) - 1);
+}
+
+void background_delete(GtkWidget *widget, gpointer data)
+{
+ int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_background));
+ if (index < 0)
+ return;
+
+ if (get_model_length(GTK_TREE_MODEL(backgrounds)) <= 1)
+ return;
+
+ GtkTreePath *path;
+ GtkTreeIter iter;
+
+ path = gtk_tree_path_new_from_indices(index, -1);
+ gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path);
+ gtk_tree_path_free(path);
+
+ gtk_list_store_remove(backgrounds, &iter);
+
+ if (index == get_model_length(GTK_TREE_MODEL(backgrounds)))
+ index--;
+ gtk_combo_box_set_active(GTK_COMBO_BOX(current_background), index);
+}
+
+void background_update_image(int index)
+{
+ GtkTreePath *path;
+ GtkTreeIter iter;
+
+ path = gtk_tree_path_new_from_indices(index, -1);
+ gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path);
+ gtk_tree_path_free(path);
+
+ int w = 70;
+ int h = 30;
+ int r;
+ int b;
+ GdkPixbuf *pixbuf;
+ GdkColor *fillColor;
+ int fillOpacity = 50;
+ GdkColor *borderColor;
+ int borderOpacity = 100;
+
+ gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), &iter,
+ bgColFillColor, &fillColor,
+ bgColFillOpacity, &fillOpacity,
+ bgColBorderColor, &borderColor,
+ bgColBorderOpacity, &borderOpacity,
+ bgColBorderWidth, &b,
+ bgColCornerRadius, &r,
+ -1);
+
+ double bg_r, bg_g, bg_b, bg_a;
+ gdkColor2CairoColor(*fillColor, &bg_r, &bg_g, &bg_b);
+ bg_a = fillOpacity / 100.0;
+
+ double b_r, b_g, b_b, b_a;
+ gdkColor2CairoColor(*borderColor, &b_r, &b_g, &b_b);
+ b_a = borderOpacity / 100.0;
+
+ g_boxed_free(GDK_TYPE_COLOR, fillColor);
+ g_boxed_free(GDK_TYPE_COLOR, borderColor);
+
+ GdkPixmap *pixmap = gdk_pixmap_new(NULL, w, h, 24);
+
+ cairo_t *cr = gdk_cairo_create(pixmap);
+ cairo_set_line_width(cr, b);
+
+ cairo_set_source_rgb(cr, 0.5, 0.5, 0.5);
+ cairo_rectangle(cr, 0, 0, w, h);
+ cairo_fill(cr);
+
+ double degrees = 3.1415926 / 180.0;
+
+ cairo_new_sub_path(cr);
+ cairo_arc(cr, w - r - b, r + b, r, -90 * degrees, 0 * degrees);
+ cairo_arc(cr, w - r - b, h - r - b, r, 0 * degrees, 90 * degrees);
+ cairo_arc(cr, r + b, h - r - b, r, 90 * degrees, 180 * degrees);
+ cairo_arc(cr, r + b, r + b, r, 180 * degrees, 270 * degrees);
+ cairo_close_path(cr);
+
+// cairo_pattern_t *gpat;
+// gpat = cairo_pattern_create_linear(0, 0, 0, h - b);
+// cairo_pattern_add_color_stop_rgba(gpat, 0.1, bg_r, bg_g, bg_b, bg_a);
+// cairo_pattern_add_color_stop_rgba(gpat, 0.9, bg_r2, bg_g2, bg_b2, bg_a2);
+// cairo_set_source(cr, gpat);
+// cairo_fill_preserve(cr);
+// cairo_pattern_destroy(gpat);
+
+ cairo_set_source_rgba(cr, bg_r, bg_g, bg_b, bg_a);
+ cairo_fill_preserve(cr);
+
+ cairo_set_source_rgba(cr, b_r, b_g, b_b, b_a);
+ cairo_set_line_width(cr, b);
+ cairo_stroke(cr);
+ cairo_destroy(cr);
+ cr = NULL;
+
+ pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, gdk_colormap_get_system(), 0, 0, 0, 0, w, h);
+ if (pixmap)
+ g_object_unref(pixmap);
+
+ gtk_list_store_set(backgrounds, &iter,
+ bgColPixbuf, pixbuf,
+ -1);
+ if (pixbuf)
+ g_object_unref(pixbuf);
+}
+
+void background_force_update()
+{
+ background_update(NULL, NULL);
+}
+
+static gboolean background_updates_disabled = FALSE;
+void background_update(GtkWidget *widget, gpointer data)
+{
+ if (background_updates_disabled)
+ return;
+ int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_background));
+ if (index < 0)
+ return;
+
+ GtkTreePath *path;
+ GtkTreeIter iter;
+
+ path = gtk_tree_path_new_from_indices(index, -1);
+ gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path);
+ gtk_tree_path_free(path);
+
+ int r;
+ int b;
+
+ r = gtk_spin_button_get_value(GTK_SPIN_BUTTON(background_corner_radius));
+ b = gtk_spin_button_get_value(GTK_SPIN_BUTTON(background_border_width));
+
+ gboolean sideTop = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(background_border_sides_top));
+ gboolean sideBottom = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(background_border_sides_bottom));
+ gboolean sideLeft = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(background_border_sides_left));
+ gboolean sideRight = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(background_border_sides_right));
+
+ GdkColor fillColor;
+ int fillOpacity;
+ GdkColor borderColor;
+ int borderOpacity;
+ gtk_color_button_get_color(GTK_COLOR_BUTTON(background_fill_color), &fillColor);
+ fillOpacity = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_fill_color)) * 100.0 / 0xffff);
+ gtk_color_button_get_color(GTK_COLOR_BUTTON(background_border_color), &borderColor);
+ borderOpacity = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_border_color)) * 100.0 / 0xffff);
+
+ GdkColor fillColorOver;
+ int fillOpacityOver;
+ GdkColor borderColorOver;
+ int borderOpacityOver;
+ gtk_color_button_get_color(GTK_COLOR_BUTTON(background_fill_color_over), &fillColorOver);
+ fillOpacityOver = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_fill_color_over)) * 100.0 / 0xffff);
+ gtk_color_button_get_color(GTK_COLOR_BUTTON(background_border_color_over), &borderColorOver);
+ borderOpacityOver = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_border_color_over)) * 100.0 / 0xffff);
+
+ GdkColor fillColorPress;
+ int fillOpacityPress;
+ GdkColor borderColorPress;
+ int borderOpacityPress;
+ gtk_color_button_get_color(GTK_COLOR_BUTTON(background_fill_color_press), &fillColorPress);
+ fillOpacityPress = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_fill_color_press)) * 100.0 / 0xffff);
+ gtk_color_button_get_color(GTK_COLOR_BUTTON(background_border_color_press), &borderColorPress);
+ borderOpacityPress = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_border_color_press)) * 100.0 / 0xffff);
+
+ gtk_list_store_set(backgrounds, &iter,
+ bgColPixbuf, NULL,
+ bgColFillColor, &fillColor,
+ bgColFillOpacity, fillOpacity,
+ bgColBorderColor, &borderColor,
+ bgColBorderOpacity, borderOpacity,
+ bgColFillColorOver, &fillColorOver,
+ bgColFillOpacityOver, fillOpacityOver,
+ bgColBorderColorOver, &borderColorOver,
+ bgColBorderOpacityOver, borderOpacityOver,
+ bgColFillColorPress, &fillColorPress,
+ bgColFillOpacityPress, fillOpacityPress,
+ bgColBorderColorPress, &borderColorPress,
+ bgColBorderOpacityPress, borderOpacityPress,
+ bgColBorderWidth, b,
+ bgColCornerRadius, r,
+ bgColBorderSidesTop, sideTop,
+ bgColBorderSidesBottom, sideBottom,
+ bgColBorderSidesLeft, sideLeft,
+ bgColBorderSidesRight, sideRight,
+ -1);
+ background_update_image(index);
+}
+
+void current_background_changed(GtkWidget *widget, gpointer data)
+{
+ int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_background));
+ if (index < 0)
+ return;
+
+ background_updates_disabled = TRUE;
+
+ GtkTreePath *path;
+ GtkTreeIter iter;
+
+ path = gtk_tree_path_new_from_indices(index, -1);
+ gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path);
+ gtk_tree_path_free(path);
+
+ int r;
+ int b;
+
+ gboolean sideTop;
+ gboolean sideBottom;
+ gboolean sideLeft;
+ gboolean sideRight;
+
+ GdkColor *fillColor;
+ int fillOpacity;
+ GdkColor *borderColor;
+ int borderOpacity;
+ GdkColor *fillColorOver;
+ int fillOpacityOver;
+ GdkColor *borderColorOver;
+ int borderOpacityOver;
+ GdkColor *fillColorPress;
+ int fillOpacityPress;
+ GdkColor *borderColorPress;
+ int borderOpacityPress;
+
+
+ gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), &iter,
+ bgColFillColor, &fillColor,
+ bgColFillOpacity, &fillOpacity,
+ bgColBorderColor, &borderColor,
+ bgColBorderOpacity, &borderOpacity,
+ bgColFillColorOver, &fillColorOver,
+ bgColFillOpacityOver, &fillOpacityOver,
+ bgColBorderColorOver, &borderColorOver,
+ bgColBorderOpacityOver, &borderOpacityOver,
+ bgColFillColorPress, &fillColorPress,
+ bgColFillOpacityPress, &fillOpacityPress,
+ bgColBorderColorPress, &borderColorPress,
+ bgColBorderOpacityPress, &borderOpacityPress,
+ bgColBorderWidth, &b,
+ bgColCornerRadius, &r,
+ bgColBorderSidesTop, &sideTop,
+ bgColBorderSidesBottom, &sideBottom,
+ bgColBorderSidesLeft, &sideLeft,
+ bgColBorderSidesRight, &sideRight,
+ -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_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_alpha(GTK_COLOR_BUTTON(background_border_color), (borderOpacity*0xffff)/100);
+
+ gtk_color_button_set_color(GTK_COLOR_BUTTON(background_fill_color_over), fillColorOver);
+ gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_fill_color_over), (fillOpacityOver*0xffff)/100);
+ gtk_color_button_set_color(GTK_COLOR_BUTTON(background_border_color_over), borderColorOver);
+ gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_border_color_over), (borderOpacityOver*0xffff)/100);
+
+ gtk_color_button_set_color(GTK_COLOR_BUTTON(background_fill_color_press), fillColorPress);
+ gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_fill_color_press), (fillOpacityPress*0xffff)/100);
+ gtk_color_button_set_color(GTK_COLOR_BUTTON(background_border_color_press), borderColorPress);
+ gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_border_color_press), (borderOpacityPress*0xffff)/100);
+
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(background_border_width), b);
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(background_corner_radius), r);
+
+ g_boxed_free(GDK_TYPE_COLOR, fillColor);
+ g_boxed_free(GDK_TYPE_COLOR, borderColor);
+ g_boxed_free(GDK_TYPE_COLOR, fillColorOver);
+ g_boxed_free(GDK_TYPE_COLOR, borderColorOver);
+ g_boxed_free(GDK_TYPE_COLOR, fillColorPress);
+ g_boxed_free(GDK_TYPE_COLOR, borderColorPress);
+
+ background_updates_disabled = FALSE;
+ background_update_image(index);
+}
diff --git a/src/tint2conf/background_gui.h b/src/tint2conf/background_gui.h
new file mode 100644
index 0000000..2844ec9
--- /dev/null
+++ b/src/tint2conf/background_gui.h
@@ -0,0 +1,10 @@
+#include "gui.h"
+
+void create_background(GtkWidget *parent);
+void background_duplicate(GtkWidget *widget, gpointer data);
+void background_delete(GtkWidget *widget, gpointer data);
+void background_update_image(int index);
+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);
diff --git a/src/tint2conf/gui.h b/src/tint2conf/gui.h
new file mode 100644
index 0000000..f4a54f1
--- /dev/null
+++ b/src/tint2conf/gui.h
@@ -0,0 +1,20 @@
+#include
+#include
+
+#include "main.h"
+#include "properties.h"
+#include "properties_rw.h"
+#include "../launcher/apps-common.h"
+#include "../launcher/icon-theme-common.h"
+#include "../util/common.h"
+#include "strnatcmp.h"
+
+#define ROW_SPACING 10
+#define COL_SPACING 8
+#define DEFAULT_HOR_SPACING 5
+
+gint compare_strings(gconstpointer a, gconstpointer b);
+void change_paragraph(GtkWidget *widget);
+int get_model_length(GtkTreeModel *model);
+void gdkColor2CairoColor(GdkColor color, double *red, double *green, double *blue);
+void cairoColor2GdkColor(double red, double green, double blue, GdkColor *color);
diff --git a/src/tint2conf/properties.c b/src/tint2conf/properties.c
index 9aa2ad0..0190619 100644
--- a/src/tint2conf/properties.c
+++ b/src/tint2conf/properties.c
@@ -17,21 +17,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**************************************************************************/
-#include
-#include
-
-#include "main.h"
-#include "properties.h"
-#include "properties_rw.h"
-#include "../launcher/apps-common.h"
-#include "../launcher/icon-theme-common.h"
-#include "../util/common.h"
-#include "strnatcmp.h"
-
-#define ROW_SPACING 10
-#define COL_SPACING 8
-#define DEFAULT_HOR_SPACING 5
-
+#include "gui.h"
+#include "background_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;
@@ -142,36 +129,12 @@ IconThemeWrapper *icon_theme;
GtkWidget *launcher_tooltip;
GtkWidget *launcher_icon_theme_override;
-GtkListStore *backgrounds;
-GtkWidget *current_background,
- *background_fill_color,
- *background_fill_color2,
- *background_gradient,
- *background_border_color,
- *background_fill_color_over,
- *background_border_color_over,
- *background_fill_color_press,
- *background_border_color_press,
- *background_border_width,
- *background_corner_radius,
- *background_border_sides_top,
- *background_border_sides_bottom,
- *background_border_sides_left,
- *background_border_sides_right;
-
+GtkListStore *gradients_lists;
GtkWidget *addScrollBarToWidget(GtkWidget *widget);
gboolean gtk_tree_model_iter_prev_tint2(GtkTreeModel *model, GtkTreeIter *iter);
-void change_paragraph(GtkWidget *widget);
void create_general(GtkWidget *parent);
-void create_background(GtkWidget *parent);
-void background_duplicate(GtkWidget *widget, gpointer data);
-void background_delete(GtkWidget *widget, gpointer data);
-void background_update_image(int index);
-void background_update(GtkWidget *widget, gpointer data);
-void current_background_changed(GtkWidget *widget, gpointer data);
-void background_combo_changed(GtkWidget *widget, gpointer data);
void create_panel(GtkWidget *parent);
void create_panel_items(GtkWidget *parent);
void create_launcher(GtkWidget *parent, GtkWindow *window);
@@ -202,7 +165,7 @@ void panel_remove_item(GtkWidget *widget, gpointer data);
void panel_move_item_down(GtkWidget *widget, gpointer data);
void panel_move_item_up(GtkWidget *widget, gpointer data);
-static gint compare_strings(gconstpointer a, gconstpointer b)
+gint compare_strings(gconstpointer a, gconstpointer b)
{
return strnatcasecmp((const char*)a, (const char*)b);
}
@@ -394,94 +357,6 @@ void change_paragraph(GtkWidget *widget)
gtk_container_set_border_width(GTK_CONTAINER(hbox), 6);
}
-GtkWidget *create_background_combo(const char *label)
-{
- GtkWidget *combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(backgrounds));
- GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new();
- gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, FALSE);
- gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "pixbuf", bgColPixbuf, NULL);
- renderer = gtk_cell_renderer_text_new();
- g_object_set(renderer, "wrap-mode", PANGO_WRAP_WORD, NULL);
- g_object_set(renderer, "wrap-width", 300, NULL);
- gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, FALSE);
- gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "text", bgColText, NULL);
- g_signal_connect(G_OBJECT(combo), "changed", G_CALLBACK(background_combo_changed), (void*)label);
- return combo;
-}
-
-void background_combo_changed(GtkWidget *widget, gpointer data)
-{
- gchar *combo_text = (gchar*)data;
- if (!combo_text || g_str_equal(combo_text, ""))
- return;
- int selected_index = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
-
- int index;
- for (index = 0; ; index++) {
- GtkTreePath *path;
- GtkTreeIter iter;
-
- path = gtk_tree_path_new_from_indices(index, -1);
- gboolean found = gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path);
- gtk_tree_path_free(path);
-
- if (!found) {
- break;
- }
-
- gchar *text;
- gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), &iter,
- bgColText, &text,
- -1);
- gchar **parts = g_strsplit(text, ", ", -1);
- int ifound;
- for (ifound = 0; parts[ifound]; ifound++) {
- if (g_str_equal(parts[ifound], combo_text))
- break;
- }
- if (parts[ifound] && index != selected_index) {
- for (; parts[ifound+1]; ifound++) {
- gchar *tmp = parts[ifound];
- parts[ifound] = parts[ifound+1];
- parts[ifound+1] = tmp;
- }
- g_free(parts[ifound]);
- parts[ifound] = NULL;
- text = g_strjoinv(", ", parts);
- g_strfreev(parts);
- gtk_list_store_set(backgrounds, &iter,
- bgColText, text,
- -1);
- g_free(text);
- } else if (!parts[ifound] && index == selected_index) {
- if (!ifound) {
- text = g_strdup(combo_text);
- } else {
- for (ifound = 0; parts[ifound]; ifound++) {
- if (compare_strings(combo_text, parts[ifound]) < 0)
- break;
- }
- if (parts[ifound]) {
- gchar *tmp = parts[ifound];
- parts[ifound] = g_strconcat(combo_text, ", ", tmp, NULL);
- g_free(tmp);
- } else {
- ifound--;
- gchar *tmp = parts[ifound];
- parts[ifound] = g_strconcat(tmp, ", ", combo_text, NULL);
- g_free(tmp);
- }
- text = g_strjoinv(", ", parts);
- g_strfreev(parts);
- }
- gtk_list_store_set(backgrounds, &iter,
- bgColText, text,
- -1);
- g_free(text);
- }
- }
-}
-
void gdkColor2CairoColor(GdkColor color, double *red, double *green, double *blue)
{
*red = color.red / (double)0xffff;
@@ -497,254 +372,6 @@ void cairoColor2GdkColor(double red, double green, double blue, GdkColor *color)
color->blue = blue * 0xffff;
}
-void create_background(GtkWidget *parent)
-{
- backgrounds = gtk_list_store_new(bgNumCols,
- GDK_TYPE_PIXBUF,
- GDK_TYPE_COLOR,
- GTK_TYPE_INT,
- GDK_TYPE_COLOR,
- GTK_TYPE_INT,
- GTK_TYPE_BOOL,
- GDK_TYPE_COLOR,
- GTK_TYPE_INT,
- GTK_TYPE_INT,
- GTK_TYPE_INT,
- GTK_TYPE_STRING,
- GDK_TYPE_COLOR,
- GTK_TYPE_INT,
- GDK_TYPE_COLOR,
- GTK_TYPE_INT,
- GDK_TYPE_COLOR,
- GTK_TYPE_INT,
- GDK_TYPE_COLOR,
- GTK_TYPE_INT,
- GTK_TYPE_BOOL,
- GTK_TYPE_BOOL,
- GTK_TYPE_BOOL,
- GTK_TYPE_BOOL);
-
- GtkWidget *table, *label, *button;
- int row, col;
- GtkTooltips *tooltips = gtk_tooltips_new();
-
- table = gtk_table_new(1, 4, FALSE);
- gtk_widget_show(table);
- gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0);
- gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING);
- gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING);
-
- row = 0, col = 0;
- label = gtk_label_new(_("Background"));
- gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
- gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
- gtk_widget_show(label);
- gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
- col++;
-
- current_background = create_background_combo(NULL);
- gtk_widget_show(current_background);
- gtk_table_attach(GTK_TABLE(table), current_background, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
- col++;
- gtk_tooltips_set_tip(tooltips, current_background, _("Selects the background you would like to modify"), NULL);
-
- button = gtk_button_new_from_stock("gtk-add");
- gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(background_duplicate), NULL);
- gtk_widget_show(button);
- gtk_table_attach(GTK_TABLE(table), button, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
- col++;
- gtk_tooltips_set_tip(tooltips, button, _("Creates a copy of the current background"), NULL);
-
- button = gtk_button_new_from_stock("gtk-remove");
- gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(background_delete), NULL);
- gtk_widget_show(button);
- gtk_table_attach(GTK_TABLE(table), button, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
- col++;
- gtk_tooltips_set_tip(tooltips, button, _("Deletes the current background"), NULL);
-
- table = gtk_table_new(4, 4, FALSE);
- gtk_widget_show(table);
- gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0);
- gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING);
- gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING);
-
- row++, col = 2;
- label = gtk_label_new(_("Fill color"));
- 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_fill_color = gtk_color_button_new();
- gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_fill_color), TRUE);
- gtk_widget_show(background_fill_color);
- gtk_table_attach(GTK_TABLE(table), background_fill_color, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
- col++;
- gtk_tooltips_set_tip(tooltips, background_fill_color, _("The fill color of the current background"), NULL);
-
- row++, col = 2;
- label = gtk_label_new(_("Secondary fill color"));
- 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_fill_color2 = gtk_color_button_new();
- gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_fill_color2), TRUE);
- gtk_widget_show(background_fill_color2);
- gtk_table_attach(GTK_TABLE(table), background_fill_color2, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
-
- col++;
- background_gradient = gtk_check_button_new_with_label(_("Enable gradient"));
- gtk_widget_show(background_gradient);
- gtk_table_attach(GTK_TABLE(table), background_gradient, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
-
- col++;
- gtk_tooltips_set_tip(tooltips, background_fill_color2, _("Color to fade into when using gradient background."), NULL);
-
- row++, col = 2;
- label = gtk_label_new(_("Border color"));
- 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_color = gtk_color_button_new();
- gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_border_color), TRUE);
- gtk_widget_show(background_border_color);
- gtk_table_attach(GTK_TABLE(table), background_border_color, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
- col++;
- gtk_tooltips_set_tip(tooltips, background_border_color, _("The border color of the current background"), NULL);
-
- row++, col = 2;
- label = gtk_label_new(_("Fill color (mouse over)"));
- 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_fill_color_over = gtk_color_button_new();
- gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_fill_color_over), TRUE);
- gtk_widget_show(background_fill_color_over);
- gtk_table_attach(GTK_TABLE(table), background_fill_color_over, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
- col++;
- gtk_tooltips_set_tip(tooltips, background_fill_color_over, _("The fill color of the current background on mouse over"), NULL);
-
- row++, col = 2;
- label = gtk_label_new(_("Border color (mouse over)"));
- 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_color_over = gtk_color_button_new();
- gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_border_color_over), TRUE);
- gtk_widget_show(background_border_color_over);
- gtk_table_attach(GTK_TABLE(table), background_border_color_over, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
- col++;
- gtk_tooltips_set_tip(tooltips, background_border_color_over, _("The border color of the current background on mouse over"), NULL);
-
- row++, col = 2;
- label = gtk_label_new(_("Fill color (pressed)"));
- 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_fill_color_press = gtk_color_button_new();
- gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_fill_color_press), TRUE);
- gtk_widget_show(background_fill_color_press);
- gtk_table_attach(GTK_TABLE(table), background_fill_color_press, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
- col++;
- gtk_tooltips_set_tip(tooltips, background_fill_color_press, _("The fill color of the current background on mouse button press"), NULL);
-
- row++, col = 2;
- label = gtk_label_new(_("Border color (pressed)"));
- 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_color_press = gtk_color_button_new();
- gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_border_color_press), TRUE);
- gtk_widget_show(background_border_color_press);
- gtk_table_attach(GTK_TABLE(table), background_border_color_press, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
- col++;
- gtk_tooltips_set_tip(tooltips, background_border_color_press, _("The border color of the current background on mouse button press"), NULL);
-
- row++, col = 2;
- label = gtk_label_new(_("Border width"));
- 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_width = gtk_spin_button_new_with_range(0, 100, 1);
- gtk_widget_show(background_border_width);
- gtk_table_attach(GTK_TABLE(table), background_border_width, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
- col++;
- gtk_tooltips_set_tip(tooltips, background_border_width, _("The width of the border of the current background, in pixels"), NULL);
-
- row++, col = 2;
- label = gtk_label_new(_("Corner radius"));
- 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_corner_radius = gtk_spin_button_new_with_range(0, 100, 1);
- gtk_widget_show(background_corner_radius);
- gtk_table_attach(GTK_TABLE(table), background_corner_radius, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
- col++;
- 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++;
-
- 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++;
-
- 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++;
-
- 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++;
-
- 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_color2), "color-set", G_CALLBACK(background_update), NULL);
- g_signal_connect(G_OBJECT(background_gradient), "toggled", 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_fill_color_over), "color-set", G_CALLBACK(background_update), NULL);
- g_signal_connect(G_OBJECT(background_border_color_over), "color-set", G_CALLBACK(background_update), NULL);
- g_signal_connect(G_OBJECT(background_fill_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_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);
-}
-
int get_model_length(GtkTreeModel *model)
{
int i;
@@ -762,498 +389,6 @@ int get_model_length(GtkTreeModel *model)
}
}
-int background_index_safe(int index)
-{
- if (index <= 0)
- index = 0;
- if (index >= get_model_length(GTK_TREE_MODEL(backgrounds)))
- index = 0;
- return index;
-}
-
-void background_create_new()
-{
- int r = 0;
- int b = 0;
- gboolean sideTop = TRUE;
- gboolean sideBottom = TRUE;
- gboolean sideLeft = TRUE;
- gboolean sideRight = TRUE;
- GdkColor fillColor;
- cairoColor2GdkColor(0, 0, 0, &fillColor);
- int fillOpacity = 0;
- GdkColor fillColor2;
- cairoColor2GdkColor(0, 0, 0, &fillColor2);
- int fillOpacity2 = 0;
- gboolean gradient = FALSE;
- GdkColor borderColor;
- cairoColor2GdkColor(0, 0, 0, &borderColor);
- int borderOpacity = 0;
-
- GdkColor fillColorOver;
- cairoColor2GdkColor(0, 0, 0, &fillColorOver);
- int fillOpacityOver = 0;
- GdkColor borderColorOver;
- cairoColor2GdkColor(0, 0, 0, &borderColorOver);
- int borderOpacityOver = 0;
-
- GdkColor fillColorPress;
- cairoColor2GdkColor(0, 0, 0, &fillColorPress);
- int fillOpacityPress = 0;
- GdkColor borderColorPress;
- cairoColor2GdkColor(0, 0, 0, &borderColorPress);
- int borderOpacityPress = 0;
-
- int index = 0;
- GtkTreeIter iter;
-
- gtk_list_store_append(backgrounds, &iter);
- gtk_list_store_set(backgrounds, &iter,
- bgColPixbuf, NULL,
- bgColFillColor, &fillColor,
- bgColFillOpacity, fillOpacity,
- bgColFillColor2, &fillColor2,
- bgColFillOpacity2, fillOpacity2,
- bgColGradient, gradient,
- bgColBorderColor, &borderColor,
- bgColBorderOpacity, borderOpacity,
- bgColBorderWidth, b,
- bgColCornerRadius, r,
- bgColText, "",
- bgColFillColorOver, &fillColorOver,
- bgColFillOpacityOver, fillOpacityOver,
- bgColBorderColorOver, &borderColorOver,
- bgColBorderOpacityOver, borderOpacityOver,
- bgColFillColorPress, &fillColorPress,
- bgColFillOpacityPress, fillOpacityPress,
- bgColBorderColorPress, &borderColorPress,
- bgColBorderOpacityPress, borderOpacityPress,
- bgColBorderSidesTop, sideTop,
- bgColBorderSidesBottom, sideBottom,
- bgColBorderSidesLeft, sideLeft,
- bgColBorderSidesRight, sideRight,
- -1);
-
- background_update_image(index);
- gtk_combo_box_set_active(GTK_COMBO_BOX(current_background), get_model_length(GTK_TREE_MODEL(backgrounds)) - 1);
- current_background_changed(0, 0);
-}
-
-void background_duplicate(GtkWidget *widget, gpointer data)
-{
- int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_background));
- if (index < 0) {
- background_create_new();
- return;
- }
-
- GtkTreePath *path;
- GtkTreeIter iter;
-
- path = gtk_tree_path_new_from_indices(index, -1);
- gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path);
- gtk_tree_path_free(path);
-
- int r;
- int b;
- gboolean sideTop;
- gboolean sideBottom;
- gboolean sideLeft;
- gboolean sideRight;
- GdkColor *fillColor;
- int fillOpacity;
- GdkColor *fillColor2;
- int fillOpacity2;
- gboolean gradient;
- GdkColor *borderColor;
- int borderOpacity;
- GdkColor *fillColorOver;
- int fillOpacityOver;
- GdkColor *borderColorOver;
- int borderOpacityOver;
- GdkColor *fillColorPress;
- int fillOpacityPress;
- GdkColor *borderColorPress;
- int borderOpacityPress;
-
- gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), &iter,
- bgColFillColor, &fillColor,
- bgColFillOpacity, &fillOpacity,
- bgColFillColor2, &fillColor2,
- bgColFillOpacity2, &fillOpacity2,
- bgColGradient, &gradient,
- bgColBorderColor, &borderColor,
- bgColBorderOpacity, &borderOpacity,
- bgColFillColorOver, &fillColorOver,
- bgColFillOpacityOver, &fillOpacityOver,
- bgColBorderColorOver, &borderColorOver,
- bgColBorderOpacityOver, &borderOpacityOver,
- bgColFillColorPress, &fillColorPress,
- bgColFillOpacityPress, &fillOpacityPress,
- bgColBorderColorPress, &borderColorPress,
- bgColBorderOpacityPress, &borderOpacityPress,
- bgColBorderWidth, &b,
- bgColCornerRadius, &r,
- bgColBorderSidesTop, &sideTop,
- bgColBorderSidesBottom, &sideBottom,
- bgColBorderSidesLeft, &sideLeft,
- bgColBorderSidesRight, &sideRight,
- -1);
-
- gtk_list_store_append(backgrounds, &iter);
- gtk_list_store_set(backgrounds, &iter,
- bgColPixbuf, NULL,
- bgColFillColor, fillColor,
- bgColFillOpacity, fillOpacity,
- bgColFillColor2, fillColor2,
- bgColFillOpacity2, fillOpacity2,
- bgColGradient, gradient,
- bgColBorderColor, borderColor,
- bgColBorderOpacity, borderOpacity,
- bgColText, "",
- bgColFillColorOver, fillColorOver,
- bgColFillOpacityOver, fillOpacityOver,
- bgColBorderColorOver, borderColorOver,
- bgColBorderOpacityOver, borderOpacityOver,
- bgColFillColorPress, fillColorPress,
- bgColFillOpacityPress, fillOpacityPress,
- bgColBorderColorPress, borderColorPress,
- bgColBorderOpacityPress, borderOpacityPress,
- bgColBorderWidth, b,
- bgColCornerRadius, r,
- bgColBorderSidesTop, sideTop,
- bgColBorderSidesBottom, sideBottom,
- bgColBorderSidesLeft, sideLeft,
- bgColBorderSidesRight, sideRight,
- -1);
- g_boxed_free(GDK_TYPE_COLOR, fillColor);
- g_boxed_free(GDK_TYPE_COLOR, fillColor2);
- g_boxed_free(GDK_TYPE_COLOR, borderColor);
- g_boxed_free(GDK_TYPE_COLOR, fillColorOver);
- g_boxed_free(GDK_TYPE_COLOR, borderColorOver);
- g_boxed_free(GDK_TYPE_COLOR, fillColorPress);
- g_boxed_free(GDK_TYPE_COLOR, borderColorPress);
- background_update_image(get_model_length(GTK_TREE_MODEL(backgrounds)) - 1);
- gtk_combo_box_set_active(GTK_COMBO_BOX(current_background), get_model_length(GTK_TREE_MODEL(backgrounds)) - 1);
-}
-
-void background_delete(GtkWidget *widget, gpointer data)
-{
- int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_background));
- if (index < 0)
- return;
-
- if (get_model_length(GTK_TREE_MODEL(backgrounds)) <= 1)
- return;
-
- GtkTreePath *path;
- GtkTreeIter iter;
-
- path = gtk_tree_path_new_from_indices(index, -1);
- gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path);
- gtk_tree_path_free(path);
-
- gtk_list_store_remove(backgrounds, &iter);
-
- if (index == get_model_length(GTK_TREE_MODEL(backgrounds)))
- index--;
- gtk_combo_box_set_active(GTK_COMBO_BOX(current_background), index);
-}
-
-void background_update_image(int index)
-{
- GtkTreePath *path;
- GtkTreeIter iter;
-
- path = gtk_tree_path_new_from_indices(index, -1);
- gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path);
- gtk_tree_path_free(path);
-
- int w = 70;
- int h = 30;
- int r;
- int b;
- GdkPixbuf *pixbuf;
- GdkColor *fillColor;
- int fillOpacity = 50;
- GdkColor *fillColor2;
- int fillOpacity2 = 50;
- gboolean gradient = FALSE;
- GdkColor *borderColor;
- int borderOpacity = 100;
-
- gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), &iter,
- bgColFillColor, &fillColor,
- bgColFillOpacity, &fillOpacity,
- bgColFillColor2, &fillColor2,
- bgColFillOpacity2, &fillOpacity2,
- bgColGradient, &gradient,
- bgColBorderColor, &borderColor,
- bgColBorderOpacity, &borderOpacity,
- bgColBorderWidth, &b,
- bgColCornerRadius, &r,
- -1);
-
- double bg_r, bg_g, bg_b, bg_a;
- gdkColor2CairoColor(*fillColor, &bg_r, &bg_g, &bg_b);
- bg_a = fillOpacity / 100.0;
-
- double bg_r2, bg_g2, bg_b2, bg_a2;
- gdkColor2CairoColor(*fillColor2, &bg_r2, &bg_g2, &bg_b2);
- bg_a2 = fillOpacity2 / 100.0;
-
- double b_r, b_g, b_b, b_a;
- gdkColor2CairoColor(*borderColor, &b_r, &b_g, &b_b);
- b_a = borderOpacity / 100.0;
-
- g_boxed_free(GDK_TYPE_COLOR, fillColor);
- g_boxed_free(GDK_TYPE_COLOR, fillColor2);
- g_boxed_free(GDK_TYPE_COLOR, borderColor);
-
- GdkPixmap *pixmap = gdk_pixmap_new(NULL, w, h, 24);
-
- cairo_t *cr = gdk_cairo_create(pixmap);
- cairo_set_line_width(cr, b);
-
- cairo_set_source_rgb(cr, 0.5, 0.5, 0.5);
- cairo_rectangle(cr, 0, 0, w, h);
- cairo_fill(cr);
-
- double degrees = 3.1415926 / 180.0;
-
- cairo_new_sub_path(cr);
- cairo_arc(cr, w - r - b, r + b, r, -90 * degrees, 0 * degrees);
- cairo_arc(cr, w - r - b, h - r - b, r, 0 * degrees, 90 * degrees);
- cairo_arc(cr, r + b, h - r - b, r, 90 * degrees, 180 * degrees);
- cairo_arc(cr, r + b, r + b, r, 180 * degrees, 270 * degrees);
- cairo_close_path(cr);
-
- if (gradient) {
- cairo_pattern_t *gpat;
- gpat = cairo_pattern_create_linear(0, 0, 0, h - b);
- cairo_pattern_add_color_stop_rgba(gpat, 0.1, bg_r, bg_g, bg_b, bg_a);
- cairo_pattern_add_color_stop_rgba(gpat, 0.9, bg_r2, bg_g2, bg_b2, bg_a2);
- cairo_set_source(cr, gpat);
- cairo_fill_preserve(cr);
- cairo_pattern_destroy(gpat);
- } else {
- cairo_set_source_rgba(cr, bg_r, bg_g, bg_b, bg_a);
- cairo_fill_preserve(cr);
- }
-
- cairo_set_source_rgba(cr, b_r, b_g, b_b, b_a);
- cairo_set_line_width(cr, b);
- cairo_stroke(cr);
- cairo_destroy(cr);
- cr = NULL;
-
- pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, gdk_colormap_get_system(), 0, 0, 0, 0, w, h);
- if (pixmap)
- g_object_unref(pixmap);
-
- gtk_list_store_set(backgrounds, &iter,
- bgColPixbuf, pixbuf,
- -1);
- if (pixbuf)
- g_object_unref(pixbuf);
-}
-
-void background_force_update()
-{
- background_update(NULL, NULL);
-}
-
-static gboolean background_updates_disabled = FALSE;
-void background_update(GtkWidget *widget, gpointer data)
-{
- if (background_updates_disabled)
- return;
- int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_background));
- if (index < 0)
- return;
-
- GtkTreePath *path;
- GtkTreeIter iter;
-
- path = gtk_tree_path_new_from_indices(index, -1);
- gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path);
- gtk_tree_path_free(path);
-
- int r;
- int b;
-
- r = gtk_spin_button_get_value(GTK_SPIN_BUTTON(background_corner_radius));
- b = gtk_spin_button_get_value(GTK_SPIN_BUTTON(background_border_width));
-
- gboolean sideTop = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(background_border_sides_top));
- gboolean sideBottom = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(background_border_sides_bottom));
- gboolean sideLeft = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(background_border_sides_left));
- gboolean sideRight = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(background_border_sides_right));
-
- GdkColor fillColor;
- int fillOpacity;
- GdkColor fillColor2;
- int fillOpacity2;
- gboolean gradient;
- GdkColor borderColor;
- int borderOpacity;
- gtk_color_button_get_color(GTK_COLOR_BUTTON(background_fill_color), &fillColor);
- fillOpacity = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_fill_color)) * 100.0 / 0xffff);
- gtk_color_button_get_color(GTK_COLOR_BUTTON(background_fill_color2), &fillColor2);
- fillOpacity2 = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_fill_color2)) * 100.0 / 0xffff);
- gradient = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(background_gradient));
- gtk_color_button_get_color(GTK_COLOR_BUTTON(background_border_color), &borderColor);
- borderOpacity = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_border_color)) * 100.0 / 0xffff);
-
- GdkColor fillColorOver;
- int fillOpacityOver;
- GdkColor borderColorOver;
- int borderOpacityOver;
- gtk_color_button_get_color(GTK_COLOR_BUTTON(background_fill_color_over), &fillColorOver);
- fillOpacityOver = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_fill_color_over)) * 100.0 / 0xffff);
- gtk_color_button_get_color(GTK_COLOR_BUTTON(background_border_color_over), &borderColorOver);
- borderOpacityOver = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_border_color_over)) * 100.0 / 0xffff);
-
- GdkColor fillColorPress;
- int fillOpacityPress;
- GdkColor borderColorPress;
- int borderOpacityPress;
- gtk_color_button_get_color(GTK_COLOR_BUTTON(background_fill_color_press), &fillColorPress);
- fillOpacityPress = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_fill_color_press)) * 100.0 / 0xffff);
- gtk_color_button_get_color(GTK_COLOR_BUTTON(background_border_color_press), &borderColorPress);
- borderOpacityPress = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_border_color_press)) * 100.0 / 0xffff);
-
- gtk_list_store_set(backgrounds, &iter,
- bgColPixbuf, NULL,
- bgColFillColor, &fillColor,
- bgColFillOpacity, fillOpacity,
- bgColFillColor2, &fillColor2,
- bgColFillOpacity2, fillOpacity2,
- bgColGradient, gradient,
- bgColBorderColor, &borderColor,
- bgColBorderOpacity, borderOpacity,
- bgColFillColorOver, &fillColorOver,
- bgColFillOpacityOver, fillOpacityOver,
- bgColBorderColorOver, &borderColorOver,
- bgColBorderOpacityOver, borderOpacityOver,
- bgColFillColorPress, &fillColorPress,
- bgColFillOpacityPress, fillOpacityPress,
- bgColBorderColorPress, &borderColorPress,
- bgColBorderOpacityPress, borderOpacityPress,
- bgColBorderWidth, b,
- bgColCornerRadius, r,
- bgColBorderSidesTop, sideTop,
- bgColBorderSidesBottom, sideBottom,
- bgColBorderSidesLeft, sideLeft,
- bgColBorderSidesRight, sideRight,
- -1);
- background_update_image(index);
-}
-
-void current_background_changed(GtkWidget *widget, gpointer data)
-{
- int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_background));
- if (index < 0)
- return;
-
- background_updates_disabled = TRUE;
-
- GtkTreePath *path;
- GtkTreeIter iter;
-
- path = gtk_tree_path_new_from_indices(index, -1);
- gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path);
- gtk_tree_path_free(path);
-
- int r;
- int b;
-
- gboolean sideTop;
- gboolean sideBottom;
- gboolean sideLeft;
- gboolean sideRight;
-
- GdkColor *fillColor;
- int fillOpacity;
- GdkColor *fillColor2;
- int fillOpacity2;
- gboolean gradient;
- GdkColor *borderColor;
- int borderOpacity;
- GdkColor *fillColorOver;
- int fillOpacityOver;
- GdkColor *borderColorOver;
- int borderOpacityOver;
- GdkColor *fillColorPress;
- int fillOpacityPress;
- GdkColor *borderColorPress;
- int borderOpacityPress;
-
-
- gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), &iter,
- bgColFillColor, &fillColor,
- bgColFillOpacity, &fillOpacity,
- bgColFillColor2, &fillColor2,
- bgColFillOpacity2, &fillOpacity2,
- bgColGradient, &gradient,
- bgColBorderColor, &borderColor,
- bgColBorderOpacity, &borderOpacity,
- bgColFillColorOver, &fillColorOver,
- bgColFillOpacityOver, &fillOpacityOver,
- bgColBorderColorOver, &borderColorOver,
- bgColBorderOpacityOver, &borderOpacityOver,
- bgColFillColorPress, &fillColorPress,
- bgColFillOpacityPress, &fillOpacityPress,
- bgColBorderColorPress, &borderColorPress,
- bgColBorderOpacityPress, &borderOpacityPress,
- bgColBorderWidth, &b,
- bgColCornerRadius, &r,
- bgColBorderSidesTop, &sideTop,
- bgColBorderSidesBottom, &sideBottom,
- bgColBorderSidesLeft, &sideLeft,
- bgColBorderSidesRight, &sideRight,
- -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_alpha(GTK_COLOR_BUTTON(background_fill_color), (fillOpacity*0xffff)/100);
-
- gtk_color_button_set_color(GTK_COLOR_BUTTON(background_fill_color2), fillColor2);
- gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_fill_color2), (fillOpacity2*0xffff)/100);
-
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_gradient), gradient);
-
- gtk_color_button_set_color(GTK_COLOR_BUTTON(background_border_color), borderColor);
- gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_border_color), (borderOpacity*0xffff)/100);
-
- gtk_color_button_set_color(GTK_COLOR_BUTTON(background_fill_color_over), fillColorOver);
- gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_fill_color_over), (fillOpacityOver*0xffff)/100);
- gtk_color_button_set_color(GTK_COLOR_BUTTON(background_border_color_over), borderColorOver);
- gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_border_color_over), (borderOpacityOver*0xffff)/100);
-
- gtk_color_button_set_color(GTK_COLOR_BUTTON(background_fill_color_press), fillColorPress);
- gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_fill_color_press), (fillOpacityPress*0xffff)/100);
- gtk_color_button_set_color(GTK_COLOR_BUTTON(background_border_color_press), borderColorPress);
- gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_border_color_press), (borderOpacityPress*0xffff)/100);
-
- gtk_spin_button_set_value(GTK_SPIN_BUTTON(background_border_width), b);
- gtk_spin_button_set_value(GTK_SPIN_BUTTON(background_corner_radius), r);
-
- g_boxed_free(GDK_TYPE_COLOR, fillColor);
- g_boxed_free(GDK_TYPE_COLOR, fillColor2);
- g_boxed_free(GDK_TYPE_COLOR, borderColor);
- g_boxed_free(GDK_TYPE_COLOR, fillColorOver);
- g_boxed_free(GDK_TYPE_COLOR, borderColorOver);
- g_boxed_free(GDK_TYPE_COLOR, fillColorPress);
- g_boxed_free(GDK_TYPE_COLOR, borderColorPress);
-
- background_updates_disabled = FALSE;
- background_update_image(index);
-}
void create_panel(GtkWidget *parent)
{
diff --git a/src/tint2conf/properties.h b/src/tint2conf/properties.h
index 4636c03..062dfa8 100644
--- a/src/tint2conf/properties.h
+++ b/src/tint2conf/properties.h
@@ -183,9 +183,6 @@ enum {
bgColPixbuf = 0,
bgColFillColor,
bgColFillOpacity,
- bgColFillColor2,
- bgColFillOpacity2,
- bgColGradient,
bgColBorderColor,
bgColBorderOpacity,
bgColBorderWidth,
@@ -209,8 +206,6 @@ enum {
extern GtkListStore *backgrounds;
extern GtkWidget *current_background,
*background_fill_color,
- *background_fill_color2,
- *background_gradient,
*background_border_color,
*background_fill_color_over,
*background_border_color_over,
@@ -223,6 +218,8 @@ extern GtkWidget *current_background,
*background_border_sides_right,
*background_corner_radius;
+extern GtkListStore *gradients_list;
+
void background_create_new();
void background_force_update();
int background_index_safe(int index);
diff --git a/src/tint2conf/properties_rw.c b/src/tint2conf/properties_rw.c
index 22a7771..4eabd07 100644
--- a/src/tint2conf/properties_rw.c
+++ b/src/tint2conf/properties_rw.c
@@ -23,7 +23,6 @@ int no_items_systray_enabled;
int no_items_battery_enabled;
static int num_bg;
-static int read_bg_color2;
static int read_bg_color_hover;
static int read_border_color_hover;
static int read_bg_color_press;
@@ -185,9 +184,6 @@ void config_write_backgrounds(FILE *fp)
strcat(sides, "R");
fprintf(fp, "border_sides = %s\n", sides);
- // This is a workaround. For some reason, there was a problem while storing fillOpacity2
- //fillOpacity2 = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_fill_color2)) * 100.0 / 0xffff);
-
config_write_color(fp, "background_color", *fillColor, fillOpacity);
config_write_color(fp, "border_color", *borderColor, borderOpacity);
config_write_color(fp, "background_color_hover", *fillColorOver, fillOpacityOver);
@@ -928,14 +924,6 @@ gboolean config_is_manual(const char *path)
void finalize_bg()
{
if (num_bg > 0) {
- if (!read_bg_color2) {
- GdkColor fillColor;
- gtk_color_button_get_color(GTK_COLOR_BUTTON(background_fill_color),&fillColor);
- gtk_color_button_set_color(GTK_COLOR_BUTTON(background_fill_color2), &fillColor);
- int fillOpacity = gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_fill_color2));
- gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_fill_color2), fillOpacity);
- background_force_update();
- }
if (!read_bg_color_hover) {
GdkColor fillColor;
gtk_color_button_get_color(GTK_COLOR_BUTTON(background_fill_color), &fillColor);
@@ -981,7 +969,6 @@ void add_entry(char *key, char *value)
finalize_bg();
background_create_new();
num_bg++;
- read_bg_color2 = 0;
read_bg_color_hover = 0;
read_border_color_hover = 0;
read_bg_color_press = 0;
diff --git a/tint2.files b/tint2.files
index 2e17683..b485fee 100644
--- a/tint2.files
+++ b/tint2.files
@@ -214,3 +214,6 @@ src/util/gradient.h
src/util/gradient.c
src/util/color.h
src/util/color.c
+src/tint2conf/background_gui.h
+src/tint2conf/background_gui.c
+src/tint2conf/gui.h