Skip to content

Commit

Permalink
changed selection behavior as requested at
Browse files Browse the repository at this point in the history
http://sourceforge.net/tracker/?func=detail&aid=2789933&group_id=222125&atid=1054680

file view - sidecars are added to the selection if they were expicitly selected
            or if the entry is collapsed
icon view - selection always contains sidecars

file operations splits partially selected groups - selected files have
disabled grouping
  • Loading branch information
nadvornik committed Jun 2, 2009
1 parent 5a743f0 commit 347fc7c
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 23 deletions.
83 changes: 82 additions & 1 deletion src/filedata.c
Original file line number Diff line number Diff line change
Expand Up @@ -2335,8 +2335,89 @@ gboolean file_data_sc_apply_ci(FileData *fd)
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
Expand Down
3 changes: 3 additions & 0 deletions src/filedata.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ gboolean file_data_sc_apply_ci(FileData *fd);
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);
Expand Down
24 changes: 5 additions & 19 deletions src/utilops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1700,20 +1700,6 @@ static void file_util_warn_op_in_progress(const gchar *title)
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);
Expand Down Expand Up @@ -1943,7 +1929,7 @@ static void file_util_delete_full(FileData *source_fd, GList *source_list, GtkWi

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))
{
Expand Down Expand Up @@ -2030,7 +2016,7 @@ static void file_util_move_full(FileData *source_fd, GList *source_list, const g

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))
{
Expand Down Expand Up @@ -2071,7 +2057,7 @@ static void file_util_copy_full(FileData *source_fd, GList *source_list, const g

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))
{
Expand Down Expand Up @@ -2112,7 +2098,7 @@ static void file_util_rename_full(FileData *source_fd, GList *source_list, const

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))
{
Expand Down Expand Up @@ -2162,7 +2148,7 @@ static void file_util_start_editor_full(const gchar *key, FileData *source_fd, G

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))
{
Expand Down
13 changes: 11 additions & 2 deletions src/view_file_icon.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ GList *vficon_pop_menu_file_list(ViewFile *vf)
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)
Expand Down Expand Up @@ -907,7 +908,7 @@ guint vficon_selection_count(ViewFile *vf, gint64 *bytes)
GList *vficon_selection_get_list(ViewFile *vf)
{
GList *list = NULL;
GList *work;
GList *work, *work2;

work = VFICON(vf)->selection;
while (work)
Expand All @@ -917,6 +918,14 @@ GList *vficon_selection_get_list(ViewFile *vf)
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;
}
Expand Down
45 changes: 44 additions & 1 deletion src/view_file_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,45 @@ void vflist_dnd_init(ViewFile *vf)

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)
Expand Down Expand Up @@ -1307,6 +1338,18 @@ GList *vflist_selection_get_list(ViewFile *vf)
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;
}
Expand Down

0 comments on commit 347fc7c

Please sign in to comment.