[Caja]: "Open Containing Folder" opens the file instead of the directory #4084

Closed
opened 2026-02-21 17:07:30 -05:00 by deekerman · 10 comments
Owner

Originally created by @zaps166 on GitHub (Mar 24, 2016).

Hi!

caja --no-desktop /path/to/file

opens the file instead of the directory with selected file (works properly with Nemo and Nautilus). This causes that the qBittorrent opens the file instead of the directory on Mate, so we have "Open" and "Open Containing Folder" which do the same thing. I suggest to remove the file name from the Caja command line in "Utils::Misc::openFolderSelect()".

Tested on:

  • Caja [1.10.4, 1.12.6, 1.13.1],
  • qBittorrent [3.3.3, 3.4.0-2f19594befa156f7b37e981f6bb0907d470a6e56].
Originally created by @zaps166 on GitHub (Mar 24, 2016). Hi! ``` caja --no-desktop /path/to/file ``` opens the file instead of the directory with selected file (works properly with Nemo and Nautilus). This causes that the qBittorrent opens the file instead of the directory on Mate, so we have "Open" and "Open Containing Folder" which do the same thing. I suggest to remove the file name from the Caja command line in "Utils::Misc::openFolderSelect()". Tested on: - Caja [1.10.4, 1.12.6, 1.13.1], - qBittorrent [3.3.3, 3.4.0-2f19594befa156f7b37e981f6bb0907d470a6e56].
Author
Owner

@Chocobo1 commented on GitHub (Mar 24, 2016):

Hmm, caja is forked from Nautilus but in this case it works different... maybe this should be a bug in caja? why they changed the behavior? (clearly users would want caja to point to the file, otherwise they would just exec the file in cmdline)

(as you pointed out) it's really easy to *fix it at our side, but that won't be optimal for users.

@Chocobo1 commented on GitHub (Mar 24, 2016): Hmm, caja is forked from Nautilus but in this case it works different... maybe this should be a bug in caja? why they changed the behavior? (clearly users would want caja to point to the file, otherwise they would just exec the file in cmdline) (as you pointed out) it's really easy to *fix it at our side, but that won't be optimal for users.
Author
Owner

@zaps166 commented on GitHub (Mar 24, 2016):

It looks like this commit: github.com/mate-desktop/caja@f4efba80ee add this "feautre" to Caja. Reverting this commit gives me an error message box, so event before Caja also can't open a directory and select the proper file.

Maybe it is not a Caja bug (please read the commit message), but the different behavior between Caja and Nautilus/Nemo... ?

Btw. I think that this Caja behavior is strange, but this is how does the Caja work...

@zaps166 commented on GitHub (Mar 24, 2016): It looks like this commit: https://github.com/mate-desktop/caja/commit/f4efba80eeca027d782aa408e8ee96c44d5af76c add this "feautre" to Caja. Reverting this commit gives me an error message box, so event before Caja also can't open a directory and select the proper file. Maybe it is not a Caja bug (please read the commit message), but the different behavior between Caja and Nautilus/Nemo... ? Btw. I think that this Caja behavior is strange, but this is how does the Caja work...
Author
Owner

@chrishirst commented on GitHub (Mar 25, 2016):

Thunar does exactly the same (Linux Mint 17.3 XFCE4)

Which apparently was due to using an "old" OS version. (#3827)

@chrishirst commented on GitHub (Mar 25, 2016): Thunar does exactly the same (Linux Mint 17.3 XFCE4) Which apparently was due to using an "old" OS version. (#3827)
Author
Owner

@ngosang commented on GitHub (Mar 25, 2016):

Just tested Caja 1.12.6 in Archlinux and it's working fine.
Open => It opens a file
Open Containing Folder => It opens the folder

@ngosang commented on GitHub (Mar 25, 2016): Just tested Caja 1.12.6 in Archlinux and it's working fine. Open => It opens a file Open Containing Folder => It opens the folder
Author
Owner

@zaps166 commented on GitHub (Mar 25, 2016):

On my ArchLinux (Caja 1.12.6) and new account (clean settings) qBittorrent opens a Gwenview (because it is a default file browser, I don't know why). Then if I change the default file browser in Mate Control Center to Caja, the qBittorrent executes "caja --no-desktop /path/to/file", so it opens a file instead of the directory (just tested again).
@ngosang please run in Mate environment caja --no-desktop /path/to/file - how does it work on your OS ?
qBittorrent works properly for Thunar, Dolphin, Gwenview, PCManFM, etc, but not for Caja...

@zaps166 commented on GitHub (Mar 25, 2016): On my ArchLinux (Caja 1.12.6) and _new_ account (clean settings) qBittorrent opens a Gwenview (because it is a default file browser, I don't know why). Then if I change the default file browser in Mate Control Center to Caja, the qBittorrent executes "caja --no-desktop /path/to/file", so it opens a file instead of the directory (just tested again). @ngosang please run in Mate environment `caja --no-desktop /path/to/file` - how does it work on your OS ? qBittorrent works properly for Thunar, Dolphin, Gwenview, PCManFM, etc, but not for Caja...
Author
Owner

@ngosang commented on GitHub (Mar 25, 2016):

I'm not using Mate environment, I'm using KDE 5 aka Plasma. I tried caja --no-desktop /path/to/file and caja /path/to/file and both are working. I see the folder.

@ngosang commented on GitHub (Mar 25, 2016): I'm not using Mate environment, I'm using KDE 5 aka Plasma. I tried `caja --no-desktop /path/to/file` and `caja /path/to/file` and both are working. I see the folder.
Author
Owner

@zaps166 commented on GitHub (Mar 25, 2016):

@ngosang very strange, I've tried on KF5(Plasma) - the behaviour is the same: Caja opens file instead of folder... I've also tried Mate on Arch Linux with default setting - the same problem.
I can see tha Caja sources: https://github.com/mate-desktop/caja/blob/master/src/caja-main.c#L581 - it opens the file (if the path points to the existing file and not to the directory).

Maybe g_app_info_launch_default_for_uri() works differently on your configuration?

The example code how does the Caja work:

#include <gio/gio.h>
#include <stdio.h>

int main()
{
    const char fileName[] = "/path/to/file";
    GFile *file = g_file_new_for_commandline_arg(fileName);
    if (file)
    {
        char *uri = g_file_get_uri(file);
        if (uri)
        {
            GFileInfo *fileinfo = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL);
            if (fileinfo && g_file_info_get_file_type(fileinfo) == G_FILE_TYPE_DIRECTORY)
            {
                fprintf(stderr, "Caja opens a directory (1st)\n");
            }
            else
            {
                if (fileinfo)
                    g_object_unref(fileinfo);
                fileinfo = g_file_query_info(file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL);
                if (fileinfo)
                {
                    GAppInfo *appinfo = g_app_info_get_default_for_type(g_file_info_get_content_type(fileinfo), true);
                    if (appinfo)
                    {
                        fprintf(stderr, "Caja opens a file\n");
                        g_app_info_launch_default_for_uri(uri, NULL, NULL);
                        g_object_unref(appinfo);
                    }
                }
                else
                {
                    fprintf(stderr, "Caja opens a directory (2nd)\n");
                }
            }
            if (fileinfo)
                g_object_unref(fileinfo);
            g_free(uri);
        }
        g_object_unref(file);
    }
}

And the qmake project:

TEMPLATE = app
SOURCES += main.cpp
CONFIG -= qt
CONFIG += link_pkgconfig
PKGCONFIG += gio-2.0

Could you try to run this example, please (if you have a time for this) :) ?

@zaps166 commented on GitHub (Mar 25, 2016): @ngosang very strange, I've tried on KF5(Plasma) - the behaviour is the same: Caja opens file instead of folder... I've also tried Mate on Arch Linux with default setting - the same problem. I can see tha Caja sources: https://github.com/mate-desktop/caja/blob/master/src/caja-main.c#L581 - it opens the file (if the path points to the existing file and not to the directory). Maybe `g_app_info_launch_default_for_uri()` works differently on your configuration? The example code how does the Caja work: ``` #include <gio/gio.h> #include <stdio.h> int main() { const char fileName[] = "/path/to/file"; GFile *file = g_file_new_for_commandline_arg(fileName); if (file) { char *uri = g_file_get_uri(file); if (uri) { GFileInfo *fileinfo = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL); if (fileinfo && g_file_info_get_file_type(fileinfo) == G_FILE_TYPE_DIRECTORY) { fprintf(stderr, "Caja opens a directory (1st)\n"); } else { if (fileinfo) g_object_unref(fileinfo); fileinfo = g_file_query_info(file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL); if (fileinfo) { GAppInfo *appinfo = g_app_info_get_default_for_type(g_file_info_get_content_type(fileinfo), true); if (appinfo) { fprintf(stderr, "Caja opens a file\n"); g_app_info_launch_default_for_uri(uri, NULL, NULL); g_object_unref(appinfo); } } else { fprintf(stderr, "Caja opens a directory (2nd)\n"); } } if (fileinfo) g_object_unref(fileinfo); g_free(uri); } g_object_unref(file); } } ``` And the qmake project: ``` TEMPLATE = app SOURCES += main.cpp CONFIG -= qt CONFIG += link_pkgconfig PKGCONFIG += gio-2.0 ``` Could you try to run this example, please (if you have a time for this) :) ?
Author
Owner

@ngosang commented on GitHub (Mar 25, 2016):

You are right caja --no-desktop /home/me/ open the folder caja --no-desktop /home/me/file.txt opens the file.

The thing is qBittorrent is working well for me because when I run:

xdg-mime query default inode/directory

I got => caja-2.desktop which is different to caja-folder-handler.desktop defined in https://github.com/qbittorrent/qBittorrent/blob/master/src/base/utils/misc.cpp#L595

qBittorrent tries to open the folder with the default file manager. The file is not highlighted but it opens the containing folder. https://github.com/qbittorrent/qBittorrent/blob/master/src/base/utils/misc.cpp#L602

@ngosang commented on GitHub (Mar 25, 2016): You are right `caja --no-desktop /home/me/` open the folder `caja --no-desktop /home/me/file.txt` opens the file. The thing is qBittorrent is working well for me because when I run: ``` xdg-mime query default inode/directory ``` I got => `caja-2.desktop` which is different to `caja-folder-handler.desktop` defined in https://github.com/qbittorrent/qBittorrent/blob/master/src/base/utils/misc.cpp#L595 qBittorrent tries to open the folder with the default file manager. The file is not highlighted but it opens the containing folder. https://github.com/qbittorrent/qBittorrent/blob/master/src/base/utils/misc.cpp#L602
Author
Owner

@Chocobo1 commented on GitHub (Mar 27, 2016):

@zaps166
I opened PR #5014, please take a look.

@Chocobo1 commented on GitHub (Mar 27, 2016): @zaps166 I opened PR #5014, please take a look.
Author
Owner

@zaps166 commented on GitHub (Mar 27, 2016):

@Chocobo1: PR is working properly for me!

@zaps166 commented on GitHub (Mar 27, 2016): @Chocobo1: PR is working properly for me!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/qBittorrent#4084
No description provided.