[Rhythmbox-devel] use of modelfilter around sourcelist-model breaks drag and drop
- From: Bastiaan Van Eeckhoudt <bastiaanve gmail com>
- To: rhythmbox-devel gnome org
- Subject: [Rhythmbox-devel] use of modelfilter around sourcelist-model breaks drag and drop
- Date: Thu, 15 Jul 2004 21:00:42 +0200
[I sent this to the list yesterday evening, but it seems it never arrived...]
Hi,
the use of the modelfilter around the sourcelist-model breaks drag and
drop to the source list.
The GtkTreeView gets passed to the rb-tree-dnd code. That grabs the
model and tries to get the RB_TYPE_TREE_DRAG_DEST interface. It then
fails, since it's using the modelfilter, which doesn't implement this
interface.
I made a quick hack (see patch), which checks if the model of the
treeview is actually a modelfilter, and then gets the real model.
This makes DnD work again, but I'm not familiar enough with GTK to
know if this will work if there's a filtered source. Maybe the drop
will land on the wrong item?
The patch also removes some lines of unused code.
This is all based on rhythmbox--main--0.9--patch-90 by the way.
Bastiaan
--- orig/lib/rb-tree-dnd.c
+++ mod/lib/rb-tree-dnd.c
@@ -23,6 +23,7 @@
#include <gtk/gtkwidget.h>
#include <gtk/gtkmain.h>
#include <gtk/gtktreednd.h>
+#include <gtk/gtktreemodelfilter.h>
#include "rb-tree-dnd.h"
#include "rb-debug.h"
@@ -368,6 +369,10 @@
else if (*pos == GTK_TREE_VIEW_DROP_AFTER)
*pos = GTK_TREE_VIEW_DROP_INTO_OR_AFTER;
}
+
+ if (GTK_IS_TREE_MODEL_FILTER (model)) {
+ model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
+ }
ret = rb_tree_drag_dest_row_drop_position (RB_TREE_DRAG_DEST (model),
path,
@@ -455,6 +460,10 @@
GList *path_list;
GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW(widget));
+ if (GTK_IS_TREE_MODEL_FILTER (model)) {
+ model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
+ }
+
path_list = get_context_data (drag_context);
rb_tree_drag_source_drag_data_delete (RB_TREE_DRAG_SOURCE (model),
path_list);
@@ -478,6 +487,10 @@
tree_view = GTK_TREE_VIEW (widget);
model = gtk_tree_view_get_model (tree_view);
+ if (GTK_IS_TREE_MODEL_FILTER (model)) {
+ model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
+ }
+
if (model == NULL)
return;
@@ -525,6 +538,10 @@
path_list = g_list_reverse (path_list);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
+ if (GTK_IS_TREE_MODEL_FILTER (model)) {
+ model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
+ }
+
if (rb_tree_drag_source_row_draggable (RB_TREE_DRAG_SOURCE (model), path_list))
{
rb_debug ("drag begin");
@@ -553,7 +570,6 @@
{
GtkTreeView *tree_view;
GtkTreePath *path = NULL;
- GtkTreeModel *model;
GtkTreeViewDropPosition pos;
RbTreeDndData *priv_data;
GdkDragAction action;
@@ -561,7 +577,6 @@
rb_debug ("drag and drop motion: (%i,%i)", x, y);
tree_view = GTK_TREE_VIEW (widget);
- model = gtk_tree_view_get_model (tree_view);
priv_data = g_object_get_data (G_OBJECT (widget), RB_TREE_DND_STRING);
@@ -603,7 +618,7 @@
action = context->suggested_action;
if (path) {
- gtk_tree_view_set_drag_dest_row (tree_view, path, pos);
+ gtk_tree_view_set_drag_dest_row (tree_view, path, pos);
gtk_tree_path_free (path);
}
@@ -622,12 +637,10 @@
{
GtkTreeView *tree_view;
GtkTreePath *path;
- GtkTreeModel *model;
GtkTreeViewDropPosition pos;
RbTreeDndData *priv_data;
tree_view = GTK_TREE_VIEW (widget);
- model = gtk_tree_view_get_model (tree_view);
priv_data = g_object_get_data (G_OBJECT (widget), RB_TREE_DND_STRING);
gtk_tree_view_get_dest_row_at_pos (tree_view, x, y, &path, &pos);
@@ -672,6 +685,9 @@
tree_view = GTK_TREE_VIEW (widget);
model = gtk_tree_view_get_model (tree_view);
+ if (GTK_IS_TREE_MODEL_FILTER (model)) {
+ model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
+ }
gtk_tree_view_get_dest_row_at_pos (tree_view, x, y, &dest_row, &pos);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]