gtk+ r22168 - in trunk: . gtk
- From: matthiasc svn gnome org
- To: svn-commits-list gnome org
- Subject: gtk+ r22168 - in trunk: . gtk
- Date: Thu, 22 Jan 2009 00:33:54 +0000 (UTC)
Author: matthiasc
Date: Thu Jan 22 00:33:54 2009
New Revision: 22168
URL: http://svn.gnome.org/viewvc/gtk+?rev=22168&view=rev
Log:
Implement select-by-words for selectable labels
Modified:
trunk/ChangeLog
trunk/gtk/gtklabel.c
Modified: trunk/gtk/gtklabel.c
==============================================================================
--- trunk/gtk/gtklabel.c (original)
+++ trunk/gtk/gtklabel.c Thu Jan 22 00:33:54 2009
@@ -69,6 +69,7 @@
gint drag_start_y;
guint in_drag : 1;
+ guint select_words : 1;
};
enum {
@@ -3335,6 +3336,8 @@
return FALSE;
label->select_info->in_drag = FALSE;
+ label->select_info->select_words = FALSE;
+
if (event->button == 1)
{
if (!GTK_WIDGET_HAS_FOCUS (widget))
@@ -3352,6 +3355,7 @@
if (event->type == GDK_2BUTTON_PRESS)
{
+ label->select_info->select_words = TRUE;
gtk_label_select_word (label);
return TRUE;
}
@@ -3504,7 +3508,6 @@
if (label->select_info == NULL)
return FALSE;
-
if ((event->state & GDK_BUTTON1_MASK) == 0)
return FALSE;
@@ -3537,9 +3540,48 @@
{
get_layout_index (label, x, y, &index);
- gtk_label_select_region_index (label,
- label->select_info->selection_anchor,
- index);
+ if (label->select_info->select_words)
+ {
+ gint min, max;
+ gint old_min, old_max;
+ gint anchor, end;
+
+ min = gtk_label_move_backward_word (label, index);
+ max = gtk_label_move_forward_word (label, index);
+
+ anchor = label->select_info->selection_anchor;
+ end = label->select_info->selection_end;
+
+ old_min = MIN (anchor, end);
+ old_max = MAX (anchor, end);
+
+ if (min < old_min)
+ {
+ anchor = min;
+ end = old_max;
+ }
+ else if (old_max < max)
+ {
+ anchor = max;
+ end = old_min;
+ }
+ else if (anchor == old_min)
+ {
+ if (anchor != min)
+ anchor = max;
+ }
+ else
+ {
+ if (anchor != max)
+ anchor = min;
+ }
+
+ gtk_label_select_region_index (label, anchor, end);
+ }
+ else
+ gtk_label_select_region_index (label,
+ label->select_info->selection_anchor,
+ index);
}
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]