[PATCH] Open folder in icon view when hovering for more than 0.5 s



The attached patch was also attached to bug 44001 [1] which demands for
spring-loaded folders. Since there is not yet a clear patent policy, I
think it's safe to get this non-patent infridging partial implementation
into Nautilus, which opens folders in the icon view that are hovered for
more than 500 ms. To my understanding, the essence of the spring-loaded
folder patent is the auto popdown.

[1] http://bugzilla.gnome.org/show_bug.cgi?id=44001

-- 
Christian Neumair <chris gnome-de org>
Index: libnautilus-private/nautilus-icon-dnd.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-dnd.c,v
retrieving revision 1.149
diff -u -p -r1.149 nautilus-icon-dnd.c
--- libnautilus-private/nautilus-icon-dnd.c	29 Aug 2005 10:00:29 -0000	1.149
+++ libnautilus-private/nautilus-icon-dnd.c	1 Sep 2005 09:25:07 -0000
@@ -84,6 +84,8 @@ static void     dnd_highlight_queue_redr
 static GtkTargetList *drop_types_list = NULL;
 static GtkTargetList *drop_types_list_root = NULL;
 
+#define DROP_TARGET_ACTIVATION_TIMEOUT 500
+
 static EelCanvasItem *
 create_selection_shadow (NautilusIconContainer *container,
 			 GList *list)
@@ -1082,6 +1084,43 @@ nautilus_icon_container_receive_dropped_
 }
 
 static void
+unschedule_drop_target_activation (NautilusIconContainer *container)
+{
+	if (container->details->drop_target_activate_id != 0) {
+		g_source_remove (container->details->drop_target_activate_id);
+		container->details->drop_target_activate_id = 0;
+	}
+}
+
+static gboolean
+drop_target_activate (NautilusIconContainer *container)
+{
+	GList list;
+
+	unschedule_drop_target_activation (container);
+
+	if (container->details->drop_target != NULL) {
+		list.prev = list.next = NULL;
+		list.data = container->details->drop_target->data;
+
+		g_signal_emit_by_name (container, "activate", &list);
+	}
+
+	return FALSE;
+}
+
+static void
+schedule_drop_target_activation (NautilusIconContainer *container)
+{
+	if (container->details->drop_target_activate_id == 0) {
+		container->details->drop_target_activate_id =
+			g_timeout_add (DROP_TARGET_ACTIVATION_TIMEOUT,
+				       (GSourceFunc) drop_target_activate,
+				       container);
+	}
+}
+
+static void
 nautilus_icon_container_get_drop_action (NautilusIconContainer *container,
 					 GdkDragContext *context,
 					 int x, int y,
@@ -1165,6 +1204,12 @@ set_drop_target (NautilusIconContainer *
 	container->details->drop_target = icon;
 	nautilus_icon_container_update_icon (container, old_icon);
 	nautilus_icon_container_update_icon (container, icon);
+
+	unschedule_drop_target_activation (container);
+
+	if (icon != NULL) {
+		schedule_drop_target_activation (container);
+	}
 }
 
 static void

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]