GtkTextBuffer *buffer)
{
GtkTextViewPrivate *priv;
+ GtkTextBuffer *old_buffer;
g_return_if_fail (GTK_IS_TEXT_VIEW (text_view));
g_return_if_fail (buffer == NULL || GTK_IS_TEXT_BUFFER (buffer));
if (priv->buffer == buffer)
return;
+ old_buffer = priv->buffer;
if (priv->buffer != NULL)
{
/* Destroy all anchored children */
if (priv->layout)
gtk_text_layout_set_buffer (priv->layout, NULL);
- g_object_unref (priv->buffer);
priv->dnd_mark = NULL;
priv->first_para_mark = NULL;
cancel_pending_scroll (text_view);
}
}
+ _gtk_text_view_accessible_set_buffer (text_view, old_buffer);
+ if (old_buffer)
+ g_object_unref (old_buffer);
+
g_object_notify (G_OBJECT (text_view), "buffer");
if (gtk_widget_get_visible (GTK_WIDGET (text_view)))
{
gtk_text_view_reset_im_context (text_view);
- if (event->button == 1)
+ if (gdk_event_triggers_context_menu ((GdkEvent *) event))
+ {
+ gtk_text_view_do_popup (text_view, event);
+ return TRUE;
+ }
+ else if (event->button == 1)
{
/* If we're in the selection, start a drag copy/move of the
* selection; otherwise, start creating a new selection.
if (gtk_text_buffer_get_selection_bounds (get_buffer (text_view),
&start, &end) &&
gtk_text_iter_in_range (&iter, &start, &end) &&
- !(event->state & GDK_SHIFT_MASK))
+ !(event->state &
+ gtk_widget_get_modifier_mask (widget,
+ GDK_MODIFIER_INTENT_EXTEND_SELECTION)))
{
priv->drag_start_x = event->x;
priv->drag_start_y = event->y;
priv->editable);
return TRUE;
}
- else if (event->button == 3)
- {
- gtk_text_view_do_popup (text_view, event);
- return TRUE;
- }
}
else if ((event->type == GDK_2BUTTON_PRESS ||
event->type == GDK_3BUTTON_PRESS) &&
"interior-focus", &interior_focus,
NULL);
- if (gtk_widget_has_focus (widget) && !interior_focus)
+ if (gtk_widget_has_visible_focus (widget) && !interior_focus)
{
GtkStyleContext *context;
old_xpos = priv->xoffset;
old_ypos = priv->yoffset;
gtk_text_view_move_viewport (text_view, scroll_step, count);
- if ((old_xpos != priv->xoffset || old_ypos != priv->yoffset) &&
+ if ((old_xpos == priv->xoffset && old_ypos == priv->yoffset) &&
leave_direction != -1 &&
!gtk_widget_keynav_failed (GTK_WIDGET (text_view),
leave_direction))
orig_start = ins;
orig_end = bound;
- if (button->state & GDK_SHIFT_MASK)
+ if (button->state &
+ gtk_widget_get_modifier_mask (GTK_WIDGET (text_view),
+ GDK_MODIFIER_INTENT_EXTEND_SELECTION))
{
/* Extend selection */
GtkTextIter old_ins, old_bound;
monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
gtk_menu_set_monitor (menu, monitor_num);
- gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+ gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
*x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width));
*y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));
GtkTextView *text_view;
gint button;
guint time;
+ GdkDevice *device;
} PopupInfo;
static gboolean
0,
priv->popup_menu);
- if (info->button)
- gtk_menu_popup (GTK_MENU (priv->popup_menu), NULL, NULL,
- NULL, NULL,
+ if (info->device)
+ gtk_menu_popup_for_device (GTK_MENU (priv->popup_menu),
+ info->device, NULL, NULL, NULL, NULL, NULL,
info->button, info->time);
else
{
{
info->button = event->button;
info->time = event->time;
+ info->device = event->device;
}
else
{
info->button = 0;
info->time = gtk_get_current_event_time ();
+ info->device = NULL;
}
gtk_clipboard_request_contents (gtk_widget_get_clipboard (GTK_WIDGET (text_view),
gtk_text_layout_get_cursor_locations (priv->layout, &iter,
&strong, &weak);
- /* cursor width calculation as in gtkstyle.c:draw_insertion_cursor(),
+ /* cursor width calculation as in gtkstylecontext.c:draw_insertion_cursor(),
* ignoring the text direction be exposing both sides of the cursor
*/