The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Gentoo: gnome-screensaver Privilege escalation iBot Security Advisories (RSS) 0 04-11-2008 06:10 PM
Move mouse to disable screensaver? dotancohen UNIX for Advanced & Expert Users 1 03-04-2008 07:29 PM
Time-lapse photography with dvd-slideshow iBot UNIX and Linux RSS News 0 02-22-2008 12:40 PM
how to create screensaver for unix in java?? madatyou1 Filesystems, Disks and Memory 0 03-19-2005 02:53 PM
Screensaver and 'fortune' Darkstripes UNIX for Dummies Questions & Answers 4 07-20-2003 09:59 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 07-23-2005
kevin1 kevin1 is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 1
A Slideshow Screensaver Using C, Gtk+ & Gdk

Yes, I know I am re-inventing the wheel, but I thought this would be an interesting exercise for teaching myself C under Ubuntu Linux and Gnome.

I want a black background against which the .jpg images will be shown. I also want the screensaver to respond to keyboard events so that it can do various things depending on which key is pressed.

The only way I have discovered of getting a completely black background is with a GTK_WINDOW_POPUP, which is displayed independently of the window manager and so hides the Gnome top & bottom panels.

I then use a GTK_WINDOW_TOPLEVEL with gtk_window_set_decorated = FALSE to display the images without borders.

This second window sucessfully receives keyboard events ... but is unfortunately invisible, presumably because the window manager displays it under the black GTK_WINDOW_POPUP. I have tried various things to get the desired result, but without success.

Can anyone suggest a method of achieving my aim? I would prefer to work at the GTK / GDK levels rather than at the Xwindow level.

Code follows:


Code:
/* Declare widgets etc.
-----------------------*/

/* black background window */
GtkWindow *window_bg;
GdkPixbuf *pixbuf_bg;
GtkWidget *picture_bg;

/* image display window */
GtkWindow *window;
GdkPixbuf *pixbuf;
GtkWidget *picture;


int main(int argc, char **argv)
{
/* Initialise GTK+ */ gtk_init(&argc, &argv); /* ***** Create & display black background *******/ window_bg = GTK_WINDOW(gtk_window_new(GTK_WINDOW_POPUP)); pixbuf_bg = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 1280, 1024); /* default black pixbuf */ picture_bg=gtk_image_new_from_pixbuf(pixbuf_bg); gtk_container_add(GTK_CONTAINER(window_bg), GTK_WIDGET(picture_bg)); gtk_widget_show_all(GTK_WIDGET(window_bg)); /* ***** Create photo display ******/ window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); pixbuf = gdk_pixbuf_new_from_file_at_scale("test.jpg", 1280, 1024, TRUE, NULL); picture=gtk_image_new_from_pixbuf(pixbuf); /* signal handlers would be here */ /* pack the image into the window & display */ gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(picture)); gtk_widget_show_all(GTK_WIDGET(window)); /* Set window to have no border etc. */ gtk_window_set_decorated(window, FALSE); /* Start main event loop */ gtk_main(); return 0;
}

Thanks,

Kevin
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:47 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0