Disable the comments action when not supported to avoid confusion

This commit is contained in:
Stephen Collins 2019-12-15 19:54:45 -07:00 committed by Michael Webster
parent 5fae2771c8
commit 55e386beef
1 changed files with 20 additions and 0 deletions

View File

@ -1859,14 +1859,34 @@ language_changed (GObject *object,
{ {
GtkSourceLanguage *new_language; GtkSourceLanguage *new_language;
const gchar *label; const gchar *label;
GtkAction *action;
new_language = gtk_source_buffer_get_language (GTK_SOURCE_BUFFER (object)); new_language = gtk_source_buffer_get_language (GTK_SOURCE_BUFFER (object));
if (new_language) if (new_language)
{
label = gtk_source_language_get_name (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 else
{
label = _("Plain Text"); 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); xed_status_menu_button_set_label (XED_STATUS_MENU_BUTTON (window->priv->language_button), label);
} }