Index: ChangeLog
===================================================================
--- ChangeLog	(revision 1311)
+++ ChangeLog	(working copy)
@@ -1,3 +1,9 @@
+2007-12-11  Li Yuan  <li.yuan@sun.com>
+
+	* gail/gaillabel.c: (gail_label_real_notify_gtk):
+	Bug #500679. Now we emit object:text-caret-moved when selection of
+	the text changed.
+
 2007-11-29  Tor Lillqvist  <tml@novell.com>
 
 	Make gail build again on Windows. Please note that the only reason
Index: gail/gaillabel.c
===================================================================
--- gail/gaillabel.c	(revision 1311)
+++ gail/gaillabel.c	(working copy)
@@ -373,6 +373,7 @@
       gint start, end;
       gboolean text_caret_moved = FALSE;
       gboolean selection_changed = FALSE;
+      gboolean is_start = TRUE;
 
       gail_obj = G_OBJECT (atk_obj);
       label = GTK_LABEL (widget);
@@ -382,13 +383,11 @@
           if (start != gail_label->cursor_position ||
               end != gail_label->selection_bound)
             {
+              if (end != gail_label->selection_bound)
+                is_start = FALSE;
               gail_label->selection_bound = end;
-              if (start != gail_label->cursor_position)
-                {
-                  /* cursor movement */
-                  gail_label->cursor_position = start;
-                  text_caret_moved = TRUE;
-                }
+              gail_label->cursor_position = start;
+              text_caret_moved = TRUE;
               if (start != end)
                 selection_changed = TRUE;
             }
@@ -399,12 +398,15 @@
             selection_changed = TRUE;
           if (gtk_label_get_selectable (label))
             {
-              gint old_cursor_position = gail_label->cursor_position;
-
+              if (gail_label->cursor_position != -1 && start != gail_label->cursor_position)
+                text_caret_moved = TRUE;
+              if (gail_label->selection_bound != -1 && end != gail_label->selection_bound)
+                {
+                  text_caret_moved = TRUE;
+                  is_start = FALSE;
+                }
               gail_label->cursor_position = start;
               gail_label->selection_bound = end;
-              if (old_cursor_position != -1 && start != old_cursor_position)
-                text_caret_moved = TRUE;
             }
           else
             {
@@ -414,11 +416,11 @@
               gail_label->selection_bound = 0;
               text_caret_moved = TRUE;
             }
-            
+
         }
         if (text_caret_moved)
           g_signal_emit_by_name (gail_obj, "text_caret_moved", 
-                                 gail_label->cursor_position);
+                                 is_start ? gail_label->cursor_position : gail_label->selection_bound);
         if (selection_changed)
           g_signal_emit_by_name (gail_obj, "text_selection_changed");
 
