Commit Graph

108 Commits

Author SHA1 Message Date
Javier Jardón
0a07e9733b gtk/: fully remove gtkalias hacks
https://bugzilla.gnome.org/show_bug.cgi?id=623845
2010-07-10 02:51:26 +02:00
Colin Walters
905f988166 Revert "Add length to gtk_tree_path_get_indices"
This reverts commit eebb16eb1a.

Was an accidental commit.
2010-06-28 14:15:10 -04:00
Colin Walters
eebb16eb1a Add length to gtk_tree_path_get_indices
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.
2010-06-28 13:50:36 -04:00
Benjamin Otte
42abeadbb8 Can't select file on file browser after changing sort order
The row values are 1-indexed not 0-indexed, this has to be taken into
account when producing the new_order array.

https://bugzilla.gnome.org/show_bug.cgi?id=621414
2010-06-28 14:19:18 +02:00
Benjamin Otte
b08a6750dc filechooser: Fix a crash when removing files
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>
2010-05-02 14:34:43 +02:00
Benjamin Otte
9514e741cd Fix error case in filesystem model
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
2010-03-29 16:29:20 +02:00
Johan Dahlin
fe85272112 [annotations] Add allow-none
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
2010-02-19 17:57:51 -02:00
Benjamin Otte
ba9f53397f Don't keep the filesystem model alive while querying files
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.
2009-11-02 20:11:09 +01:00
Federico Mena Quintero
f0e2d7d88b Fix thinkos in which fields get used
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:20 +02:00
Federico Mena Quintero
02d96465f4 Oops, it's gsize, not GSize
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:19 +02:00
Federico Mena Quintero
7e9fbd16e4 In set_filter(), handle the case where the new filter is the same as the old filter
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:17 +02:00
Federico Mena Quintero
fb1a72fcb0 s/get_is_visible/iter_is_visible for clarity
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:17 +02:00
Federico Mena Quintero
9efa64fba5 Remove obsolete comment
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:17 +02:00
Federico Mena Quintero
55a04b1da0 Make the code match the docs in _gtk_file_system_model_clear_cache()
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:17 +02:00
Federico Mena Quintero
112d2430be Free some missing fields in ::finalize()
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:17 +02:00
Federico Mena Quintero
5ea265ca61 Clarify variable names in gtk_file_system_model_sort()
To comply with the i -> indexes; r -> rows convention.

Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:17 +02:00
Federico Mena Quintero
7ecc87ed59 Nothing to do for ref/unref_node
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:17 +02:00
Federico Mena Quintero
8bf24cdd9d Clarify a couple of spots with comments
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:16 +02:00
Federico Mena Quintero
14cc3e17f5 Clarify array indexes vs. row numbers
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>
2009-10-15 22:06:16 +02:00
Federico Mena Quintero
d0468ee7e1 Big comment on how GtkFileSystemModel works
Let's have some documentation on the idea behind this beast...

Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:16 +02:00
Federico Mena Quintero
04c78019fb Remove obsolete code to use a cached mime-type
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>
2009-10-15 22:06:16 +02:00
Federico Mena Quintero
6166fccf30 Fix thinko in node_should_be_visible()
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:16 +02:00
Federico Mena Quintero
908911d6db Factory out functions to emit row_inserted, row_changed, row_deleted
This is to avoid temporary variables for the path/iter and to avoid duplicated code.

Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:16 +02:00
Federico Mena Quintero
ad2e6ff52c When updating a file, handle the case where the old file info is the same as the new one
This prevents us from inadvertently losing the last ref to the info.

Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:16 +02:00
Federico Mena Quintero
688917cdbb When removing a file, also remove it from the file_lookup hash table
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:15 +02:00
Federico Mena Quintero
385fa71ec0 Comment on how the file_lookup hash table gets rebuilt on demand
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:15 +02:00
Federico Mena Quintero
6820dee988 Clarify the arguments to g_file_query_info_async()
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:15 +02:00
Federico Mena Quintero
3b86973075 Clarify the code flow in gtk_file_system_model_got_files()
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:15 +02:00
Federico Mena Quintero
3f7c144605 Remove the dir_thaw_source while disposing the model
Otherwise that timeout may trigger after the model has died.

Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:15 +02:00
Federico Mena Quintero
30016185be Make _gtk_file_system_model_remove_file() static
It was only used internally by the model.

Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:14 +02:00
Federico Mena Quintero
2e0382cf02 Make _gtk_file_system_model_add_file() static
It was only used internally by the model, anyway.

Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:14 +02:00
Federico Mena Quintero
93588c6d5c Clarify the comments that some fields in GtkFileSystemModel can be NULL
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:14 +02:00
Federico Mena Quintero
88bb9342ab Clarify the arguments to g_file_monitor_directory()
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:14 +02:00
Federico Mena Quintero
d2d997a021 Clarify an argument to g_file_enumerate_children_async()
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:14 +02:00
Federico Mena Quintero
d5d9601852 Fix and tighten an assertion
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:14 +02:00
Federico Mena Quintero
86c32c2502 Complete the documentation string for _gtk_file_system_model_new()
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:14 +02:00
Federico Mena Quintero
3232c469fc Start with a file array with a resonable preallocated size
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>
2009-10-15 22:06:13 +02:00
Federico Mena Quintero
5110415684 Compute the node size only once to avoid the scary macro
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:13 +02:00
Federico Mena Quintero
dfe20ea1a8 g_error() as soon as we catch an invalid column type
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>
2009-10-15 22:06:13 +02:00
Benjamin Otte
836c3ab043 Improve show_and_select_files() function
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.
2009-10-15 22:01:40 +02:00
Benjamin Otte
5a31dfd66b Convert search to use a GtkFileSystemModel
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.
2009-10-15 22:01:09 +02:00
Benjamin Otte
affa8c8459 Add a constructor to filesystem model that does not monitor a directory
This is in preparation for switching search and recent models to use
GtkFileSystemModel
2009-10-15 22:00:09 +02:00
Benjamin Otte
10e8d6abca Make the filesystem model filter API use a GtkFileFilter
This gets rid of the vfunc API and does exactly what the file chooser
wants.
2009-10-15 22:00:09 +02:00
Benjamin Otte
18b56b9970 Implement new GtkFileSystemModel
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.
2009-10-15 22:00:06 +02:00
Benjamin Otte
3c9a34dba3 move GtkFileSystemModel private stuff out of the private header 2009-10-15 22:00:06 +02:00
Milan Bouchet-Valat
a27e748586 bgo#355851 - Hide backup files in the file chooser
Backup files are hidden along with dotfiles, just like Nautilus.

Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-06-11 19:58:51 -05:00
Matthias Clasen
50329fa7c0 Privately export this method. It classifies directories and mountables the
* gtk/gtkfilesystem.[hc] (_gtk_file_info_consider_as_directory):
        Privately export this method. It classifies directories and mountables
        the same.

        * gtk/gtkfilesystem.c (enclosing_volume_mount_cb): Silently drop
        G_IO_ERROR_ALREADY_MOUNTED error for gvfs backends without visible
        mounts.

        * gtk/gtkfilesystemmodel.c:
        * gtk/gtkfilechooserbutton.c:
        * gtk/gtkfilechooserentry.c:
        * gtk/gtkfilechooserdefault.c: Use the new function instead of
        direct checks for G_FILE_TYPE_DIRECTORY throughout.


svn path=/trunk/; revision=21898
2008-12-14 02:14:19 +00:00
Christian Persch
ae2bf7863c Bug 554704 – gtkfilesystemmodel does too much work
svn path=/trunk/; revision=21572
2008-10-02 19:48:02 +00:00
Christian Persch
ab8c161601 Bug 554696 – invalid free function used
svn path=/trunk/; revision=21569
2008-10-02 19:47:45 +00:00
Christian Persch
87d51e0ab4 Bug 554691 – mem leak in filechooser
svn path=/trunk/; revision=21568
2008-10-02 19:47:40 +00:00