return TRUE;
}
+static gboolean file_data_list_contains_whole_group(GList *list, FileData *fd)
+{
+ GList *work;
+ if (fd->parent) fd = fd->parent;
+ if (!g_list_find(list, fd)) return FALSE;
+
+ work = fd->sidecar_files;
+ while (work)
+ {
+ if (!g_list_find(list, work->data)) return FALSE;
+ work = work->next;
+ }
+ return TRUE;
+}
+
+#if 0
+static gboolean file_data_list_dump(GList *list)
+{
+ GList *work, *work2;
+
+ work = list;
+ while (work)
+ {
+ FileData *fd = work->data;
+ printf("%s\n", fd->name);
+ work2 = fd->sidecar_files;
+ while (work2)
+ {
+ FileData *fd = work2->data;
+ printf(" %s\n", fd->name);
+ work2 = work2->next;
+ }
+ work = work->next;
+ }
+ return TRUE;
+}
+#endif
+
+GList *file_data_process_groups(GList *list)
+{
+ GList *out = NULL;
+ GList *work = list;
+
+ /* change partial groups to independent files */
+ while (work)
+ {
+ FileData *fd = work->data;
+ work = work->next;
+
+ if (!file_data_list_contains_whole_group(list, fd))
+ file_data_disable_grouping(fd, TRUE);
+ }
+
+ /* remove sidecars from the list,
+ they can be still acessed via main_fd->sidecar_files */
+ work = list;
+ while (work)
+ {
+ FileData *fd = work->data;
+ work = work->next;
+
+ if (!fd->parent)
+ {
+ out = g_list_prepend(out, fd);
+ }
+ else
+ {
+ file_data_unref(fd);
+ }
+ }
+
+ g_list_free(list);
+ out = g_list_reverse(out);
+
+ return out;
+}
+
+
+
+
+
/*
- * notify other modules about the change described by FileFataChangeInfo
+ * notify other modules about the change described by FileDataChangeInfo
*/
/* might use file_maint_ functions for now, later it should be changed to a system of callbacks
void file_data_sc_free_ci(FileData *fd);
void file_data_sc_free_ci_list(GList *fd_list);
+GList *file_data_process_groups(GList *list);
+
+
typedef void (*FileDataNotifyFunc)(FileData *fd, NotifyType type, gpointer data);
gboolean file_data_register_notify_func(FileDataNotifyFunc func, gpointer data, NotifyPriority priority);
gboolean file_data_unregister_notify_func(FileDataNotifyFunc func, gpointer data);
file_util_warning_dialog(title, _("Another operation in progress.\n"), GTK_STOCK_DIALOG_ERROR, NULL);
}
-static void file_util_disable_grouping_sc_list(GList *list)
-{
- GList *work = list;
-
- while (work)
- {
- FileData *fd = work->data;
- work = work->next;
-
- if (fd->parent) file_data_disable_grouping(fd, TRUE);
- }
-
-}
-
static void file_util_details_dialog_close_cb(GtkWidget *widget, gpointer data)
{
gtk_widget_destroy(data);
if (!flist) return;
- file_util_disable_grouping_sc_list(flist);
+ flist = file_data_process_groups(flist);
if (!file_data_sc_add_ci_delete_list(flist))
{
if (!flist) return;
- file_util_disable_grouping_sc_list(flist);
+ flist = file_data_process_groups(flist);
if (!file_data_sc_add_ci_move_list(flist, dest_path))
{
if (!flist) return;
- file_util_disable_grouping_sc_list(flist);
+ flist = file_data_process_groups(flist);
if (!file_data_sc_add_ci_copy_list(flist, dest_path))
{
if (!flist) return;
- file_util_disable_grouping_sc_list(flist);
+ flist = file_data_process_groups(flist);
if (!file_data_sc_add_ci_rename_list(flist, dest_path))
{
if (!flist) return;
- file_util_disable_grouping_sc_list(flist);
+ flist = file_data_process_groups(flist);
if (!file_data_sc_add_ci_unspecified_list(flist, dest_path))
{
return vf_selection_get_list(vf);
}
- return g_list_append(NULL, file_data_ref(VFICON(vf)->click_id->fd));
+
+ return g_list_prepend(filelist_copy(VFICON(vf)->click_id->fd->sidecar_files), file_data_ref(VFICON(vf)->click_id->fd));
}
void vficon_pop_menu_view_cb(GtkWidget *widget, gpointer data)
GList *vficon_selection_get_list(ViewFile *vf)
{
GList *list = NULL;
- GList *work;
+ GList *work, *work2;
work = VFICON(vf)->selection;
while (work)
g_assert(fd->magick == 0x12345678);
list = g_list_prepend(list, file_data_ref(fd));
+
+ work2 = fd->sidecar_files;
+ while (work2)
+ {
+ fd = work2->data;
+ list = g_list_prepend(list, file_data_ref(fd));
+ work2 = work2->next;
+ }
work = work->next;
}
GList *vflist_pop_menu_file_list(ViewFile *vf)
{
+ GList *list;
if (!VFLIST(vf)->click_fd) return NULL;
if (vflist_row_is_selected(vf, VFLIST(vf)->click_fd))
return vf_selection_get_list(vf);
}
- return g_list_append(NULL, file_data_ref(VFLIST(vf)->click_fd));
+ list = g_list_append(NULL, file_data_ref(VFLIST(vf)->click_fd));
+
+ if (VFLIST(vf)->click_fd->sidecar_files)
+ {
+ /* check if the row is expanded */
+ GtkTreeModel *store;
+ GtkTreeIter iter;
+
+ store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
+ if (vflist_find_row(vf, VFLIST(vf)->click_fd, &iter) >= 0)
+ {
+ GtkTreePath *tpath;
+
+ tpath = gtk_tree_model_get_path(store, &iter);
+ if (!gtk_tree_view_row_expanded(GTK_TREE_VIEW(vf->listview), tpath))
+ {
+ /* unexpanded - add whole group */
+ GList *work = VFLIST(vf)->click_fd->sidecar_files;
+ while (work)
+ {
+ FileData *sfd = work->data;
+ list = g_list_prepend(list, file_data_ref(sfd));
+ work = work->next;
+ }
+ }
+ gtk_tree_path_free(tpath);
+ }
+ list = g_list_reverse(list);
+ }
+
+ return list;
}
void vflist_pop_menu_view_cb(GtkWidget *widget, gpointer data)
gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1);
list = g_list_prepend(list, file_data_ref(fd));
+
+ if (!fd->parent && !gtk_tree_view_row_expanded(GTK_TREE_VIEW(vf->listview), tpath))
+ {
+ /* unexpanded - add whole group */
+ GList *work2 = fd->sidecar_files;
+ while (work2)
+ {
+ FileData *sfd = work2->data;
+ list = g_list_prepend(list, file_data_ref(sfd));
+ work2 = work2->next;
+ }
+ }
work = work->next;
}