Add an --initial-folder option to testfilechooser.c

Signed-off-by: default avatarFederico Mena Quintero <federico@novell.com>
parent c98ebe31
......@@ -490,6 +490,7 @@ main (int argc, char **argv)
char *action_arg = NULL;
char *backend = NULL;
char *initial_filename = NULL;
char *initial_folder = NULL;
GError *error = NULL;
GOptionEntry options[] = {
{ "action", 'a', 0, G_OPTION_ARG_STRING, &action_arg, "Filechooser action", "ACTION" },
......@@ -497,6 +498,7 @@ main (int argc, char **argv)
{ "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 },
{ "initial-filename", 'f', 0, G_OPTION_ARG_FILENAME, &initial_filename, "Initial filename to select", "FILENAME" },
{ "initial-folder", 'F', 0, G_OPTION_ARG_FILENAME, &initial_folder, "Initial folder to show", "FILENAME" },
{ NULL }
};
......@@ -507,6 +509,12 @@ main (int argc, char **argv)
return 1;
}
if (initial_filename && initial_folder)
{
g_print ("Only one of --initial-filename and --initial-folder may be specified");
return 1;
}
if (force_rtl)
gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
......@@ -627,11 +635,14 @@ main (int argc, char **argv)
"file:///usr/share/pixmaps",
NULL);
/* Initial filename */
/* Initial filename or folder */
if (initial_filename)
set_filename (GTK_FILE_CHOOSER (dialog), initial_filename);
if (initial_folder)
set_current_folder (GTK_FILE_CHOOSER (dialog), initial_folder);
/* show_all() to reveal bugs in composite widget handling */
gtk_widget_show_all (dialog);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment