Fix for bug #78499:

2003-03-29  Matthias Clasen  <maclas@gmx.de>

	Fix for bug #78499:

	* gtk/gtkentry.h (struct _GtkEntry): Add flags select_words and
	select_lines.

	* gtk/gtkentry.c (gtk_entry_button_press): Set select_words and
	select_lines on double/triple click.

	* gtk/gtkentry.c (gtk_entry_motion_notify): Implement
	select-by-words and select-by-lines behaviour.
This commit is contained in:
Matthias Clasen 2003-03-29 00:39:23 +00:00 committed by Matthias Clasen
parent bdd6e817d3
commit 490ebddc8c
7 changed files with 107 additions and 1 deletions

View File

@ -1,5 +1,16 @@
2003-03-29 Matthias Clasen <maclas@gmx.de>
Fix for bug #78499:
* gtk/gtkentry.h (struct _GtkEntry): Add flags select_words and
select_lines.
* gtk/gtkentry.c (gtk_entry_button_press): Set select_words and
select_lines on double/triple click.
* gtk/gtkentry.c (gtk_entry_motion_notify): Implement
select-by-words and select-by-lines behaviour.
Fixes for bug #56248:
* gtk/gtknotebook.c (stop_scrolling): New function to remove the

View File

@ -1,5 +1,16 @@
2003-03-29 Matthias Clasen <maclas@gmx.de>
Fix for bug #78499:
* gtk/gtkentry.h (struct _GtkEntry): Add flags select_words and
select_lines.
* gtk/gtkentry.c (gtk_entry_button_press): Set select_words and
select_lines on double/triple click.
* gtk/gtkentry.c (gtk_entry_motion_notify): Implement
select-by-words and select-by-lines behaviour.
Fixes for bug #56248:
* gtk/gtknotebook.c (stop_scrolling): New function to remove the

View File

@ -1,5 +1,16 @@
2003-03-29 Matthias Clasen <maclas@gmx.de>
Fix for bug #78499:
* gtk/gtkentry.h (struct _GtkEntry): Add flags select_words and
select_lines.
* gtk/gtkentry.c (gtk_entry_button_press): Set select_words and
select_lines on double/triple click.
* gtk/gtkentry.c (gtk_entry_motion_notify): Implement
select-by-words and select-by-lines behaviour.
Fixes for bug #56248:
* gtk/gtknotebook.c (stop_scrolling): New function to remove the

View File

@ -1,5 +1,16 @@
2003-03-29 Matthias Clasen <maclas@gmx.de>
Fix for bug #78499:
* gtk/gtkentry.h (struct _GtkEntry): Add flags select_words and
select_lines.
* gtk/gtkentry.c (gtk_entry_button_press): Set select_words and
select_lines on double/triple click.
* gtk/gtkentry.c (gtk_entry_motion_notify): Implement
select-by-words and select-by-lines behaviour.
Fixes for bug #56248:
* gtk/gtknotebook.c (stop_scrolling): New function to remove the

View File

@ -1,5 +1,16 @@
2003-03-29 Matthias Clasen <maclas@gmx.de>
Fix for bug #78499:
* gtk/gtkentry.h (struct _GtkEntry): Add flags select_words and
select_lines.
* gtk/gtkentry.c (gtk_entry_button_press): Set select_words and
select_lines on double/triple click.
* gtk/gtkentry.c (gtk_entry_motion_notify): Implement
select-by-words and select-by-lines behaviour.
Fixes for bug #56248:
* gtk/gtknotebook.c (stop_scrolling): New function to remove the

View File

@ -1303,6 +1303,9 @@ gtk_entry_button_press (GtkWidget *widget,
{
gboolean have_selection = gtk_editable_get_selection_bounds (editable, &sel_start, &sel_end);
entry->select_words = FALSE;
entry->select_lines = FALSE;
if (event->state & GDK_SHIFT_MASK)
{
gtk_entry_reset_im_context (entry);
@ -1328,10 +1331,12 @@ gtk_entry_button_press (GtkWidget *widget,
break;
case GDK_2BUTTON_PRESS:
entry->select_words = TRUE;
gtk_entry_select_word (entry);
break;
case GDK_3BUTTON_PRESS:
entry->select_lines = TRUE;
gtk_entry_select_line (entry);
break;
@ -1382,6 +1387,7 @@ gtk_entry_button_press (GtkWidget *widget,
* entry->in_drag which may have been set above
*/
entry->in_drag = FALSE;
entry->select_words = TRUE;
gtk_entry_select_word (entry);
break;
@ -1391,6 +1397,7 @@ gtk_entry_button_press (GtkWidget *widget,
* entry->in_drag which may have been set above
*/
entry->in_drag = FALSE;
entry->select_lines = TRUE;
gtk_entry_select_line (entry);
break;
@ -1460,9 +1467,12 @@ gtk_entry_motion_notify (GtkWidget *widget,
entry->mouse_cursor_obscured = FALSE;
}
if (event->window != entry->text_area || entry->button !=1)
if (event->window != entry->text_area || entry->button != 1)
return FALSE;
if (entry->select_lines)
return TRUE;
if (event->is_hint || (entry->text_area != event->window))
gdk_window_get_pointer (entry->text_area, NULL, NULL, NULL);
@ -1499,6 +1509,45 @@ gtk_entry_motion_notify (GtkWidget *widget,
else
tmp_pos = gtk_entry_find_position (entry, event->x + entry->scroll_offset);
if (entry->select_words)
{
gint min, max;
gint old_min, old_max;
gint pos, bound;
min = gtk_entry_move_backward_word (entry, tmp_pos);
max = gtk_entry_move_forward_word (entry, tmp_pos);
pos = entry->current_pos;
bound = entry->selection_bound;
old_min = MIN(entry->current_pos, entry->selection_bound);
old_max = MAX(entry->current_pos, entry->selection_bound);
if (min < old_min)
{
pos = min;
bound = old_max;
}
else if (old_max < max)
{
pos = max;
bound = old_min;
}
else if (pos == old_min)
{
if (entry->current_pos != min)
pos = max;
}
else
{
if (entry->current_pos != max)
pos = min;
}
gtk_entry_set_positions (entry, pos, bound);
}
else
gtk_entry_set_positions (entry, tmp_pos, -1);
}

View File

@ -90,6 +90,8 @@ struct _GtkEntry
guint mouse_cursor_obscured : 1;
guint select_words : 1;
guint select_lines : 1;
guint button;
guint blink_timeout;
guint recompute_idle;