summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2013-02-17 11:04:45 +0100
committerStefano Karapetsas <[email protected]>2013-02-17 11:04:45 +0100
commitcffbe9073f80f68c0d3defe72a23861ab639eba0 (patch)
treecb6dfbabb74fa763d5c2a1d7d68727a1b9430c6b
parentf4efba80eeca027d782aa408e8ee96c44d5af76c (diff)
downloadcaja-cffbe9073f80f68c0d3defe72a23861ab639eba0.tar.bz2
caja-cffbe9073f80f68c0d3defe72a23861ab639eba0.tar.xz
Check if caja is mistakenly set as default application for a content type, to avoid infinite loops
-rw-r--r--src/caja-main.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/caja-main.c b/src/caja-main.c
index 70f050f9..1d74cd78 100644
--- a/src/caja-main.c
+++ b/src/caja-main.c
@@ -331,6 +331,7 @@ main (int argc, char *argv[])
GOptionContext *context;
GFile *file;
GFileInfo *fileinfo;
+ GAppInfo *appinfo;
char *uri;
char **uris;
GPtrArray *uris_array;
@@ -533,14 +534,29 @@ main (int argc, char *argv[])
uri = g_file_get_uri (file);
if (uri)
{
- fileinfo = g_file_query_info (file, "standard::type", G_FILE_QUERY_INFO_NONE, NULL, NULL);
+ fileinfo = g_file_query_info (file, G_FILE_ATTRIBUTE_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_object_unref (fileinfo);
+ fileinfo = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL);
+ appinfo = g_app_info_get_default_for_type (g_file_info_get_content_type (fileinfo), TRUE);
+ if (appinfo)
+ {
+ if (g_strcmp0 (g_app_info_get_executable (appinfo), "caja") != 0)
+ {
+ g_app_info_launch_default_for_uri (uri, NULL, NULL);
+ }
+ else
+ {
+ fprintf (stderr, _("caja: set erroneously as default application for '%s' content type.\n"),
+ g_file_info_get_content_type (fileinfo));
+ }
+ g_object_unref (appinfo);
+ }
g_free (uri);
}
g_object_unref (fileinfo);