Mercurial > geeqie
comparison src/filedata.c @ 849:db68d673448f
added possibility to disable grouping of selected files
author | nadvornik |
---|---|
date | Sun, 22 Jun 2008 09:19:42 +0000 |
parents | 8911a4f0e56c |
children | 0c3f6ef17d18 |
comparison
equal
deleted
inserted
replaced
848:e1d158ac6d36 | 849:db68d673448f |
---|---|
335 fd->ref = 1; | 335 fd->ref = 1; |
336 fd->magick = 0x12345678; | 336 fd->magick = 0x12345678; |
337 | 337 |
338 file_data_set_path(fd, path_utf8); /* set path, name, collate_key_*, original_path */ | 338 file_data_set_path(fd, path_utf8); /* set path, name, collate_key_*, original_path */ |
339 | 339 |
340 if (check_sidecars && sidecar_file_priority(fd->extension)) | 340 if (check_sidecars) |
341 file_data_check_sidecars(fd); | 341 file_data_check_sidecars(fd); |
342 | 342 |
343 return fd; | 343 return fd; |
344 } | 344 } |
345 | 345 |
346 static void file_data_check_sidecars(FileData *fd) | 346 static void file_data_check_sidecars(FileData *fd) |
347 { | 347 { |
348 int base_len = fd->extension - fd->path; | 348 int base_len; |
349 GString *fname = g_string_new_len(fd->path, base_len); | 349 GString *fname; |
350 FileData *parent_fd = NULL; | 350 FileData *parent_fd = NULL; |
351 GList *work = sidecar_ext_get_list(); | 351 GList *work; |
352 | |
353 if (fd->disable_grouping || !sidecar_file_priority(fd->extension)) | |
354 return; | |
355 | |
356 base_len = fd->extension - fd->path; | |
357 fname = g_string_new_len(fd->path, base_len); | |
358 work = sidecar_ext_get_list(); | |
352 | 359 |
353 while (work) | 360 while (work) |
354 { | 361 { |
355 /* check for possible sidecar files; | 362 /* check for possible sidecar files; |
356 the sidecar files created here are referenced only via fd->sidecar_files or fd->parent, | 363 the sidecar files created here are referenced only via fd->sidecar_files or fd->parent, |
375 | 382 |
376 if (!stat_utf8(fname->str, &nst)) | 383 if (!stat_utf8(fname->str, &nst)) |
377 continue; | 384 continue; |
378 | 385 |
379 new_fd = file_data_new(fname->str, &nst, FALSE); | 386 new_fd = file_data_new(fname->str, &nst, FALSE); |
387 | |
388 if (new_fd->disable_grouping) | |
389 { | |
390 file_data_unref(new_fd); | |
391 continue; | |
392 } | |
393 | |
380 new_fd->ref--; /* do not use ref here */ | 394 new_fd->ref--; /* do not use ref here */ |
381 } | 395 } |
382 | 396 |
383 if (!parent_fd) | 397 if (!parent_fd) |
384 parent_fd = new_fd; /* parent is the one with the highest prio, found first */ | 398 parent_fd = new_fd; /* parent is the one with the highest prio, found first */ |
533 file_data_free(sfd); | 547 file_data_free(sfd); |
534 return NULL; | 548 return NULL; |
535 } | 549 } |
536 | 550 |
537 return sfd; | 551 return sfd; |
552 } | |
553 | |
554 /* disables / enables grouping for particular file, sends UPDATE notification */ | |
555 void file_data_disable_grouping(FileData *fd, gboolean disable) | |
556 { | |
557 if (!fd->disable_grouping == !disable) return; | |
558 fd->disable_grouping = !!disable; | |
559 | |
560 if (disable) | |
561 { | |
562 if (fd->parent) | |
563 { | |
564 FileData *parent = file_data_ref(fd->parent); | |
565 file_data_disconnect_sidecar_file(parent, fd); | |
566 file_data_send_notification(fd, NOTIFY_TYPE_INTERNAL); | |
567 file_data_send_notification(parent, NOTIFY_TYPE_INTERNAL); | |
568 file_data_unref(parent); | |
569 } | |
570 else if (fd->sidecar_files) | |
571 { | |
572 GList *sidecar_files = filelist_copy(fd->sidecar_files); | |
573 GList *work = sidecar_files; | |
574 while (work) | |
575 { | |
576 FileData *sfd = work->data; | |
577 work = work->next; | |
578 file_data_disconnect_sidecar_file(fd, sfd); | |
579 file_data_send_notification(sfd, NOTIFY_TYPE_INTERNAL); | |
580 } | |
581 file_data_send_notification(fd, NOTIFY_TYPE_INTERNAL); | |
582 file_data_check_sidecars((FileData *)sidecar_files->data); /* this will group the sidecars back together */ | |
583 filelist_free(sidecar_files); | |
584 } | |
585 } | |
586 else | |
587 { | |
588 file_data_check_sidecars(fd); | |
589 file_data_send_notification(fd, NOTIFY_TYPE_INTERNAL); | |
590 } | |
538 } | 591 } |
539 | 592 |
540 /* compare name without extension */ | 593 /* compare name without extension */ |
541 gint file_data_compare_name_without_ext(FileData *fd1, FileData *fd2) | 594 gint file_data_compare_name_without_ext(FileData *fd1, FileData *fd2) |
542 { | 595 { |
1033 | 1086 |
1034 return g_string_free(result, FALSE); | 1087 return g_string_free(result, FALSE); |
1035 } | 1088 } |
1036 | 1089 |
1037 | 1090 |
1038 /* disables / enables grouping for particular file, sends UPDATE notification */ | 1091 |
1039 void file_data_disable_grouping(FileData *fd); // now file_data_disconnect_sidecar_file, broken | |
1040 void file_data_disable_grouping(FileData *fd); | |
1041 | |
1042 /* runs stat on a file and sends UPDATE notification if it has been changed */ | |
1043 void file_data_sc_update(FileData *fd); | |
1044 | |
1045 | |
1046 | |
1047 | |
1048 /* | 1092 /* |
1049 * add FileDataChangeInfo (see typedefs.h) for the given operation | 1093 * add FileDataChangeInfo (see typedefs.h) for the given operation |
1050 * uses file_data_add_change_info | 1094 * uses file_data_add_change_info |
1051 * | 1095 * |
1052 * fails if the fd->change already exists - change operations can't run in parallel | 1096 * fails if the fd->change already exists - change operations can't run in parallel |