Skip to content

Commit 6816696

Browse files
monstaraveit65
authored andcommitted
libview: fix text selection with mouse in annotation window
taken from: GNOME/evince@91ac78b
1 parent efe29e6 commit 6816696

File tree

1 file changed

+32
-23
lines changed

1 file changed

+32
-23
lines changed

libview/ev-annotation-window.c

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,34 @@ ev_annotation_window_close (EvAnnotationWindow *window)
280280
g_signal_emit (window, signals[CLOSED], 0);
281281
}
282282

283+
static gboolean
284+
ev_annotation_window_button_press_event (GtkWidget *widget,
285+
GdkEventButton *event)
286+
{
287+
EvAnnotationWindow *window = EV_ANNOTATION_WINDOW (widget);
288+
289+
if (event->type == GDK_BUTTON_PRESS && event->button == 1) {
290+
window->in_move = TRUE;
291+
window->x = event->x_root - event->x;
292+
window->y = event->y_root - event->y;
293+
gtk_window_begin_move_drag (GTK_WINDOW (widget),
294+
event->button,
295+
event->x_root,
296+
event->y_root,
297+
event->time);
298+
return TRUE;
299+
}
300+
301+
return FALSE;
302+
}
303+
283304
static void
284305
ev_annotation_window_init (EvAnnotationWindow *window)
285306
{
286307
GtkWidget *vbox, *hbox;
287308
GtkWidget *icon;
288309
GtkWidget *swindow;
310+
GtkWidget *header;
289311
GtkIconTheme *icon_theme;
290312
GdkPixbuf *pixbuf;
291313

@@ -302,10 +324,19 @@ ev_annotation_window_init (EvAnnotationWindow *window)
302324
gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
303325
gtk_widget_show (icon);
304326

327+
header = gtk_event_box_new ();
328+
gtk_widget_add_events (header, GDK_BUTTON_PRESS_MASK);
329+
g_signal_connect_swapped (header, "button-press-event",
330+
G_CALLBACK (ev_annotation_window_button_press_event),
331+
window);
332+
305333
window->title = gtk_label_new (NULL);
306-
gtk_box_pack_start (GTK_BOX (hbox), window->title, TRUE, TRUE, 0);
334+
gtk_container_add (GTK_CONTAINER (header), window->title);
307335
gtk_widget_show (window->title);
308336

337+
gtk_box_pack_start (GTK_BOX (hbox), header, TRUE, TRUE, 0);
338+
gtk_widget_show (header);
339+
309340
window->close_button = gtk_button_new ();
310341
gtk_button_set_relief (GTK_BUTTON (window->close_button), GTK_RELIEF_NONE);
311342
gtk_container_set_border_width (GTK_CONTAINER (window->close_button), 0);
@@ -464,27 +495,6 @@ ev_annotation_window_constructor (GType type,
464495
return object;
465496
}
466497

467-
static gboolean
468-
ev_annotation_window_button_press_event (GtkWidget *widget,
469-
GdkEventButton *event)
470-
{
471-
EvAnnotationWindow *window = EV_ANNOTATION_WINDOW (widget);
472-
473-
if (event->type == GDK_BUTTON_PRESS && event->button == 1) {
474-
window->in_move = TRUE;
475-
window->x = event->x_root - event->x;
476-
window->y = event->y_root - event->y;
477-
gtk_window_begin_move_drag (GTK_WINDOW (widget),
478-
event->button,
479-
event->x_root,
480-
event->y_root,
481-
event->time);
482-
return TRUE;
483-
}
484-
485-
return FALSE;
486-
}
487-
488498
static gboolean
489499
ev_annotation_window_configure_event (GtkWidget *widget,
490500
GdkEventConfigure *event)
@@ -543,7 +553,6 @@ ev_annotation_window_class_init (EvAnnotationWindowClass *klass)
543553
g_object_class->set_property = ev_annotation_window_set_property;
544554
g_object_class->dispose = ev_annotation_window_dispose;
545555

546-
gtk_widget_class->button_press_event = ev_annotation_window_button_press_event;
547556
gtk_widget_class->configure_event = ev_annotation_window_configure_event;
548557
gtk_widget_class->focus_in_event = ev_annotation_window_focus_in_event;
549558
gtk_widget_class->focus_out_event = ev_annotation_window_focus_out_event;

0 commit comments

Comments
 (0)