[Glade-users] Separation between GUI and main
- From: mferrero at reer.it (Manuel Ferrero)
- Subject: [Glade-users] Separation between GUI and main
- Date: Fri, 20 Jan 2012 16:44:39 +0100
I'm learning GTK+ and Glade on my win32 machine.
Right now I was able to write, compile and run a simple code with a
window, an hbox and a toggle button in it.
When the user presses the button I display the state of the button via
the callback function.
The main function is this:
---SNIP---
int main(int argc, char *argv[])
{
gtk_init(&argc, &argv);
GtkBuilder *builder_handler;
GtkWidget *window;
GtkWidget *connect_button;
builder_handler = gtk_builder_new();
gtk_builder_add_from_file(builder_handler, GUI_XML_FILENAME, NULL);
window = GTK_WIDGET(gtk_builder_get_object(builder_handler, "window"));
connect_button = GTK_WIDGET(gtk_builder_get_object(builder_handler,
"connect_button"));
gtk_builder_connect_signals(builder_handler, NULL);
g_object_unref (G_OBJECT (builder_handler));
gtk_widget_show (connect_button);
gtk_widget_show (window);
gtk_main ();
return 0;
} // main
---PINS---
I'll spare you the callbacks.
Now my question is this: with Glade I add another button (expanding the
hbox of course) and I name it my_button_2.
The code has to know about this new button so at least I have to declare
a new GtkWidget pointer, call the gtk_builder_get_object() to assing the
pointer and then show it with a gtk_widget_show().
Leave alone the callbacks for all the signals.
I don't understand how this can separate the GUI from the code.
Am I missing something?
Is tehre some way to connect signals without knowing the objects? In
this case I could only write the needed callbacks to manage the new button.
Please remember I'm really new to this programming style, I'm an
embedded C programmer so I know nealry nothign about objects and events.
Thanks in advance.
--
Regards,
Manuel Ferrero
R&D department
Reer SpA
Tel. +39 011 2482215
Fax. +39 011 859867
L'utilizzo non autorizzato del presente messaggio e' vietato e potrebbe costituire reato.
Se il presente messaggio non e' a Lei indirizzato, il suo contenuto non deve essere considerato
come trasmesso o autorizzato dalla Reer SpA; in tale caso Le saremmo grati se, via e-mail,
ce ne comunicasse l'errata ricezione.
The unauthorized use of this e-mail is prohibited and could constitute an offence.
If you are not the intended recipient of this message its contents shall be understood as neither
given nor endorsed by Reer SpA. Please notify Reer SpA by e-mail immediately in that case.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]