Re: Force liststore to update when leaving treeview

2019-02-12 Thread Reuben Rissler




On 02/12/2019 11:32 AM, Mike Martin via gtk-app-devel-list wrote:

Is this possible?
Yes. I did this a while back, but would need to find an archive to 
provide you with exact code.


I have a (for example) a grid which contains
Various action widgets
And a Treeview based on a liststore

Is there any way to make sure that the changes made to a cell in the
liststore are "committed" if I click on one of the other widgets

I cant find anything to do this and if I leave the cell without pressing
enter or clicking on another cell, all changes are lost
Connect to the GtkCellRenderer "editing-started" signal. In that 
callback, you will have an GtkEntry (GtkCellEditable) object. Connect to 
the Entry's "changed" signal and keep a permanent string around with the 
text the user is typing. Also preserve the path and column being edited 
(obtained with "editing-started").


Also connect to GtkCellRenderer "editing-canceled" signal. In this 
callback, use the path, column, and text you retained from 
"editing-started", and update the ListStore.


thanks

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



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


Re: Scrolling to a line in GtkTextView

2019-02-12 Thread Reuben Rissler




On 02/12/2019 12:47 PM, Mitko Haralanov via gtk-app-devel-list wrote:

Hi,

In my application, I would like to have a GtkTextView be scrolled to a
particular line after the GtkTextBuffer is loaded.
This was already discussed 
https://stackoverflow.com/questions/48934458/gtk-sourceview-scroll-to-mark-not-working.


Basically, the GUI calculations are not done and the lines aren't 
calculated, therefore you need to scroll after the GUI rendering is 
finished. Use idle_add or timeout_add.


According to the documentation, I can use gtk_text_view_scroll_to_mark() in
order to reliably scroll to the desired line after the line height
computation has been completed. In practice that doesn't work reliably.
Below is the code snippet that I am using:


while (delay++ < 100)
g_main_context_iteration(NULL, FALSE);
debug("Scrolling to line: %lu", lineno);
gtk_text_buffer_get_iter_at_line(GTK_TEXT_BUFFER(priv->sourceBuf),
, (gint)(lineno - 1));
debug("Line: %d, offset: %d", gtk_text_iter_get_line(),
   gtk_text_iter_get_offset());
gtk_text_buffer_place_cursor(GTK_TEXT_BUFFER(priv->sourceBuf), );
mark = gtk_text_buffer_get_mark(GTK_TEXT_BUFFER(priv->sourceBuf),
"result-view-search");
gtk_text_buffer_move_mark(GTK_TEXT_BUFFER(priv->sourceBuf), mark,
   );
gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(priv->sourceView), mark, 0.0,
  TRUE, 0.0, 0.5);

What I am noticing is that the reliability of this highly depends on the
line number to which I want to scroll and the length of the busy loop in
the beginning - the higher the line number, the longer the busy loop needs
to be in order to reliably scroll to that line.

If the busy loop is not long enough, the text view does scroll but not the
correct line.

What is the proper way to correctly and reliably scroll a GtkTextView to a
certain line?

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



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


Re: Force liststore to update when leaving treeview

2019-02-12 Thread Reuben Rissler




On 02/12/2019 12:25 PM, Mitko Haralanov via gtk-app-devel-list wrote:

One idea is to hook the widget to the "leave-notify-event", which will
be triggered when the mouse leaves the widget.
Have you used this with a GtkTreeView? I mean, actually implemented what 
Mike Martin is requesting?


On Tue, Feb 12, 2019 at 8:32 AM Mike Martin via gtk-app-devel-list
 wrote:

Is this possible?

I have a (for example) a grid which contains
Various action widgets
And a Treeview based on a liststore

Is there any way to make sure that the changes made to a cell in the
liststore are "committed" if I click on one of the other widgets

I cant find anything to do this and if I leave the cell without pressing
enter or clicking on another cell, all changes are lost

thanks

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

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



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


Scrolling to a line in GtkTextView

2019-02-12 Thread Mitko Haralanov via gtk-app-devel-list
Hi,

In my application, I would like to have a GtkTextView be scrolled to a
particular line after the GtkTextBuffer is loaded.

According to the documentation, I can use gtk_text_view_scroll_to_mark() in
order to reliably scroll to the desired line after the line height
computation has been completed. In practice that doesn't work reliably.
Below is the code snippet that I am using:


while (delay++ < 100)
g_main_context_iteration(NULL, FALSE);
debug("Scrolling to line: %lu", lineno);
gtk_text_buffer_get_iter_at_line(GTK_TEXT_BUFFER(priv->sourceBuf),
, (gint)(lineno - 1));
debug("Line: %d, offset: %d", gtk_text_iter_get_line(),
  gtk_text_iter_get_offset());
gtk_text_buffer_place_cursor(GTK_TEXT_BUFFER(priv->sourceBuf), );
mark = gtk_text_buffer_get_mark(GTK_TEXT_BUFFER(priv->sourceBuf),
"result-view-search");
gtk_text_buffer_move_mark(GTK_TEXT_BUFFER(priv->sourceBuf), mark,
  );
gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(priv->sourceView), mark, 0.0,
 TRUE, 0.0, 0.5);

What I am noticing is that the reliability of this highly depends on the
line number to which I want to scroll and the length of the busy loop in
the beginning - the higher the line number, the longer the busy loop needs
to be in order to reliably scroll to that line.

If the busy loop is not long enough, the text view does scroll but not the
correct line.

What is the proper way to correctly and reliably scroll a GtkTextView to a
certain line?

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


Re: Force liststore to update when leaving treeview

2019-02-12 Thread Mitko Haralanov via gtk-app-devel-list
One idea is to hook the widget to the "leave-notify-event", which will
be triggered when the mouse leaves the widget.

On Tue, Feb 12, 2019 at 8:32 AM Mike Martin via gtk-app-devel-list
 wrote:
>
> Is this possible?
>
> I have a (for example) a grid which contains
> Various action widgets
> And a Treeview based on a liststore
>
> Is there any way to make sure that the changes made to a cell in the
> liststore are "committed" if I click on one of the other widgets
>
> I cant find anything to do this and if I leave the cell without pressing
> enter or clicking on another cell, all changes are lost
>
> thanks
>
> Mike
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Force liststore to update when leaving treeview

2019-02-12 Thread Mike Martin via gtk-app-devel-list
Is this possible?

I have a (for example) a grid which contains
Various action widgets
And a Treeview based on a liststore

Is there any way to make sure that the changes made to a cell in the
liststore are "committed" if I click on one of the other widgets

I cant find anything to do this and if I leave the cell without pressing
enter or clicking on another cell, all changes are lost

thanks

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