Commit 6cd6a0a2 authored by Federico Mena Quintero's avatar Federico Mena Quintero Committed by Federico Mena Quintero

Don't reload the current folder unnecessarily on ::map().

2005-09-27  Federico Mena Quintero  <federico@ximian.com>

	Don't reload the current folder unnecessarily on ::map().

	* gtk/gtkfilechooserprivate.h (ReloadState): New enum to represent
	the reloading state.
	(struct _GtkFileChooserDefault): Added a "reload_state" field.

	* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_init):
	Initialize impl->reload_state.
	(gtk_file_chooser_default_map): Check the impl->reload_state; load
	a default folder if no folder has been set, or reload the current
	one only if we had been unmapped first.
	(gtk_file_chooser_default_update_current_folder): Set the
	reload_state to RELOAD_HAS_FOLDER.
	(gtk_file_chooser_default_unmap): Implement, and set the
	reload_state to RELOAD_WAS_UNMAPPED.
	(shortcuts_model_create): Don't call shortcuts_add_bookmarks()
	here; they'll get (re)loaded on ::map() anyway.

	* gtk/gtkfilechooserwidget.c
	(gtk_file_chooser_widget_constructor): Don't set a default folder here.

	* tests/autotestfilechooser.c (test_action_widgets): Don't take in
	a dialog; build it ourselves.
	(test_reload): New test to ensure that we don't load the default
	folder more than once, and that we reload it when
	unmapping/remapping.
	(get_impl_from_dialog): New utility function.
	(test_widgets_for_current_action): Use get_impl_from_dialog().
parent 72851a22
...@@ -135,6 +135,12 @@ typedef enum { ...@@ -135,6 +135,12 @@ typedef enum {
LOAD_FINISHED /* Model is fully loaded and inserted into the tree */ LOAD_FINISHED /* Model is fully loaded and inserted into the tree */
} LoadState; } LoadState;
typedef enum {
RELOAD_EMPTY, /* No folder has been set */
RELOAD_HAS_FOLDER, /* We have a folder, although it may not be completely loaded yet; no need to reload */
RELOAD_WAS_UNMAPPED /* We had a folder but got unmapped; reload is needed */
} ReloadState;
struct _GtkFileChooserDefault struct _GtkFileChooserDefault
{ {
GtkVBox parent_instance; GtkVBox parent_instance;
...@@ -182,6 +188,7 @@ struct _GtkFileChooserDefault ...@@ -182,6 +188,7 @@ struct _GtkFileChooserDefault
GtkTreeModelSort *sort_model; GtkTreeModelSort *sort_model;
LoadState load_state; LoadState load_state;
ReloadState reload_state;
guint load_timeout_id; guint load_timeout_id;
GSList *pending_select_paths; GSList *pending_select_paths;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment