View Full Version : Screensavers, previews and python
Firewing1
18th November 2006, 11:15 PM
Hey,
I'm trying to figure out how to make a screensaver preview program in Python. I've been looking at the gnome-screensaver code, and it seems because it's in C it can use Gdk functions python can't.
Anyone know way to make a little box that shown the preview of a screensaver in there with Python?
Firewing1
Firewing1
29th January 2007, 12:41 AM
Anyone? The C code uses GtkDrawable as the widget - How would I map the screensaver to display there?
Firewing1
bob
29th January 2007, 12:45 AM
Please read the Guidelines and note the invisible rules about bumping your post. After all, it's only been two and a half months. Give it time.... :D
mwette
29th January 2007, 12:59 AM
#!/usr/bin/env python
import gtk
def destroy(*args): gtk.main_quit()
def expose(wid, *args): wid.show()
if 1:
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
image = gtk.Image()
image.set_from_file('/usr/share/icons/Bluecurve/96x96/mimetypes/file.png')
window.add(image)
window.connect("destroy", destroy)
window.connect('expose_event', expose)
window.show_all()
gtk.main()
Also, try the tutorial (http://pygtk.org/pygtk2tutorial/index.html) .
[EDIT: of course you may want to use things like scrollable windows, but it should be doable]
Firewing1
29th January 2007, 02:38 AM
That works for a single icon, though - I'd (ideally) like for it to be a real-time preview of the screensaver.
Firewing1
Firewing1
29th January 2007, 03:27 AM
Was looking at the gnome-screensaver code, turn out they use their own custom widget (that's what the Drawable's for).
gdk_spawn_on_screen_with_pipes - The C function that does exactly what I want to do... Except I can't find it for python!
Firewing1
mwette
29th January 2007, 04:56 AM
That works for a single icon, though - I'd (ideally) like for it to be a real-time preview of the screensaver.
Firewing1
Well you DID say
I'm trying to figure out how to make a screensaver preview program in Python.
implying that you want to do the work :)
You can always generate a c hook for that routine. But what do you want it to do?
There is lots of pygtk capability. Many GDK routines are bound into pygtk.
Firewing1
29th January 2007, 05:20 AM
Just show a miniature version of the screensaver in a widget - I asked on #pygtk, they said the same thing ('subprocess' module in Python). Hopefully I'll figure out some simple C code and then just run the helper command as a child.
Firewing1
brunson
29th January 2007, 05:26 AM
I think you're searching from the wrong direction.
All of the screen savers are executable, you can run then and they display in their own window. It's probably a default behavior if not given any other display directives. They also have to be written to an API specified by xscreensaver. You'd have to reimplement the environment (pix buffer, whatever) and the call them the same way xscreensaver does. Whether that's doable with the pyGTK bindings, I don't know, but there doesn't seem to be anything xscreensaver specific they're dynamically linked against, though they may have to be compiled against statically.
I'd recommend looking at how to write a plugin for xscreensaver, you'll probably discover more about the the hooks they require to be run by another application.
Firewing1
31st January 2007, 12:09 AM
Yeah - I'll look into it, but the thing is I'm going this for gnome-screensaver...
Firewing1
brunson
31st January 2007, 12:22 AM
They're interchangable. gnome-screensaver is pretty much a port of xscreensaver to the gnome environment. Plus, I'm pretty sure the modules are compatible.
Firewing1
31st January 2007, 02:48 AM
I've been looking, there's no way in python to do it. I even checked the GTK/PYGTK sources, the gdk_spawn_* commands are in the .override ignore lists :(
Firewing1
mwette
31st January 2007, 03:00 AM
Are you trying to write something like gnome-screensaver-preferences?
Firewing1
31st January 2007, 03:48 AM
Yes, but this program will generate custom .desktop files so that one can easily customize a xscreensaver and then use it in gnome-screensaver.
Firewing1
Firewing1
17th February 2007, 05:45 PM
Found it! I can use a plug and socket to embed windows into one another. Basically I'll have a Drawable area that acts like a my virtual window, then I'll sock-plug the xscreensaver into it.
Firewing1
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.