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 

slide transition for a window or image

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
ramesh
GTK+ Guru


Joined: 16 Nov 2006
Posts: 201
Location: INDIA

PostPosted: Thu Aug 21, 2008 10:25 am    Post subject: slide transition for a window or image Reply with quote

hi all
is there any example for slide transition for a window or image

thank you
Back to top
dreblen
Never Seen the Sunlight


Joined: 14 Jun 2007
Posts: 643
Location: Falun, WI USA

PostPosted: Thu Aug 21, 2008 7:16 pm    Post subject: Reply with quote

I don't know what you would mean for a window, but you can put together your own wipe system for images.
this example isn't perfect (e.g. there are some display issues during the wipe and if you exit while the wipe is running the program won't quit),
but it demonstrates how you can do transitions.
Code: (C)
1
2
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
#include <gtk/gtk.h>

/* replace these with two files that actually exist,
 * initially SOURCE_FILE will wipe into DEST_FILE,
 * and it will alternate after that */
#define SOURCE_FILE    "test.png"
#define DEST_FILE    "test2.png"

typedef enum
{
    GTK_IMAGE_WIPE_LEFT = 0,
    GTK_IMAGE_WIPE_RIGHT,
    GTK_IMAGE_WIPE_UP,
    GTK_IMAGE_WIPE_DOWN,
} GtkImageWipeDirection;

typedef struct _GtkImageWipeData
{
    GtkImage *im;
    GdkPixbuf *src;
    GdkPixbuf *dest;
    GtkImageWipeDirection dir;
    GdkInterpType interp_type;
    gint steps;
} GtkImageWipeData;

gboolean _gtk_image_wipe_timeout(GtkImageWipeData *wd)
{
    GdkPixbuf *src, *dest;
    /* step is the current step that we're on */
   
static gint step = 0;

    gint dest_x;
    gint dest_y;
    gint dest_width;
    gint dest_height;
    gint width;
    gint height;

    src = wd->src;
    dest = wd->dest;

    width = gdk_pixbuf_get_width(src);
    height = gdk_pixbuf_get_height(src);

    /* if we're done */
   
if(step == wd->steps+1)
    {
        /* create a new pixbuf */
       
dest = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
        /* fill it with a 0% alpha white color */
       
gdk_pixbuf_fill(dest, 0xFFFFFF00);
        /* composite the new image under our result image,
         * this is so if our new image has transparency, it won't
         * show through to the old image */
       
gdk_pixbuf_composite(src, dest, 0, 0, width, height, 0, 0, 1.0, 1.0, wd->interp_type, 255);
        /* update the GtkImage */
       
gtk_image_set_from_pixbuf(wd->im, dest);
        /* reset step so that this function can be called more than once */
       
step = 0;
        return FALSE;
    }

    /* we use a switch-case to determine the
     * proper numbers to plug into gdk_pixbuf_composite */
   
switch(wd->dir)
    {
        case GTK_IMAGE_WIPE_LEFT:
           
dest_x = width - (step * ((gdouble)width / wd->steps));
            dest_y = 0;
            dest_width = width - dest_x;
            dest_height = height;
            break;
        case GTK_IMAGE_WIPE_RIGHT:
           
dest_x = 0;
            dest_y = 0;
            dest_width = step * ((gdouble)width / wd->steps);
            dest_height = height;
            break;
        case GTK_IMAGE_WIPE_UP:
           
dest_x = 0;
            dest_y = height - (step * ((gdouble)height / wd->steps));
            dest_width = width;
            dest_height = height - dest_y;
            break;
        case GTK_IMAGE_WIPE_DOWN:
           
dest_x = 0;
            dest_y = 0;
            dest_width = width;
            dest_height = step * ((gdouble)height / wd->steps);
            break;
        default:
            return FALSE;
    }

    /* composite our partial image,
     * see URL for doc on gdk_pixbuf_composite:
     * http://library.gnome.org/devel/gdk-pixbuf/stable/gdk-pixbuf-scaling.html#gdk-pixbuf-composite */
   
gdk_pixbuf_composite(src, dest, dest_x, dest_y, dest_width, dest_height, 0, 0, 1.0, 1.0, wd->interp_type, 255);
    /* update the GtkImage */
   
gtk_image_set_from_pixbuf(wd->im, dest);

    /* add one to step for next time */
   
step++;

    return TRUE;
}

void gtk_image_wipe(GtkImage *im, GdkPixbuf *source, GdkPixbuf *dest, gint steps, gint interval, GtkImageWipeDirection direction, GdkInterpType interp_type)
{
    guint src_id;
    GtkImageWipeData wd;
    gint w, h;

    w = gdk_pixbuf_get_width(source);
    h = gdk_pixbuf_get_height(source);

    wd.im = im;
    wd.src = source;
    /* here we ensure that the old image is the same size as the new one */
   
wd.dest = gdk_pixbuf_scale_simple(dest, w, h, interp_type);
    wd.dir = direction;
    wd.interp_type = interp_type;
    wd.steps = steps;

    if(interval < 1)
        interval = 1;

    src_id = g_timeout_add(interval, (GSourceFunc)_gtk_image_wipe_timeout, (gpointer)&wd);
    do
   
{
        /* make sure that the GUI is updated while we're looping */
       
while(gtk_events_pending())
            gtk_main_iteration();
    /* it won't be able to find the GSource once our timeout returns FALSE,
     * it will then return NULL and this function can return */
   
}while(g_main_context_find_source_by_id(NULL, src_id) != NULL);

    return;
}

void call_wipe(GtkImage *im, GtkImageWipeDirection dir)
{
    GdkPixbuf *src, *dest;
    GError *err;

    static gint state = 0;
    static gboolean running = FALSE;

    err = NULL;

    /* if we are already wiping, then don't try to wipe again */

   
if(running == TRUE)
        return;

    /* state is used to change which image is src and which is dest */
   
if(state == 0)
    {
        src = gdk_pixbuf_new_from_file(SOURCE_FILE, &err);
        if(err != NULL)
        {
            g_critical(err->message);
            g_error_free(err);
            return;
        }
        dest = gdk_pixbuf_new_from_file(DEST_FILE, &err);
        if(err != NULL)
        {
            g_critical(err->message);
            g_error_free(err);
            return;
        }
        state = 1;
    }
    else
   
{
        dest = gdk_pixbuf_new_from_file(SOURCE_FILE, &err);
        if(err != NULL)
        {
            g_critical(err->message);
            g_error_free(err);
            return;
        }
        src = gdk_pixbuf_new_from_file(DEST_FILE, &err);
        if(err != NULL)
        {
            g_critical(err->message);
            g_error_free(err);
            return;
        }
        state = 0;
    }

    /* we're running now */
   
running = TRUE;
    /* 100 is the number of steps to take in wiping,
     * the higher the steps, the smoother the wipe will be,
     * it will also be slower however */
    /* 10 is the interval of how often the timeout is called,
     * it is in milliseconds */
   
gtk_image_wipe(im, src, dest, 100, 10, dir, GDK_INTERP_BILINEAR);
    /* done running */
   
running = FALSE;
}

void wipe_left_cb(GtkWidget *button, GtkImage *im)
{
    call_wipe(im, GTK_IMAGE_WIPE_LEFT);
}

void wipe_right_cb(GtkWidget *button, GtkImage *im)
{
    call_wipe(im, GTK_IMAGE_WIPE_RIGHT);
}

void wipe_up_cb(GtkWidget *button, GtkImage *im)
{
    call_wipe(im, GTK_IMAGE_WIPE_UP);
}

void wipe_down_cb(GtkWidget *button, GtkImage *im)
{
    call_wipe(im, GTK_IMAGE_WIPE_DOWN);
}

int main(int argc, char **argv)
{
    GtkWidget *win;
    GtkWidget *vbox;
    GtkWidget *swin;
    GtkWidget *im;
    GtkWidget *hbox;
    GtkWidget *button;

    gtk_init(&argc, &argv);

    win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(win), "delete-event", G_CALLBACK(gtk_main_quit), NULL);

    vbox = gtk_vbox_new(FALSE, 5);
    gtk_container_add(GTK_CONTAINER(win), vbox);
    gtk_widget_show(vbox);

    swin = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
    gtk_box_pack_start(GTK_BOX(vbox), swin, TRUE, TRUE, 0);
    gtk_widget_show(swin);

    im = gtk_image_new_from_file(DEST_FILE);
    gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(swin), im);
    gtk_widget_show(im);

    hbox = gtk_hbox_new(TRUE, 2);
    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
    gtk_widget_show(hbox);

    button = gtk_button_new_with_label("Wipe Left");
    g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(wipe_left_cb), (gpointer)im);
    gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
    gtk_widget_show(button);

    button = gtk_button_new_with_label("Wipe Right");
    g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(wipe_right_cb), (gpointer)im);
    gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
    gtk_widget_show(button);

    button = gtk_button_new_with_label("Wipe Up");
    g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(wipe_up_cb), (gpointer)im);
    gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
    gtk_widget_show(button);

    button = gtk_button_new_with_label("Wipe Down");
    g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(wipe_down_cb), (gpointer)im);
    gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
    gtk_widget_show(button);

    gtk_widget_show(win);

    gtk_main();

    return 0;
}
Back to top
ramesh
GTK+ Guru


Joined: 16 Nov 2006
Posts: 201
Location: INDIA

PostPosted: Fri Aug 22, 2008 4:02 am    Post subject: Reply with quote

amazing.
thank you very much.
here how can i give the pixmap folder name.(that contains a lot of images)
and also how can i give the time for slide to open next image automatically.
Back to top
dreblen
Never Seen the Sunlight


Joined: 14 Jun 2007
Posts: 643
Location: Falun, WI USA

PostPosted: Fri Aug 22, 2008 8:40 pm    Post subject: Reply with quote

you can use GDir and g_dir_read_name to get the files in a directory
http://library.gnome.org/devel/glib/unstable/glib-File-Utilities.html
this example only gives a next and previous button, but you could add a timeout for doing a slideshow.
Code: (C)
1
2
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
#include <gtk/gtk.h>
#include <stdlib.h>
#include <time.h>

typedef enum
{
    GTK_IMAGE_WIPE_LEFT = 0,
    GTK_IMAGE_WIPE_RIGHT,
    GTK_IMAGE_WIPE_UP,
    GTK_IMAGE_WIPE_DOWN,
} GtkImageWipeDirection;

typedef struct _GtkImageWipeData
{
    GtkImage *im;
    GdkPixbuf *src;
    GdkPixbuf *dest;
    GtkImageWipeDirection dir;
    GdkInterpType interp_type;
    gint steps;
} GtkImageWipeData;

static const gchar *valid_suffixes[] = {
    ".png", ".jpg", ".jpeg", ".ico", ".bmp", NULL
};

gboolean slideshow_running;
guint slideshow_id;
GList *files;

gboolean _gtk_image_wipe_timeout(GtkImageWipeData *wd)
{
    GdkPixbuf *src, *dest;
    /* step is the current step that we're on */
   
static gint step = 0;

    gint dest_x;
    gint dest_y;
    gint dest_width;
    gint dest_height;
    gint width;
    gint height;

    src = wd->src;
    dest = wd->dest;

    width = gdk_pixbuf_get_width(src);
    height = gdk_pixbuf_get_height(src);

    /* if we're done */
   
if(step == wd->steps+1)
    {
        /* create a new pixbuf */
       
dest = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
        /* fill it with a 0% alpha white color */
       
gdk_pixbuf_fill(dest, 0xFFFFFF00);
        /* composite the new image under our result image,
         * this is so if our new image has transparency, it won't
         * show through to the old image */
       
gdk_pixbuf_composite(src, dest, 0, 0, width, height, 0, 0, 1.0, 1.0, wd->interp_type, 255);
        /* update the GtkImage */
       
gtk_image_set_from_pixbuf(wd->im, dest);
        /* reset step so that this function can be called more than once */
       
step = 0;
        return FALSE;
    }

    /* we use a switch-case to determine the
     * proper numbers to plug into gdk_pixbuf_composite */
   
switch(wd->dir)
    {
        case GTK_IMAGE_WIPE_LEFT:
           
dest_x = width - (step * ((gdouble)width / wd->steps));
            dest_y = 0;
            dest_width = width - dest_x;
            dest_height = height;
            break;
        case GTK_IMAGE_WIPE_RIGHT:
           
dest_x = 0;
            dest_y = 0;
            dest_width = step * ((gdouble)width / wd->steps);
            dest_height = height;
            break;
        case GTK_IMAGE_WIPE_UP:
           
dest_x = 0;
            dest_y = height - (step * ((gdouble)height / wd->steps));
            dest_width = width;
            dest_height = height - dest_y;
            break;
        case GTK_IMAGE_WIPE_DOWN:
           
dest_x = 0;
            dest_y = 0;
            dest_width = width;
            dest_height = step * ((gdouble)height / wd->steps);
            break;
        default:
            return FALSE;
    }

    /* composite our partial image,
     * see URL for doc on gdk_pixbuf_composite:
     * http://library.gnome.org/devel/gdk-pixbuf/stable/gdk-pixbuf-scaling.html#gdk-pixbuf-composite */
   
gdk_pixbuf_composite(src, dest, dest_x, dest_y, dest_width, dest_height, 0, 0, 1.0, 1.0, wd->interp_type, 255);
    /* update the GtkImage */
   
gtk_image_set_from_pixbuf(wd->im, dest);

    /* add one to step for next time */
   
step++;

    return TRUE;
}

void gtk_image_wipe(GtkImage *im, GdkPixbuf *source, GdkPixbuf *dest, gint steps, gint interval, GtkImageWipeDirection direction, GdkInterpType interp_type)
{
    guint src_id;
    GtkImageWipeData wd;
    gint w, h;

    w = gdk_pixbuf_get_width(source);
    h = gdk_pixbuf_get_height(source);

    wd.im = im;
    wd.src = source;
    /* here we ensure that the old image is the same size as the new one */
   
wd.dest = gdk_pixbuf_scale_simple(dest, w, h, interp_type);
    wd.dir = direction;
    wd.interp_type = interp_type;
    wd.steps = steps;

    if(interval < 1)
        interval = 1;

    src_id = g_timeout_add(interval, (GSourceFunc)_gtk_image_wipe_timeout, (gpointer)&wd);
    do
   
{
        /* make sure that the GUI is updated while we're looping */
       
while(gtk_events_pending())
            gtk_main_iteration();
    /* it won't be able to find the GSource once our timeout returns FALSE,
     * it will then return NULL and this function can return */
   
}while(g_main_context_find_source_by_id(NULL, src_id) != NULL);

    return;
}

/* this function checks each item in array to see if str has it as a suffix */
gboolean g_str_has_suffix_in_array(const gchar *str, const gchar **array)
{
    gint i;

    for(i = 0; array[i] != NULL; i++)
    {
        if(g_str_has_suffix(str, array[i]))
            return TRUE;
    }
    return FALSE;
}

gboolean slideshow_timeout(GtkImage *im)
{
    GdkPixbuf *one, *two;
    gchar *oneS, *twoS;
    GError *err;

    err = NULL;

    if(files == NULL)
        return FALSE;

    if(slideshow_running == FALSE)
        return FALSE;

    if(files->next == NULL)
    {
        slideshow_running = FALSE;
        return FALSE;
    }
    oneS = (gchar*)files->data;
    twoS = (gchar*)files->next->data;

    if(files->prev != NULL)
    {
        one = gdk_pixbuf_new_from_file(oneS, &err);
        if(err != NULL)
        {
            g_warning(err->message);
            g_error_free(err);
            return TRUE;
        }
    }
    else
   
{
        one = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 1, 1);
        gdk_pixbuf_fill(one, 0x00000000);
    }
    two = gdk_pixbuf_new_from_file(twoS, &err);
    if(err != NULL)
    {
        g_warning(err->message);
        g_error_free(err);
        return TRUE;
    }

    gtk_image_set_from_pixbuf(im, one);

    gtk_image_wipe(im, two, one, 100, 100, rand()%4, GDK_INTERP_BILINEAR);

    files = files->next;

    return TRUE;
}

void file_set_cb(GtkFileChooserButton *but, GtkImage *im)
{
    GDir *dir;
    GError *err;
    const gchar *item;
    gchar *path, *uri;
    gchar sep[2];

    err = NULL;

    sprintf(sep, "%c", G_DIR_SEPARATOR);

    path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(but));

    /* open the chosen directory */
   
dir = g_dir_open(path, 0, &err);
    if(err != NULL)
    {
        g_warning(err->message);
        g_error_free(err);
        return;
    }

    slideshow_running = FALSE;

    if(files != NULL)
    {
        g_list_free(files);
        files = NULL;
    }

    /* get all the items in the directory */
   
while((item = g_dir_read_name(dir)))
    {
        /* build a path so that we can test it with g_file_test */
       
uri = g_strjoin(sep, path, item, NULL);
        /* test to make sure it's not a directory or something else */
       
if(g_file_test(uri, G_FILE_TEST_IS_REGULAR))
        {
            /* if it doesn't have a valid suffix, then move on */
           
if(!g_str_has_suffix_in_array(item, valid_suffixes))
                continue;
            /* if it does have a valid suffix, then add it to a list of files */
           
else
               
files = g_list_append(files, (gpointer)g_strdup(uri));
        }
    }

    files = g_list_first(files);

    gtk_image_set_from_file(im, (gchar*)files->data);

    srand((unsigned)time(NULL));
}

void slideshow_next_image(GtkWidget *button, GtkImage *im)
{
    GdkPixbuf *one, *two;
    gchar *oneS, *twoS;
    GError *err;

    err = NULL;

    if(files == NULL)
        return;

    if(files->next == NULL)
        return;

    oneS = (gchar*)files->data;
    twoS = (gchar*)files->next->data;

    one = gdk_pixbuf_new_from_file(oneS, &err);
    if(err != NULL)
    {
        g_warning(err->message);
        g_error_free(err);
        return;
    }
    two = gdk_pixbuf_new_from_file(twoS, &err);
    if(err != NULL)
    {
        g_warning(err->message);
        g_error_free(err);
        return;
    }

    if(slideshow_running == TRUE)
        return;
    gtk_image_set_from_pixbuf(im, one);
    slideshow_running = TRUE;
    gtk_image_wipe(im, two, one, 100, 100, rand()%4, GDK_INTERP_BILINEAR);
    slideshow_running = FALSE;

    files = files->next;
}

void slideshow_prev_image(GtkWidget *button, GtkImage *im)
{
    GdkPixbuf *one, *two;
    gchar *oneS, *twoS;
    GError *err;

    err = NULL;

    if(files == NULL)
        return;

    if(files->next == NULL || files->prev == NULL)
        return;

    oneS = (gchar*)files->data;
    twoS = (gchar*)files->prev->data;

    one = gdk_pixbuf_new_from_file(oneS, &err);
    if(err != NULL)
    {
        g_warning(err->message);
        g_error_free(err);
        return;
    }
    two = gdk_pixbuf_new_from_file(twoS, &err);
    if(err != NULL)
    {
        g_warning(err->message);
        g_error_free(err);
        return;
    }

    if(slideshow_running == TRUE)
        return;
    gtk_image_set_from_pixbuf(im, one);
    slideshow_running = TRUE;
    gtk_image_wipe(im, two, one, 100, 100, rand()%4, GDK_INTERP_BILINEAR);
    slideshow_running = FALSE;

    files = files->prev;
}

int main(int argc, char **argv)
{
    GtkWidget *win;
    GtkWidget *vbox;
    GtkWidget *button;
    GtkWidget *hbox;
    GtkWidget *swin;
    GtkWidget *im;

    slideshow_running = FALSE;
    files = NULL;

    gtk_init(&argc, &argv);

    win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(win), "delete-event", G_CALLBACK(gtk_main_quit), NULL);

    vbox = gtk_vbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(win), vbox);
    gtk_widget_show(vbox);

    im = gtk_image_new();

    button = gtk_file_chooser_button_new("Select Folder", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
    g_signal_connect(G_OBJECT(button), "file-set", G_CALLBACK(file_set_cb), (gpointer)im);
    gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
    gtk_widget_show(button);

    hbox = gtk_hbox_new(FALSE, 2);
    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
    gtk_widget_show(hbox);

    button = gtk_button_new_with_label("Previous");
    g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(slideshow_prev_image), (gpointer)im);
    gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
    gtk_widget_show(button);

    button = gtk_button_new_with_label("Next");
    g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(slideshow_next_image), (gpointer)im);
    gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
    gtk_widget_show(button);

    swin = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
    gtk_box_pack_start(GTK_BOX(vbox), swin, TRUE, TRUE, 0);
    gtk_widget_show(swin);

    /* im was created earlier */
   
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(swin), im);
    gtk_widget_show(im);

    gtk_widget_show(win);

    gtk_main();

    return 0;
}
Back to top
ramesh
GTK+ Guru


Joined: 16 Nov 2006
Posts: 201
Location: INDIA

PostPosted: Mon Aug 25, 2008 4:23 am    Post subject: Reply with quote

awesome work.
thank you for your replay.
i need to implement this to some more extend.
1).it should have "prev" and "next" options" aswellas it should automatically transimit after 20 sec or 30 sec... etc. mean we have to give the time for the slideshow.
2).here we are choosing a pixmap dir. that nice, after selecting a directory, can we show all the images in the pixmap dir. in the window (like thumbnail or image viewer)
3). sothat we can select an image to start slide show.

please help me.
any help it is appreciable.
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