SF.net SVN: geany:[5686] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sun Apr 3 17:25:28 UTC 2011


Revision: 5686
          http://geany.svn.sourceforge.net/geany/?rev=5686&view=rev
Author:   eht16
Date:     2011-04-03 17:25:27 +0000 (Sun, 03 Apr 2011)

Log Message:
-----------
Reflect the existence of the entered command in `Set Custom Commands` dialog as well using the yes/no icon.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/tools.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2011-04-03 16:38:31 UTC (rev 5685)
+++ trunk/ChangeLog	2011-04-03 17:25:27 UTC (rev 5686)
@@ -7,6 +7,9 @@
  * scintilla/makefile.win32, tagmanager/makefile.win32, makefile.win32:
    Replace escape character '\' by slash '/' in paths in the
    Windows Makefiles (patch by Matthew Brush, thanks).
+ * src/tools.c:
+   Reflect the existence of the entered command in `Set Custom Commands`
+   dialog as well using the yes/no icon.
 
 
 2011-04-03  Colomban Wendling  <colomban(at)geany(dot)org>

Modified: trunk/src/tools.c
===================================================================
--- trunk/src/tools.c	2011-04-03 16:38:31 UTC (rev 5685)
+++ trunk/src/tools.c	2011-04-03 17:25:27 UTC (rev 5686)
@@ -81,19 +81,45 @@
 static GString *cc_buffer;
 
 
+static gboolean cc_exists_command(const gchar *command)
+{
+	gchar *path = g_find_program_in_path(command);
+
+	if (path != NULL)
+	{
+		g_free(path);
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+
 /* update STATUS and TOOLTIP columns according to cmd */
 static void cc_dialog_update_row_status(GtkListStore *store, GtkTreeIter *iter, const gchar *cmd)
 {
 	GError *err = NULL;
 	const gchar *stock_id;
 	gchar *tooltip = NULL;
+	gint argc;
+	gchar **argv;
 
-	if (! NZV(cmd) || g_shell_parse_argv(cmd, NULL, NULL, &err))
+	if (! NZV(cmd))
+	{
 		stock_id = GTK_STOCK_YES;
-	else
+	}
+	else if (g_shell_parse_argv(cmd, &argc, &argv, &err))
 	{
+		if (argc > 0 && cc_exists_command(argv[0]))
+			stock_id = GTK_STOCK_YES;
+		else
+			err = g_error_new( G_FILE_ERROR, G_FILE_ERROR_NOENT, _("Command not found"));
+	}
+
+	if (err != NULL)
+	{
 		stock_id = GTK_STOCK_NO;
-		tooltip = g_strdup_printf(_("Command cannot be parsed: %s"), err->message);
+		tooltip = g_strdup_printf(_("Command cannot be found/parsed: %s"), err->message);
 		g_error_free(err);
 	}
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list