mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 05:31:07 +00:00
ee3d137660
Sat Nov 13 22:30:29 GMT 1999 Tony Gale <gale@gtk.org> * docs/gtkfaq.sgml: threads example from Erik Mouw. New question on GtkLabel background colors. * docs/gtk_tut.sgml: - Correct the example code callback function definitions. - Update the gtkdial example code, from Frans van Schaik. - Update setselection.c to current API. * examples/Makefile examples/*/*.c: Update to code listed in tutorial.
50 lines
1.4 KiB
C
50 lines
1.4 KiB
C
/* example-start filesel filesel.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)));
|
|
}
|
|
|
|
void destroy( GtkWidget *widget,
|
|
gpointer data )
|
|
{
|
|
gtk_main_quit ();
|
|
}
|
|
|
|
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");
|
|
|
|
gtk_signal_connect (GTK_OBJECT (filew), "destroy",
|
|
(GtkSignalFunc) destroy, &filew);
|
|
/* Connect the ok_button to file_ok_sel function */
|
|
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button),
|
|
"clicked", (GtkSignalFunc) file_ok_sel, filew );
|
|
|
|
/* Connect the cancel_button to destroy the widget */
|
|
gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION
|
|
(filew)->cancel_button),
|
|
"clicked", (GtkSignalFunc) gtk_widget_destroy,
|
|
GTK_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;
|
|
}
|
|
/* example-end */
|