Вопрос

I'm writing a gedit plugin for gtk3. Is there an easy way to get the name of the current document using python ?

Это было полезно?

Решение

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()

Другие советы

Someone here may know, but I think you'd improve your chances of getting an answer by asking on the gedit mailing list.

EDIT:

There's also a GEdit python plugin howto on the GNOME wiki.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top