It helps to reduce code redundancy.
if (flags & EDITOR_ERROR_SKIPPED) return _("File was skipped.");
return _("Unknown error.");
}
+
+const gchar *editor_get_name(gint n)
+{
+ if (!is_valid_editor_command(n)) return NULL;
+
+ if (options->editor[n].name && strlen(options->editor[n].name) > 0)
+ return options->editor[n].name;
+
+ return _("(unknown)");
+}
gint editor_window_flag_set(gint n);
const gchar *editor_get_error_str(gint flags);
+const gchar *editor_get_name(gint n);
+
#endif
{
gchar *key;
GtkAction *action;
-
+ const gchar *name;
+
key = g_strdup_printf("Editor%d", i);
action = gtk_action_group_get_action(lw->action_group, key);
g_object_set_data(G_OBJECT(action), "edit_index", GINT_TO_POINTER(i));
- if (options->editor[i].command && strlen(options->editor[i].command) > 0)
+ name = editor_get_name(i);
+ if (name)
{
- gchar *text;
+ gchar *text = g_strdup_printf(_("_%d %s..."), i, name);
- 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);
- }
g_object_set(action, "label", text,
"sensitive", TRUE, NULL);
g_free(text);
#include "collect.h"
#include "collect-dlg.h"
#include "dupe.h"
+#include "editors.h"
#include "filedata.h"
#include "img-view.h"
#include "preferences.h"
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);
+
}
}