2005-09-09 Matthias Clasen <mclasen@redhat.com>
+
+ Stop cursor blinking in non-editable regions of a text view.
+ (#311508, Torbjörn Andersson)
+ * gtk/gtktextview.c (gtk_text_view_check_cursor_blink):
+ (cursor_blinks): Take editability into account when deciding
+ whether the cursor blinks.
+ (gtk_text_view_button_release_event):
+ (gtk_text_view_move_cursor_internal): Update cursor blinking here.
+
+ * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_start_editing):
+ Use connect_after to connect to the focus_out event. This
+ ensures that the entry has already stopped blinking by the time
+ we emit the edited signal. (#315229, Thomas Leonard)
+
* tests/testgtk.c: Use GDK_MOD1_MASK, not GDK_ALT_MASK.
* gtk/gtkwindow.c (gtk_window_parse_geometry): Don't set
2005-09-09 Matthias Clasen <mclasen@redhat.com>
+
+ Stop cursor blinking in non-editable regions of a text view.
+ (#311508, Torbjörn Andersson)
+ * gtk/gtktextview.c (gtk_text_view_check_cursor_blink):
+ (cursor_blinks): Take editability into account when deciding
+ whether the cursor blinks.
+ (gtk_text_view_button_release_event):
+ (gtk_text_view_move_cursor_internal): Update cursor blinking here.
+
+ * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_start_editing):
+ Use connect_after to connect to the focus_out event. This
+ ensures that the entry has already stopped blinking by the time
+ we emit the edited signal. (#315229, Thomas Leonard)
+
* tests/testgtk.c: Use GDK_MOD1_MASK, not GDK_ALT_MASK.
* gtk/gtkwindow.c (gtk_window_parse_geometry): Don't set
event->y + text_view->yoffset);
gtk_text_buffer_place_cursor (get_buffer (text_view), &iter);
-
+ gtk_text_view_check_cursor_blink (text_view);
+
text_view->pending_place_cursor_button = 0;
return FALSE;
#endif
if (gtk_debug_flags & GTK_DEBUG_UPDATES)
return FALSE;
-
+
if (text_view->editable)
{
- g_object_get (settings, "gtk-cursor-blink", &blink, NULL);
- return blink;
+ GtkTextMark *insert;
+ GtkTextIter iter;
+
+ insert = gtk_text_buffer_get_insert (get_buffer (text_view));
+ gtk_text_buffer_get_iter_at_mark (get_buffer (text_view), &iter, insert);
+
+ if (gtk_text_iter_editable (&iter, text_view->editable))
+ {
+ g_object_get (settings, "gtk-cursor-blink", &blink, NULL);
+ return blink;
+ }
}
- else
- return FALSE;
+
+ return FALSE;
}
static gint
{
if (text_view->layout != NULL &&
text_view->cursor_visible &&
- GTK_WIDGET_HAS_FOCUS (text_view))
+ GTK_WIDGET_HAS_FOCUS (text_view) &&
+ cursor_blinks (text_view))
{
- if (cursor_blinks (text_view))
+ if (text_view->blink_timeout == 0)
{
- if (text_view->blink_timeout == 0)
- {
- gtk_text_layout_set_cursor_visible (text_view->layout, TRUE);
-
- text_view->blink_timeout = g_timeout_add (get_cursor_time (text_view) * CURSOR_OFF_MULTIPLIER,
- blink_cb,
- text_view);
- }
+ gtk_text_layout_set_cursor_visible (text_view->layout, TRUE);
+
+ text_view->blink_timeout = g_timeout_add (get_cursor_time (text_view) * CURSOR_OFF_MULTIPLIER,
+ blink_cb,
+ text_view);
}
- else
- gtk_text_layout_set_cursor_visible (text_view->layout, TRUE);
}
else
{
gtk_text_view_stop_cursor_blink (text_view);
+ gtk_text_layout_set_cursor_visible (text_view->layout, TRUE);
}
}
static void
-gtk_text_view_pend_cursor_blink(GtkTextView *text_view)
+gtk_text_view_pend_cursor_blink (GtkTextView *text_view)
{
if (text_view->layout != NULL &&
text_view->cursor_visible &&
GTK_WIDGET_HAS_FOCUS (text_view) &&
cursor_blinks (text_view))
{
- if (text_view->blink_timeout != 0)
- {
- g_source_remove (text_view->blink_timeout);
- text_view->blink_timeout = 0;
- }
-
+ gtk_text_view_stop_cursor_blink (text_view);
gtk_text_layout_set_cursor_visible (text_view->layout, TRUE);
text_view->blink_timeout = g_timeout_add (get_cursor_time (text_view) * CURSOR_PEND_MULTIPLIER,
"insert",
new_location);
else
- gtk_text_buffer_place_cursor (get_buffer (text_view),
- new_location);
+ gtk_text_buffer_place_cursor (get_buffer (text_view),
+ new_location);
+ gtk_text_view_check_cursor_blink (text_view);
}
static void
if (step == GTK_MOVEMENT_PAGES)
{
gtk_text_view_scroll_pages (text_view, count, extend_selection);
+ gtk_text_view_check_cursor_blink (text_view);
gtk_text_view_pend_cursor_blink (text_view);
return;
}
else if (step == GTK_MOVEMENT_HORIZONTAL_PAGES)
{
gtk_text_view_scroll_hpages (text_view, count, extend_selection);
+ gtk_text_view_check_cursor_blink (text_view);
gtk_text_view_pend_cursor_blink (text_view);
return;
}
gtk_text_view_set_virtual_cursor_pos (text_view, cursor_x_pos, -1);
}
+ gtk_text_view_check_cursor_blink (text_view);
gtk_text_view_pend_cursor_blink (text_view);
}
}
gtk_text_buffer_select_range (buffer, &end, &start);
-
+ gtk_text_view_check_cursor_blink (text_view);
+
text_view->selection_drag_handler = g_signal_connect (text_view,
"motion_notify_event",
G_CALLBACK (selection_motion_event_handler),