new function (which I then decided not to use but I think it's needed to

2002-01-17  Havoc Pennington  <hp@redhat.com>
	* gtk/gtktextlayout.c (_gtk_text_layout_get_line_xrange): new
	function (which I then decided not to use but I think it's needed
	to fix #68963
	* gtk/gtktextview.c: add page_horizontally action signal and
	implement Ctrl+PgUp, Ctrl+PgDown based on patch from Padraig,
	hackily modified to avoid adding GTK_MOVEMENT_ API. Part of
	#53934
	* gtk/gtkmarshalers.list: add NONE:INT,BOOL
This commit is contained in:
Havoc Pennington 2002-01-17 22:38:18 +00:00 committed by Havoc Pennington
parent cf25093441
commit 9e404f2a1e
17 changed files with 332 additions and 20 deletions

View File

@ -1,3 +1,16 @@
2002-01-17 Havoc Pennington <hp@redhat.com>
* gtk/gtktextlayout.c (_gtk_text_layout_get_line_xrange): new
function (which I then decided not to use but I think it's needed
to fix #68963
* gtk/gtktextview.c: add page_horizontally action signal and
implement Ctrl+PgUp, Ctrl+PgDown based on patch from Padraig,
hackily modified to avoid adding GTK_MOVEMENT_ API. Part of
#53934
* gtk/gtkmarshalers.list: add NONE:INT,BOOL
Thu Jan 17 17:02:38 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_real_unrealize): Call

View File

@ -1,3 +1,16 @@
2002-01-17 Havoc Pennington <hp@redhat.com>
* gtk/gtktextlayout.c (_gtk_text_layout_get_line_xrange): new
function (which I then decided not to use but I think it's needed
to fix #68963
* gtk/gtktextview.c: add page_horizontally action signal and
implement Ctrl+PgUp, Ctrl+PgDown based on patch from Padraig,
hackily modified to avoid adding GTK_MOVEMENT_ API. Part of
#53934
* gtk/gtkmarshalers.list: add NONE:INT,BOOL
Thu Jan 17 17:02:38 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_real_unrealize): Call

View File

@ -1,3 +1,16 @@
2002-01-17 Havoc Pennington <hp@redhat.com>
* gtk/gtktextlayout.c (_gtk_text_layout_get_line_xrange): new
function (which I then decided not to use but I think it's needed
to fix #68963
* gtk/gtktextview.c: add page_horizontally action signal and
implement Ctrl+PgUp, Ctrl+PgDown based on patch from Padraig,
hackily modified to avoid adding GTK_MOVEMENT_ API. Part of
#53934
* gtk/gtkmarshalers.list: add NONE:INT,BOOL
Thu Jan 17 17:02:38 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_real_unrealize): Call

View File

@ -1,3 +1,16 @@
2002-01-17 Havoc Pennington <hp@redhat.com>
* gtk/gtktextlayout.c (_gtk_text_layout_get_line_xrange): new
function (which I then decided not to use but I think it's needed
to fix #68963
* gtk/gtktextview.c: add page_horizontally action signal and
implement Ctrl+PgUp, Ctrl+PgDown based on patch from Padraig,
hackily modified to avoid adding GTK_MOVEMENT_ API. Part of
#53934
* gtk/gtkmarshalers.list: add NONE:INT,BOOL
Thu Jan 17 17:02:38 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_real_unrealize): Call

View File

@ -1,3 +1,16 @@
2002-01-17 Havoc Pennington <hp@redhat.com>
* gtk/gtktextlayout.c (_gtk_text_layout_get_line_xrange): new
function (which I then decided not to use but I think it's needed
to fix #68963
* gtk/gtktextview.c: add page_horizontally action signal and
implement Ctrl+PgUp, Ctrl+PgDown based on patch from Padraig,
hackily modified to avoid adding GTK_MOVEMENT_ API. Part of
#53934
* gtk/gtkmarshalers.list: add NONE:INT,BOOL
Thu Jan 17 17:02:38 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_real_unrealize): Call

View File

@ -1,3 +1,16 @@
2002-01-17 Havoc Pennington <hp@redhat.com>
* gtk/gtktextlayout.c (_gtk_text_layout_get_line_xrange): new
function (which I then decided not to use but I think it's needed
to fix #68963
* gtk/gtktextview.c: add page_horizontally action signal and
implement Ctrl+PgUp, Ctrl+PgDown based on patch from Padraig,
hackily modified to avoid adding GTK_MOVEMENT_ API. Part of
#53934
* gtk/gtkmarshalers.list: add NONE:INT,BOOL
Thu Jan 17 17:02:38 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_real_unrealize): Call

View File

@ -1,3 +1,16 @@
2002-01-17 Havoc Pennington <hp@redhat.com>
* gtk/gtktextlayout.c (_gtk_text_layout_get_line_xrange): new
function (which I then decided not to use but I think it's needed
to fix #68963
* gtk/gtktextview.c: add page_horizontally action signal and
implement Ctrl+PgUp, Ctrl+PgDown based on patch from Padraig,
hackily modified to avoid adding GTK_MOVEMENT_ API. Part of
#53934
* gtk/gtkmarshalers.list: add NONE:INT,BOOL
Thu Jan 17 17:02:38 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_real_unrealize): Call

View File

@ -2550,12 +2550,6 @@ Internal function used by #GtkHPaned and #GtkVPaned
@child1_req:
@child2_req:
<!-- ##### MACRO gtk_paned_handle_size ##### -->
<para>
Old name for gtk_paned_set_handle_size().
</para>
<!-- ##### FUNCTION gtk_paned_set_handle_size ##### -->
<para>
Set the the handle size to @size x @size pixels.

View File

@ -96,9 +96,9 @@ Creates a new #GtkMenu.
Adds a new #GtkMenuItem to the end of the menu's item list.
</para>
<!-- # Unused Parameters # -->
@menu: a #GtkMenu.
@child: The #GtkMenuItem to add.
<!-- # Unused Parameters # -->
@m:
@c:
@ -108,9 +108,9 @@ Adds a new #GtkMenuItem to the end of the menu's item list.
Adds a new #GtkMenuItem to the beginning of the menu's item list.
</para>
<!-- # Unused Parameters # -->
@menu: a #GtkMenu.
@child: The #GtkMenuItem to add.
<!-- # Unused Parameters # -->
@menu_child:
@m:
@c:
@ -122,10 +122,10 @@ Adds a new #GtkMenuItem to the menu's item list at the position
indicated by @position.
</para>
<!-- # Unused Parameters # -->
@menu: a #GtkMenu.
@child: The #GtkMenuItem to add.
@pos:
<!-- # Unused Parameters # -->
@position: The position in the item list where @child is added.
Positions are numbered from 0 to n-1.

View File

@ -407,6 +407,7 @@ gtk_notebook_set_current_page() instead.
@notebook: the object which received the signal.
@arg1:
@Returns:
<!-- ##### SIGNAL GtkNotebook::focus-tab ##### -->
<para>
@ -423,6 +424,7 @@ gtk_notebook_set_current_page() instead.
@notebook: the object which received the signal.
@arg1:
@Returns:
<!-- ##### SIGNAL GtkNotebook::switch-page ##### -->
<para>

View File

@ -95,6 +95,13 @@ parameters. This is equivalent to
@child: the child to add
<!-- ##### MACRO gtk_paned_handle_size ##### -->
<para>
Old name for gtk_paned_set_handle_size().
</para>
<!-- ##### MACRO gtk_paned_gutter_size ##### -->
<para>
Old name for gtk_paned_set_gutter_size().

View File

@ -648,6 +648,15 @@ in an idle job in the background.
@textview: the object which received the signal.
@arg1:
<!-- ##### SIGNAL GtkTextView::page-horizontally ##### -->
<para>
</para>
@textview: the object which received the signal.
@arg1:
@arg2:
<!-- ##### SIGNAL GtkTextView::paste-clipboard ##### -->
<para>

View File

@ -36,6 +36,7 @@ INT:POINTER
NONE:BOOLEAN
NONE:ENUM
NONE:INT
NONE:INT,BOOL
NONE:INT,INT
NONE:NONE
NONE:STRING,INT,POINTER

View File

@ -2249,6 +2249,45 @@ gtk_text_layout_get_line_yrange (GtkTextLayout *layout,
}
}
/**
* _gtk_text_layout_get_line_xrange:
* @layout: a #GtkTextLayout
* @iter: a #GtkTextIter
* @x: location to store the top of the paragraph in pixels,
* or %NULL.
* @width location to store the height of the paragraph in pixels,
* or %NULL.
*
* Find the range of X coordinates for the paragraph containing
* the given iter. Private for 2.0 due to API freeze, could
* be made public for 2.2.
**/
void
_gtk_text_layout_get_line_xrange (GtkTextLayout *layout,
const GtkTextIter *iter,
gint *x,
gint *width)
{
GtkTextLine *line;
g_return_if_fail (GTK_IS_TEXT_LAYOUT (layout));
g_return_if_fail (_gtk_text_iter_get_btree (iter) == _gtk_text_buffer_get_btree (layout->buffer));
line = _gtk_text_iter_get_text_line (iter);
if (x)
*x = 0; /* FIXME This is wrong; should represent the first available cursor position */
if (width)
{
GtkTextLineData *line_data = _gtk_text_line_get_data (line, layout);
if (line_data)
*width = line_data->width;
else
*width = 0;
}
}
void
gtk_text_layout_get_iter_location (GtkTextLayout *layout,
const GtkTextIter *iter,

View File

@ -345,6 +345,10 @@ void gtk_text_layout_get_line_yrange (GtkTextLayout *layout,
const GtkTextIter *iter,
gint *y,
gint *height);
void _gtk_text_layout_get_line_xrange (GtkTextLayout *layout,
const GtkTextIter *iter,
gint *x,
gint *width);
void gtk_text_layout_get_cursor_locations (GtkTextLayout *layout,
GtkTextIter *iter,
GdkRectangle *strong_pos,

View File

@ -109,6 +109,7 @@ enum
SET_SCROLL_ADJUSTMENTS,
POPULATE_POPUP,
MOVE_CURSOR,
PAGE_HORIZONTALLY,
SET_ANCHOR,
INSERT_AT_CURSOR,
DELETE_FROM_CURSOR,
@ -223,13 +224,18 @@ static void gtk_text_view_set_scroll_adjustments (GtkTextView *text_view,
GtkAdjustment *vadj);
static void gtk_text_view_popup_menu (GtkWidget *widget);
static void gtk_text_view_move_cursor (GtkTextView *text_view,
GtkMovementStep step,
gint count,
gboolean extend_selection);
static void gtk_text_view_move_cursor (GtkTextView *text_view,
GtkMovementStep step,
gint count,
gboolean extend_selection);
static void gtk_text_view_page_horizontally (GtkTextView *text_view,
gint count,
gboolean extend_selection);
static void gtk_text_view_set_anchor (GtkTextView *text_view);
static void gtk_text_view_scroll_pages (GtkTextView *text_view,
gint count);
static void gtk_text_view_scroll_hpages (GtkTextView *text_view,
gint count);
static void gtk_text_view_insert_at_cursor (GtkTextView *text_view,
const gchar *str);
static void gtk_text_view_delete_from_cursor (GtkTextView *text_view,
@ -508,6 +514,7 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
container_class->forall = gtk_text_view_forall;
klass->move_cursor = gtk_text_view_move_cursor;
klass->page_horizontally = gtk_text_view_page_horizontally;
klass->set_anchor = gtk_text_view_set_anchor;
klass->insert_at_cursor = gtk_text_view_insert_at_cursor;
klass->delete_from_cursor = gtk_text_view_delete_from_cursor;
@ -649,6 +656,14 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
_gtk_marshal_VOID__ENUM_INT_BOOLEAN,
GTK_TYPE_NONE, 3, GTK_TYPE_MOVEMENT_STEP, GTK_TYPE_INT, GTK_TYPE_BOOL);
signals[PAGE_HORIZONTALLY] =
gtk_signal_new ("page_horizontally",
GTK_RUN_LAST | GTK_RUN_ACTION,
GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkTextViewClass, page_horizontally),
_gtk_marshal_VOID__INT_BOOLEAN,
GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_BOOL);
signals[SET_ANCHOR] =
gtk_signal_new ("set_anchor",
GTK_RUN_LAST | GTK_RUN_ACTION,
@ -735,7 +750,7 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
*/
binding_set = gtk_binding_set_by_class (klass);
/* Moving the insertion point */
add_move_binding (binding_set, GDK_Right, 0,
GTK_MOVEMENT_VISUAL_POSITIONS, 1);
@ -845,6 +860,46 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
add_move_binding (binding_set, GDK_KP_Page_Down, 0,
GTK_MOVEMENT_PAGES, 1);
gtk_binding_entry_add_signal (binding_set, GDK_Page_Up, GDK_CONTROL_MASK,
"page_horizontally", 2,
GTK_TYPE_INT, -1,
GTK_TYPE_BOOL, FALSE);
gtk_binding_entry_add_signal (binding_set, GDK_Page_Up, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
"page_horizontally", 2,
GTK_TYPE_INT, -1,
GTK_TYPE_BOOL, TRUE);
gtk_binding_entry_add_signal (binding_set, GDK_KP_Page_Up, GDK_CONTROL_MASK,
"page_horizontally", 2,
GTK_TYPE_INT, -1,
GTK_TYPE_BOOL, FALSE);
gtk_binding_entry_add_signal (binding_set, GDK_KP_Page_Up, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
"page_horizontally", 2,
GTK_TYPE_INT, -1,
GTK_TYPE_BOOL, TRUE);
gtk_binding_entry_add_signal (binding_set, GDK_Page_Down, GDK_CONTROL_MASK,
"page_horizontally", 2,
GTK_TYPE_INT, 1,
GTK_TYPE_BOOL, FALSE);
gtk_binding_entry_add_signal (binding_set, GDK_Page_Down, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
"page_horizontally", 2,
GTK_TYPE_INT, 1,
GTK_TYPE_BOOL, TRUE);
gtk_binding_entry_add_signal (binding_set, GDK_KP_Page_Down, GDK_CONTROL_MASK,
"page_horizontally", 2,
GTK_TYPE_INT, 1,
GTK_TYPE_BOOL, FALSE);
gtk_binding_entry_add_signal (binding_set, GDK_KP_Page_Down, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
"page_horizontally", 2,
GTK_TYPE_INT, 1,
GTK_TYPE_BOOL, TRUE);
/* Setting the cut/paste/copy anchor */
gtk_binding_entry_add_signal (binding_set, GDK_space, GDK_CONTROL_MASK,
@ -4329,11 +4384,16 @@ gtk_text_view_move_iter_by_lines (GtkTextView *text_view,
}
}
/* FIXME when we are unfrozen and can change GtkMovementStep,
* fix this
*/
#define PAGE_HORIZONTALLY_HACK_VALUE 57
static void
gtk_text_view_move_cursor (GtkTextView *text_view,
GtkMovementStep step,
gint count,
gboolean extend_selection)
gtk_text_view_move_cursor_internal (GtkTextView *text_view,
GtkMovementStep step,
gint count,
gboolean extend_selection)
{
GtkTextIter insert;
GtkTextIter newplace;
@ -4348,6 +4408,12 @@ gtk_text_view_move_cursor (GtkTextView *text_view,
gtk_text_view_pend_cursor_blink (text_view);
return;
}
else if (step == PAGE_HORIZONTALLY_HACK_VALUE)
{
gtk_text_view_scroll_hpages (text_view, count);
gtk_text_view_pend_cursor_blink (text_view);
return;
}
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view), &insert,
gtk_text_buffer_get_mark (get_buffer (text_view),
@ -4413,7 +4479,7 @@ gtk_text_view_move_cursor (GtkTextView *text_view,
else if (count < 0)
gtk_text_buffer_get_iter_at_offset (get_buffer (text_view), &newplace, 0);
break;
default:
break;
}
@ -4442,6 +4508,24 @@ gtk_text_view_move_cursor (GtkTextView *text_view,
gtk_text_view_pend_cursor_blink (text_view);
}
static void
gtk_text_view_move_cursor (GtkTextView *text_view,
GtkMovementStep step,
gint count,
gboolean extend_selection)
{
gtk_text_view_move_cursor_internal (text_view, step, count, extend_selection);
}
static void
gtk_text_view_page_horizontally (GtkTextView *text_view,
gint count,
gboolean extend_selection)
{
gtk_text_view_move_cursor_internal (text_view, PAGE_HORIZONTALLY_HACK_VALUE,
count, extend_selection);
}
static void
gtk_text_view_set_anchor (GtkTextView *text_view)
{
@ -4528,6 +4612,77 @@ gtk_text_view_scroll_pages (GtkTextView *text_view,
"insert"));
}
static void
gtk_text_view_scroll_hpages (GtkTextView *text_view,
gint count)
{
gdouble newval;
gdouble oldval;
GtkAdjustment *adj;
gint cursor_x_pos, cursor_y_pos;
GtkTextIter new_insert;
gint y, height;
gint x, width;
g_return_if_fail (text_view->hadjustment != NULL);
adj = text_view->hadjustment;
/* Validate the line that we're moving within.
*/
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view),
&new_insert,
gtk_text_buffer_get_mark (get_buffer (text_view), "insert"));
gtk_text_layout_get_line_yrange (text_view->layout, &new_insert, &y, &height);
gtk_text_layout_validate_yrange (text_view->layout, &new_insert, y, y + height);
/* FIXME do we need to update the adjustment ranges here? */
if (count < 0 && adj->value <= (adj->lower + 1e-12))
{
/* already at far left, just be sure we are at offset 0 */
gtk_text_iter_set_line_offset (&new_insert, 0);
gtk_text_buffer_place_cursor (get_buffer (text_view), &new_insert);
}
else if (count > 0 && adj->value >= (adj->upper - adj->page_size - 1e-12))
{
/* already at far right, just be sure we are at the end */
gtk_text_iter_forward_to_line_end (&new_insert);
gtk_text_buffer_place_cursor (get_buffer (text_view), &new_insert);
}
else
{
gtk_text_view_get_virtual_cursor_pos (text_view, &cursor_x_pos, &cursor_y_pos);
newval = adj->value;
oldval = adj->value;
newval += count * adj->page_increment;
set_adjustment_clamped (adj, newval);
cursor_x_pos += adj->value - oldval;
gtk_text_layout_get_iter_at_pixel (text_view->layout, &new_insert, cursor_x_pos, cursor_y_pos);
clamp_iter_onscreen (text_view, &new_insert);
gtk_text_buffer_place_cursor (get_buffer (text_view), &new_insert);
gtk_text_view_set_virtual_cursor_pos (text_view, cursor_x_pos, cursor_y_pos);
}
/* FIXME for lines shorter than the overall widget width, this results in a
* "bounce" effect as we scroll to the right of the widget, then scroll
* back to get the end of the line onscreen.
* http://bugzilla.gnome.org/show_bug.cgi?id=68963
*/
/* Adjust to have the cursor _entirely_ onscreen, move_mark_onscreen
* only guarantees 1 pixel onscreen.
*/
DV(g_print (G_STRLOC": scrolling onscreen\n"));
gtk_text_view_scroll_mark_onscreen (text_view,
gtk_text_buffer_get_mark (get_buffer (text_view),
"insert"));
}
static gboolean
whitespace (gunichar ch, gpointer user_data)
{

View File

@ -168,6 +168,15 @@ struct _GtkTextViewClass
GtkMovementStep step,
gint count,
gboolean extend_selection);
/* FIXME should be deprecated in favor of adding GTK_MOVEMENT_HORIZONTAL_PAGES
* or something in GTK 2.2, was put in to avoid adding enum values during
* the freeze.
*/
void (* page_horizontally) (GtkTextView *text_view,
gint count,
gboolean extend_selection);
/* move the "anchor" (what Emacs calls the mark) to the cursor position */
void (* set_anchor) (GtkTextView *text_view);
@ -187,7 +196,8 @@ struct _GtkTextViewClass
/* propagates to GtkWindow move_focus */
void (* move_focus) (GtkTextView *text_view,
GtkDirectionType direction);
GtkDirectionType direction);
GtkFunction pad1;
GtkFunction pad2;