[Glade-users] [gtkbuilder+glade3.4]The Child-window can not creat again



I wirte a sample application use GktBuilder + glade3. there are one
main-window(top level) and some other child-window (top level too, creat and
show when the menu item is actived, in my code it is named window_rank).
after close the child-window for first time, i click the menu item again.
But this child-window cannot be created and showed again. with many errors
or warming like this:

(lsacs_gsecu:11866): GLib-GObject-WARNING **: invalid unclassed pointer in
cast to `GtkCList'

(lsacs_gsecu:11866): Gtk-CRITICAL **: gtk_clist_append: assertion
`GTK_IS_CLIST (clist)' failed

(lsacs_gsecu:11866): GLib-GObject-WARNING **: invalid unclassed pointer in
cast to `GtkCList'

(lsacs_gsecu:11866): Gtk-CRITICAL **: gtk_clist_set_text: assertion
`GTK_IS_CLIST (clist)' failed

(lsacs_gsecu:11866): GLib-GObject-WARNING **: invalid unclassed pointer in
cast to `GtkCList'

....

i thinke when i destroy the child-window, these UI data are freed, so i
cannot use builder again.
some one tell me that i can hide the child-window instead of destroy it, but
it will bring many terrible problem specially when the window contain
treeview.
so, do anyone can tell me how can i do with that child-window, or tell me
where can i find some example which develop by gktbuilder+glade

extremely grateful

*my code is here:*

main.c:

#include "gsecu.h"
#define BUILDER_XML_FILE "gsecu.xml"

gboolean init_app (LsacsGsecu *editor);
int main (int argc, char *argv[])
{
        LsacsGsecu *gsecu;
        gsecu = g_slice_new(LsacsGsecu);
        gtk_init (&argc, &argv);
        if (init_app (gsecu) == FALSE) return 1; /* error loading UI */
        gtk_widget_show(gsecu->window);
        gtk_main();
        return 0;
}


gboolean init_app (LsacsGsecu *gsecu)

{
        GtkBuilder *builder;
        GError                  *err=NULL;
        /* use GtkBuilder to build our interface from the XML file */
        builder = gtk_builder_new ();
        if (gtk_builder_add_from_file (builder, BUILDER_XML_FILE, &err) == 0)
        {
                error_message (err->message);
                g_error_free (err);
                return FALSE;
        }

        /* get the widgets which will be referenced in callbacks */
        gsecu->window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
        //???????
        gsecu->window_rank = GTK_WIDGET (gtk_builder_get_object
(builder, "window_rank"));
        gsecu->clist_rank = GTK_WIDGET (gtk_builder_get_object
(builder, "clist_rank"));
        gsecu->entry_rank = GTK_WIDGET (gtk_builder_get_object
(builder, "entry_rank"));
        /* connect signals, passing our LsacsGsecu struct as user data */
        gtk_builder_connect_signals (builder, gsecu);
        /* free memory used by GtkBuilder object */
        g_object_unref (G_OBJECT (builder));
        return TRUE;
}

inittable.c:

void on_initrank_activate (GtkObject *object, LsacsGsecu *gsecu)

{
        struct stat filebuf;
        gchar *p_space = " ";
        int fd,ranknum;
        int i;
        RANKNAME_SREC rankbuf;
        if((fd=open(LSACS_RANKNAME,O_RDWR|O_CREAT|O_APPEND))<0)
        {
                OK_dialog("??rankname????", gsecu->window_rank);
                return;
        }
        fstat(fd,&filebuf);
        ranknum=(filebuf.st_size/(sizeof(RANKNAME_SREC)));
        for(i=1;i<=ranknum;i++)
        {
                gtk_clist_append(GTK_CLIST(gsecu->clist_rank), &p_space);
                lseek(fd,(i-1)*sizeof(RANKNAME_SREC),SEEK_SET);
                read(fd,&rankbuf,sizeof(RANKNAME_SREC));

gtk_clist_set_text(GTK_CLIST(gsecu->clist_rank),(i-1),0,rankbuf.rankname);
        }
        close(fd);
        gtk_clist_set_column_width (GTK_CLIST (gsecu->clist_rank), 0, 270);
        gtk_widget_show(gsecu->window_rank);
}

i have spended many many time to solve it, can some one help me !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/glade-users/attachments/20090428/b0f1aa3d/attachment-0001.html 




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