From 54a8c6c616fa4c334f59d1f79f02720c0d91e22f Mon Sep 17 00:00:00 2001 From: JosephMcc Date: Tue, 5 Sep 2017 00:21:09 -0700 Subject: [PATCH] Don't present users with the hidden highlight languages (#167) Fixes a crash when choosing 'Defaults' as the the highlight language. Adapted from https://github.com/GNOME/gedit/commit/0434e2f9188cb39b51408859e3e30a8a625b41c6 Closes https://github.com/linuxmint/xed/issues/160 --- xed/xed-window.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/xed/xed-window.c b/xed/xed-window.c index 4adb551..7a7496d 100644 --- a/xed/xed-window.c +++ b/xed/xed-window.c @@ -837,7 +837,11 @@ get_languages_sorted_by_section (XedWindow *window) GtkSourceLanguage *lang; lang = gtk_source_language_manager_get_language (lm, ids[i]); - languages = g_slist_prepend (languages, lang); + + if (!gtk_source_language_get_hidden (lang)) + { + languages = g_slist_prepend (languages, lang); + } } return g_slist_sort (languages, (GCompareFunc)language_compare); @@ -1691,14 +1695,18 @@ fill_language_combo (XedWindow *window) GtkSourceLanguage *lang; lang = gtk_source_language_manager_get_language (lm, ids[i]); - name = gtk_source_language_get_name (lang); - menu_item = gtk_menu_item_new_with_label (name); - gtk_widget_show (menu_item); - g_object_set_data_full (G_OBJECT (menu_item), LANGUAGE_DATA, g_object_ref (lang), - (GDestroyNotify) g_object_unref); - xed_status_combo_box_add_item (XED_STATUS_COMBO_BOX (window->priv->language_combo), - GTK_MENU_ITEM (menu_item), name); + if (!gtk_source_language_get_hidden (lang)) + { + name = gtk_source_language_get_name (lang); + menu_item = gtk_menu_item_new_with_label (name); + gtk_widget_show (menu_item); + + g_object_set_data_full (G_OBJECT (menu_item), LANGUAGE_DATA, g_object_ref (lang), + (GDestroyNotify) g_object_unref); + xed_status_combo_box_add_item (XED_STATUS_COMBO_BOX (window->priv->language_combo), + GTK_MENU_ITEM (menu_item), name); + } } }