Find the answer to your Linux question:
Results 1 to 2 of 2
Hi there, with glade-2 I've created an application which should show translated data into a clist. Therefore I use several buttons to control the clist. One of them is the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2005
    Posts
    2

    GTK: how to write into a clist?


    Hi there,

    with glade-2 I've created an application which should show translated data into a clist. Therefore I use several buttons to control the clist. One of them is the start/stop button and a clear button. When the start/stop is pushed I want to write some text ("Hello World") into the clist. Currently I want to do this directly by the start-stop-function. In the future, the start-stop function reveices and translate the data to text.

    I think that there's a problem using the g_signal_connect functions. I'm not sure.

    The code produced by glade:

    interface.c
    -----------
    Code:
    GtkWidget* create_main_window (void)
    {
      GtkWidget *clist1;
      GtkWidget *startstop;
      GtkWidget *clr;
    
      startstop = gtk_label_new_with_mnemonic (_("Start\nStop"));
      gtk_widget_show (startstop);
      gtk_box_pack_start (GTK_BOX (hbox21), startstop, FALSE, FALSE, 3);
    
      gtk_widget_show (clr);
      gtk_table_attach (....);
      gtk_container_set_border_width (....);
    
      clist1 = gtk_clist_new (9);
      gtk_widget_show (clist1);
      gtk_container_add (GTK_CONTAINER (scrolledwindow2), clist1);
    
      ...several clist options here...
    
      g_signal_connect ((gpointer) startstop, "clicked",
                        G_CALLBACK (on_start_stop_clicked),
                        NULL);
    
      g_signal_connect_swapped ((gpointer) clr, "clicked",
                                G_CALLBACK (on_clr_clicked),
                                GTK_OBJECT (clr_clicked_object));
    
      GLADE_HOOKUP_OBJECT (main_window, clist1, "clist1"); // ?????
    }
    callbacks.c
    -----------

    Code:
    void on_start_stop_clicked (GtkButton *button, gpointer user_data)
    {
      gtk_clist_set_text((GtkCList*)user_data, 1, 1, "Hello World");
    }
    
    void on_clr_clicked(GtkButton *button, gpointer user_data)
    {
      gtk_clist_clear((GtkCList*)user_data);
    }
    The messages I receive when the program is running in a terminal window are:
    (prog:22717): Gtk-CRITICAL **: file gtkclist.c: line 2243 (gtk_clist_set_text): assertion `GTK_IS_CLIST (clist)' failed

    (prog:22717): Gtk-CRITICAL **: file gtkclist.c: line 2701 (gtk_clist_clear): assertion `GTK_IS_CLIST (clist)' failed
    How can I solve this???????

  2. #2
    Linux User
    Join Date
    Oct 2004
    Location
    Serbia&Montenegro
    Posts
    281
    I had a similar problem with text widgets. When I use gtk_text_insert in a function different from main() it gives an error: assertion GTK_IS_TEXT (text) failed. But when I use gtk_text_insert after I declare text it works fine. This is a little problem with GTK. Try it yourself.
    Linux registered user #358842
    Human knowledge belongs to the world.

Posting Permissions

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