Re: (no subject)



Thanks you for the help! Although i am using Gtk+ 1.2, and this function is for
2.0, your hint let me to look at the GtkBin class, and find way to do it:

box = GTK_WIDGET(GTK_BIN(data)->child));
gtk_container_remove(GTK_CONTAINER(data), box);

i dont know if it's the best and correct way to do it, but it's working now.
Some error codes are appearing on the terminal though.
Citando Peter Krueger <pkrueger appss de>:

On Fri, 16 Apr 2004, Gustavo Cipriano Mota Sousa wrote:
I am writting an app that uses a clist, and a frame, and, when the clist is
selected, information about that row should be showed in the frame.

I used the following code to connect the signal:

frame = gtk_frame_new("Result");
gtk_signal_connect(GTK_OBJECT(clist), "select_row",
    GTK_SIGNAL_FUNC(callback_select_row), (gpointer) frame);

and this one as a callback:
void callback_select_row(GtkWidget *widget, gint row, gint column,
                    GdkEventButton *event, gpointer data) {
    GtkWidget *box, *label;
    gint i;

    /* code for reading data */
    box = gtk_vbox_new(TRUE, 1);
    for (i = 0; i < x; i++) {
        sprintf(str, "%s: %s", field[i].name, row[i]);
        label = gtk_label_new(str);
        gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0);
        gtk_widget_show(label);
    }
    gtk_container_add(GTK_CONTAINER(data), box);
    gtk_widget_show(box);

It works perfectly when i select a line from the list for the first time,
but
when i select another one, it keeps showing the data, related to the first
selected row. I need someway to clear, the contents of the frame, or box,
before adding new things. I am new at gtk and i have no clue how to achieve
it.
Hello Gustavo!
You can use the function
  GtkWidget* gtk_bin_get_child(GtkBin *bin);
with your frame as argument to get the vbox from your last call. If
there is a child (the function returns something != NULL), remove it from
the frame with:
  void gtk_container_remove(GtkContainer *container, GtkWidget *widget);
This will delete the old widgets of the box and the labels in it.

Regards,
                       Peter
--
====================================================================
Peter Krüger

applied software solutions (appss) GmbH
Sandtorstr. 23
D-39106 Magdeburg
Germany

Phone:  +49-(0)391-54486-19388
Fax:    +49-(0)391-54486-19222
email:  krueger appss de
URL:    http://www.appss.de

Managing Director: Uwe Hess, Dietmar Schäfer
Register: HRB12386, AG Mageburg

"Virtual business becomes reality!"

This e-mail may contain confidential and/or privileged information. If
you are not the intended recipient (or have received this e-mail in
error) please notify the sender immediately and destroy this e-mail. Any
unauthorised copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
====================================================================




------ BEGIN GEEK CODE BLOCK-----
Version: 3.1
GU d-(?) s+:- a--- C++(+++)>$ UBL++>$ P+ L++>$ !E W++ N? o? K? w- O- M- V- PS
PE+(++) Y? PGP- t S? X? R+ tv- b+ DI? D- G++ e- h! r- y?
------ END GEEK CODE BLOCK ------

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.





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