[gedit-list] [Help Needed] How to get the buffer of a newly opened file from a gedit plugin file?



I've written a code for a Gedit Plugin which opens another file,

self.window.create_tab_from_location(Gio.file_new_for_path(file_path), 
                                    None, line_number, 0, False, True)

Now, after the file gets opened in a separate tab. I want access to its buffer. I wrote the following code for that

view = self.window.get_active_view()
buffer = view.get_buffer()

Somehow, I'm unable to access the buffer.

I opened Gedit from the terminal, so I tried printing the value of the view object before and after opening the new file and I'm getting the following values:

pallab pallab:~$ gedit

<View object at 0x7ff6965d4120 (GeditView at 0x22ee3f0)>
<View object at 0x7ff696560ab0 (GeditView at 0x22ee700)>

The first result was before the window.create_tab_from_location was executed and the second one was after that.

I tried printing the buffer after that. So, I added another line

view = self.window.get_active_view()                                  
buffer = view.get_buffer()                                            
print (buffer.get_text(buffer.get_start_iter(), buffer.get_end_iter(), False)


But, it didn't print anything.

So, how do I get access to this new file's buffer?

OS : Ubuntu 14.04 LTS

Gedit version: 3.10.4



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