GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Sep 18, 2014 5:39 am

All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Noobie GTK+ question
PostPosted: Mon May 12, 2008 1:56 pm 
Offline
Familiar Face

Joined: Mon May 12, 2008 1:50 pm
Posts: 10
Hi Everyone,

I want to create a slideshow program on Linux and I was wondering whether GTK+ is the right place to start?

Eventually I would like to my slideshow to play video (mpeg, avi, etc) and maybe even flash (swf).

I'm not new to programming on Linux, but never developed anything graphical.

Cheers,

Lee


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 12, 2008 2:52 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
GTK+ is the right place to start for the application. You can use GtkImage for the slide show. You will need to search for additional widgets--such as the one that Totem uses--for playing videos.

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 12, 2008 3:04 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
Yeah, GTK should work nicely. If you have programming experience in any language (C, C++, Ruby, Python, C#, PHP, etc.) you could start GTK programming in that language to help you more quickly grasp the GUI concepts.

I would think a slide show app would be a nice and fun way to get started.

Let us know if you need any help along the way and good luck.

_________________
Micah Carrick - Forum Administrator
http://www.micahcarrick.com


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 12, 2008 3:41 pm 
Offline
Familiar Face

Joined: Mon May 12, 2008 1:50 pm
Posts: 10
I've managed to display an image in full screen.

Quote:
#include <gtk/gtk.h>

int main (int argc, char **argv)
{
GtkWidget *window;
GtkWidget *image;

gtk_init (&argc, &argv);

// Create window (full screen)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_decorated(GTK_WINDOW(window), FALSE);
gtk_window_set_resizable(GTK_WINDOW(window), FALSE);

GdkScreen *screen = gtk_window_get_screen(GTK_WINDOW(window));
gtk_widget_set_size_request(window, gdk_screen_get_width(screen),
gdk_screen_get_height(screen));
gtk_window_fullscreen(GTK_WINDOW(window));


g_signal_connect (G_OBJECT (window), "destroy", gtk_main_quit, NULL);

// Load image
image = gtk_image_new_from_file ("/downloads/slideshow/slideshow/images/g_pint_01.jpg");
gtk_container_add (GTK_CONTAINER (window), image);

gtk_widget_show_all (window);
gtk_main ();

return 0;
}



Is there anyway to stretch the image (1024x768) to fit the full screen (1280x1024)?

Cheers,

Lee


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 12, 2008 4:01 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
You can get the GdkScreen with gdk_screen_get_default(). Then use gdk_screen_get_width() and gdk_screen_get_height() to get the dimensions of the screen.

Then, for the image, load it as a GdkPixbuf instead with gdk_pixbuf_new_from_file(). Use gdk_pixbuf_scale() to resize the image. In this function, use bilinear scaling if it should be fast and look good. If you can wait a bit of time (preload next image), then use hyper for better image quality.

Lastly, create the GtkImage with gtk_image_new_from_pixbuf().

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 12, 2008 4:41 pm 
Offline
Familiar Face

Joined: Mon May 12, 2008 1:50 pm
Posts: 10
Thanks for that openldev, I've used the following to stretch the image.

Quote:
pixbuf = gdk_pixbuf_new_from_file ( "/downloads/slideshow/slideshow/images/g_pint_01.jpg", NULL ) ;

pixbuf = gdk_pixbuf_scale_simple ( pixbuf, gdk_screen_get_width ( screen ), gdk_screen_get_height ( screen ), GDK_INTERP_BILINEAR ) ;


image = gtk_image_new_from_pixbuf ( pixbuf ) ;

gtk_container_add ( GTK_CONTAINER ( window ), image ) ;


Does anybody know if GTK+ can provide some transitional effects between images (e.g. wipe, fade, etc)?

Cheers,

Lee


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 12, 2008 5:25 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
You can create your own custom animations (frame by frame) with GdkPixbufAnimation.

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 13, 2008 8:25 am 
Offline
Familiar Face

Joined: Mon May 12, 2008 1:50 pm
Posts: 10
On a different note...

I was wondering which development tools are favored by GTK programmers?

I'm using Kdevelop (took some tweaking for GTK/C), however I was wondering if I'm overlooking any GTK specific IDEs.

Regards,

Lee


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 13, 2008 2:05 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
I believe Anjuta is the closest thing to an actively developed IDE.

I use Glade and Gedit myself. I have a symbol browser plugin for gedit and I'm just about half way done making an autocomplete plugin. Those along with the terminal and file browser pane make gedit perfect for me.

_________________
Micah Carrick - Forum Administrator
http://www.micahcarrick.com


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 13, 2008 3:28 pm 
Offline
Familiar Face

Joined: Mon May 12, 2008 1:50 pm
Posts: 10
Thanks for that. I've installed Anjuta, but there's on build option (although there's a debug option). don't worry, I'll do some digging.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group