Remove debug output.

2006-12-24  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtktextutil.c: Remove debug output.

        * gtk/gtktextview.c: Improve the DND scrolling
        behaviour.  (#92387, Carlos Garnacho Parro)
This commit is contained in:
Matthias Clasen
2006-12-25 03:57:39 +00:00
committed by Matthias Clasen
parent 502a54a17c
commit e7e84bb8ec
3 changed files with 58 additions and 31 deletions

View File

@@ -1,5 +1,10 @@
2006-12-24 Matthias Clasen <mclasen@redhat.com>
* gtk/gtktextutil.c: Remove debug output.
* gtk/gtktextview.c: Improve the DND scrolling
behaviour. (#92387, Carlos Garnacho Parro)
* gtk/gtkaccellabel.c: Improve translators comments.
(#389298, Christian Persch)

View File

@@ -327,16 +327,12 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
gtk_text_layout_validate (layout, DRAG_ICON_MAX_HEIGHT);
gtk_text_layout_get_size (layout, &layout_width, &layout_height);
g_print ("%s: layout size %d %d\n", G_STRFUNC, layout_width, layout_height);
layout_width = MIN (layout_width, DRAG_ICON_MAX_WIDTH);
layout_height = MIN (layout_height, DRAG_ICON_MAX_HEIGHT);
pixmap_width = layout_width + DRAG_ICON_LAYOUT_BORDER * 2;
pixmap_height = layout_height + DRAG_ICON_LAYOUT_BORDER * 2;
g_print ("%s: pixmap size %d %d\n", G_STRFUNC, pixmap_width, pixmap_height);
drawable = gdk_pixmap_new (widget->window,
pixmap_width + 2, pixmap_height + 2, -1);

View File

@@ -1,3 +1,4 @@
/* -*- Mode: C; c-file-style: "gnu"; tab-width: 8 -*- */
/* GTK - The GIMP Toolkit
* gtktextview.c Copyright (C) 2000 Red Hat, Inc.
*
@@ -5507,18 +5508,25 @@ gtk_text_view_unselect (GtkTextView *text_view)
static void
get_iter_at_pointer (GtkTextView *text_view,
GtkTextIter *iter)
GtkTextIter *iter,
gint *x,
gint *y)
{
gint x, y;
gint xcoord, ycoord;
GdkModifierType state;
gdk_window_get_pointer (text_view->text_window->bin_window,
&x, &y, &state);
&xcoord, &ycoord, &state);
gtk_text_layout_get_iter_at_pixel (text_view->layout,
iter,
x + text_view->xoffset,
y + text_view->yoffset);
xcoord + text_view->xoffset,
ycoord + text_view->yoffset);
if (x)
*x = xcoord;
if (y)
*y = ycoord;
}
static void
@@ -5528,7 +5536,7 @@ move_mark_to_pointer_and_scroll (GtkTextView *text_view,
GtkTextIter newplace;
GtkTextMark *mark;
get_iter_at_pointer (text_view, &newplace);
get_iter_at_pointer (text_view, &newplace, NULL, NULL);
mark = gtk_text_buffer_get_mark (get_buffer (text_view), mark_name);
@@ -5561,26 +5569,55 @@ selection_scan_timeout (gpointer data)
return TRUE; /* remain installed. */
}
#define DND_SCROLL_MARGIN 0.20
#define UPPER_OFFSET_ANCHOR 0.8
#define LOWER_OFFSET_ANCHOR 0.2
static gboolean
check_scroll (gdouble offset, GtkAdjustment *adj)
{
if ((offset > UPPER_OFFSET_ANCHOR &&
adj->value + adj->page_size < adj->upper) ||
(offset < LOWER_OFFSET_ANCHOR &&
adj->value > adj->lower))
return TRUE;
return FALSE;
}
static gint
drag_scan_timeout (gpointer data)
{
GtkTextView *text_view;
GtkTextIter newplace;
gint x, y, width, height;
gdouble pointer_xoffset, pointer_yoffset;
text_view = GTK_TEXT_VIEW (data);
get_iter_at_pointer (text_view, &newplace);
get_iter_at_pointer (text_view, &newplace, &x, &y);
gdk_drawable_get_size (text_view->text_window->bin_window, &width, &height);
gtk_text_buffer_move_mark (get_buffer (text_view),
text_view->dnd_mark,
&newplace);
DV(g_print (G_STRLOC": scrolling onscreen\n"));
gtk_text_view_scroll_to_mark (text_view,
text_view->dnd_mark,
DND_SCROLL_MARGIN, FALSE, 0.0, 0.0);
pointer_xoffset = (gdouble) x / width;
pointer_yoffset = (gdouble) y / height;
if (check_scroll (pointer_xoffset, text_view->hadjustment) ||
check_scroll (pointer_yoffset, text_view->vadjustment))
{
/* do not make offsets surpass lower nor upper anchors, this makes
* scrolling speed relative to the distance of the pointer to the
* anchors when it moves beyond them.
*/
pointer_xoffset = CLAMP (pointer_xoffset, LOWER_OFFSET_ANCHOR, UPPER_OFFSET_ANCHOR);
pointer_yoffset = CLAMP (pointer_yoffset, LOWER_OFFSET_ANCHOR, UPPER_OFFSET_ANCHOR);
gtk_text_view_scroll_to_mark (text_view,
text_view->dnd_mark,
0., TRUE, pointer_xoffset, pointer_yoffset);
}
return TRUE;
}
@@ -5709,7 +5746,7 @@ selection_motion_event_handler (GtkTextView *text_view,
gtk_text_buffer_get_iter_at_mark (buffer, &orig_start, data->orig_start);
gtk_text_buffer_get_iter_at_mark (buffer, &orig_end, data->orig_end);
get_iter_at_pointer (text_view, &cursor);
get_iter_at_pointer (text_view, &cursor, NULL, NULL);
start = cursor;
extend_selection (text_view, data->granularity, &start, &end);
@@ -6302,20 +6339,9 @@ gtk_text_view_drag_motion (GtkWidget *widget,
gtk_text_mark_set_visible (text_view->dnd_mark, FALSE);
}
gtk_text_buffer_move_mark (get_buffer (text_view),
text_view->dnd_mark,
&newplace);
DV(g_print (G_STRLOC": scrolling to mark\n"));
gtk_text_view_scroll_to_mark (text_view,
text_view->dnd_mark,
DND_SCROLL_MARGIN, FALSE, 0.0, 0.0);
if (text_view->scroll_timeout != 0) /* reset on every motion event */
g_source_remove (text_view->scroll_timeout);
text_view->scroll_timeout =
gdk_threads_add_timeout (50, drag_scan_timeout, text_view);
if (!text_view->scroll_timeout)
text_view->scroll_timeout =
gdk_threads_add_timeout (100, drag_scan_timeout, text_view);
/* TRUE return means don't propagate the drag motion to parent
* widgets that may also be drop sites.