[Glade-users] C Beginner question



Hello list and happy holidays!

I'm not new to Glade, but I am new to C...well sort of.  I've played
with C for a while, but I'm stronger in scripting languages like PHP,
Perl...etc.  However, I wanted to do a comparison of sorts, so I'm
porting one of my PHP-GTK/Glade apps over to C.  In doing so, I'm
finding the lack of documentation frustrating (simply because I don't
understand C that well). Can anybody point me to some good
documentation, besides the Gtk documentation?

For example, I know that I can go here:
http://www.gtk.org/tutorial/x941.html to see the Gtk way of getting the
text entered into a GtkEntry.  However, how do I do it if I'm using
Glade.  I mean, the autoconnect should already know/create my widget, so
how do I simply call to the entry?  

My GtkEntry widget is called "ssh_user_entry", and my GtkButton is
called "connect_btn", so I would assume the C/Glade way would be:

void on_connect_btn_clicked(GtkButton *button, GtkWidget
*ssh_user_entry)
{
        const gchar *ssh_user_text;
        ssh_user_text = gtk_entry_get_text (GTK_ENTRY (ssh_user_entry));
        printf ("Entry contents: %s\n", ssh_user_text);
}

int main (int argc, char *argv[])
{
        GladeXML *xml;  /* glade xml file */
        gtk_init(&argc, &argv);
        xml = glade_xml_new(GLADE_FILE, NULL, NULL);    
        glade_xml_signal_autoconnect(xml); /* connect signal handlers */
        gtk_main();

        return 0;
}

However, this is not working.  I keep getting the following error when
clicking the button:

Gtk-CRITICAL **: gtk_entry_get_text: assertion `GTK_IS_ENTRY (entry)'
failed
Entry contents: (null)


In PHP-GTK it is MUCH easier, as all I had to do was:
class phpConnMgr extends GtkWindow
{
        function __construct()
        {
                $gladefile = $GLOBALS['gladefile'];
                parent::__construct();
                $this->glade = new GladeXML(dirname(__FILE__) . $gladefile);
                $this->glade->signal_autoconnect_instance($this);
        }

        function on_connect_btn_clicked()
        {
                $user = $this->glade->get_widget("ssh_user_entry")->get_text();
                echo "$user\n";
        }
}
$phpConnMgr = new phpConnMgr();
Gtk::main();



If you can let me know the proper way to do this in C/Glade, and/or let
me know where some simple examples of these common tasks are documented,
I'd really appreciate it!

Thanks,
-Lup






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