Commit Graph

524 Commits

Author SHA1 Message Date
Christian Dywan
d21bf0c1ec Remove deprecated GtkFileChooser functions 2010-05-03 01:40:41 +02:00
Tomas Bzatek
faf0beede0 FileChooser: Initialize search engines on demand
We postpone initialization of the search engines until
it's really needed. See bug 614971 for reference.
2010-04-07 15:07:05 +02:00
Cody Russell
b6d9bb6e1e Fix for bug #557689 and bug #402349, where opening a file chooser in
folder browse mode would require the user to click on something
before clicking "Open".
2010-04-05 12:57:33 -05:00
Matthias Clasen
bf88eee131 Fix file chooser refcounting issues
This was reported in bug 600992.
2010-03-08 23:56:43 -05:00
Javier Jardón
16a59ad912 Deprecate widget flag: GTK_WIDGET_REALIZED
Use gtk_widget_get_realized() instead

https://bugzilla.gnome.org/show_bug.cgi?id=69872
2010-03-03 20:41:05 +01:00
Javier Jardón
1fe7d3cefd Deprecate widget flag: GTK_WIDGET_MAPPED
Use gtk_widget_get_mapped() instead.

https://bugzilla.gnome.org/show_bug.cgi?id=69872
2010-03-03 20:19:03 +01:00
Javier Jardón
e8e95d4c5e Don't use GTK_WIDGET_*SET_FLAGS (wid, GTK_CAN_DEFAULT)
Use new API instead: gtk_widget_set_can_default ()
2010-03-02 07:58:05 +01:00
Javier Jardón
214a023e91 Deprecate widget flag: GTK_WIDGET_VISIBLE
Use gtk_widget_get_visible() instead

https://bugzilla.gnome.org/show_bug.cgi?id=69872
2010-03-01 07:52:07 +01:00
Javier Jardón
4232115e22 Deprecate widget flag: GTK_WIDGET_HAS_FOCUS
Use gtk_widget_has_focus() instead

https://bugzilla.gnome.org/show_bug.cgi?id=69872
2010-03-01 06:11:01 +01:00
Javier Jardón
64f526d34e Deprecate widget flag: GTK_WIDGET_SENSITIVE
Use gtk_widget_get_sensitive() instead

https://bugzilla.gnome.org/show_bug.cgi?id=69872
2010-03-01 05:59:23 +01:00
Christian Dywan
bb1824c131 Deprecate flag macros for toplevel, state, no window and composite child
Deprecate widget flag macros GTK_WIDGET_STATE, GTK_WIDGET_SAVED_STATE,
GTK_WIDGET_FLAGS, GTK_WIDGET_TOPLEVEL, GTK_WIDGET_NO_WINDOW and
GTK_WIDGET_COMPOSITE_CHILD.

Also deprecate the type macros GTK_WIDGET_TYPE, GTK_OBJECT_TYPE_NAME and
GTK_OBJECT_TYPE which have become redundant.

Instances of GTK_WIDGET_TOPLEVEL are replaced with gtk_widget_is_toplevel,
GTK_WIDGET_TYPE is replaced with G_OBJECT_TYPE, GTK_WIDGET_COMPOSITE_CHILD
is replaced with use of the "composite-child" property and uses of
GTK_WIDGET_NO_WINDOW are adjusted to use gtk_widget_get_has_window.

Uses of GTK_WIDGET_SAVED_STATE and GTK_WIDGET_FLAGS inside GtkWidget are
changed to direct flag usage.

Documentation is updated to refer to gtk_widget_set_has_window and
gtk_widget_get_has_window.

Gail and tests are updated as well.

Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=69872
2010-01-04 07:57:05 +01:00
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