diff src/menu.c @ 731:fa8f7d7396cf

Introduce an helper function that returns the name of an editor. It helps to reduce code redundancy.
author zas_
date Thu, 22 May 2008 09:12:36 +0000
parents 2d8a8e892b5e
children 1646720364cf
line wrap: on
line diff
--- a/src/menu.c	Thu May 22 08:49:52 2008 +0000
+++ b/src/menu.c	Thu May 22 09:12:36 2008 +0000
@@ -18,6 +18,7 @@
 #include "collect.h"
 #include "collect-dlg.h"
 #include "dupe.h"
+#include "editors.h"
 #include "filedata.h"
 #include "img-view.h"
 #include "preferences.h"
@@ -69,19 +70,18 @@
 
 	for (i = 0; i < GQ_EDITOR_GENERIC_SLOTS; i++)
 		{
-		if (options->editor[i].command && strlen(options->editor[i].command) > 0)
-			{
-			gchar *text;
-			if (options->editor[i].name && strlen(options->editor[i].name) > 0)
-				text = g_strdup_printf(_("_%d %s..."), i, options->editor[i].name);
-			else
-				text = g_strdup_printf(_("_%d (unknown)..."), i);
-			if (accel_grp)
-				add_menu_item(menu, text, accel_grp, i + 49, GDK_CONTROL_MASK, func, GINT_TO_POINTER(i));
-			else
-				menu_item_add(menu, text, func, GINT_TO_POINTER(i));
-			g_free(text);
-			}
+		gchar *text;
+		const gchar *name = editor_get_name(i);
+
+		if (!name) continue;
+
+		text = g_strdup_printf(_("_%d %s..."), i, name);
+		if (accel_grp)
+			add_menu_item(menu, text, accel_grp, i + 49, GDK_CONTROL_MASK, func, GINT_TO_POINTER(i));
+		else
+			menu_item_add(menu, text, func, GINT_TO_POINTER(i));
+		g_free(text);
+		
 		}
 }