Re: GtkTextView: annoying delay


just found out that it has to do something with the cursor,
When it blinks it updates the last character so inserting a:
   gtk_text_view_set_cursor_visible (tv, FALSE);
   gtk_text_view_set_cursor_visible (tv, TRUE);
at the end of tb_insert_text fixes my problem ...
Interestingly, if i only add:
   gtk_text_view_set_cursor_visible (tv, FALSE);
to hide the cursor, the last character _never_ gets blue.

probably there is a better solution ?

thanks anyway,

-Maximilian Treiber

Maximilian Treiber wrote:

Hi List,

i have a small problem with a simple program:

#include <gtk/gtk.h>

static void tb_insert_text (GtkTextBuffer *tb, GtkTextIter *iter, gchar *c, gint len, GtkTextView *tv)
   GtkTextIter s;
   GtkTextIter e;
   gtk_text_buffer_get_bounds (tb, &s, &e);
   gtk_text_buffer_apply_tag_by_name (tb, "test", &s, &e);
   gtk_widget_queue_draw (GTK_WIDGET (tv));

int main (int argc, char *argv[])
   GtkWidget *window;
   GtkWidget *tv;
   GtkTextBuffer *tb;
   gtk_init (&argc, &argv);
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_window_set_default_size (GTK_WINDOW (window), 400, 400);
   tb = gtk_text_buffer_new (NULL);
   tv = gtk_text_view_new_with_buffer (tb);
g_signal_connect_after (G_OBJECT (tb), "insert-text", G_CALLBACK (tb_insert_text), tv);
   gtk_text_buffer_create_tag (tb, "test", "foreground", "blue", NULL);
   gtk_container_add (GTK_CONTAINER (window), tv);
   gtk_widget_show (tv);
   gtk_widget_show (window);
   gtk_main ();
   return 0;

All the text should get tagged with the "test"-tag and turned blue after a user enters some text into the TextView.

Now, when i enter a single character at the end of the the text, the character stays black for a second until it gets blue. This is very annoying because the final program has to react very quick to new user input. Is there a way to force the Buffer/View to apply and display the tag immediately ? I already tried gtk_widget_queue_draw() as you can see, with no visible results. Also, i tried to do the hightlighting on the "changed" event, insteat of after the "insert-text" event ...


-Maximilian Treiber

gtk-app-devel-list mailing list
gtk-app-devel-list gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]