/* OPERATION_MODE_RECENT */
GtkRecentManager *recent_manager;
GtkFileSystemModel *recent_model;
- guint load_recent_id;
GtkWidget *extra_and_filters;
GtkWidget *filter_combo_hbox;
static gboolean recent_files_setting_is_enabled (GtkFileChooserWidget *impl);
static void recent_start_loading (GtkFileChooserWidget *impl);
-static void recent_stop_loading (GtkFileChooserWidget *impl);
static void recent_clear_model (GtkFileChooserWidget *impl,
gboolean remove_from_treeview);
static gboolean recent_should_respond (GtkFileChooserWidget *impl);
gtk_revealer_set_reveal_child (GTK_REVEALER (priv->browse_header_revealer), FALSE);
location_bar_update (impl);
stop_loading_and_clear_list_model (impl, TRUE);
- recent_stop_loading (impl);
search_stop_searching (impl, TRUE);
recent_clear_model (impl, TRUE);
search_clear_model (impl, TRUE);
g_clear_pointer (&priv->file_exists_get_info_cancellable, g_cancellable_cancel);
search_stop_searching (impl, TRUE);
- recent_stop_loading (impl);
}
/* Removes the settings signal handler. It's safe to call multiple times */
return;
stop_loading_and_clear_list_model (impl, TRUE);
- recent_stop_loading (impl);
recent_clear_model (impl, TRUE);
search_stop_searching (impl, FALSE);
g_set_object (&priv->recent_model, NULL);
}
-/* Stops any ongoing loading of the recent files list; does
- * not touch the recent_model
- */
-static void
-recent_stop_loading (GtkFileChooserWidget *impl)
-{
- GtkFileChooserWidgetPrivate *priv = gtk_file_chooser_widget_get_instance_private (impl);
-
- if (priv->load_recent_id)
- {
- g_source_remove (priv->load_recent_id);
- priv->load_recent_id = 0;
- }
-}
-
static void
recent_setup_model (GtkFileChooserWidget *impl)
{
GTK_SORT_DESCENDING);
}
-typedef struct
-{
- GtkFileChooserWidget *impl;
- GList *items;
-} RecentLoadData;
-
-static void
-recent_idle_cleanup (gpointer data)
-{
- RecentLoadData *load_data = data;
- GtkFileChooserWidget *impl = load_data->impl;
- GtkFileChooserWidgetPrivate *priv = gtk_file_chooser_widget_get_instance_private (impl);
-
- gtk_tree_view_set_model (GTK_TREE_VIEW (priv->browse_files_tree_view),
- GTK_TREE_MODEL (priv->recent_model));
- gtk_tree_view_set_search_column (GTK_TREE_VIEW (priv->browse_files_tree_view), -1);
-
- gtk_tree_view_column_set_sort_column_id (priv->list_name_column, -1);
- gtk_tree_view_column_set_sort_column_id (priv->list_time_column, -1);
- gtk_tree_view_column_set_sort_column_id (priv->list_size_column, -1);
- gtk_tree_view_column_set_sort_column_id (priv->list_type_column, -1);
- gtk_tree_view_column_set_sort_column_id (priv->list_location_column, -1);
-
- update_columns (impl, TRUE, _("Accessed"));
-
- set_busy_cursor (impl, FALSE);
-
- priv->load_recent_id = 0;
-
- g_free (load_data);
-}
-
static gboolean
recent_item_is_private (GtkRecentInfo *info)
{
g_list_free_full (folders, g_object_unref);
}
-static gboolean
-recent_idle_load (gpointer data)
+static void
+recent_start_loading (GtkFileChooserWidget *impl)
{
- RecentLoadData *load_data = data;
- GtkFileChooserWidget *impl = load_data->impl;
GtkFileChooserWidgetPrivate *priv = gtk_file_chooser_widget_get_instance_private (impl);
+ GList *items;
+
+ recent_clear_model (impl, TRUE);
+ recent_setup_model (impl);
if (!priv->recent_manager)
- return FALSE;
+ return;
- load_data->items = gtk_recent_manager_get_items (priv->recent_manager);
- if (!load_data->items)
- return FALSE;
+ items = gtk_recent_manager_get_items (priv->recent_manager);
+ if (!items)
+ return;
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN)
- populate_model_with_recent_items (impl, load_data->items);
+ populate_model_with_recent_items (impl, items);
else
- populate_model_with_folders (impl, load_data->items);
-
- g_list_free_full (load_data->items, (GDestroyNotify) gtk_recent_info_unref);
- load_data->items = NULL;
+ populate_model_with_folders (impl, items);
- return FALSE;
-}
+ g_list_free_full (items, (GDestroyNotify) gtk_recent_info_unref);
-static void
-recent_start_loading (GtkFileChooserWidget *impl)
-{
- GtkFileChooserWidgetPrivate *priv = gtk_file_chooser_widget_get_instance_private (impl);
- RecentLoadData *load_data;
-
- recent_stop_loading (impl);
- recent_clear_model (impl, TRUE);
- recent_setup_model (impl);
- set_busy_cursor (impl, TRUE);
-
- g_assert (priv->load_recent_id == 0);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (priv->browse_files_tree_view),
+ GTK_TREE_MODEL (priv->recent_model));
+ gtk_tree_view_set_search_column (GTK_TREE_VIEW (priv->browse_files_tree_view), -1);
- load_data = g_new (RecentLoadData, 1);
- load_data->impl = impl;
- load_data->items = NULL;
+ gtk_tree_view_column_set_sort_column_id (priv->list_name_column, -1);
+ gtk_tree_view_column_set_sort_column_id (priv->list_time_column, -1);
+ gtk_tree_view_column_set_sort_column_id (priv->list_size_column, -1);
+ gtk_tree_view_column_set_sort_column_id (priv->list_type_column, -1);
+ gtk_tree_view_column_set_sort_column_id (priv->list_location_column, -1);
- /* begin lazy loading the recent files into the model */
- priv->load_recent_id = g_idle_add_full (G_PRIORITY_DEFAULT,
- recent_idle_load,
- load_data,
- recent_idle_cleanup);
- g_source_set_name_by_id (priv->load_recent_id, "[gtk] recent_idle_load");
+ update_columns (impl, TRUE, _("Accessed"));
}
/* Called from ::should_respond(). We return whether there are selected