1998-03-31 23:43:49 +00:00
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
/* Get the selected filename and print it to the console */
|
2005-01-03 19:26:36 +00:00
|
|
|
static void file_ok_sel( GtkWidget *w,
|
|
|
|
GtkFileSelection *fs )
|
1998-03-31 23:43:49 +00:00
|
|
|
{
|
|
|
|
g_print ("%s\n", gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)));
|
|
|
|
}
|
|
|
|
|
1999-11-13 23:06:46 +00:00
|
|
|
int main( int argc,
|
|
|
|
char *argv[] )
|
1998-03-31 23:43:49 +00:00
|
|
|
{
|
|
|
|
GtkWidget *filew;
|
|
|
|
|
|
|
|
gtk_init (&argc, &argv);
|
|
|
|
|
|
|
|
/* Create a new file selection widget */
|
|
|
|
filew = gtk_file_selection_new ("File selection");
|
|
|
|
|
2002-02-19 19:47:16 +00:00
|
|
|
g_signal_connect (G_OBJECT (filew), "destroy",
|
|
|
|
G_CALLBACK (gtk_main_quit), NULL);
|
1998-03-31 23:43:49 +00:00
|
|
|
/* Connect the ok_button to file_ok_sel function */
|
2002-02-19 19:47:16 +00:00
|
|
|
g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (filew)->ok_button),
|
2002-08-24 11:53:26 +00:00
|
|
|
"clicked", G_CALLBACK (file_ok_sel), (gpointer) filew);
|
1998-03-31 23:43:49 +00:00
|
|
|
|
|
|
|
/* Connect the cancel_button to destroy the widget */
|
2002-02-19 19:47:16 +00:00
|
|
|
g_signal_connect_swapped (G_OBJECT (GTK_FILE_SELECTION (filew)->cancel_button),
|
2002-08-24 11:53:26 +00:00
|
|
|
"clicked", G_CALLBACK (gtk_widget_destroy),
|
|
|
|
G_OBJECT (filew));
|
1998-03-31 23:43:49 +00:00
|
|
|
|
|
|
|
/* Lets set the filename, as if this were a save dialog, and we are giving
|
|
|
|
a default filename */
|
|
|
|
gtk_file_selection_set_filename (GTK_FILE_SELECTION(filew),
|
|
|
|
"penguin.png");
|
|
|
|
|
2002-02-19 01:25:26 +00:00
|
|
|
gtk_widget_show (filew);
|
1998-03-31 23:43:49 +00:00
|
|
|
gtk_main ();
|
|
|
|
return 0;
|
|
|
|
}
|