Re: [gedit-list] Gedit signals



Benjamin Gramlich wrote:
I'm playing around with developing a gedit plugin to automatically
indent text based on language syntax. Is there a way to connect to a
signal from the creation of a new line or the keypress of "Enter"?

ciao,

bg

_______________________________________________
gedit-list mailing list
gedit-list gnome org
http://mail.gnome.org/mailman/listinfo/gedit-list

Hello,

I guess there's more than a single way to do this, and someone else might give you a better answer, but here are a couple of ways. Basically, the plugin system let's you view things as if your code is just part of a GTK application (PyGTK, if you're using Python). So, for example:

  1. If you look at the code of the completion plugin
     (http://guichaz.free.fr/gedit-completion), you can see how to
     directly catch a key-press event.
  2. If you look at
     http://live.gnome.org/Gedit/PythonPluginHowTo#head-1ec3d77628f1d0a14686652680bc3f8ceedea7e6,
     you can see how to get the window object. You can call its
     get_active_doc() method to get the active document. Once you have
     the document, you can connect to its "changed" signal (see
     http://www.pygtk.org/docs/pygtk/class-gtktextbuffer.html). You can
     use this (as well as other methods) for your purpose.

The main point is that a PyGTK tutorial/reference (or GTK+, if you're using C) will usually give you what you need. The API of gedit per-se is quite small (which is a good thing).

HTH,

Ami



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