Hi,
well i want to make a pick-a-color-button with a button and a
ColorSelectionDialog Widget. The picked color should be the new
backgroud color of the button. Well the code itself works, but I still
get an error. These are parts of my code:
GtkColorSelection *temp_color;
// The callback for the color-button
void color_button_clicked (GtkButton *button, gpointer user_data)
{
GtkWidget *col_sel;
col_sel = gtk_color_selection_dialog_new ("Choose color");
g_signal_connect_swapped (GTK_OBJECT (GTK_COLOR_SELECTION_DIALOG
(col_sel)->cancel_button),
"clicked",
G_CALLBACK (gtk_widget_destroy),
(gpointer) col_sel);
g_signal_connect (GTK_OBJECT (GTK_COLOR_SELECTION_DIALOG
(col_sel)->ok_button),
"clicked",
G_CALLBACK (apply_color), button);
g_signal_connect (GTK_OBJECT (GTK_COLOR_SELECTION_DIALOG
(col_sel)->colorsel),
"color_changed",
G_CALLBACK (update_temp_color), NULL);
gtk_widget_show (col_sel);
}
// apply color to button
void apply_color (GtkWidget *button, gpointer user_data) {
GdkColor *temp;
gtk_color_selection_get_current_color (temp_color, temp);
gtk_widget_modify_bg (GTK_WIDGET(user_data), GTK_STATE_NORMAL, temp);
}
// temp-color is global. It is used to store the actual color
void update_temp_color (GtkColorSelection *colorselection, gpointer
user_data) {
temp_color = colorselection;
}
Well, sometimes it works quite fine, but mostly I get an error
in libglib-2.0.0.dll. Im using DevC++ 4.9.8.0.
Does anyone know whats wrong? I'm really stuck with my program, due to
that, so I would really appreciate your help. Thanks!
Greets,
Sean P. Mertiens
|