(reload_current_folder): Likewise.
(refresh_current_folder_and_file_part): Likewise, and ensure that
the error cases result in the invariant being held.
+ (start_loading_current_folder): Check if the folder to be loaded
+ is non-native for the local_only=TRUE case; if so, return an error
+ as we are configured to load only local folders.
+ (reload_current_folder): Pass on errors from
+ start_loading_current_folder(). Tighten the preconditions, as we
+ are sure that we can only receive non-NULL folder-files to load.
+ (refresh_current_folder_and_file_part): Pass on errors from
+ reload_current_folder(). At the very end, assert the invariant
+ described above.
2009-01-22 Matthew Barnes <mbarnes@redhat.com>
for some locales. It should not be that necessary, now that we
do show preedit text even in password entries. Pointed out by
Frederic Crozat.
+ (start_loading_current_folder): Check if the folder to be loaded
+ is non-native for the local_only=TRUE case; if so, return an error
+ as we are configured to load only local folders.
+ (reload_current_folder): Pass on errors from
+ start_loading_current_folder(). Tighten the preconditions, as we
+ are sure that we can only receive non-NULL folder-files to load.
+ (refresh_current_folder_and_file_part): Pass on errors from
+ reload_current_folder(). At the very end, assert the invariant
+ described above.
2009-01-21 Federico Mena Quintero <federico@novell.com>
g_object_unref (cancellable);
}
-static void
+static RefreshStatus
start_loading_current_folder (GtkFileChooserEntry *chooser_entry)
{
- if (chooser_entry->current_folder_file == NULL ||
- chooser_entry->file_system == NULL)
- return;
+ if (chooser_entry->file_system == NULL)
+ return REFRESH_OK;
+
+ g_assert (chooser_entry->current_folder_file != NULL);
+ g_assert (chooser_entry->current_folder == NULL);
+ g_assert (chooser_entry->load_folder_cancellable == NULL);
if (chooser_entry->local_only
&& !g_file_is_native (chooser_entry->current_folder_file))
- return;
+ {
+ g_object_unref (chooser_entry->current_folder_file);
+ chooser_entry->current_folder_file = NULL;
- g_assert (chooser_entry->current_folder == NULL);
- g_assert (chooser_entry->load_folder_cancellable == NULL);
+ return REFRESH_NOT_LOCAL;
+ }
chooser_entry->load_folder_cancellable =
_gtk_file_system_get_folder (chooser_entry->file_system,
"standard::name,standard::display-name,standard::type",
load_directory_get_folder_callback,
g_object_ref (chooser_entry));
+
+ return REFRESH_OK;
}
-static void
+static RefreshStatus
reload_current_folder (GtkFileChooserEntry *chooser_entry,
GFile *folder_file,
gboolean force_reload)
{
gboolean reload = FALSE;
+ g_assert (folder_file != NULL);
+
if (chooser_entry->current_folder_file)
{
- if ((folder_file && !(g_file_equal (folder_file, chooser_entry->current_folder_file)
- && chooser_entry->load_folder_cancellable))
+ if ((!(g_file_equal (folder_file, chooser_entry->current_folder_file)
+ && chooser_entry->load_folder_cancellable))
|| force_reload)
{
reload = TRUE;
discard_current_folder (chooser_entry);
discard_loading_and_current_folder_file (chooser_entry);
- chooser_entry->current_folder_file = (folder_file) ? g_object_ref (folder_file) : NULL;
+ chooser_entry->current_folder_file = g_object_ref (folder_file);
}
}
else
{
- chooser_entry->current_folder_file = (folder_file) ? g_object_ref (folder_file) : NULL;
+ chooser_entry->current_folder_file = g_object_ref (folder_file);
reload = TRUE;
}
if (reload)
- start_loading_current_folder (chooser_entry);
+ return start_loading_current_folder (chooser_entry);
+ else
+ return REFRESH_OK;
}
static RefreshStatus
}
else
{
+ g_assert (folder_file != NULL);
+
file_part_len = strlen (file_part);
total_len = strlen (text);
if (total_len > file_part_len)
if (result == REFRESH_OK)
{
- /* FMQ: this needs to return an error if the folder is not local */
- reload_current_folder (chooser_entry, folder_file, file_part_pos == -1);
+ result = reload_current_folder (chooser_entry, folder_file, file_part_pos == -1);
}
else
{
if (folder_file)
g_object_unref (folder_file);
+ g_assert (/* we are OK and we have a current folder file and (loading process or folder handle)... */
+ ((result == REFRESH_OK)
+ && (chooser_entry->current_folder_file != NULL)
+ && (((chooser_entry->load_folder_cancellable != NULL) && (chooser_entry->current_folder == NULL))
+ || ((chooser_entry->load_folder_cancellable == NULL) && (chooser_entry->current_folder != NULL))))
+ /* ... OR we have an error, and we don't have a current folder file nor a loading process nor a folder handle */
+ || ((result != REFRESH_OK)
+ && (chooser_entry->current_folder_file == NULL)
+ && (chooser_entry->load_folder_cancellable == NULL)
+ && (chooser_entry->current_folder == NULL)));
+
return result;
}