Re: how to i get the arrow-buttons moving?



On Wed, Sep 03, 2014 at 01:13:06PM -0700, Gary Kline wrote:
      thanks for your input, marcus, but could you give me a few lines of
      code?  I tried using the gtk_label_set_text() for over an hour
      last night until it felt like my shoulder was going to drop off and
      fall on the floor! 

You should be able to set the text with something like:

gtk_label_set_text (GTK_LABEL (label), "some text");

But this requires that you have a valid pointer to your label, eiter in
a global variable or passed to the signal handler as the user_data
pointer.

      other than usinng "g_signal_connect()" to bail out with a Quit,
      the only times I see anything to do with a signal are after going 
      GTK_ARROW_UP or _DOWN....  I may have misplaced the 
      gtk_label_get_text() stuff.  

      iv'e got:

      gtk_label_get_text(GTK_LABEL(user_data), buf );

      which now looks aways off...  need more clues.

Gtk_label_get_text () returns the string in the return value, so you
need to to something like:

str = gtk_label_get_text (GTK_LABEL (user_data));

This of course also requires that the user_data pointer is pointing at a
label. In your code sample you passed 0 and 1 as the pointers, which
most likely will not be valid pointers to your labels.

It's often a good idea to group the elements that you need to access
into an object and pass it as the user_data pointer. A struct would be
sufficient. This could also include a field which says which label is
currently selected, for example using and int in the range of 1 to 3.

If you want to reuse the signal handler and still distinguish which
button caused the signal then you can use the currently unused first
argument which should point to the sender of the signal, or the button
which was pressed down.

                Marcus


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