I'm writing a gedit plugin for gtk3. Is there an easy way to get the name of the current document using python ?
Asked
Active
Viewed 908 times
2 Answers
2
Here is a very good tutorial on writing gedit 3 plugins. The example #3 does what you want: connect to a "open new tab" signal and write the document name.
And here you have the complete Gedit API reference.
handler_id = self.window.connect("tab-added", self.on_tab_added)
(...)
def on_tab_added(self, window, tab, data=None):
document = tab.get_document()
print "'%s' has been added." % document.get_short_name_for_display()
print "New file's path: %s" % document.get_uri_for_display()

Erman Kadir Kahraman
- 469
- 6
- 6

César García Tapia
- 3,326
- 4
- 27
- 51
-
Cheers. It would be nice if they had a reference in python as it would be clearer to see as a python developer. – Stuart Axon Jan 16 '13 at 13:40
-
Get used to read the C documentation, is the best documented. And, as the python binding is automatically generated, it's very easy to "translate" from C to python: **(C)** gedit_document_goto_line (doc,line) -> **(python)** doc.goto_line (line) – César García Tapia Jan 16 '13 at 13:48
1
I think you'd improve your chances of getting an answer by asking on the gedit mailing list.
There's also a GEdit python plugin howto on the GNOME wiki.

double-beep
- 5,031
- 17
- 33
- 41

liberforce
- 11,189
- 37
- 48