comparison src/utilops.c @ 1231:ca8ccf0c3e81

added done callback to utilops used the callback for metadata writting at exit and for renaming new folder
author nadvornik
date Fri, 02 Jan 2009 14:58:21 +0000
parents ebfd305d902e
children e0e12512cde2
comparison
equal deleted inserted replaced
1230:d13233ab7def 1231:ca8ccf0c3e81
312 /* data for the operation itself, internal or external */ 312 /* data for the operation itself, internal or external */
313 gboolean external; /* TRUE for external command, FALSE for internal */ 313 gboolean external; /* TRUE for external command, FALSE for internal */
314 314
315 gint external_command; 315 gint external_command;
316 gpointer resume_data; 316 gpointer resume_data;
317
318 FileUtilDoneFunc done_func;
319 gpointer done_data;
317 }; 320 };
318 321
319 enum { 322 enum {
320 UTILITY_COLUMN_FD = 0, 323 UTILITY_COLUMN_FD = 0,
321 UTILITY_COLUMN_PIXBUF, 324 UTILITY_COLUMN_PIXBUF,
1564 /* FIXME: put it here for now */ 1567 /* FIXME: put it here for now */
1565 if (ud->type == UTILITY_TYPE_WRITE_METADATA) 1568 if (ud->type == UTILITY_TYPE_WRITE_METADATA)
1566 { 1569 {
1567 metadata_write_queue_remove_list(ud->flist); 1570 metadata_write_queue_remove_list(ud->flist);
1568 } 1571 }
1572
1573 if (ud->done_func)
1574 ud->done_func((ud->phase == UTILITY_PHASE_DONE), ud->dest_path, ud->done_data);
1575
1569 if (ud->with_sidecars) 1576 if (ud->with_sidecars)
1570 file_data_sc_free_ci_list(ud->flist); 1577 file_data_sc_free_ci_list(ud->flist);
1571 else 1578 else
1572 file_data_free_ci_list(ud->flist); 1579 file_data_free_ci_list(ud->flist);
1573 1580
1639 ud->messages.fail = _("File deletion failed"); 1646 ud->messages.fail = _("File deletion failed");
1640 1647
1641 file_util_dialog_run(ud); 1648 file_util_dialog_run(ud);
1642 } 1649 }
1643 1650
1644 static void file_util_write_metadata_full(FileData *source_fd, GList *source_list, GtkWidget *parent, UtilityPhase phase) 1651 static void file_util_write_metadata_full(FileData *source_fd, GList *source_list, GtkWidget *parent, UtilityPhase phase, FileUtilDoneFunc done_func, gpointer done_data)
1645 { 1652 {
1646 UtilityData *ud; 1653 UtilityData *ud;
1647 GList *flist = filelist_copy(source_list); 1654 GList *flist = filelist_copy(source_list);
1648 1655
1649 if (source_fd) 1656 if (source_fd)
1666 1673
1667 ud->dir_fd = NULL; 1674 ud->dir_fd = NULL;
1668 ud->flist = flist; 1675 ud->flist = flist;
1669 ud->content_list = NULL; 1676 ud->content_list = NULL;
1670 ud->parent = parent; 1677 ud->parent = parent;
1678
1679 ud->done_func = done_func;
1680 ud->done_data = done_data;
1671 1681
1672 ud->messages.title = _("Write metadata"); 1682 ud->messages.title = _("Write metadata");
1673 ud->messages.question = _("Write metadata?"); 1683 ud->messages.question = _("Write metadata?");
1674 ud->messages.desc_flist = _("This will write the changed metadata into the following files"); 1684 ud->messages.desc_flist = _("This will write the changed metadata into the following files");
1675 ud->messages.desc_source_fd = ""; 1685 ud->messages.desc_source_fd = "";
2230 // ud->flist = filelist_recursive(fd); 2240 // ud->flist = filelist_recursive(fd);
2231 2241
2232 file_util_dialog_run(ud); 2242 file_util_dialog_run(ud);
2233 } 2243 }
2234 2244
2235 static void file_util_create_dir_full(FileData *fd, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase) 2245 static void file_util_create_dir_full(FileData *fd, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase, FileUtilDoneFunc done_func, gpointer done_data)
2236 { 2246 {
2237 UtilityData *ud; 2247 UtilityData *ud;
2238 2248
2239 ud = file_util_data_new(UTILITY_TYPE_CREATE_FOLDER); 2249 ud = file_util_data_new(UTILITY_TYPE_CREATE_FOLDER);
2240 2250
2256 ud->dest_path = unique_filename(buf, NULL, " ", FALSE); 2266 ud->dest_path = unique_filename(buf, NULL, " ", FALSE);
2257 g_free(buf); 2267 g_free(buf);
2258 } 2268 }
2259 2269
2260 ud->dir_fd = file_data_new_simple(ud->dest_path); 2270 ud->dir_fd = file_data_new_simple(ud->dest_path);
2271
2272 ud->done_func = done_func;
2273 ud->done_data = done_data;
2261 2274
2262 ud->messages.title = _("Create Folder"); 2275 ud->messages.title = _("Create Folder");
2263 ud->messages.question = _("Create folder?"); 2276 ud->messages.question = _("Create folder?");
2264 ud->messages.desc_flist = ""; 2277 ud->messages.desc_flist = "";
2265 ud->messages.desc_source_fd = ""; 2278 ud->messages.desc_source_fd = "";
2275 void file_util_delete(FileData *source_fd, GList *source_list, GtkWidget *parent) 2288 void file_util_delete(FileData *source_fd, GList *source_list, GtkWidget *parent)
2276 { 2289 {
2277 file_util_delete_full(source_fd, source_list, parent, options->file_ops.confirm_delete ? UTILITY_PHASE_START : UTILITY_PHASE_ENTERING); 2290 file_util_delete_full(source_fd, source_list, parent, options->file_ops.confirm_delete ? UTILITY_PHASE_START : UTILITY_PHASE_ENTERING);
2278 } 2291 }
2279 2292
2280 void file_util_write_metadata(FileData *source_fd, GList *source_list, GtkWidget *parent) 2293 void file_util_write_metadata(FileData *source_fd, GList *source_list, GtkWidget *parent, FileUtilDoneFunc done_func, gpointer done_data)
2281 { 2294 {
2282 file_util_write_metadata_full(source_fd, source_list, parent, 2295 file_util_write_metadata_full(source_fd, source_list, parent,
2283 (options->metadata.save_in_image_file && options->metadata.confirm_write) ? UTILITY_PHASE_START : UTILITY_PHASE_ENTERING); 2296 (options->metadata.save_in_image_file && options->metadata.confirm_write) ? UTILITY_PHASE_START : UTILITY_PHASE_ENTERING,
2297 done_func, done_data);
2284 } 2298 }
2285 2299
2286 void file_util_copy(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent) 2300 void file_util_copy(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent)
2287 { 2301 {
2288 file_util_copy_full(source_fd, source_list, dest_path, parent, UTILITY_PHASE_START); 2302 file_util_copy_full(source_fd, source_list, dest_path, parent, UTILITY_PHASE_START);
2340 void file_util_delete_dir(FileData *fd, GtkWidget *parent) 2354 void file_util_delete_dir(FileData *fd, GtkWidget *parent)
2341 { 2355 {
2342 file_util_delete_dir_full(fd, parent, UTILITY_PHASE_START); 2356 file_util_delete_dir_full(fd, parent, UTILITY_PHASE_START);
2343 } 2357 }
2344 2358
2345 void file_util_create_dir(FileData *dir_fd, GtkWidget *parent) 2359 void file_util_create_dir(FileData *dir_fd, GtkWidget *parent, FileUtilDoneFunc done_func, gpointer done_data)
2346 { 2360 {
2347 file_util_create_dir_full(dir_fd, NULL, parent, UTILITY_PHASE_ENTERING); 2361 file_util_create_dir_full(dir_fd, NULL, parent, UTILITY_PHASE_ENTERING, done_func, done_data);
2348 } 2362 }
2349 2363
2350 void file_util_rename_dir(FileData *source_fd, const gchar *new_path, GtkWidget *parent) 2364 void file_util_rename_dir(FileData *source_fd, const gchar *new_path, GtkWidget *parent)
2351 { 2365 {
2352 file_util_rename_dir_full(source_fd, new_path, parent, UTILITY_PHASE_ENTERING); 2366 file_util_rename_dir_full(source_fd, new_path, parent, UTILITY_PHASE_ENTERING);