Commit 2c8bfd58 authored by Christian Hergert's avatar Christian Hergert

view: update change-case action enabled state

When the selection changes, we need to change the activation sensitivity
of the underlying GAction exposed by the view.
parent b028492e
......@@ -1530,6 +1530,17 @@ buffer_style_scheme_changed_cb (GtkSourceBuffer *buffer,
gtk_source_view_update_style_scheme (view);
}
static void
buffer_has_selection_changed_cb (GtkSourceBuffer *buffer,
GParamSpec *pspec,
GtkSourceView *view)
{
gtk_widget_action_set_enabled (GTK_WIDGET (view),
"source.change-case",
(gtk_text_view_get_editable (GTK_TEXT_VIEW (view)) &&
gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (buffer))));
}
static void
implicit_trailing_newline_changed_cb (GtkSourceBuffer *buffer,
GParamSpec *pspec,
......@@ -1560,6 +1571,9 @@ remove_source_buffer (GtkSourceView *view)
buffer_style_scheme_changed_cb,
view);
g_signal_handlers_disconnect_by_func (priv->source_buffer,
buffer_has_selection_changed_cb,
view);
g_signal_handlers_disconnect_by_func (priv->source_buffer,
implicit_trailing_newline_changed_cb,
view);
......@@ -1614,6 +1628,11 @@ set_source_buffer (GtkSourceView *view,
G_CALLBACK (implicit_trailing_newline_changed_cb),
view);
g_signal_connect (buffer,
"notify::has-selection",
G_CALLBACK (buffer_has_selection_changed_cb),
view);
buffer_internal = _gtk_source_buffer_internal_get_from_buffer (priv->source_buffer);
g_signal_connect (buffer_internal,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment