changed selection behavior as requested at
authorVladimir Nadvornik <nadvornik@suse.cz>
Tue, 2 Jun 2009 22:33:53 +0000 (22:33 +0000)
committerVladimir Nadvornik <nadvornik@suse.cz>
Tue, 2 Jun 2009 22:33:53 +0000 (22:33 +0000)
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

src/filedata.c
src/filedata.h
src/utilops.c
src/view_file_icon.c
src/view_file_list.c

index 48b8350..890547a 100644 (file)
@@ -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
index ff3c839..e666285 100644 (file)
@@ -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);
index 39b4e25..34099c9 100644 (file)
@@ -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);
@@ -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))
                {
@@ -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))
                {
@@ -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))
                {
@@ -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))
                {
@@ -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))
                {
index 712d939..8f26b07 100644 (file)
@@ -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)
@@ -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)
@@ -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;
                }
index edb1d4f..4d21105 100644 (file)
@@ -362,6 +362,7 @@ 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))
@@ -369,7 +370,37 @@ GList *vflist_pop_menu_file_list(ViewFile *vf)
                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)
@@ -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;
                }