diff --git a/moo/mooedit/mooedit-actions.c b/moo/mooedit/mooedit-actions.c index bd3087d4..b8f8d7a0 100644 --- a/moo/mooedit/mooedit-actions.c +++ b/moo/mooedit/mooedit-actions.c @@ -746,7 +746,7 @@ moo_edit_action_check (MooEditAction *action) { GSList *l; MooLang *lang = moo_text_view_get_lang (MOO_TEXT_VIEW (action->doc)); - const char *lang_id = lang ? lang->id : MOO_LANG_NONE; + const char *lang_id = moo_lang_id (lang); gboolean visible = FALSE; for (l = action->langs; l != NULL; l = l->next) diff --git a/moo/mooedit/mooeditwindow.c b/moo/mooedit/mooeditwindow.c index f9aab672..73ce9b76 100644 --- a/moo/mooedit/mooeditwindow.c +++ b/moo/mooedit/mooeditwindow.c @@ -2232,8 +2232,6 @@ moo_edit_window_message (MooEditWindow *window, /* Language menu */ -#define NONE_LANGUAGE_ID "MOO_LANG_NONE" - static int cmp_langs (MooLang *lang1, MooLang *lang2) @@ -2297,7 +2295,7 @@ create_lang_action (MooEditWindow *window) "Language", 0, NULL, NULL); moo_menu_mgr_append (menu_mgr, LANG_ACTION_ID, - NONE_LANGUAGE_ID, "None", + MOO_LANG_NONE, "None", MOO_MENU_ITEM_RADIO, NULL, NULL); for (l = sections; l != NULL; l = l->next) @@ -2341,7 +2339,7 @@ update_lang_menu (MooEditWindow *window) g_return_if_fail (action != NULL); moo_menu_mgr_set_active (moo_menu_action_get_mgr (MOO_MENU_ACTION (action)), - lang ? lang->id : NONE_LANGUAGE_ID, TRUE); + moo_lang_id (lang), TRUE); } diff --git a/moo/mooedit/moolang.c b/moo/mooedit/moolang.c index bf8aaf14..71e98576 100644 --- a/moo/mooedit/moolang.c +++ b/moo/mooedit/moolang.c @@ -254,6 +254,13 @@ moo_lang_id_from_name (const char *name) } +const char * +moo_lang_id (MooLang *lang) +{ + return lang ? lang->id : MOO_LANG_NONE; +} + + void moo_lang_add_style (MooLang *lang, const char *name, diff --git a/moo/mooedit/moolang.h b/moo/mooedit/moolang.h index 49bcafd9..f6ac3e74 100644 --- a/moo/mooedit/moolang.h +++ b/moo/mooedit/moolang.h @@ -224,6 +224,7 @@ void moo_lang_add_style (MooLang *lang, const MooTextStyle *style); char *moo_lang_id_from_name (const char *name); +const char *moo_lang_id (MooLang *lang); /*****************************************************************************/ diff --git a/moo/mooedit/moousertools.c b/moo/mooedit/moousertools.c index 4d855194..36339544 100644 --- a/moo/mooedit/moousertools.c +++ b/moo/mooedit/moousertools.c @@ -728,7 +728,6 @@ check_visible_func (MooAction *_action, G_GNUC_UNUSED gpointer dummy) { MooToolAction *action; - const char *lang_id; MooLang *lang; gboolean visible; @@ -737,10 +736,9 @@ check_visible_func (MooAction *_action, g_return_if_fail (action->data != NULL); lang = moo_text_view_get_lang (MOO_TEXT_VIEW (doc)); - lang_id = lang ? lang->id : MOO_LANG_NONE; visible = NULL != g_slist_find_custom (action->data->langs, - lang_id, + moo_lang_id (lang), (GCompareFunc) strcmp); g_value_set_boolean (prop_value, visible);