 |
 |
 |
 |
| Programming & Packaging A place to discuss programming and packaging. |

18th November 2006, 11:15 PM
|
 |
Administrator
|
|
Join Date: Dec 2004
Location: Canada
Age: 22
Posts: 9,224

|
|
|
Screensavers, previews and python
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
|

29th January 2007, 12:41 AM
|
 |
Administrator
|
|
Join Date: Dec 2004
Location: Canada
Age: 22
Posts: 9,224

|
|
|
Anyone? The C code uses GtkDrawable as the widget - How would I map the screensaver to display there?
Firewing1
|

29th January 2007, 12:45 AM
|
 |
Administrator (yeah, back again)
|
|
Join Date: Jul 2004
Location: Colton, NY; Junction of Heaven & Earth (also Routes 56 & 68).
Age: 67
Posts: 21,215

|
|
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....
__________________
Linux & Beer - That TOTALLY Computes!
Registered Linux User #362651
Don't use any of my solutions on working computers or near small children.
|

29th January 2007, 12:59 AM
|
|
Registered User
|
|
Join Date: Nov 2005
Location: Los Angeles area
Posts: 887

|
|
Code:
#!/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 .
[EDIT: of course you may want to use things like scrollable windows, but it should be doable]
|

29th January 2007, 02:38 AM
|
 |
Administrator
|
|
Join Date: Dec 2004
Location: Canada
Age: 22
Posts: 9,224

|
|
|
That works for a single icon, though - I'd (ideally) like for it to be a real-time preview of the screensaver.
Firewing1
|

29th January 2007, 03:27 AM
|
 |
Administrator
|
|
Join Date: Dec 2004
Location: Canada
Age: 22
Posts: 9,224

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

29th January 2007, 04:56 AM
|
|
Registered User
|
|
Join Date: Nov 2005
Location: Los Angeles area
Posts: 887

|
|
Quote:
|
Originally Posted by Firewing1
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
Quote:
|
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.
|

29th January 2007, 05:20 AM
|
 |
Administrator
|
|
Join Date: Dec 2004
Location: Canada
Age: 22
Posts: 9,224

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

29th January 2007, 05:26 AM
|
|
Registered User
|
|
Join Date: Jun 2005
Location: Westminster, Colorado
Posts: 2,304

|
|
|
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.
|

31st January 2007, 12:09 AM
|
 |
Administrator
|
|
Join Date: Dec 2004
Location: Canada
Age: 22
Posts: 9,224

|
|
|
Yeah - I'll look into it, but the thing is I'm going this for gnome-screensaver...
Firewing1
|

31st January 2007, 12:22 AM
|
|
Registered User
|
|
Join Date: Jun 2005
Location: Westminster, Colorado
Posts: 2,304

|
|
|
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.
|

31st January 2007, 02:48 AM
|
 |
Administrator
|
|
Join Date: Dec 2004
Location: Canada
Age: 22
Posts: 9,224

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

31st January 2007, 03:00 AM
|
|
Registered User
|
|
Join Date: Nov 2005
Location: Los Angeles area
Posts: 887

|
|
|
Are you trying to write something like gnome-screensaver-preferences?
|

31st January 2007, 03:48 AM
|
 |
Administrator
|
|
Join Date: Dec 2004
Location: Canada
Age: 22
Posts: 9,224

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

17th February 2007, 05:45 PM
|
 |
Administrator
|
|
Join Date: Dec 2004
Location: Canada
Age: 22
Posts: 9,224

|
|
|
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
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Current GMT-time: 21:31 (Wednesday, 22-05-2013)
|
|
 |
 |
 |
 |
|
|