summaryrefslogtreecommitdiff
path: root/examples/filesel
diff options
context:
space:
mode:
authorShawn Amundson <amundson@src.gnome.org>1998-03-31 23:43:49 +0000
committerShawn Amundson <amundson@src.gnome.org>1998-03-31 23:43:49 +0000
commitc36ca76bb84879ed1e2ba51541c95eacd56e550e (patch)
tree8a01644357246180f22165e28d7f0cdf8cf67afe /examples/filesel
parent30f22e0208593dba5ca5d3b824d8d03519414296 (diff)
downloadgtk+-c36ca76bb84879ed1e2ba51541c95eacd56e550e.tar.gz
Tue Mar 31 15:41:57 PST 1998 Shawn T. Amundson
* Makefile.am: * examples/*: added the rest of the tutorial examples
Diffstat (limited to 'examples/filesel')
-rw-r--r--examples/filesel/Makefile8
-rw-r--r--examples/filesel/filesel.c46
2 files changed, 54 insertions, 0 deletions
diff --git a/examples/filesel/Makefile b/examples/filesel/Makefile
new file mode 100644
index 0000000000..7df5a5d7f8
--- /dev/null
+++ b/examples/filesel/Makefile
@@ -0,0 +1,8 @@
+
+CC = gcc
+
+filesel: filesel.c
+ $(CC) `gtk-config --cflags` `gtk-config --libs` filesel.c -o filesel
+
+clean:
+ rm -f *.o filesel
diff --git a/examples/filesel/filesel.c b/examples/filesel/filesel.c
new file mode 100644
index 0000000000..5a19392b00
--- /dev/null
+++ b/examples/filesel/filesel.c
@@ -0,0 +1,46 @@
+/* This file extracted from the GTK tutorial. */
+
+/* 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;
+}