]> Pileus Git - ~andy/gtk/blobdiff - tests/testfilechooser.c
gtk: remove "gboolean homogeneous" from gtk_box_new()
[~andy/gtk] / tests / testfilechooser.c
index 4164d739b23828b6a50c8c05c96108eb465d0d05..dcefbc1eb30a378be9ec441ce986990f6bb5d65a 100644 (file)
@@ -17,7 +17,7 @@
  * 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>
@@ -199,11 +199,13 @@ my_new_from_file_at_size (const char *filename,
         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;
        }
 
@@ -212,11 +214,13 @@ my_new_from_file_at_size (const char *filename,
 
        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;
         }
 
@@ -403,9 +407,9 @@ unmap_and_remap_cb (GtkButton *button,
 }
 
 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);
 }
 
@@ -484,13 +488,15 @@ main (int argc, char **argv)
   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 }
   };
 
@@ -501,6 +507,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);
 
@@ -520,17 +532,11 @@ main (int argc, char **argv)
       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:
@@ -594,7 +600,7 @@ main (int argc, char **argv)
   /* 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);
@@ -621,6 +627,14 @@ main (int argc, char **argv)
                                            "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);
 
@@ -630,7 +644,7 @@ main (int argc, char **argv)
 
   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");