Find the answer to your Linux question:
Results 1 to 4 of 4
I'm getting the error debian:~/giis-4.6-seprate-files# gtk-builder-convert tab1.glade tab1.xml Wrote tab1.xml debian:~/giis-4.6-seprate-files# gcc -Wall -g -o tab1 tab1.c `pkg-config --cflags --libs gtk+-2.0` -export-dynamic debian:~/giis-4.6-seprate-files# ./tab1 <============ERROR (tab1:8594): Gtk-CRITICAL **: gtk_widget_show: assertion ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,769

    Arrow GTK+ Error -- Need help


    I'm getting the error
    debian:~/giis-4.6-seprate-files# gtk-builder-convert tab1.glade tab1.xml
    Wrote tab1.xml
    debian:~/giis-4.6-seprate-files# gcc -Wall -g -o tab1 tab1.c `pkg-config --cflags --libs gtk+-2.0` -export-dynamic

    debian:~/giis-4.6-seprate-files# ./tab1 <============ERROR
    (tab1:8594): Gtk-CRITICAL **: gtk_widget_show: assertion `GTK_IS_WIDGET (widget)' failed
    Below is the source code of c file and .glade file.

    Any know what's the issue here?
    Code:
    #include <gtk/gtk.h>
    #include <math.h>
    #include <stdio.h>
    /*
    First run :
      gtk-builder-convert tab1.glade tab1.xml
     Then run:
      gcc -Wall -g -o tab1 tab1.c `pkg-config --cflags --libs gtk+-2.0` -export-dynamic
      
    Then execute it using:
      ./tab1
    */
    
    
    
    #define GUI "gui/tab1.xml"
    
    typedef struct{
    
            GtkWidget               *main_win; //For main window
    	GtkWidget		*btn_viewfiles; // search button
    	GtkWidget		*textview_viewfiles;	 //textview _search files
    
    } TAB1;
    GtkTextBuffer *buffer; //to store data.
    
    
    void on_main_win_destroy (GtkObject *object, gpointer user_data);
    void on_btn_viewfiles_clicked(GtkButton *button, TAB1 *from_gui);
    gboolean build_app (TAB1 *from_gui);
    
    
    int main (int argc, char *argv[]) {
      
            TAB1      *from_gui;
            from_gui = g_slice_new (TAB1);
            gtk_init (&argc, &argv);
    
            if (build_app (from_gui) == FALSE) return 1;
    
            gtk_widget_show (from_gui->main_win);
    
    	g_print("Starting gui\n");
    
            gtk_main ();
    
            g_slice_free (TAB1, from_gui);
            
            return 0;
    }
    
    
    gboolean build_app (TAB1 *from_gui){
    
            GtkBuilder              *builder;
            
            builder = gtk_builder_new ();
            gtk_builder_add_from_file (builder, GUI, NULL);
    
            from_gui->main_win = 	GTK_WIDGET (gtk_builder_get_object (builder, "main_win"));
            from_gui->btn_viewfiles = 	GTK_WIDGET (gtk_builder_get_object (builder, "btn_viewfiles"));
    	from_gui->textview_viewfiles = GTK_WIDGET (gtk_builder_get_object (builder, "textview_viewfiles"));
    
            gtk_builder_connect_signals (builder, from_gui);
                        
            g_object_unref (G_OBJECT (builder));
    
            return TRUE;
    }
    
    
    void on_main_win_destroy (GtkObject *object, gpointer user_data){
    	gtk_main_quit();
    }
    
    void on_btn_viewfiles_clicked(GtkButton *button, TAB1 *from_gui){
    g_print("reached  ");
    }
    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
    <!--Generated with glade3 3.4.5 on Wed Jun 10 13:43:45 2009 -->
    <glade-interface>
      <widget class="GtkWindow" id="main_win">
        <property name="width_request">300</property>
        <property name="height_request">229</property>
        <property name="title" translatable="yes">View files</property>
        <signal name="destroy" handler="on_main_win_destroy"/>
        <child>
          <widget class="GtkLayout" id="layout1">
            <property name="visible">True</property>
            <child>
              <widget class="GtkButton" id="btn_viewfiles">
                <property name="width_request">75</property>
                <property name="height_request">31</property>
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">True</property>
                <property name="label" translatable="yes">Search</property>
                <property name="response_id">0</property>
                <signal name="clicked" handler="on_btn_viewfiles_clicked"/>
              </widget>
              <packing>
                <property name="x">35</property>
                <property name="y">4</property>
              </packing>
            </child>
            <child>
              <widget class="GtkTextView" id="textview_viewfiles">
                <property name="width_request">100</property>
                <property name="height_request">119</property>
                <property name="visible">True</property>
                <property name="can_focus">True</property>
              </widget>
              <packing>
                <property name="x">194</property>
                <property name="y">49</property>
              </packing>
            </child>
          </widget>
        </child>
      </widget>
    </glade-interface>
    First they ignore you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -----
    FOSS India Award winning ext3fs Undelete tool www.giis.co.in. Online Linux Terminal http://www.webminal.org

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,737
    My guess is that something failed in your build_app() function and from_gui->main_win or some sub-component is NULL. Run this in the debugger and see what component is not being initialized properly.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,769

    Exclamation

    Thanks ,Rubberman. I'll try debugging (I need to install debugger) it tonight. I have other simple addition/subtraction/even number GTK+ programs working
    I Made some mistake some where with this..
    First they ignore you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -----
    FOSS India Award winning ext3fs Undelete tool www.giis.co.in. Online Linux Terminal http://www.webminal.org

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,737
    Quote Originally Posted by Lakshmipathi View Post
    Thanks ,Rubberman. I'll try debugging (I need to install debugger) it tonight. I have other simple addition/subtraction/even number GTK+ programs working
    I Made some mistake some where with this..
    Yeah. When you find it, you will probably whack yourself on the forehead with a Homer - doh!
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •