| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 
 |  
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <gtk/gtk.h>
 
int inter, pos_x, pos_y;
char *fname;
 
gint x, y;
GtkWidget *fen, *img, *box, *label;
 
/* La fonction qui nous sert à afficher l'image dont le chemin
   est passé en argument. */
 
void imageDisplay(char *image)
{
        printf(" -> imageDisplay();\n");
        printf(" ---> image = %s\n", image);
 
        img = gtk_image_new_from_file(image);
        if(!img)
        {
                fprintf(stderr,"imageDisplay() : error loading image\n");
                sortie(1);
        }
 
        //gtk_box_pack_start(GTK_BOX(box), cover, FALSE, FALSE, 5);
        printf("inter=%d\n",inter);
        sleep(inter);
}
 
void windowDisplay()
{
        printf(" -> windowDisplay();\n");
 
        fen = gtk_window_new (GTK_WINDOW_POPUP);
        gtk_window_move (GTK_WINDOW(fen), pos_x, pos_y);
        g_signal_connect(G_OBJECT(fen),"destroy",G_CALLBACK(gtk_main_quit),NULL);
        gtk_window_set_default_size (GTK_WINDOW(fen), 150, 150);
 
        box = gtk_vbox_new(FALSE, 10);
        gtk_container_add(GTK_CONTAINER(fen), box);
 
        fname = getImagePath();
        printf(" ---> fname = %s\n", fname);
        imageDisplay(fname);
 
        gtk_box_pack_start(GTK_BOX(box), cover, FALSE, FALSE, 5);
        gtk_widget_show_all(fen);
 
        g_timeout_add( (guint)inter, (gpointer)windowDisplay, NULL);
}
 
 
int main ( int argc, char **argv )
{
        /* on passe en entier l'intervalle et la position */
	inter = atoi( argv[2] );
	pos_x = atoi( argv[3] );
	pos_y = atoi( argv[4] );
 
        gtk_init(&argc, &argv);
 
        windowDisplay();
 
	gtk_main();
 
	return 0;
} | 
Partager