2
* Copyright (C) 2009 Giuseppe Torelli - <colossus73@gmail.com>
3
* Copyright (c) 2009 Tadej Borovšak <tadeboro@gmail.com>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
20
#include "slideshow_project.h"
22
void img_save_slideshow(img_window_struct *img)
24
GKeyFile *img_key_file;
32
model = gtk_icon_view_get_model(GTK_ICON_VIEW(img->thumbnail_iconview));
33
if (!gtk_tree_model_get_iter_first (model,&iter))
36
img_key_file = g_key_file_new();
38
/* Slideshow settings */
39
g_key_file_set_comment(img_key_file, NULL, NULL, comment_string, NULL);
41
g_key_file_set_string(img_key_file,"slideshow settings","name",img->slideshow_filename);
42
g_key_file_set_integer(img_key_file,"slideshow settings","export format",img->slideshow_format_index);
44
if ((img->image_area)->allocation.height == 480)
45
g_key_file_set_integer(img_key_file,"slideshow settings","video format",480);
47
g_key_file_set_integer(img_key_file,"slideshow settings","video format",576);
48
g_key_file_set_string(img_key_file,"slideshow settings","aspect ratio",img->aspect_ratio);
49
conf = g_strdup_printf( "%lx", (gulong)img->background_color );
50
g_key_file_set_string(img_key_file,"slideshow settings", "background color", conf);
52
g_key_file_set_boolean(img_key_file,"slideshow settings", "distort images", img->distort_images);
54
/* Slide individual settings */
55
g_key_file_set_integer(img_key_file, "images", "number", img->slides_nr);
59
gtk_tree_model_get(model, &iter,1,&entry,-1);
60
conf = g_strdup_printf("image_%d",count);
62
g_key_file_set_string(img_key_file, "images", conf, entry->filename);
63
g_key_file_set_integer(img_key_file,"transition speed", conf, entry->speed);
64
g_key_file_set_integer(img_key_file,"slide duration", conf, entry->duration);
65
g_key_file_set_integer(img_key_file,"transition type", conf, entry->combo_transition_type_index);
68
while (gtk_tree_model_iter_next (model,&iter));
70
/* Write the project file */
71
conf = g_key_file_to_data(img_key_file, &len, NULL);
72
g_file_set_contents(img->project_filename, conf, len, NULL);
75
string = g_path_get_basename(img->project_filename);
76
img_set_window_title(img,string);
78
g_key_file_free(img_key_file);
80
img->project_is_modified = FALSE;
83
void img_load_slideshow(img_window_struct *img)
86
slide_struct *slide_info;
89
GKeyFile *img_key_file;
90
gchar *dummy,*slide_filename;
92
gint number,i,duration,combo_transition_type_index, height;
97
img_key_file = g_key_file_new();
98
if(!g_key_file_load_from_file(img_key_file,img->project_filename,G_KEY_FILE_KEEP_COMMENTS,NULL))
100
g_key_file_free( img_key_file );
104
dummy = g_key_file_get_comment(img_key_file,NULL,NULL,NULL);
106
if (strncmp(dummy,comment_string,strlen(comment_string)) != 0)
108
dialog = gtk_message_dialog_new(GTK_WINDOW(img->imagination_window),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("This is not an Imagination project file!"));
109
gtk_window_set_title(GTK_WINDOW(dialog),"Imagination");
110
gtk_dialog_run (GTK_DIALOG (dialog));
111
gtk_widget_destroy (GTK_WIDGET (dialog));
117
if (img->slideshow_filename)
119
g_free(img->slideshow_filename);
120
img->slideshow_filename = NULL;
122
/* Set the slideshow options */
123
img->slideshow_filename = g_key_file_get_string(img_key_file,"slideshow settings","name",NULL);
124
img->slideshow_format_index = g_key_file_get_integer(img_key_file,"slideshow settings","export format",NULL);
125
img->aspect_ratio = g_key_file_get_string(img_key_file,"slideshow settings","aspect ratio",NULL);
126
height = g_key_file_get_integer(img_key_file,"slideshow settings","video format",NULL);
127
gtk_widget_set_size_request( img->image_area, 720, height );
128
dummy = g_key_file_get_string(img_key_file, "slideshow settings", "background color", NULL );
129
img->background_color = (guint32)strtoul( dummy, NULL, 16 );
131
img->distort_images = g_key_file_get_boolean(img_key_file, "slideshow settings", "distort images", NULL );
133
/* Loads the thumbnails and set the slides info */
134
number = g_key_file_get_integer(img_key_file,"images","number",NULL);
135
model = gtk_combo_box_get_model(GTK_COMBO_BOX(img->transition_type));
136
for (i = 1; i <= number; i++)
138
dummy = g_strdup_printf("image_%d",i);
139
slide_filename = g_key_file_get_string(img_key_file,"images",dummy,NULL);
141
thumb = img_load_pixbuf_from_file(slide_filename);
144
speed = g_key_file_get_integer(img_key_file,"transition speed" ,dummy,NULL);
145
duration= g_key_file_get_integer (img_key_file,"slide duration" ,dummy,NULL);
146
combo_transition_type_index = g_key_file_get_integer(img_key_file,"transition type",dummy,NULL);
148
/* Get the mem address of the transition according to the index */
149
path = gtk_tree_path_new_from_indices(combo_transition_type_index,-1);
150
gtk_tree_model_get_iter(model,&iter,path);
151
gtk_tree_model_get(model,&iter,1,&render,-1);
152
slide_info = img_set_slide_info(duration, speed, render, combo_transition_type_index, slide_filename);
155
gtk_list_store_append (img->thumbnail_model,&iter);
156
gtk_list_store_set (img->thumbnail_model, &iter, 0, thumb, 1, slide_info, -1);
157
g_object_unref (thumb);
161
g_free(slide_filename);
164
g_key_file_free (img_key_file);
165
img_set_total_slideshow_duration(img);
166
img_set_statusbar_message(img,0);
167
gtk_widget_show(img->thumb_scrolledwindow);
169
dummy = g_path_get_basename(img->project_filename);
170
img_set_window_title(img, dummy);
171
img_set_buttons_state(img, TRUE);