Commit Graph

605 Commits

Author SHA1 Message Date
Matthias Clasen
ee5324359d filechooser: Save and restore view type
With this, the filechooser comes up with the
same view (grid or list) that it had the last
time you used it.
2022-12-13 14:45:15 -03:00
Georges Basile Stavracas Neto
10338a5237 filechooserwidget: Rename callback
It's shared between both column and grid views now.
2022-12-13 14:45:15 -03:00
Georges Basile Stavracas Neto
1c5caf53b6 filechooserwidget: Implement 'keynav-failed' for grid view
It's exactly the same as of the column view. Since we're sharing
the callback now, rename it to browse_files_view_keynav_failed_cb.
2022-12-13 14:45:15 -03:00
Georges Basile Stavracas Neto
0bb6377a3a filechooserwidget: Use correct view in various places
Most of the pointer comparisons against 'browse_files_column_view'
should actually be performed against the current view widget. As
it turns out, it weren't that many places after all.
2022-12-13 14:45:15 -03:00
Georges Basile Stavracas Neto
27613e3bc5 filechooserwidget: Add a grid view
Add a grid view outside of the widgetry tree. The grid view mimics
the column view using bindings, so we only need to manage the column
view.

Also add a button in the path bar section to toggle the view. This
is handled as a new 'toggle-view' action in the file chooser.

The way switching between views currently work is by setting either
the column or grid view as the child of the GtkScrolledWindow. This
has the benefit of unmapping the unused view, which is nice and can
avoid some tricky situations with thumbnails.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/233
2022-12-13 14:45:15 -03:00
Matthias Clasen
ae29fee903 openuriportal: Support OpenDirectory
This required an extra argument. Update all callers.
2022-12-09 11:05:48 -05:00
Matthias Clasen
2e90a752eb filechooserwidget: Fixes
Fix a memory leak in the file manager launch path.
2022-12-09 11:05:48 -05:00
Matthias Clasen
f339cc276c gtk: Stop using gtk_widget_show/hide
gtk_widget_set_visible and gtk_window_present
are better alternatives, and calling gtk_widget_show
on newly created widgets is no longer necessary
anyway.
2022-11-28 14:34:55 -05:00
robxnano
adc0264dac
filechooser: Fix gtk_file_chooser_set_choice again
If the choice was in the form of a GtkDropDown, the code failed to
find the widget and so the choice never got set. Fixes #5346.
2022-11-16 18:07:20 +00:00
Matthias Clasen
f54ab91ff3 Deprecate GtkFileChooser and implementations
These are being replaced by GtkFileDialog.

This commit only moves the headers for GtkFileChooserWidget and
GtkFileChooserDialog to deprecated/, and keeps the implementations
in gtk/, since they will eventually be salvaged into a private
GtkFileChooserWindow.
2022-10-29 13:31:41 -04:00
Matthias Clasen
9ab732ce2d gtk: Port to async dialog API 2022-10-29 13:31:41 -04:00
Bilal Elmoussaoui
6ca33c639e g-i: Add missing since annotation 2022-10-27 15:38:14 +00:00
Matthias Clasen
f44570e71a filechooserwidget: Drop deprecation guards
We got rid of all deprecated api here.
2022-10-21 21:48:39 -04:00
Corey Berla
e5cea4e39d filechooserwidget: Show popup when clicking on empty space
Add gesture to right click or long press in the empty space
in the FileChooserWidget.  Only show the global settings when
clicking on the empty space.
2022-10-21 13:57:21 -07:00
Matthias Clasen
1d9c61cada filechooserwidget: Remember sort columns and order
These settings existed before, we keep using them.
This loses some information about sorting by multiple
columns, but it is sufficient to get the same primary
sort column back.
2022-10-20 22:34:41 -04:00
Corey Berla
71adb26a0d filechooserwidget: Fix time_sort_func 2022-10-20 22:34:41 -04:00
Corey Berla
e27fa33690 filechooser: Add show-time property
The "Show Time" setting does not take immediate effect (only after
changing folders) because it's set as a single call to
column_view_get_time_visible() on the FileChooserCell creation.
Instead create a bind a show-time property that gets updated
as the setting is changed.
2022-10-20 22:34:41 -04:00
Corey Berla
f7dfead861 filechoosercell: Add a GtkDragSource
Allow dragging one or more items.  If the item dragged is not part of
the current selection, only drag that item.
2022-10-20 22:34:41 -04:00
Corey Berla
8af191e52d filechooserwidget: Expose selection model
FileChooserCell may need to change the selection during a DND.
2022-10-20 22:34:41 -04:00
Corey Berla
06382ff836 filechooserwidget: Rename and expose get_selected_files()
GtkFileChooserCell will need this function
2022-10-20 22:34:41 -04:00
Matthias Clasen
cd469788c3 filechooserwidget: Make rename popover work
Make the rename popover operate on the file that
the context menu was opened for, and pop up at
the same position.
2022-10-20 22:34:40 -04:00
Matthias Clasen
44b5076cf2 filechooserwidget: Make context menus mostly work
Move the gestures to the individual cells, and
make them trigger the context menu via an action
that takes item position and coordinates.

The semantics are changed slightly: the menu actions
now operate on the clicked item, not on the selection.

Still to do: Fix up keyboard activation.
2022-10-20 22:34:40 -04:00
Matthias Clasen
e5be9e1035 filesystemmodel: Drop the model types
We are no longer storing extra values, so no need
to take their types in the api.
2022-10-20 22:34:40 -04:00
Matthias Clasen
b831d01f0d filesystemmodel: Drop unused arguments
Drop the unused get_func arguments in constructors.

Update all callers.
2022-10-20 22:34:40 -04:00
Matthias Clasen
edd5ed169e filesystemmodel: Drop _gtk_file_system_model_get_value
This function is unused, so drop it, and its callback.
2022-10-20 22:34:40 -04:00
Matthias Clasen
8ec9c3fdc6 filechooser: Some work on popup menus
This is a start towards placing menus properly.

We once again center keyboard-triggered menus
on the file list.
2022-10-20 22:34:40 -04:00
Matthias Clasen
e95022040f filechooser: Drop deprecated includes
We no longer use cell renderers and tree models
here. Yay.
2022-10-20 22:34:40 -04:00
Matthias Clasen
df49bf9eec filechooserwidget: Use a string sorter for names
We can use the new collation property of GtkStringSorter,
and get the benefit of sort key caching. This commit
also fixes an accidental leak of all sorters, and
removes the sorter from the location column - we never
show that column when individual colummns are sortable.
2022-10-20 22:34:40 -04:00
Matthias Clasen
53327f3aea filechooser: Drop unnecessary theme tracking
The widgets we are using handle theme changes
themselves, so there is no need for the filechooser
to do anything.
2022-10-20 22:34:40 -04:00
Matthias Clasen
c0c3d75062 filechooser: Bring back sorting
Add a sort model between the filter model and the
file system model, and set it up to sort according
to the circumstances.
2022-10-20 22:34:40 -04:00
Corey Berla
d0d0409f9d filechooserwidget: Reimplement DnD Drop Target
This reverts commit 34752a15a71597d00a8d08befc545ac1c178b81b.

Leaving out the drag source portion as that needs a total
reimplementation.  The GtkDropTarget only required minor
modifications.
2022-10-20 22:34:40 -04:00
Matthias Clasen
3a7d094542 filechooserwidget: Reinstate show_and_select_files
Now that we have information about visible and
filtered-out status of items, we can make this
function work again.
2022-10-20 22:34:40 -04:00
Matthias Clasen
280adcbb8c filechooserwidget: Add a filter model
Put a filter model between the selection model and
the filesystem model, and make it filter on the
filechooser::visible attribute. This makes the filer
combo in the filterchooser and the 'show hidden files'
item work. But we need to prod the filter to trigger
a refiltering every now and then.
2022-10-20 22:34:40 -04:00
Georges Basile Stavracas Neto
eeeee99aa8 filechooserwidget: Connect to the right model
When recreating the browse_files_model model, connect to that
model's item-changed signal, instead of connecting to the selection
model.
2022-10-20 22:34:40 -04:00
Georges Basile Stavracas Neto
0f503e0ba2 filechooserwidget: Connect to items-changed when changing model
Just like previous commit, we need to call list_items_changed()
even if we change from single selection to multi selection or
vice-versa.
2022-10-20 22:34:40 -04:00
Matthias Clasen
ec4f814bd4 filechooserwidget: Listen to items-changed too
To track changes of the selected items in a selection
model, we need to listen to both ::selection-changed
and ::items-changed.

This fixes the open button not turning sensitive
when initially loading a new folder.
2022-10-20 22:34:40 -04:00
Matthias Clasen
0141ba4e00 filechooser: Prevent recursion when activating items
When a list item is activated, we activate the default widget.
Unfortunately, due to some other bug, sometimes the open button
is not made sensitive, and then default.activate falls back
to activating the focus widget (which is the item we are just
coming from). Boom
2022-10-20 22:34:40 -04:00
Georges Basile Stavracas Neto
07d6166ab8 filechooserwidget: Use GListModel API for post-renaming selection 2022-10-20 22:34:40 -04:00
Georges Basile Stavracas Neto
f520801626 filesystemmodel: Retire GtkFileSystemItem
This has to be the shortest-living object in GTK history!

It helped us greatly during the transition to GtkColumnView, but
now we can remove it in favour of GFileInfo directly. Perhaps I
could have never introduced GtkFileSystemItem in the first place,
but we're 30 commits deep and it's too late to just redo the whole
thing that will get us exactly here anyway.
2022-10-20 22:34:40 -04:00
Georges Basile Stavracas Neto
ddf1cd6678 filechooserwidget: Remove treeview
Now that most of the treeview usage is gone, remove the remaining
code that uses it - mostly event handling code, which for now won't
work, but will be fixed by next commits - and drop the tree view
entirely.
2022-10-20 22:34:40 -04:00
Georges Basile Stavracas Neto
9c6d5e2ca5 filechooserwidget: Use GtkSelectionModel for selection
So far, GtkFileChooserWidget has relied on GtkTreeView's selection
management. This commit moves it away from GtkTreeView, and that's
a massive surgery - sorry :(

The most important aspect of this commit is that 'selection_model'
is now the main model we deal with. Changing between directories,
recent files, and search, all sets the selection_model's model.

Selections are entirely handled by GtkSelectionModel now.
2022-10-20 22:34:40 -04:00
Georges Basile Stavracas Neto
d5b31a30fd filechooserwidget: Stop centering on selected files 2022-10-20 22:34:40 -04:00
Georges Basile Stavracas Neto
39c678988d filechooserwidget: Don't queue redraw / resize on tree view 2022-10-20 22:34:40 -04:00
Georges Basile Stavracas Neto
9052c191cb filechooserwidget: Compare focus against column view
This effectively doesn't work, but focus will be reworked at some
point, and this gets us a tiny bit closer to that.
2022-10-20 22:34:40 -04:00
Georges Basile Stavracas Neto
766f442636 gtkfilechooserwidget: Don't set size request 2022-10-20 22:34:40 -04:00
Georges Basile Stavracas Neto
3a3482e41e filechooserwidget: Remove DnD code
Another case where we'll reimplement it later.
2022-10-20 22:34:40 -04:00
Georges Basile Stavracas Neto
5c41dbfaa5 filechooserwidget: Remove sorting
This will be reimplemented later using list models. For now, let's
remove it so we can untangle all this code properly.
2022-10-20 22:34:40 -04:00
Georges Basile Stavracas Neto
c9d2ff7a0f filechooserwidget: Stop autosizing treeview 2022-10-20 22:34:40 -04:00
Georges Basile Stavracas Neto
de2624faa7 filechooserwidget: Move tooltip text to column view
Use a closure binding to query the tooltip.
2022-10-20 22:34:40 -04:00
Georges Basile Stavracas Neto
cda784a5f4 filechooserwidget: Move folder navigation to column view
React to column view's 'activate' signal, instead of treeview's
'row-activated'. It doesn't handle file sensitivity yet, but that
will probably be dropped later.
2022-10-20 22:34:40 -04:00