]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtktreednd.c
Fix typos
[~andy/gtk] / gtk / gtktreednd.c
index 8f1cd7b3af8b70a0c33a55221dc05adbd049a9d6..1f5d99d2f42e8342dbe25ce207575fe670283715 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
+#include <config.h>
 #include <string.h>
 #include "gtktreednd.h"
+#include "gtkintl.h"
+#include "gtkalias.h"
 
 GType
 gtk_tree_drag_source_get_type (void)
@@ -40,7 +43,9 @@ gtk_tree_drag_source_get_type (void)
        NULL
       };
 
-      our_type = g_type_register_static (G_TYPE_INTERFACE, "GtkTreeDragSource", &our_info, 0);
+      our_type = g_type_register_static (G_TYPE_INTERFACE, 
+                                        I_("GtkTreeDragSource"),
+                                        &our_info, 0);
     }
   
   return our_type;
@@ -67,12 +72,40 @@ gtk_tree_drag_dest_get_type (void)
        NULL
       };
 
-      our_type = g_type_register_static (G_TYPE_INTERFACE, "GtkTreeDragDest", &our_info, 0);
+      our_type = g_type_register_static (G_TYPE_INTERFACE, I_("GtkTreeDragDest"), &our_info, 0);
     }
   
   return our_type;
 }
 
+/**
+ * gtk_tree_drag_source_row_draggable:
+ * @drag_source: a #GtkTreeDragSource
+ * @path: row on which user is initiating a drag
+ * 
+ * Asks the #GtkTreeDragSource whether a particular row can be used as
+ * the source of a DND operation. If the source doesn't implement
+ * this interface, the row is assumed draggable.
+ *
+ * Return value: %TRUE if the row can be dragged
+ **/
+gboolean
+gtk_tree_drag_source_row_draggable (GtkTreeDragSource *drag_source,
+                                    GtkTreePath       *path)
+{
+  GtkTreeDragSourceIface *iface = GTK_TREE_DRAG_SOURCE_GET_IFACE (drag_source);
+
+  g_return_val_if_fail (path != NULL, FALSE);
+
+  if (iface->row_draggable)
+    return (* iface->row_draggable) (drag_source, path);
+  else
+    return TRUE;
+    /* Returning TRUE if row_draggable is not implemented is a fallback.
+       Interface implementations such as GtkTreeStore and GtkListStore really should
+       implement row_draggable. */
+}
+
 
 /**
  * gtk_tree_drag_source_drag_data_delete:
@@ -157,15 +190,14 @@ gtk_tree_drag_dest_drag_data_received (GtkTreeDragDest  *drag_dest,
 
 
 /**
- * gtk_tree_drag_dest_drop_possible:
+ * gtk_tree_drag_dest_row_drop_possible:
  * @drag_dest: a #GtkTreeDragDest
- * @src_model: #GtkTreeModel being dragged from
- * @src_path: row being dragged
  * @dest_path: destination row
+ * @selection_data: the data being dragged
  * 
  * Determines whether a drop is possible before the given @dest_path,
- * at the same depth as @dest_path. i.e., can we drop @src_model such
- * that it now resides at @dest_path. @dest_path does not have to
+ * at the same depth as @dest_path. i.e., can we drop the data in
+ * @selection_data at that location. @dest_path does not have to
  * exist; the return value will almost certainly be %FALSE if the
  * parent of @dest_path doesn't exist, though.
  * 
@@ -173,18 +205,16 @@ gtk_tree_drag_dest_drag_data_received (GtkTreeDragDest  *drag_dest,
  **/
 gboolean
 gtk_tree_drag_dest_row_drop_possible (GtkTreeDragDest   *drag_dest,
-                                      GtkTreeModel      *src_model,
-                                      GtkTreePath       *src_path,
-                                      GtkTreePath       *dest_path)
+                                      GtkTreePath       *dest_path,
+                                     GtkSelectionData  *selection_data)
 {
   GtkTreeDragDestIface *iface = GTK_TREE_DRAG_DEST_GET_IFACE (drag_dest);
 
   g_return_val_if_fail (iface->row_drop_possible != NULL, FALSE);
-  g_return_val_if_fail (GTK_IS_TREE_MODEL (src_model), FALSE);
-  g_return_val_if_fail (src_path != NULL, FALSE);
+  g_return_val_if_fail (selection_data != NULL, FALSE);
   g_return_val_if_fail (dest_path != NULL, FALSE);
 
-  return (* iface->row_drop_possible) (drag_dest, src_model, src_path, dest_path);
+  return (* iface->row_drop_possible) (drag_dest, dest_path, selection_data);
 }
 
 typedef struct _TreeRowData TreeRowData;
@@ -220,7 +250,7 @@ gtk_tree_set_row_drag_data (GtkSelectionData *selection_data,
   g_return_val_if_fail (GTK_IS_TREE_MODEL (tree_model), FALSE);
   g_return_val_if_fail (path != NULL, FALSE);
 
-  if (selection_data->target != gdk_atom_intern ("GTK_TREE_MODEL_ROW", FALSE))
+  if (selection_data->target != gdk_atom_intern_static_string ("GTK_TREE_MODEL_ROW"))
     return FALSE;
   
   path_str = gtk_tree_path_to_string (path);
@@ -234,11 +264,13 @@ gtk_tree_set_row_drag_data (GtkSelectionData *selection_data,
   trd = g_malloc (struct_size); 
 
   strcpy (trd->path, path_str);
+
+  g_free (path_str);
   
   trd->model = tree_model;
   
   gtk_selection_data_set (selection_data,
-                          gdk_atom_intern ("GTK_TREE_MODEL_ROW", FALSE),
+                          gdk_atom_intern_static_string ("GTK_TREE_MODEL_ROW"),
                           8, /* bytes */
                           (void*)trd,
                           struct_size);
@@ -282,7 +314,10 @@ gtk_tree_get_row_drag_data (GtkSelectionData  *selection_data,
   if (path)
     *path = NULL;
   
-  if (selection_data->target != gdk_atom_intern ("GTK_TREE_MODEL_ROW", FALSE))
+  if (selection_data->target != gdk_atom_intern_static_string ("GTK_TREE_MODEL_ROW"))
+    return FALSE;
+
+  if (selection_data->length < 0)
     return FALSE;
 
   trd = (void*) selection_data->data;
@@ -295,3 +330,6 @@ gtk_tree_get_row_drag_data (GtkSelectionData  *selection_data,
   
   return TRUE;
 }
+
+#define __GTK_TREE_DND_C__
+#include "gtkaliasdef.c"