summaryrefslogtreecommitdiff
path: root/libview
diff options
context:
space:
mode:
authorNelson Benitez Leon <[email protected]>2013-08-14 10:37:03 +0200
committermonsta <[email protected]>2018-04-02 14:13:03 +0300
commitac75aa493d154655d85a3000ff722cc1b3b0eec8 (patch)
tree8bc9fff8d1186643edf53e2bd1ca5269e96a88cd /libview
parent4b345b72c7211c74c12402e9c498f1273241acd6 (diff)
downloadatril-ac75aa493d154655d85a3000ff722cc1b3b0eec8.tar.bz2
atril-ac75aa493d154655d85a3000ff722cc1b3b0eec8.tar.xz
libview: fix annotation window focus change after creation
Be able to start entering text right after selecting or creating an annotation, also hide text cursor when window goes unfocused (backdrop state). https://bugzilla.gnome.org/show_bug.cgi?id=668446 taken from: https://git.gnome.org/browse/evince/commit/?id=fc8fe57
Diffstat (limited to 'libview')
-rw-r--r--libview/ev-annotation-window.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/libview/ev-annotation-window.c b/libview/ev-annotation-window.c
index 6e0ee9ed..776187f2 100644
--- a/libview/ev-annotation-window.c
+++ b/libview/ev-annotation-window.c
@@ -247,14 +247,14 @@ ev_annotation_window_set_resize_cursor (GtkWidget *widget,
}
}
-static gboolean
-text_view_button_press (GtkWidget *widget,
- GdkEventButton *event,
- EvAnnotationWindow *window)
+static void
+text_view_state_flags_changed (GtkWidget *widget,
+ GtkStateFlags previous_flags)
{
- ev_annotation_window_grab_focus (window);
+ GtkStateFlags current_flags = gtk_widget_get_state_flags (widget);
- return FALSE;
+ if (current_flags & GTK_STATE_FLAG_BACKDROP)
+ gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (widget), FALSE);
}
static void
@@ -315,9 +315,9 @@ ev_annotation_window_init (EvAnnotationWindow *window)
GTK_POLICY_AUTOMATIC);
window->text_view = gtk_text_view_new ();
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (window->text_view), GTK_WRAP_WORD);
- g_signal_connect (window->text_view, "button_press_event",
- G_CALLBACK (text_view_button_press),
- window);
+ g_signal_connect (window->text_view, "state-flags-changed",
+ G_CALLBACK (text_view_state_flags_changed),
+ window);
gtk_container_add (GTK_CONTAINER (swindow), window->text_view);
gtk_widget_show (window->text_view);
@@ -493,6 +493,10 @@ ev_annotation_window_focus_in_event (GtkWidget *widget,
window->in_move = FALSE;
}
+ gtk_widget_grab_focus (window->text_view);
+ send_focus_change (window->text_view, TRUE);
+ gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (window->text_view), TRUE);
+
return FALSE;
}