summaryrefslogtreecommitdiff
path: root/src/caja-main.c
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2013-02-15 00:40:27 +0100
committerStefano Karapetsas <[email protected]>2013-02-15 00:40:27 +0100
commitf4efba80eeca027d782aa408e8ee96c44d5af76c (patch)
tree6f5fd7c46a3fe4363552003de6a6940dc05bb051 /src/caja-main.c
parent90c877576f3e8d9ba17327e667aadb60bf53012e (diff)
downloadcaja-f4efba80eeca027d782aa408e8ee96c44d5af76c.tar.bz2
caja-f4efba80eeca027d782aa408e8ee96c44d5af76c.tar.xz
Allow to open files with Caja using g_app_info_launch_default_for_uri
If there are only files to open, close Caja instead of open a default folder window Closes https://github.com/mate-desktop/mate-file-manager/issues/37
Diffstat (limited to 'src/caja-main.c')
-rw-r--r--src/caja-main.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/caja-main.c b/src/caja-main.c
index 3a99163f..70f050f9 100644
--- a/src/caja-main.c
+++ b/src/caja-main.c
@@ -330,6 +330,7 @@ main (int argc, char *argv[])
CajaApplication *application;
GOptionContext *context;
GFile *file;
+ GFileInfo *fileinfo;
char *uri;
char **uris;
GPtrArray *uris_array;
@@ -530,13 +531,29 @@ main (int argc, char *argv[])
if (file != NULL)
{
uri = g_file_get_uri (file);
- g_object_unref (file);
if (uri)
{
- g_ptr_array_add (uris_array, uri);
+ fileinfo = g_file_query_info (file, "standard::type", G_FILE_QUERY_INFO_NONE, NULL, NULL);
+ if (g_file_info_get_file_type(fileinfo) == G_FILE_TYPE_DIRECTORY)
+ {
+ g_ptr_array_add (uris_array, uri);
+ }
+ else
+ {
+ g_app_info_launch_default_for_uri (uri, NULL, NULL);
+ g_free (uri);
+ }
+ g_object_unref (fileinfo);
}
+ g_object_unref (file);
}
}
+ if (uris_array->len == 0)
+ {
+ /* Caja is being used only to open files (not directories), so closing */
+ g_strfreev (remaining);
+ return EXIT_SUCCESS;
+ }
g_ptr_array_add (uris_array, NULL);
uris = (char**) g_ptr_array_free (uris_array, FALSE);
g_strfreev (remaining);