Re: grabbing a spinbutton from a dialog
- From: Iago Rubio <iago rubio hispalinux es>
- To: gtk-app-devel-list gnome org
- Subject: Re: grabbing a spinbutton from a dialog
- Date: Fri, 13 Aug 2004 10:22:27 +0200
On Fri, 2004-08-13 at 07:07, Rob Benton wrote:
I know there's probably a better way to do this than what I'm
attempting. I have a New menuitem that I want to create a dialog with 2
spinbuttons. On the response handler the function needs to extract the
values from the 2 spinbuttons. Here's my flow:
Mainmenu->New->create a dialog with 2 spin buttons->signal connect
response->get dialog vbox->get first hbox->get spinbutton->get value
+->get second hbox->get
spinbutton->get value
So far I've been trying to use the gtk_container_get_children()
methods. Is there a better way to do this? That seems like a lot of
code to get 2 ints.
You can create an structure with the spin buttons and pass it to
callbacks.
typedef struct _MySpins {
GtkWidget* spin1;
GtkWidget* spin2;
} MySpinButtons;
MySpinButtons spin_buttons = g_malloc( sizeof(MySpinButtons) );
spin_buttons->spin1 = the_first_spin_button;
spin_buttons->spin2 = the_second_spin_button;
Then pass this to g_signal_connect as user_data, so in the callback you
can catch it.
g_signal_connect( your_widget, "your-signal", your_callback_function,
(gpointer) spin_buttons );
// In the callback
MySpinButtons spin_buttons;
spin_buttons = (MySpinButtons) user_data;
Remember to free the structure when no longer needed ( meaning when you
destroy the dialog ).
g_signal_connect_swapped ( your_dialog, "destroy", g_free, spin_buttons
);
Hope this helps.
--
Iago Rubio
- Home page * http://www.iagorubio.com
- Last project * http://cssed.sourceforge.net
- GPG Keyserv * pgp.rediris.es id=0x909BD4DD
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]