[gtk+/places-sidebar: 534/539] Add a DropState enum to the internal state of the sidebar



commit 7d52dff5ec1ed69cd98715d71c92dff2ef6bdc41
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Apr 19 11:00:36 2013 -0500

    Add a DropState enum to the internal state of the sidebar
    
    We want to show a little animation when a DnD operation is happening and the user hovers
    between existing bookmarks.  The animation should indicate the user that he's about to
    create a new bookmark from the file right there.
    
    Signed-off-by: Federico Mena Quintero <federico gnome org>

 gtk/gtkplacessidebar.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
---
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index 98cd47f..f66b7c0 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -108,6 +108,26 @@
 
 #define DO_NOT_COMPILE 0
 
+/* These are used when a destination-side DnD operation is taking place.
+ * Normally, when a file is being hovered directly over a bookmark,
+ * we'll be in DROP_STATE_NORMAL.
+ *
+ * But when a file is being hovered between bookmarks, this means the user
+ * may want to create a new bookmark for that file between those bookmarks.
+ * In that case, the drop state will be *not* DROP_STATE_NORMAL.
+ *
+ * When the drop state is FADING_OUT, it means that the user is hovering
+ * directly over an existing bookmark and an immediate drop will cause the
+ * file being dragged to be dropped on the bookmark, instead of causing
+ * a new bookmark to be created.
+ */
+typedef enum {
+       DROP_STATE_NORMAL,
+       DROP_STATE_NEW_BOOKMARK_FADING_IN,
+       DROP_STATE_NEW_BOOKMARK_ARMED,
+       DROP_STATE_NEW_BOOKMARK_FADING_OUT
+} DropState;
+
 struct _GtkPlacesSidebar {
        GtkScrolledWindow parent;
 
@@ -143,6 +163,9 @@ struct _GtkPlacesSidebar {
 
        GtkPlacesOpenFlags open_flags;
 
+       DropState drop_state;
+       int new_bookmark_index;
+
        guint show_desktop : 1;
 };
 
@@ -3588,6 +3611,9 @@ gtk_places_sidebar_init (GtkPlacesSidebar *sidebar)
                                  sidebar->hostnamed_cancellable,
                                  hostname_proxy_new_cb,
                                  g_object_ref (sidebar));
+
+       sidebar->drop_state = DROP_STATE_NORMAL;
+       sidebar->new_bookmark_index = -1;
 }
 
 static void


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