Skip to content

Conversation

@Marcool04
Copy link

FileChooserNative can be used in place of FileChooserDialog so that the native file picker dialogue is displayed if available (for example, on KDE in linux)

`FileChooserNative` can be used in place of  `FileChooserDialog` so that the native file picker dialogue is displayed if available (for example, on KDE in linux)
@Cimbali
Copy link
Owner

Cimbali commented Sep 2, 2025

HI, thanks for your contribution! I’m curious why do you think a native picker is better? Currently the whole app is styled with Gtk I’m not sure I fully grasp the issue with having the file picker be matching the application as opposed to matching the system.

@Marcool04
Copy link
Author

Good question :)

It's a matter of taste I guess, but on my system (KDE on linux), GTK apps blend in very well with the system, except where the file picker is concerned. In my case I have bookmarks, and shortcuts, and "recent files" and such setup in the native file picker, which this modification allows me to take advantage of. The GTK picker does not have these advantages.

It is ultimately a choice though I guess and I'd understand if you prefer to stick with the uniform look.

It's been working fine for me with this minor tweek made on my end anyhow for a few days now.

Thanks a lot for maintaining this really useful piece of software.

@Cimbali
Copy link
Owner

Cimbali commented Sep 3, 2025

Hmmm, bookmarks make sense yes. I’d need to test whether:

  • this works flawlessly on all platforms
  • this doesn’t interfere with the “recent PDF documents” feature that uses Gtk.RecentManager (but I think it should be ok, we maintain this manually anyway)

    pympress/pympress/ui.py

    Lines 851 to 875 in efc7899

    def populate_recent_menu(self, gaction, is_opening=None):
    """ Callback for the recent document menu.
    Gets the URI and requests the document swap.
    Args:
    gaction (:class:`~Gio.Action`): the action triggering the call
    is_opening (:class:`~GLib.Variant`): a wrapped boolean indicating whether the menu is opening or closing.
    """
    if not is_opening.get_boolean():
    self.recent_menu.remove_all()
    return
    for file in Gtk.RecentManager.get_default().get_items():
    if not file.exists() or not file.get_mime_type() == 'application/pdf':
    continue
    item = Gio.MenuItem.new(file.get_display_name(), 'app.open-file')
    item.set_action_and_target_value('app.open-file', GLib.Variant.new_string(file.get_uri()))
    item.set_icon(file.get_gicon())
    self.recent_menu.append_item(item)
    if self.recent_menu.get_n_items() >= 10:
    break

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants