Call gtk_tree_view_set_cursor() in addition to
gtk_tree_selection_select_iter() when selecting the file in
show_and_select_files() so the preview update machinery gets
triggered.
(cherry picked from commit 795c8070db)
If you type 'subfolder/' and hit Enter, the file chooser will switch you to
it. But if you type just 'subfolder' without the trailing slash, apps would
receive *that* filename (e.g. file:///foo/bar/subfolder) as the response, and
they would likely print an error that they can't open that file (as it is
a folder). So, we change the file chooser's current folder to that subfolder
in this case.
Signed-off-by: Federico Mena Quintero <federico@novell.com>
Previously name_entry_get_parent_info_cb() would fail as it doesn't handle SELECT_FOLDER.
Now we just make that function act the same as for CREATE_FOLDER mode. In either
case, if you type "/blah/nonexistent" and hit Enter, you want a folder
with that name to be created (under the already-existing /blah).
Signed-off-by: Federico Mena Quintero <federico@novell.com>
The old save_entry_get_info_cb() was misnamed; it is actually used
to see if a file's presumed parent *is* a folder. So we rename
it to name_entry_get_parent_info_cb().
Signed-off-by: Federico Mena Quintero <federico@novell.com>
file_exists_get_info_cb() used to let some actions fall through to
the code that checks for the file type of the selected file's parent
(e.g. to see if /foo/bar *is* indeed a folder if you type /foo/bar/baz).
However, we need to be more explicit for each file chooser action, as
in SELECT_FOLDER mode typing /foo/foldername and hitting Enter would not
give you an immediate selection, but rather the file chooser would
complain that it couldn't create that directory as it already exists.
Signed-off-by: Federico Mena Quintero <federico@novell.com>
It doesn't make sense to keep them separate as GtkSizeRequest requires a
GtkWidget and GtkWidget implements GtkSizeRequest, so you can never have
one without the other.
It also makes the code a lot easier because no casts are required when
calling functions.
Also, the names would translate to gtk_widget_get_width() and people
agreed that this would be a too generic name, so a "preferred" was added
to the names.
So this patch moves the functions:
gtk_size_request_get_request_mode() => gtk_widget_get_request_mode()
gtk_size_request_get_width() => gtk_widget_get_preferred_width()
gtk_size_request_get_height() => gtk_widget_get_preferred_height()
gtk_size_request_get_size() => gtk_widget_get_preferred_size()
gtk_size_request_get_width_for_height() =>
gtk_widget_get_preferred_width_for_height()
gtk_size_request_get_height_for_width() =>
gtk_widget_get_preferred_height_for_width()
... and moves the corresponding vfuncs to the GtkWidgetClass.
The patch also renames the implementations of the vfuncs in widgets to
include the word "preferrred".
Since the location button is hidden in save mode, we need to add the
path bar to the size group too. The location button still has to be in
the group though, because it's larger than the path bar (when
shown). Instead of using the recent/search icons, add their hboxes so
that themed widget spacings don't introduce variations.
The keysyms create a lot of potential namespace conflicts for
C, and are especially problematic for introspection, where we take
constants into the namespace, so GDK_Display conflicts with GdkDisplay.
For C application compatiblity, add gdkkeysyms-compat.h which uses
the old names.
Just one user in GTK+ continues to use gdkkeysyms-compat.h, which is
the gtkimcontextsimple.c, since porting that requires porting more
custom Perl code.
gtk_window_get_group() never returns NULL; if the window isn't in a group,
a default window group is returned instead. Use gtk_window_has_group() instead.
This fixes some previous commits to use accessors to access GtkWindow.
Reported by Philip Withnall in bug
https://bugzilla.gnome.org/show_bug.cgi?id=627828
Long ago, before we had file monitoring at the GIO/Glib level, we would
reload the current folder each time a file chooser gets (re)mapped.
This was basically to let the GIMP recycle the same file chooser for all
file/open or file/save operations, instead of creating a new one every time.
In that case, we reloaded the folder with each ::map() event so that the
file chooser would present an up-to-date view of the folder that was being
displayed. Now, the folder should always be up-to-date as we do
file monitoring all the time.
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.
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
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>
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>
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.
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.
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
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.
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).
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.
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.
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.
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.
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.
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.
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
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>
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>
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.
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>
The previous patch for this bug was about the initial *file* not existing,
but this also handles the initial *folder* not existing
(such as /usr/nonexistent/nonexistent.txt).
Signed-off-by: Federico Mena Quintero <federico@novell.com>
We now use a GtkSizeGroup to control the vertical size of the various widgets
that get put in the path bar's area: the location bar, the search entry,
the recently-used title label.
This keeps the shortcuts pane and the file list from jumping up and down
when one switches between operation modes (browse/search/recently-used).
Signed-off-by: Federico Mena Quintero <federico@novell.com>
Ellipsize labels in the Save folder's combo so they don't grow too wide.
Ellipsize labels in normal directory buttons in the pathbar, and make
their requisition's width reasonably small. Use a tooltip for buttons
that got ellipsized.
Instead of placing the down-slider directly beside the last button in
the pathbar, use the remaining space in the pathbar for the last
button. Use a different method to find the first visible button.
Walk down from the end, adding buttons until we use all free space.
Signed-off-by: Federico Mena Quintero <federico@novell.com>
Dup the file chooser entry string because the string may be modified
depending on what clients do in the confirm-overwrite signal and this
corrupts the pointer.
* gtk/gtkfilechooserdefault.c (shortcuts_list_create): Never scroll
the places horizontally. Instead, ellipsize the text.
svn path=/trunk/; revision=22397
2009-01-21 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (save_widgets_create): Set
local_only on the location entry when we create it...
(set_local_only): ... and set it here only if the location entry
exists.
Signed-off-by: Federico Mena Quintero <federico@novell.com>
svn path=/trunk/; revision=22163
Patch by Carlos Garnacho <carlos@imendio.com> - add a local_only
property to GtkFileChooserEntry:
* gtk/gtkfilechooserentry.c (struct _GtkFileChooserEntry): Add a
local_only field.
(_gtk_file_chooser_entry_init): Default to local_only being true.
(start_explicit_completion): Don't allow completion of non-native
files if local_only is turned on.
(start_loading_current_folder): Don't start loading non-native
folders if local_only is turned on.
(_gtk_file_chooser_entry_set_local_only): New function.
(_gtk_file_chooser_entry_get_local_only): New function.
* gtk/gtkfilechooserentry.h (_gtk_file_chooser_entry_set_local_only,
_gtk_file_chooser_entry_get_local_only): New prototypes.
* gtk/gtkfilechooserdefault.c (set_local_only): Set the local_only
property on the entry.
Signed-off-by: Federico Mena Quintero <federico@novell.com>
svn path=/trunk/; revision=22156
* gtk/gtkfilechooserdefault.c (save_dialog_geometry): New function.
(settings_save): Save the dialog's geometry.
(gtk_file_chooser_default_get_default_size): Load the geometry
from the settings. If it was already saved, return that instead
of computing an ad-hoc size.
Signed-off-by: Federico Mena Quintero <federico@novell.com>
svn path=/trunk/; revision=22119
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_map):
Don't change the default size in ::map() so we don't flicker...
(gtk_file_chooser_default_realize): ... so do it in ::realize()
instead, when the window is not yet visible. This avoids a
dialog-that-resizes when you first pop up the file chooser.
(emit_default_size_changed): Just emit the signal; don't check for
the widget's state so we can be emitted during the initial
::realize() when we are not mapped yet.
(update_preview_widget_visibility): Only emit default_size_changed
if the widget is not mapped, to avoid resizing the dialog while it
is visible.
Signed-off-by: Federico Mena Quintero <federico@novell.com>
svn path=/trunk/; revision=22117
* gtk/gtkfilechooserdefault.c (update_current_folder_get_info_cb):
Mount the enclosing volume if the folder we're switching to is not
mounted. Patch by Tomas Bzatek, based on work by Carlos Garnacho
svn path=/trunk/; revision=21899
* 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
* gtk/gtkfilechooserdefault.c (update_current_folder_get_info_cb):
Don't show an error dialog when changing to a non-existing folder,
since this is ususally just an annoyance.
svn path=/trunk/; revision=21894
2008-09-26 Matthias Clasen <mclasen@redhat.com>
Bug 553133 – GtkFileChooser won't ask to mount a volume
* gtk/gtkfilechooserdefault.c (shortcuts_activate_volume): Use
a GtkMountOperation when mounting, so that we get a password
dialog when required.
svn path=/trunk/; revision=21523
2008-09-25 Michael Natterer <mitch@imendio.com>
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_finalize):
don't unref the file system backend, the newly added
unset_file_system_backend() already does this (bug #553135).
svn path=/trunk/; revision=21514
2008-09-22 Matthias Clasen <mclasen@redhat.com>
Bug 553135 – eog crash: assertion failed. Gtk error:
shortcuts_remove_rows: code should not be reached
* gtk/gtkfilechooserdefault.c: Disconnect from GtkFileSystem
signals when we are destroyed, in order to avoid nasty surprises.
Patch by Claudio Saavedra
svn path=/trunk/; revision=21492
2008-09-22 Emmanuele Bassi <ebassi@linux.intel.com>
Bug 552789 – Show size column in the search and recently used
files modes
* gtk/gtkfilechooserdefault.c: Display the file size column
when in OPERATION_MODE_SEARCH. This removes a stat() call
and simplifies the code a little bit by changing the query
for file informations for each search engine hit.
svn path=/trunk/; revision=21491
2008-09-18 Emmanuele Bassi <ebassi@linux.intel.com>
* gtk/gtkfilechooserdefault.c (settings_save): Save the size column
visibility state with the rest of the FileChooser settings.
svn path=/trunk/; revision=21437
2008-09-18 Emmanuele Bassi <ebassi@linux.intel.com>
Bug 325095 – show a 'size' column
* gtk/gtkfilechooserdefault.c:
* gtk/gtkfilechooserprivate.h: Add a context menu item controlling
the visibility of the file size column. This works only for the
browse mode, and the column is not visible by default.
* gtk/gtkfilechoosersettings.[ch]: Add a ShowSizeColumn key to the
settings file.
svn path=/trunk/; revision=21431
2008-09-07 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserdefault.c (search_add_hit): Don't unref the
GFile we just put into the search_model. This adds a new memory
leak...
svn path=/trunk/; revision=21315
2008-09-05 Michael Natterer <mitch@imendio.com>
* gtk/gtkfilechooserdefault.c (file_list_drag_data_received_cb):
stop the emission of the signal also when we bail out early
because we don't accept drops from ourselves. Keeps the code from
running into a warning in gtktreeview.c.
svn path=/trunk/; revision=21302
2008-08-26 Matthias Clasen <mclasen@redhat.com>
Bug 549354 – Crash trying to open a file on a remote folder
* gtk/gtkfilechooserdefault.c (error_message_with_parent): Handle
the fact that parent may be NULL without crashing.
svn path=/trunk/; revision=21206
Only emit default-size-changed if the file chooser widget is mapped.
It only makes sense to do this once we know our final configuration,
which is actually when we are mapped.
Signed-off-by: Federico Mena Quintero <federico@novell.com>
svn path=/trunk/; revision=21164
2008-08-04 Carlos Garnacho <carlos@imendio.com>
* gtk/gtk.symbols:
* gtk/gtkfilechooser.[ch]: Make GFile-oriented API public. Fixes
#545978.
* gtk/gtkfilechooserbutton.c:
* gtk/gtkfilechooserdefault.c:
* gtk/gtkfilechooserutils.c: Update to use public GFile API.
svn path=/trunk/; revision=20971
2008-07-06 Matthias Clasen <mclasen@redhat.com>
Bug 541645 – gtkfilechooserdefault segfaults when bookmark does not
contain ://
* gtk/gtkfilechooserdefault.c (_gtk_file_chooser_label_for_file):
Be more robust. Reported by Jelte van der Hoek
svn path=/trunk/; revision=20787
* gtk/gtkfilechooserdefault.c (browse_files_select_first_row): Don't
select the first row if the folder is empty.
Patch by Olle Bergkvist.
svn path=/trunk/; revision=20751
2008-06-30 Cody Russell <bratsche@gnome.org>
* Practically everything changed.
Change all references of GIMP Toolkit (and variations of it)
to GTK+ Toolkit, showing no mercy at all to our beloved
ancestry. (#540529)
svn path=/trunk/; revision=20709