summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Jeanmougin <marc@jeanmougin.fr>2018-09-11 20:00:01 +0000
committerMarc Jeanmougin <marc@jeanmougin.fr>2018-09-11 20:00:01 +0000
commit9f11d4ba5a2bbbcf52946abf5eb2ed52dc12586f (patch)
treea82dc320a9eadb43280ae6d8221c7de1f6f6b8b7
parentAdd gitlab job for protected code (diff)
parentUpdate CONTRIBUTING.md (diff)
downloadinkscape-9f11d4ba5a2bbbcf52946abf5eb2ed52dc12586f.tar.gz
inkscape-9f11d4ba5a2bbbcf52946abf5eb2ed52dc12586f.zip
Merge branch 'master' of gitlab.com:inkscape/inkscape
-rw-r--r--CONTRIBUTING.md45
-rw-r--r--INSTALL.md23
-rw-r--r--po/POTFILES.in1
-rw-r--r--src/helper/sp-marshal.list3
-rw-r--r--src/ui/dialog/xml-tree.cpp249
-rw-r--r--src/ui/dialog/xml-tree.h45
-rw-r--r--src/widgets/CMakeLists.txt2
-rw-r--r--src/widgets/sp-xmlview-attr-list.cpp128
-rw-r--r--src/widgets/sp-xmlview-attr-list.h12
-rw-r--r--src/widgets/sp-xmlview-content.cpp136
-rw-r--r--src/widgets/sp-xmlview-content.h45
11 files changed, 179 insertions, 510 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 93b61a294..73460db77 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -64,25 +64,44 @@ appreciate this. New files should have one or two lines describing the
purpose of the code inside the file.
-Makefiles
-=========
-Inkscape currently uses CMake. We encourage you to build it by creating a build
-folder, and running
+Building
+========
-`cmake <<<source folder>>> \`
-`-DCMAKE_C_COMPILER_LAUNCHER=ccache \`
-`-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \`
-`-DCMAKE_BUILD_TYPE=Debug \`
-`-DCMAKE_INSTALL_PREFIX:PATH=$PWD/..`
+This is the best set of instructions for setting up your build directory...
-This uses ccache to speed up later builds (optional), create a Debug build
-(use "Release" otherwise) and makes a local install prefix.
+You should install ninja and ccache for the fastest build:
-(If you have ninja available, add "-G Ninja" to enable it)
+```bash
+sudo apt-get install ninja-build ccache
+```
+
+Next we prepare a build directory with a symlink to Inkscape's share folder, add a profile dir and set the bin folder (optional):
-Then, run `make -j$(nproc) install` (or `ninja install`) to build & install
+```bash
+ln -s share share/inkscape
+mkdir -p build/conf
+cd build
+export INKSCAPE_PROFILE_DIR=$PWD/conf
+PATH=$PWD/bin/:$PATH
+```
+Now we invoke cmake, letting it know to use our new build directory prefix, ccache and the Ninja compiler:
+```bash
+cmake -DCMAKE_INSTALL_PREFIX:PATH=$PWD/../ -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=Debug -G Ninja ..
+```
+
+Invoke ninja to build the code. You may also use plain gcc's `make` if you didn't specific `-G` in the command above:
+```bash
+ninja
+```
+
+Now we can run inkscape that we have built, with the latest resources and code:
+
+```bash
+./bin/inkscape
+```
+
Testing
=======
diff --git a/INSTALL.md b/INSTALL.md
index 549e3d055..0978924be 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -17,27 +17,8 @@ a developer and packager task. These instructions are kept on the Inkscape wiki.
Running Without Installing
==========================
-For developers and others who want to run inkscape without installing it:
-
-```bash
-ln -s . share/inkscape
-mkdir -p build/conf
-cd build
-cmake -DCMAKE_INSTALL_PREFIX:PATH=$PWD/../ ..
-make -j4
-export INKSCAPE_PROFILE_DIR=$PWD/conf
-PATH=$PWD/bin/:$PATH
-./bin/inkscape
-```
-
-This won't work for other platforms such as Windows and Mac, see above. But
-what it is doing is linking the share directory into a location where
-the inkscape binary will be able to find it. Allowing you to change the
-inkscape shared files without rebuilding or installing.
-
-Then setting a local configuration directory, keeping your configurations
-separate from any installed version.
-
+For developers and others who want to run inkscape without installing it please
+see the ***Building*** section in the `CONTRIBUTING.md` file.
Required Dependencies
=====================
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 9cfad9943..1446c00cb 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -365,7 +365,6 @@ src/widgets/paint-selector.cpp
src/widgets/sp-attribute-widget.cpp
src/widgets/sp-color-selector.cpp
src/widgets/sp-xmlview-attr-list.cpp
-src/widgets/sp-xmlview-content.cpp
src/widgets/stroke-marker-selector.cpp
src/widgets/stroke-style.cpp
src/widgets/swatch-selector.cpp
diff --git a/src/helper/sp-marshal.list b/src/helper/sp-marshal.list
index 35f7858e2..ba5c3a889 100644
--- a/src/helper/sp-marshal.list
+++ b/src/helper/sp-marshal.list
@@ -1,4 +1,4 @@
-# marshallers for sodipodi
+# marshallers for inkscape
VOID:POINTER,UINT
BOOLEAN:POINTER
BOOLEAN:POINTER,UINT
@@ -6,3 +6,4 @@ BOOLEAN:POINTER,POINTER
INT:POINTER,POINTER
DOUBLE:POINTER,UINT
VOID:INT,INT
+VOID:STRING,STRING
diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp
index 647e0beed..1a39af095 100644
--- a/src/ui/dialog/xml-tree.cpp
+++ b/src/ui/dialog/xml-tree.cpp
@@ -42,8 +42,8 @@
#include "ui/tools/tool-base.h"
#include "widgets/sp-xmlview-attr-list.h"
-#include "widgets/sp-xmlview-content.h"
#include "widgets/sp-xmlview-tree.h"
+#include "ui/dialog/cssdialog.h"
namespace Inkscape {
namespace UI {
@@ -60,8 +60,6 @@ XmlTree::XmlTree() :
selected_repr (nullptr),
tree (nullptr),
attributes (nullptr),
- content (nullptr),
- attr_name (),
status (""),
tree_toolbar(),
xml_element_new_button ( _("New element node")),
@@ -72,12 +70,6 @@ XmlTree::XmlTree() :
indent_node_button(),
raise_node_button(),
lower_node_button(),
- attr_toolbar(),
- xml_attribute_delete_button (_("Delete attribute")),
- text_container (),
- attr_container (),
- attr_subpaned_container(Gtk::ORIENTATION_VERTICAL),
- set_attr (_("Set")),
new_window(nullptr)
{
@@ -86,6 +78,8 @@ XmlTree::XmlTree() :
return;
}
+ notebook_content = new Gtk::Notebook();
+
Gtk::Box *contents = _getContents();
contents->set_spacing(0);
contents->set_size_request(320, 260);
@@ -98,8 +92,7 @@ XmlTree::XmlTree() :
status_box.pack_start( status, TRUE, TRUE, 0);
contents->pack_end(status_box, false, false, 2);
- paned.set_position(256);
- contents->pack_start(paned, TRUE, TRUE, 0);
+ contents->pack_start(*notebook_content, true, true, 0);
_message_stack = new Inkscape::MessageStack();
_message_context = new Inkscape::MessageContext(_message_stack);
@@ -107,7 +100,7 @@ XmlTree::XmlTree() :
sigc::bind(sigc::ptr_fun(_set_status_message), GTK_WIDGET(status.gobj())));
/* tree view */
- paned.pack1(left_box);
+ notebook_content->insert_page(node_box, _("_Nodes"), NOTEBOOK_PAGE_NODES, true);
tree = SP_XMLVIEW_TREE(sp_xmlview_tree_new(nullptr, nullptr, nullptr));
gtk_widget_set_tooltip_text( GTK_WIDGET(tree), _("Drag to reorder nodes") );
@@ -178,81 +171,36 @@ XmlTree::XmlTree() :
lower_node_button.set_sensitive(false);
tree_toolbar.add(lower_node_button);
- left_box.pack_start(tree_toolbar, FALSE, TRUE, 0);
+ node_box.pack_start(tree_toolbar, FALSE, TRUE, 0);
Gtk::ScrolledWindow *tree_scroller = new Gtk::ScrolledWindow();
tree_scroller->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC );
tree_scroller->set_shadow_type(Gtk::SHADOW_IN);
tree_scroller->add(*Gtk::manage(Glib::wrap(GTK_WIDGET(tree))));
- left_box.pack_start(*tree_scroller);
+ node_box.pack_start(*tree_scroller);
/* node view */
- paned.pack2(right_box);
+ notebook_content->insert_page(attr_box, _("_Attributes"), NOTEBOOK_PAGE_ATTRS, true);
/* attributes */
- right_box.pack_start( attr_container, TRUE, TRUE, 0 );
-
attributes = SP_XMLVIEW_ATTR_LIST(sp_xmlview_attr_list_new(nullptr));
- attr_toolbar.set_toolbar_style(Gtk::TOOLBAR_ICONS);
-
- auto xml_attribute_delete_icon =
- Gtk::manage(sp_get_icon_image("xml-attribute-delete", Gtk::ICON_SIZE_LARGE_TOOLBAR));
- xml_attribute_delete_button.set_icon_widget(*xml_attribute_delete_icon);
- xml_attribute_delete_button.set_tooltip_text(_("Delete attribute"));
- xml_attribute_delete_button.set_sensitive(false);
- attr_toolbar.add(xml_attribute_delete_button);
-
- attr_container.pack_start( attr_toolbar, FALSE, TRUE, 0 );
- attr_container.pack_start( attr_subpaned_container, TRUE, TRUE, 0 );
-
Gtk::ScrolledWindow *attr_scroller = new Gtk::ScrolledWindow();
attr_scroller->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC );
attr_scroller->set_shadow_type(Gtk::SHADOW_IN);
attr_scroller->set_size_request(-1, 80);
- attr_subpaned_container.pack1( *attr_scroller );
+ attr_box.pack_start( *attr_scroller );
attr_scroller->add(*Gtk::manage(Glib::wrap(GTK_WIDGET(attributes))));
- attr_vbox.pack_start( attr_hbox, FALSE, TRUE, 0);
-
- attr_name.set_tooltip_text(_("Attribute name") ); // TRANSLATORS: "Attribute" is a noun here
- attr_name.set_width_chars (10);
- attr_hbox.pack_start( attr_name, TRUE, TRUE, 0);
-
- set_attr.set_sensitive(FALSE);
- attr_hbox.pack_start(set_attr, FALSE, FALSE, 0);
-
- Gtk::ScrolledWindow *scroller = new Gtk::ScrolledWindow();
- scroller->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC );
- scroller->set_shadow_type(Gtk::SHADOW_IN);
- scroller->set_size_request(-1, 40);
-
- attr_vbox.pack_start(*scroller, TRUE, TRUE, 0);
-
- attr_value.set_wrap_mode(Gtk::WRAP_CHAR);
- attr_value.set_tooltip_text( _("Attribute value") );// TRANSLATORS: "Attribute" is a noun here
- attr_value.set_editable(TRUE);
- scroller->add(attr_value);
-
- attr_subpaned_container.pack2( attr_vbox, FALSE, FALSE );
-
- /* text */
- text_container.set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC );
- right_box.pack_start(text_container, TRUE, TRUE, 0);
-
- content = SP_XMLVIEW_CONTENT(sp_xmlview_content_new(nullptr));
- text_container.add(*Gtk::manage(Glib::wrap(GTK_WIDGET(content))));
-
/* Signal handlers */
GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(tree));
g_signal_connect (G_OBJECT(selection), "changed", G_CALLBACK (on_tree_select_row), this);
g_signal_connect_after( G_OBJECT(tree), "tree_move", G_CALLBACK(after_tree_move), this);
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(attributes));
- g_signal_connect (G_OBJECT(selection), "changed", G_CALLBACK (on_attr_select_row), this);
g_signal_connect( G_OBJECT(attributes), "row-value-changed", G_CALLBACK(on_attr_row_changed), this);
+ g_signal_connect( G_OBJECT(attributes), "attr-value-edited", G_CALLBACK(on_attr_edited), this);
xml_element_new_button.signal_clicked().connect(sigc::mem_fun(*this, &XmlTree::cmd_new_element_node));
xml_text_new_button.signal_clicked().connect(sigc::mem_fun(*this, &XmlTree::cmd_new_text_node));
@@ -262,10 +210,10 @@ XmlTree::XmlTree() :
indent_node_button.signal_clicked().connect(sigc::mem_fun(*this, &XmlTree::cmd_indent_node));
raise_node_button.signal_clicked().connect(sigc::mem_fun(*this, &XmlTree::cmd_raise_node));
lower_node_button.signal_clicked().connect(sigc::mem_fun(*this, &XmlTree::cmd_lower_node));
- xml_attribute_delete_button.signal_clicked().connect(sigc::mem_fun(*this, &XmlTree::cmd_delete_attr));
- set_attr.signal_clicked().connect(sigc::mem_fun(*this, &XmlTree::cmd_set_attr));
- attr_name.signal_changed().connect(sigc::mem_fun(*this, &XmlTree::onNameChanged));
- attr_value.signal_key_press_event().connect(sigc::mem_fun(*this, &XmlTree::sp_xml_tree_key_press), false);
+
+ styles = new CssDialog;
+ css_box.pack_start(*styles);
+ notebook_content->insert_page(css_box, _("_Styles"), NOTEBOOK_PAGE_STYLES, true);
desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &XmlTree::set_tree_desktop) );
deskTrack.connect(GTK_WIDGET(gobj()));
@@ -273,12 +221,6 @@ XmlTree::XmlTree() :
/* initial show/hide */
show_all();
-/*
- // hide() doesn't seem to work in the constructor, so moved this to present()
- text_container.hide();
- attr_container.hide();
-*/
-
tree_reset_context();
g_assert(desktop != nullptr);
@@ -288,9 +230,6 @@ XmlTree::XmlTree() :
void XmlTree::present()
{
- text_container.hide();
- attr_container.hide();
-
set_tree_select(get_dt_select());
UI::Widget::Panel::present();
@@ -341,19 +280,6 @@ void XmlTree::attr_reset_context(gint attr)
}
}
-bool XmlTree::sp_xml_tree_key_press(GdkEventKey *event)
-{
- unsigned int shortcut = sp_shortcut_get_for_event((GdkEventKey*)event);
-
- /* fixme: if you need to add more xml-tree-specific callbacks, you should probably upgrade
- * the sp_shortcut mechanism to take into account windows. */
- if (shortcut == (SP_SHORTCUT_CONTROL_MASK | GDK_KEY_Return)) {
- cmd_set_attr();
- return true;
- }
- return false;
-}
-
void XmlTree::set_tree_desktop(SPDesktop *desktop)
{
if ( desktop == current_desktop ) {
@@ -450,7 +376,6 @@ void XmlTree::set_tree_select(Inkscape::XML::Node *repr)
gtk_tree_selection_unselect_all (selection);
on_tree_unselect_row_disable();
- on_tree_unselect_row_hide();
}
propagate_tree_select(repr);
}
@@ -464,12 +389,6 @@ void XmlTree::propagate_tree_select(Inkscape::XML::Node *repr)
} else {
sp_xmlview_attr_list_set_repr(attributes, nullptr);
}
-
- 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, nullptr);
- }
}
@@ -540,8 +459,6 @@ void XmlTree::on_tree_select_row(GtkTreeSelection *selection, gpointer data)
self->propagate_tree_select(nullptr);
self->set_dt_select(nullptr);
self->on_tree_unselect_row_disable();
- self->on_tree_unselect_row_hide();
- self->on_attr_unselect_row_clear_text();
return;
}
@@ -665,21 +582,6 @@ void XmlTree::on_tree_select_row_enable(GtkTreeIter *node)
lower_node_button.set_sensitive(false);
}
}
-
- //on_tree_select_row_show_if_element
- if (repr->type() == Inkscape::XML::ELEMENT_NODE) {
- attr_container.show();
- } else {
- attr_container.hide();
- }
-
- //on_tree_select_row_show_if_text
- if ( repr->type() == Inkscape::XML::TEXT_NODE || repr->type() == Inkscape::XML::COMMENT_NODE || repr->type() == Inkscape::XML::PI_NODE ) {
- text_container.show();
- } else {
- text_container.hide();
- }
-
}
@@ -724,52 +626,32 @@ void XmlTree::on_tree_unselect_row_disable()
indent_node_button.set_sensitive(false);
raise_node_button.set_sensitive(false);
lower_node_button.set_sensitive(false);
- xml_attribute_delete_button.set_sensitive(false);
}
-void XmlTree::on_tree_unselect_row_hide()
-{
- attr_container.hide();
- text_container.hide();
-}
-
-void XmlTree::on_attr_select_row(GtkTreeSelection *selection, gpointer data)
+void XmlTree::on_attr_edited(SPXMLViewAttrList *attributes, const gchar * name, const gchar * value, gpointer data)
{
XmlTree *self = static_cast<XmlTree *>(data);
+ g_assert(self->selected_repr != nullptr);
- GtkTreeIter iter;
- GtkTreeModel *model;
-
- if (!gtk_tree_selection_get_selected (selection, &model, &iter)) {
- // Nothing selected
- self->selected_attr = 0;
- self->attr_reset_context(self->selected_attr);
-
- self->xml_attribute_delete_button.set_sensitive(false);
- self->on_attr_unselect_row_clear_text();
- return;
+ if(value) {
+ self->selected_repr->setAttribute(name, value, false);
+ } else {
+ self->selected_repr->setAttribute(name, nullptr, false);
}
- gchar *name = nullptr;
- gchar *value = nullptr;
- guint attr = 0;
- gtk_tree_model_get (model, &iter, ATTR_COL_NAME, &name, ATTR_COL_VALUE, &value, ATTR_COL_ATTR, &attr, -1);
-
- self->attr_name.set_text(name);
- self->attr_value.get_buffer()->set_text(value);
-
- self->attr_value.grab_focus ();
- self->xml_attribute_delete_button.set_sensitive(true);
-
- self->selected_attr = attr;
- self->attr_reset_context(self->selected_attr);
-
- if (name) {
- g_free(name);
+ SPObject *updated = self->current_document->getObjectByRepr(self->selected_repr);
+ if (updated) {
+ // force immediate update of dependent attributes
+ updated->updateRepr();
}
- if (value) {
- g_free(value);
+ reinterpret_cast<SPObject *>(self->current_desktop->currentLayer())->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+
+ if(value) {
+ DocumentUndo::done(self->current_document, SP_VERB_DIALOG_XML_EDITOR, _("Change attribute"));
+ sp_xmlview_attr_list_select_row_by_key(attributes, name);
+ } else {
+ DocumentUndo::done(self->current_document, SP_VERB_DIALOG_XML_EDITOR, _("Delete attribute"));
}
}
@@ -796,20 +678,6 @@ void XmlTree::on_attr_row_changed(SPXMLViewAttrList *attributes, const gchar * n
}
}
-void XmlTree::on_attr_unselect_row_clear_text()
-{
- attr_name.set_text("");
- // Set text with empty Glib::ustring
- attr_value.get_buffer()->set_text( Glib::ustring() );
-}
-
-void XmlTree::onNameChanged()
-{
- Glib::ustring text = attr_name.get_text();
- /* TODO: need to do checking a little more rigorous than this */
- set_attr.set_sensitive(!text.empty());
-}
-
void XmlTree::onCreateNameChanged()
{
Glib::ustring text = name_entry->get_text();
@@ -822,9 +690,6 @@ void XmlTree::on_desktop_selection_changed()
if (!blocked++) {
Inkscape::XML::Node *node = get_dt_select();
set_tree_select(node);
- if (!node) {
- on_attr_unselect_row_clear_text();
- }
}
blocked--;
}
@@ -941,7 +806,6 @@ void XmlTree::cmd_new_element_node()
} // end of cmd_new_element_node()
-
void XmlTree::cmd_new_text_node()
{
g_assert(selected_repr != nullptr);
@@ -955,9 +819,6 @@ void XmlTree::cmd_new_text_node()
set_tree_select(text);
set_dt_select(text);
-
- gtk_window_set_focus(GTK_WINDOW(new_window), GTK_WIDGET(content));
-
}
void XmlTree::cmd_duplicate_node()
@@ -989,54 +850,6 @@ void XmlTree::cmd_delete_node()
Q_("nodeAsInXMLinHistoryDialog|Delete node"));
}
-
-
-void XmlTree::cmd_delete_attr()
-{
- g_assert(selected_repr != nullptr);
- g_assert(selected_attr != 0);
-
- selected_repr->setAttribute(g_quark_to_string(selected_attr), nullptr);
-
- SPObject *updated = current_document->getObjectByRepr(selected_repr);
- if (updated) {
- // force immediate update of dependent attributes
- updated->updateRepr();
- }
-
- DocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR,
- _("Delete attribute"));
-}
-
-
-
-void XmlTree::cmd_set_attr()
-{
- g_assert(selected_repr != nullptr);
-
- gchar *name = g_strdup(attr_name.get_text().c_str());
- gchar *value = g_strdup(attr_value.get_buffer()->get_text().c_str());
-
- selected_repr->setAttribute(name, value, false);
-
- g_free(name);
- g_free(value);
-
- SPObject *updated = current_document->getObjectByRepr(selected_repr);
- if (updated) {
- // force immediate update of dependent attributes
- updated->updateRepr();
- }
-
- reinterpret_cast<SPObject *>(current_desktop->currentLayer())->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
- DocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR,
- _("Change attribute"));
-
- /* TODO: actually, the row won't have been created yet. why? */
- sp_xmlview_attr_list_select_row_by_key(attributes, name);
-}
-
-
void XmlTree::cmd_raise_node()
{
g_assert(selected_repr != nullptr);
diff --git a/src/ui/dialog/xml-tree.h b/src/ui/dialog/xml-tree.h
index 72622a070..168bff9b7 100644
--- a/src/ui/dialog/xml-tree.h
+++ b/src/ui/dialog/xml-tree.h
@@ -23,9 +23,11 @@
#include <gtkmm/toolbar.h>
#include <gtkmm/separatortoolitem.h>
#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/notebook.h>
#include <gtkmm/paned.h>
#include <gtkmm/button.h>
+#include "ui/dialog/cssdialog.h"
#include "ui/dialog/desktop-tracker.h"
#include "message.h"
@@ -126,9 +128,9 @@ private:
static void after_tree_move(SPXMLViewTree *attributes, gpointer value, gpointer data);
/**
- * Callback for when attribute selection changes
+ * Callback for when an attribute is edited.
*/
- static void on_attr_select_row(GtkTreeSelection *selection, gpointer data);
+ static void on_attr_edited(SPXMLViewAttrList *attributes, const gchar * name, const gchar * value, gpointer /*data*/);
/**
* Callback for when attribute list values change
@@ -142,7 +144,6 @@ private:
void on_tree_unselect_row_disable();
void on_tree_unselect_row_hide();
void on_attr_unselect_row_disable();
- void on_attr_unselect_row_clear_text();
void onNameChanged();
void onCreateNameChanged();
@@ -168,12 +169,8 @@ private:
void cmd_indent_node();
void cmd_unindent_node();
- void cmd_delete_attr();
- void cmd_set_attr();
void present() override;
- bool sp_xml_tree_key_press(GdkEventKey *event);
-
bool in_dt_coordsys(SPObject const &item);
/**
@@ -186,6 +183,14 @@ private:
*/
gint blocked;
+ /* Each of the notebook page type (by number) */
+ Gtk::Notebook *notebook_content;
+ enum {
+ NOTEBOOK_PAGE_NODES,
+ NOTEBOOK_PAGE_ATTRS,
+ NOTEBOOK_PAGE_STYLES,
+ };
+
/**
* Status bar
*/
@@ -212,16 +217,15 @@ private:
/* XmlTree Widgets */
SPXMLViewTree *tree;
SPXMLViewAttrList *attributes;
- SPXMLViewContent *content;
-
- Gtk::Entry attr_name;
- Gtk::TextView attr_value;
+ CssDialog *styles;
- Gtk::Button *create_button;
+ /* XML Node Creation pop-up window */
Gtk::Entry *name_entry;
- Gtk::Paned paned;
- Gtk::VBox left_box;
- Gtk::VBox right_box;
+ Gtk::Button *create_button;
+
+ Gtk::VBox node_box;
+ Gtk::VBox attr_box;
+ Gtk::VBox css_box;
Gtk::HBox status_box;
Gtk::Label status;
Gtk::Toolbar tree_toolbar;
@@ -236,17 +240,6 @@ private:
Gtk::ToolButton raise_node_button;
Gtk::ToolButton lower_node_button;
- Gtk::Toolbar attr_toolbar;
- Gtk::ToolButton xml_attribute_delete_button;
-
- Gtk::VBox attr_vbox;
- Gtk::ScrolledWindow text_container;
- Gtk::HBox attr_hbox;
- Gtk::VBox attr_container;
- Gtk::Paned attr_subpaned_container;
-
- Gtk::Button set_attr;
-
GtkWidget *new_window;
DesktopTracker deskTrack;
diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt
index 052e82347..3853bb91a 100644
--- a/src/widgets/CMakeLists.txt
+++ b/src/widgets/CMakeLists.txt
@@ -22,7 +22,6 @@ set(widgets_SRC
sp-color-selector.cpp
sp-widget.cpp
sp-xmlview-attr-list.cpp
- sp-xmlview-content.cpp
sp-xmlview-tree.cpp
spinbutton-events.cpp
spw-utilities.cpp
@@ -55,7 +54,6 @@ set(widgets_SRC
sp-color-selector.h
sp-widget.h
sp-xmlview-attr-list.h
- sp-xmlview-content.h
sp-xmlview-tree.h
spinbutton-events.h
spw-utilities.h
diff --git a/src/widgets/sp-xmlview-attr-list.cpp b/src/widgets/sp-xmlview-attr-list.cpp
index 720856ba5..8fc1981e3 100644
--- a/src/widgets/sp-xmlview-attr-list.cpp
+++ b/src/widgets/sp-xmlview-attr-list.cpp
@@ -25,11 +25,11 @@ static void sp_xmlview_attr_list_destroy(GtkWidget * object);
static void event_attr_changed (Inkscape::XML::Node * repr, const gchar * name, const gchar * old_value, const gchar * new_value, bool is_interactive, gpointer data);
static Inkscape::XML::NodeEventVector repr_events = {
- nullptr, /* child_added */
- nullptr, /* child_removed */
- event_attr_changed,
- nullptr, /* content_changed */
- nullptr /* order_changed */
+ nullptr, /* child_added */
+ nullptr, /* child_removed */
+ event_attr_changed,
+ nullptr, /* content_changed */
+ nullptr /* order_changed */
};
GtkWidget *sp_xmlview_attr_list_new (Inkscape::XML::Node * repr)
@@ -56,8 +56,11 @@ GtkWidget *sp_xmlview_attr_list_new (Inkscape::XML::Node * repr)
column = gtk_tree_view_get_column (GTK_TREE_VIEW(attr_list), colpos);
gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
gtk_cell_renderer_set_padding (cell, 2, 0);
+ g_object_set(cell, "editable", TRUE, NULL);
sp_xmlview_attr_list_set_repr (attr_list, repr);
+ g_signal_connect(cell, "edited", (GCallback) attr_value_edited, attr_list);
+ g_signal_connect( G_OBJECT(attr_list), "key-press-event", G_CALLBACK(attr_key_pressed), NULL);
return GTK_WIDGET(attr_list);
}
@@ -65,26 +68,26 @@ GtkWidget *sp_xmlview_attr_list_new (Inkscape::XML::Node * repr)
void
sp_xmlview_attr_list_set_repr (SPXMLViewAttrList * list, Inkscape::XML::Node * repr)
{
- if ( repr == list->repr ) return;
- if (list->repr) {
- gtk_list_store_clear(list->store);
- sp_repr_remove_listener_by_data (list->repr, list);
- Inkscape::GC::release(list->repr);
- }
- list->repr = repr;
- if (repr) {
- Inkscape::GC::anchor(repr);
- sp_repr_add_listener (repr, &repr_events, list);
- sp_repr_synthesize_events (repr, &repr_events, list);
- }
+ if ( repr == list->repr ) return;
+ if (list->repr) {
+ gtk_list_store_clear(list->store);
+ sp_repr_remove_listener_by_data (list->repr, list);
+ Inkscape::GC::release(list->repr);
+ }
+ list->repr = repr;
+ if (repr) {
+ Inkscape::GC::anchor(repr);
+ sp_repr_add_listener (repr, &repr_events, list);
+ sp_repr_synthesize_events (repr, &repr_events, list);
+ }
}
G_DEFINE_TYPE(SPXMLViewAttrList, sp_xmlview_attr_list, GTK_TYPE_TREE_VIEW);
void sp_xmlview_attr_list_class_init (SPXMLViewAttrListClass * klass)
{
- auto widget_class = GTK_WIDGET_CLASS(klass);
- widget_class->destroy = sp_xmlview_attr_list_destroy;
+ auto widget_class = GTK_WIDGET_CLASS(klass);
+ widget_class->destroy = sp_xmlview_attr_list_destroy;
g_signal_new("row-value-changed",
G_TYPE_FROM_CLASS(klass),
@@ -92,27 +95,33 @@ void sp_xmlview_attr_list_class_init (SPXMLViewAttrListClass * klass)
G_STRUCT_OFFSET (SPXMLViewAttrListClass, row_changed),
nullptr, nullptr,
g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1,
- G_TYPE_STRING);
+ G_TYPE_NONE, 1, G_TYPE_STRING);
+ g_signal_new("attr-value-edited",
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (SPXMLViewAttrListClass, row_changed),
+ nullptr, nullptr,
+ sp_marshal_VOID__STRING_STRING,
+ G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
}
void
sp_xmlview_attr_list_init (SPXMLViewAttrList * list)
{
list->store = nullptr;
- list->repr = nullptr;
+ list->repr = nullptr;
}
void sp_xmlview_attr_list_destroy(GtkWidget * object)
{
- SPXMLViewAttrList * list;
+ SPXMLViewAttrList * list;
- list = SP_XMLVIEW_ATTR_LIST (object);
+ list = SP_XMLVIEW_ATTR_LIST (object);
- g_object_unref(list->store);
- sp_xmlview_attr_list_set_repr (list, nullptr);
+ g_object_unref(list->store);
+ sp_xmlview_attr_list_set_repr (list, nullptr);
- GTK_WIDGET_CLASS(sp_xmlview_attr_list_parent_class)->destroy (object);
+ GTK_WIDGET_CLASS(sp_xmlview_attr_list_parent_class)->destroy (object);
}
void sp_xmlview_attr_list_select_row_by_key(SPXMLViewAttrList * list, const gchar *name)
@@ -141,6 +150,43 @@ void sp_xmlview_attr_list_select_row_by_key(SPXMLViewAttrList * list, const gcha
}
void
+attr_value_edited (GtkCellRendererText *cell,
+ gchar * path_string,
+ gchar * new_value,
+ gpointer data) {
+
+ SPXMLViewAttrList * list = SP_XMLVIEW_ATTR_LIST (data);
+ GtkTreeIter iter;
+ gboolean valid = gtk_tree_model_get_iter_from_string( GTK_TREE_MODEL(list->store), &iter, path_string );
+ if(valid) {
+ gchar *name = nullptr;
+ gtk_tree_model_get (GTK_TREE_MODEL(list->store), &iter, ATTR_COL_NAME, &name, -1);
+ g_signal_emit_by_name(G_OBJECT (list), "attr-value-edited", name, new_value );
+ }
+}
+
+gboolean
+attr_key_pressed(GtkWidget *attributes, GdkEventKey *event, gpointer /*data*/)
+{
+ GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(attributes));
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ gchar *name = nullptr;
+ if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
+ gtk_tree_model_get (model, &iter, 0, &name, -1);
+
+ switch (event->keyval)
+ {
+ case GDK_KEY_Delete:
+ case GDK_KEY_KP_Delete:
+ g_signal_emit_by_name(G_OBJECT (attributes), "attr-value-edited", name, nullptr);
+ return true;
+ }
+ }
+ return false;
+}
+
+void
event_attr_changed (Inkscape::XML::Node * /*repr*/,
const gchar * name,
const gchar * /*old_value*/,
@@ -148,10 +194,8 @@ event_attr_changed (Inkscape::XML::Node * /*repr*/,
bool /*is_interactive*/,
gpointer data)
{
- gint row = -1;
- SPXMLViewAttrList * list;
-
- list = SP_XMLVIEW_ATTR_LIST (data);
+ gint row = -1;
+ SPXMLViewAttrList * list = SP_XMLVIEW_ATTR_LIST (data);
GtkTreeIter iter;
gboolean valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL(list->store), &iter );
@@ -171,18 +215,18 @@ event_attr_changed (Inkscape::XML::Node * /*repr*/,
}
}
- if (match) {
- if (new_value) {
- gtk_list_store_set (list->store, &iter, ATTR_COL_NAME, name, ATTR_COL_VALUE, new_value, ATTR_COL_ATTR, g_quark_from_string (name), -1);
- } else {
- gtk_list_store_remove (list->store, &iter);
- }
- } else if (new_value != nullptr) {
- gtk_list_store_append (list->store, &iter);
+ if (match) {
+ if (new_value) {
+ gtk_list_store_set (list->store, &iter, ATTR_COL_NAME, name, ATTR_COL_VALUE, new_value, ATTR_COL_ATTR, g_quark_from_string (name), -1);
+ } else {
+ gtk_list_store_remove (list->store, &iter);
+ }
+ } else if (new_value != nullptr) {
+ gtk_list_store_append (list->store, &iter);
gtk_list_store_set (list->store, &iter, ATTR_COL_NAME, name, ATTR_COL_VALUE, new_value, ATTR_COL_ATTR, g_quark_from_string (name), -1);
- }
+ }
- // send a "changed" signal so widget owners will know I've updated
- g_signal_emit_by_name(G_OBJECT (list), "row-value-changed", name );
+ // send a "changed" signal so widget owners will know I've updated
+ g_signal_emit_by_name(G_OBJECT (list), "row-value-changed", name );
}
diff --git a/src/widgets/sp-xmlview-attr-list.h b/src/widgets/sp-xmlview-attr-list.h
index 799dbe76a..1367b0628 100644
--- a/src/widgets/sp-xmlview-attr-list.h
+++ b/src/widgets/sp-xmlview-attr-list.h
@@ -21,17 +21,17 @@
struct SPXMLViewAttrList
{
- GtkTreeView list;
- GtkListStore *store;
+ GtkTreeView list;
+ GtkListStore *store;
- Inkscape::XML::Node * repr;
+ Inkscape::XML::Node * repr;
};
struct SPXMLViewAttrListClass
{
- GtkTreeViewClass parent_class;
+ GtkTreeViewClass parent_class;
- void (* row_changed) (SPXMLViewAttrList *list, gint row);
+ void (* row_changed) (SPXMLViewAttrList *list, gint row);
};
GType sp_xmlview_attr_list_get_type ();
@@ -41,6 +41,8 @@ GtkWidget * sp_xmlview_attr_list_new (Inkscape::XML::Node * repr);
void sp_xmlview_attr_list_set_repr (SPXMLViewAttrList * list, Inkscape::XML::Node * repr);
void sp_xmlview_attr_list_select_row_by_key(SPXMLViewAttrList * list, const gchar *name);
+void attr_value_edited (GtkCellRendererText *cell, gchar * path_string, gchar * new_value, gpointer data);
+gboolean attr_key_pressed(GtkWidget *attributes, GdkEventKey *event, gpointer data);
/* Attribute list store columns */
enum {ATTR_COL_NAME=0, ATTR_COL_ATTR=1, ATTR_COL_VALUE=2, ATTR_N_COLS=3 };
diff --git a/src/widgets/sp-xmlview-content.cpp b/src/widgets/sp-xmlview-content.cpp
deleted file mode 100644
index 6fc08c4ac..000000000
--- a/src/widgets/sp-xmlview-content.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Specialization of GtkTextView for the XML tree view
- *
- * Authors:
- * MenTaLguY <mental@rydia.net>
- *
- * Copyright (C) 2002 MenTaLguY
- * Abhishek Sharma
- *
- * Released under the GNU GPL; see COPYING for details
- */
-
-#include <cstring>
-#include <glibmm/i18n.h>
-
-#include "xml/node-event-vector.h"
-#include "sp-xmlview-content.h"
-#include "desktop.h"
-#include "document-private.h"
-#include "document-undo.h"
-#include "inkscape.h"
-#include "verbs.h"
-
-using Inkscape::DocumentUndo;
-
-static void sp_xmlview_content_destroy(GtkWidget * object);
-
-void sp_xmlview_content_changed (GtkTextBuffer *tb, SPXMLViewContent *text);
-
-static void event_content_changed (Inkscape::XML::Node * repr, const gchar * old_content, const gchar * new_content, gpointer data);
-
-static Inkscape::XML::NodeEventVector repr_events = {
- nullptr, /* child_added */
- nullptr, /* child_removed */
- nullptr, /* attr_changed */
- event_content_changed,
- nullptr /* order_changed */
-};
-
-GtkWidget *sp_xmlview_content_new(Inkscape::XML::Node * repr)
-{
- GtkTextBuffer *tb = gtk_text_buffer_new(nullptr);
- SPXMLViewContent *text = SP_XMLVIEW_CONTENT(g_object_new(SP_TYPE_XMLVIEW_CONTENT, nullptr));
- gtk_text_view_set_buffer (GTK_TEXT_VIEW (text), tb);
- gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text), GTK_WRAP_CHAR);
-
- g_signal_connect (G_OBJECT (tb), "changed", G_CALLBACK (sp_xmlview_content_changed), text);
-
- /* should we alter the scrolling adjustments here? */
-
- sp_xmlview_content_set_repr (text, repr);
-
- return GTK_WIDGET(text);
-}
-
-void
-sp_xmlview_content_set_repr (SPXMLViewContent * text, Inkscape::XML::Node * repr)
-{
- if ( repr == text->repr ) return;
- if (text->repr) {
- sp_repr_remove_listener_by_data (text->repr, text);
- Inkscape::GC::release(text->repr);
- }
- text->repr = repr;
- if (repr) {
- Inkscape::GC::anchor(repr);
- sp_repr_add_listener (repr, &repr_events, text);
- sp_repr_synthesize_events (repr, &repr_events, text);
- } else {
- gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (text)), "", 0);
- gtk_text_view_set_editable (GTK_TEXT_VIEW (text), FALSE);
- }
-}
-
-G_DEFINE_TYPE(SPXMLViewContent, sp_xmlview_content, GTK_TYPE_TEXT_VIEW);
-
-void sp_xmlview_content_class_init(SPXMLViewContentClass * klass)
-{
- auto widget_class = GTK_WIDGET_CLASS(klass);
- widget_class->destroy = sp_xmlview_content_destroy;
-}
-
-void
-sp_xmlview_content_init (SPXMLViewContent *text)
-{
- text->repr = nullptr;
- text->blocked = FALSE;
-}
-
-void sp_xmlview_content_destroy(GtkWidget * object)
-{
- SPXMLViewContent * text = SP_XMLVIEW_CONTENT (object);
-
- sp_xmlview_content_set_repr (text, nullptr);
-
- GTK_WIDGET_CLASS (sp_xmlview_content_parent_class)->destroy (object);
-}
-
-void
-event_content_changed (Inkscape::XML::Node * /*repr*/, const gchar * /*old_content*/, const gchar * new_content, gpointer data)
-{
- SPXMLViewContent * text;
- text = SP_XMLVIEW_CONTENT (data);
-
- if (text->blocked) return;
-
- text->blocked = TRUE;
-
- if (new_content) {
- gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (text)), new_content, strlen (new_content));
- } else {
- gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (text)), "", 0);
- }
- gtk_text_view_set_editable (GTK_TEXT_VIEW (text), new_content != nullptr);
-
- text->blocked = FALSE;
-}
-
-void
-sp_xmlview_content_changed (GtkTextBuffer *tb, SPXMLViewContent *text)
-{
- if (text->blocked) return;
-
- if (text->repr) {
- GtkTextIter start, end;
- gchar *data;
- text->blocked = TRUE;
- gtk_text_buffer_get_bounds (tb, &start, &end);
- data = gtk_text_buffer_get_text (tb, &start, &end, TRUE);
- text->repr->setContent(data);
- g_free (data);
- text->blocked = FALSE;
- DocumentUndo::done(SP_ACTIVE_DESKTOP->getDocument(), SP_VERB_DIALOG_XML_EDITOR,
- _("Type text in a text node"));
- }
-}
diff --git a/src/widgets/sp-xmlview-content.h b/src/widgets/sp-xmlview-content.h
deleted file mode 100644
index 962b80738..000000000
--- a/src/widgets/sp-xmlview-content.h
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef __SP_XMLVIEW_CONTENT_H__
-#define __SP_XMLVIEW_CONTENT_H__
-
-/*
- * Specialization of GtkTextView for editing XML node text
- *
- * Authors:
- * MenTaLguY <mental@rydia.net>
- *
- * Copyright (C) 2002 MenTaLguY
- *
- * Released under the GNU GPL; see COPYING for details
- */
-
-#include <config.h>
-#include <gtk/gtk.h>
-
-#define SP_TYPE_XMLVIEW_CONTENT (sp_xmlview_content_get_type ())
-#define SP_XMLVIEW_CONTENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_XMLVIEW_CONTENT, SPXMLViewContent))
-#define SP_IS_XMLVIEW_CONTENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_XMLVIEW_CONTENT))
-#define SP_XMLVIEW_CONTENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_XMLVIEW_CONTENT))
-
-struct SPXMLViewContent
-{
- GtkTextView textview;
-
- Inkscape::XML::Node * repr;
- gint blocked;
-};
-
-struct SPXMLViewContentClass
-{
- GtkTextViewClass parent_class;
-};
-
-GType sp_xmlview_content_get_type ();
-GtkWidget * sp_xmlview_content_new (Inkscape::XML::Node * repr);
-
-#define SP_XMLVIEW_CONTENT_GET_REPR(text) (SP_XMLVIEW_CONTENT (text)->repr)
-
-void sp_xmlview_content_set_repr (SPXMLViewContent * text, Inkscape::XML::Node * repr);
-
-
-
-#endif