changeset 1402:611c25ef73f4

Cleanup and minor fixes.
author zas_
date Sun, 08 Mar 2009 20:49:48 +0000
parents e18871df295f
children 9274b3b4eaad
files src/editors.c
diffstat 1 files changed, 22 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/editors.c	Sun Mar 08 17:51:03 2009 +0000
+++ b/src/editors.c	Sun Mar 08 20:49:48 2009 +0000
@@ -275,16 +275,13 @@
 			g_strfreev(mime_types);
 			if (!editor->ext_list) editor->hidden = TRUE; 
 			}
-		
 		}
 		
-
 	if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "X-Geeqie-Keep-Fullscreen", NULL)) editor->flags |= EDITOR_KEEP_FS;
 	if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "X-Geeqie-Verbose", NULL)) editor->flags |= EDITOR_VERBOSE;
 	if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "X-Geeqie-Verbose-Multi", NULL)) editor->flags |= EDITOR_VERBOSE_MULTI;
 	if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "X-Geeqie-Filter", NULL)) editor->flags |= EDITOR_DEST;
 	if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "Terminal", NULL)) editor->flags |= EDITOR_TERMINAL;
-
 	
 	editor->flags |= editor_command_parse(editor, NULL, NULL);
 	g_key_file_free(key_file);
@@ -315,9 +312,8 @@
 	while ((dir = readdir(dp)) != NULL)
 		{
 		gchar *namel = dir->d_name;
-		size_t len = strlen(namel);
 		
-		if (len > 8 && g_ascii_strncasecmp(namel + len - 8, ".desktop", 8) == 0)
+		if (g_str_has_suffix(namel, ".desktop"))
 			{
 			gchar *name = path_to_utf8(namel);
 			gchar *dpath = g_build_filename(path, name, NULL);
@@ -373,7 +369,7 @@
 	GList **listp = data;
 	EditorDescription *editor = value;
 	
-	/* do not show the special commands in any list, they are called explicitelly */ 
+	/* do not show the special commands in any list, they are called explicitly */ 
 	if (strcmp(editor->key, CMD_COPY) == 0 ||
 	    strcmp(editor->key, CMD_MOVE) == 0 ||  
 	    strcmp(editor->key, CMD_RENAME) == 0 ||
@@ -387,7 +383,7 @@
 {
 	const EditorDescription *ea = a;
 	const EditorDescription *eb = b;
-	int ret;
+	gint ret;
 	
 	ret = strcmp(ea->menu_path, eb->menu_path);
 	if (ret != 0) return ret;
@@ -574,7 +570,7 @@
 {
 	GString *string;
 	gchar *pathl;
-	const gchar *p = NULL;
+	const gchar *p;
 
 	string = g_string_new("");
 
@@ -624,6 +620,7 @@
 			p = "";
 		}
 
+	g_assert(p);
 	while (*p != '\0')
 		{
 		/* must escape \, ", `, and $ to avoid problems,
@@ -641,6 +638,12 @@
 	pathl = path_from_utf8(string->str);
 	g_string_free(string, TRUE);
 
+	if (pathl && !pathl[0]) /* empty string case */
+		{
+		g_free(pathl);
+		pathl = NULL;
+		}
+
 	return pathl;
 }
 
@@ -861,11 +864,11 @@
 
 		if ((ed->flags & EDITOR_DEST) && fd->change && fd->change->dest) /* FIXME: error handling */
 			{
-			setenv("GEEQIE_DESTINATION", fd->change->dest, TRUE);
+			g_setenv("GEEQIE_DESTINATION", fd->change->dest, TRUE);
 			}
 		else
 			{
-			unsetenv("GEEQIE_DESTINATION");
+			g_unsetenv("GEEQIE_DESTINATION");
 			}
 
 		ok = g_spawn_async_with_pipes(working_directory, args, NULL,
@@ -940,7 +943,10 @@
 
 		if (ed->vd)
 			{
-			editor_verbose_window_progress(ed, (ed->flags & EDITOR_FOR_EACH) ? fd->path : _("running..."));
+			if (ed->flags & EDITOR_FOR_EACH)
+				editor_verbose_window_progress(ed, fd->path);
+			else
+				editor_verbose_window_progress(ed, _("running..."));
 			}
 		ed->count++;
 
@@ -957,9 +963,9 @@
 
 		if (!error)
 			return 0;
-		else
-			/* command was not started, call the finish immediately */
-			return editor_command_next_finish(ed, 0);
+		
+		/* command was not started, call the finish immediately */
+		return editor_command_next_finish(ed, 0);
 		}
 
 	/* everything is done */
@@ -1012,17 +1018,14 @@
 
 	if (ed->vd)
 		{
-		const gchar *text;
-
 		if (ed->count == ed->total)
 			{
-			text = _("done");
+			editor_verbose_window_progress(ed, _("done"));
 			}
 		else
 			{
-			text = _("stopped by user");
+			editor_verbose_window_progress(ed, _("stopped by user"));
 			}
-		editor_verbose_window_progress(ed, text);
 		editor_verbose_window_enable_close(ed->vd);
 		}