From 55e386beefe724208be410e8d9e1af63a78cf67d Mon Sep 17 00:00:00 2001 From: Stephen Collins Date: Sun, 15 Dec 2019 19:54:45 -0700 Subject: [PATCH] Disable the comments action when not supported to avoid confusion --- xed/xed-window.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/xed/xed-window.c b/xed/xed-window.c index 9fe4c5d..0e1953f 100644 --- a/xed/xed-window.c +++ b/xed/xed-window.c @@ -1859,14 +1859,34 @@ language_changed (GObject *object, { GtkSourceLanguage *new_language; const gchar *label; + GtkAction *action; new_language = gtk_source_buffer_get_language (GTK_SOURCE_BUFFER (object)); if (new_language) + { label = gtk_source_language_get_name (new_language); + + action = gtk_action_group_get_action (window->priv->action_group, "EditToggleComment"); + gtk_action_set_sensitive (action, + gtk_source_language_get_metadata (new_language, "line-comment-start") != NULL); + + action = gtk_action_group_get_action (window->priv->action_group, "EditToggleCommentBlock"); + gtk_action_set_sensitive (action, + (gtk_source_language_get_metadata (new_language, "block-comment-start") != NULL + && gtk_source_language_get_metadata (new_language, "block-comment-end") != NULL)); + } else + { label = _("Plain Text"); + action = gtk_action_group_get_action (window->priv->action_group, "EditToggleComment"); + gtk_action_set_sensitive (action, FALSE); + + action = gtk_action_group_get_action (window->priv->action_group, "EditToggleCommentBlock"); + gtk_action_set_sensitive (action, FALSE); + } + xed_status_menu_button_set_label (XED_STATUS_MENU_BUTTON (window->priv->language_button), label); }