tigerjack
Joined: 07 Apr 2008 Posts: 1
|
Posted: Mon Apr 07, 2008 11:25 am Post subject: N00b Needs 'Next' and 'Back' Button |
|
|
EDIT: After fiddling about for days, the minute after I post here, I fixed the problem - see my updated code. HOWEVER, any help anyone can give me on have a global next, back button solution as I describe below would be greatly appreciated!
Hey there, excuse my ignorance, hope someone can help!
I have been using C for some time, but only really for simple mathematical stuff, only just really started on gtk - I'm using Glade3 for the building but am having trouble with the guts of the coding.
Basically what I want is to have a Next and a Back button that destroy the current window and show the 'next' one, or the previous one. It seemed that it should be quite simple but I am having some problems, so at the moment I am struggling to even get a single instance of a next button to work...
Here is an example of what I have been trying - this one results in a segmentation fault...
| Quote: |
#include <gtk/gtk.h>
#include <glade/glade.h>
int main (int argc, char *argv[])
{
GladeXML *gxml;
GtkWidget *window;
GtkWidget *window2;
GtkWidget *next;
gtk_init (&argc, &argv);
gxml = glade_xml_new ("prac.glade", NULL, NULL);
window = glade_xml_get_widget (gxml, "window1");
window2 = glade_xml_get_widget (gxml, "window2");
next=glade_xml_get_widget (gxml,"button1");
g_signal_connect_swapped (G_OBJECT (next), "clicked",
G_CALLBACK (gtk_widget_hide), (gpointer)window);
g_signal_connect_swapped (G_OBJECT (next), "clicked",
G_CALLBACK (gtk_widget_show), (gpointer)window2);
gtk_widget_show (window);
gtk_widget_show (next);
gtk_main ();
return 0;
}
|
In the long run, I would like a global solution, ie so every next button on whatever page emits the same signal and it works out what page is the next one etc.
Thanks in advance for any help you guys can give me! |
|