[gtk+/wip/csoriano/bookmarks] f
- From: Carlos Soriano Sánchez <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/csoriano/bookmarks] f
- Date: Fri, 29 May 2015 15:45:37 +0000 (UTC)
commit 9a04582cf99fd7f45052c6ccb2dddf61c61b68f9
Author: Carlos Soriano <csoriano gnome org>
Date: Fri May 29 17:45:18 2015 +0200
f
gtk/gtkplacessidebar.c | 98 +++++++++++++++++------------------------------
1 files changed, 36 insertions(+), 62 deletions(-)
---
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index 9cb4f32..674bc37 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -1800,77 +1800,24 @@ update_places (GtkPlacesSidebar *sidebar)
}
}
-static void
-update_possible_drop_targets (GtkPlacesSidebar *sidebar,
- gboolean dragging)
-{
- GList *rows;
- GList *l;
- PlaceType place_type;
- gchar *uri;
- gboolean sensitive;
-
- rows = gtk_container_get_children (GTK_CONTAINER (sidebar->list_box));
-
- for (l = rows; l != NULL; l = l->next)
- {
- sensitive = TRUE;
- g_object_get (SIDEBAR_ROW (l->data), "place-type", &place_type, "uri", &uri, NULL);
-
- if (dragging)
- {
- if (sidebar->drag_data_info == DND_TEXT_URI_LIST ||
- sidebar->drop_state == DROP_STATE_NEW_BOOKMARK_ARMED_PERMANENT)
- {
- switch (place_type)
- {
- case PLACES_CONNECT_TO_SERVER:
- sensitive = FALSE;
- break;
- case PLACES_BUILT_IN:
- if (g_strcmp0 (uri, "recent:///") == 0)
- sensitive = FALSE;
-
- break;
- default:
- break;
- }
- }
- else
- {
- sensitive = place_type == PLACES_BOOKMARK;
- }
- }
-
- g_object_set (SIDEBAR_ROW (l->data), "sensitive", sensitive, NULL);
- }
-
- g_list_free (rows);
-}
-
static gboolean
check_valid_drop_target (GtkPlacesSidebar *sidebar,
- gint y)
+ SidebarRow *row)
{
- GtkListBoxRow *row;
PlaceType place_type;
SectionType section_type;
gboolean valid = FALSE;
- row = gtk_list_box_get_row_at_y (GTK_LIST_BOX (sidebar->list_box), y);
if (row == NULL)
- return valid;
+ return FALSE;
g_object_get (row,
"place-type", &place_type,
"section_type", §ion_type,
NULL);
- if (place_type == PLACES_DROP_FEEDBACK)
- {
- valid = TRUE;
- goto out;
- }
+ if (place_type == PLACES_CONNECT_TO_SERVER)
+ return FALSE;
/* Dragging a bookmark? */
if (sidebar->drag_data_received &&
@@ -1882,7 +1829,7 @@ check_valid_drop_target (GtkPlacesSidebar *sidebar,
else
{
/* Dragging a file */
- valid = TRUE;
+ valid = TRUE;
}
/* Disallow drops on recent:/// */
@@ -1896,10 +1843,37 @@ check_valid_drop_target (GtkPlacesSidebar *sidebar,
valid = FALSE;
}
-out:
return valid;
}
+static void
+update_possible_drop_targets (GtkPlacesSidebar *sidebar,
+ gboolean dragging)
+{
+ GList *rows;
+ GList *l;
+ PlaceType place_type;
+ gchar *uri;
+ gboolean sensitive;
+
+ rows = gtk_container_get_children (GTK_CONTAINER (sidebar->list_box));
+
+ for (l = rows; l != NULL; l = l->next)
+ {
+ sensitive = TRUE;
+ g_object_get (SIDEBAR_ROW (l->data), "place-type", &place_type, "uri", &uri, NULL);
+
+ if (dragging)
+ {
+ sensitive = check_valid_drop_target (sidebar, SIDEBAR_ROW (l->data));
+ }
+
+ g_object_set (SIDEBAR_ROW (l->data), "sensitive", sensitive, NULL);
+ }
+
+ g_list_free (rows);
+}
+
static gboolean
get_drag_data (GtkWidget *list_box,
GdkDragContext *context,
@@ -1945,7 +1919,7 @@ start_drop_feedback (GtkPlacesSidebar *sidebar,
sidebar->drop_state = DROP_STATE_NEW_BOOKMARK_ARMED;
}
- if (row != NULL)
+ if (check_valid_drop_target (sidebar, row))
gtk_list_box_drag_highlight_row (GTK_LIST_BOX (sidebar->list_box), GTK_LIST_BOX_ROW (row));
update_possible_drop_targets (sidebar, TRUE);
@@ -2095,7 +2069,7 @@ drag_motion_callback (GtkWidget *widget,
}
}
- valid_drop_target = check_valid_drop_target (sidebar, y);
+ valid_drop_target = check_valid_drop_target (sidebar, SIDEBAR_ROW (row));
if (!valid_drop_target)
{
g_print ("drop position invalid\n");
@@ -2360,7 +2334,7 @@ drag_data_received_callback (GtkWidget *list_box,
success = FALSE;
- valid_drop_target = check_valid_drop_target (sidebar, y);
+ valid_drop_target = check_valid_drop_target (sidebar, SIDEBAR_ROW (target_row));
if (!valid_drop_target)
goto out;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]