Commit Graph

513 Commits

Author SHA1 Message Date
Benjamin Otte
8632d8763d Simplify cleanup code
The patch ensures that the file browse model can only get removed in one
place, so it's easier to clean up.
2009-11-02 20:11:03 +01:00
Tor Lillqvist
6d62e4fafe Fix build on Windows 2009-10-16 13:29:54 +03:00
Federico Mena Quintero
1d283145bf Fix a g_strdup_printf()
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:19 +02:00
Federico Mena Quintero
c39e8af7f4 Put the list of column types in a macro
Every call to _gtk_file_system_model_new*() gets the same list of column types,
so we now keep the list in a macro instead of having duplicated copies all around.

Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:19 +02:00
Federico Mena Quintero
4c242317b0 Clarify the arguments of g_file_query_info_async()
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:19 +02:00
Federico Mena Quintero
2f3367fbf8 Make copy_attribute() a function instead of a macro
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:19 +02:00
Federico Mena Quintero
442484a280 Don't leak a treepath if the treeview is not populated yet
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:18 +02:00
Federico Mena Quintero
35028b9f05 Factor out function to set a fixed size for the icon cell renderers
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:18 +02:00
Federico Mena Quintero
90647c1a13 Comment that the column order needs to be kept in sync across two functions
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:18 +02:00
Federico Mena Quintero
0144521438 Fix typo in a comment
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:18 +02:00
Federico Mena Quintero
6e3a6ba12f Make get_selected_file() return a ref'ed file
The old semantics was to return a GFile* owned by the file system model; the new
semantics is to hand out new references whenever possible.

Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:18 +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
ccee7ef4fb Show an error dialog when we can't read the folder's contents
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-10-15 22:06:15 +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
6bdaaea3a4 Remove unused error argument from show_and_select_files() 2009-10-15 22:01:40 +02:00
Benjamin Otte
682a3c8c75 Enable the size column in recent files/search
Previously information about file sizes was not available for search
results and recent files, so the column was always hidden. As this
information is now available, we can stop the special handling and use
the same setting as in browse mode.
2009-10-15 22:01:40 +02:00
Benjamin Otte
d68bca1771 Use the faster accessor function in the sort functions
Use the faster _gtk_file_system_model_get_value() function instead of
gtk_tree_model_get() inside the sort functions. This gives a significant
speed-up when sorting large lists.
In a test case with 40.000 files, the sorting time went from ~5 seconds
to less than 0.5 seconds for my test case. There is 2 significant
problems with gtk_tree_model_get() that cause this:
1) The value is copied, which takes quite a bit of time for strings.
   ~25% of excessive time or ~1 second in my test
2) The tree model functions need to lookup the interface vfunc. And
   gtk_tree_model_get() doesn't do that only once, but multiple times
   (verifying column id, getting the actual value, ...)
   ~75% of excessive time or ~3 seconds in my test
2009-10-15 22:01:39 +02:00
Benjamin Otte
53a00e3cc3 Convert recent files to a GtkFileSystemModel
This does to the recent files what the last commit did to the search. It
uses a GtkFileSystemModel and its API niceties to show the recent files.
2009-10-15 22:01:39 +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
390a3910f5 Don't count the "enter directory name" line as a selected file 2009-10-15 22:00: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
cd337e2a95 Only query the absolutely necessary attributes
Since the time taken by g_file_enumerate_children() depends a lot on the
attributes that are queried, we query the minimum attributes that need
to be queired to display the file chooser.

In particular, the attributes for loading the icon are ignored, as icons
are loaded on demand (see previous commit).
2009-10-15 22:00:08 +02:00
Benjamin Otte
4a1ff32325 Load icons on-demand
Because loading icons takes a noticable performance, this code loads the
pixbuf on demand and only loads icons for rows that are visible. There
is a few caveats to this:
- The pixbuf cell renderer must report the proer size even if the icon
  is not yet loaded. This is achieved by setting a fixed size.
- On theme changes the cahced pixbufs and the cell renderer must be
  updated to conform to the new theme.
2009-10-15 22:00:08 +02:00
Benjamin Otte
105e6fbc11 Use the GtkTreeSortable of the filesystem model
Previously, there was a GtkTreeSortModel wrapped around the filesystem
model to make it sortable. As the new implementation implements the
GtkTreeSortable interface, we can use this instead.
2009-10-15 22:00:08 +02:00
Benjamin Otte
3e385ffd07 Clean up code to use the model directly
A lot of code special cases accesses to the tree view for the different
browse modes, which was previously necessary, because the models were
different. Now that they are identical in the first columns, there is no
such need anymore, and the functions don't need to be special cased.
2009-10-15 22:00:08 +02:00
Benjamin Otte
30c1a1ee2c Replace the cell data computations
Previously custom functions were used to compute the data passed to the
cell renderers. Now that all this data is saved by the tree models with
compatible nodes, the usual default attribute-to-column mapping can be
used.
With this, caching of the values can happen in the tree model, which
avoids costly lookups of icons or computation of strings. Last but not
least it avoids spurious bugs that could happen when strings changed
without anyone noticing, like the mtime when a new day begins.
2009-10-15 22:00:08 +02:00
Benjamin Otte
a5390ad49e Consolidate tree models for different browse modes
All tree models in browse mode now share the first 10 column types
containing all the necessary information to display the model on screen.
Therefor it is now easy to just operate on the tree model associated
with the file tree view and in most cases it isn't necessary anymore to
special case the browse modes.
2009-10-15 22:00:07 +02:00
Benjamin Otte
d6f3d0e7eb Simplify gtk_file_chooser_default_unselect_file() 2009-10-15 22:00:07 +02:00
Benjamin Otte
0ccb2f2427 Creating the model no longer fails
So remove the code that checked for failure, as it's not needed anymore.
2009-10-15 22:00:07 +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
Christian Persch
a2420c7db5 Plug a mem leak
The filechooser was leaking tooltips. Reported in bug bug 593080.
2009-08-29 20:40:50 -04:00
Pascal Terjan
f8171ce092 Update tooltip if no removable one is selected 2009-08-06 23:28:49 +02:00
Pascal Terjan
a4514f993e Allow disabling New Folder button in File Choser
Bug #570516. Add a new property "create-folders" meaning that the
"New Folder" button should be displayed in the modes where it used
to be.
2009-07-30 16:58:42 +02:00
Emmanuele Bassi
2d79405118 Bug #514260 – Better filtering for "Recently Used" files
Instead of refiltering the recently used files we should rebuild
the list altogether when the current GtkFileFilter changes; this
allows us to keep showing the maximum amount of recently used
files.

Fixes bug:

  http://bugzilla.gnome.org/show_bug.cgi?id=514260
2009-07-30 11:16:29 +01:00
Federico Mena Quintero
d55ff39ad0 bgo#161489 - In the file chooser, let the left/right arrow keys switch focus between the file list and shortcuts
Based on a patch by Christian Neumair <cneumair@gnome.org>

Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-07-27 19:24:42 -05:00
Federico Mena Quintero
b50548e350 From the shortcuts pane, focus the GtkEntry and redirect unhandled keystrokes to it
This lets us do this:

1. click on a folder in the shortcuts pane
2. start typing a filename

Then, the typed filename will actually go to the filename entry, like
the user expects.  (Or to the search entry, in case the user clicked
on the Search shortcut.)

Also, removed the obsolete callback that made "/" and "~" typed in the
shortcuts pane bring up the location entry.

Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-07-27 19:12:41 -05:00
Federico Mena Quintero
0f5f7539f3 bgo#534462: Disable interactive search in the file chooser's shortcuts pane
People often do this:
1. Bring up a SAVE dialog
2. Click on a folder in the shortcuts pane
3. Start typing a filename
4. Oops!  The interactive-search entry in the shortcuts pane appears.

With this, the shortcuts pane will not bring up the interactive-search entry.  Then it
will be clear that you are not typing in the right place.

Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-07-27 19:12:41 -05:00
Xan Lopez
3484246dc3 g_strdup_print does not exist, the function is g_strdup_printf. 2009-07-20 09:58:22 +03:00
Matthias Clasen
267d209441 Remove markup from translatable strings
Pointed out in bug 588964. String change !
2009-07-20 01:10:52 -04:00
Matthias Clasen
143b55c3cb Add a tooltip to the save folder combo
Add a tooltip that shows the full path of the current folder, to avoid
ambiguity. We only show the tooltip when the expander is collapsed to
avoid cluttering the full file chooser.
2009-07-15 19:17:36 -04:00
Benjamin Otte
271a635a2f make the size column resizable 2009-06-27 11:33:23 +02:00
Benjamin Otte
02ac8ea3af make sure the "Create folder" button doesn't get shown accidentally
Switching to search or recent files mode and back to browse mode made
the button visible previously
2009-06-27 11:32:57 +02:00
Benjamin Otte
655e0d8ddc unconditionally set right alignment for the size column 2009-06-27 11:29:36 +02:00
Matthias Clasen
823151ba8c Fix 'Add to bookmarks' initial sensitivity
Make sure that we always call bookmarks_check_add_sensitivity() at
least once before popping up a newly created menu. Fixes bug 585858.
2009-06-21 23:30:27 -04:00
Federico Mena Quintero
68171b506f Show the size column by default in the file chooser
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-06-18 19:48:38 -05:00
Federico Mena Quintero
3c75004474 Don't set the sort column when there is no model
We can't set the sort column when we load the GtkFileChooser's settings, as the
file models may not have been created yet.  Wait until the models are actually
present; then we can set the sort column.

Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-06-17 20:33:57 -05:00
Matthias Clasen
d51132e584 Don't use deprecated api internally 2009-06-16 11:27:06 -04:00
Benjamin Gramlich
1d4cba6876 bgo#484922 - Remember the sort column and order in the file chooser
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-06-12 17:31:28 -05:00
Benjamin Gramlich
69a0611391 Add load/save functions for the sort column order in GtkFileChooserSettings
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-06-12 16:40:25 -05:00