/**
* Specialization of GtkTreeView for the XML tree view
*
* Authors:
* MenTaLguY <mental@rydia.net>
*
* Copyright (C) 2002 MenTaLguY
*
* Released under the GNU GPL; see COPYING for details
*/
#include <cstring>
#include <string>
#include "xml/node-event-vector.h"
#include "sp-xmlview-tree.h"
struct NodeData {
};
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
static NodeData * node_data_new (SPXMLViewTree * tree, GtkTreeIter * node, GtkTreeRowReference *rowref, Inkscape::XML::Node * repr);
static GtkTreeRowReference * add_node (SPXMLViewTree * tree, GtkTreeIter * parent, GtkTreeIter * before, Inkscape::XML::Node * repr);
static void element_child_added (Inkscape::XML::Node * repr, Inkscape::XML::Node * child, Inkscape::XML::Node * ref, gpointer data);
static void element_attr_changed (Inkscape::XML::Node * repr, const gchar * key, const gchar * old_value, const gchar * new_value, bool is_interactive, gpointer data);
static void element_child_removed (Inkscape::XML::Node * repr, Inkscape::XML::Node * child, Inkscape::XML::Node * ref, gpointer data);
static void element_order_changed (Inkscape::XML::Node * repr, Inkscape::XML::Node * child, Inkscape::XML::Node * oldref, Inkscape::XML::Node * newref, gpointer data);
static void text_content_changed (Inkscape::XML::Node * repr, const gchar * old_content, const gchar * new_content, gpointer data);
static void comment_content_changed (Inkscape::XML::Node * repr, const gchar * old_content, const gchar * new_content, gpointer data);
static void pi_content_changed (Inkscape::XML::Node * repr, const gchar * old_content, const gchar * new_content, gpointer data);
static gboolean tree_model_iter_compare(GtkTreeModel* store, GtkTreeIter * iter1, GtkTreeIter * iter2);
static gboolean tree_ref_to_iter (SPXMLViewTree * tree, GtkTreeIter* iter, GtkTreeRowReference *ref);
gboolean search_equal_func (GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer search_data);
gboolean foreach_func (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data);
void on_row_changed(GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data);
void on_drag_data_received(GtkWidget *wgt, GdkDragContext *context, int x, int y, GtkSelectionData *seldata, guint info, guint time, gpointer userdata);
gboolean do_drag_motion(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer user_data);
NULL, /* content_changed */
};
NULL, /* child_added */
NULL, /* child_removed */
NULL, /* attr_changed */
NULL /* order_changed */
};
NULL, /* child_added */
NULL, /* child_removed */
NULL, /* attr_changed */
NULL /* order_changed */
};
NULL, /* child_added */
NULL, /* child_removed */
NULL, /* attr_changed */
NULL /* order_changed */
};
{
// Detach the model from the view until all the data is loaded
GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes ("", renderer, "text", STORE_TEXT_COL, NULL);
g_signal_connect(GTK_TREE_VIEW(tree), "drag_data_received", G_CALLBACK(on_drag_data_received), tree);
return GTK_WIDGET(tree);
}
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
// Signal for when a tree drag and drop has completed
g_signal_new ( "tree_move",
0,
G_TYPE_NONE, 1,
}
void
{
}
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
}
/*
* Add a new row to the tree
*/
add_node (SPXMLViewTree * tree, GtkTreeIter *parent, GtkTreeIter *before, Inkscape::XML::Node * repr)
{
}
return NULL;
}
gtk_tree_store_set (tree->store, &iter, STORE_TEXT_COL, default_text, STORE_DATA_COL, data, STORE_REPR_COL, repr, -1);
vec = &text_repr_events;
vec = &pi_repr_events;
} else {
}
if (vec) {
/* cheat a little to get the id updated properly */
}
}
return rowref;
}
NodeData *node_data_new(SPXMLViewTree * tree, GtkTreeIter * /*node*/, GtkTreeRowReference *rowref, Inkscape::XML::Node *repr)
{
return data;
}
void element_child_added (Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node * child, Inkscape::XML::Node * ref, gpointer ptr)
{
return;
}
}
void element_attr_changed(Inkscape::XML::Node * repr, const gchar * key, const gchar * /*old_value*/, const gchar * new_value, bool /*is_interactive*/, gpointer ptr)
{
return;
} else if (new_value) {
} else {
}
}
}
void element_child_removed(Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node * child, Inkscape::XML::Node * /*ref*/, gpointer ptr)
{
}
}
void element_order_changed(Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node * child, Inkscape::XML::Node * /*oldref*/, Inkscape::XML::Node * newref, gpointer ptr)
{
} else {
}
}
void text_content_changed(Inkscape::XML::Node * /*repr*/, const gchar * /*old_content*/, const gchar * new_content, gpointer ptr)
{
}
}
void comment_content_changed(Inkscape::XML::Node * /*repr*/, const gchar * /*old_content*/, const gchar *new_content, gpointer ptr)
{
}
}
void pi_content_changed(Inkscape::XML::Node *repr, const gchar * /*old_content*/, const gchar *new_content, gpointer ptr)
{
}
}
/*
* Save the source path on drag start, will need it in on_row_changed() when moving a row
*/
{
if (!tree) {
return;
}
return;
}
}
}
}
/*
* Main drag & drop function
* Get the old and new paths, and change the Inkscape::XML::Node repr's
*/
void on_row_changed(GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data)
{
return;
}
//No parent of drop location
return;
}
GtkTreeRowReference *old_parent_ref = static_cast<GtkTreeRowReference *>(g_object_get_data (G_OBJECT (tree), "drag-src-path"));
if (!old_parent_ref) {
//No drag source location
return;
}
//Drag source parent is not valid
return;
}
// Find the sibling node before iter
}
// If before_iter is invalid, before_repr stays as NULL which is ok
}
// Drop onto oneself causes assert in changeOrder() below, ignore
if (repr == before_repr)
return;
} else {
}
// Reselect the dragged row
//gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(tree), path, NULL, true, 0.66, 0.0);
// Signal that a drag and drop has completed successfully
}
/*
* Set iter to ref or node data's child with the same repr or first child
*/
{
if (repr) {
return false;
}
} else {
return false;
}
}
return true;
}
/*
* Set iter to the node data's child with the same repr
*/
{
return false;
}
/*
* The node we are looking for is likely to be the last one, so check it first.
*/
if (n_children > 1) {
//g_message("repr_to_child hit %d", n_children);
return valid;
}
}
}
return valid;
}
/*
* Get a matching GtkTreeRowReference for a GtkTreeIter
*/
{
return ref;
}
/*
* Get a matching GtkTreeIter for a GtkTreeRowReference
*/
{
if (!path) {
return false;
}
}
/*
* Compare 2 GtkTreeIter and return 0 if they are equal
*/
{
return result;
}
/*
* Disable drag and drop target on : root node and non-element nodes
*/
gboolean do_drag_motion(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer user_data)
{
int action = 0;
if (path) {
if (sp_xmlview_tree_node_get_repr (GTK_TREE_MODEL(tree->store), &iter)->type() != Inkscape::XML::ELEMENT_NODE) {
action = 0;
}
if (!gtk_tree_path_up(path)) {
action = 0;
}
if (!gtk_tree_path_up(path)) {
action = 0;
}
if (!path) {
action = 0;
}
}
return (action == 0);
}
/*
* Set the tree selection and scroll to the row with the given repr
*/
void
{
/*
* Would like to simple call gtk_tree_store_clear here,
* but it is extremely slow on large data sets.
* Instead just unref the old and create a new store.
*/
//gtk_tree_store_clear(tree->store);
}
if (repr) {
// Set the tree model here, after all data is inserted
}
}
/*
* Return the repr at a given GtkTreeIter position
*/
{
return repr;
}
/*
* Find a GtkTreeIter position in the tree by repr
*/
{
/*
* Use a NodeData here to pass in the repr to the foreach function and store a rowref if found,
* if found we can return the iter
*/
return TRUE;
}
return FALSE;
}
gboolean foreach_func(GtkTreeModel *model, GtkTreePath * /*path*/, GtkTreeIter *iter, gpointer user_data)
{
return TRUE;
}
return FALSE;
}
/*
* Callback function for string searches in the tree
* Return a match on any substring
*/
gboolean search_equal_func(GtkTreeModel *model, gint /*column*/, const gchar *key, GtkTreeIter *iter, gpointer /*search_data*/)
{
return !match;
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 :