Skip to content

Add org.freedesktop.FileManager1 D-Bus interface and methods - #60

Open
noskla wants to merge 5 commits into
lxde:masterfrom
noskla:master
Open

Add org.freedesktop.FileManager1 D-Bus interface and methods#60
noskla wants to merge 5 commits into
lxde:masterfrom
noskla:master

Conversation

@noskla

@noskla noskla commented Aug 17, 2026

Copy link
Copy Markdown

This pull request adds support for the org.freedesktop.FileManager1 D-Bus interface to PCManFM, it enables external programs to interact with the file manager via standard D-Bus methods.

Change was tested and I actively use the compiled version of my branch on my operating system

noskla added 5 commits August 17, 2026 18:49
Introduce dbus-service.[ch] implementing the initial scaffolding for
the org.freedesktop.FileManager1 D-Bus interface: introspection XML,
bus name ownership, object registration, and init/finalize entry
points. Method calls are not yet implemented and return
G_DBUS_ERROR_UNKNOWN_METHOD.

Wire the new service into pcmanfm.c so it is initialized by the
single-instance server process and finalized on shutdown, and add
dbus-service.c to the build.
Add uri_strv_to_paths() to convert an array of URIs into a list of
FmPath objects, and show_folder() to open (or reuse) a main window
tab for a given folder path. Wire the ShowFolders D-Bus method to
open a tab/window for each requested folder.
Add PendingSelect/select_file_in_page()/on_page_loaded_select() and
show_and_select_path() to open the parent folder of a given file
path and select/scroll to it, handling both already-loaded tabs and
tabs whose content loads asynchronously via the tab page's "loaded"
signal.

Wire the ShowItems D-Bus method to this new logic via
handle_show_items().
Add handle_show_item_properties(), which reuses show_and_select_path() to open/select each item's parent folder as a reasonable stand-in for a full Properties dialog (out of scope for now). Wire the ShowItemProperties D-Bus method to it.

This completes the org.freedesktop.FileManager1 interface with all three methods implemented; drop the staging .ready file now that its contents have been fully incorporated.
Bug: Invoking org.freedesktop.FileManager1.ShowItems (or
ShowItemProperties) over D-Bus while no window/tab is already open on
the target directory crashed pcmanfm with SIGSEGV. This is reproducible
by e.g. Firefox's "Open Containing Folder" / "Open Download Directory"
action, which calls ShowItems via the FileManager1 D-Bus interface.

Root cause: show_and_select_path() in dbus-service.c creates a new tab
(or window+tab) for the target file's parent directory and then
immediately calls fm_folder_view_select_file_path() /
fm_folder_view_scroll_to_path() on it. For a freshly created tab the
FmFolderModel has not been built yet -- it is only created
asynchronously once the FmFolder finishes loading ("loaded" signal).
Calling select/scroll against a folder view with no model yet
dereferences invalid state deep inside libfm-gtk3
(fm_folder_model_find_iter_by_filename), crashing the process.

Fix: only perform the immediate select/scroll call when the tab's
folder is already loaded (checked via fm_folder_is_loaded()). This is
the case when an existing tab already showing the target directory is
reused. For freshly created tabs/windows, defer the select/scroll to
the existing "loaded" signal handler (on_page_loaded_select) instead of
also trying it immediately, since the earlier code tried to do both
which caused the crash on the immediate attempt.

Verified with gdb: reproduced the exact crash/backtrace by calling
ShowItems over D-Bus against the unpatched binary running under
"gdb -batch -ex run -ex bt full", then confirmed repeated calls (both
opening a new window and reusing an already-loaded tab) no longer crash
after this fix.
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.

1 participant