X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fdialogs%2Fxml-tree.cpp;h=33ac02a9b0df915c5dd9347bc771dd1a8ce5002c;hb=3da8c9f095f6e1d434809a58940f93585c58ebf3;hp=6da0096e206346eed254a0580e4ad90fe77e94b8;hpb=723b4d8bde8ce8503d1d01ee0f2e3548ec0dc88c;p=inkscape.git
diff --git a/src/dialogs/xml-tree.cpp b/src/dialogs/xml-tree.cpp
index 6da0096e2..33ac02a9b 100644
--- a/src/dialogs/xml-tree.cpp
+++ b/src/dialogs/xml-tree.cpp
@@ -78,7 +78,7 @@ static sigc::connection document_replaced_connection;
static win_data wd;
// impossible original values to make sure they are read from prefs
static gint x = -1000, y = -1000, w = 0, h = 0;
-static gchar *prefs_path = "dialogs.xml";
+static gchar const *const prefs_path = "dialogs.xml";
static GtkWidget *status = NULL;
static Inkscape::MessageStack *_message_stack = NULL;
static Inkscape::MessageContext *_message_context = NULL;
@@ -772,7 +772,7 @@ void propagate_tree_select(Inkscape::XML::Node *repr)
sp_xmlview_attr_list_set_repr(attributes, NULL);
}
- if (repr && ( repr->type() == Inkscape::XML::TEXT_NODE || repr->type() == Inkscape::XML::COMMENT_NODE ) ) {
+ if (repr && ( repr->type() == Inkscape::XML::TEXT_NODE || repr->type() == Inkscape::XML::COMMENT_NODE || repr->type() == Inkscape::XML::PI_NODE ) ) {
sp_xmlview_content_set_repr(content, repr);
} else {
sp_xmlview_content_set_repr(content, NULL);
@@ -986,7 +986,7 @@ void on_tree_select_row_show_if_text(GtkCTree *tree, GtkCTreeNode *node,
{
Inkscape::XML::Node *repr = sp_xmlview_tree_node_get_repr(SP_XMLVIEW_TREE(tree), node);
- if ( repr->type() == Inkscape::XML::TEXT_NODE || repr->type() == Inkscape::XML::COMMENT_NODE ) {
+ if ( repr->type() == Inkscape::XML::TEXT_NODE || repr->type() == Inkscape::XML::COMMENT_NODE || repr->type() == Inkscape::XML::PI_NODE ) {
gtk_widget_show(GTK_WIDGET(data));
} else {
gtk_widget_hide(GTK_WIDGET(data));
@@ -1304,7 +1304,16 @@ void on_clicked_get_editable_text(GtkWidget */*widget*/, gpointer data)
dest->text = gtk_editable_get_chars(dest->editable, 0, -1);
}
-
+gboolean
+quit_on_esc (GtkWidget *w, GdkEventKey *event, GObject */*tbl*/)
+{
+ switch (get_group0_keyval (event)) {
+ case GDK_Escape: // defocus
+ gtk_widget_destroy(w);
+ return TRUE;
+ }
+ return FALSE;
+}
void cmd_new_element_node(GtkObject */*object*/, gpointer /*data*/)
{
@@ -1321,6 +1330,7 @@ void cmd_new_element_node(GtkObject */*object*/, gpointer /*data*/)
gtk_window_set_transient_for(GTK_WINDOW(window), GTK_WINDOW(dlg));
gtk_window_set_modal(GTK_WINDOW(window), TRUE);
gtk_signal_connect(GTK_OBJECT(window), "destroy", gtk_main_quit, NULL);
+ gtk_signal_connect(GTK_OBJECT(window), "key-press-event", G_CALLBACK(quit_on_esc), window);
vbox = gtk_vbox_new(FALSE, 4);
gtk_container_add(GTK_CONTAINER(window), vbox);
@@ -1337,6 +1347,8 @@ void cmd_new_element_node(GtkObject */*object*/, gpointer /*data*/)
gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
cancel = gtk_button_new_with_label(_("Cancel"));
+ GTK_WIDGET_SET_FLAGS( GTK_WIDGET(cancel),
+ GTK_CAN_DEFAULT );
gtk_signal_connect_object( GTK_OBJECT(cancel), "clicked",
G_CALLBACK(gtk_widget_destroy),
GTK_OBJECT(window) );
@@ -1365,9 +1377,7 @@ void cmd_new_element_node(GtkObject */*object*/, gpointer /*data*/)
gtk_main();
- g_assert(selected_repr != NULL);
-
- if (name.text) {
+ if (selected_repr != NULL && name.text) {
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(current_document);
Inkscape::XML::Node *new_repr;
new_repr = xml_doc->createElement(name.text);
@@ -1463,11 +1473,7 @@ void cmd_set_attr(GtkObject */*object*/, gpointer /*data*/)
gchar *value = gtk_text_buffer_get_text( gtk_text_view_get_buffer(attr_value),
&start, &end, TRUE );
- if (!sp_repr_set_attr(selected_repr, name, value)) {
- gchar *message = g_strdup_printf(_("Cannot set %s: Another element with value %s already exists!"), name, value);
- _message_stack->flash(Inkscape::WARNING_MESSAGE, message);
- g_free(message);
- }
+ selected_repr->setAttribute(name, value, false);
g_free(name);
g_free(value);