[nautilus] Switch views when hovering over pathbar



commit 87bb40d7fa04a56c3ae515dd5340a9656c497a48
Author: William Jon McCann <jmccann redhat com>
Date:   Sat Jan 19 12:42:55 2013 -0500

    Switch views when hovering over pathbar
    
    https://bugzilla.gnome.org/show_bug.cgi?id=692097

 src/nautilus-window-slot-dnd.c |   75 +++++++++++++++++++++++++++++-----------
 1 files changed, 55 insertions(+), 20 deletions(-)
---
diff --git a/src/nautilus-window-slot-dnd.c b/src/nautilus-window-slot-dnd.c
index 27b9380..b9e6df8 100644
--- a/src/nautilus-window-slot-dnd.c
+++ b/src/nautilus-window-slot-dnd.c
@@ -45,19 +45,21 @@ typedef struct {
 
   NautilusFile *target_file;
   NautilusWindowSlot *target_slot;
+  GtkWidget *widget;
 
   gboolean is_notebook;
-  guint switch_tab_timer;
+  guint switch_location_timer;
 } NautilusDragSlotProxyInfo;
 
-static gboolean
-slot_proxy_switch_tab_timer (gpointer user_data)
+static void
+switch_tab (NautilusDragSlotProxyInfo *drag_info)
 {
-  NautilusDragSlotProxyInfo *drag_info = user_data;
   GtkWidget *notebook, *slot;
   gint idx, n_pages;
 
-  drag_info->switch_tab_timer = 0;
+  if (drag_info->target_slot == NULL) {
+    return;
+  }
 
   notebook = gtk_widget_get_ancestor (GTK_WIDGET (drag_info->target_slot), NAUTILUS_TYPE_NOTEBOOK);
   n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook));
@@ -71,39 +73,70 @@ slot_proxy_switch_tab_timer (gpointer user_data)
           break;
         }
     }
+}
+
+static void
+switch_location (NautilusDragSlotProxyInfo *drag_info)
+{
+  GFile *location;
+  NautilusWindowSlot *target_slot;
+  GtkWidget *window;
+
+  if (drag_info->target_file == NULL) {
+    return;
+  }
+
+  window = gtk_widget_get_toplevel (drag_info->widget);
+  g_assert (NAUTILUS_IS_WINDOW (window));
+
+  target_slot = nautilus_window_get_active_slot (NAUTILUS_WINDOW (window));
+
+  location = nautilus_file_get_location (drag_info->target_file);
+  nautilus_window_slot_open_location (target_slot, location, 0);
+  g_object_unref (location);
+}
+
+static gboolean
+slot_proxy_switch_location_timer (gpointer user_data)
+{
+  NautilusDragSlotProxyInfo *drag_info = user_data;
+
+  drag_info->switch_location_timer = 0;
+
+  if (drag_info->is_notebook)
+    switch_tab (drag_info);
+  else
+    switch_location (drag_info);
 
   return FALSE;
 }
 
 static void
-slot_proxy_check_switch_tab_timer (NautilusDragSlotProxyInfo *drag_info,
-                                   GtkWidget *widget)
+slot_proxy_check_switch_location_timer (NautilusDragSlotProxyInfo *drag_info,
+                                        GtkWidget *widget)
 {
   GtkSettings *settings;
   guint timeout;
 
-  if (!drag_info->is_notebook)
-    return;
-
-  if (drag_info->switch_tab_timer)
+  if (drag_info->switch_location_timer)
     return;
 
   settings = gtk_widget_get_settings (widget);
   g_object_get (settings, "gtk-timeout-expand", &timeout, NULL);
 
-  drag_info->switch_tab_timer =
+  drag_info->switch_location_timer =
     gdk_threads_add_timeout (timeout,
-                             slot_proxy_switch_tab_timer,
+                             slot_proxy_switch_location_timer,
                              drag_info);
 }
 
 static void
-slot_proxy_remove_switch_tab_timer (NautilusDragSlotProxyInfo *drag_info)
+slot_proxy_remove_switch_location_timer (NautilusDragSlotProxyInfo *drag_info)
 {
-  if (drag_info->switch_tab_timer != 0)
+  if (drag_info->switch_location_timer != 0)
     {
-      g_source_remove (drag_info->switch_tab_timer);
-      drag_info->switch_tab_timer = 0;
+      g_source_remove (drag_info->switch_location_timer);
+      drag_info->switch_location_timer = 0;
     }
 }
 
@@ -188,10 +221,10 @@ slot_proxy_drag_motion (GtkWidget          *widget,
  out:
   if (action != 0) {
     gtk_drag_highlight (widget);
-    slot_proxy_check_switch_tab_timer (drag_info, widget);
+    slot_proxy_check_switch_location_timer (drag_info, widget);
   } else {
     gtk_drag_unhighlight (widget);
-    slot_proxy_remove_switch_tab_timer (drag_info);
+    slot_proxy_remove_switch_location_timer (drag_info);
   }
 
   gdk_drag_status (context, action, time);
@@ -213,7 +246,7 @@ drag_info_free (gpointer user_data)
 static void
 drag_info_clear (NautilusDragSlotProxyInfo *drag_info)
 {
-  slot_proxy_remove_switch_tab_timer (drag_info);
+  slot_proxy_remove_switch_location_timer (drag_info);
 
   if (!drag_info->have_data) {
     goto out;
@@ -419,6 +452,8 @@ nautilus_drag_slot_proxy_init (GtkWidget *widget,
   if (target_slot != NULL)
     drag_info->target_slot = g_object_ref (target_slot);
 
+  drag_info->widget = widget;
+
   gtk_drag_dest_set (widget, 0,
                      NULL, 0,
                      GDK_ACTION_MOVE |



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