xournalpp / xournalpp

Xournal++ is a handwriting notetaking software with PDF annotation support. Written in C++ with GTK3, supporting Linux (e.g. Ubuntu, Debian, Arch, SUSE), macOS and Windows 10. Supports pen input from devices such as Wacom Tablets.
https://xournalpp.github.io
GNU General Public License v2.0
11.35k stars 808 forks source link

Request to change GtkFileChooser to GtkFileChooserNative #5460

Open marvin1099 opened 10 months ago

marvin1099 commented 10 months ago

Operating System

Linux

(Linux only) Distribution

Arch (Garuda)

(Linux only) Desktop Environment

KDE

(Linux Only) Display Server

X.Org

Installation Method

Arch Repo (extra)

Xournal++ Version

1.2.2 (09ae3333)

libgtk Version

3.24.39

Bug Description

I wold be great if xournal would support single click on the fileselector so its easyer to use on touchscreen. I have setup my kde to open files and folders in single klick (I like that more anyway) but xournal doesn't seem to have support.

Expected Behaviour

If you have enabled Singleklick in your settings, I would be nice if xournal would open folders on Singleklick.

Steps to Reproduce

  1. Enable single klick in system settings
  2. Try to save any file
  3. Folders will only open after dobble click

Additional Context

No response

rolandlo commented 10 months ago

I don't think we can change that behaviour with the GtkFileChooser. So I'm closing the issue.

marvin1099 commented 10 months ago

Im currius, why are you using the gdk filepicker, is it not possible to use system defaut (i have seen something about "xdg-desktop-portal", might not be correct). Im not shure if it is hard to use the sytem default, i know it is somewath simple on windows, but not shure about linux.

rolandlo commented 10 months ago

Hmm, maybe I closed the issue prematurely. We could use the Gtk.FileChooserNative instead. It does offer less features and we may need some of those (not sure). One would have to check if that one supports single click when it's the system's default. The plugin API (via app.getFilePath or app.saveAs) uses the native dialog. You could check there if single click is supported.

marvin1099 commented 10 months ago

So i have tested a python script that uses Gtk.FileChooserNative and it works single click (it just runs the default filechooser as expected, so works perfectly). Here is the code i used for testing (It probably wont be much use, but it can't hurt):

#!/usr/bin/env python3

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

class FileChooserExample(Gtk.Window):

    def __init__(self):
        Gtk.Window.__init__(self, title="FileChooser Example")
        self.set_border_width(10)

        button = Gtk.Button(label="Select a file")
        button.connect("clicked", self.on_file_clicked)

        self.add(button)

    def on_file_clicked(self, widget):
        dialog = Gtk.FileChooserNative(title="Select a file",
                                       action=Gtk.FileChooserAction.OPEN)
        dialog.set_transient_for(self)

        response = dialog.run()
        if response == Gtk.ResponseType.ACCEPT:
            print("File selected: " + dialog.get_filename())
        elif response == Gtk.ResponseType.CANCEL:
            print("Canceled file selecttion")

        dialog.destroy()

win = FileChooserExample()
win.connect("destroy", Gtk.main_quit)
win.show_all()
Gtk.main()

So when i run the app like this

python ./Test.py

it reports

File selected: /home/marvin/Downloads/pras-first-h.png

Expected behavior overall. I'm not sure what of GtkFileChooser you are using, but if the app is just grabbing the path then this should work.

It would be great if it was implemented. For saving and loading of course, that would make the file selection so much easyer.

marvin1099 commented 10 months ago

Hmm, maybe I closed the issue prematurely. We could use the Gtk.FileChooserNative instead. It does offer less features and we may need some of those (not sure). One would have to check if that one supports single click when it's the system's default. The plugin API (via app.getFilePath or app.saveAs) uses the native dialog. You could check there if single click is supported.

Please consider reopening the issue, as a alternative title it could also say "Request to change GtkFileChooser to GtkFileChooserNative". If you still don't think this should be something that is part of the project, than say so and i put a pin on it. If you don't answer in like a weak, i will just open a new issue, to get this reconsidered. Thanks for all comments and input.

marvin1099 commented 10 months ago

Thank you. Hopefully it gets implemented at some point, I have my fingers crossed.

tockudex commented 1 month ago

Thank you. Hopefully it gets implemented at some point, I have my fingers crossed.

If you're still interested in the implementation of this feature, I believe a pull request with the required modification could greatly accelerate said implementation.

marvin1099 commented 1 month ago

Thank you. Hopefully it gets implemented at some point, I have my fingers crossed.

If you're still interested in the implementation of this feature, I believe a pull request with the required modification could greatly accelerate said implementation.

Yes I'm but I'm not familiar with the codebase and don't have a lot of c experience. So I see if I can figure it out but I'm not shure jet. Would still be great to have, i will try to see if I can find the relevant code parts in the next weaks and try to make to work.

tockudex commented 1 month ago

Glad to hear it, thanks ! I'd like to help, but I have literary no experience in C or C++…

marvin1099 commented 1 month ago

Jep i dont think this will be added any time soon. I just looked at the codebase and im smart enoght to know when something is above me. This is in fact way above me. I only code a bit in my free time and code with python usually and even then i do simple cli scripts.

I still hope someone else will try to figure this out, but I just have basic c++ experience. I can't make this happen if someone else looks at this and might be able to swich out GtkFileChooser for Gtk.FileChooserNative please try to do so. I would be very grateful.

LDprg commented 2 weeks ago

I would also like to see this implemented. Most apps nowadays work correctly with the xdg-portals, and it is very annoying that xournalpp does not.

tockudex commented 2 weeks ago

For proper triaging, the label “bug” should be replaced by “enhancement”, “os::linux” and “UX”.

Could you take a look at this please, @rolandlo as I'm not sure @marvin1099 can apply the changes himself?

LDprg commented 2 weeks ago

I did create a PR solving this, which should mostly work (I did notice one bug and I did not double-check to really replace all file dialogs).

However, my testing is limited to my main system (KDE Wayland, Arch btw.). So feel free to give feedback.

marvin1099 commented 2 weeks ago

Thanks that you took the time to make this @LDprg , I did not think that anyone would make a implementation of this.

As for feedback I may tr y to compile and run soon and will report at that point.

Also thanks @tockudex for suggesting the tag change and @rolandlo for adding the correct tags.

I think this makes this suggestion more transparent and therefore, I would argue have a higher interest that before.

Might not be true but can't be worse than before where there was no interest on this.