Problem saving color returned from gtk_color_selection_get_current_color

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux