Problem saving color returned from gtk_color_selection_get_current_color
- From: "Stewart Weiss" <stewart weiss acm org>
- To: <gtk-list gnome org>
- Subject: Problem saving color returned from gtk_color_selection_get_current_color
- Date: Fri, 23 Nov 2007 16:12:17 -0500
I am baffled by this one. In a callback that opens the
GtkColorSelectionDialog,
I am trying to save the selected color so that I can access it in other
functions.
So when I call
gtk_color_selection_get_current_color (colorsel, &selectedcolor);
it works fine if I have declared
GdkColor selected_color;
in global scope.
However, if I have
typedef struct _AppState {
....
GdkColor selected_color;
...
} AppState;
and in my main program
AppState state;
and then PASS on the stack the pointer to this automatic variable in main,
the struct member loses the stored value as soon as the callback terminates.
I.e., in my function
void draw_brusH ( ... AppState *state)
the state->selected_color has RGB (0,0,0).
Even if I COPY the value out using
gtk_color_selection_get_current_color (colorsel, &selectedcolor);
state->current_color.red = selectedcolor.red;
// and same for green and blue
it STILL gets zeroed when the callback terminates.
I want to avoid global variables. Can anyone explain this and provide a
solution?
Stewart
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]