]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkfilechooserdefault.c
Free volumes not actually put into the shortcut list.
[~andy/gtk] / gtk / gtkfilechooserdefault.c
index 667a0a54723e8c37957816d13261d70176cc2a58..8987297667fd8402043ffd0074b524b2b8bfa938 100644 (file)
@@ -1216,7 +1216,7 @@ shortcuts_add_volumes (GtkFileChooserDefault *impl)
       GtkFileSystemVolume *volume;
 
       volume = l->data;
-      
+
       if (impl->local_only)
        {
          GtkFilePath *base_path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
@@ -1224,11 +1224,16 @@ shortcuts_add_volumes (GtkFileChooserDefault *impl)
          gtk_file_path_free (base_path);
 
          if (!is_local)
-           continue;
+           {
+             gtk_file_system_volume_free (impl->file_system, volume);
+             continue;
+           }
        }
 
-      shortcuts_insert_path (impl, start_row + n, TRUE, volume, NULL, NULL, FALSE, NULL);
-      n++;
+      if (shortcuts_insert_path (impl, start_row + n, TRUE, volume, NULL, NULL, FALSE, NULL))
+       n++;
+      else
+       gtk_file_system_volume_free (impl->file_system, volume);
     }
 
   impl->num_volumes = n;
@@ -1625,42 +1630,30 @@ shortcuts_add_bookmark_from_path (GtkFileChooserDefault *impl,
                                  const GtkFilePath     *path,
                                  int                    pos)
 {
-  GtkFileInfo *info;
   GError *error;
-  gboolean result;
 
   if (shortcut_find_position (impl, path) != -1)
     return FALSE;
 
-  result = FALSE;
-
+  /* FIXME: this check really belongs in gtk_file_system_insert_bookmark.  */
   error = NULL;
-  info = get_file_info (impl->file_system, path, FALSE, &error);
-
-  if (!info)
-    error_getting_info_dialog (impl, path, error);
-  else if (!gtk_file_info_get_is_folder (info))
+  if (!check_is_folder (impl->file_system, path, &error))
     {
-      char *msg;
-      char *uri;
-
-      uri = gtk_file_system_path_to_uri (impl->file_system, path);
-      msg = g_strdup_printf (_("Could not add bookmark for %s because it is not a folder."),
-                            uri);
-      error_message (impl, msg);
-      g_free (uri);
-      g_free (msg);
+      error_dialog (impl,
+                   _("Could not add bookmark for %s because it is not a folder."),
+                   path,
+                   error);
+      return FALSE;
     }
-  else
+
+  error = NULL;
+  if (!gtk_file_system_insert_bookmark (impl->file_system, path, pos, &error))
     {
-      error = NULL;
-      if (gtk_file_system_insert_bookmark (impl->file_system, path, pos, &error))
-       result = TRUE;
-      else
-       error_could_not_add_bookmark_dialog (impl, path, error);
+      error_could_not_add_bookmark_dialog (impl, path, error);
+      return FALSE;
     }
 
-  return result;
+  return TRUE;
 }
 
 static void
@@ -3155,8 +3148,7 @@ update_appearance (GtkFileChooserDefault *impl)
        _gtk_file_system_model_set_show_files (impl->browse_files_model, TRUE);
     }
 
-  if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN
-      || impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
+  if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN)
     gtk_widget_hide (impl->browse_new_folder_button);
   else
     gtk_widget_show (impl->browse_new_folder_button);
@@ -3428,11 +3420,14 @@ check_icon_theme (GtkFileChooserDefault *impl)
   if (impl->settings_signal_id)
     return;
 
-  settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (impl)));
-  impl->settings_signal_id = g_signal_connect (settings, "notify",
-                                              G_CALLBACK (settings_notify_cb), impl);
+  if (gtk_widget_has_screen (GTK_WIDGET (impl)))
+    {
+      settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (impl)));
+      impl->settings_signal_id = g_signal_connect (settings, "notify",
+                                                  G_CALLBACK (settings_notify_cb), impl);
 
-  change_icon_theme (impl);
+      change_icon_theme (impl);
+    }
 }
 
 static void
@@ -3700,7 +3695,7 @@ gtk_file_chooser_default_set_current_folder (GtkFileChooser    *chooser,
                   GTK_FILE_SYSTEM_ERROR,
                   GTK_FILE_SYSTEM_ERROR_FAILED,
                   _("Can't change to folder because it isn't local"));
-      
+
       return FALSE;
     }
 
@@ -3913,6 +3908,8 @@ get_paths_foreach (GtkTreeModel *model,
   gtk_tree_model_sort_convert_iter_to_child_iter (info->impl->sort_model, &sel_iter, iter);
 
   file_path = _gtk_file_system_model_get_path (GTK_FILE_SYSTEM_MODEL (fs_model), &sel_iter);
+  if (!file_path)
+    return; /* We are on the editable row */
 
   if (!info->path_from_entry
       || gtk_file_path_compare (info->path_from_entry, file_path) != 0)
@@ -5018,7 +5015,7 @@ location_popup_handler (GtkFileChooserDefault *impl)
     {
       title = _("Open Location");
     }
-  else 
+  else
     {
       g_assert (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
                || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
@@ -5062,7 +5059,7 @@ location_popup_handler (GtkFileChooserDefault *impl)
            {
              gtk_widget_grab_focus (impl->browse_files_tree_view);
            }
-         else 
+         else
            {
              g_assert (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
                        || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);