[gktbuilder+glade3.4]Child-window can not recreat
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 ! ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Treeview CRITICAL Error
dhk wrote: only seems to compile when the -O (Optimization) option is present. However the options is set as -O0 (that's Dash-Oh-Zero) which should turn optimization off. I'd like to be able to compile the program without optimization, but so far this has just been an annoyance. In my opinion every application should try to compile without warnings AND run fine with -O0, -O2, -O3. If your app does not compile AND run fine with -O0 to -O3 then you should stop and try to understand why. Think about it as an opportunity to know better your application! Sometime ago, my app was behaving in a strange way when compiling with -O3, although it worked fine with -O2. I tracked down the problem to just 2, 3 lines of complex, cheesy code, separated by commas. Replacing these 2, 3 lines by 4, 5 lines of simple, robust code, solved the issue. Third - the problem. The application window has a notebook with a handful of tabs, each with different tree views on them. The program seems to run fine. However, when the second tab is selected, no matter what the previous tab was, the following three error lines get printed about three times. I use a lot of notebooks and treeviews myself and they work fine. Probably this is a problem of compatibility between your TreeViews and TreeStores. Are you sure the number of columns and their type is right? the treeviews are visible? the tree stores are visible? there is no confusion between them when you change from one Treeview to another? do you understand well the Treeview/TreeStore model? Now the strange part. The functions that call gtk_tree_store_prepend() and gtk_tree_view_set_cursor() get a tree view pasted in as a gpointer and then it's cast to a GtkWidget. In the debugger when the tree view is printed it says "out>" and when printed with a star '*' preceding the tree view it displays 0x0: NULL. You can print the memory address of your treeviews, when you create them, and then in a few selected places, for example: printf ("treeview in callback: %d\n", my_tree_view); /* ignore the warning */ fflush (stdout); to assert if you get always the memory address you expect. Otherwise something is wrong. If you get NULL when you expected your treeview address, this is usually an error easy to track down. Carlos ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: g_spawn and files left locked on windows.
> My application invokes the lilypond program using the g_spawn... > functions. This works fine on linux, but on windows the files created by > lilypond are left locked when lilypond has exited. That sounds very odd and in fact impossible. Are you confusing file protection with locking? Please file a bug report at bugzilla.gnome.org and *attach* a *minimal* (single C or Python source file) but *complete* (can be compiled and run as such) sample program that reproduces the problem, *without* using lilypond. --tml ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
g_spawn and files left locked on windows.
My application invokes the lilypond program using the g_spawn... functions. This works fine on linux, but on windows the files created by lilypond are left locked when lilypond has exited. I can't re-use them on the next invocation, for example. Should I be exploring this as a possible bug in lilypond, or could there be something about the way I invoke it? Richard Shann ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list