* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-#include <config.h>
+#include "config.h"
#include <string.h>
#include <sys/types.h>
g_return_val_if_fail (width > 0 && height > 0, NULL);
if (stat (filename, &st) != 0) {
+ int errsv = errno;
+
g_set_error (error,
G_FILE_ERROR,
- g_file_error_from_errno (errno),
+ g_file_error_from_errno (errsv),
_("Could not get information for file '%s': %s"),
- filename, g_strerror (errno));
+ filename, g_strerror (errsv));
return NULL;
}
f = fopen (filename, "rb");
if (!f) {
+ int errsv = errno;
+
g_set_error (error,
G_FILE_ERROR,
- g_file_error_from_errno (errno),
+ g_file_error_from_errno (errsv),
_("Failed to open file '%s': %s"),
- filename, g_strerror (errno));
+ filename, g_strerror (errsv));
return NULL;
}
}
static void
-kill_dependent (GtkWindow *win, GtkObject *dep)
+kill_dependent (GtkWindow *win, GtkWidget *dep)
{
- gtk_object_destroy (dep);
+ gtk_widget_destroy (dep);
g_object_unref (dep);
}
gboolean force_rtl = FALSE;
gboolean multiple = FALSE;
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, "Filechooser action", "ACTION" },
- { "backend", 'b', 0, G_OPTION_ARG_STRING, &backend, "Filechooser backend (default: gtk+)", "BACKEND" },
+ { "action", 'a', 0, G_OPTION_ARG_STRING, &action_arg, "Filechooser action", "ACTION" },
{ "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 }
};
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);
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", backend,
"select-multiple", multiple,
NULL);
- g_free (backend);
-
switch (action)
{
case GTK_FILE_CHOOSER_ACTION_OPEN:
/* Preview widget */
/* THIS IS A TERRIBLE PREVIEW WIDGET, AND SHOULD NOT BE COPIED AT ALL.
*/
- preview_vbox = gtk_vbox_new (0, FALSE);
+ preview_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
/*gtk_file_chooser_set_preview_widget (GTK_FILE_CHOOSER (dialog), preview_vbox);*/
preview_label = gtk_label_new (NULL);
"file:///usr/share/pixmaps",
NULL);
+ /* 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);
control_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- vbbox = gtk_vbutton_box_new ();
+ vbbox = gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
gtk_container_add (GTK_CONTAINER (control_window), vbbox);
button = gtk_button_new_with_mnemonic ("_Select all");