Re: How to scroll to a specific line

2018-07-27 Thread John Coppens
On Fri, 27 Jul 2018 07:32:13 -0400
Reuben Rissler  wrote:

> I have also seen place_cursor_onscreen() work well. Now the thing is, 
> none of this will work until the Gtk.SourceView has properly been 
> rendered. This means doing something like:
> 
>          self.source_buffer.set_text("my text")
>          GLib.idle_add(self.scroll_function)
> 
>      def scroll_function (self):
>          # your scroll code here, like you use already
> 
> So you see, the scroll part is not the problem, but rather the 
> calculations of iters fails, because these iters are not yet, or are 
> invalidated when the buffer/view changes.

Hello Reuben.

Thanks for the suggestion. Believe it or not, I had just arrived at that
same solution! I first tried to use GLib.timeout_add(), and that worked too,
if the time was larger than 300 - 400 ms, which is on the verge of annoying.
I then tried idle_add(), and I guess that makes the 300-400ms 'built-in'.

Now, can this visible delay be eliminated? Maybe disabling the scroll
animation alltogether? (it's really visually a scrolling issue) I haven't seen
this problem in Geany (which I believe uses scintilla).

I did a more complete description of the issue on Stackoverflow, because, at
first, I didn't see my question appearing on the mailing list here:

https://stackoverflow.com/questions/51558047/how-to-select-and-scroll-a-specific-line-in-gtksource

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


Re: [PyGObject] Drag & Drop in a TreeView

2018-07-27 Thread c.buhtz--- via gtk-app-devel-list
Dear Reuben

On 2018-07-23 08:03 Reuben Rissler  wrote:
> This is how I have done it in the past. Note, I do not proclaim 
> spectacular or Pythonic code, and would humbly accept any corrections 
> and/or better ways to accomplish this. It seems to me there should be
> a way to let the TreeView do this work itself, but alas, I have not
> found it yet.

Your code works for me - thank you very much. But I also have the
question if anyone here could improve it or show a more easier and
elegant way.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to scroll to a specific line

2018-07-27 Thread Reuben Rissler

On 07/26/2018 02:17 PM, John Coppens wrote:

get_iter_at_line, place_cursor, place_cursor_onscreen, and others. Even tried to
more or less calculate the scroll position and manipulate the vadjustments.

An example:
 itr = self.tbff.get_iter_at_line(linenr)
 self.tbff.place_cursor(itr)
 self.tview.place_cursor_onscreen()

I suspect that the problem may come from the fact that the widget has not
been rendered yet. I also tried to defer the actual scroll to GLib.idle_add,
but that didn't work out either.



This has worked for me:


        text_iter = self.source_buffer.get_iter_at_line (linenr)
        self.source_buffer.place_cursor(text_iter)
        self.source_view.scroll_to_iter(text_iter, 0.1, True, 0.0, 0.5)

I have also seen place_cursor_onscreen() work well. Now the thing is, 
none of this will work until the Gtk.SourceView has properly been 
rendered. This means doing something like:


        self.source_buffer.set_text("my text")
        GLib.idle_add(self.scroll_function)

    def scroll_function (self):
        # your scroll code here, like you use already

So you see, the scroll part is not the problem, but rather the 
calculations of iters fails, because these iters are not yet, or are 
invalidated when the buffer/view changes.


Cheers, Reuben


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

How to scroll to a specific line

2018-07-27 Thread John Coppens
Hi all...

I've been looking at many posts and articles from all over Google, didn't find
any solution that works.

I'm using Gtk-3, introspection, and Python 3. I've tried many combinations of

get_iter_at_line, place_cursor, place_cursor_onscreen, and others. Even tried to
more or less calculate the scroll position and manipulate the vadjustments.

An example:
itr = self.tbff.get_iter_at_line(linenr)
self.tbff.place_cursor(itr)
self.tview.place_cursor_onscreen()

I suspect that the problem may come from the fact that the widget has not
been rendered yet. I also tried to defer the actual scroll to GLib.idle_add,
but that didn't work out either.

Can anyone point me in the right direction?

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