allow dropping a folder to a root folder
authorColin Leroy <colin@colino.net>
Thu, 7 Nov 2002 14:22:31 +0000 (14:22 +0000)
committerColin Leroy <colin@colino.net>
Thu, 7 Nov 2002 14:22:31 +0000 (14:22 +0000)
(rescanning optimisations for soon)

ChangeLog.claws
configure.in
src/folder.c
src/folderview.c

index 3d2c6b764195af003af6afaa10a6386380bde0c8..f407805c3283f7ab28f3a3b13a927461bb0d52f1 100644 (file)
@@ -1,3 +1,9 @@
+2002-11-07 [colin]     0.8.5claws89
+
+       * src/folderview.c
+         src/folder.c
+               Allow folder dropping to a root folder
+
 2002-11-07 [paul]      0.8.5claws88
 
        * src/compose.c
index 7894eacd15ae46054646cd4ccc286036a97089dc..ee8cb85efd33e396e54385872f9dc538f7018e72 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws88
+EXTRA_VERSION=claws89
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 1ed264a78280671ed4bf036bdfbf7f9477a61dd0..fd31aa5db5ad748f8371bb08f0f79f542f27469d 100644 (file)
@@ -1480,6 +1480,7 @@ FolderItem *folder_item_move_to(FolderItem *src, FolderItem *dest)
        FolderItem *tmp = dest->parent;
        char * srcpath, * dstpath;
        char * phys_srcpath, * phys_dstpath;
+
        while (tmp) {
                if (tmp == src) {
                        alertpanel_error(_("Can't move a folder to one of its children."));
@@ -1493,6 +1494,10 @@ FolderItem *folder_item_move_to(FolderItem *src, FolderItem *dest)
        srcpath = folder_item_get_identifier(src);
        dstpath = folder_item_get_identifier(dest);
        
+       if(dstpath == NULL && dest->folder && dest->parent == NULL) {
+               /* dest can be a root folder */
+               dstpath = folder_get_identifier(dest->folder);
+       }
        if (srcpath == NULL || dstpath == NULL) {
                printf("Can't get identifiers\n");
                return NULL;
@@ -1500,7 +1505,7 @@ FolderItem *folder_item_move_to(FolderItem *src, FolderItem *dest)
 
        phys_srcpath = folder_item_get_path(src);
        phys_dstpath = g_strconcat(folder_item_get_path(dest),G_DIR_SEPARATOR_S,g_basename(srcpath),NULL);
-       
+
        if (src->parent == dest) {
                alertpanel_error(_("Source and destination are the same."));
                g_free(srcpath);
index 26e23699085d735c1c59619ae6b8e56f0de52207..f185fba236e013ffdec045a2ef2e2154105117b6 100644 (file)
@@ -2554,10 +2554,7 @@ static gboolean folderview_drag_motion_cb(GtkWidget      *widget,
                node = gtk_ctree_node_nth(GTK_CTREE(widget), row);
                item = gtk_ctree_node_get_row_data(GTK_CTREE(widget), node);
                src_item = folderview->summaryview->folder_item;
-               /* FIXME: Dragging on a "root folder" (ie, ~/Mail) should be
-                  possible when the source is the folderview. Requires hacking
-                  folder_item_move_to() because there's no identifier for these
-                  folders. */
+
                if (item && item->folder && item->path &&
                    src_item && src_item != item) {
                        switch (item->folder->type) {
@@ -2568,7 +2565,13 @@ static gboolean folderview_drag_motion_cb(GtkWidget      *widget,
                        default:
                                break;
                        }
+               } else if (item && item->folder && folder_item_get_path(item) &&
+                          src_item && src_item != item) {
+                       /* a root folder - acceptable only from folderview */
+                       if (item->folder->type == F_MH || item->folder->type == F_IMAP)
+                               acceptable = TRUE;
                }
+                       
        }
 
        if (acceptable) {
@@ -2620,6 +2623,13 @@ static void folderview_drag_received_cb(GtkWidget        *widget,
                node = gtk_ctree_node_nth(GTK_CTREE(widget), row);
                item = gtk_ctree_node_get_row_data(GTK_CTREE(widget), node);
                src_item = folderview->summaryview->folder_item;
+               
+               /* re-check (due to acceptable possibly set for folder moves */
+               if (!(item && item->folder && item->path &&
+                     src_item && src_item != item && 
+                     (item->folder->type == F_MH || item->folder->type == F_IMAP))) {
+                       return;
+               }
                if (item && src_item) {
                        switch (drag_context->action) {
                                case GDK_ACTION_COPY:
@@ -2659,6 +2669,7 @@ static void folderview_drag_received_cb(GtkWidget        *widget,
                        return;
                buf = g_strdup_printf(_("Moving %s to %s..."), src_item->name, item->name);
                STATUSBAR_PUSH(folderview->mainwin, buf);
+               g_free(buf);
                main_window_cursor_wait(folderview->mainwin);
                if ((new_item = folder_item_move_to(src_item, item)) != NULL)
                        gtk_drag_finish(drag_context, TRUE, TRUE, time);