[GTK+] What is the equivalent of GTK_FILE_CHOOSER (dialog) in xblite ?

57 views
Skip to first unread message

Julien

unread,
Mar 23, 2009, 2:01:53 PM3/23/09
to xblite
Hello all,

I'm playing with GTK+ for xblite and cannot figure me out which
argument pass to gtk_file_chooser_get_filename. In other words, what
is the equivalent of GTK_FILE_CHOOSER for the xblite binding of GTK+.

IF (gtk_dialog_run (dialog) = $$GTK_RESPONSE_ACCEPT) THEN
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER
(dialog));
END IF

I assume that in C++, GTK_FILE_CHOOSER() returns a pointer to the
"File" field of the "Open file" dialog but have no idea how to
retrieve such GTK child grid in xblite.

Some valid code to open the "Open file" dialog is pasted in the 2nd
message of this thread.
http://www.xblite.com/forum/m-1237579901/

Thanks for any help.

Julien

Liviu

unread,
Mar 25, 2009, 7:06:37 PM3/25/09
to xblite
Hi Julien,

This code works for me:

gtk_init (argc, argv)
title$ = "Open file"
dialog = gtk_file_chooser_dialog_new (&title$, NULL, $
$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_utf8 (dialog)
PRINT CSTRING$(filename)
'open_file (filename);
'g_free (filename);
END IF

gtk_widget_destroy (dialog)

a$ = INLINE$("Press ENTER to exit")


As you see, you will have to use gtk_file_chooser_get_filename_utf8
instead of gtk_file_chooser_get_filename
(see gtkfilechooser.h
/* Reserve old names for DLL ABI backward compatibility */
#define gtk_file_chooser_get_filename
gtk_file_chooser_get_filename_utf8
)

As far I understand GTK_FILE_CHOOSER is a macro that cast the dialog
pointer.
(
#define GTK_TYPE_FILE_CHOOSER_DIALOG
(gtk_file_chooser_dialog_get_type ())
#define GTK_FILE_CHOOSER_DIALOG(obj)
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_CHOOSER_DIALOG,
GtkFileChooserDialog))
)

To be onest, I am using Common Dialog Controls for this kind of
situations (and when I know the program will run only on Win32).

Hope this helps more than confuse..

Cheers,
Liviu


On Mar 24, 7:01 am, Julien <j.a.rouil...@gmail.com> wrote:
> Hello all,

Julien

unread,
Mar 29, 2009, 8:04:28 AM3/29/09
to xblite
Hi Liviu,

Thanks a lot. Seems that you better understood than me what
GTK_FILE_CHOOSER is. :-)
Your code works fine and that's the only thing that matters.
Cheers.

Julien
Reply all
Reply to author
Forward
0 new messages