GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Noobie GTK+ question

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
ldavies
Familiar Face


Joined: 12 May 2008
Posts: 10

PostPosted: Mon May 12, 2008 1:56 pm    Post subject: Noobie GTK+ question Reply with quote

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
Back to top
openldev
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 386
Location: Fairfax, Virginia

PostPosted: Mon May 12, 2008 2:52 pm    Post subject: Reply with quote

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.
Back to top
Micah Carrick
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 496
Location: Portland, OR USA

PostPosted: Mon May 12, 2008 3:04 pm    Post subject: Reply with quote

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.
Back to top
ldavies
Familiar Face


Joined: 12 May 2008
Posts: 10

PostPosted: Mon May 12, 2008 3:41 pm    Post subject: Reply with quote

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
Back to top
openldev
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 386
Location: Fairfax, Virginia

PostPosted: Mon May 12, 2008 4:01 pm    Post subject: Reply with quote

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().
Back to top
ldavies
Familiar Face


Joined: 12 May 2008
Posts: 10

PostPosted: Mon May 12, 2008 4:41 pm    Post subject: Reply with quote

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
Back to top
openldev
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 386
Location: Fairfax, Virginia

PostPosted: Mon May 12, 2008 5:25 pm    Post subject: Reply with quote

You can create your own custom animations (frame by frame) with GdkPixbufAnimation.
Back to top
ldavies
Familiar Face


Joined: 12 May 2008
Posts: 10

PostPosted: Tue May 13, 2008 8:25 am    Post subject: Reply with quote

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
Back to top
Micah Carrick
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 496
Location: Portland, OR USA

PostPosted: Tue May 13, 2008 2:05 pm    Post subject: Reply with quote

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.
Back to top
ldavies
Familiar Face


Joined: 12 May 2008
Posts: 10

PostPosted: Tue May 13, 2008 3:28 pm    Post subject: Reply with quote

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.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP