Hello, I'm programming my first GTK+ app, is a Gnome screen-saver. I will try to explain my problem but I think that you will understand it better if you see a picture of my program.
The fishes are animated gif and the background is a .png image. When I resize the window by clicking the "maximize window" title bar button the background image keeps the same size.
How can solve it? What is the event name of click that button? The background image have to be fit to the window border. This is the source code of my app.
[code=]
#include <gtk/gtk.h>
#include <glade/glade.h>
//#include "callbacks.h"
//#define GLADE_FILE "src/gquarium.glade"
int
main (int argc, char *argv[])
{
/* Declare Widgets */
GtkWidget *window;
GtkWidget *fixed_layout;
GtkWidget *image_bg;
GtkWidget *image_fish_1;
GtkWidget *image_fish_2;
GtkWidget *image_fish_3;
GtkWidget *image_fish_4;
/* Initialize */
gtk_init(&argc, &argv);
/* Build window Widget */
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_window_set_title(GTK_WINDOW(window), "Gquarium");
gtk_window_set_default_icon_from_file ("gquarium_icon.png", NULL);
gtk_widget_set_size_request(window, 1024, 768);
/* Build fixed_layout */
fixed_layout = gtk_fixed_new();
gtk_container_add(GTK_CONTAINER(window), fixed_layout);
/* Build images */
image_bg = gtk_image_new_from_file(argv[1]);
if (image_bg == NULL){
printf("Could not open \"%s\"\n", argv[1]);
return 1;
}
gtk_fixed_put(GTK_FIXED(fixed_layout), image_bg, 0, 0);
image_fish_1 = gtk_image_new_from_file(argv[2]);
if (image_fish_1 == NULL){
printf("Could not open \"%s\"\n", argv[2]);
return 1;
}
gtk_fixed_put(GTK_FIXED(fixed_layout), image_fish_1, 100, 100);
image_fish_2 = gtk_image_new_from_file(argv[3]);
if (image_fish_2 == NULL){
printf("Could not open \"%s\"\n", argv[3]);
return 1;
}
gtk_fixed_put(GTK_FIXED(fixed_layout), image_fish_2, 400, 400);
image_fish_3 = gtk_image_new_from_file(argv[4]);
if (image_fish_3 == NULL){
printf("Could not open\"%s\"\n", argv[4]);
return 1;
}
gtk_fixed_put(GTK_FIXED(fixed_layout), image_fish_3, 250, 250);
image_fish_4 = gtk_image_new_from_file(argv[5]);
if (image_fish_4 == NULL){
printf("Could not open\"%s\"\n", argv[5]);
return 1;
}
gtk_fixed_put(GTK_FIXED(fixed_layout), image_fish_4, 250, 550);
/* Attach standard event handlers */
g_signal_connect(G_OBJECT(window), "destroy",
G_CALLBACK(gtk_main_quit), G_OBJECT(window));
//g_signal_connect(G_OBJECT(window), "event",
// G_CALLBACK(resize_window), G_OBJECT(window));
/*Show the window*/
gtk_widget_show_all(window);
/*Moving the fish*/
/* Enter the event loop */
gtk_main();
return 0;
}
[/code]
NOTE: remember that the gnome screen-saver can't use keyboard events or mouse events I only can use window manager or xwindow system events.
I'm waiting for your help. Thanks and sorry for my little English.