Updating displayed spinbutton value from a text file

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Updating displayed spinbutton value from a text file

Gtk+ - Apps Dev mailing list
     I'm using gtk+3.10 on Ubuntu 14.04 and am writing an application in C, with the user interface constructed with a builder.ui file. I am using spinbuttons to create and change Cairo drawings of some mathematical functions. The spinbuttons’ adjustment value is initialised from the builder.ui file and can then can be changed with the spinbutton, I also read values from a text file to create and change the drawings, which after being read from the file (containing many drawing parameters) these parameters are then written to seperate files for each parameter which are then read into the drawing function in drawing.c, which is compiled together with mymain.c.
     This works ok (the drawings change), except that when reading the values from the file I would also like to update the values displayed in the spinbuttons so that they match those in the file and with the correctly updated drawings.
     I have tried using the following, taken from Foundations of GTK+ Development, by Andrew Krause (gtk+2):

gtk_spin_button_set_value (GtkSpinButton *spin_drawingparameter1, int drawingparameter1);

in the callback for the spinbutton *spin_readfile (which makes the choice between reading/not reading the file).

When attempting to compile I receive this error message:

mymain.c: In function ‘callback_readfile’:
mymain.c:1124:28: error: expected expression before ‘GtkSpinButton’
 gtk_spin_button_set_value (GtkSpinButton *spin_drawingparameter1, int drawingparameter1);
                            ^
mymain.c:1124:28: error: too few arguments to function ‘gtk_spin_button_set_value’
In file included from /usr/include/gtk-3.0/gtk/gtk.h:176:0,
                 from mymain.c:9:
/usr/include/gtk-3.0/gtk/gtkspinbutton.h:197:7: note: declared here
 void  gtk_spin_button_set_value    (GtkSpinButton  *spin_button,
       ^
make: *** [mymain] Error 1

The first error I don't know what I need to do at all, while the second error may be related to the gtk+ version, or it might not....
Can this be done in my builder.ui file, perhaps with “change-value”?

Any help would be greatly appreciated,
Thanks,
Roger Matthews

_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|

Re: Updating displayed spinbutton value from a text file

Allin Cottrell
On Wed, 4 Jul 2018, Roger Matthews via gtk-app-devel-list wrote:

>     I'm using gtk+3.10 on Ubuntu 14.04 and am writing an application in C, with the user interface constructed with a builder.ui file. I am using spinbuttons to create and change Cairo drawings of some mathematical functions. The spinbuttons’ adjustment value is initialised from the builder.ui file and can then can be changed with the spinbutton, I also read values from a text file to create and change the drawings, which after being read from the file (containing many drawing parameters) these parameters are then written to seperate files for each parameter which are then read into the drawing function in drawing.c, which is compiled together with mymain.c.
>     This works ok (the drawings change), except that when reading the values from the file I would also like to update the values displayed in the spinbuttons so that they match those in the file and with the correctly updated drawings.
>     I have tried using the following, taken from Foundations of GTK+ Development, by Andrew Krause (gtk+2):
>
> gtk_spin_button_set_value (GtkSpinButton *spin_drawingparameter1,
> int drawingparameter1);
>
> in the callback for the spinbutton *spin_readfile (which makes the
> choice between reading/not reading the file).
>
> When attempting to compile I receive this error message:
>
> mymain.c: In function ‘callback_readfile’:
> mymain.c:1124:28: error: expected expression before ‘GtkSpinButton’
>
> gtk_spin_button_set_value (GtkSpinButton *spin_drawingparameter1,
> int drawingparameter1);

Try

gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin_drawingparameter1),...

You have a broken attempt at a cast.

--
Allin Cottrell
Department of Economics
Wake Forest University
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list