Re: how to navigate from one window to another in gtk.



Hi Sameer,

On 9/19/06, sameer tandra <sameer tandra gmail com> wrote:

Hi

   I am developing a reservation application in gtk under linux which
consists of 10 transaction forms.

I have expirementing with  two forms in which i am navigating from one form
to another with a click event.
In compilation itself i am getting many errors.I am not able to resolve.

          Kindly give me help.

Here i am attaching the program which i have done and the errors i am
getting.



#include<gtk/gtk.h>

#include<glib.h>

#include<stdio.h>

#include<string.h>

gint destroyapp (GtkWidget *widget, gpointer gdata)
{

g_print ("Quitting...\n");

gtk_main_quit();

return (FALSE);

}





int button_clicked(GtkWidget *widget, gpointer gdata)

{

gtk_main_quit();

If u do this here your gtk will get quit.. So comment it out


int main(int argc,char *argv[])

????? you can write the new window functionality in the button_clicked
function itself, you dont need a "main"


{

GtkWidget *window,*label,*box,*separator,*exit_btn;

gtk_init(&argc,&argv);

Your gtk is already initialised, it should not be called again in this
new window creation

window=gtk_window_new(GTK_WINDOW_TOPLEVEL);



Gtk_Widget_show(window);

Capital G & W??? its gtk_window_show();

box=gtk_vbox_new(FALSE,10);

label=gtk_label_new("gtk");

separator=gtk_hseparator_new();

exit_btn=gtk_button_new_with_label("exit");

Gtk_Widget_show(label);

Gtk_Widget_show(box);

Gtk_Widget_show(separator);

Gtk_Widget_show(exit_btn);

Gtk_main();


No capital albhabets anywhere!!!

return 0;

}

}

int main (int argc, char *argv[])

{



GtkWidget *window;

GtkWidget *button;

gtk_init (&argc, &argv);

window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

button = gtk_button_new_with_label("Click Me");

gtk_signal_connect(GTK_OBJECT(window), "delete_event",
GTK_SIGNAL_FUNC(destroyapp), NULL);

gtk_signal_connect(GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(button_clicked), NULL);

gtk_container_add(GTK_CONTAINER (window), button);

gtk_container_border_width (GTK_CONTAINER (window), 15);

gtk_widget_show(button);

gtk_widget_show(window);
gtk_main();

return 0;

}

The errors are as follows:

/tmp/cclYSbJO.o(.text+0x55): In function `main.0':
: undefined reference to `Gtk_Widget_show'

/tmp/cclYSbJO.o(.text+0xa3): In function `main.0':
: undefined reference to `Gtk_Widget_show'

/tmp/cclYSbJO.o(.text+0xb1): In function `main.0':
: undefined reference to `Gtk_Widget_show'

/tmp/cclYSbJO.o(.text+0xbf): In function `main.0':
: undefined reference to `Gtk_Widget_show'

/tmp/cclYSbJO.o(.text+0xcd): In function `main.0':
: undefined reference to `Gtk_Widget_show'

/tmp/cclYSbJO.o(.text+0xd5): In function `main.0':
: undefined reference to `Gtk_main'

collect2: ld returned 1 exit status.

These errors were because you were trying to call functions that didnt exist.
Read up gtk & its functions from here
http://developer.gnome.org/doc/API/2.0/gtk/index.html
It might be useful

--
Anupama Chandwani

Celunite Soft Technologies
3rd Floor, Business Avenue
Koregaon Park
Pune, MS 411001
INDIA



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]