[glib] gdesktopappinfo: Large-scale whitespace fixup



commit c8e1dbb106e27653176a1692f05c287cd8ca0bfd
Author: Ryan Lortie <desrt desrt ca>
Date:   Sat Jul 27 15:08:58 2013 -0400

    gdesktopappinfo: Large-scale whitespace fixup
    
    Fix up a lot of whitespace issues in this file since we're about to do
    some pretty serious rewriting here anyway...
    
    Add some fold markers while we're at it.

 gio/gdesktopappinfo.c | 1208 +++++++++++++++++++++++++------------------------
 1 files changed, 626 insertions(+), 582 deletions(-)
---
diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
index 041a8e3..f6f5bc0 100644
--- a/gio/gdesktopappinfo.c
+++ b/gio/gdesktopappinfo.c
@@ -22,6 +22,8 @@
  *         Ryan Lortie <desrt desrt ca>
  */
 
+/* Prelude {{{1 */
+
 #include "config.h"
 
 #include <errno.h>
@@ -77,16 +79,16 @@ enum {
 
 static void     g_desktop_app_info_iface_init         (GAppInfoIface    *iface);
 static GList *  get_all_desktop_entries_for_mime_type (const char       *base_mime_type,
-                                                      const char      **except,
-                                                      gboolean          include_fallback,
+                                                       const char      **except,
+                                                       gboolean          include_fallback,
                                                        char            **explicit_default);
 static void     mime_info_cache_reload                (const char       *dir);
 static gboolean g_desktop_app_info_ensure_saved       (GDesktopAppInfo  *info,
-                                                      GError          **error);
+                                                       GError          **error);
 
 /**
  * GDesktopAppInfo:
- * 
+ *
  * Information about an installed application from a desktop file.
  */
 struct _GDesktopAppInfo
@@ -133,12 +135,13 @@ typedef enum {
 } UpdateMimeFlags;
 
 G_DEFINE_TYPE_WITH_CODE (GDesktopAppInfo, g_desktop_app_info, G_TYPE_OBJECT,
-                        G_IMPLEMENT_INTERFACE (G_TYPE_APP_INFO,
-                                               g_desktop_app_info_iface_init))
+                         G_IMPLEMENT_INTERFACE (G_TYPE_APP_INFO, g_desktop_app_info_iface_init))
 
 G_LOCK_DEFINE_STATIC (g_desktop_env);
 static gchar *g_desktop_env = NULL;
 
+/* DesktopFileDir implementation {{{1 */
+
 typedef struct
 {
   gchar                      *path;
@@ -147,6 +150,16 @@ typedef struct
 static DesktopFileDir *desktop_file_dirs;
 static guint           n_desktop_file_dirs;
 
+/* DesktopFileDir "API" {{{2 */
+
+/*< internal >
+ * desktop_file_dir_create:
+ * @array: the #GArray to add a new item to
+ * @data_dir: an XDG_DATA_DIR
+ *
+ * Creates a #DesktopFileDir for the corresponding @data_dir, adding it
+ * to @array.
+ */
 static void
 desktop_file_dir_create (GArray      *array,
                          const gchar *data_dir)
@@ -158,6 +171,8 @@ desktop_file_dir_create (GArray      *array,
   g_array_append_val (array, dir);
 }
 
+/* Global setup API {{{2 */
+
 static void
 desktop_file_dirs_refresh (void)
 {
@@ -183,6 +198,8 @@ desktop_file_dirs_refresh (void)
     }
 }
 
+/* GDesktopAppInfo implementation {{{1 */
+/* GObject implementation {{{2 */
 static void
 g_desktop_app_info_finalize (GObject *object)
 {
@@ -215,15 +232,15 @@ g_desktop_app_info_finalize (GObject *object)
   g_strfreev (info->mime_types);
   g_free (info->app_id);
   g_strfreev (info->actions);
-  
+
   G_OBJECT_CLASS (g_desktop_app_info_parent_class)->finalize (object);
 }
 
 static void
-g_desktop_app_info_set_property(GObject         *object,
-                               guint            prop_id,
-                               const GValue    *value,
-                               GParamSpec      *pspec)
+g_desktop_app_info_set_property (GObject      *object,
+                                 guint         prop_id,
+                                 const GValue *value,
+                                 GParamSpec   *pspec)
 {
   GDesktopAppInfo *self = G_DESKTOP_APP_INFO (object);
 
@@ -262,7 +279,7 @@ static void
 g_desktop_app_info_class_init (GDesktopAppInfoClass *klass)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-  
+
   gobject_class->get_property = g_desktop_app_info_get_property;
   gobject_class->set_property = g_desktop_app_info_set_property;
   gobject_class->finalize = g_desktop_app_info_finalize;
@@ -274,8 +291,7 @@ g_desktop_app_info_class_init (GDesktopAppInfoClass *klass)
    */
   g_object_class_install_property (gobject_class,
                                    PROP_FILENAME,
-                                   g_param_spec_string ("filename", "Filename", "",
-                                                       NULL,
+                                   g_param_spec_string ("filename", "Filename", "", NULL,
                                                         G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 }
 
@@ -284,25 +300,34 @@ g_desktop_app_info_init (GDesktopAppInfo *local)
 {
 }
 
+/* Construction... {{{2 */
+
+/*< internal >
+ * binary_from_exec:
+ * @exec: an exec line
+ *
+ * Returns the first word in an exec line (ie: the binary name).
+ *
+ * If @exec is "  progname --foo %F" then returns "progname".
+ */
 static char *
 binary_from_exec (const char *exec)
 {
   const char *p, *start;
-  
+
   p = exec;
   while (*p == ' ')
     p++;
   start = p;
   while (*p != ' ' && *p != 0)
     p++;
-  
+
   return g_strndup (start, p - start);
-  
 }
 
 static gboolean
-g_desktop_app_info_load_from_keyfile (GDesktopAppInfo *info, 
-                                     GKeyFile        *key_file)
+g_desktop_app_info_load_from_keyfile (GDesktopAppInfo *info,
+                                      GKeyFile        *key_file)
 {
   char *start_group;
   char *type;
@@ -338,10 +363,10 @@ g_desktop_app_info_load_from_keyfile (GDesktopAppInfo *info,
       char *t;
       t = g_find_program_in_path (try_exec);
       if (t == NULL)
-       {
-         g_free (try_exec);
-         return FALSE;
-       }
+        {
+          g_free (try_exec);
+          return FALSE;
+        }
       g_free (t);
     }
 
@@ -400,36 +425,36 @@ g_desktop_app_info_load_from_keyfile (GDesktopAppInfo *info,
   /* Remove the special-case: no Actions= key just means 0 extra actions */
   if (info->actions == NULL)
     info->actions = g_new0 (gchar *, 0 + 1);
- 
+
   info->icon = NULL;
   if (info->icon_name)
     {
       if (g_path_is_absolute (info->icon_name))
-       {
-         GFile *file;
-         
-         file = g_file_new_for_path (info->icon_name);
-         info->icon = g_file_icon_new (file);
-         g_object_unref (file);
-       }
+        {
+          GFile *file;
+
+          file = g_file_new_for_path (info->icon_name);
+          info->icon = g_file_icon_new (file);
+          g_object_unref (file);
+        }
       else
         {
           char *p;
 
-          /* Work around a common mistake in desktop files */    
+          /* Work around a common mistake in desktop files */
           if ((p = strrchr (info->icon_name, '.')) != NULL &&
               (strcmp (p, ".png") == 0 ||
                strcmp (p, ".xpm") == 0 ||
-               strcmp (p, ".svg") == 0)) 
+               strcmp (p, ".svg") == 0))
             *p = 0;
 
-         info->icon = g_themed_icon_new (info->icon_name);
+          info->icon = g_themed_icon_new (info->icon_name);
         }
     }
-  
+
   if (info->exec)
     info->binary = binary_from_exec (info->exec);
-  
+
   if (info->path && info->path[0] == '\0')
     {
       g_free (info->path);
@@ -472,13 +497,8 @@ g_desktop_app_info_load_file (GDesktopAppInfo *self)
 
   key_file = g_key_file_new ();
 
-  if (g_key_file_load_from_file (key_file,
-                                self->filename,
-                                G_KEY_FILE_NONE,
-                                NULL))
-    {
-      retval = g_desktop_app_info_load_from_keyfile (self, key_file);
-    }
+  if (g_key_file_load_from_file (key_file, self->filename, G_KEY_FILE_NONE, NULL))
+    retval = g_desktop_app_info_load_from_keyfile (self, key_file);
 
   g_key_file_unref (key_file);
   return retval;
@@ -512,7 +532,7 @@ g_desktop_app_info_new_from_keyfile (GKeyFile *key_file)
 /**
  * g_desktop_app_info_new_from_filename:
  * @filename: the path of a desktop file, in the GLib filename encoding
- * 
+ *
  * Creates a new #GDesktopAppInfo.
  *
  * Returns: a new #GDesktopAppInfo or %NULL on error.
@@ -534,19 +554,19 @@ g_desktop_app_info_new_from_filename (const char *filename)
 /**
  * g_desktop_app_info_new:
  * @desktop_id: the desktop file id
- * 
- * Creates a new #GDesktopAppInfo based on a desktop file id. 
  *
- * A desktop file id is the basename of the desktop file, including the 
- * .desktop extension. GIO is looking for a desktop file with this name 
+ * Creates a new #GDesktopAppInfo based on a desktop file id.
+ *
+ * A desktop file id is the basename of the desktop file, including the
+ * .desktop extension. GIO is looking for a desktop file with this name
  * in the <filename>applications</filename> subdirectories of the XDG data
- * directories (i.e. the directories specified in the 
- * <envar>XDG_DATA_HOME</envar> and <envar>XDG_DATA_DIRS</envar> environment 
+ * directories (i.e. the directories specified in the
+ * <envar>XDG_DATA_HOME</envar> and <envar>XDG_DATA_DIRS</envar> environment
  * variables). GIO also supports the prefix-to-subdirectory mapping that is
- * described in the <ulink url="http://standards.freedesktop.org/menu-spec/latest/";>Menu Spec</ulink> 
+ * described in the <ulink url="http://standards.freedesktop.org/menu-spec/latest/";>Menu Spec</ulink>
  * (i.e. a desktop id of kde-foo.desktop will match
  * <filename>/usr/share/applications/kde/foo.desktop</filename>).
- * 
+ *
  * Returns: a new #GDesktopAppInfo, or %NULL if no desktop file with that id
  */
 GDesktopAppInfo *
@@ -601,7 +621,7 @@ g_desktop_app_info_new (const char *desktop_id)
       g_object_unref (appinfo);
       appinfo = NULL;
     }
-  
+
   return appinfo;
 }
 
@@ -610,7 +630,7 @@ g_desktop_app_info_dup (GAppInfo *appinfo)
 {
   GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
   GDesktopAppInfo *new_info;
-  
+
   new_info = g_object_new (G_TYPE_DESKTOP_APP_INFO, NULL);
 
   new_info->filename = g_strdup (info->filename);
@@ -638,13 +658,15 @@ g_desktop_app_info_dup (GAppInfo *appinfo)
   new_info->hidden = info->hidden;
   new_info->terminal = info->terminal;
   new_info->startup_notify = info->startup_notify;
-  
+
   return G_APP_INFO (new_info);
 }
 
+/* GAppInfo interface implementation functions {{{2 */
+
 static gboolean
 g_desktop_app_info_equal (GAppInfo *appinfo1,
-                         GAppInfo *appinfo2)
+                          GAppInfo *appinfo2)
 {
   GDesktopAppInfo *info1 = G_DESKTOP_APP_INFO (appinfo1);
   GDesktopAppInfo *info2 = G_DESKTOP_APP_INFO (appinfo2);
@@ -691,7 +713,7 @@ g_desktop_app_info_get_display_name (GAppInfo *appinfo)
  * A desktop file is hidden if the Hidden key in it is
  * set to True.
  *
- * Returns: %TRUE if hidden, %FALSE otherwise. 
+ * Returns: %TRUE if hidden, %FALSE otherwise.
  **/
 gboolean
 g_desktop_app_info_get_is_hidden (GDesktopAppInfo *info)
@@ -720,7 +742,7 @@ static const char *
 g_desktop_app_info_get_description (GAppInfo *appinfo)
 {
   GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
-  
+
   return info->comment;
 }
 
@@ -728,7 +750,7 @@ static const char *
 g_desktop_app_info_get_executable (GAppInfo *appinfo)
 {
   GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
-  
+
   return info->binary;
 }
 
@@ -736,7 +758,7 @@ static const char *
 g_desktop_app_info_get_commandline (GAppInfo *appinfo)
 {
   GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
-  
+
   return info->exec;
 }
 
@@ -850,33 +872,35 @@ g_desktop_app_info_get_show_in (GDesktopAppInfo *info,
   if (info->only_show_in)
     {
       if (desktop_env == NULL)
-       return FALSE;
+        return FALSE;
 
       found = FALSE;
       for (i = 0; info->only_show_in[i] != NULL; i++)
-       {
-         if (strcmp (info->only_show_in[i], desktop_env) == 0)
-           {
-             found = TRUE;
-             break;
-           }
-       }
+        {
+          if (strcmp (info->only_show_in[i], desktop_env) == 0)
+            {
+              found = TRUE;
+              break;
+            }
+        }
       if (!found)
-       return FALSE;
+        return FALSE;
     }
 
   if (info->not_show_in && desktop_env)
     {
       for (i = 0; info->not_show_in[i] != NULL; i++)
-       {
-         if (strcmp (info->not_show_in[i], desktop_env) == 0)
-           return FALSE;
-       }
+        {
+          if (strcmp (info->not_show_in[i], desktop_env) == 0)
+            return FALSE;
+        }
     }
 
   return TRUE;
 }
 
+/* Launching... {{{2 */
+
 static char *
 expand_macro_single (char macro, char *uri)
 {
@@ -886,18 +910,18 @@ expand_macro_single (char macro, char *uri)
   char *name;
 
   file = g_file_new_for_uri (uri);
-  
+
   switch (macro)
     {
     case 'u':
-    case 'U':  
+    case 'U':
       result = g_shell_quote (uri);
       break;
     case 'f':
     case 'F':
       path = g_file_get_path (file);
       if (path)
-       result = g_shell_quote (path);
+        result = g_shell_quote (path);
       break;
     case 'd':
     case 'D':
@@ -905,7 +929,7 @@ expand_macro_single (char macro, char *uri)
       if (path)
         {
           name = g_path_get_dirname (path);
-         result = g_shell_quote (name);
+          result = g_shell_quote (name);
           g_free (name);
         }
       break;
@@ -915,7 +939,7 @@ expand_macro_single (char macro, char *uri)
       if (path)
         {
           name = g_path_get_basename (path);
-         result = g_shell_quote (name);
+          result = g_shell_quote (name);
           g_free (name);
         }
       break;
@@ -923,14 +947,14 @@ expand_macro_single (char macro, char *uri)
 
   g_object_unref (file);
   g_free (path);
-  
+
   return result;
 }
 
 static void
-expand_macro (char              macro, 
-              GString          *exec, 
-              GDesktopAppInfo  *info, 
+expand_macro (char              macro,
+              GString          *exec,
+              GDesktopAppInfo  *info,
               GList           **uri_list)
 {
   GList *uris = *uri_list;
@@ -951,18 +975,18 @@ expand_macro (char              macro,
   if (!info->no_fuse)
     {
       switch (macro)
-       {
-       case 'u':
-         force_file_uri_macro = 'f';
-         force_file_uri = TRUE;
-         break;
-       case 'U':
-         force_file_uri_macro = 'F';
-         force_file_uri = TRUE;
-         break;
-       default:
-         break;
-       }
+        {
+        case 'u':
+          force_file_uri_macro = 'f';
+          force_file_uri = TRUE;
+          break;
+        case 'U':
+          force_file_uri_macro = 'F';
+          force_file_uri = TRUE;
+          break;
+        default:
+          break;
+        }
     }
 
   switch (macro)
@@ -972,11 +996,11 @@ expand_macro (char              macro,
     case 'd':
     case 'n':
       if (uris)
-       {
-         uri = uris->data;
+        {
+          uri = uris->data;
           if (!force_file_uri ||
-             /* Pass URI if it contains an anchor */
-             strchr (uri, '#') != NULL)
+              /* Pass URI if it contains an anchor */
+              strchr (uri, '#') != NULL)
             {
               expanded = expand_macro_single (macro, uri);
             }
@@ -987,27 +1011,27 @@ expand_macro (char              macro,
                 expanded = expand_macro_single (macro, uri);
             }
 
-         if (expanded)
-           {
-             g_string_append (exec, expanded);
-             g_free (expanded);
-           }
-         uris = uris->next;
-       }
+          if (expanded)
+            {
+              g_string_append (exec, expanded);
+              g_free (expanded);
+            }
+          uris = uris->next;
+        }
 
       break;
 
-    case 'U':  
+    case 'U':
     case 'F':
     case 'D':
     case 'N':
       while (uris)
-       {
-         uri = uris->data;
-         
+        {
+          uri = uris->data;
+
           if (!force_file_uri ||
-             /* Pass URI if it contains an anchor */
-             strchr (uri, '#') != NULL)
+              /* Pass URI if it contains an anchor */
+              strchr (uri, '#') != NULL)
             {
               expanded = expand_macro_single (macro, uri);
             }
@@ -1018,44 +1042,44 @@ expand_macro (char              macro,
                 expanded = expand_macro_single (macro, uri);
             }
 
-         if (expanded)
-           {
-             g_string_append (exec, expanded);
-             g_free (expanded);
-           }
-         
-         uris = uris->next;
-         
-         if (uris != NULL && expanded)
-           g_string_append_c (exec, ' ');
-       }
+          if (expanded)
+            {
+              g_string_append (exec, expanded);
+              g_free (expanded);
+            }
+
+          uris = uris->next;
+
+          if (uris != NULL && expanded)
+            g_string_append_c (exec, ' ');
+        }
 
       break;
 
     case 'i':
       if (info->icon_name)
-       {
-         g_string_append (exec, "--icon ");
+        {
+          g_string_append (exec, "--icon ");
           expanded = g_shell_quote (info->icon_name);
-         g_string_append (exec, expanded);
+          g_string_append (exec, expanded);
           g_free (expanded);
-       }
+        }
       break;
 
     case 'c':
-      if (info->name) 
+      if (info->name)
         {
           expanded = g_shell_quote (info->name);
-         g_string_append (exec, expanded);
+          g_string_append (exec, expanded);
           g_free (expanded);
         }
       break;
 
     case 'k':
-      if (info->filename) 
+      if (info->filename)
         {
           expanded = g_shell_quote (info->filename);
-         g_string_append (exec, expanded);
+          g_string_append (exec, expanded);
           g_free (expanded);
         }
       break;
@@ -1067,17 +1091,17 @@ expand_macro (char              macro,
       g_string_append_c (exec, '%');
       break;
     }
-  
+
   *uri_list = uris;
 }
 
 static gboolean
 expand_application_parameters (GDesktopAppInfo   *info,
                                const gchar       *exec_line,
-                              GList            **uris,
-                              int               *argc,
-                              char            ***argv,
-                              GError           **error)
+                               GList            **uris,
+                               int               *argc,
+                               char            ***argv,
+                               GError           **error)
 {
   GList *uri_list = *uris;
   const char *p = exec_line;
@@ -1096,12 +1120,12 @@ expand_application_parameters (GDesktopAppInfo   *info,
   while (*p)
     {
       if (p[0] == '%' && p[1] != '\0')
-       {
-         expand_macro (p[1], expanded_exec, info, uris);
-         p++;
-       }
+        {
+          expand_macro (p[1], expanded_exec, info, uris);
+          p++;
+        }
       else
-       g_string_append_c (expanded_exec, *p);
+        g_string_append_c (expanded_exec, *p);
 
       p++;
     }
@@ -1121,7 +1145,7 @@ expand_application_parameters (GDesktopAppInfo   *info,
 
 static gboolean
 prepend_terminal_to_vector (int    *argc,
-                           char ***argv)
+                            char ***argv)
 {
 #ifndef G_OS_WIN32
   char **real_argv;
@@ -1131,24 +1155,24 @@ prepend_terminal_to_vector (int    *argc,
   int term_argc = 0;
   char *check;
   char **the_argv;
-  
+
   g_return_val_if_fail (argc != NULL, FALSE);
   g_return_val_if_fail (argv != NULL, FALSE);
-       
+
   /* sanity */
   if(*argv == NULL)
     *argc = 0;
-  
+
   the_argv = *argv;
 
   /* compute size if not given */
   if (*argc < 0)
     {
       for (i = 0; the_argv[i] != NULL; i++)
-       ;
+        ;
       *argc = i;
     }
-  
+
   term_argc = 2;
   term_argv = g_new0 (char *, 3);
 
@@ -1163,39 +1187,39 @@ prepend_terminal_to_vector (int    *argc,
   else
     {
       if (check == NULL)
-       check = g_find_program_in_path ("nxterm");
+        check = g_find_program_in_path ("nxterm");
       if (check == NULL)
-       check = g_find_program_in_path ("color-xterm");
+        check = g_find_program_in_path ("color-xterm");
       if (check == NULL)
-       check = g_find_program_in_path ("rxvt");
+        check = g_find_program_in_path ("rxvt");
       if (check == NULL)
-       check = g_find_program_in_path ("xterm");
+        check = g_find_program_in_path ("xterm");
       if (check == NULL)
-       check = g_find_program_in_path ("dtterm");
+        check = g_find_program_in_path ("dtterm");
       if (check == NULL)
-       {
-         check = g_strdup ("xterm");
-         g_warning ("couldn't find a terminal, falling back to xterm");
-       }
+        {
+          check = g_strdup ("xterm");
+          g_warning ("couldn't find a terminal, falling back to xterm");
+        }
       term_argv[0] = check;
       term_argv[1] = g_strdup ("-e");
     }
 
   real_argc = term_argc + *argc;
   real_argv = g_new (char *, real_argc + 1);
-  
+
   for (i = 0; i < term_argc; i++)
     real_argv[i] = term_argv[i];
-  
+
   for (j = 0; j < *argc; j++, i++)
     real_argv[i] = (char *)the_argv[j];
-  
+
   real_argv[i] = NULL;
-  
+
   g_free (*argv);
   *argv = real_argv;
   *argc = real_argc;
-  
+
   /* we use g_free here as we sucked all the inner strings
    * out from it into real_argv */
   g_free (term_argv);
@@ -1259,11 +1283,11 @@ child_setup (gpointer user_data)
 
 static void
 notify_desktop_launch (GDBusConnection  *session_bus,
-                      GDesktopAppInfo  *info,
-                      long              pid,
-                      const char       *display,
-                      const char       *sn_id,
-                      GList            *uris)
+                       GDesktopAppInfo  *info,
+                       long              pid,
+                       const char       *display,
+                       const char       *sn_id,
+                       GList            *uris)
 {
   GDBusMessage *msg;
   GVariantBuilder uri_variant;
@@ -1282,22 +1306,22 @@ notify_desktop_launch (GDBusConnection  *session_bus,
   g_variant_builder_init (&extras_variant, G_VARIANT_TYPE ("a{sv}"));
   if (sn_id != NULL && g_utf8_validate (sn_id, -1, NULL))
     g_variant_builder_add (&extras_variant, "{sv}",
-                          "startup-id",
-                          g_variant_new ("s",
-                                         sn_id));
+                           "startup-id",
+                           g_variant_new ("s",
+                                          sn_id));
   gio_desktop_file = g_getenv ("GIO_LAUNCHED_DESKTOP_FILE");
   if (gio_desktop_file != NULL)
     g_variant_builder_add (&extras_variant, "{sv}",
-                          "origin-desktop-file",
-                          g_variant_new_bytestring (gio_desktop_file));
+                           "origin-desktop-file",
+                           g_variant_new_bytestring (gio_desktop_file));
   if (g_get_prgname () != NULL)
     g_variant_builder_add (&extras_variant, "{sv}",
-                          "origin-prgname",
-                          g_variant_new_bytestring (g_get_prgname ()));
+                           "origin-prgname",
+                           g_variant_new_bytestring (g_get_prgname ()));
   g_variant_builder_add (&extras_variant, "{sv}",
-                        "origin-pid",
-                        g_variant_new ("x",
-                                       (gint64)getpid ()));
+                         "origin-pid",
+                         g_variant_new ("x",
+                                        (gint64)getpid ()));
 
   if (info->filename)
     desktop_file_id = info->filename;
@@ -1305,20 +1329,20 @@ notify_desktop_launch (GDBusConnection  *session_bus,
     desktop_file_id = info->desktop_id;
   else
     desktop_file_id = "";
-  
+
   msg = g_dbus_message_new_signal ("/org/gtk/gio/DesktopAppInfo",
-                                  "org.gtk.gio.DesktopAppInfo",
-                                  "Launched");
+                                   "org.gtk.gio.DesktopAppInfo",
+                                   "Launched");
   g_dbus_message_set_body (msg, g_variant_new ("(@aysxasa{sv})",
-                                              g_variant_new_bytestring (desktop_file_id),
-                                              display ? display : "",
-                                              (gint64)pid,
-                                              &uri_variant,
-                                              &extras_variant));
+                                               g_variant_new_bytestring (desktop_file_id),
+                                               display ? display : "",
+                                               (gint64)pid,
+                                               &uri_variant,
+                                               &extras_variant));
   g_dbus_connection_send_message (session_bus,
-                                 msg, 0,
-                                 NULL,
-                                 NULL);
+                                  msg, 0,
+                                  NULL,
+                                  NULL);
   g_object_unref (msg);
 }
 
@@ -1428,18 +1452,18 @@ g_desktop_app_info_launch_uris_with_spawn (GDesktopAppInfo            *info,
                           &pid,
                           error))
         {
-         if (sn_id)
-           g_app_launch_context_launch_failed (launch_context, sn_id);
+          if (sn_id)
+            g_app_launch_context_launch_failed (launch_context, sn_id);
 
-         g_free (display);
-         g_free (sn_id);
-         g_list_free (launched_uris);
+          g_free (display);
+          g_free (sn_id);
+          g_list_free (launched_uris);
 
-         goto out;
-       }
+          goto out;
+        }
 
       if (pid_callback != NULL)
-       pid_callback (info, pid, pid_callback_data);
+        pid_callback (info, pid, pid_callback_data);
 
       if (launch_context != NULL)
         {
@@ -1456,11 +1480,11 @@ g_desktop_app_info_launch_uris_with_spawn (GDesktopAppInfo            *info,
         }
 
       notify_desktop_launch (session_bus,
-                            info,
-                            pid,
-                            display,
-                            sn_id,
-                            launched_uris);
+                             info,
+                             pid,
+                             display,
+                             sn_id,
+                             launched_uris);
 
       g_free (display);
       g_free (sn_id);
@@ -1606,9 +1630,9 @@ g_desktop_app_info_launch_uris_internal (GAppInfo                   *appinfo,
 
 static gboolean
 g_desktop_app_info_launch_uris (GAppInfo           *appinfo,
-                               GList              *uris,
-                               GAppLaunchContext  *launch_context,
-                               GError            **error)
+                                GList              *uris,
+                                GAppLaunchContext  *launch_context,
+                                GError            **error)
 {
   return g_desktop_app_info_launch_uris_internal (appinfo, uris,
                                                   launch_context,
@@ -1621,8 +1645,8 @@ static gboolean
 g_desktop_app_info_supports_uris (GAppInfo *appinfo)
 {
   GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
- 
-  return info->exec && 
+
+  return info->exec &&
     ((strstr (info->exec, "%u") != NULL) ||
      (strstr (info->exec, "%U") != NULL));
 }
@@ -1631,17 +1655,17 @@ static gboolean
 g_desktop_app_info_supports_files (GAppInfo *appinfo)
 {
   GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
- 
-  return info->exec && 
+
+  return info->exec &&
     ((strstr (info->exec, "%f") != NULL) ||
      (strstr (info->exec, "%F") != NULL));
 }
 
 static gboolean
 g_desktop_app_info_launch (GAppInfo           *appinfo,
-                          GList              *files,
-                          GAppLaunchContext  *launch_context,
-                          GError            **error)
+                           GList              *files,
+                           GAppLaunchContext  *launch_context,
+                           GError            **error)
 {
   GList *uris;
   char *uri;
@@ -1654,13 +1678,13 @@ g_desktop_app_info_launch (GAppInfo           *appinfo,
       uris = g_list_prepend (uris, uri);
       files = files->next;
     }
-  
+
   uris = g_list_reverse (uris);
-  
+
   res = g_desktop_app_info_launch_uris (appinfo, uris, launch_context, error);
-  
+
   g_list_free_full (uris, g_free);
-  
+
   return res;
 }
 
@@ -1696,14 +1720,14 @@ g_desktop_app_info_launch (GAppInfo           *appinfo,
  */
 gboolean
 g_desktop_app_info_launch_uris_as_manager (GDesktopAppInfo            *appinfo,
-                                          GList                      *uris,
-                                          GAppLaunchContext          *launch_context,
-                                          GSpawnFlags                 spawn_flags,
-                                          GSpawnChildSetupFunc        user_setup,
-                                          gpointer                    user_setup_data,
-                                          GDesktopAppLaunchCallback   pid_callback,
-                                          gpointer                    pid_callback_data,
-                                          GError                    **error)
+                                           GList                      *uris,
+                                           GAppLaunchContext          *launch_context,
+                                           GSpawnFlags                 spawn_flags,
+                                           GSpawnChildSetupFunc        user_setup,
+                                           gpointer                    user_setup_data,
+                                           GDesktopAppLaunchCallback   pid_callback,
+                                           gpointer                    pid_callback_data,
+                                           GError                    **error)
 {
   return g_desktop_app_info_launch_uris_internal ((GAppInfo*)appinfo,
                                                   uris,
@@ -1716,6 +1740,8 @@ g_desktop_app_info_launch_uris_as_manager (GDesktopAppInfo            *appinfo,
                                                   error);
 }
 
+/* OnlyShowIn API support {{{2 */
+
 /**
  * g_desktop_app_info_set_desktop_env:
  * @desktop_env: a string specifying what desktop this is
@@ -1760,6 +1786,8 @@ g_desktop_app_info_should_show (GAppInfo *appinfo)
   return g_desktop_app_info_get_show_in (info, NULL);
 }
 
+/* mime types/default apps support {{{2 */
+
 typedef enum {
   APP_DIR,
   MIMETYPE_DIR
@@ -1799,10 +1827,10 @@ ensure_dir (DirType   type,
 }
 
 static gboolean
-update_mimeapps_list (const char  *desktop_id, 
-                     const char  *content_type,
+update_mimeapps_list (const char  *desktop_id,
+                      const char  *content_type,
                       UpdateMimeFlags flags,
-                     GError     **error)
+                      GError     **error)
 {
   char *dirname, *filename, *string;
   GKeyFile *key_file;
@@ -1887,14 +1915,14 @@ update_mimeapps_list (const char  *desktop_id,
       g_strfreev (content_types);
       content_types = g_key_file_get_keys (key_file, ADDED_ASSOCIATIONS_GROUP, NULL, NULL);
     }
-  
+
   for (k = 0; content_types && content_types[k]; k++)
-    { 
+    {
       /* Add to the right place in the list */
-  
+
       length = 0;
       old_list = g_key_file_get_string_list (key_file, ADDED_ASSOCIATIONS_GROUP,
-                                            content_types[k], &length, NULL);
+                                             content_types[k], &length, NULL);
 
       list = g_new (char *, 1 + length + 1);
 
@@ -1913,21 +1941,21 @@ update_mimeapps_list (const char  *desktop_id,
       if (old_list)
         {
           for (j = 0; old_list[j] != NULL; j++)
-           {
-             if (g_strcmp0 (old_list[j], desktop_id) != 0)
+            {
+              if (g_strcmp0 (old_list[j], desktop_id) != 0)
                 {
                   /* rewrite other entries if they're different from the new one */
                   list[i++] = g_strdup (old_list[j]);
                 }
-             else if (flags & UPDATE_MIME_SET_NON_DEFAULT)
-               {
+              else if (flags & UPDATE_MIME_SET_NON_DEFAULT)
+                {
                   /* we encountered an old entry which is equal to the one we're adding as non-default,
                    * don't change its position in the list.
                    */
-                 flags ^= UPDATE_MIME_SET_NON_DEFAULT;
-                 list[i++] = g_strdup (old_list[j]);
-               }
-           }
+                  flags ^= UPDATE_MIME_SET_NON_DEFAULT;
+                  list[i++] = g_strdup (old_list[j]);
+                }
+            }
         }
 
       /* add it at the end of the list */
@@ -1935,14 +1963,14 @@ update_mimeapps_list (const char  *desktop_id,
         list[i++] = g_strdup (desktop_id);
 
       list[i] = NULL;
-  
+
       g_strfreev (old_list);
 
       if (list[0] == NULL || desktop_id == NULL)
         g_key_file_remove_key (key_file,
-                              ADDED_ASSOCIATIONS_GROUP,
-                              content_types[k],
-                              NULL);
+                               ADDED_ASSOCIATIONS_GROUP,
+                               content_types[k],
+                               NULL);
       else
         g_key_file_set_string_list (key_file,
                                     ADDED_ASSOCIATIONS_GROUP,
@@ -1951,7 +1979,7 @@ update_mimeapps_list (const char  *desktop_id,
 
       g_strfreev (list);
     }
-  
+
   if (content_type)
     {
       /* reuse the list from above */
@@ -1962,13 +1990,13 @@ update_mimeapps_list (const char  *desktop_id,
       content_types = g_key_file_get_keys (key_file, REMOVED_ASSOCIATIONS_GROUP, NULL, NULL);
     }
 
-  for (k = 0; content_types && content_types[k]; k++) 
+  for (k = 0; content_types && content_types[k]; k++)
     {
       /* Remove from removed associations group (unless remove) */
-  
+
       length = 0;
       old_list = g_key_file_get_string_list (key_file, REMOVED_ASSOCIATIONS_GROUP,
-                                            content_types[k], &length, NULL);
+                                             content_types[k], &length, NULL);
 
       list = g_new (char *, 1 + length + 1);
 
@@ -1978,25 +2006,25 @@ update_mimeapps_list (const char  *desktop_id,
       if (old_list)
         {
           for (j = 0; old_list[j] != NULL; j++)
-           {
-             if (g_strcmp0 (old_list[j], desktop_id) != 0)
-               list[i++] = g_strdup (old_list[j]);
-           }
+            {
+              if (g_strcmp0 (old_list[j], desktop_id) != 0)
+                list[i++] = g_strdup (old_list[j]);
+            }
         }
       list[i] = NULL;
-  
+
       g_strfreev (old_list);
 
       if (list[0] == NULL || desktop_id == NULL)
         g_key_file_remove_key (key_file,
-                              REMOVED_ASSOCIATIONS_GROUP,
-                              content_types[k],
-                              NULL);
+                               REMOVED_ASSOCIATIONS_GROUP,
+                               content_types[k],
+                               NULL);
       else
         g_key_file_set_string_list (key_file,
-                                   REMOVED_ASSOCIATIONS_GROUP,
-                                   content_types[k],
-                                   (const char * const *)list, i);
+                                    REMOVED_ASSOCIATIONS_GROUP,
+                                    content_types[k],
+                                    (const char * const *)list, i);
 
       g_strfreev (list);
     }
@@ -2042,8 +2070,8 @@ g_desktop_app_info_set_as_last_used_for_type (GAppInfo    *appinfo,
 
 static gboolean
 g_desktop_app_info_set_as_default_for_type (GAppInfo    *appinfo,
-                                           const char  *content_type,
-                                           GError     **error)
+                                            const char  *content_type,
+                                            GError     **error)
 {
   GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
 
@@ -2064,8 +2092,8 @@ g_desktop_app_info_set_as_default_for_type (GAppInfo    *appinfo,
 
 static void
 update_program_done (GPid     pid,
-                    gint     status,
-                    gpointer data)
+                     gint     status,
+                     gpointer data)
 {
   /* Did the application exit correctly */
   if (g_spawn_check_exit_status (status, NULL))
@@ -2076,67 +2104,67 @@ update_program_done (GPid     pid,
 
 static void
 run_update_command (char *command,
-                   char *subdir)
-{
-       char *argv[3] = {
-               NULL,
-               NULL,
-               NULL,
-       };
-       GPid pid = 0;
-       GError *error = NULL;
-
-       argv[0] = command;
-       argv[1] = g_build_filename (g_get_user_data_dir (), subdir, NULL);
-
-       if (g_spawn_async ("/", argv,
-                          NULL,       /* envp */
-                          G_SPAWN_SEARCH_PATH |
-                          G_SPAWN_STDOUT_TO_DEV_NULL |
-                          G_SPAWN_STDERR_TO_DEV_NULL |
-                          G_SPAWN_DO_NOT_REAP_CHILD,
-                          NULL, NULL, /* No setup function */
-                          &pid,
-                          &error)) 
-         g_child_watch_add (pid, update_program_done, NULL);
-       else
-         {
-           /* If we get an error at this point, it's quite likely the user doesn't
-            * have an installed copy of either 'update-mime-database' or
-            * 'update-desktop-database'.  I don't think we want to popup an error
-            * dialog at this point, so we just do a g_warning to give the user a
-            * chance of debugging it.
-            */
-           g_warning ("%s", error->message);
-         }
-       
-       g_free (argv[1]);
+                    char *subdir)
+{
+        char *argv[3] = {
+                NULL,
+                NULL,
+                NULL,
+        };
+        GPid pid = 0;
+        GError *error = NULL;
+
+        argv[0] = command;
+        argv[1] = g_build_filename (g_get_user_data_dir (), subdir, NULL);
+
+        if (g_spawn_async ("/", argv,
+                           NULL,       /* envp */
+                           G_SPAWN_SEARCH_PATH |
+                           G_SPAWN_STDOUT_TO_DEV_NULL |
+                           G_SPAWN_STDERR_TO_DEV_NULL |
+                           G_SPAWN_DO_NOT_REAP_CHILD,
+                           NULL, NULL, /* No setup function */
+                           &pid,
+                           &error))
+          g_child_watch_add (pid, update_program_done, NULL);
+        else
+          {
+            /* If we get an error at this point, it's quite likely the user doesn't
+             * have an installed copy of either 'update-mime-database' or
+             * 'update-desktop-database'.  I don't think we want to popup an error
+             * dialog at this point, so we just do a g_warning to give the user a
+             * chance of debugging it.
+             */
+            g_warning ("%s", error->message);
+          }
+
+        g_free (argv[1]);
 }
 
 static gboolean
 g_desktop_app_info_set_as_default_for_extension (GAppInfo    *appinfo,
-                                                const char  *extension,
-                                                GError     **error)
+                                                 const char  *extension,
+                                                 GError     **error)
 {
   char *filename, *basename, *mimetype;
   char *dirname;
   gboolean res;
 
   if (!g_desktop_app_info_ensure_saved (G_DESKTOP_APP_INFO (appinfo), error))
-    return FALSE;  
-  
+    return FALSE;
+
   dirname = ensure_dir (MIMETYPE_DIR, error);
   if (!dirname)
     return FALSE;
-  
+
   basename = g_strdup_printf ("user-extension-%s.xml", extension);
   filename = g_build_filename (dirname, basename, NULL);
   g_free (basename);
   g_free (dirname);
 
   mimetype = g_strdup_printf ("application/x-extension-%s", extension);
-  
-  if (!g_file_test (filename, G_FILE_TEST_EXISTS)) 
+
+  if (!g_file_test (filename, G_FILE_TEST_EXISTS))
     {
       char *contents;
 
@@ -2155,26 +2183,26 @@ g_desktop_app_info_set_as_default_for_extension (GAppInfo    *appinfo,
       run_update_command ("update-mime-database", "mime");
     }
   g_free (filename);
-  
+
   res = g_desktop_app_info_set_as_default_for_type (appinfo,
-                                                   mimetype,
-                                                   error);
+                                                    mimetype,
+                                                    error);
 
   g_free (mimetype);
-  
+
   return res;
 }
 
 static gboolean
 g_desktop_app_info_add_supports_type (GAppInfo    *appinfo,
-                                     const char  *content_type,
-                                     GError     **error)
+                                      const char  *content_type,
+                                      GError     **error)
 {
   GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
 
   if (!g_desktop_app_info_ensure_saved (G_DESKTOP_APP_INFO (info), error))
-    return FALSE;  
-  
+    return FALSE;
+
   return update_mimeapps_list (info->desktop_id, content_type,
                                UPDATE_MIME_SET_NON_DEFAULT,
                                error);
@@ -2188,14 +2216,14 @@ g_desktop_app_info_can_remove_supports_type (GAppInfo *appinfo)
 
 static gboolean
 g_desktop_app_info_remove_supports_type (GAppInfo    *appinfo,
-                                        const char  *content_type,
-                                        GError     **error)
+                                         const char  *content_type,
+                                         GError     **error)
 {
   GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
 
   if (!g_desktop_app_info_ensure_saved (G_DESKTOP_APP_INFO (info), error))
     return FALSE;
-  
+
   return update_mimeapps_list (info->desktop_id, content_type,
                                UPDATE_MIME_REMOVE,
                                error);
@@ -2209,10 +2237,11 @@ g_desktop_app_info_get_supported_types (GAppInfo *appinfo)
   return (const char**) info->mime_types;
 }
 
+/* Saving and deleting {{{2 */
 
 static gboolean
 g_desktop_app_info_ensure_saved (GDesktopAppInfo  *info,
-                                GError          **error)
+                                 GError          **error)
 {
   GKeyFile *key_file;
   char *dirname;
@@ -2221,7 +2250,7 @@ g_desktop_app_info_ensure_saved (GDesktopAppInfo  *info,
   gsize data_size;
   int fd;
   gboolean res;
-  
+
   if (info->filename != NULL)
     return TRUE;
 
@@ -2229,46 +2258,46 @@ g_desktop_app_info_ensure_saved (GDesktopAppInfo  *info,
    * g_app_info_create_from_commandline. All other
    * object should have a filename
    */
-  
+
   dirname = ensure_dir (APP_DIR, error);
   if (!dirname)
     return FALSE;
-  
+
   key_file = g_key_file_new ();
 
   g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP,
-                        "Encoding", "UTF-8");
+                         "Encoding", "UTF-8");
   g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP,
-                        G_KEY_FILE_DESKTOP_KEY_VERSION, "1.0");
+                         G_KEY_FILE_DESKTOP_KEY_VERSION, "1.0");
   g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP,
-                        G_KEY_FILE_DESKTOP_KEY_TYPE,
+                         G_KEY_FILE_DESKTOP_KEY_TYPE,
                          G_KEY_FILE_DESKTOP_TYPE_APPLICATION);
-  if (info->terminal) 
+  if (info->terminal)
     g_key_file_set_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP,
-                           G_KEY_FILE_DESKTOP_KEY_TERMINAL, TRUE);
+                            G_KEY_FILE_DESKTOP_KEY_TERMINAL, TRUE);
   if (info->nodisplay)
     g_key_file_set_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP,
-                           G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY, TRUE);
+                            G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY, TRUE);
 
   g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP,
-                        G_KEY_FILE_DESKTOP_KEY_EXEC, info->exec);
+                         G_KEY_FILE_DESKTOP_KEY_EXEC, info->exec);
 
   g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP,
-                        G_KEY_FILE_DESKTOP_KEY_NAME, info->name);
+                         G_KEY_FILE_DESKTOP_KEY_NAME, info->name);
 
   if (info->generic_name != NULL)
     g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP,
-                          GENERIC_NAME_KEY, info->generic_name);
+                           GENERIC_NAME_KEY, info->generic_name);
 
   if (info->fullname != NULL)
     g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP,
-                          FULL_NAME_KEY, info->fullname);
+                           FULL_NAME_KEY, info->fullname);
 
   g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP,
-                        G_KEY_FILE_DESKTOP_KEY_COMMENT, info->comment);
-  
+                         G_KEY_FILE_DESKTOP_KEY_COMMENT, info->comment);
+
   g_key_file_set_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP,
-                         G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY, TRUE);
+                          G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY, TRUE);
 
   data = g_key_file_to_data (key_file, &data_size, NULL);
   g_key_file_free (key_file);
@@ -2277,7 +2306,7 @@ g_desktop_app_info_ensure_saved (GDesktopAppInfo  *info,
   filename = g_build_filename (dirname, desktop_id, NULL);
   g_free (desktop_id);
   g_free (dirname);
-  
+
   fd = g_mkstemp (filename);
   if (fd == -1)
     {
@@ -2285,7 +2314,7 @@ g_desktop_app_info_ensure_saved (GDesktopAppInfo  *info,
 
       display_name = g_filename_display_name (filename);
       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
-                  _("Can't create user desktop file %s"), display_name);
+                   _("Can't create user desktop file %s"), display_name);
       g_free (display_name);
       g_free (filename);
       g_free (data);
@@ -2296,7 +2325,7 @@ g_desktop_app_info_ensure_saved (GDesktopAppInfo  *info,
 
   /* FIXME - actually handle error */
   (void) g_close (fd, NULL);
-  
+
   res = g_file_set_contents (filename, data, data_size, error);
   g_free (data);
   if (!res)
@@ -2308,9 +2337,9 @@ g_desktop_app_info_ensure_saved (GDesktopAppInfo  *info,
 
   info->filename = filename;
   info->desktop_id = desktop_id;
-  
+
   run_update_command ("update-desktop-database", "applications");
-  
+
   return TRUE;
 }
 
@@ -2332,9 +2361,9 @@ static gboolean
 g_desktop_app_info_delete (GAppInfo *appinfo)
 {
   GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
-  
+
   if (info->filename)
-    { 
+    {
       if (g_remove (info->filename) == 0)
         {
           update_mimeapps_list (info->desktop_id, NULL,
@@ -2353,6 +2382,7 @@ g_desktop_app_info_delete (GAppInfo *appinfo)
   return FALSE;
 }
 
+/* Create for commandline {{{2 */
 /**
  * g_app_info_create_from_commandline:
  * @commandline: the commandline to use
@@ -2372,9 +2402,9 @@ g_desktop_app_info_delete (GAppInfo *appinfo)
  **/
 GAppInfo *
 g_app_info_create_from_commandline (const char           *commandline,
-                                   const char           *application_name,
-                                   GAppInfoCreateFlags   flags,
-                                   GError              **error)
+                                    const char           *application_name,
+                                    GAppInfoCreateFlags   flags,
+                                    GError              **error)
 {
   char **split;
   char *basename;
@@ -2386,7 +2416,7 @@ g_app_info_create_from_commandline (const char           *commandline,
 
   info->filename = NULL;
   info->desktop_id = NULL;
-  
+
   info->terminal = (flags & G_APP_INFO_CREATE_NEEDS_TERMINAL) != 0;
   info->startup_notify = (flags & G_APP_INFO_CREATE_SUPPORTS_STARTUP_NOTIFICATION) != 0;
   info->hidden = FALSE;
@@ -2396,7 +2426,7 @@ g_app_info_create_from_commandline (const char           *commandline,
     info->exec = g_strconcat (commandline, " %f", NULL);
   info->nodisplay = TRUE;
   info->binary = binary_from_exec (info->exec);
-  
+
   if (application_name)
     info->name = g_strdup (application_name);
   else
@@ -2407,13 +2437,15 @@ g_app_info_create_from_commandline (const char           *commandline,
       g_strfreev (split);
       info->name = basename;
       if (info->name == NULL)
-       info->name = g_strdup ("custom");
+        info->name = g_strdup ("custom");
     }
   info->comment = g_strdup_printf (_("Custom definition for %s"), info->name);
-  
+
   return G_APP_INFO (info);
 }
 
+/* GAppInfo interface init */
+
 static void
 g_desktop_app_info_iface_init (GAppInfoIface *iface)
 {
@@ -2442,14 +2474,16 @@ g_desktop_app_info_iface_init (GAppInfoIface *iface)
   iface->get_supported_types = g_desktop_app_info_get_supported_types;
 }
 
+/* Recommended applications {{{2 */
+
 static gboolean
-app_info_in_list (GAppInfo *info, 
+app_info_in_list (GAppInfo *info,
                   GList    *list)
 {
   while (list != NULL)
     {
       if (g_app_info_equal (info, list->data))
-       return TRUE;
+        return TRUE;
       list = list->next;
     }
   return FALSE;
@@ -2458,7 +2492,7 @@ app_info_in_list (GAppInfo *info,
 /**
  * g_app_info_get_recommended_for_type:
  * @content_type: the content type to find a #GAppInfo for
- * 
+ *
  * Gets a list of recommended #GAppInfos for a given content type, i.e.
  * those applications which claim to support the given content type exactly,
  * and not by MIME type subclassing.
@@ -2489,12 +2523,12 @@ g_app_info_get_recommended_for_type (const gchar *content_type)
 
       info = g_desktop_app_info_new (desktop_entry);
       if (info)
-       {
-         if (app_info_in_list (G_APP_INFO (info), infos))
-           g_object_unref (info);
-         else
-           infos = g_list_prepend (infos, info);
-       }
+        {
+          if (app_info_in_list (G_APP_INFO (info), infos))
+            g_object_unref (info);
+          else
+            infos = g_list_prepend (infos, info);
+        }
       g_free (desktop_entry);
     }
 
@@ -2506,7 +2540,7 @@ g_app_info_get_recommended_for_type (const gchar *content_type)
 /**
  * g_app_info_get_fallback_for_type:
  * @content_type: the content type to find a #GAppInfo for
- * 
+ *
  * Gets a list of fallback #GAppInfos for a given content type, i.e.
  * those applications which claim to support the given content type
  * by MIME type subclassing and not directly.
@@ -2535,13 +2569,13 @@ g_app_info_get_fallback_for_type (const gchar *content_type)
 
       info = g_desktop_app_info_new (desktop_entry);
       if (info)
-       {
-         if (app_info_in_list (G_APP_INFO (info), infos) ||
-             app_info_in_list (G_APP_INFO (info), recommended_infos))
-           g_object_unref (info);
-         else
-           infos = g_list_prepend (infos, info);
-       }
+        {
+          if (app_info_in_list (G_APP_INFO (info), infos) ||
+              app_info_in_list (G_APP_INFO (info), recommended_infos))
+            g_object_unref (info);
+          else
+            infos = g_list_prepend (infos, info);
+        }
       g_free (desktop_entry);
     }
 
@@ -2572,7 +2606,7 @@ g_app_info_get_all_for_type (const char *content_type)
   GDesktopAppInfo *info;
 
   g_return_val_if_fail (content_type != NULL, NULL);
-  
+
   desktop_entries = get_all_desktop_entries_for_mime_type (content_type, NULL, TRUE, &user_default);
   infos = NULL;
 
@@ -2593,17 +2627,17 @@ g_app_info_get_all_for_type (const char *content_type)
 
       info = g_desktop_app_info_new (desktop_entry);
       if (info)
-       {
-         if (app_info_in_list (G_APP_INFO (info), infos))
-           g_object_unref (info);
-         else
-           infos = g_list_prepend (infos, info);
-       }
+        {
+          if (app_info_in_list (G_APP_INFO (info), infos))
+            g_object_unref (info);
+          else
+            infos = g_list_prepend (infos, info);
+        }
       g_free (desktop_entry);
     }
 
   g_list_free (desktop_entries);
-  
+
   return g_list_reverse (infos);
 }
 
@@ -2640,14 +2674,14 @@ g_app_info_reset_type_associations (const char *content_type)
  */
 GAppInfo *
 g_app_info_get_default_for_type (const char *content_type,
-                                gboolean    must_support_uris)
+                                 gboolean    must_support_uris)
 {
   GList *desktop_entries, *l;
   char *user_default = NULL;
   GAppInfo *info;
 
   g_return_val_if_fail (content_type != NULL, NULL);
-  
+
   desktop_entries = get_all_desktop_entries_for_mime_type (content_type, NULL, TRUE, &user_default);
 
   info = NULL;
@@ -2658,11 +2692,11 @@ g_app_info_get_default_for_type (const char *content_type,
 
       if (info)
         {
-         if (must_support_uris && !g_app_info_supports_uris (info))
-           {
-             g_object_unref (info);
-             info = NULL;
-           }
+          if (must_support_uris && !g_app_info_supports_uris (info))
+            {
+              g_object_unref (info);
+              info = NULL;
+            }
         }
     }
 
@@ -2683,17 +2717,17 @@ g_app_info_get_default_for_type (const char *content_type,
 
       info = (GAppInfo *)g_desktop_app_info_new (desktop_entry);
       if (info)
-       {
-         if (must_support_uris && !g_app_info_supports_uris (info))
-           {
-             g_object_unref (info);
-             info = NULL;
-           }
-         else
-           break;
-       }
+        {
+          if (must_support_uris && !g_app_info_supports_uris (info))
+            {
+              g_object_unref (info);
+              info = NULL;
+            }
+          else
+            break;
+        }
     }
-  
+
   g_list_free_full (desktop_entries, g_free);
 
   return info;
@@ -2788,20 +2822,21 @@ get_apps_from_dir (GHashTable *apps,
     }
 }
 
+/* "Get all" API {{{2 */
 
 /**
  * g_app_info_get_all:
  *
- * Gets a list of all of the applications currently registered 
+ * Gets a list of all of the applications currently registered
  * on this system.
- * 
- * For desktop files, this includes applications that have 
- * <literal>NoDisplay=true</literal> set or are excluded from 
+ *
+ * For desktop files, this includes applications that have
+ * <literal>NoDisplay=true</literal> set or are excluded from
  * display by means of <literal>OnlyShowIn</literal> or
  * <literal>NotShowIn</literal>. See g_app_info_should_show().
  * The returned list does not include applications which have
- * the <literal>Hidden</literal> key set. 
- * 
+ * the <literal>Hidden</literal> key set.
+ *
  * Returns: (element-type GAppInfo) (transfer full): a newly allocated #GList of references to 
#GAppInfo<!---->s.
  **/
 GList *
@@ -2836,7 +2871,7 @@ g_app_info_get_all (void)
   return g_list_reverse (infos);
 }
 
-/* Cacheing of mimeinfo.cache and defaults.list files */
+/* Caching of mimeinfo.cache and defaults.list files {{{2 */
 
 typedef struct {
   char *path;
@@ -2859,14 +2894,14 @@ static MimeInfoCache *mime_info_cache = NULL;
 G_LOCK_DEFINE_STATIC (mime_info_cache);
 
 static void mime_info_cache_dir_add_desktop_entries (MimeInfoCacheDir  *dir,
-                                                    const char        *mime_type,
-                                                    char             **new_desktop_file_ids);
+                                                     const char        *mime_type,
+                                                     char             **new_desktop_file_ids);
 
 static MimeInfoCache * mime_info_cache_new (void);
 
 static void
-destroy_info_cache_value (gpointer  key, 
-                          GList    *value, 
+destroy_info_cache_value (gpointer  key,
+                          GList    *value,
                           gpointer  data)
 {
   g_list_free_full (value, g_free);
@@ -2881,14 +2916,14 @@ destroy_info_cache_map (GHashTable *info_cache_map)
 
 static gboolean
 mime_info_cache_dir_out_of_date (MimeInfoCacheDir *dir,
-                                const char       *cache_file,
-                                time_t           *timestamp)
+                                 const char       *cache_file,
+                                 time_t           *timestamp)
 {
   struct stat buf;
   char *filename;
-  
+
   filename = g_build_filename (dir->path, cache_file, NULL);
-  
+
   if (g_stat (filename, &buf) < 0)
     {
       g_free (filename);
@@ -2896,9 +2931,9 @@ mime_info_cache_dir_out_of_date (MimeInfoCacheDir *dir,
     }
   g_free (filename);
 
-  if (buf.st_mtime != *timestamp) 
+  if (buf.st_mtime != *timestamp)
     return TRUE;
-  
+
   return FALSE;
 }
 
@@ -2911,78 +2946,78 @@ mime_info_cache_dir_init (MimeInfoCacheDir *dir)
   gchar *filename, **mime_types;
   int i;
   struct stat buf;
-  
+
   load_error = NULL;
   mime_types = NULL;
-  
+
   if (dir->mime_info_cache_map != NULL &&
       !mime_info_cache_dir_out_of_date (dir, "mimeinfo.cache",
-                                       &dir->mime_info_cache_timestamp))
+                                        &dir->mime_info_cache_timestamp))
     return;
-  
+
   if (dir->mime_info_cache_map != NULL)
     destroy_info_cache_map (dir->mime_info_cache_map);
-  
+
   dir->mime_info_cache_map = g_hash_table_new_full (g_str_hash, g_str_equal,
-                                                   (GDestroyNotify) g_free,
-                                                   NULL);
-  
+                                                    (GDestroyNotify) g_free,
+                                                    NULL);
+
   key_file = g_key_file_new ();
-  
+
   filename = g_build_filename (dir->path, "mimeinfo.cache", NULL);
-  
+
   if (g_stat (filename, &buf) < 0)
     goto error;
-  
+
   dir->mime_info_cache_timestamp = buf.st_mtime;
-  
+
   g_key_file_load_from_file (key_file, filename, G_KEY_FILE_NONE, &load_error);
-  
+
   g_free (filename);
   filename = NULL;
-  
+
   if (load_error != NULL)
     goto error;
-  
+
   mime_types = g_key_file_get_keys (key_file, MIME_CACHE_GROUP,
-                                   NULL, &load_error);
-  
+                                    NULL, &load_error);
+
   if (load_error != NULL)
     goto error;
-  
+
   for (i = 0; mime_types[i] != NULL; i++)
     {
       gchar **desktop_file_ids;
       char *unaliased_type;
       desktop_file_ids = g_key_file_get_string_list (key_file,
-                                                    MIME_CACHE_GROUP,
-                                                    mime_types[i],
-                                                    NULL,
-                                                    NULL);
-      
+                                                     MIME_CACHE_GROUP,
+                                                     mime_types[i],
+                                                     NULL,
+                                                     NULL);
+
       if (desktop_file_ids == NULL)
-       continue;
+        continue;
 
       unaliased_type = _g_unix_content_type_unalias (mime_types[i]);
       mime_info_cache_dir_add_desktop_entries (dir,
-                                              unaliased_type,
-                                              desktop_file_ids);
+                                               unaliased_type,
+                                               desktop_file_ids);
       g_free (unaliased_type);
-    
+
       g_strfreev (desktop_file_ids);
     }
-  
+
   g_strfreev (mime_types);
   g_key_file_free (key_file);
-  
+
   return;
  error:
   g_free (filename);
   g_key_file_free (key_file);
-  
+
   if (mime_types != NULL)
     g_strfreev (mime_types);
-  
+
   if (load_error)
     g_error_free (load_error);
 }
@@ -3003,17 +3038,17 @@ mime_info_cache_dir_init_defaults_list (MimeInfoCacheDir *dir)
 
   if (dir->defaults_list_map != NULL &&
       !mime_info_cache_dir_out_of_date (dir, "defaults.list",
-                                       &dir->defaults_list_timestamp))
+                                        &dir->defaults_list_timestamp))
     return;
-  
+
   if (dir->defaults_list_map != NULL)
     g_hash_table_destroy (dir->defaults_list_map);
   dir->defaults_list_map = g_hash_table_new_full (g_str_hash, g_str_equal,
-                                                 g_free, (GDestroyNotify)g_strfreev);
-  
+                                                  g_free, (GDestroyNotify)g_strfreev);
+
 
   key_file = g_key_file_new ();
-  
+
   filename = g_build_filename (dir->path, "defaults.list", NULL);
   if (g_stat (filename, &buf) < 0)
     goto error;
@@ -3028,38 +3063,38 @@ mime_info_cache_dir_init_defaults_list (MimeInfoCacheDir *dir)
     goto error;
 
   mime_types = g_key_file_get_keys (key_file, DEFAULT_APPLICATIONS_GROUP,
-                                   NULL, NULL);
+                                    NULL, NULL);
   if (mime_types != NULL)
     {
       for (i = 0; mime_types[i] != NULL; i++)
-       {
-         desktop_file_ids = g_key_file_get_string_list (key_file,
-                                                        DEFAULT_APPLICATIONS_GROUP,
-                                                        mime_types[i],
-                                                        NULL,
-                                                        NULL);
-         if (desktop_file_ids == NULL)
-           continue;
-         
-         unaliased_type = _g_unix_content_type_unalias (mime_types[i]);
-         g_hash_table_replace (dir->defaults_list_map,
-                               unaliased_type,
-                               desktop_file_ids);
-       }
-      
+        {
+          desktop_file_ids = g_key_file_get_string_list (key_file,
+                                                         DEFAULT_APPLICATIONS_GROUP,
+                                                         mime_types[i],
+                                                         NULL,
+                                                         NULL);
+          if (desktop_file_ids == NULL)
+            continue;
+
+          unaliased_type = _g_unix_content_type_unalias (mime_types[i]);
+          g_hash_table_replace (dir->defaults_list_map,
+                                unaliased_type,
+                                desktop_file_ids);
+        }
+
       g_strfreev (mime_types);
     }
 
   g_key_file_free (key_file);
   return;
-  
+
  error:
   g_free (filename);
   g_key_file_free (key_file);
-  
+
   if (mime_types != NULL)
     g_strfreev (mime_types);
-  
+
   if (load_error)
     g_error_free (load_error);
 }
@@ -3081,18 +3116,18 @@ mime_info_cache_dir_init_mimeapps_list (MimeInfoCacheDir *dir)
 
   if (dir->mimeapps_list_added_map != NULL &&
       !mime_info_cache_dir_out_of_date (dir, "mimeapps.list",
-                                       &dir->mimeapps_list_timestamp))
+                                        &dir->mimeapps_list_timestamp))
     return;
-  
+
   if (dir->mimeapps_list_added_map != NULL)
     g_hash_table_destroy (dir->mimeapps_list_added_map);
   dir->mimeapps_list_added_map = g_hash_table_new_full (g_str_hash, g_str_equal,
-                                                       g_free, (GDestroyNotify)g_strfreev);
-  
+                                                        g_free, (GDestroyNotify)g_strfreev);
+
   if (dir->mimeapps_list_removed_map != NULL)
     g_hash_table_destroy (dir->mimeapps_list_removed_map);
   dir->mimeapps_list_removed_map = g_hash_table_new_full (g_str_hash, g_str_equal,
-                                                         g_free, (GDestroyNotify)g_strfreev);
+                                                          g_free, (GDestroyNotify)g_strfreev);
 
   if (dir->mimeapps_list_defaults_map != NULL)
     g_hash_table_destroy (dir->mimeapps_list_defaults_map);
@@ -3100,7 +3135,7 @@ mime_info_cache_dir_init_mimeapps_list (MimeInfoCacheDir *dir)
                                                            g_free, g_free);
 
   key_file = g_key_file_new ();
-  
+
   filename = g_build_filename (dir->path, "mimeapps.list", NULL);
   if (g_stat (filename, &buf) < 0)
     goto error;
@@ -3115,48 +3150,48 @@ mime_info_cache_dir_init_mimeapps_list (MimeInfoCacheDir *dir)
     goto error;
 
   mime_types = g_key_file_get_keys (key_file, ADDED_ASSOCIATIONS_GROUP,
-                                   NULL, NULL);
+                                    NULL, NULL);
   if (mime_types != NULL)
     {
       for (i = 0; mime_types[i] != NULL; i++)
-       {
-         desktop_file_ids = g_key_file_get_string_list (key_file,
-                                                        ADDED_ASSOCIATIONS_GROUP,
-                                                        mime_types[i],
-                                                        NULL,
-                                                        NULL);
-         if (desktop_file_ids == NULL)
-           continue;
-         
-         unaliased_type = _g_unix_content_type_unalias (mime_types[i]);
-         g_hash_table_replace (dir->mimeapps_list_added_map,
-                               unaliased_type,
-                               desktop_file_ids);
-       }
-      
+        {
+          desktop_file_ids = g_key_file_get_string_list (key_file,
+                                                         ADDED_ASSOCIATIONS_GROUP,
+                                                         mime_types[i],
+                                                         NULL,
+                                                         NULL);
+          if (desktop_file_ids == NULL)
+            continue;
+
+          unaliased_type = _g_unix_content_type_unalias (mime_types[i]);
+          g_hash_table_replace (dir->mimeapps_list_added_map,
+                                unaliased_type,
+                                desktop_file_ids);
+        }
+
       g_strfreev (mime_types);
     }
 
   mime_types = g_key_file_get_keys (key_file, REMOVED_ASSOCIATIONS_GROUP,
-                                   NULL, NULL);
+                                    NULL, NULL);
   if (mime_types != NULL)
     {
       for (i = 0; mime_types[i] != NULL; i++)
-       {
-         desktop_file_ids = g_key_file_get_string_list (key_file,
-                                                        REMOVED_ASSOCIATIONS_GROUP,
-                                                        mime_types[i],
-                                                        NULL,
-                                                        NULL);
-         if (desktop_file_ids == NULL)
-           continue;
-         
-         unaliased_type = _g_unix_content_type_unalias (mime_types[i]);
-         g_hash_table_replace (dir->mimeapps_list_removed_map,
-                               unaliased_type,
-                               desktop_file_ids);
-       }
-      
+        {
+          desktop_file_ids = g_key_file_get_string_list (key_file,
+                                                         REMOVED_ASSOCIATIONS_GROUP,
+                                                         mime_types[i],
+                                                         NULL,
+                                                         NULL);
+          if (desktop_file_ids == NULL)
+            continue;
+
+          unaliased_type = _g_unix_content_type_unalias (mime_types[i]);
+          g_hash_table_replace (dir->mimeapps_list_removed_map,
+                                unaliased_type,
+                                desktop_file_ids);
+        }
+
       g_strfreev (mime_types);
     }
 
@@ -3184,14 +3219,14 @@ mime_info_cache_dir_init_mimeapps_list (MimeInfoCacheDir *dir)
 
   g_key_file_free (key_file);
   return;
-  
+
  error:
   g_free (filename);
   g_key_file_free (key_file);
-  
+
   if (mime_types != NULL)
     g_strfreev (mime_types);
-  
+
   if (load_error)
     g_error_free (load_error);
 }
@@ -3203,7 +3238,7 @@ mime_info_cache_dir_new (const char *path)
 
   dir = g_new0 (MimeInfoCacheDir, 1);
   dir->path = g_strdup (path);
-  
+
   return dir;
 }
 
@@ -3212,26 +3247,26 @@ mime_info_cache_dir_free (MimeInfoCacheDir *dir)
 {
   if (dir == NULL)
     return;
-  
+
   if (dir->mime_info_cache_map != NULL)
     {
       destroy_info_cache_map (dir->mime_info_cache_map);
       dir->mime_info_cache_map = NULL;
-      
+
   }
-  
+
   if (dir->defaults_list_map != NULL)
     {
       g_hash_table_destroy (dir->defaults_list_map);
       dir->defaults_list_map = NULL;
     }
-  
+
   if (dir->mimeapps_list_added_map != NULL)
     {
       g_hash_table_destroy (dir->mimeapps_list_added_map);
       dir->mimeapps_list_added_map = NULL;
     }
-  
+
   if (dir->mimeapps_list_removed_map != NULL)
     {
       g_hash_table_destroy (dir->mimeapps_list_removed_map);
@@ -3249,22 +3284,22 @@ mime_info_cache_dir_free (MimeInfoCacheDir *dir)
 
 static void
 mime_info_cache_dir_add_desktop_entries (MimeInfoCacheDir  *dir,
-                                        const char        *mime_type,
-                                        char             **new_desktop_file_ids)
+                                         const char        *mime_type,
+                                         char             **new_desktop_file_ids)
 {
   GList *desktop_file_ids;
   int i;
-  
+
   desktop_file_ids = g_hash_table_lookup (dir->mime_info_cache_map,
-                                         mime_type);
-  
+                                          mime_type);
+
   for (i = 0; new_desktop_file_ids[i] != NULL; i++)
     {
       if (!g_list_find_custom (desktop_file_ids, new_desktop_file_ids[i], (GCompareFunc) strcmp))
-       desktop_file_ids = g_list_append (desktop_file_ids,
-                                         g_strdup (new_desktop_file_ids[i]));
+        desktop_file_ids = g_list_append (desktop_file_ids,
+                                          g_strdup (new_desktop_file_ids[i]));
     }
-  
+
   g_hash_table_insert (dir->mime_info_cache_map, g_strdup (mime_type), desktop_file_ids);
 }
 
@@ -3280,17 +3315,17 @@ mime_info_cache_init_dir_lists (void)
   for (i = 0; i < n_desktop_file_dirs; i++)
     {
       MimeInfoCacheDir *dir;
-      
+
       dir = mime_info_cache_dir_new (desktop_file_dirs[i].path);
-      
+
       if (dir != NULL)
-       {
-         mime_info_cache_dir_init (dir);
-         mime_info_cache_dir_init_defaults_list (dir);
-         mime_info_cache_dir_init_mimeapps_list (dir);
-         
-         mime_info_cache->dirs = g_list_append (mime_info_cache->dirs, dir);
-       }
+        {
+          mime_info_cache_dir_init (dir);
+          mime_info_cache_dir_init_defaults_list (dir);
+          mime_info_cache_dir_init_mimeapps_list (dir);
+
+          mime_info_cache->dirs = g_list_append (mime_info_cache->dirs, dir);
+        }
     }
 }
 
@@ -3298,9 +3333,9 @@ static void
 mime_info_cache_update_dir_lists (void)
 {
   GList *tmp;
-  
+
   tmp = mime_info_cache->dirs;
-  
+
   while (tmp != NULL)
     {
       MimeInfoCacheDir *dir = (MimeInfoCacheDir *) tmp->data;
@@ -3309,7 +3344,7 @@ mime_info_cache_update_dir_lists (void)
       mime_info_cache_dir_init (dir);
       mime_info_cache_dir_init_defaults_list (dir);
       mime_info_cache_dir_init_mimeapps_list (dir);
-      
+
       tmp = tmp->next;
     }
 }
@@ -3323,13 +3358,13 @@ mime_info_cache_init (void)
   else
     {
       time_t now;
-      
+
       time (&now);
       if (now >= mime_info_cache->last_stat_time + 10)
-       {
-         mime_info_cache_update_dir_lists ();
-         mime_info_cache->last_stat_time = now;
-       }
+        {
+          mime_info_cache_update_dir_lists ();
+          mime_info_cache->last_stat_time = now;
+        }
     }
 
   G_UNLOCK (mime_info_cache);
@@ -3358,7 +3393,7 @@ mime_info_cache_free (MimeInfoCache *cache)
 /**
  * mime_info_cache_reload:
  * @dir: directory path which needs reloading.
- * 
+ *
  * Reload the mime information for the @dir.
  */
 static void
@@ -3377,15 +3412,15 @@ mime_info_cache_reload (const char *dir)
 }
 
 static GList *
-append_desktop_entry (GList      *list, 
+append_desktop_entry (GList      *list,
                       const char *desktop_entry,
-                     GList      *removed_entries)
+                      GList      *removed_entries)
 {
   /* Add if not already in list, and valid */
   if (!g_list_find_custom (list, desktop_entry, (GCompareFunc) strcmp) &&
       !g_list_find_custom (removed_entries, desktop_entry, (GCompareFunc) strcmp))
     list = g_list_prepend (list, g_strdup (desktop_entry));
-  
+
   return list;
 }
 
@@ -3399,15 +3434,15 @@ append_desktop_entry (GList      *list,
  * non-default ones, and handlers for inherited mimetypes are listed
  * after the base ones.
  *
- * Optionally doesn't list the desktop ids given in the @except 
+ * Optionally doesn't list the desktop ids given in the @except
  *
  * Return value: a #GList containing the desktop ids which claim
  *    to handle @mime_type.
  */
 static GList *
 get_all_desktop_entries_for_mime_type (const char  *base_mime_type,
-                                      const char **except,
-                                      gboolean     include_fallback,
+                                       const char **except,
+                                       gboolean     include_fallback,
                                        char       **explicit_default)
 {
   GList *desktop_entries, *removed_entries, *list, *dir_list, *tmp;
@@ -3422,7 +3457,7 @@ get_all_desktop_entries_for_mime_type (const char  *base_mime_type,
   int i, j, k;
   GPtrArray *array;
   char **anc;
-  
+
   mime_info_cache_init ();
 
   if (include_fallback)
@@ -3431,23 +3466,23 @@ get_all_desktop_entries_for_mime_type (const char  *base_mime_type,
       mime_types = _g_unix_content_type_get_parents (base_mime_type);
       array = g_ptr_array_new ();
       for (i = 0; mime_types[i]; i++)
-       g_ptr_array_add (array, mime_types[i]);
+        g_ptr_array_add (array, mime_types[i]);
       g_free (mime_types);
       for (i = 0; i < array->len; i++)
-       {
-         anc = _g_unix_content_type_get_parents (g_ptr_array_index (array, i));
-         for (j = 0; anc[j]; j++)
-           {
-             for (k = 0; k < array->len; k++)
-               {
-                 if (strcmp (anc[j], g_ptr_array_index (array, k)) == 0)
-                   break;
-               }
-             if (k == array->len) /* not found */
-               g_ptr_array_add (array, g_strdup (anc[j]));
-           }
-         g_strfreev (anc);
-       }
+        {
+          anc = _g_unix_content_type_get_parents (g_ptr_array_index (array, i));
+          for (j = 0; anc[j]; j++)
+            {
+              for (k = 0; k < array->len; k++)
+                {
+                  if (strcmp (anc[j], g_ptr_array_index (array, k)) == 0)
+                    break;
+                }
+              if (k == array->len) /* not found */
+                g_ptr_array_add (array, g_strdup (anc[j]));
+            }
+          g_strfreev (anc);
+        }
       g_ptr_array_add (array, NULL);
       mime_types = (char **)g_ptr_array_free (array, FALSE);
     }
@@ -3459,13 +3494,13 @@ get_all_desktop_entries_for_mime_type (const char  *base_mime_type,
     }
 
   G_LOCK (mime_info_cache);
-  
+
   removed_entries = NULL;
   desktop_entries = NULL;
 
   for (i = 0; except != NULL && except[i] != NULL; i++)
     removed_entries = g_list_prepend (removed_entries, g_strdup (except[i]));
-  
+
   for (i = 0; mime_types[i] != NULL; i++)
     {
       mime_type = mime_types[i];
@@ -3477,10 +3512,10 @@ get_all_desktop_entries_for_mime_type (const char  *base_mime_type,
 
       /* Go through all apps listed in user and system dirs */
       for (dir_list = mime_info_cache->dirs;
-          dir_list != NULL;
-          dir_list = dir_list->next)
-       {
-         dir = dir_list->data;
+           dir_list != NULL;
+           dir_list = dir_list->next)
+        {
+          dir = dir_list->data;
 
           /* Pick the explicit default application if we got no result earlier
            * (ie, for more specific mime types)
@@ -3497,40 +3532,40 @@ get_all_desktop_entries_for_mime_type (const char  *base_mime_type,
                 }
             }
 
-         /* Then added associations from mimeapps.list */
-         default_entries = g_hash_table_lookup (dir->mimeapps_list_added_map, mime_type);
-         for (j = 0; default_entries != NULL && default_entries[j] != NULL; j++)
+          /* Then added associations from mimeapps.list */
+          default_entries = g_hash_table_lookup (dir->mimeapps_list_added_map, mime_type);
+          for (j = 0; default_entries != NULL && default_entries[j] != NULL; j++)
             desktop_entries = append_desktop_entry (desktop_entries, default_entries[j], removed_entries);
 
-         /* Then removed associations from mimeapps.list */
-         removed_associations = g_hash_table_lookup (dir->mimeapps_list_removed_map, mime_type);
-         for (j = 0; removed_associations != NULL && removed_associations[j] != NULL; j++)
-           removed_entries = append_desktop_entry (removed_entries, removed_associations[j], NULL);
+          /* Then removed associations from mimeapps.list */
+          removed_associations = g_hash_table_lookup (dir->mimeapps_list_removed_map, mime_type);
+          for (j = 0; removed_associations != NULL && removed_associations[j] != NULL; j++)
+            removed_entries = append_desktop_entry (removed_entries, removed_associations[j], NULL);
 
-         /* Then system defaults (or old per-user config) (using removed associations from this dir or 
earlier) */
-         default_entries = g_hash_table_lookup (dir->defaults_list_map, mime_type);
-         for (j = 0; default_entries != NULL && default_entries[j] != NULL; j++)
+          /* Then system defaults (or old per-user config) (using removed associations from this dir or 
earlier) */
+          default_entries = g_hash_table_lookup (dir->defaults_list_map, mime_type);
+          for (j = 0; default_entries != NULL && default_entries[j] != NULL; j++)
             {
               if (default_entry == NULL && old_default_entry == NULL && !already_found_handler)
                 old_default_entry = g_strdup (default_entries[j]);
 
               desktop_entries = append_desktop_entry (desktop_entries, default_entries[j], removed_entries);
             }
-       }
+        }
 
       /* Go through all entries that support the mimetype */
       for (dir_list = mime_info_cache->dirs;
-          dir_list != NULL;
-          dir_list = dir_list->next) 
+           dir_list != NULL;
+           dir_list = dir_list->next)
         {
-         dir = dir_list->data;
-       
-         list = g_hash_table_lookup (dir->mime_info_cache_map, mime_type);
-         for (tmp = list; tmp != NULL; tmp = tmp->next)
-           desktop_entries = append_desktop_entry (desktop_entries, tmp->data, removed_entries);
+          dir = dir_list->data;
+
+          list = g_hash_table_lookup (dir->mime_info_cache_map, mime_type);
+          for (tmp = list; tmp != NULL; tmp = tmp->next)
+            desktop_entries = append_desktop_entry (desktop_entries, tmp->data, removed_entries);
         }
     }
-  
+
   G_UNLOCK (mime_info_cache);
 
   g_strfreev (mime_types);
@@ -3554,11 +3589,11 @@ get_all_desktop_entries_for_mime_type (const char  *base_mime_type,
   g_list_free_full (removed_entries, g_free);
 
   desktop_entries = g_list_reverse (desktop_entries);
-  
+
   return desktop_entries;
 }
 
-/* GDesktopAppInfoLookup interface: */
+/* GDesktopAppInfoLookup interface {{{2 */
 
 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 
@@ -3570,12 +3605,14 @@ g_desktop_app_info_lookup_default_init (GDesktopAppInfoLookupInterface *iface)
 {
 }
 
+/* "Get for mime type" APIs {{{2 */
+
 /**
  * g_desktop_app_info_lookup_get_default_for_uri_scheme:
  * @lookup: a #GDesktopAppInfoLookup
  * @uri_scheme: a string containing a URI scheme.
  *
- * Gets the default application for launching applications 
+ * Gets the default application for launching applications
  * using this URI scheme for a particular GDesktopAppInfoLookup
  * implementation.
  *
@@ -3583,14 +3620,14 @@ g_desktop_app_info_lookup_default_init (GDesktopAppInfoLookupInterface *iface)
  * to implement g_app_info_get_default_for_uri_scheme() backends
  * in a GIO module. There is no reason for applications to use it
  * directly. Applications should use g_app_info_get_default_for_uri_scheme().
- * 
+ *
  * Returns: (transfer full): #GAppInfo for given @uri_scheme or %NULL on error.
  *
  * Deprecated: The #GDesktopAppInfoLookup interface is deprecated and unused by gio.
  */
 GAppInfo *
 g_desktop_app_info_lookup_get_default_for_uri_scheme (GDesktopAppInfoLookup *lookup,
-                                                     const char            *uri_scheme)
+                                                      const char            *uri_scheme)
 {
   GDesktopAppInfoLookupIface *iface;
 
@@ -3603,6 +3640,8 @@ g_desktop_app_info_lookup_get_default_for_uri_scheme (GDesktopAppInfoLookup *loo
 
 G_GNUC_END_IGNORE_DEPRECATIONS
 
+/* Misc getter APIs {{{2 */
+
 /**
  * g_desktop_app_info_get_startup_wm_class:
  * @info: a #GDesktopAppInfo that supports startup notify
@@ -3694,6 +3733,8 @@ g_desktop_app_info_has_key (GDesktopAppInfo *info,
                              G_KEY_FILE_DESKTOP_GROUP, key, NULL);
 }
 
+/* Desktop actions support {{{2 */
+
 /**
  * g_desktop_app_info_list_actions:
  * @info: a #GDesktopAppInfo
@@ -3841,3 +3882,6 @@ g_desktop_app_info_launch_action (GDesktopAppInfo   *info,
       g_object_unref (session_bus);
     }
 }
+/* Epilogue {{{1 */
+
+/* vim:set foldmethod=marker: */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]