Re: [gedit-list] Scheduling timers from plugins



> Also, thanks for providing those version numbers. That was another question of mine
> looming on the horizon. Where'd you find this?

I'm not sure whether you're asking about (a) Python version numbers in gedit, or (b) gedit version numbers in Ubuntu, but here's where you could find both:

(a) I just updated the section "How to write plugins" on the Gedit Plugins wiki page (https://wiki.gnome.org/Apps/Gedit/Plugins) to explain which versions of Python work with which versions of gedit.  This had previously been announced on this mailing list (https://mail.gnome.org/archives/gedit-list/2012-November/msg00001.html) but wasn't really documented until now, I think.

(b) The site packages.ubuntu.com shows which versions of packages such as gedit are contained in each Ubuntu release.

cheers
adam

On Sat, Oct 26, 2013 at 9:14 PM, Dustin Oprea <myselfasunder gmail com> wrote:

I was in a hurry and forgot.

I've confirmed that GObject.timeout_add() and .timeout_add_seconds() work.


Thank you, Adam. Also, thanks for providing those version numbers. That was another question of mine looming on the horizon. Where'd you find this?

Dustin

On Oct 26, 2013 7:09 PM, "Adam Dingle" <adam medovina org> wrote:
Dustin,

first, it's best to cc the entire list when you reply, since others may be able to help too (or at least may be interested in what's discussed).

I'd look at the source to the Snippets plugin which comes with gedit - it's written in Python and includes calls to timeout_add.  On a 64-bit Ubuntu system, you could find this at

/usr/lib/x86_64-linux-gnu/gedit/plugins/snippets/

Alternatively, you could download a gedit tarball at http://ftp.gnome.org/pub/GNOME/sources/gedit/ or get the sources using git (see https://git.gnome.org/browse/gedit).

Note that gedit 3.6 (and earlier) uses Python 2.x, but gedit 3.8 (and later) uses Python 3.x.  So if you write your plugin using Python 2.x now, you'll have to port to Python 3.x when you upgrade to Ubuntu 13.10, which includes gedit 3.8.3.

Also note that the way to call timeout_add is apparently different in these two versions of Python.  Specifically, gedit-3.6.2/plugins/snippets/snippets/document.py has 'GObject.timeout_add(...)' for Python 2.x, but in gedit 3.8.3 this code reads 'GLib.timeout_add(...)' for Python 3.x.  I'd also look at the import statements at the top of this file for whichever version of Python you want to use.  If all this works in the Snippets plugin, it should work in yours too.  :)

adam

On Sat, Oct 26, 2013 at 6:48 PM, Dustin Oprea <myselfasunder gmail com> wrote:
Since everything breaks when I import gobject, I thought that it might belong to a previous GTK/PyGTK version. Since I found some examples using glib.timeout_add() and glib.timeout_add_seconds() (using "glib" rather than "gobject"), I tried doing this as well. I don't get any import related errors (the error in the previous method occurs on import), but I do get another seg-fault. I was guessing that this happens simply because there is some violation in a late-type binding (like those methods can't actually be found on "glib", at the time of invocation).

Python: 2.7.4
Gedit: 3.6.2
Distro: Ubuntu/13.04
Glib package: libglib2.0-0



Dustin Oprea


On Sat, Oct 26, 2013 at 6:24 PM, Adam Dingle <adam medovina org> wrote:
Dustin,

I'd like to think you should be able to use gobject.timeout_add() and gobject.timeout_add_seconds().  I don't think they will interfere with GTK's loop.  Regarding the error when you import gobject:

- which version of Python are you using?
- which version of gedit?
- do you know which version of GLib is installed on your system?
- which version of which operating system (e.g. Debian, Fedora, Ubuntu) are you running?

adam

On Sat, Oct 26, 2013 at 6:17 PM, Dustin Oprea <myselfasunder gmail com> wrote:
What's an acceptable strategy to regularly invoke functionality in a Python plugin (via some kind of timer)?

The only examples I can find for timers with PyGTK, in general, are gobject.timeout_add() and gobject.timeout_add_seconds(), but I think they're deprecated as the plugin completely ceases to work when I import gobject (I get a "type object 'gobject.GObject' has no attribute 'ref" error).

I'm also assuming that normal Python timers might interfere with GTK's loop, so I shouldn't be using them.


Dustin Oprea




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