Mercurial > geeqie.yaz
comparison src/utilops.c @ 914:9427c91951e8
basic infrastructure for early error and dangerous operations checking
it needs more work
author | nadvornik |
---|---|
date | Tue, 22 Jul 2008 21:46:08 +0000 |
parents | 5a737cc935cc |
children | b416159a5820 |
comparison
equal
deleted
inserted
replaced
913:2f9edd196dca | 914:9427c91951e8 |
---|---|
797 { | 797 { |
798 file_util_perform_ci_internal(ud); | 798 file_util_perform_ci_internal(ud); |
799 } | 799 } |
800 } | 800 } |
801 } | 801 } |
802 | |
803 | |
804 static void file_util_check_resume_cb(GenericDialog *gd, gpointer data) | |
805 { | |
806 UtilityData *ud = data; | |
807 ud->phase = UTILITY_PHASE_CHECKED; | |
808 file_util_dialog_run(ud); | |
809 } | |
810 | |
811 static void file_util_check_abort_cb(GenericDialog *gd, gpointer data) | |
812 { | |
813 UtilityData *ud = data; | |
814 ud->phase = UTILITY_PHASE_START; | |
815 file_util_dialog_run(ud); | |
816 } | |
817 | |
818 void file_util_check_ci(UtilityData *ud) | |
819 { | |
820 gint error = CHANGE_OK; | |
821 | |
822 if (ud->dir_fd) | |
823 { | |
824 error = file_data_sc_check_ci_dest(ud->dir_fd); | |
825 } | |
826 else | |
827 { | |
828 GList *work = ud->flist; | |
829 while (work) | |
830 { | |
831 FileData *fd; | |
832 | |
833 fd = work->data; | |
834 work = work->next; | |
835 | |
836 error |= file_data_sc_check_ci_dest(fd); | |
837 } | |
838 } | |
839 | |
840 if (!error) | |
841 { | |
842 ud->phase = UTILITY_PHASE_CHECKED; | |
843 file_util_dialog_run(ud); | |
844 return; | |
845 } | |
846 | |
847 // FIXME: the dialogs needs better error messages with a list of files and error descriptions | |
848 if (!(error & CHANGE_ERROR_MASK)) | |
849 { | |
850 /* just a warning */ | |
851 GenericDialog *d; | |
852 | |
853 d = file_util_gen_dlg("This operation can be dangerous", GQ_WMCLASS, "dlg_confirm", | |
854 ud->parent, TRUE, | |
855 file_util_check_abort_cb, ud); | |
856 | |
857 generic_dialog_add_message(d, GTK_STOCK_DIALOG_WARNING, NULL, "Really continue?"); | |
858 | |
859 generic_dialog_add_button(d, GTK_STOCK_GO_FORWARD, _("Co_ntinue"), | |
860 file_util_check_resume_cb, TRUE); | |
861 gtk_widget_show(d->dialog); | |
862 return; | |
863 } | |
864 else | |
865 { | |
866 /* fatal error */ | |
867 GenericDialog *d; | |
868 | |
869 d = file_util_gen_dlg("This operation can't continue", GQ_WMCLASS, "dlg_confirm", | |
870 ud->parent, TRUE, | |
871 file_util_check_abort_cb, ud); | |
872 generic_dialog_add_message(d, GTK_STOCK_DIALOG_WARNING, NULL, "This operation can't continue"); | |
873 | |
874 gtk_widget_show(d->dialog); | |
875 return; | |
876 } | |
877 | |
878 } | |
879 | |
880 | |
881 | |
882 | |
802 | 883 |
803 static void file_util_cancel_cb(GenericDialog *gd, gpointer data) | 884 static void file_util_cancel_cb(GenericDialog *gd, gpointer data) |
804 { | 885 { |
805 UtilityData *ud = data; | 886 UtilityData *ud = data; |
806 | 887 |
1358 break; | 1439 break; |
1359 } | 1440 } |
1360 ud->phase = UTILITY_PHASE_ENTERING; | 1441 ud->phase = UTILITY_PHASE_ENTERING; |
1361 break; | 1442 break; |
1362 case UTILITY_PHASE_ENTERING: | 1443 case UTILITY_PHASE_ENTERING: |
1363 /* FIXME use file_data_sc_check_ci_dest to detect problems and eventually go back to PHASE_START | 1444 file_util_check_ci(ud); |
1364 or to PHASE_CANCEL */ | 1445 break; |
1365 | 1446 |
1366 ud->phase = UTILITY_PHASE_CHECKED; | 1447 ud->phase = UTILITY_PHASE_CHECKED; |
1367 case UTILITY_PHASE_CHECKED: | 1448 case UTILITY_PHASE_CHECKED: |
1368 file_util_perform_ci(ud); | 1449 file_util_perform_ci(ud); |
1369 break; | 1450 break; |