Commit Graph

489 Commits

Author SHA1 Message Date
Bastien Nocera
179b39eb86 Merge branch 'wip/hadess/fix-remote-filechooser-main' into 'master'
Fix crasher/warnings when browsing remote filesystems

Closes #2482

See merge request GNOME/gtk!1490
2020-03-13 12:36:10 +00:00
Timm Bäder
d7fb33caf7 filechooserwidget: Avoid criticals when in recent mode
Don't try to use the browse_files_model just because we have a location
entry. The model might still be NULL at this point.
2020-03-06 16:29:32 +01:00
Timm Bäder
a1c75795bc Replace fallthrough comments with G_GNUC_FALLTHROUGH 2020-03-06 10:39:42 +01:00
Benjamin Otte
a411959c91 droptarget: Redo
This is a huge reorganization of GtkDropTarget. I did not know how to
split this up, so it's unfortunately all one commit.

Highlights:

- Split GtkDropTarget into GtkDropTarget and GtkDropTargetAsync
  GtkDropTarget is the simple one that only works with GTypes and offers
  a synchronous interface.
  GtkDropTargetAsync retains the full old functionality and allows
  handling mime types.

- Drop events are handled differently
  Instead of picking a single drop target and sending all DND events to
  it, every event is sent to every drop target. The first one to handle
  the event gets to call gdk_drop_status(), further handlers do not
  interact with the GdkDrop.
  Of course, for the ultimate GDK_DROP_STARTING event, only the first
  one to accept the drop gets to handle it.
  This allows stacking DND event controllers that aren't necessarily
  interested in handling the event or that might decide later to drop
  it.

- Port all widgets to either of those
  Both have a somewhat changed API due to the new event handling.
  For the ones who should use the sync version, lots of cleanup was
  involved to operate on a sync API.
2020-03-02 03:18:55 +01:00
Bastien Nocera
8cb45cdeae filechooser: Fallback if content-type unavailable
Fallback to fast-content-type if the content-type attribute isn't
available, as is the case for most remote filesystems.

Closes: #2482
2020-02-28 17:33:08 +01:00
Bastien Nocera
823714cf66 filechooser: Fix crash when file has no content-type
This might happen for slow filesystems where a fast-content-type might
be provided instead. Don't try to manipulate that content_type if it's
NULL, otherwise we'll either throw warnings (at best) or crash (at
worse).

Conflicts:
	gtk/gtkfilechooserwidget.c
2020-02-28 17:32:48 +01:00
Emmanuele Bassi
c8f4f903c6 Remove last instances of GtkFileChooser:show-hidden
The file chooser widget is still setting the show-hidden property, even
though it was removed.
2020-02-26 10:15:16 +00:00
Matthias Clasen
a43d13aa74 popover: Drop ::relative-to
It is enough to just set the parent (and make the parent
call gtk_native_check_resize in size_allocate).

This commit removes the relative_to argument to the
constructors of GtkPopover and GtkPopoverMenu, and
updates all callers.
2020-02-24 20:46:41 -05:00
Matthias Clasen
7f46b25c04 Merge branch 'wip/ebassi/filechooser-new' into 'master'
Clean up the GtkFileChooser API

Closes #2455

See merge request GNOME/gtk!1454
2020-02-24 00:32:23 +00:00
Benjamin Otte
a19066b17c filechooserwidget: Stop using selection data
Use gdk_drop_read_async()
2020-02-23 01:59:00 +01:00
Emmanuele Bassi
ff6772fd98 Remove preview widget from GtkFileChooser
The preview widget harks from a platform before time, when we didn't
have GIO, or a thumbnail specification.

Very few applications use it correctly, if at all; it has an horrid hack
to deal with the ownership of the widget's instance when accessed
through the getter function; it messes up the layout of the widget and
its label is less than useful when it comes to file names longer than a
dozen characters; it's a poor substitute for a proper thumbnail view.
2020-02-22 16:39:01 +00:00
Emmanuele Bassi
e5ef26efa8 Remove GtkFileChooserEntry:local-only
We don't use it any more in GtkFileChooserWidget.
2020-02-22 15:22:06 +00:00
Emmanuele Bassi
4a3742979d Remove GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER
We don't need a whole separate action, now that the file chooser widget
can create folders; we can create use SELECT_FOLDER and create one.
2020-02-22 15:22:06 +00:00
Emmanuele Bassi
b09e7df81b Remove GtkFileChooser:local-only
Now that the whole API goes through GFile we don't have the weird split
between local-only and non-local-only modes.
2020-02-22 15:22:06 +00:00
Emmanuele Bassi
516eab5c43 Remove GtkFileChooser:show-hidden
This is a user setting and a user action, not something that ought to be
programmatically set via the file selection API.
2020-02-22 15:22:06 +00:00
Emmanuele Bassi
063ad28b1a Remove overwrite confirmation machinery from GtkFileChooser
Overwrite confirmation should not be optional, and it should not loop
into application code to create their own dialog and user response.
2020-02-22 15:22:06 +00:00
Emmanuele Bassi
d505573ee6 Drop GtkFileChooser:extra-widget
We have "choices" as a more rational (and portable) API; additionally,
the ownership semantics of the extra widget property getter are a hack.
2020-02-22 15:22:06 +00:00
Emmanuele Bassi
5f070ff233 Remove filename/URI API from GtkFileChooser
GtkFileChooser's API predates GIO by a few years, so it started off with
filenames and URI as character arrays. After introducing GIO as a
dependency, the API included GFile-based entry points.

It's much more appropriate to use GFile everywhere, as we want to
encourage people to use GIO instead of passing random bytes to low level
POSIX API.

See: #2455
2020-02-22 15:22:06 +00:00
Timm Bäder
f14978c68f filechooserwidget: Fold function into only caller 2020-02-20 10:23:09 +01:00
Timm Bäder
c0de02520c filechooserwidget: Use a proper GtkPopoverMenu
Instead of a fake one where we add .menu to a normal popover. This makes
the menu look like other context menus.
2020-02-20 10:23:09 +01:00
Timm Bäder
b8a752c751 filechooserwidget: Allow typing a location in recent mode
This is triggered by typing / or hitting Ctrl+L. Since we don't have a
visual indicator for this mode right now anyway, the reason for not
allowing it in recent mode cited in the comment just above the
early-exit is irrelevant.

Closes #2178
2020-02-20 10:23:09 +01:00
Timm Bäder
194039c749 filechooserwidget: Remove unused constants 2020-02-20 10:23:09 +01:00
Benjamin Otte
80ba7fd682 dragdest: Make gtk_drop_target_new() args be transfer full
Saves tons of code.
2020-02-17 04:04:21 +01:00
Benjamin Otte
810f55c006 filechooser: Remove outdated hack
In GTK2, the filechooser was using a Paned, so switching between sidebar
and files list with the arrow keys didn't work (the slider would be
selected instead). So in
https://bugzilla.gnome.org/show_bug.cgi?id=161489 a crude hack was added
to make this possible.

Over the years the filechooser code has changed so that it now would do
this by default, yet the hack had been retained.
2020-02-09 16:54:38 -05:00
Benjamin Otte
546a748cd8 widget: Replace style-updated signal with css_changed vfunc
1. Rename the thing
2. Turn it from a signal to a vfunc
3. Pass the GtkCssStyleChange to it

We don't export any public API about the GtkCssStyleChange yet, it's
just a boring opaque struct.
2020-02-05 02:46:13 +01:00
Benjamin Otte
afbff574f5 filechooser: Remove default size machinery
The FileChooser ToolKit (fctk) had its own machinery to handle default
sizes which was completely busted and trying to marshal random numbers
through the widget hierarchy that maybe made sense in 2012 but don't do
now.

Get rid of it, just keep the dialog's GSetting - which funnily enough
used to be written by the dialog but written by the widget.
But that's fctk for you.
2020-01-28 02:17:31 +01:00
Matthias Clasen
997186f640 filechooser: Stop using gtk_style_context_get
Just go to the css style directly.
2020-01-27 12:52:24 -05:00
Matthias Clasen
ec255f9bb1 Update all callers 2020-01-11 00:50:22 -05:00
Matthias Clasen
1c03bbeb9c Update all users 2020-01-08 18:48:23 -05:00
Matthias Clasen
5206a92522 Update all callers 2020-01-08 18:48:22 -05:00
Matthias Clasen
9c11c60530 filechooser: Remove code for sidebar pre-arming
This is just not a feature we can support currently.
Doing it properly would require infrastructure for
a generalized :drag(sensitive) state highlighting
potential drag sites everywhere.
2020-01-08 18:48:22 -05:00
Matthias Clasen
fb4b5c666b filechooserwidget: Use GDK content formats api: 2020-01-08 18:48:22 -05:00
Matthias Clasen
0224517806 filechooser: Stop using gtk_drag_source_get_drag 2020-01-08 18:48:22 -05:00
Matthias Clasen
818b456f9f filechooserwidget: Stop using gtk_drag_source_get_origin 2020-01-08 18:48:21 -05:00
Matthias Clasen
8e8254feae filechooserwidget: wip 2020-01-08 18:48:21 -05:00
Matthias Clasen
508570864d Remove gtk_drop_target_get_target
Now that drop targets are event controllers,
we can just use gtk_event_controller_get_widget.
Update all callers.
2020-01-08 18:48:21 -05:00
Matthias Clasen
e9067ae2db Replace gtk_drop_target_attach/detach
Since drop targets are now just event controller,
gtk_widget_add/remove_controller works just fine
for them.
2020-01-08 18:48:21 -05:00
Matthias Clasen
46f42fc53d droptarget: Drop defaults flags
These no longer have any effect.

Update all callers.
2020-01-08 18:48:20 -05:00
Matthias Clasen
b9034015d7 filechooser: Convert to GtkDropTarget 2020-01-08 18:48:20 -05:00
Matthias Clasen
74722fb10e filechooser: Port to GtkDragSource 2020-01-08 18:48:19 -05:00
Matthias Clasen
7ee5779efc gtk: Remove menu code
GtkMenu, GtkMenuBar, GtkMenuItem and their subclasses
and supporting classes are replaced by model-based popover
implementations.
2019-12-29 20:31:58 -05:00
Matthias Clasen
bfa0509f08 Privatize popover menu pieces
Don't allow manual creation of popover menus
anymore. This lets us also make GtkModelButton
private
2019-11-11 12:42:06 +01:00
Timm Bäder
6b07ce2b13 filechooserwidget: Remove unused function parameter 2019-10-22 09:37:08 +02:00
Timm Bäder
008e8076a1 filechooserwidget: Inline function into only caller 2019-10-22 09:37:08 +02:00
Timm Bäder
426d5ca1b7 filechooserwidget: Add .menu to right-click popover
Make it look like the other menus.
2019-10-22 09:37:08 +02:00
Timm Bäder
aaae141687 filechooserwidget: Focus the searchbar when searching
This code path is taken if the search is already active, so focus the
search entry.
2019-10-22 09:37:08 +02:00
Timm Bäder
4826255ea3 filechooserwidget: Rename a callback 2019-10-22 09:37:08 +02:00
Timm Bäder
ce72154913 Rename gtkbookmarkmanager.h to gtkbookmarksmanagerprivate.h
It's a private type, so gets a private header file name.
2019-09-11 08:12:31 +02:00
Timm Bäder
4c28ee80a6 filechooserwidget: Create recent manager when setting operation mode
Creating a recent manager can be fairly expensive and we won't use it if
the widget is not visible or the recent mode has not been entered. Code
other places can already handle a NULL recent manager, so just create it
when entering the recent mode. And shove 25ms of startup time off the
widget-factory this way.
2019-09-09 17:36:26 +02:00
Timm Bäder
f4c4fe860b filechooserwidget: Remove custom recent_info_has_application impl 2019-09-09 17:36:26 +02:00
Timm Bäder
4766b475d0 filechooserwidget: Inline come functions into only callers
Similar to the previous commit(s), make it clearer what this function
does.
2019-09-09 17:36:26 +02:00
Timm Bäder
ae75d4b565 filechooser: Move extract_recent_folders to filechooserwidget
It's not used anywhere else.
2019-09-09 17:36:26 +02:00
Timm Bäder
c102387916 filechooserwidget: Load recent files synchronously
Delaying this by one frame by putting it in an idle just makes the code
more complex for no gain. The actual slow part is reading the
recently-used.xbel, which happens when creating the recent manager.
2019-09-09 17:36:26 +02:00
Timm Bäder
9952f72680 filechooserwidget: Properly watch for different display
The value returned by gtk_widget_get_settings() depends on the widget's
display, so watch for notify::display instead of using (un)root for
this.

Fixes the warnings seen when show a file chooser from the inspector.
2019-09-09 17:36:25 +02:00
Nelson Benítez León
487e095d24 filechooser: keep file selected after being renamed
Because otherwise when the file list is sorted "by name"
and the new name causes the file to be re-sorted to another
row, the selection stays in the old row which is now
occupied by a different file.

Fixed by keeping track of the renamed file and revealing
it in the "row-changed" signal handler, which gets emitted
after a file is renamed.

Fixes issue #948
2019-08-12 17:32:56 -04:00
Timm Bäder
3935027880 filechooserwidget: Fold function into only caller 2019-07-19 18:14:50 +02:00
Timm Bäder
8665828d7f filechooserwidget: Don't emit default-size-changed() in unroot()
It doesn't make much sense to assume the default size has changed just
because the widget has been unrooted.
2019-07-19 18:14:50 +02:00
Timm Bäder
5674a3db46 filechooserwidget: Don't look at saved window position
We don't save it anymore so no need to look at it here.
2019-07-19 18:14:49 +02:00
Timm Bäder
a9364bc053 Revert "file chooser: Stop using gtk_window_get_position"
This reverts commit 2ed533c3e1.

This also made the filechooser dialog not save the window size anymore,
which does not depend on the gtk_window_get_position() removal.
2019-07-19 18:14:49 +02:00
Timm Bäder
59313e1459 gtkfilechooserwidget: Temporarily disable revealer transitions...
... when going between recent and browse. It just looks weird to have
this transition while the treeview model is just cleared/repopulated
without any transition.
2019-07-19 18:14:49 +02:00
Nelson Benítez León
c789a39660 GtkFileChooser: add a sortable "Type" column
along with a new 'type-format' setting that allows
to choose the output format for the "Type" column.

The options implemented for this setting are:

'mime' : Output from g_content_type_get_mime_type().

'description' : Output from g_content_type_get_description().

'category' : It uses the corresponding generic icon
  of the mime type to group by categories (aka basic types).

  This produces a more compact output than previous options,
  and allows for type families to be grouped together, so eg.
  after sorting by "Type" column, jpeg and png images will
  be placed together, or the various types of archiver files
  will also be grouped together.

  This format was copied from and currently used by Nautilus
  list view, so we also improve consistency with Nautilus.
  Bugzilla entry for Nautilus implementation is:
  https://bugzilla.gnome.org/show_bug.cgi?id=683722

  The list of type families or categories can be checked on:
  https://developer.gnome.org/icon-naming-spec/#mimetypes

  This 'category' format is set as default.

Issue #362
2019-06-22 13:22:59 -04:00
Matthias Clasen
820929958d file chooser: Stop using gtk_widget_get_action_group
We create this action group ourselves,
we can keep track of it.
2019-06-15 21:40:55 -04:00
Matthias Clasen
7f65e5f96b Rename GtkGestureMultiPress to GtkGestureClick
The name just made it hard for people to find the
right gesture to use.
2019-05-29 17:10:46 +00:00
Matthias Clasen
7447abb52b Stop using gtk_widget_get_toplevel
All uses of it can be replaced by gtk_widget_get_root.
2019-05-28 20:25:16 +00:00
Matthias Clasen
948347afa9 Stop using gtk_widget_is_toplevel 2019-05-28 20:25:16 +00:00
Matthias Clasen
18788c2a86 Remove gtk_widget_get/set_has_surface
These serve no purpose anymore - widgets don't
have surfaces, unless they're a GtkNative.
2019-05-28 20:25:15 +00:00
Matthias Clasen
81548911de file chooser widget: Drop the priv pointer 2019-05-28 03:02:33 +00:00
Matthias Clasen
e795c0c67e file chooser widget: Make final 2019-05-28 02:41:15 +00:00
Timm Bäder
3a863ccd00 filechooserwidget: Remove unused gobject data 2019-05-18 13:47:59 +02:00
Timm Bäder
d53d7eb9e7 filechooserwidget: Remove some unused struct members 2019-05-15 17:08:58 +02:00
Emmanuele Bassi
59c6862a03 Use gtk_widget_class_set_layout_manager_type()
Instead of manually creating the layout manager inside the instance
initialization function, we can let GtkWidget do that for us.
2019-05-06 12:06:27 +01:00
Matthias Clasen
965d0e04d1 gtk: Use root/unroot instead of display-changed
The display-changed signal is going away
2019-05-02 01:33:41 +00:00
Timm Bäder
074a0014c1 filechooserwidget: Only query clock-format setting once
We don't support that setting life-updating anyway. So, instead of
getting the value *every time we format a time*, get it once for the
filechooserwidget and reuse that value.
2019-04-30 06:43:42 +02:00
Timm Bäder
175e3d751d filechooserwidget: Remove unnecessary deprecation guards 2019-04-30 05:36:20 +02:00
Timm Bäder
83e9361005 filechooserwidget: Stop using gtk_widget_get_allocat* 2019-04-30 05:36:20 +02:00
Timm Bäder
17bb1248b5 filechooserwidget: Shorten cancel_all_operations() impl 2019-04-30 05:36:20 +02:00
Timm Bäder
8211e79be9 filechooserwidget: Shorten dispose impl a bit 2019-04-30 05:36:20 +02:00
Timm Bäder
d5282862e5 filechooserwidget: Remove some unnecessary show() calls
Widgets are visible by default now.
2019-04-30 05:36:20 +02:00
Timm Bäder
26b6d18563 filechooserwidget: Use a bin layout
Instead of implementing size_allocate and measure manually.
2019-04-30 05:36:20 +02:00
Timm Bäder
31fb5cc2d4 filechooserwidget: Shorten finalize implementation a bit 2019-04-30 05:36:20 +02:00
Timm Bäder
90301c6813 filechooserwidget: Inline fuction into only caller 2019-04-30 05:36:20 +02:00
Timm Bäder
1d81a58cf1 filechooserwidget: Pick reasonable default sidebar width
The old default of 148px doesn't work everywhere. Instead, pick a
default value of -1 and measure() the sidebar widget in the
filechooserwidget in that case. Other values >= 0 are still handled as
before.
2019-04-30 05:36:20 +02:00
Timm Bäder
09cec2e6a1 filechooserwidget: Delay view switch to search hits
Leave it to the ::hits-added handler to switch to the list of search
hits. This way we don't get a weird transition when the current search
didn't have any hits and the next one doesn't either.
Searches with hits still feel good.
2019-04-30 05:36:20 +02:00
Matthias Clasen
92e21c3f1c Drop the can-default property
It was added at a time when default buttons
had a very large external border that would disrupt
aligment. Not a problem nowadays.
2019-04-28 23:28:39 +00:00
Matthias Clasen
3d1fdf77dc file chooser: Stop using gtk_window_activate_default
Instead, use the new way of activating default.

I think most of the default handling in
GtkFileChooserDialog should be dropped, but
for now this keeps things working.
2019-04-28 23:20:13 +00:00
Matthias Clasen
ff604e1906 file chooser: Stay focused
When hitting Escape in the location entry,
we were not moving the focus anywhere,
causing focus to be NULL, and key bindings
to stop working. The visible effect was
that Ctrl-L / Escape / Ctrl-L would not
get back to the location entry, as expected.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1851
2019-04-28 16:08:21 +00:00
Matthias Clasen
34974a8a66 Merge branch 'wip/baedert/filechooser2' into 'master'
Assorted filechooser improvements

See merge request GNOME/gtk!783
2019-04-28 15:33:07 +00:00
Matthias Clasen
b9467a4dc7 file chooser: Prevent accidental search
When hitting Escape, the file chooser will go
into search mode, because the search entry
consumes the key to emit the ::search-stopped
signal. Recognize this situation and avoid
switching to search mode in this case.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1850
2019-04-28 15:20:07 +00:00
Timm Bäder
b75bc8aa64 filechooserwidget: Allow keynav from the treeview to the search entry 2019-04-28 11:27:42 +02:00
Timm Bäder
78049f452a filechooserwidget: Remove unneeded function prototype 2019-04-28 11:08:09 +02:00
Timm Bäder
cf2ef4863b filechooserwidget: Don't focus treeview when searching
It's just weird that the search entry does not have focus while we type.
2019-04-28 11:07:14 +02:00
Timm Bäder
2bd348558e filechooserwidget: Remove some GdkEvent usage 2019-04-28 11:05:37 +02:00
Timm Bäder
0f6d83bb5f filechooserbutton: Remove some dead code 2019-04-28 11:02:59 +02:00
Matthias Clasen
eea1388cf4 file chooser: Fix Ctrl-L
We were forwarding key events to the search entry
and unconditionally considered search started
afterwards. That is not correct, since things
like a Ctrl key press should not trigger search.
Fix this by only switching to search mode when
the event was actually consumed.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1829
2019-04-27 17:43:59 +00:00
Matthias Clasen
285293ac17 file chooser: Fix some compiler warnings 2019-04-05 05:10:26 +00:00
Carlos Garnacho
e59c6abd91 filechooserwidget: Drop usage of gtk_search_entry_handle_event()
Just use gtk_event_controller_key_forward() to let know the search
entry of the Esc key being pressed.
2019-04-03 13:23:34 +02:00
Matthias Clasen
5b5a68c5db Fix filechooser search
This makes the search entry show up again
when I type. There is still some misbehavior
where the entry loses focus again, and Escape
does not work to exit search.
2019-03-31 23:06:42 -04:00
Matthias Clasen
2ed533c3e1 file chooser: Stop using gtk_window_get_position
It is going away.
2019-03-26 17:55:29 -04:00
Matthias Clasen
f13e6179e8 filechooser: Stop using ::set-focus
We can achieve the same with the focus-widget property.
2019-03-16 21:24:44 -04:00
Matthias Clasen
2bf1561b48 Port widgets to the root focus API 2019-03-16 21:24:44 -04:00