[gtk+/gtk-2-24] Freeze file system model during editing



commit c7e3531f7a22599e9ca38e3ea70a9c08428f7602
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Wed Nov 19 14:43:10 2014 +0000

    Freeze file system model during editing
    
    If a file system event arrives while GtkFileChooserWidget is asking the
    user to edit the name of a newly created folder, the file system model
    will drop the row with the editable cell, and the user will have to
    start from scratch.
    
    This makes creating new directories impossible inside a directory with a
    file currently being downloaded, for instance, and it's really unhelpful
    to the user because the editable row simply disappears.
    
    We already have a mechanism in place to freeze the file system model, so
    we can reuse it between the add_editable() and the remove_editable()
    calls.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=729927
    
    Conflicts:
        gtk/gtkfilesystemmodel.c

 gtk/gtkfilesystemmodel.c |   81 +++++++++++++++++++++++++---------------------
 1 files changed, 44 insertions(+), 37 deletions(-)
---
diff --git a/gtk/gtkfilesystemmodel.c b/gtk/gtkfilesystemmodel.c
index 88d7eae..307eec8 100644
--- a/gtk/gtkfilesystemmodel.c
+++ b/gtk/gtkfilesystemmodel.c
@@ -1995,43 +1995,6 @@ _gtk_file_system_model_set_filter (GtkFileSystemModel      *model,
 }
 
 /**
- * _gtk_file_system_model_add_editable:
- * @model: a #GtkFileSystemModel
- * @iter: Location to return the iter corresponding to the editable row
- * 
- * Adds an "empty" row at the beginning of the model.  This does not refer to
- * any file, but is a temporary placeholder for a file name that the user will
- * type when a corresponding cell is made editable.  When your code is done
- * using this temporary row, call _gtk_file_system_model_remove_editable().
- **/
-void
-_gtk_file_system_model_add_editable (GtkFileSystemModel *model, GtkTreeIter *iter)
-{
-  g_return_if_fail (GTK_IS_FILE_SYSTEM_MODEL (model));
-  g_return_if_fail (!get_node (model, 0)->visible);
-
-  node_set_visible_and_filtered_out (model, 0, TRUE, FALSE);
-  ITER_INIT_FROM_INDEX (model, iter, 0);
-}
-
-/**
- * _gtk_file_system_model_remove_editable:
- * @model: a #GtkFileSystemModel
- * 
- * Removes the "empty" row at the beginning of the model that was
- * created with _gtk_file_system_model_add_editable().  You should call
- * this function when your code is finished editing this temporary row.
- **/
-void
-_gtk_file_system_model_remove_editable (GtkFileSystemModel *model)
-{
-  g_return_if_fail (GTK_IS_FILE_SYSTEM_MODEL (model));
-  g_return_if_fail (get_node (model, 0)->visible);
-
-  node_set_visible_and_filtered_out (model, 0, FALSE, FALSE);
-}
-
-/**
  * freeze_updates:
  * @model: a #GtkFileSystemModel
  *
@@ -2168,3 +2131,47 @@ _gtk_file_system_model_add_and_query_file (GtkFileSystemModel *model,
                            gtk_file_system_model_query_done,
                            model);
 }
+
+/**
+ * _gtk_file_system_model_add_editable:
+ * @model: a #GtkFileSystemModel
+ * @iter: Location to return the iter corresponding to the editable row
+ * 
+ * Adds an “empty” row at the beginning of the model.  This does not refer to
+ * any file, but is a temporary placeholder for a file name that the user will
+ * type when a corresponding cell is made editable.  When your code is done
+ * using this temporary row, call _gtk_file_system_model_remove_editable().
+ **/
+void
+_gtk_file_system_model_add_editable (GtkFileSystemModel *model, GtkTreeIter *iter)
+{
+  g_return_if_fail (GTK_IS_FILE_SYSTEM_MODEL (model));
+  g_return_if_fail (!get_node (model, 0)->visible);
+
+  node_set_visible_and_filtered_out (model, 0, TRUE, FALSE);
+  ITER_INIT_FROM_INDEX (model, iter, 0);
+
+  /* we don't want file system changes to affect the model while
+   * editing is in place
+   */
+  freeze_updates (model);
+}
+
+/**
+ * _gtk_file_system_model_remove_editable:
+ * @model: a #GtkFileSystemModel
+ * 
+ * Removes the “empty” row at the beginning of the model that was
+ * created with _gtk_file_system_model_add_editable().  You should call
+ * this function when your code is finished editing this temporary row.
+ **/
+void
+_gtk_file_system_model_remove_editable (GtkFileSystemModel *model)
+{
+  g_return_if_fail (GTK_IS_FILE_SYSTEM_MODEL (model));
+  g_return_if_fail (get_node (model, 0)->visible);
+
+  thaw_updates (model);
+
+  node_set_visible_and_filtered_out (model, 0, FALSE, FALSE);
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]