add spring-loaded folders
authorColin Leroy <colin@colino.net>
Mon, 25 Nov 2002 17:00:10 +0000 (17:00 +0000)
committerColin Leroy <colin@colino.net>
Mon, 25 Nov 2002 17:00:10 +0000 (17:00 +0000)
ChangeLog.claws
configure.in
src/folderview.c
src/gtkutils.c
src/gtkutils.h

index 1658624..92aa5a6 100644 (file)
@@ -1,3 +1,10 @@
+2002-11-25 [colin]     0.8.6claws5
+
+       * src/gtkutils.[ch]
+               Add gtkut_ctree_node_is_parent()
+       * src/folderview.c
+               Spring-loaded folders
+
 2002-11-25 [colin]     0.8.6claws4
 
        * src/utils.[ch]
index 2d92660..a33c709 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=6
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws4
+EXTRA_VERSION=claws5
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index d78aab2..6cf17dc 100644 (file)
@@ -2510,6 +2510,24 @@ static void folderview_property_cb(FolderView *folderview, guint action,
 #endif 
 }
 
+static GSList *recollapse_folders = NULL;
+static void folderview_recollapse(GtkCTree *ctree, GtkCTreeNode *node)
+{
+       GSList *list = NULL;
+       GSList *done = NULL;
+       for (list = recollapse_folders; list != NULL; list = g_slist_next(list)) {
+               if (!gtkut_ctree_node_is_parent(GTK_CTREE_NODE(list->data), node)
+               &&  list->data != node) {
+                       gtk_ctree_collapse(ctree, GTK_CTREE_NODE(list->data));
+                       done = g_slist_append(done, GTK_CTREE_NODE(list->data));
+               }
+       }
+       for (list = done; list != NULL; list = g_slist_next(list)) {
+               recollapse_folders = g_slist_remove(recollapse_folders, list->data);
+       }
+       g_slist_free(done);
+}
+
 static gboolean folderview_drag_motion_cb(GtkWidget      *widget,
                                          GdkDragContext *context,
                                          gint            x,
@@ -2548,6 +2566,12 @@ static gboolean folderview_drag_motion_cb(GtkWidget      *widget,
        }
 
        if (acceptable) {
+               folderview_recollapse(GTK_CTREE(widget), node);
+               if (item->collapsed) {
+                       gtk_ctree_expand(GTK_CTREE(widget), node);
+                       recollapse_folders = g_slist_append(recollapse_folders, node);
+               }
+
                gtk_signal_handler_block_by_func
                        (GTK_OBJECT(widget),
                         GTK_SIGNAL_FUNC(folderview_selected), folderview);
@@ -2693,6 +2717,7 @@ static void folderview_drag_received_cb(GtkWidget        *widget,
                inc_unlock();           
                gtk_widget_set_sensitive(folderview->ctree, TRUE);
        }
+       recollapse_folders = NULL;
 }
 
 static gint folderview_clist_compare(GtkCList *clist,
@@ -2788,6 +2813,8 @@ static void folderview_start_drag(GtkWidget *widget, gint button, GdkEvent *even
 
        list = gtk_target_list_new(folderview_drag_types, 1);
 
+       recollapse_folders = NULL; /* in case the last drag has been cancelled */
+       
        context = gtk_drag_begin(widget, list,
                                 GDK_ACTION_MOVE|GDK_ACTION_COPY|GDK_ACTION_DEFAULT, button, event);
        gtk_drag_set_icon_default(context);
index f0276b0..0e6c084 100644 (file)
@@ -255,6 +255,22 @@ void gtkut_ctree_expand_parent_all(GtkCTree *ctree, GtkCTreeNode *node)
                gtk_ctree_expand(ctree, node);
 }
 
+gboolean gtkut_ctree_node_is_parent(GtkCTreeNode *parent, GtkCTreeNode *node)
+{
+       GtkCTreeNode *tmp;
+       g_return_val_if_fail(node != NULL, FALSE);
+       g_return_val_if_fail(parent != NULL, FALSE);
+       tmp = node;
+       
+       while (tmp) {
+               if(GTK_CTREE_ROW(tmp)->parent && GTK_CTREE_ROW(tmp)->parent == parent)
+                       return TRUE;
+               tmp = GTK_CTREE_ROW(tmp)->parent;
+       }
+       
+       return FALSE;
+}
+
 void gtkut_ctree_set_focus_row(GtkCTree *ctree, GtkCTreeNode *node)
 {
        gtkut_clist_set_focus_row(GTK_CLIST(ctree),
index 40915ab..94b0acc 100644 (file)
@@ -106,6 +106,8 @@ GtkCTreeNode *gtkut_ctree_find_collapsed_parent
                                         GtkCTreeNode   *node);
 void gtkut_ctree_expand_parent_all     (GtkCTree       *ctree,
                                         GtkCTreeNode   *node);
+gboolean gtkut_ctree_node_is_parent    (GtkCTreeNode   *parent, 
+                                        GtkCTreeNode   *node);
 void gtkut_ctree_set_focus_row         (GtkCTree       *ctree,
                                         GtkCTreeNode   *node);