1619
1644
static void img_combo_box_transition_type_changed (GtkComboBox *combo, img_window_struct *img)
1621
GList *selected, *bak;
1623
1649
GtkTreeModel *model;
1625
1651
slide_struct *info_slide;
1631
/* Get the address of the transition function stored in the model of the combo box*/
1632
model = gtk_combo_box_get_model(combo);
1633
gtk_combo_box_get_active_iter(combo, &iter);
1634
gtk_tree_model_get(model, &iter, 0, &pix, 2, &address, 3, &transition_id, -1);
1636
/* Get index of currently selected item */
1637
if (transition_id == -1)
1638
gtk_widget_set_sensitive(img->trans_duration,FALSE);
1657
/* Check if anything is selected and return if nothing is */
1658
selected = gtk_icon_view_get_selected_items(
1659
GTK_ICON_VIEW( img->active_icon ) );
1660
if( selected == NULL )
1663
/* Get information about selected transition */
1664
model = gtk_combo_box_get_model( combo );
1665
gtk_combo_box_get_active_iter( combo, &iter );
1666
gtk_tree_model_get( model, &iter, 0, &pix,
1671
/* If user applied None transition, make duration combo insensitive */
1672
if( transition_id == -1 )
1673
gtk_widget_set_sensitive( img->trans_duration, FALSE );
1640
gtk_widget_set_sensitive(img->trans_duration,TRUE);
1675
gtk_widget_set_sensitive( img->trans_duration, TRUE );
1642
1677
/* If user selected group name, automatically select first transition
1643
1678
* from this group. */
1646
1681
GtkTreeIter parent = iter;
1647
1682
gtk_tree_model_iter_nth_child( model, &iter, &parent, 0 );
1648
gtk_tree_model_get(model, &iter, 0, &pix, 2, &address, 3, &transition_id, -1);
1649
g_signal_handlers_block_by_func(img->transition_type,
1650
img_combo_box_transition_type_changed,
1652
gtk_combo_box_set_active_iter(GTK_COMBO_BOX(img->transition_type),
1654
g_signal_handlers_unblock_by_func(img->transition_type,
1655
img_combo_box_transition_type_changed,
1683
gtk_tree_model_get( model, &iter, 0, &pix,
1687
g_signal_handlers_block_by_func( img->transition_type,
1688
img_combo_box_transition_type_changed,
1690
gtk_combo_box_set_active_iter( GTK_COMBO_BOX( img->transition_type),
1692
g_signal_handlers_unblock_by_func( img->transition_type,
1693
img_combo_box_transition_type_changed,
1697
/* Get string representation of the path, which will be
1698
* saved inside slide */
1658
1699
p = gtk_tree_model_get_path( model, &iter );
1659
1700
path = gtk_tree_path_to_string( p );
1660
1701
gtk_tree_path_free( p );
1703
/* Update all selected slides */
1662
1704
model = GTK_TREE_MODEL( img->thumbnail_model );
1663
selected = gtk_icon_view_get_selected_items(GTK_ICON_VIEW (img->active_icon));
1664
if (selected == NULL)
1670
/* Avoiding GList memory leak. */
1671
1705
bak = selected;
1672
1706
while (selected)
1674
gtk_tree_model_get_iter(model, &iter,selected->data);
1675
gtk_tree_model_get(model, &iter,1,&info_slide,-1);
1708
gtk_tree_model_get_iter( model, &iter, selected->data );
1709
gtk_tree_model_get( model, &iter, 1, &info_slide, -1 );
1676
1710
gtk_list_store_set( GTK_LIST_STORE( model ), &iter, 2, pix, -1 );
1678
g_object_unref( G_OBJECT( pix ) );
1679
1711
info_slide->render = (ImgRender)address;
1680
1712
info_slide->transition_id = transition_id;
1681
1713
g_free( info_slide->path );
2412
2449
g_list_free( selection );
2452
static void img_report_slides_transitions(img_window_struct *img)
2454
static GtkWidget *viewport;
2456
GHashTable *trans_hash;
2459
GtkTreeModel *model;
2464
#define GIP( val ) GINT_TO_POINTER( ( val ) )
2465
#define GPI( val ) GPOINTER_TO_INT( ( val ) )
2467
if (img->report_dialog == NULL)
2473
img->report_dialog = gtk_dialog_new_with_buttons(
2474
_("Slides Transitions Report Dialog"),
2475
GTK_WINDOW( img->imagination_window ),
2476
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
2477
GTK_STOCK_CLOSE, GTK_RESPONSE_ACCEPT,
2479
gtk_container_set_border_width( GTK_CONTAINER( img->report_dialog ),
2481
gtk_window_set_default_size( GTK_WINDOW( img->report_dialog ),
2483
gtk_window_set_modal( GTK_WINDOW( img->report_dialog ), FALSE );
2485
action = gtk_dialog_get_action_area( GTK_DIALOG( img->report_dialog ) );
2486
gtk_button_box_set_layout( GTK_BUTTON_BOX( action ),
2487
GTK_BUTTONBOX_SPREAD);
2488
g_signal_connect( G_OBJECT( img->report_dialog ), "delete-event",
2489
G_CALLBACK( gtk_widget_hide_on_delete ), NULL );
2490
g_signal_connect( G_OBJECT( img->report_dialog ), "response",
2491
G_CALLBACK( gtk_widget_hide_on_delete ), NULL );
2493
vbox = gtk_dialog_get_content_area( GTK_DIALOG( img->report_dialog ) );
2494
swindow = gtk_scrolled_window_new( NULL, NULL );
2495
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( swindow ),
2496
GTK_POLICY_AUTOMATIC,
2497
GTK_POLICY_AUTOMATIC);
2498
gtk_box_pack_start( GTK_BOX( vbox ), swindow, TRUE, TRUE, 0 );
2500
viewport = gtk_viewport_new( NULL, NULL );
2501
gtk_viewport_set_shadow_type( GTK_VIEWPORT( viewport ),
2503
gtk_container_add( GTK_CONTAINER( swindow ), viewport );
2506
/* Delete previous shown rows */
2507
if( img->vbox_slide_report_rows )
2509
gtk_widget_destroy( img->vbox_slide_report_rows );
2510
img->vbox_slide_report_rows = NULL;
2513
model = GTK_TREE_MODEL(img->thumbnail_model);
2514
if( gtk_tree_model_get_iter_first( model, &iter ) == 0)
2517
/* Hash table is used only for quick way of accessing transition info.
2518
* Information is stored inside array of 3 gpointers */
2519
trans_hash = g_hash_table_new( g_direct_hash, NULL );
2521
for( flag = TRUE, i = 0;
2523
flag = gtk_tree_model_iter_next( model, &iter ), i++ )
2525
slide_struct *slide;
2528
gtk_tree_model_get( model, &iter, 1, &slide, -1 );
2529
if( slide->transition_id < 1 )
2532
info = g_hash_table_lookup( trans_hash, GIP( slide->transition_id ) );
2535
/* Create new info element */
2536
info = g_slice_alloc0( sizeof( gpointer ) * 3 );
2537
info[0] = GIP( slide->transition_id );
2538
g_hash_table_insert( trans_hash, GIP( slide->transition_id ),
2542
/* Increment counter */
2543
info[1] = GIP( GPI( info[1] ) + 1 );
2545
/* Append another element to glist */
2546
info[2] = g_list_append( (GList *)info[2], GIP( i ) );
2549
/* Set the vertical box container that was previously
2550
* destroyed so to allow update in real time */
2551
img->vbox_slide_report_rows = gtk_vbox_new( FALSE, 15 );
2552
gtk_container_add( GTK_CONTAINER( viewport ), img->vbox_slide_report_rows );
2554
label = gtk_label_new( _("\n<span weight='bold'>Note:</span>\n\n"
2555
"Slides whose transition is applied only once are "
2557
"Click on the slide to have Imagination "
2558
"automatically select it." ) );
2559
gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 );
2560
gtk_label_set_use_markup( GTK_LABEL( label ), TRUE );
2561
gtk_box_pack_start( GTK_BOX( img->vbox_slide_report_rows ), label,
2564
/* Get information and free hash table */
2565
values = g_hash_table_get_values( trans_hash );
2566
g_hash_table_destroy( trans_hash );
2568
/* Sort values list here */
2569
values = g_list_sort( values, img_sort_report_transitions );
2571
/* Display results */
2572
for( tmp = values; tmp; tmp = g_list_next( tmp ) )
2574
gpointer *info = tmp->data;
2576
if( GPI( info[1] ) > 1 )
2579
GtkWidget *hbox_rows,
2586
hbox_rows = gtk_hbox_new( FALSE, 15 );
2587
gtk_box_pack_start( GTK_BOX( img->vbox_slide_report_rows ),
2588
hbox_rows, FALSE, FALSE, 0 );
2590
frame = gtk_frame_new( NULL );
2591
gtk_frame_set_shadow_type( GTK_FRAME( frame ), GTK_SHADOW_NONE );
2592
gtk_box_pack_start( GTK_BOX( hbox_rows ), frame, FALSE, FALSE, 0 );
2594
#if PLUGINS_INSTALLED
2596
g_strdup_printf( "%s/imagination/pixmaps/imagination-%d.png",
2597
DATADIR, GPI( info[0] ) );
2598
#else /* PLUGINS_INSTALLED */
2600
g_strdup_printf( "./pixmaps/imagination-%d.png",
2603
image = gtk_image_new_from_file( filename );
2605
gtk_container_add( GTK_CONTAINER( frame ), image );
2607
nr = g_strdup_printf( "(%d)", GPI( info[1] ) );
2608
nr_label = gtk_label_new( nr );
2609
gtk_box_pack_start( GTK_BOX( hbox_rows ), nr_label,
2613
for( tmp1 = (GList *)info[2]; tmp1; tmp1 = g_list_next( tmp1 ) )
2621
path = gtk_tree_path_new_from_indices( GPI( tmp1->data ), -1 );
2622
gtk_tree_model_get_iter( model, &iter, path );
2623
gtk_tree_path_free( path );
2625
gtk_tree_model_get( model, &iter, 0, &pixbuf, -1 );
2627
button = gtk_button_new();
2628
g_object_set_data( G_OBJECT( button ), "index", tmp1->data );
2629
g_signal_connect( G_OBJECT( button ), "clicked",
2630
G_CALLBACK( img_select_slide_from_slide_report_dialog ), img );
2631
gtk_box_pack_start( GTK_BOX( hbox_rows ), button,
2634
image = gtk_image_new_from_pixbuf( pixbuf );
2635
g_object_unref( G_OBJECT( pixbuf ) );
2636
gtk_container_add( GTK_CONTAINER( button ), image );
2639
g_list_free( (GList *)info[2] );
2640
g_slice_free1( sizeof( gpointer ) * 3, info );
2643
if( GTK_WIDGET_VISIBLE( img->report_dialog ) )
2644
gtk_widget_show_all( img->report_dialog );
2650
static void img_select_slide_from_slide_report_dialog(GtkButton *button, img_window_struct *img)
2653
gint slide = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button), "index"));
2655
gtk_icon_view_unselect_all(GTK_ICON_VIEW (img->active_icon));
2656
path = gtk_tree_path_new_from_indices(slide, -1);
2657
gtk_icon_view_set_cursor (GTK_ICON_VIEW (img->active_icon), path, NULL, FALSE);
2658
gtk_icon_view_select_path (GTK_ICON_VIEW (img->active_icon), path);
2659
gtk_icon_view_scroll_to_path (GTK_ICON_VIEW (img->active_icon), path, FALSE, 0, 0);
2660
gtk_tree_path_free (path);
2663
static void img_show_slides_report_dialog(GtkMenuItem *item, img_window_struct *img)
2665
img_report_slides_transitions(img);
2666
gtk_widget_show_all(img->report_dialog);
2670
img_sort_report_transitions( gconstpointer a,
2673
gint val_a = GPOINTER_TO_INT( ( (gpointer *)a )[1] ),
2674
val_b = GPOINTER_TO_INT( ( (gpointer *)b )[1] );
2676
return( val_a - val_b );