gtk_builder NOT Working
- From: cet cet <xnidos yahoo com>
- To: gtk-app-devel-list gnome org
- Subject: gtk_builder NOT Working
- Date: Wed, 4 Nov 2009 06:00:40 -0800 (PST)
I trying a test application with gtk_builder the application compiles
without any error but i can't see any visual parts of the program.Glade
Version:3.6.x saves in GtkBuilder format.
compile command:
gcc -Wall -g -o builder_new builder_new.c -export-dynamic `pkg-config --cflags --libs gtk+-2.0`
I only get "i got mwindow" message from the program then program exits;
Below my code;
#include <gtk/gtk.h>
void
show_message(GtkWidget *widget,gpointer user_data)
{
GtkWidget *dialog,*mwindow=GTK_WIDGET(user_data);
dialog = gtk_message_dialog_new (GTK_WINDOW(mwindow),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_CLOSE,
"Hi From Main Window");
gtk_widget_show(dialog);
g_signal_connect_swapped (dialog, "response",
G_CALLBACK (gtk_widget_destroy),
dialog);
}
int
main (int argc, char *argv[])
{
GtkWidget *mwindow=NULL,*button2,*button1;
GtkBuilder *builder;
GError *error=NULL;
gtk_init (&argc, &argv);
builder=gtk_builder_new();
gtk_builder_add_from_file(builder,"builder_new.glade",&error);
if(error){
g_print("Interface Load Error:%s",error->message);
g_error_free(error);
error=NULL;
g_object_unref(builder);
gtk_main_quit();
}
gtk_builder_connect_signals(builder,NULL);
mwindow=GTK_WIDGET(gtk_builder_get_object(builder,"window1"));
button1=GTK_WIDGET(gtk_builder_get_object(builder,"button1"));
button2=GTK_WIDGET(gtk_builder_get_object(builder,"button2"));
if(mwindow) g_print("i got mwindow\n");
/*g_object_unref(builder);*/
g_signal_connect(G_OBJECT(button1),"clicked",
G_CALLBACK(show_message),mwindow);
g_signal_connect_swapped(G_OBJECT(button2),"clicked",
G_CALLBACK(gtk_main_quit),mwindow);
g_signal_connect(G_OBJECT(mwindow),"destroy",
G_CALLBACK(gtk_main_quit),NULL);
gtk_widget_show_all(mwindow);
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]