index 079a09b5a23d120c32721e9c967682be7dab9e88..dd5371460f7c21a552f5a3f58a1f147f709bb002 100644 (file)
--- a/src/dialogs/xml-tree.cpp
+++ b/src/dialogs/xml-tree.cpp
* Lauris Kaplinski <lauris@kaplinski.com>
* MenTaLguY <mental@rydia.net>
* bulia byak <buliabyak@users.sf.net>
+ * Johan Engelen <goejendaagh@zonnet.nl>
*
- * Copyright (C) 1999-2005 Authors
+ * Copyright (C) 1999-2006 Authors
* Copyright (C) 2004 David Turner
*
* Released under GNU GPL, read the file 'COPYING' for more information
#include "message-stack.h"
#include "message-context.h"
+#define MIN_ONSCREEN_DISTANCE 50
+
struct EditableDest {
GtkEditable *editable;
gchar *text;
dlg = sp_window_new("", TRUE);
if (x == -1000 || y == -1000) {
- x = prefs_get_int_attribute(prefs_path, "x", 0);
- y = prefs_get_int_attribute(prefs_path, "y", 0);
+ x = prefs_get_int_attribute(prefs_path, "x", -1000);
+ y = prefs_get_int_attribute(prefs_path, "y", -1000);
}
if (w ==0 || h == 0) {
w = prefs_get_int_attribute(prefs_path, "w", 0);
h = prefs_get_int_attribute(prefs_path, "h", 0);
}
- if (x != 0 || y != 0) {
+
+// if (x<0) x=0;
+// if (y<0) y=0;
+
+ if (w && h) {
+ gtk_window_resize((GtkWindow *) dlg, w, h);
+ }
+ if (x >= 0 && y >= 0 && (x < (gdk_screen_width()-MIN_ONSCREEN_DISTANCE)) && (y < (gdk_screen_height()-MIN_ONSCREEN_DISTANCE))) {
gtk_window_move((GtkWindow *) dlg, x, y);
} else {
gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_CENTER);
}
- if (w && h) {
- gtk_window_resize((GtkWindow *) dlg, w, h);
- }
sp_transientize(dlg);
wd.win = dlg;
wd.stop = 0;
NULL,
_("New element node"),
NULL,
- sp_icon_new( GTK_ICON_SIZE_LARGE_TOOLBAR,
+ sp_icon_new( Inkscape::ICON_SIZE_LARGE_TOOLBAR,
INKSCAPE_STOCK_ADD_XML_ELEMENT_NODE ),
G_CALLBACK(cmd_new_element_node),
NULL);
button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
NULL, _("New text node"), NULL,
- sp_icon_new( GTK_ICON_SIZE_LARGE_TOOLBAR,
+ sp_icon_new( Inkscape::ICON_SIZE_LARGE_TOOLBAR,
INKSCAPE_STOCK_ADD_XML_TEXT_NODE ),
G_CALLBACK(cmd_new_text_node),
NULL);
button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
NULL, _("Duplicate node"), NULL,
- sp_icon_new( GTK_ICON_SIZE_LARGE_TOOLBAR,
+ sp_icon_new( Inkscape::ICON_SIZE_LARGE_TOOLBAR,
INKSCAPE_STOCK_DUPLICATE_XML_NODE ),
G_CALLBACK(cmd_duplicate_node),
NULL);
button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
NULL, _("Delete node"), NULL,
- sp_icon_new( GTK_ICON_SIZE_LARGE_TOOLBAR,
+ sp_icon_new( Inkscape::ICON_SIZE_LARGE_TOOLBAR,
INKSCAPE_STOCK_DELETE_XML_NODE ),
G_CALLBACK(cmd_delete_node), NULL );
button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
NULL, _("Delete attribute"), NULL,
- sp_icon_new( GTK_ICON_SIZE_LARGE_TOOLBAR,
+ sp_icon_new( Inkscape::ICON_SIZE_LARGE_TOOLBAR,
INKSCAPE_STOCK_DELETE_XML_ATTRIBUTE ),
(GCallback) cmd_delete_attr, NULL);
}
current_desktop = desktop;
if (desktop) {
- sel_changed_connection = SP_DT_SELECTION(desktop)->connectChanged(&on_desktop_selection_changed);
+ sel_changed_connection = sp_desktop_selection(desktop)->connectChanged(&on_desktop_selection_changed);
document_replaced_connection = desktop->connectDocumentReplaced(&on_document_replaced);
- set_tree_document(SP_DT_DOCUMENT(desktop));
+ set_tree_document(sp_desktop_document(desktop));
} else {
set_tree_document(NULL);
}
return NULL;
}
- return SP_DT_SELECTION(current_desktop)->singleRepr();
+ return sp_desktop_selection(current_desktop)->singleRepr();
}
return;
}
- Inkscape::Selection *selection = SP_DT_SELECTION(current_desktop);
+ Inkscape::Selection *selection = sp_desktop_selection(current_desktop);
SPObject *object;
if (repr) {
repr = sp_repr_parent(repr);
} // end of while loop
- object = SP_DT_DOCUMENT(current_desktop)->getObjectByRepr(repr);
+ object = sp_desktop_document(current_desktop)->getObjectByRepr(repr);
} else {
object = NULL;
}
blocked++;
if ( object && in_dt_coordsys(*object)
- && !( SP_IS_TSPAN(object) ||
- SP_IS_STRING(object) ||
- SP_IS_ROOT(object) ) )
+ && !(SP_IS_STRING(object) ||
+ SP_IS_ROOT(object) ) )
{
- /* We cannot set selection to tspan, string, or root; failures and
- * crashes will occur. */
- /* TODO: when a tspan is highlighted, set selection to its parent
- * text
- */
+ /* We cannot set selection to root or string - they are not items and selection is not
+ * equipped to deal with them */
selection->set(SP_ITEM(object));
}
blocked--;
if (GTK_CTREE_ROW(node)->parent == new_parent &&
GTK_CTREE_ROW(node)->sibling == new_sibling)
{
- sp_document_done(current_document);
+ sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR,
+ _("Drag XML subtree"));
} else {
sp_document_cancel(current_document);
}
gtk_window_get_position((GtkWindow *) dlg, &x, &y);
gtk_window_get_size((GtkWindow *) dlg, &w, &h);
+ if (x<0) x=0;
+ if (y<0) y=0;
+
prefs_set_int_attribute(prefs_path, "x", x);
prefs_set_int_attribute(prefs_path, "y", y);
prefs_set_int_attribute(prefs_path, "w", w);
if (current_desktop)
sel_changed_connection.disconnect();
- sel_changed_connection = SP_DT_SELECTION(dt)->connectChanged(&on_desktop_selection_changed);
+ sel_changed_connection = sp_desktop_selection(dt)->connectChanged(&on_desktop_selection_changed);
set_tree_document(doc);
}
g_assert(selected_repr != NULL);
if (name.text) {
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(current_document);
Inkscape::XML::Node *new_repr;
- new_repr = sp_repr_new(name.text);
+ new_repr = xml_doc->createElement(name.text);
g_free(name.text);
selected_repr->appendChild(new_repr);
set_tree_select(new_repr);
set_dt_select(new_repr);
+
+ sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR,
+ _("Create new element node"));
}
} // end of cmd_new_element_node()
{
g_assert(selected_repr != NULL);
- Inkscape::XML::Node *text = sp_repr_new_text("");
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(current_document);
+ Inkscape::XML::Node *text = xml_doc->createTextNode("");
selected_repr->appendChild(text);
- sp_document_done(current_document);
+ sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR,
+ _("Create new text node"));
set_tree_select(text);
set_dt_select(text);
g_assert(selected_repr != NULL);
Inkscape::XML::Node *parent = sp_repr_parent(selected_repr);
- Inkscape::XML::Node *dup = selected_repr->duplicate();
+ Inkscape::XML::Node *dup = selected_repr->duplicate(parent->document());
parent->addChild(dup, selected_repr);
- sp_document_done(current_document);
+ sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR,
+ _("Duplicate node"));
GtkCTreeNode *node = sp_xmlview_tree_get_repr_node(SP_XMLVIEW_TREE(tree), dup);
g_assert(selected_repr != NULL);
sp_repr_unparent(selected_repr);
- sp_document_done(current_document);
+ sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR,
+ _("Delete node"));
}
updated->updateRepr();
}
- sp_document_done(current_document);
+ sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR,
+ _("Delete attribute"));
}
updated->updateRepr();
}
- sp_document_done(current_document);
+ sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR,
+ _("Change attribute"));
/* TODO: actually, the row won't have been created yet. why? */
gint row = sp_xmlview_attr_list_find_row_from_key(GTK_CLIST(attributes),
parent->changeOrder(selected_repr, ref);
- sp_document_done(current_document);
+ sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR,
+ _("Raise node"));
set_tree_select(selected_repr);
set_dt_select(selected_repr);
parent->changeOrder(selected_repr, selected_repr->next());
- sp_document_done(current_document);
+ sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR,
+ _("Lower node"));
set_tree_select(selected_repr);
set_dt_select(selected_repr);
parent->removeChild(repr);
prev->addChild(repr, ref);
- sp_document_done(current_document);
+ sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR,
+ _("Indent node"));
set_tree_select(repr);
set_dt_select(repr);
parent->removeChild(repr);
grandparent->addChild(repr, parent);
- sp_document_done(current_document);
+ sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR,
+ _("Unindent node"));
set_tree_select(repr);
set_dt_select(repr);