diff options
author | Matthias Clasen <mclasen@redhat.com> | 2008-02-16 01:23:18 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2008-02-16 01:23:18 +0000 |
commit | f27fe11cb8cc1b9e095a8f111628a7ca026a7e7b (patch) | |
tree | 66704cc8e23ba6693cab9f55b11a79dd49dc3632 /tests | |
parent | 2dd5dd634051363fd3d17c3badb1b78a76011bf6 (diff) | |
download | gtk+-f27fe11cb8cc1b9e095a8f111628a7ca026a7e7b.tar.gz |
Add a --backend option. (#516073, Christian Persch)
2008-02-15 Matthias Clasen <mclasen@redhat.com>
* tests/testfilechooser.c: Add a --backend option.
(#516073, Christian Persch)
svn path=/trunk/; revision=19588
Diffstat (limited to 'tests')
-rw-r--r-- | tests/testfilechooser.c | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/tests/testfilechooser.c b/tests/testfilechooser.c index 548114fd17..4164d739b2 100644 --- a/tests/testfilechooser.c +++ b/tests/testfilechooser.c @@ -481,37 +481,56 @@ main (int argc, char **argv) GtkWidget *extra; GtkFileFilter *filter; GtkWidget *preview_vbox; - int i; + gboolean force_rtl = FALSE; gboolean multiple = FALSE; + char *action_arg = NULL; + char *backend = NULL; + GError *error = NULL; + GOptionEntry options[] = { + { "action", 'a', 0, G_OPTION_ARG_STRING, &action, "Filechooser action", "ACTION" }, + { "backend", 'b', 0, G_OPTION_ARG_STRING, &backend, "Filechooser backend (default: gtk+)", "BACKEND" }, + { "multiple", 'm', 0, G_OPTION_ARG_NONE, &multiple, "Select-multiple", NULL }, + { "right-to-left", 'r', 0, G_OPTION_ARG_NONE, &force_rtl, "Force right-to-left layout.", NULL }, + { NULL } + }; + + if (!gtk_init_with_args (&argc, &argv, "", options, NULL, &error)) + { + g_print ("Failed to parse args: %s\n", error->message); + g_error_free (error); + return 1; + } - gtk_init (&argc, &argv); - - /* to test rtl layout, set RTL=1 in the environment */ - if (g_getenv ("RTL")) + if (force_rtl) gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL); action = GTK_FILE_CHOOSER_ACTION_OPEN; - /* lame-o arg parsing */ - for (i = 1; i < argc; i++) + if (action_arg != NULL) { - if (! strcmp ("--action=open", argv[i])) + if (! strcmp ("open", action_arg)) action = GTK_FILE_CHOOSER_ACTION_OPEN; - else if (! strcmp ("--action=save", argv[i])) + else if (! strcmp ("save", action_arg)) action = GTK_FILE_CHOOSER_ACTION_SAVE; - else if (! strcmp ("--action=select_folder", argv[i])) + else if (! strcmp ("select_folder", action_arg)) action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; - else if (! strcmp ("--action=create_folder", argv[i])) + else if (! strcmp ("create_folder", action_arg)) action = GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER; - else if (! strcmp ("--multiple", argv[i])) - multiple = TRUE; + + g_free (action_arg); } + if (backend == NULL) + backend = g_strdup ("gtk+"); + dialog = g_object_new (GTK_TYPE_FILE_CHOOSER_DIALOG, "action", action, - "file-system-backend", "gtk+", + "file-system-backend", backend, "select-multiple", multiple, NULL); + + g_free (backend); + switch (action) { case GTK_FILE_CHOOSER_ACTION_OPEN: |