]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkfilechooserbutton.c
filechooser: Use _gtk_file_has_native_path() throughout when testing for local_only
[~andy/gtk] / gtk / gtkfilechooserbutton.c
index 47f5240237cf6a800632ff9766e78d81051292af..a14bd92e2ea74dee58ebf406e82c408412ef0938 100644 (file)
@@ -1954,7 +1954,7 @@ model_add_volumes (GtkFileChooserButton *button,
               base_file = _gtk_file_system_volume_get_root (volume);
               if (base_file != NULL)
                 {
-                  if (!g_file_is_native (base_file))
+                  if (!_gtk_file_has_native_path (base_file))
                     {
                       g_object_unref (base_file);
                       continue;
@@ -2014,7 +2014,7 @@ model_add_bookmarks (GtkFileChooserButton *button,
 
       file = l->data;
 
-      if (g_file_is_native (file))
+      if (_gtk_file_has_native_path (file))
        {
          gtk_list_store_insert (store, &iter, pos);
          gtk_list_store_set (store, &iter,
@@ -2236,7 +2236,7 @@ test_if_file_is_visible (GtkFileSystem *fs,
   if (!file)
     return FALSE;
 
-  if (local_only && !g_file_is_native (file))
+  if (local_only && !_gtk_file_has_native_path (file))
     return FALSE;
 
   if (!is_folder)
@@ -2289,7 +2289,7 @@ filter_model_visible_func (GtkTreeModel *model,
 
                if (base_file)
                  {
-                   if (!g_file_is_native (base_file))
+                   if (!_gtk_file_has_native_path (base_file))
                      retval = FALSE;
                     g_object_unref (base_file);
                  }
@@ -2346,13 +2346,13 @@ static void
 update_combo_box (GtkFileChooserButton *button)
 {
   GtkFileChooserButtonPrivate *priv = button->priv;
-  GSList *files;
+  GFile *file;
   GtkTreeIter iter;
   gboolean row_found;
 
   gtk_tree_model_get_iter_first (priv->filter_model, &iter);
 
-  files = gtk_file_chooser_get_files (GTK_FILE_CHOOSER (priv->dialog));
+  file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (priv->dialog));
 
   row_found = FALSE;
 
@@ -2375,9 +2375,7 @@ update_combo_box (GtkFileChooserButton *button)
        case ROW_TYPE_SHORTCUT:
        case ROW_TYPE_BOOKMARK:
        case ROW_TYPE_CURRENT_FOLDER:
-         row_found = (files &&
-                      files->data &&
-                      g_file_equal (data, files->data));
+         row_found = (file && g_file_equal (data, file));
          break;
        case ROW_TYPE_VOLUME:
          {
@@ -2386,9 +2384,7 @@ update_combo_box (GtkFileChooserButton *button)
            base_file = _gtk_file_system_volume_get_root (data);
             if (base_file)
               {
-               row_found = (files &&
-                            files->data &&
-                            g_file_equal (base_file, files->data));
+               row_found = (file && g_file_equal (base_file, file));
                g_object_unref (base_file);
               }
          }
@@ -2410,12 +2406,12 @@ update_combo_box (GtkFileChooserButton *button)
   while (!row_found && gtk_tree_model_iter_next (priv->filter_model, &iter));
 
   /* If it hasn't been found already, update & select the current-folder row. */
-  if (!row_found && files && files->data)
+  if (!row_found && file)
     {
       GtkTreeIter filter_iter;
       gint pos;
     
-      model_update_current_folder (button, files->data);
+      model_update_current_folder (button, file);
       gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (priv->filter_model));
 
       pos = model_get_type_position (button, ROW_TYPE_CURRENT_FOLDER);
@@ -2429,8 +2425,8 @@ update_combo_box (GtkFileChooserButton *button)
       g_signal_handler_unblock (priv->combo_box, priv->combo_box_changed_id);
     }
 
-  g_slist_foreach (files, (GFunc) g_object_unref, NULL);
-  g_slist_free (files);
+  if (file)
+    g_object_unref (file);
 }
 
 /* Button */
@@ -2476,9 +2472,9 @@ update_label_and_image (GtkFileChooserButton *button)
 {
   GtkFileChooserButtonPrivate *priv = button->priv;
   gchar *label_text;
-  GSList *files;
+  GFile *file;
 
-  files = gtk_file_chooser_get_files (GTK_FILE_CHOOSER (priv->dialog));
+  file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (priv->dialog));
   label_text = NULL;
 
   if (priv->update_button_cancellable)
@@ -2487,13 +2483,10 @@ update_label_and_image (GtkFileChooserButton *button)
       priv->update_button_cancellable = NULL;
     }
 
-  if (files && files->data)
+  if (file)
     {
-      GFile *file;
       GtkFileSystemVolume *volume = NULL;
 
-      file = files->data;
-
       volume = _gtk_file_system_get_volume_for_file (priv->fs, file);
       if (volume)
         {
@@ -2543,10 +2536,10 @@ update_label_and_image (GtkFileChooserButton *button)
           if (pixbuf)
             g_object_unref (pixbuf);
         }
+
+      g_object_unref (file);
     }
 out:
-  g_slist_foreach (files, (GFunc) g_object_unref, NULL);
-  g_slist_free (files);
 
   if (label_text)
     {
@@ -2816,7 +2809,7 @@ dialog_notify_cb (GObject    *dialog,
 
          /* If the path isn't local but we're in local-only mode now, remove
           * the custom-folder row */
-         if (data && g_file_is_native (G_FILE (data)) &&
+         if (data && _gtk_file_has_native_path (G_FILE (data)) &&
              gtk_file_chooser_get_local_only (GTK_FILE_CHOOSER (priv->dialog)))
            {
              pos--;