mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-29 06:51:10 +00:00
1bfcf9ba16
Sat Aug 24 12:46:37 BST 2002 Tony Gale <gale@gtk.org> * docs/tutorial/gtk-tut.sgml, examples/*: update g_connect_signal usage * docs/faq/gtk-faq.html: spelling/grammar fixes
41 lines
1.2 KiB
C
41 lines
1.2 KiB
C
|
|
#include <gtk/gtk.h>
|
|
|
|
/* Get the selected filename and print it to the console */
|
|
void file_ok_sel( GtkWidget *w,
|
|
GtkFileSelection *fs )
|
|
{
|
|
g_print ("%s\n", gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)));
|
|
}
|
|
|
|
int main( int argc,
|
|
char *argv[] )
|
|
{
|
|
GtkWidget *filew;
|
|
|
|
gtk_init (&argc, &argv);
|
|
|
|
/* Create a new file selection widget */
|
|
filew = gtk_file_selection_new ("File selection");
|
|
|
|
g_signal_connect (G_OBJECT (filew), "destroy",
|
|
G_CALLBACK (gtk_main_quit), NULL);
|
|
/* Connect the ok_button to file_ok_sel function */
|
|
g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (filew)->ok_button),
|
|
"clicked", G_CALLBACK (file_ok_sel), (gpointer) filew);
|
|
|
|
/* Connect the cancel_button to destroy the widget */
|
|
g_signal_connect_swapped (G_OBJECT (GTK_FILE_SELECTION (filew)->cancel_button),
|
|
"clicked", G_CALLBACK (gtk_widget_destroy),
|
|
G_OBJECT (filew));
|
|
|
|
/* 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");
|
|
|
|
gtk_widget_show (filew);
|
|
gtk_main ();
|
|
return 0;
|
|
}
|