Re: [glade--]Problems with glade_get_widget_tree() during runtime



Hi,
   I made the changes you suggested and some of the
errors were corrected. I still have a few errors
appearing when I click on the button. I have pasted
the changed code below:-
----------------------------------------------------------------------------
        GladeXML *xml;
        GtkTextView *textview;
                                                      
                         
        xml =
glade_get_widget_tree((GtkWidget*)(button->gobj()));
        if(xml == NULL) g_print("XML object returned
is NULL.\n");
----------------------------------------------------------------------i
                                                      
                         
We commented out all the lines except the above lines
and one error still appears. The change you suggested
removed two errors though.
                                                      
                         
The errors on clicking that I am getting right now are
:-
                                                      
                         
(AA:4276): Gtk-WARNING **: INVAlid cast from
`(unknown)' to `(unknown)'
                                                      
                         
I feel that the argument passed to
glade_get_widget_tree is not right , i.e.
conversion of the argument is not right . I think that
due to this the error
"invalid cast from unknown to unknown" comes.
                                                      
                         
Any help with this would be appreciated.
                                                      
                         
Thanks in advance,
Mukund Gopalan

--- Mukund Gopalan <gmukund_2002 yahoo com> wrote:
> Hi all,
> 
> Let me start by thanking this group for helping me
> (through online posts, though indirectly) with the
> problems I've had so far with Glade.  Thank you all
> much :)
> 
> Following is what I am facing now:
> 
> I have made a simple GUI with Glade.  The code being
> produced is in C++.  The GUI contains a button and a
> textview.  Upon pressing the button, I am trying to
> display the text "Button pressed" in the textview. 
> The signal handler code looks as follows:
> 
> ---------------------
> void window::on_button_clicked()
> {                                                   
>  
>                       
>    gchar output[50] = "Button clicked\n";
>    GladeXML *xml;
>    GtkTextView *textview;
>                                                     
>  
>                          
>    xml = glade_get_widget_tree(GTK_WIDGET(button));
>    textview = 
> (GtkTextView*)glade_xml_get_widget(xml,
> "textview");
>                                                     
>  
>                          
>    GtkTextBuffer* buf = 
> gtk_text_view_get_buffer(textview);
>    gtk_text_buffer_insert_at_cursor(buf, output,
> strlen(output));
> }
> -----------------------
> 
> The code compiles fine, but when I run it it gives
> me
> the following errors  in the console , upon pressing
> the button:
> 
> -----------------------
> (AA:19940): GLib-GObject-WARNING **: invalid cast
> from
> `(null)' to `GtkWidget'
>                                                     
>  
>                          
> (AA:19940): Gtk-WARNING **: invalid cast from
> `(unknown)' to `(unknown)'
>                                                     
>  
>                          
> (AA:19940): Gtk-CRITICAL **: file gtkobject.c: line
> 661 (gtk_object_get_data_by_id): assertion
> `GTK_IS_OBJECT (object)' failed
>                                                     
>  
>                          
> ** (AA:19940): CRITICAL **: file glade-xml.c: line
> 544
> (glade_xml_get_widget): assertion `self != NULL'
> failed.
>                                                     
>  
>                          
> (AA:19940): Gtk-CRITICAL **: file gtktextview.c:
> line
> 1210 (gtk_text_view_get_buffer): assertion
> `GTK_IS_TEXT_VIEW (text_view)' failed
>                                                     
>  
>                          
> (AA:19940): Gtk-CRITICAL **: file gtktextbuffer.c:
> line 598 (gtk_text_buffer_insert_at_cursor):
> assertion
> `GTK_IS_TEXT_BUFFER (buffer)' failed
> ---------------------
> 
> I then commented out all but the first line:
> 
> ----------------------
> void window::on_button_clicked()
> {                                                   
>  
>                       
>    gchar output[50] = "Button clicked\n";
>    GladeXML *xml;
>    GtkTextView *textview;
>                                                     
>  
>                          
>    xml = glade_get_widget_tree(GTK_WIDGET(button));
> //   textview = 
> (GtkTextView*)glade_xml_get_widget(xml, "textview");
>                                                     
>  
>                          
> //   GtkTextBuffer* buf = 
> gtk_text_view_get_buffer(textview);
> //   gtk_text_buffer_insert_at_cursor(buf, output,
> strlen(output));
> }
> -------------------
> 
> I compiled and ran the code, and got the errors:
> 
> --------------------- 
> (AA:20793): GLib-GObject-WARNING **: invalid cast
> from
> `(null)' to `GtkWidget'
>  
> (AA:20793): Gtk-WARNING **: invalid cast from
> `(unknown)' to `(unknown)'
>  
> (AA:20793): Gtk-CRITICAL **: file gtkobject.c: line
> 661 (gtk_object_get_data_by_id): assertion
> `GTK_IS_OBJECT (object)' failed
> -----------------------
> 
> So as one can see the problem is the conversion of
> 'button' to a widget.  
> 
> I have made the window, the button, and the textview
> public.  
> 
> Has anyone experienced such a problem before?
> 
> Any help would be appreciated.
> 
> Again, the code is in C++.
> 
> Thanks in advance,
> Mukund Gopalan
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - More reliable, more storage, less spam
> http://mail.yahoo.com
> _______________________________________________
> glademm-list mailing list
> glademm-list gnome org
> http://mail.gnome.org/mailman/listinfo/glademm-list


__________________________________
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
http://mail.yahoo.com



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