[Xfce4-commits] <exo:master> Automatically go to create mode for new filenames.

Nick Schermer noreply at xfce.org
Mon Feb 15 11:18:01 CET 2010


Updating branch refs/heads/master
         to 319dabef4a2643929ede0bcfbcfc4c9c0085b937 (commit)
       from 5707da3cd4bd7bb8cf6569e7673b9762ab29ce64 (commit)

commit 319dabef4a2643929ede0bcfbcfc4c9c0085b937
Author: Nick Schermer <nick at xfce.org>
Date:   Mon Feb 15 11:14:58 2010 +0100

    Automatically go to create mode for new filenames.
    
    Instead of acting stupid, we try to detect the file
    type from the new filename. This makes creating new launchers
    and menus work in alacarte.

 exo-desktop-item-edit/main.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/exo-desktop-item-edit/main.c b/exo-desktop-item-edit/main.c
index 17b2deb..525bfc4 100644
--- a/exo-desktop-item-edit/main.c
+++ b/exo-desktop-item-edit/main.c
@@ -193,9 +193,23 @@ main (int argc, char **argv)
       return EXIT_FAILURE;
     }
 
+  /* create a file from the arguments */
+  gfile = g_file_new_for_commandline_arg (argv[1]);
+  if (!opt_create_new && opt_type == NULL
+      && !g_file_query_exists (gfile, NULL))
+    {
+      /* to help alacarte and some users a bit, we try to be smart here */
+      if (g_str_has_suffix (argv[1], ".desktop"))
+        opt_type = "Application";
+      else if (g_str_has_suffix (argv[1], ".directory"))
+        opt_type = "Directory";
+
+      /* go to create mode if we found a valid suffix */
+      opt_create_new = (opt_type != NULL);
+    }
+
   /* allocate a key file */
   key_file = g_key_file_new ();
-  gfile = g_file_new_for_commandline_arg (argv[1]);
 
   /* create new key file if --create-new was specified */
   if (opt_create_new)



More information about the Xfce4-commits mailing list