[gtk+/wip/csoriano/bookmarks: 14/14] gtkplacessidebar: make insensitive invalid drop targets
- From: Carlos Soriano Sánchez <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/csoriano/bookmarks: 14/14] gtkplacessidebar: make insensitive invalid drop targets
- Date: Mon, 13 Apr 2015 17:45:26 +0000 (UTC)
commit 13ec09925bb4cd78ba62efb47d50e980b10c97ad
Author: Carlos Soriano <csoriano gnome org>
Date: Mon Apr 13 01:24:10 2015 +0200
gtkplacessidebar: make insensitive invalid drop targets
gtk/gtkplacessidebar.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 89 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index 9fbfb5f..3b3e537 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -1440,6 +1440,74 @@ pos_is_into_or_before (GtkTreeViewDropPosition pos)
return (pos == GTK_TREE_VIEW_DROP_BEFORE || pos == GTK_TREE_VIEW_DROP_INTO_OR_BEFORE);
}
+static void
+dim_label (GtkPlacesSidebar *sidebar,
+ gint pos)
+{
+ g_print ("dim label %d\n", pos);
+}
+
+static void
+dedim_label (GtkPlacesSidebar *sidebar,
+ gint pos)
+{
+ g_print ("dim label %d\n", pos);
+}
+
+static void
+update_possible_drop_targets (GtkPlacesSidebar *sidebar)
+{
+ GtkTreeIter iter;
+ PlaceType place_type;
+ gchar *uri;
+ gboolean dim;
+ gint index;
+
+ if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (sidebar->store), &iter))
+ return;
+
+ index = 0;
+ do
+ {
+ gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter,
+ PLACES_SIDEBAR_COLUMN_ROW_TYPE, &place_type,
+ PLACES_SIDEBAR_COLUMN_URI, &uri,
+ -1);
+ if (sidebar->dragging_over)
+ {
+ switch (place_type)
+ {
+ case PLACES_CONNECT_TO_SERVER:
+ dim = TRUE;
+ break;
+ case PLACES_BUILT_IN:
+
+ if (g_strcmp0 (uri, "recent:///") == 0)
+ dim = TRUE;
+ else
+ dim = FALSE;
+
+ g_free (uri);
+ break;
+ default:
+ dim = FALSE;
+ break;
+ }
+ }
+ else
+ {
+ dim = FALSE;
+ }
+ if (dim)
+ dim_label (sidebar, index);
+ else
+ dedim_label (sidebar, index);
+
+ index++;
+ }
+ while (gtk_tree_model_iter_next (GTK_TREE_MODEL (sidebar->store), &iter));
+}
+
/* Computes the appropriate row and position for dropping */
static gboolean
compute_drop_position (GtkTreeView *tree_view,
@@ -3848,6 +3916,23 @@ icon_cell_renderer_func (GtkTreeViewColumn *column,
g_object_set (cell, "visible", type != PLACES_HEADING, NULL);
}
+static void
+icon_cell_renderer_text_func (GtkTreeViewColumn *column,
+ GtkCellRenderer *cell,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer user_data)
+{
+ PlaceType type;
+
+ gtk_tree_model_get (model, iter,
+ PLACES_SIDEBAR_COLUMN_ROW_TYPE, &type,
+ -1);
+
+ g_print ("sensitive false %d\n", gtk_cell_renderer_get_sensitive (cell));
+ g_object_set (cell, "sensitive", FALSE, NULL);
+}
+
static gint
places_sidebar_sort_func (GtkTreeModel *model,
GtkTreeIter *iter_a,
@@ -4144,11 +4229,15 @@ gtk_places_sidebar_init (GtkPlacesSidebar *sidebar)
"text", PLACES_SIDEBAR_COLUMN_NAME,
"visible", PLACES_SIDEBAR_COLUMN_NO_EJECT,
"editable-set", PLACES_SIDEBAR_COLUMN_BOOKMARK,
+ "sensitive", FALSE,
NULL);
g_object_set (cell,
"ellipsize", PANGO_ELLIPSIZE_END,
"ellipsize-set", TRUE,
NULL);
+ gtk_tree_view_column_set_cell_data_func (col, cell,
+ icon_cell_renderer_text_func,
+ sidebar, NULL);
g_signal_connect (cell, "edited",
G_CALLBACK (bookmarks_edited), sidebar);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]