@@ -324,9 +324,8 @@ image_window_eval( VipsImage *image,
324324 printf ( "image_window_eval: %d%%\n" , progress -> percent );
325325#endif /*DEBUG_VERBOSE*/
326326
327- /* You'd think we could just update the progress bar now, but it
328- * seems to trigger a lot of races. Instead, set an idle handler and
329- * do the update there.
327+ /* This can come from the background load thread, so we can't update
328+ * the UI directly.
330329 */
331330
332331 update = g_new ( EvalUpdate , 1 );
@@ -420,7 +419,7 @@ image_window_tile_source_changed( TileSource *tile_source, ImageWindow *win )
420419static void
421420image_window_error_response ( GtkWidget * button , int response , ImageWindow * win )
422421{
423- gtk_info_bar_set_revealed ( GTK_INFO_BAR ( win -> error_bar ), FALSE );
422+ image_window_error_hide ( win );
424423}
425424
426425static void
@@ -573,25 +572,59 @@ image_window_replace_action( GSimpleAction *action,
573572}
574573
575574static void
576- image_window_saveas_response ( GtkDialog * dialog ,
577- gint response_id , gpointer user_data )
575+ image_window_saveas_options_response ( GtkDialog * dialog ,
576+ gint response , gpointer user_data )
577+ {
578+ GtkWidget * file_chooser = GTK_WIDGET ( user_data );
579+
580+ // final save and everything worked OK, we can all pop down
581+ if ( response == GTK_RESPONSE_ACCEPT ) {
582+ gtk_window_destroy ( GTK_WINDOW ( dialog ) );
583+ gtk_window_destroy ( GTK_WINDOW ( file_chooser ) );
584+ }
585+
586+ // save options was cancelled, just pop that down
587+ if ( response == GTK_RESPONSE_CANCEL )
588+ gtk_window_destroy ( GTK_WINDOW ( dialog ) );
589+
590+ // other return codes are intermediate stages of processing and we
591+ // should do nothing
592+ }
593+
594+ static void
595+ image_window_saveas_response ( GtkDialog * dialog ,
596+ gint response , gpointer user_data )
578597{
579598 ImageWindow * win = VIPSDISP_IMAGE_WINDOW ( user_data );
580599
581- GFile * file ;
600+ if ( response == GTK_RESPONSE_ACCEPT ) {
601+ GFile * file ;
602+ char * filename ;
603+ SaveOptions * options ;
582604
583- /* We need to pop down immediately so we expose the cancel
584- * button.
585- */
586- file = gtk_file_chooser_get_file ( GTK_FILE_CHOOSER ( dialog ) );
587- image_window_error_hide ( win );
588- gtk_window_destroy ( GTK_WINDOW ( dialog ) );
605+ file = gtk_file_chooser_get_file ( GTK_FILE_CHOOSER ( dialog ) );
606+ filename = g_file_get_path ( file );
607+ VIPS_UNREF ( file );
608+
609+ options = save_options_new ( GTK_WINDOW ( dialog ),
610+ win -> tile_source -> image , filename );
611+
612+ g_free ( filename );
613+
614+ if ( !options ) {
615+ image_window_error ( win );
616+ return ;
617+ }
589618
590- if ( response_id == GTK_RESPONSE_ACCEPT &&
591- tile_source_write_to_file ( win -> tile_source , file ) )
592- image_window_error ( win );
619+ g_signal_connect_object ( options , "response" ,
620+ G_CALLBACK ( image_window_saveas_options_response ),
621+ dialog , 0 );
593622
594- VIPS_UNREF ( file );
623+ gtk_window_present ( GTK_WINDOW ( options ) );
624+ }
625+
626+ if ( response == GTK_RESPONSE_CANCEL )
627+ gtk_window_destroy ( GTK_WINDOW ( dialog ) );
595628}
596629
597630static void
@@ -601,27 +634,29 @@ image_window_saveas_action( GSimpleAction *action,
601634 ImageWindow * win = VIPSDISP_IMAGE_WINDOW ( user_data );
602635
603636 if ( win -> tile_source ) {
604- GtkWidget * dialog ;
637+ GtkWidget * file_chooser ;
605638 GFile * file ;
606639
607- dialog = gtk_file_chooser_dialog_new ( "Save file" ,
640+ file_chooser = gtk_file_chooser_dialog_new ( "Save file" ,
608641 GTK_WINDOW ( win ) ,
609642 GTK_FILE_CHOOSER_ACTION_SAVE ,
610643 "_Cancel" , GTK_RESPONSE_CANCEL ,
611644 "_Save" , GTK_RESPONSE_ACCEPT ,
612645 NULL );
613- gtk_window_set_modal ( GTK_WINDOW ( dialog ), TRUE );
646+
647+ gtk_window_set_modal ( GTK_WINDOW ( file_chooser ), true );
614648
615649 if ( (file = tile_source_get_file ( win -> tile_source )) ) {
616- gtk_file_chooser_set_file ( GTK_FILE_CHOOSER ( dialog ),
650+ gtk_file_chooser_set_file (
651+ GTK_FILE_CHOOSER ( file_chooser ),
617652 file , NULL );
618653 VIPS_UNREF ( file );
619654 }
620655
621- g_signal_connect ( dialog , "response" ,
656+ g_signal_connect ( file_chooser , "response" ,
622657 G_CALLBACK ( image_window_saveas_response ), win );
623658
624- gtk_widget_show ( dialog );
659+ gtk_widget_show ( file_chooser );
625660 }
626661}
627662
@@ -909,6 +944,7 @@ image_window_scale_begin( GtkGesture* self,
909944 imagedisplay_gtk_to_image ( VIPSDISP_IMAGEDISPLAY ( win -> imagedisplay ),
910945 finger_cx , finger_cy , & win -> scale_cx , & win -> scale_cy );
911946}
947+
912948static void
913949image_window_scale_changed ( GtkGestureZoom * self ,
914950 gdouble scale , gpointer user_data )
@@ -1343,7 +1379,6 @@ image_window_init( ImageWindow *win )
13431379 g_settings_get_value ( win -> settings , "control" ) );
13441380 change_state ( GTK_WIDGET ( win ), "info" ,
13451381 g_settings_get_value ( win -> settings , "info" ) );
1346-
13471382}
13481383
13491384static void
@@ -1493,6 +1528,10 @@ image_window_open( ImageWindow *win, GFile *file )
14931528{
14941529 TileSource * tile_source ;
14951530
1531+ // show the progress bar ... if we don't, it can take so many events
1532+ // to show that we never see it
1533+ gtk_action_bar_set_revealed ( GTK_ACTION_BAR ( win -> progress_bar ),
1534+ TRUE );
14961535 if ( !(tile_source = tile_source_new_from_file ( file )) ) {
14971536 image_window_error ( win );
14981537 return ;
0 commit comments