GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Wed Aug 31, 2016 4:21 am

All times are UTC

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: N00b Needs 'Next' and 'Back' Button
PostPosted: Mon Apr 07, 2008 11:25 am 

Joined: Mon Apr 07, 2008 10:16 am
Posts: 1
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...

#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 ("", 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!

 Post subject:
PostPosted: Thu Apr 10, 2008 2:21 pm 
GTK+ Geek

Joined: Wed Dec 19, 2007 9:15 pm
Posts: 61
Location: Glasgow, Scotland
Looks like you ought to be using GtkAssistant. It is a window which can have multiple stages and has previous/next buttons built in.

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group