Re: [Rhythmbox-devel] playlist source burner 0.5



> --- lib/rb-tree-dnd.c	5 Apr 2004 14:26:48 -0000	1.7
> +++ lib/rb-tree-dnd.c	2 Sep 2004 21:36:46 -0000
> 
> Is it just me, or does drag and drop to the source list still not work
> even with this patch?

Here is a patch which fixes dnd from the library view and from nautilus
to the source list, this hides the GtkTreeModelFilter in rb-sourcelist-
model instead of explicitly creating it in rb-sourcelist. Since rb-
sourcelist-model implements a specific interface to be able to handle
dnd and since the "displayed" model will be the GtkTreeModelFilter and
not the underlying GtkListStore, I think this change makes sense.
Walters disagreed sometimes ago though, that's why I'm posting it here
to get approval before committing it ;)
This is available from teuf gnome org--2004/rhythmbox--tags-merge--0.9--
patch-6 and teuf gnome org--2004/rhythmbox--tags-merge--0.9--patch-7 for
the arch addicts over here.

Christophe

* added files

    {arch}/rhythmbox/rhythmbox--tags-merge/rhythmbox--tags-merge--0.9/teuf gnome org--2004/patch-log/patch-6
    {arch}/rhythmbox/rhythmbox--tags-merge/rhythmbox--tags-merge--0.9/teuf gnome org--2004/patch-log/patch-7

* modified files

--- orig/sources/rb-sourcelist-model.c
+++ mod/sources/rb-sourcelist-model.c
@@ -108,7 +108,7 @@
 			NULL
 		};
 
-		rb_sourcelist_model_type = g_type_register_static (GTK_TYPE_LIST_STORE, "RBSourceListModel",
+		rb_sourcelist_model_type = g_type_register_static (GTK_TYPE_TREE_MODEL_FILTER, "RBSourceListModel",
 								   &rb_sourcelist_model_info, 0);
 		g_type_add_interface_static (rb_sourcelist_model_type,
 					     RB_TYPE_TREE_DRAG_SOURCE,
@@ -184,10 +184,32 @@
 		(* G_OBJECT_CLASS (parent_class)->finalize) (object);
 }
 
+static gboolean
+rb_sourcelist_is_row_visible (GtkTreeModel *model,
+			      GtkTreeIter *iter,
+			      gpointer data)
+{
+	RBSource *source;
+
+	gtk_tree_model_get (GTK_TREE_MODEL (model), iter,
+			    RB_SOURCELIST_MODEL_COLUMN_SOURCE, &source, -1);
+	
+	if (source != NULL) {
+		gboolean visible;	
+		g_object_get (G_OBJECT (source), "visibility", &visible, NULL);
+
+		return visible;
+	} else {
+		return FALSE;
+	}
+}
+
+
 GtkTreeModel *
 rb_sourcelist_model_new (void)
 {
 	RBSourceListModel *model;
+	GtkListStore *store;
  	GType *column_types = g_new (GType, RB_SOURCELIST_MODEL_N_COLUMNS);
 
 	column_types[RB_SOURCELIST_MODEL_COLUMN_PLAYING] = G_TYPE_BOOLEAN;
@@ -195,11 +217,18 @@
 	column_types[RB_SOURCELIST_MODEL_COLUMN_NAME] = G_TYPE_STRING;
 	column_types[RB_SOURCELIST_MODEL_COLUMN_SOURCE] = G_TYPE_POINTER;
 	column_types[RB_SOURCELIST_MODEL_COLUMN_ATTRIBUTES] = PANGO_TYPE_ATTR_LIST;
+	store = gtk_list_store_newv (RB_SOURCELIST_MODEL_N_COLUMNS, 
+				     column_types);
+
+ 	model = RB_SOURCELIST_MODEL (g_object_new (RB_TYPE_SOURCELIST_MODEL, 
+						   "child-model", store,
+						   "virtual-root", NULL,
+						   NULL));
+
+	gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (model), 
+						rb_sourcelist_is_row_visible, 
+						NULL, NULL);
 
- 	model = RB_SOURCELIST_MODEL (g_object_new (RB_TYPE_SOURCELIST_MODEL, NULL));
- 	gtk_list_store_set_column_types (GTK_LIST_STORE (model),
- 					 RB_SOURCELIST_MODEL_N_COLUMNS,
- 					 column_types);
 	g_free (column_types);
 
 	return GTK_TREE_MODEL (model);


--- orig/sources/rb-sourcelist-model.h
+++ mod/sources/rb-sourcelist-model.h
@@ -40,14 +40,14 @@
 
 typedef struct RBSourceListModel
 {
-	GtkListStore parent;
+	GtkTreeModelFilter parent;
 
 	RBSourceListModelPriv *priv;
 } RBSourceListModel;
 
 typedef struct RBSourceListModelClass
 {
-	GtkListStoreClass parent_class;
+	GtkTreeModelFilterClass parent_class;
 
 	void (*drop_received) (RBSourceListModel *model, RBSource *target, GtkTreeViewDropPosition pos, GtkSelectionData *data);
 


--- orig/sources/rb-sourcelist.c
+++ mod/sources/rb-sourcelist.c
@@ -83,9 +83,6 @@
 static void rb_sourcelist_title_cell_data_func (GtkTreeViewColumn *column, GtkCellRenderer *renderer,
 						GtkTreeModel *tree_model, GtkTreeIter *iter,
 						RBSourceList *sourcelist);
-static gboolean rb_sourcelist_is_row_visible (GtkTreeModel *model,
-					      GtkTreeIter *iter,
-					      gpointer data);
 
 static GtkVBoxClass *parent_class = NULL;
 
@@ -184,15 +181,10 @@
 
 	sourcelist->priv = g_new0 (RBSourceListPriv, 1);
 
-	sourcelist->priv->real_model = rb_sourcelist_model_new ();
-	sourcelist->priv->filter_model = gtk_tree_model_filter_new (sourcelist->priv->real_model,
-								    NULL);
-
-	gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (sourcelist->priv->filter_model),
-						rb_sourcelist_is_row_visible, 
-						NULL, NULL);
+	sourcelist->priv->filter_model = rb_sourcelist_model_new ();
+	sourcelist->priv->real_model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (sourcelist->priv->filter_model));
 
-	g_signal_connect_object (G_OBJECT (sourcelist->priv->real_model),
+	g_signal_connect_object (G_OBJECT (sourcelist->priv->filter_model),
 				 "drop_received",
 				 G_CALLBACK (drop_received_cb),
 				 sourcelist, 0);
@@ -549,28 +541,6 @@
 	gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (sourcelist->priv->filter_model));
 }
 
-
-static gboolean
-rb_sourcelist_is_row_visible (GtkTreeModel *model,
-			      GtkTreeIter *iter,
-			      gpointer data)
-{
-	RBSource *source;
-
-	gtk_tree_model_get (GTK_TREE_MODEL (model), iter,
-			    RB_SOURCELIST_MODEL_COLUMN_SOURCE, &source, -1);
-
-	if (source != NULL) {
-		gboolean visible;
-		g_object_get (G_OBJECT (source), 
-			      "visibility", &visible, 
-			      NULL);
-		return visible;
-	} else {
-		return FALSE;
-	}
-}
-
 static void
 rb_sourcelist_title_cell_data_func (GtkTreeViewColumn *column, GtkCellRenderer *renderer,
 				    GtkTreeModel *tree_model, GtkTreeIter *iter,



Attachment: signature.asc
Description: Ceci est une partie de message =?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=



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