Disable the comments action when not supported to avoid confusion
This commit is contained in:
parent
5fae2771c8
commit
55e386beef
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue