On Thu, 2006-08-24 at 10:06 -0700, Dafydd Harries wrote:
> Source-Version: 0.15.0-1
> We believe that the bug you reported is fixed in the latest version of
> ruby-gnome2, which is due to be installed in the Debian FTP archive:
[snip]
>    * Add patch from Philipp Kern to enable tree view drag+drop. Closes: 
> #383309.

Uh. Thank you very much Dafydd. There's just a tiny problem. There is
another part of the patch which I added after some conversation with
ruby-gnome2's maintainer. It does alter the last one in a slight way:

The signature of row-drop-possible was previously like that:
  * dest_path: Gtk::TreePath of the destination
  * selection_data: The Gtk::SelectionData containing the information
    about the row dropped to that destination.

ruby-gnome2 does not expose the function necessary to read the data out
of the selection, so I adapted the patch to pass the source model and
path instead. Like this one could retrieve the data just fine. (Given
that the drag started in the current application, otherwise the pointer
fails. In this case nil is passed as both parameters.

It would be nice if this patch, which I attached, would also be added to
the package, it's a blocker to upload mine.

Should I reopen #383309, leave it closed or submit a new wishlist bug?

Kind regards,
Philipp Kern
diff -Naur ruby-gnome2-all-0.14.1/gtk/src/rbgtktreedrag.c ruby-gnome2-0.14.1-new/gtk/src/rbgtktreedrag.c
--- ruby-gnome2-all-0.14.1/gtk/src/rbgtktreedrag.c	2006-08-16 18:48:48.000000000 +0200
+++ ruby-gnome2-0.14.1-new/gtk/src/rbgtktreedrag.c	2006-08-16 18:47:45.000000000 +0200
@@ -54,24 +54,25 @@
 }
 
 static void
-_rb_marshal_BOOLEAN__BOXED_BOXED(GClosure     *closure,
-                                 GValue       *return_value,
-                                 guint         n_param_values,
-                                 const GValue *param_values,
-                                 gpointer      invocation_hint,
-                                 gpointer      marshal_data)
-{
-  typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_BOXED) (gpointer     data1,
-                                                         gpointer     arg_1,
-                                                         gpointer     arg_2,
-                                                         gpointer     data2);
-  register GMarshalFunc_BOOLEAN__BOXED_BOXED callback;
+_rb_marshal_BOOLEAN__BOXED_OBJECT_BOXED(GClosure     *closure,
+                                        GValue       *return_value,
+                                        guint         n_param_values,
+                                        const GValue *param_values,
+                                        gpointer      invocation_hint,
+                                        gpointer      marshal_data)
+{
+  typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_OBJECT_BOXED) (gpointer     data1,
+                                                                gpointer     arg_1,
+                                                                gpointer     arg_2,
+                                                                gpointer     arg_3,
+                                                                gpointer     data2);
+  register GMarshalFunc_BOOLEAN__BOXED_OBJECT_BOXED callback;
   register GCClosure *cc = (GCClosure*) closure;
   register gpointer data1, data2;
   gboolean v_return;
 
   g_return_if_fail (return_value != NULL);
-  g_return_if_fail (n_param_values == 3);
+  g_return_if_fail (n_param_values == 4);
 
   if (G_CCLOSURE_SWAP_DATA (closure))
     {
@@ -83,11 +84,12 @@
       data1 = g_value_peek_pointer (param_values + 0);
       data2 = closure->data;
     }
-  callback = (GMarshalFunc_BOOLEAN__BOXED_BOXED) (marshal_data ? marshal_data : cc->callback);
+  callback = (GMarshalFunc_BOOLEAN__BOXED_OBJECT_BOXED) (marshal_data ? marshal_data : cc->callback);
 
   v_return = callback (data1,
                        g_marshal_value_peek_boxed (param_values + 1),
-                       g_marshal_value_peek_boxed (param_values + 2),
+                       g_marshal_value_peek_object (param_values + 2),
+                       g_marshal_value_peek_boxed (param_values + 3),
                        data2);
 
   g_value_set_boolean (return_value, v_return);
@@ -110,10 +112,11 @@
                  G_SIGNAL_RUN_LAST,
                  0,
                  NULL, NULL,
-                 _rb_marshal_BOOLEAN__BOXED_BOXED,
-                 G_TYPE_BOOLEAN, 2,
+                 _rb_marshal_BOOLEAN__BOXED_OBJECT_BOXED,
+                 G_TYPE_BOOLEAN, 3,
                  GTK_TYPE_TREE_PATH,
-                 GTK_TYPE_SELECTION_DATA);
+                 GTK_TYPE_TREE_MODEL,
+                 GTK_TYPE_TREE_PATH);
 }
 
 static gboolean
@@ -146,11 +149,20 @@
 
   guint signal_id = g_signal_lookup("row-drop-possible", G_TYPE_FROM_INSTANCE(drag_dest));
 
+  GtkTreeModel* source_model = NULL;
+  GtkTreePath* source_path = NULL;
+  /* The selection_data must be of type GTK_TREE_MODEL_ROW, otherwise
+     the get function returns false and the out values are hopefully left
+     as-is. */
+  gtk_tree_get_row_drag_data(selection_data, &source_model, &source_path);
+
   if(g_signal_has_handler_pending(drag_dest, signal_id, 0, FALSE))
-    g_signal_emit(drag_dest, signal_id, 0, dest_path, selection_data, &retval);
+    g_signal_emit(drag_dest, signal_id, 0, dest_path, source_model, source_path, &retval);
   else
     retval = TRUE; /* default value */
 
+  if(source_path)
+    gtk_tree_path_free(source_path);
   return retval;
 }
 

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to