"mark_set" callback fires 3 or 4 times when using arrow keys/mouse in textview?

2015-12-22 Thread David C. Rankin

All,

  I am using using the 'mark_set' signal to update the row:col values within my 
GtkTextBuffer. I have a simple setup with the textview inside a scrolled window 
inside a window:


  window
scrolled window
  textview

  I use a structure to hold the various persistent values for my application, 
for example:


typedef struct {
GtkWidget *window;
GtkWidget *view;
GtkTextBuffer *buffer;
GtkWidget *entry;
GtkTextMark *cursor;
gint line;/* line number   */
gint col; /* column number */
gint indent;
gint indentlevel;
gint tabsz;
gint winwidth;
gint winheight;
gboolean overwrite;
} context;

  All I am trying to do is update the current 'line' and 'col' values in the 
instance of the struct used with my application ('app'). Within my main window 
create function I initialize the values for 'context app;', create the window, 
scrolled window and textview, and connect the 'mark_set' signal to my 
'on_mark_set' callback, passing the instance of the struct as the data to the 
callback:


g_signal_connect (app->buffer, "mark_set",
  G_CALLBACK (on_mark_set), app);

  The 'on_mark_set' callback (with g_print for debug purposes):

void on_mark_set (GtkTextBuffer *buffer, context *app)
{
GtkTextIter iter;

app->cursor = gtk_text_buffer_get_insert (buffer);

gtk_text_buffer_get_iter_at_mark (buffer, , app->cursor);

app->line = gtk_text_iter_get_line ();
app->col = gtk_text_iter_get_line_offset ();

g_print (" line: %3d col: %d\n", app->line + 1, app->col + 1);
}

  The values for 'app->line' and 'app->col' are correctly set (only once) 
following each keypress where input is being provided to the buffer. e.g. 
inputting 'abc' into the textview results in:


$ ./bin/text_view_fn
 line:   1 col: 2
 line:   1 col: 3
 line:   1 col: 4

  However, when I use the arrow keys to move the input cursor or use the mouse 
to reposition it, the callback tripple-fires or quadruple-fires. e.g. pressing 
the left-arrow to backup one position results in the following:


 line:   1 col: 3
 line:   1 col: 3
 line:   1 col: 3

  or repositioning by clicking the mouse at the beginning results in a 
quadruple-fire of the callback:


 line:   1 col: 1
 line:   1 col: 1
 line:   1 col: 1
 line:   1 col: 1

  How can I limit the the execution of the 'on_mark_set' callback to a single 
call regardless of whether there is data being entered or if cursor is being 
moved with the arrow-keys or mouse? Any help will be greatly appreciated.



--
David C. Rankin, J.D.,P.E.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


gtk_image_new_from_file fails on Windows for SVG

2015-12-22 Thread Richard Shann
For a long time now I have been working around 
gtk_image_new_from_file ()

not working on windows trying to load SVG images. Instead I have used

pb = rsvg_pixbuf_from_file (filename, );

and then

gtk_image_new_from_pixbuf (pb)

and this works for some SVG images. However, even this is failing for
the SVG files generated by LilyPond, it generates an image with only the
background color.

I thought this might be due to the use of the syntax "currentColor" but
changing this to "black" did not help. I also noticed that rsvg library
has a change log entry for fixing rgb color parsing, so avoided that
syntax, but I still can't get the images to load on Windows. The Gtk
version being built (and run) against is 3.6.5 
Any suggestions what might be causing the trouble in LilyPond's output?

Richard


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list