54
52
return g_strdup_printf("%02d:%02d:%02d", h, m, s);
56
sens_cell_func( GtkCellLayout *layout,
57
GtkCellRenderer *cell,
62
gboolean sensitive = ! gtk_tree_model_iter_has_child( model, iter );
63
g_object_set( cell, "sensitive", sensitive, NULL );
57
66
GtkWidget *_gtk_combo_box_new_text(gboolean pointer)
59
68
GtkWidget *combo_box;
67
tree = gtk_tree_store_new (4, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_INT);
76
tree = gtk_tree_store_new( 6, GDK_TYPE_PIXBUF,
80
GDK_TYPE_PIXBUF_ANIMATION,
68
82
model = GTK_TREE_MODEL( tree );
70
84
combo_box = gtk_combo_box_new_with_model (model);
71
85
g_object_unref (G_OBJECT( model ));
72
cell = gtk_cell_renderer_pixbuf_new ();
73
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, FALSE);
74
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell, "pixbuf", 0, NULL);
86
cell = img_cell_renderer_anim_new ();
87
gtk_cell_layout_pack_start( GTK_CELL_LAYOUT( combo_box ), cell, FALSE );
88
gtk_cell_layout_set_attributes( GTK_CELL_LAYOUT (combo_box), cell,
91
gtk_cell_layout_set_cell_data_func( GTK_CELL_LAYOUT( combo_box ), cell,
92
sens_cell_func, NULL, NULL );
94
cell = gtk_cell_renderer_text_new ();
95
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, TRUE);
96
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell,
99
gtk_cell_layout_set_cell_data_func( GTK_CELL_LAYOUT( combo_box ), cell,
100
sens_cell_func, NULL, NULL );
101
g_object_set(cell, "ypad", (guint)0, NULL);
81
108
combo_box = gtk_combo_box_new_with_model (model);
82
109
g_object_unref (G_OBJECT( model ));
111
cell = gtk_cell_renderer_text_new ();
112
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, TRUE);
113
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell,
116
g_object_set(cell, "ypad", (guint)0, NULL);
85
cell = gtk_cell_renderer_text_new ();
86
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, TRUE);
87
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell, "text", pointer ? 1 : 0, NULL);
88
g_object_set(cell, "ypad", (guint)0, NULL);
97
127
if (img_struct->slides_nr == 0)
99
message = g_strdup_printf(_("Welcome to Imagination - %d transitions loaded."),img_struct->nr_transitions_loaded);
100
gtk_statusbar_push(GTK_STATUSBAR(img_struct->statusbar),img_struct->context_id,message);
102
gtk_label_set_text(GTK_LABEL(img_struct->total_slide_number_label),NULL);
129
message = g_strdup_printf(
130
ngettext( "Welcome to Imagination - %d transition loaded.",
131
"Welcome to Imagination - %d transitions loaded.",
132
img_struct->nr_transitions_loaded ),
133
img_struct->nr_transitions_loaded );
134
gtk_statusbar_push( GTK_STATUSBAR( img_struct->statusbar ),
135
img_struct->context_id, message );
137
gtk_label_set_text( GTK_LABEL( img_struct->total_slide_number_label ), NULL );
104
139
else if (selected)
106
message = g_strdup_printf(_("%d slides selected"),selected);
107
gtk_statusbar_push(GTK_STATUSBAR(img_struct->statusbar),img_struct->context_id,message);
141
message = g_strdup_printf( ngettext( "%d slide selected",
142
"%d slides selected",
143
selected ), selected);
144
gtk_statusbar_push( GTK_STATUSBAR( img_struct->statusbar ),
145
img_struct->context_id, message );
112
150
total_slides = g_strdup_printf("%d",img_struct->slides_nr);
113
151
gtk_label_set_text(GTK_LABEL(img_struct->total_slide_number_label),total_slides);
114
message = g_strdup_printf(ngettext("%d slide imported %s" ,"%d slides imported %s",img_struct->slides_nr),img_struct->slides_nr,_(" - Use the CTRL key to select/unselect or SHIFT for multiple select"));
115
gtk_statusbar_push(GTK_STATUSBAR(img_struct->statusbar),img_struct->context_id,message);
152
message = g_strdup_printf( ngettext( "%d slide loaded %s",
153
"%d slides loaded %s",
154
img_struct->slides_nr ),
155
img_struct->slides_nr,
156
_(" - Use the CTRL key to select/unselect "
157
"or SHIFT for multiple select") );
158
gtk_statusbar_push( GTK_STATUSBAR( img_struct->statusbar ),
159
img_struct->context_id, message );
116
160
g_free(total_slides);
121
165
void img_load_available_transitions(img_window_struct *img)
124
const gchar *transition_name;
125
gchar *fname = NULL, *name, *filename;
126
gchar **trans, **bak;
129
167
GtkTreeIter piter, citer;
130
168
GtkTreeStore *model;
131
169
gpointer address;
132
gchar *search_paths[3], **path;
133
void (*plugin_set_name)(gchar **, gchar ***);
170
gchar *search_paths[3],
135
model = GTK_TREE_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(img->transition_type)));
173
model = GTK_TREE_STORE( gtk_combo_box_get_model(
174
GTK_COMBO_BOX( img->transition_type ) ) );
137
176
/* Fill the combo box with no transition */
138
gtk_tree_store_append(model, &piter, NULL);
139
gtk_tree_store_set(model, &piter, 0, NULL, 1, _("None"), 2, NULL, 3, -1, -1);
140
gtk_combo_box_set_active(GTK_COMBO_BOX(img->transition_type), 0);
177
gtk_tree_store_append( model, &piter, NULL );
178
gtk_tree_store_set( model, &piter, 0, NULL,
184
gtk_combo_box_set_active( GTK_COMBO_BOX( img->transition_type ), 0 );
142
186
/* Create NULL terminated array of paths that we'll be looking at */
143
187
#if PLUGINS_INSTALLED
144
search_paths[0] = g_strconcat(PACKAGE_LIB_DIR,"/imagination",NULL);
188
search_paths[0] = g_build_path(G_DIR_SEPARATOR_S, PACKAGE_LIB_DIR, "imagination", NULL );
146
190
search_paths[0] = g_strdup("./transitions");
148
search_paths[1] = g_strconcat( g_get_home_dir(), "/.imagination/plugins", NULL );
192
search_paths[1] = g_build_path(G_DIR_SEPARATOR_S, g_get_home_dir(), ".imagination",
149
194
search_paths[2] = NULL;
151
196
/* Search all paths listed in array */
152
197
for( path = search_paths; *path; path++ )
154
201
dir = g_dir_open( *path, 0, NULL );
155
202
if( dir == NULL )
181
237
/* Add transitions */
182
238
for( bak = trans; *trans; trans += 3 )
244
GdkPixbufAnimation *anim;
245
gint id = GPOINTER_TO_INT( trans[2] );
184
247
#if PLUGINS_INSTALLED
186
g_strdup_printf( "%s/imagination/pixmaps/imagination-%d.png",
187
DATADIR, GPOINTER_TO_INT( trans[2] ) );
248
tmp = g_build_filename( DATADIR, "imagination",
188
250
#else /* PLUGINS_INSTALLED */
190
g_strdup_printf( "./pixmaps/imagination-%d.png",
191
GPOINTER_TO_INT( trans[2] ) );
251
tmp = g_strdup( "./pixmaps" );
192
252
#endif /* ! PLUGINS_INSTALLED */
194
pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
254
pix_name = g_strdup_printf( "%s%simagination-%d.png",
255
tmp, G_DIR_SEPARATOR_S, id );
256
anim_name = g_strdup_printf( "%s%simagination-%d.gif",
257
tmp, G_DIR_SEPARATOR_S, id );
260
pixbuf = gdk_pixbuf_new_from_file( pix_name, NULL );
196
262
/* Local plugins will fail to load images from system
197
263
* folder, so we'll try to load the from home folder. */
202
g_strdup_printf( "%s/.imagination/pixmaps/imagination-%d.png",
204
GPOINTER_TO_INT( trans[2] ) );
205
pixbuf = gdk_pixbuf_new_from_file( filename, NULL );
269
tmp = g_build_filename( g_get_home_dir(),
275
g_strdup_printf( "%s%simagination-%d.png",
276
tmp, G_DIR_SEPARATOR_S, id );
278
g_strdup_printf( "%s%simagination-%d.gif",
279
tmp, G_DIR_SEPARATOR_S, id );
282
pixbuf = gdk_pixbuf_new_from_file( pix_name, NULL );
284
anim = gdk_pixbuf_animation_new_from_file( anim_name,
208
288
g_module_symbol( module, trans[1], &address );
209
289
gtk_tree_store_append( model, &citer, &piter );
210
290
gtk_tree_store_set( model, &citer, 0, pixbuf,
213
3, GPOINTER_TO_INT( trans[2] ),
215
296
img->nr_transitions_loaded++;
297
g_object_unref( G_OBJECT( pixbuf ) );
298
g_object_unref( G_OBJECT( anim ) );
233
316
GtkWidget *file_selector;
319
GtkFileFilter *video_filter, *all_files_filter;
320
gchar *file_extention, *dot_position, *proposed_filename, *file_basename, *stripped_filename;
237
322
file_selector = gtk_file_chooser_dialog_new (_("Please choose the slideshow project filename"),
238
323
GTK_WINDOW (img->imagination_window),
243
328
GTK_RESPONSE_ACCEPT,
331
/* only video files filter */
332
video_filter = gtk_file_filter_new ();
333
switch (img->video_format)
337
gtk_file_filter_set_name (video_filter, _("VOB (DVD video)") );
338
gtk_file_filter_add_pattern (video_filter, "*.vob");
339
file_extention = ".vob";
343
gtk_file_filter_set_name (video_filter, _("MP4 (MPEG-4)") );
344
gtk_file_filter_add_pattern (video_filter, "*.mp4");
345
file_extention = ".mp4";
349
gtk_file_filter_set_name (video_filter, _("OGV (Theora/Vorbis)") );
350
gtk_file_filter_add_pattern (video_filter, "*.ogv");
351
file_extention = ".ogv";
355
gtk_file_filter_set_name (video_filter, _("FLV (Flash video)") );
356
gtk_file_filter_add_pattern (video_filter, "*.flv");
357
file_extention = ".flv";
361
gtk_file_filter_set_name (video_filter, _("3GP (Mobile Phones)") );
362
gtk_file_filter_add_pattern (video_filter, "*.3gp");
363
file_extention = ".3gp";
366
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_selector), video_filter);
368
/* All files filter */
369
all_files_filter = gtk_file_filter_new ();
370
gtk_file_filter_set_name(all_files_filter, _("All files"));
371
gtk_file_filter_add_pattern(all_files_filter, "*");
372
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(file_selector), all_files_filter);
374
/* Propose a file name */
375
if (img->project_filename)
377
file_basename = g_path_get_basename(img->project_filename);
378
dot_position = g_strrstr(file_basename, ".");
379
if (NULL != dot_position)
381
stripped_filename = g_strndup(file_basename, dot_position - file_basename);
382
g_free(file_basename);
386
stripped_filename = file_basename;
388
proposed_filename = g_strjoin(NULL, stripped_filename, file_extention, NULL);
389
g_free(stripped_filename);
393
proposed_filename = g_strjoin(NULL, "unknown", file_extention, NULL);
395
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER (file_selector), proposed_filename);
396
g_free(proposed_filename);
398
/* set current dir to the project current dir */
399
if (img->project_current_dir)
400
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(file_selector),img->project_current_dir);
246
402
gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER (file_selector),TRUE);
247
403
response = gtk_dialog_run (GTK_DIALOG(file_selector));
248
404
if (response == GTK_RESPONSE_ACCEPT)
282
438
slide->font_color[1] = 0; /* G */
283
439
slide->font_color[2] = 0; /* B */
284
440
slide->font_color[3] = 1; /* A */
441
/* default: no font color background */
442
slide->font_bgcolor[0] = 1; /* R */
443
slide->font_bgcolor[1] = 1; /* G */
444
slide->font_bgcolor[2] = 1; /* B */
445
slide->font_bgcolor[3] = 1; /* A */
447
/* Load error handling */
448
slide->load_ok = TRUE;
449
slide->original_filename = NULL;
1139
/* Prints a message in the message tab */
1141
img_message (img_window_struct *img,
1142
gboolean alert_user,
1143
gchar *message, ...)
1145
GtkTextIter message_end;
1147
char *parsed_message;
1148
int parsed_message_size = 0;
1150
va_start (args, message);
1151
parsed_message_size = vsnprintf(NULL, 0, message, args);
1153
/* if we have a glibc 2.0, just print the first 500 char */
1154
if (-1 == parsed_message_size)
1155
parsed_message_size = 500;
1156
parsed_message = malloc(parsed_message_size + 1);
1158
// vprintf(message, args);
1159
va_start(args, message);
1160
vsnprintf(parsed_message, parsed_message_size + 1, message, args);
1163
gtk_text_buffer_get_end_iter(img->message_buffer, &message_end);
1164
gtk_text_buffer_insert(img->message_buffer, &message_end,
1165
parsed_message, -1);
1167
free(parsed_message);
1171
PangoAttrList * pango_list = pango_attr_list_new();
1172
PangoAttribute * pango_attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
1173
pango_attr_list_insert(pango_list, pango_attr);
1174
gtk_label_set_attributes(GTK_LABEL(img->message_label), pango_list);
1175
pango_attr_list_unref (pango_list);