all repos — tint2 @ b94cb3eb7e5f603ba1ad580950492d453fee2f21

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

Tint2conf: more gradient support
o9000 mrovi9000@gmail.com
commit

b94cb3eb7e5f603ba1ad580950492d453fee2f21

parent

8ec7f2dd9cfd871ac816e8b5383c8a140b7901a4

M src/tint2conf/background_gui.csrc/tint2conf/background_gui.c

@@ -98,7 +98,7 @@ GDK_TYPE_COLOR,

GTK_TYPE_INT, GDK_TYPE_COLOR, GTK_TYPE_INT, - GTK_TYPE_INT, + GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_STRING,

@@ -106,12 +106,12 @@ GDK_TYPE_COLOR,

GTK_TYPE_INT, GDK_TYPE_COLOR, GTK_TYPE_INT, - GTK_TYPE_INT, + GTK_TYPE_INT, GDK_TYPE_COLOR, GTK_TYPE_INT, GDK_TYPE_COLOR, GTK_TYPE_INT, - GTK_TYPE_INT, + GTK_TYPE_INT, GTK_TYPE_BOOL, GTK_TYPE_BOOL, GTK_TYPE_BOOL,

@@ -359,7 +359,7 @@ g_signal_connect(G_OBJECT(background_border_color_over), "color-set", G_CALLBACK(background_update), NULL);

g_signal_connect(G_OBJECT(background_gradient_over), "changed", 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_gradient_over), "changed", G_CALLBACK(background_update), NULL); + g_signal_connect(G_OBJECT(background_gradient_press), "changed", 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);

@@ -426,8 +426,8 @@ bgColBorderColor,

&borderColor, bgColBorderOpacity, borderOpacity, - bgColGradientId, - -1, + bgColGradientId, + -1, bgColBorderWidth, b, bgColCornerRadius,

@@ -442,8 +442,8 @@ bgColBorderColorOver,

&borderColorOver, bgColBorderOpacityOver, borderOpacityOver, - bgColGradientIdOver, - -1, + bgColGradientIdOver, + -1, bgColFillColorPress, &fillColorPress, bgColFillOpacityPress,

@@ -452,8 +452,8 @@ bgColBorderColorPress,

&borderColorPress, bgColBorderOpacityPress, borderOpacityPress, - bgColGradientIdPress, - -1, + bgColGradientIdPress, + -1, bgColBorderSidesTop, sideTop, bgColBorderSidesBottom,

@@ -542,12 +542,12 @@ bgColBorderSidesLeft,

&sideLeft, bgColBorderSidesRight, &sideRight, - bgColGradientId, - &gradient_id, - bgColGradientIdOver, - &gradient_id_over, - bgColGradientIdPress, - &gradient_id_press, + bgColGradientId, + &gradient_id, + bgColGradientIdOver, + &gradient_id_over, + bgColGradientIdPress, + &gradient_id_press, -1); gtk_list_store_append(backgrounds, &iter);

@@ -561,8 +561,8 @@ bgColFillOpacity,

fillOpacity, bgColBorderColor, borderColor, - bgColGradientId, - gradient_id, + bgColGradientId, + gradient_id, bgColBorderOpacity, borderOpacity, bgColText,

@@ -575,8 +575,8 @@ bgColBorderColorOver,

borderColorOver, bgColBorderOpacityOver, borderOpacityOver, - bgColGradientIdOver, - gradient_id_over, + bgColGradientIdOver, + gradient_id_over, bgColFillColorPress, fillColorPress, bgColFillOpacityPress,

@@ -585,8 +585,8 @@ bgColBorderColorPress,

borderColorPress, bgColBorderOpacityPress, borderOpacityPress, - bgColGradientIdPress, - gradient_id_press, + bgColGradientIdPress, + gradient_id_press, bgColBorderWidth, b, bgColCornerRadius,

@@ -651,6 +651,7 @@ GdkColor *fillColor;

int fillOpacity = 50; GdkColor *borderColor; int borderOpacity = 100; + int gradient_id; gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), &iter,

@@ -666,6 +667,8 @@ bgColBorderWidth,

&b, bgColCornerRadius, &r, + bgColGradientId, + &gradient_id, -1); double bg_r, bg_g, bg_b, bg_a;

@@ -697,9 +700,8 @@ 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); - int gradient_index = gtk_combo_box_get_active(GTK_COMBO_BOX(background_gradient)); - if (index >= 1 && gradient_index >= 1) { - GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)gradient_index)->data; + if (index >= 1 && gradient_id >= 1) { + GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)gradient_id)->data; gradient_draw(cr, g, w, h, TRUE); }

@@ -800,8 +802,8 @@ bgColBorderColor,

&borderColor, bgColBorderOpacity, borderOpacity, - bgColGradientId, - gradient_id, + bgColGradientId, + gradient_id, bgColFillColorOver, &fillColorOver, bgColFillOpacityOver,

@@ -810,8 +812,8 @@ bgColBorderColorOver,

&borderColorOver, bgColBorderOpacityOver, borderOpacityOver, - bgColGradientIdOver, - gradient_id_over, + bgColGradientIdOver, + gradient_id_over, bgColFillColorPress, &fillColorPress, bgColFillOpacityPress,

@@ -820,8 +822,8 @@ bgColBorderColorPress,

&borderColorPress, bgColBorderOpacityPress, borderOpacityPress, - bgColGradientIdPress, - gradient_id_press, + bgColGradientIdPress, + gradient_id_press, bgColBorderWidth, b, bgColCornerRadius,

@@ -885,8 +887,8 @@ bgColBorderColor,

&borderColor, bgColBorderOpacity, &borderOpacity, - bgColGradientId, - &gradient_id, + bgColGradientId, + &gradient_id, bgColFillColorOver, &fillColorOver, bgColFillOpacityOver,

@@ -895,8 +897,8 @@ bgColBorderColorOver,

&borderColorOver, bgColBorderOpacityOver, &borderOpacityOver, - bgColGradientIdOver, - &gradient_id_over, + bgColGradientIdOver, + &gradient_id_over, bgColFillColorPress, &fillColorPress, bgColFillOpacityPress,

@@ -905,8 +907,8 @@ bgColBorderColorPress,

&borderColorPress, bgColBorderOpacityPress, &borderOpacityPress, - bgColGradientIdPress, - &gradient_id_press, + bgColGradientIdPress, + &gradient_id_press, bgColBorderWidth, &b, bgColCornerRadius,

@@ -959,3 +961,61 @@

background_updates_disabled = FALSE; background_update_image(index); } + +void background_update_for_gradient(int gradient_id_changed) +{ + gboolean deleted = gradient_id_changed >= get_model_length(GTK_TREE_MODEL(gradient_ids)); + int current_bg_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_background)); + for (int index = 1;; 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; + } + + int gradient_id, gradient_id_over, gradient_id_press; + + gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), + &iter, + bgColGradientId, + &gradient_id, + bgColGradientIdOver, + &gradient_id_over, + bgColGradientIdPress, + &gradient_id_press, + -1); + gboolean changed = FALSE; + if (gradient_id == gradient_id_changed && deleted) + gradient_id = -1, changed = TRUE; + if (gradient_id_over == gradient_id_changed && deleted) + gradient_id_over = -1, changed = TRUE; + if (gradient_id_press == gradient_id_changed && deleted) + gradient_id_press = -1, changed = TRUE; + if (changed) { + gtk_list_store_set(GTK_LIST_STORE(backgrounds), + &iter, + bgColGradientId, + gradient_id, + bgColGradientIdOver, + gradient_id_over, + bgColGradientIdPress, + gradient_id_press, + -1); + if (index == current_bg_index) { + gtk_combo_box_set_active(GTK_COMBO_BOX(background_gradient), gradient_id); + gtk_combo_box_set_active(GTK_COMBO_BOX(background_gradient_over), gradient_id_over); + gtk_combo_box_set_active(GTK_COMBO_BOX(background_gradient_press), gradient_id_press); + background_force_update(); + } else { + background_update_image(index); + } + } else { + background_update_image(index); + } + } +}
M src/tint2conf/gradient_gui.csrc/tint2conf/gradient_gui.c

@@ -168,9 +168,42 @@ gtk_combo_box_set_active(GTK_COMBO_BOX(current_gradient), index);

current_gradient_changed(0, 0); } +gpointer copy_GradientConfigColorStop(gconstpointer arg, gpointer data) +{ + GradientConfigColorStop *old = (GradientConfigColorStop *)arg; + + GradientConfigColorStop *copy = (GradientConfigColorStop *)calloc(1, sizeof(GradientConfigColorStop)); + memcpy(copy, old, sizeof(GradientConfigColorStop)); + return copy; +} + void gradient_duplicate(GtkWidget *widget, gpointer data) { - gradient_create_new(GRADIENT_CONFIG_VERTICAL); + int old_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient)); + if (old_index < 0) { + gradient_create_new(GRADIENT_CONFIG_VERTICAL); + return; + } + + GradientConfig *g_old = (GradientConfig*)g_list_nth(gradients, (guint)old_index)->data; + + int index = get_model_length(GTK_TREE_MODEL(gradient_ids)); + + GradientConfig *g = (GradientConfig *)calloc(1, sizeof(GradientConfig)); + g->type = g_old->type; + g->extra_color_stops = g_list_copy_deep(g->extra_color_stops, copy_GradientConfigColorStop, NULL); + gradients = g_list_append(gradients, g); + GtkTreeIter iter; + gtk_list_store_append(gradient_ids, &iter); + gtk_list_store_set(gradient_ids, &iter, + grColPixbuf, NULL, + grColId, &index, + grColText, "", + -1); + + gradient_update_image(index); + gtk_combo_box_set_active(GTK_COMBO_BOX(current_gradient), index); + current_gradient_changed(0, 0); } void gradient_delete(GtkWidget *widget, gpointer data)

@@ -192,9 +225,11 @@

gradients = g_list_remove(gradients, g_list_nth(gradients, (guint)index)->data); gtk_list_store_remove(gradient_ids, &iter); - if (index == get_model_length(GTK_TREE_MODEL(gradient_ids))) + background_update_for_gradient(index); + + if (index >= get_model_length(GTK_TREE_MODEL(gradient_ids))) index--; - gtk_combo_box_set_active(GTK_COMBO_BOX(gradient_ids), index); + gtk_combo_box_set_active(GTK_COMBO_BOX(current_gradient), index); } void gradient_draw(cairo_t *c, GradientConfig *g, int w, int h, gboolean preserve)

@@ -302,6 +337,7 @@ grColId, &index,

grColText, "", -1); gradient_update_image(index); + background_update_for_gradient(index); } void current_gradient_changed(GtkWidget *widget, gpointer data)
M src/tint2conf/gradient_gui.hsrc/tint2conf/gradient_gui.h

@@ -12,6 +12,7 @@ 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); +void background_update_for_gradient(int gradient_id); typedef enum GradientConfigType { GRADIENT_CONFIG_VERTICAL = 0,
M src/tint2conf/theme_view.csrc/tint2conf/theme_view.c

@@ -191,7 +191,7 @@ gchar *path;

gtk_tree_model_get(model, &iter, COL_THEME_FILE, &path, -1); char fname[128]; - sprintf(fname, "tint2-%d.jpg", (int)getpid()); + sprintf(fname, "tint2-%d.png", (int)getpid()); gchar *snap = g_build_filename(g_get_tmp_dir(), fname, NULL); g_remove(snap);