Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add Open interface and script tweak #2011

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions assets/dbus/org.freedesktop.FileManager1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
<method name="Trash">
<arg name="URIs" type="as" direction="in"/>
</method>
<method name="Open">
<arg name="Args" type="as" direction="in"/>
</method>
</interface>
</node>
21 changes: 11 additions & 10 deletions assets/scripts/dde-file-manager
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

f="${1#file://}"
args=""
for arg in "$@"; do
args+="$arg,"
done

# dde-file-manager --show-item xxx
if [[ "$1" == "--show-item" ]]; then
dbus-send --print-reply --dest=org.freedesktop.FileManager1 /org/freedesktop/FileManager1 org.freedesktop.FileManager1.ShowItems "array:string:${@:2}" "string:"
# dde-file-manager /path/to/xxx or file:///path/to/xxx
elif [ -e "$f" ]; then
dbus-send --print-reply --dest=org.freedesktop.FileManager1 /org/freedesktop/FileManager1 org.freedesktop.FileManager1.ShowItems "array:string:$f" "string:"
else
exec /usr/libexec/dde-file-manager "$@"
fi
args=${args%,}

dbus-send --print-reply --dest=org.freedesktop.FileManager1 /org/freedesktop/FileManager1 org.freedesktop.FileManager1.Open array:string:"$args"

if [ $? -ne 0 ]; then
echo "dbus call failed"
exec file-manager.sh "$@"
fi
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,11 @@ void FileManager1DBus::Trash(const QStringList &URIs)
QJsonDocument doc(argsObj);
QProcess::startDetached("dde-file-manager", QStringList() << "--event" << doc.toJson());
}

void FileManager1DBus::Open(const QStringList &Args)
{
if (QProcess::startDetached("file-manager.sh", QStringList() << Args))
return;

QProcess::startDetached("dde-file-manager", QStringList() << Args);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public slots:
void ShowItemProperties(const QStringList &URIs, const QString &StartupId);
void ShowItems(const QStringList &URIs, const QString &StartupId);
void Trash(const QStringList &URIs);
void Open(const QStringList &Args);
};

#endif // FILEMANAGER1DBUS_H
Loading