mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-05 02:11:08 +00:00
filechooserentry: Refactor function
Name the function set_completion_folder() and make it accept NULL, so it behaves like a regular setter function.
This commit is contained in:
parent
ea8f5f15c1
commit
d27d73f885
@ -119,6 +119,8 @@ static gboolean completion_match_func (GtkEntryCompletion *comp,
|
|||||||
gpointer data);
|
gpointer data);
|
||||||
|
|
||||||
static void refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry);
|
static void refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry);
|
||||||
|
static void set_completion_folder (GtkFileChooserEntry *chooser_entry,
|
||||||
|
GFile *folder);
|
||||||
static void finished_loading_cb (GtkFileSystemModel *model,
|
static void finished_loading_cb (GtkFileSystemModel *model,
|
||||||
GError *error,
|
GError *error,
|
||||||
GtkFileChooserEntry *chooser_entry);
|
GtkFileChooserEntry *chooser_entry);
|
||||||
@ -237,28 +239,12 @@ gtk_file_chooser_entry_finalize (GObject *object)
|
|||||||
G_OBJECT_CLASS (_gtk_file_chooser_entry_parent_class)->finalize (object);
|
G_OBJECT_CLASS (_gtk_file_chooser_entry_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
discard_loading_and_current_folder_file (GtkFileChooserEntry *chooser_entry)
|
|
||||||
{
|
|
||||||
if (chooser_entry->current_folder_file)
|
|
||||||
{
|
|
||||||
g_object_unref (chooser_entry->current_folder_file);
|
|
||||||
chooser_entry->current_folder_file = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_file_chooser_entry_dispose (GObject *object)
|
gtk_file_chooser_entry_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (object);
|
GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (object);
|
||||||
|
|
||||||
discard_loading_and_current_folder_file (chooser_entry);
|
set_completion_folder (chooser_entry, NULL);
|
||||||
|
|
||||||
if (chooser_entry->completion_store)
|
|
||||||
{
|
|
||||||
g_object_unref (chooser_entry->completion_store);
|
|
||||||
chooser_entry->completion_store = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (_gtk_file_chooser_entry_parent_class)->dispose (object);
|
G_OBJECT_CLASS (_gtk_file_chooser_entry_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
@ -654,8 +640,6 @@ completion_store_set (GtkFileSystemModel *model,
|
|||||||
static void
|
static void
|
||||||
populate_completion_store (GtkFileChooserEntry *chooser_entry)
|
populate_completion_store (GtkFileChooserEntry *chooser_entry)
|
||||||
{
|
{
|
||||||
discard_completion_store (chooser_entry);
|
|
||||||
|
|
||||||
chooser_entry->completion_store = GTK_TREE_MODEL (
|
chooser_entry->completion_store = GTK_TREE_MODEL (
|
||||||
_gtk_file_system_model_new_for_directory (chooser_entry->current_folder_file,
|
_gtk_file_system_model_new_for_directory (chooser_entry->current_folder_file,
|
||||||
"standard::name,standard::display-name,standard::type",
|
"standard::name,standard::display-name,standard::type",
|
||||||
@ -735,31 +719,36 @@ finished_loading_cb (GtkFileSystemModel *model,
|
|||||||
gtk_entry_completion_insert_prefix (completion);
|
gtk_entry_completion_insert_prefix (completion);
|
||||||
}
|
}
|
||||||
|
|
||||||
static RefreshStatus
|
static void
|
||||||
reload_current_folder (GtkFileChooserEntry *chooser_entry,
|
set_completion_folder (GtkFileChooserEntry *chooser_entry,
|
||||||
GFile *folder_file)
|
GFile *folder_file)
|
||||||
{
|
{
|
||||||
g_assert (folder_file != NULL);
|
if (folder_file &&
|
||||||
|
chooser_entry->local_only
|
||||||
|
&& !g_file_is_native (folder_file))
|
||||||
|
folder_file = NULL;
|
||||||
|
|
||||||
if (chooser_entry->current_folder_file
|
if ((chooser_entry->current_folder_file
|
||||||
&& g_file_equal (folder_file, chooser_entry->current_folder_file))
|
&& folder_file
|
||||||
return REFRESH_OK;
|
&& g_file_equal (folder_file, chooser_entry->current_folder_file))
|
||||||
|
|| chooser_entry->current_folder_file == folder_file)
|
||||||
|
return;
|
||||||
|
|
||||||
if (chooser_entry->current_folder_file)
|
if (chooser_entry->current_folder_file)
|
||||||
{
|
{
|
||||||
discard_loading_and_current_folder_file (chooser_entry);
|
g_object_unref (chooser_entry->current_folder_file);
|
||||||
|
chooser_entry->current_folder_file = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chooser_entry->local_only
|
|
||||||
&& !g_file_is_native (folder_file))
|
|
||||||
return REFRESH_NOT_LOCAL;
|
|
||||||
|
|
||||||
chooser_entry->current_folder_file = g_object_ref (folder_file);
|
|
||||||
chooser_entry->current_folder_loaded = FALSE;
|
chooser_entry->current_folder_loaded = FALSE;
|
||||||
|
|
||||||
populate_completion_store (chooser_entry);
|
discard_completion_store (chooser_entry);
|
||||||
|
|
||||||
return REFRESH_OK;
|
if (folder_file)
|
||||||
|
{
|
||||||
|
chooser_entry->current_folder_file = g_object_ref (folder_file);
|
||||||
|
populate_completion_store (chooser_entry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -815,11 +804,11 @@ refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry)
|
|||||||
|
|
||||||
if (result == REFRESH_OK)
|
if (result == REFRESH_OK)
|
||||||
{
|
{
|
||||||
reload_current_folder (chooser_entry, folder_file);
|
set_completion_folder (chooser_entry, folder_file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
discard_loading_and_current_folder_file (chooser_entry);
|
set_completion_folder (chooser_entry, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (folder_file)
|
if (folder_file)
|
||||||
|
Loading…
Reference in New Issue
Block a user