GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with Glade 3.6.1

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
Javichu



Joined: 15 Mar 2010
Posts: 3

PostPosted: Mon Mar 15, 2010 4:12 pm    Post subject: Problem with Glade 3.6.1 Reply with quote

First of all, hello everyone!

I'm a newbie GTK+ programmer, trying to set up a nice looking GUI to perform lots of stuff in Windows. After all the trouble setting it all to work under Visual C/C++, I finally managed to compile, link and execute a simple GUI. I know you'll be thinking: "get a Linux!" but my boss is as he is, and won't let me install a nice pretty Ubuntu for myself...

Anyway, my problem has been discussed in these forums before, but I can't seem to find a solution that fits my case. Fact is I have such a simple program, and I can't get the callbacks to work. I'll try to be clear:

Glade version: 3.6.1.

C code:

#include <gtk/gtk.h>

void on_button1_pressed (GtkObject *object, gpointer user_data)
{
gtk_main_quit();
}

int main(int argc, char *argv[])
{
GtkBuilder *builder;
GtkWidget *window, *button1;

gtk_init (&argc, &argv);
builder = gtk_builder_new ();

gtk_builder_add_from_file (builder, "e:\\dev_mantis\\gui.xml", NULL);
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
button1 = GTK_WIDGET (gtk_builder_get_object (builder, "button1"));
gtk_builder_connect_signals (builder, NULL);
gtk_widget_show (window);
gtk_main();
return 0;
}


Where "e:\\dev_mantis\\gui.xml" can be one of two files:

1. A GtkBuilder file saved directly as GtkBuilder from Glade3.
2. A Libglade file parsed by gtk-builder-convert.

If all I've read so far is correct, those 2 options should be "the same", and in either case, work fine with the program I've typed. The problem comes when I try to get a callback to work. My GUI right now is just a window with a huge button in the middle with the callback "on_button1_pressed " associated to the mouse click. With the GtkBuilder file I get the following error:

"Gtk-CRITICAL **: gtk_widget_show: assertion 'GTK_IS_WIDGET <widget> failed".

This is logical, since the contents of "window" when I debug are always '0', which means the file generated is not recognized by the "gtk_builder_add_from_file" function?

If I try it with Libglade file and conversion, I get the following warning:

"Gtk-WARNING **: could not find signal handler 'on_button_pressed'"

Which, at least for me, has no explanation at all. I've read about dynamic linking and gcc modifiers, but since I'm on a Visual C environment, I don't know what to do.

I hope any of you, GTK+ gurús, can help this poor Windows-forced worker.

Thanks in advance, and good luck!
Back to top
frankh
Familiar Face


Joined: 16 Mar 2010
Posts: 9

PostPosted: Tue Mar 23, 2010 12:50 pm    Post subject: Re: Problem with Glade 3.6.1 Reply with quote

Javichu wrote:
My GUI right now is just a window with a huge button in the middle with the callback "on_button1_pressed " associated to the mouse click. With the GtkBuilder file I get the following error:

"Gtk-WARNING **: could not find signal handler 'on_button_pressed'"

You have associated the button with the signal handler "on_button1_pressed" in Glade, and it complains about the handler "on_button_pressed" not existing? Have you double-checked that the signal handler name specified in the Glade file is the same as the handler in the C code? That is, that the signal handler name in the glade file is indeed "on_button1_pressed" and not "on_button_pressed"?
Back to top
tadeboro
Never Seen the Sunlight


Joined: 23 Jul 2008
Posts: 2114
Location: Slovenia

PostPosted: Wed Mar 24, 2010 3:14 pm    Post subject: Reply with quote

Hello and welcome to the GTK+ forums.

First, to determine what kind of project you're saving in, you should know what version of Glade are you using. Versions < 3.6 will save projects in libglade format, which needs to be converted using gtk-builder-convert script. Version >= 3.6 can save GtkBuilder format natively, so no conversion is needed.

As for the missing signal handlers, you need to mark you signal handlers exportable by linker. You can do that by prefixing your function with G_MODULE_EXPORT, so you callback looks like this:
Code: (C)
1
2
3
4
5
6
G_MODULE_EXPORT void
cb_clicked( GtkButton *button,
            gpointer   data )
{
    /* Code here */
}

Tadej
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP