/*# @method is_ancestor GtkTreePath @brief Returns TRUE if descendant is a descendant of path. @param descendant another GtkTreePath @return TRUE if descendant is contained inside path */ FALCON_FUNC TreePath::is_ancestor( VMARG ) { Item* i_desc = vm->param( 0 ); #ifndef NO_PARAMETER_CHECK if ( !i_desc || !i_desc->isObject() || !IS_DERIVED( i_desc, GtkTreePath ) ) throw_inv_params( "GtkTreePath" ); #endif GtkTreePath* desc = GET_TREEPATH( *i_desc ); MYSELF; vm->retval( (bool) gtk_tree_path_is_ancestor( self->getTreePath(), desc ) ); }
static gboolean bookmark_tree_store_row_drop_possible (GtkTreeDragDest *drag_dest, GtkTreePath *dest_path, GtkSelectionData *selection_data) { GtkTreeModel *src_model = NULL; GtkTreePath *src_path = NULL; GtkTreePath *tmp = NULL; gboolean retval = FALSE; GtkTreeIter iter; GNode *src_node, *dst_node; gftp2_bookmark *src_bm, *dst_bm; if (!gtk_tree_get_row_drag_data (selection_data, &src_model, &src_path)) goto out; /* fprintf (stderr, "%s -to- %s", gtk_tree_path_to_string (src_path), gtk_tree_path_to_string (dest_path)); */ /* can only drag to ourselves */ if (src_model != GTK_TREE_MODEL (drag_dest)) goto out; /* Can't drop into ourself. */ if (gtk_tree_path_is_ancestor (src_path, dest_path)) goto out; /* Can't drop if dest_path's parent doesn't exist */ if (gtk_tree_path_get_depth (dest_path) > 1) { tmp = gtk_tree_path_copy (dest_path); gtk_tree_path_up (tmp); if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (drag_dest), &iter, tmp)) goto out; gtk_tree_model_get (src_model, &iter, /* src_model == dst_model */ COLUMN_ENTRY, &dst_node, -1); g_assert (dst_node); dst_bm = (gftp2_bookmark *)dst_node->data; /* can't drag an item into a non-folder */ if (!dst_bm->is_folder) goto out; gtk_tree_model_get_iter (src_model, &iter, src_path); gtk_tree_model_get (src_model, &iter, COLUMN_ENTRY, &src_node, -1); g_assert (src_node); src_bm = (gftp2_bookmark *)src_node->data; /* can't drag folder into a folder */ if (src_bm->is_folder) goto out; } /* Can otherwise drop anywhere. */ retval = TRUE; out: /* fprintf (stderr, " %s\n", retval ? "Can drop" : "Can't drop"); */ if (src_path) gtk_tree_path_free (src_path); if (tmp) gtk_tree_path_free (tmp); return retval; }
static VALUE rg_ancestor_p(VALUE self, VALUE descendant) { return CBOOL2RVAL(gtk_tree_path_is_ancestor(_SELF(self), _SELF(descendant))); }