summaryrefslogtreecommitdiff
path: root/tests/testfilechooser.c
diff options
context:
space:
mode:
authorJonathan Blandford <jrb@redhat.com>2004-03-02 19:38:54 +0000
committerJonathan Blandford <jrb@src.gnome.org>2004-03-02 19:38:54 +0000
commitfe8838bce28cceac06b271d2c349500cee1da151 (patch)
tree6b5a297ca096d112195b43302ede7aaffc5b5f84 /tests/testfilechooser.c
parentc0778545828071a643afdcb08595410037155f8c (diff)
downloadgtk+-fe8838bce28cceac06b271d2c349500cee1da151.tar.gz
improve tests a little.
Tue Mar 2 14:38:10 2004 Jonathan Blandford <jrb@redhat.com> * tests/testfilechooser.c (main): improve tests a little.
Diffstat (limited to 'tests/testfilechooser.c')
-rw-r--r--tests/testfilechooser.c47
1 files changed, 39 insertions, 8 deletions
diff --git a/tests/testfilechooser.c b/tests/testfilechooser.c
index 9fbb270783..0beb08cad9 100644
--- a/tests/testfilechooser.c
+++ b/tests/testfilechooser.c
@@ -25,6 +25,7 @@
static GtkWidget *preview_label;
static GtkWidget *preview_image;
+static GtkFileChooserAction action;
static void
print_current_folder (GtkFileChooser *chooser)
@@ -306,18 +307,48 @@ main (int argc, char **argv)
GtkFileFilter *filter;
GtkWidget *preview_vbox;
GtkWidget *extra;
+ int i;
gtk_init (&argc, &argv);
+ action = GTK_FILE_CHOOSER_ACTION_OPEN;
+
+ /* lame-o arg parsing */
+ for (i = 1; i < argc; i++)
+ {
+ if (! strcmp ("--action=open", argv[i]))
+ action = GTK_FILE_CHOOSER_ACTION_OPEN;
+ else if (! strcmp ("--action=save", argv[i]))
+ action = GTK_FILE_CHOOSER_ACTION_SAVE;
+ else if (! strcmp ("--action=select_folder", argv[i]))
+ action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
+ else if (! strcmp ("--action=create_folder", argv[i]))
+ action = GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER;
+ }
+
dialog = g_object_new (GTK_TYPE_FILE_CHOOSER_DIALOG,
- "action", GTK_FILE_CHOOSER_ACTION_OPEN,
- "title", "Select a file",
+ "action", action,
+ "file-system-backend", "gnome-vfs",
NULL);
-
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_OK,
- NULL);
+ switch (action)
+ {
+ case GTK_FILE_CHOOSER_ACTION_OPEN:
+ case GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER:
+ gtk_window_set_title (GTK_WINDOW (dialog), "Select a file");
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_OK,
+ NULL);
+ break;
+ case GTK_FILE_CHOOSER_ACTION_SAVE:
+ case GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER:
+ gtk_window_set_title (GTK_WINDOW (dialog), "Save a file");
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_OK,
+ NULL);
+ break;
+ }
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
g_signal_connect (dialog, "selection-changed",
@@ -368,7 +399,7 @@ main (int argc, char **argv)
/* Extra widget */
extra = gtk_check_button_new_with_mnemonic ("Lar_t whoever asks about this button");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (extra), TRUE);
- gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), extra);
+ // gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), extra);
/* Shortcuts */