Async callbacks are delivered in idles, so we need to make sure
we get the gdk lock before calling any gdk/gtk stuff. This was
missing in a few places.
When a file was inserted during the period that the editable row was
active, the node IDs would not get updated correctly.
Signed-off-by: Federico Mena Quintero <federico@novell.com>
The old version wasn't introspectable as it didn't have a length
return parameter. Also, delete gtk_tree_path_get_indices_with_depth,
since it's no longer needed.
The file removal code was not properly clearing the file=>array index
cache, so later lookups into that cache would return invalid array
indexes.
The easiest way to reproduce it is to create a directory with two files
and deleting both of them.
Reported-by: Javier Jardón <jjardon@gnome.org>
We should not unref the model here, it might not even exist anymore.
Instead check if it exists and only use it if it does.
The unref was leftover from a previous fix in
ba9f53397f.
Spotted by Matthias Clasen in
https://bugzilla.gnome.org/show_bug.cgi?id=614099
This commit was created using a script that searched for all docstrings
containing a parameter and the string 'or %NULL'.
Gdk backends and demos excluded as they are not part of a public API
https://bugzilla.gnome.org/show_bug.cgi?id=610474
This allows disposing of the filesystemmodel while the file enumeration
is still happening.
As the filechooser does not disconnect its signals because it assumes it
is the only owner of the model, this also prevents a SEGV when emitting
the "load-finished" signal in that case.
There was some confusion between "index" as used for the model->files[] array,
and node->index as used for our 1-based row numbers. Now we use "index" only
for indices in the model->files[] array, and node->row for row numbers. Functions
and variables are renamed to clarify whether they refer to indexes or rows.
Signed-off-by: Federico Mena Quintero <federico@novell.com>
The non-standard "filechooser::mime-type" was a remnant of the recent-files code using
a hand-built GFileInfo; now we just query the file info ourselves.
Signed-off-by: Federico Mena Quintero <federico@novell.com>
g_array_new() doesn't reserve any size by default, so during the initial population
of the file array, we'll do more reallocs than strictly needed. We'll start with
a reasonable preallocated size, in this case the number of files which we can
get in a single chunk out of GIO.
Signed-off-by: Federico Mena Quintero <federico@novell.com>
There's no point in running a GtkFileSystemModel with invalid column types.
This way we can also avoid clearing the memory of the column_types array.
Signed-off-by: Federico Mena Quintero <federico@novell.com>
The previous function enumerated the whole directory and used a lot of
outdated API to decide how to show files.
The new code queries the filesystem model to decide about this.
The now unused old functions were removed.
Replace the list model code with the file system model and use all the
file system model API niceties we get from that.
Also adds the function _gtk_file_system_model_add_and_query_file() which
g_file_query_info()'s the file before adding it, so it gets added with
the right information.
The new model is mostly API-compatible with the old model (minimal
changes were required), but is a lot faster and has a lot of very
desirable features.
- the model does no longer support a tree, just a list of files in a
given directory
- the storage has been moved to a GArray as opposed to a tree
- no more dependency on GtkFileSystem
- columns are managed by the creator of the model, so any number of
nodes can be added as needed. This also makes the API more similar
to GtkListStore.
- Values are filled on demand using a function given when creating the
model.
- The function can decide to let the model cache returned values or
decide to be called again the next time the value is queried.
- implements GtkTreeSortable
- _gtk_file_system_model_get_value() was added to significantly speed
up value access, which is necessary when sorting large models.