]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkfilechooserdefault.c
label: refactor code
[~andy/gtk] / gtk / gtkfilechooserdefault.c
index 45d53b09cb5fa43d79ba3cef17cee34598b73b40..99c4200abdf2a7d3fc24bdeab151e63d3fa39f77 100644 (file)
@@ -392,7 +392,7 @@ static void remove_bookmark_button_clicked_cb (GtkButton             *button,
 
 static void update_cell_renderer_attributes (GtkFileChooserDefault *impl);
 
-static void load_remove_timer (GtkFileChooserDefault *impl);
+static void load_remove_timer (GtkFileChooserDefault *impl, LoadState new_load_state);
 static void browse_files_center_selected_row (GtkFileChooserDefault *impl);
 
 static void location_button_toggled_cb (GtkToggleButton *toggle,
@@ -1854,7 +1854,7 @@ shortcuts_append_bookmarks (GtkFileChooserDefault *impl,
 
       file = bookmarks->data;
 
-      if (impl->local_only && !g_file_is_native (file))
+      if (impl->local_only && !_gtk_file_has_native_path (file))
        continue;
 
       if (shortcut_find_position (impl, file) != -1)
@@ -1976,16 +1976,16 @@ shortcuts_add_volumes (GtkFileChooserDefault *impl)
          if (_gtk_file_system_volume_is_mounted (volume))
            {
              GFile *base_file;
-              gboolean base_is_native = TRUE;
+              gboolean base_has_native_path = FALSE;
 
              base_file = _gtk_file_system_volume_get_root (volume);
               if (base_file != NULL)
                 {
-                  base_is_native = g_file_is_native (base_file);
+                  base_has_native_path = _gtk_file_has_native_path (base_file);
                   g_object_unref (base_file);
                 }
 
-              if (!base_is_native)
+              if (!base_has_native_path)
                 continue;
            }
        }
@@ -5159,7 +5159,7 @@ set_local_only (GtkFileChooserDefault *impl,
        }
 
       if (local_only && impl->current_folder &&
-           !g_file_is_native (impl->current_folder))
+           !_gtk_file_has_native_path (impl->current_folder))
        {
          /* If we are pointing to a non-local folder, make an effort to change
           * back to a local folder, but it's really up to the app to not cause
@@ -6316,9 +6316,9 @@ load_setup_timer (GtkFileChooserDefault *impl)
   impl->load_state = LOAD_PRELOAD;
 }
 
-/* Removes the load timeout and switches to the LOAD_FINISHED state */
+/* Removes the load timeout; changes the impl->load_state to the specified value. */
 static void
-load_remove_timer (GtkFileChooserDefault *impl)
+load_remove_timer (GtkFileChooserDefault *impl, LoadState new_load_state)
 {
   if (impl->load_timeout_id != 0)
     {
@@ -6326,12 +6326,16 @@ load_remove_timer (GtkFileChooserDefault *impl)
 
       g_source_remove (impl->load_timeout_id);
       impl->load_timeout_id = 0;
-      impl->load_state = LOAD_EMPTY;
     }
   else
     g_assert (impl->load_state == LOAD_EMPTY ||
              impl->load_state == LOAD_LOADING ||
              impl->load_state == LOAD_FINISHED);
+
+  g_assert (new_load_state == LOAD_EMPTY ||
+           new_load_state == LOAD_LOADING ||
+           new_load_state == LOAD_FINISHED);
+  impl->load_state = new_load_state;
 }
 
 /* Selects the first row in the file list */
@@ -6404,9 +6408,14 @@ show_and_select_files (GtkFileChooserDefault *impl,
   gboolean selected_a_file;
   GSList *walk;
 
+  g_assert (impl->load_state == LOAD_FINISHED);
+  g_assert (impl->browse_files_model != NULL);
+
   selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
   fsmodel = GTK_FILE_SYSTEM_MODEL (gtk_tree_view_get_model (GTK_TREE_VIEW (impl->browse_files_tree_view)));
 
+  g_assert (fsmodel == impl->browse_files_model);
+
   enabled_hidden = impl->show_hidden;
   removed_filters = (impl->current_filter == NULL);
 
@@ -6541,7 +6550,7 @@ browse_files_model_finished_loading_cb (GtkFileSystemModel    *model,
 
   if (impl->load_state == LOAD_PRELOAD)
     {
-      load_remove_timer (impl);
+      load_remove_timer (impl, LOAD_FINISHED);
       load_set_model (impl);
     }
   else if (impl->load_state == LOAD_LOADING)
@@ -6574,7 +6583,7 @@ static void
 stop_loading_and_clear_list_model (GtkFileChooserDefault *impl,
                                    gboolean remove_from_treeview)
 {
-  load_remove_timer (impl); /* This changes the state to LOAD_EMPTY */
+  load_remove_timer (impl, LOAD_EMPTY);
   
   if (impl->browse_files_model)
     {
@@ -7329,7 +7338,7 @@ gtk_file_chooser_default_update_current_folder (GtkFileChooser    *chooser,
 
   operation_mode_set (impl, OPERATION_MODE_BROWSE);
 
-  if (impl->local_only && !g_file_is_native (file))
+  if (impl->local_only && !_gtk_file_has_native_path (file))
     {
       g_set_error_literal (error,
                            GTK_FILE_CHOOSER_ERROR,