Print Topic - Archive

XBLite Forum  /  General Programming Discussion  /  xblite and GTK+
Posted by: Julien, March 20, 2009, 8:11pm
Hi folks,

I know that this is more a GTK+ question than an xblite one,
but I'm trying to use Liviu Armeanu's GTK+ binding for xblite to create a "File Open" dialog window...

At runtime, I get this error :
Gtk-CRITICAL **:gtk_window_set_transient_for: assertion `parent == NULL || GTK_IS_WINDOW (parent)' failed

This is like the parent window that is then passed to the "File Open" dialog could not be created.

Is there some GTK guru here?
Here the code:

gtk_init (argc, argv)
window = gtk_window_new ($$GTK_WINDOW_TOPLEVEL)
title$ = "Open file"
dialog = gtk_file_chooser_dialog_new (&title$, &window, $$GTK_FILE_CHOOSER_ACTION_OPEN, &$$GTK_STOCK_CANCEL, $$GTK_RESPONSE_CANCEL, &$$GTK_STOCK_OPEN, $$GTK_RESPONSE_ACCEPT, NULL)
gtk_main ()
Posted by: Julien, March 21, 2009, 5:24pm; Reply: 1
The xblite code below works to create a GTK+ "Open file" dialog.
As parent window for the dialog, I pass a value of 0 (variable None).
The dialog displays, however, I don't know what should be the xblite/GTK equivalent for this GTK_FILE_CHOOSER (dialog)

For those interested in GTK+ for xblite, see : http://homepages.ihug.co.nz/~armeanu/xblite.html
See the message on the xblite Google Groups forum if you encounter installation problems with the necessary libraries.

gtk_init (argc, argv)
title$ = "Open file"
dialog = gtk_file_chooser_dialog_new (&title$, None, $$GTK_FILE_CHOOSER_ACTION_OPEN, &$$GTK_STOCK_CANCEL, $$GTK_RESPONSE_CANCEL, &$$GTK_STOCK_OPEN, $$GTK_RESPONSE_ACCEPT, NULL)
    
IF (gtk_dialog_run (dialog) = $$GTK_RESPONSE_ACCEPT) THEN
    'filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
    'open_file (filename);
    'g_free (filename);
END IF
     
gtk_widget_destroy (dialog)
Posted by: Julien, March 29, 2009, 12:07pm; Reply: 2
To retrieve the file name of the file to open, use gtk_file_chooser_get_filename_utf8 instead of gtk_file_chooser_get_filename.

See this thread for details : http://groups.google.com/group/xblite/browse_thread/thread/f520978a90715b2a
Print page generated: February 5, 2012, 2:39pm