[gtk/wip/baedert/for-master: 121/146] filechooserwidget: Create recent manager when setting operation mode
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/for-master: 121/146] filechooserwidget: Create recent manager when setting operation mode
- Date: Mon, 9 Sep 2019 14:41:53 +0000 (UTC)
commit 95e09b6d6d8d4f07e28ea68fab56879b108f8ec1
Author: Timm Bäder <mail baedert org>
Date: Fri Aug 30 07:37:55 2019 +0200
filechooserwidget: Create recent manager when setting operation mode
Creating a recent manager can be fairly expensive and we won't use it if
the widget is not visible or the recent mode has not been entered. Code
other places can already handle a NULL recent manager, so just create it
when entering the recent mode. And shove 25ms of startup time off the
widget-factory this way.
gtk/gtkfilechooserwidget.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index f2bc4b2b12..b229972dad 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -3150,6 +3150,9 @@ operation_mode_set_recent (GtkFileChooserWidget *impl)
GFile *file;
GtkRevealerTransitionType old_revealer_transition_type;
+ if (!priv->recent_manager)
+ priv->recent_manager = gtk_recent_manager_get_default ();
+
gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_files_stack), "list");
gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_header_stack), "pathbar");
@@ -6812,6 +6815,10 @@ add_selection_to_recent_list (GtkFileChooserWidget *impl)
files = gtk_file_chooser_widget_get_files (GTK_FILE_CHOOSER (impl));
+
+ if (!priv->recent_manager)
+ priv->recent_manager = gtk_recent_manager_get_default ();
+
for (l = files; l; l = l->next)
{
GFile *file = l->data;
@@ -8640,7 +8647,6 @@ gtk_file_chooser_widget_init (GtkFileChooserWidget *impl)
priv->operation_mode = OPERATION_MODE_BROWSE;
priv->sort_column = MODEL_COL_NAME;
priv->sort_order = GTK_SORT_ASCENDING;
- priv->recent_manager = gtk_recent_manager_get_default ();
priv->create_folders = TRUE;
priv->auto_selecting_first_row = FALSE;
priv->renamed_file = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]