Skip to content
This repository was archived by the owner on Sep 2, 2021. It is now read-only.
Closed
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
23 changes: 18 additions & 5 deletions appshell/appshell_extensions_gtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,20 +550,33 @@ int ShowFolderInOSWindow(ExtensionString pathname)
{
int error = NO_ERROR;
GError *gerror = NULL;
gchar *uri = g_strdup_printf("file://%s", pathname.c_str());
GFile* file = g_file_new_for_path(pathname.c_str());
GFile* parent = NULL;

if (!gtk_show_uri(NULL, uri, GDK_CURRENT_TIME, &gerror)) {
if (g_file_query_file_type(file, G_FILE_QUERY_INFO_NONE, NULL) == G_FILE_TYPE_REGULAR) {
parent = g_file_get_parent(file);
}

gchar *cmdline = g_strdup_printf("xdg-open file://%s",
parent ? g_file_get_path(parent) : g_file_get_path(file));

// run xdg-open and show the file in the default file browser
if (!g_spawn_command_line_async(cmdline, &gerror)) {
error = ConvertGnomeErrorCode(gerror);
g_warning("%s", gerror->message);
g_error_free(gerror);
}

g_free(uri);

if (parent) {
g_object_unref(parent);
}

g_object_unref(file);
g_free(cmdline);

return error;
}


int ConvertGnomeErrorCode(GError* gerror, bool isReading)
{
if (gerror == NULL)
Expand Down