Commit 99648a41 authored by Jabier Arraiza's avatar Jabier Arraiza

Move XMLDialog and Attributes Dialog to Gtk::Paned

parent 444263ab
Pipeline #65580335 passed with stages
in 118 minutes and 57 seconds
......@@ -317,27 +317,32 @@
color: @theme_fg_color;
}
#XMLDialogAndAttribuesDialog,
#SelectorsAndStyleDialog{
min-height:200px;
min-width:250px;
}
#XMLAndAttributesDialog button,
#SelectorsAndStyleDialog button{
padding:4px;
min-height:16px;
margin:2px;
}
#XMLAndAttributesDialog .directiontoggler image,
#XMLAndAttributesDialog .stylesheettoggler image,
#SelectorsAndStyleDialog .directiontoggler image,
#SelectorsAndStyleDialog .stylesheettoggler image {
color: transparent;
}
#XMLAndAttributesDialog .directiontoggler,
#XMLAndAttributesDialog .stylesheettoggler,
#SelectorsAndStyleDialog .directiontoggler,
#SelectorsAndStyleDialog .stylesheettoggler {
margin:2px;
}
#XMLAndAttributesDialog .toggle,
#SelectorsAndStyleDialog .toggle {
min-width: 18px;
padding-left: 6px;
......
......@@ -137,6 +137,8 @@ AttrDialog::AttrDialog()
setDesktop(getDesktop());
}
/**
* @brief AttrDialog::~AttrDialog
* Class destructor
......
......@@ -361,7 +361,7 @@ void SelectorsDialog::_showWidgets()
_selectors_box.pack_start(_scrolled_window_selectors, Gtk::PACK_EXPAND_WIDGET);
_scrolled_window_selectors.add(_treeView);
_scrolled_window_selectors.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
Gtk::Label *dirogglerlabel = Gtk::manage(new Gtk::Label(_("Paned vertical")));
Gtk::Label *dirtogglerlabel = Gtk::manage(new Gtk::Label(_("Paned vertical")));
_direction.property_active().signal_changed().connect(sigc::mem_fun(*this, &SelectorsDialog::_toggleDirection));
_direction.get_style_context()->add_class("directiontoggler");
_styleButton(_create, "list-add", "Add a new CSS Selector");
......@@ -370,7 +370,7 @@ void SelectorsDialog::_showWidgets()
_button_box.pack_start(_create, Gtk::PACK_SHRINK);
_button_box.pack_start(_del, Gtk::PACK_SHRINK);
_button_box.pack_start(_direction, Gtk::PACK_SHRINK);
_button_box.pack_start(*dirogglerlabel, Gtk::PACK_SHRINK);
_button_box.pack_start(*dirtogglerlabel, Gtk::PACK_SHRINK);
_selectors_box.pack_end(_button_box, Gtk::PACK_SHRINK);
_del.signal_clicked().connect(sigc::mem_fun(*this, &SelectorsDialog::_delSelector));
_del.hide();
......
......@@ -73,8 +73,8 @@ XmlTree::XmlTree() :
if (!desktop) {
return;
}
flowbox_content = Gtk::manage(new Inkscape::UI::Widget::InkFlowBox("XMLFlow"));
Gtk::Box *contents = _getContents();
contents->set_name("XMLAndAttributesDialog");
contents->set_spacing(0);
contents->set_size_request(320, 260);
......@@ -84,16 +84,15 @@ XmlTree::XmlTree() :
status.set_markup("");
status.set_line_wrap(true);
status_box.pack_start( status, TRUE, TRUE, 0);
contents->pack_start(*flowbox_content, true, true, 0);
status_box.pack_start(_direction, Gtk::PACK_SHRINK);
contents->pack_start(_paned, true, true, 0);
_message_stack = std::make_shared<Inkscape::MessageStack>();
_message_context = std::unique_ptr<Inkscape::MessageContext>(new Inkscape::MessageContext(_message_stack));
_message_changed_connection = _message_stack->connectChanged(
sigc::bind(sigc::ptr_fun(_set_status_message), GTK_WIDGET(status.gobj())));
/* tree view */
flowbox_content->insert(&node_box, _("_Nodes"), FLOWBOX_PAGE_NODES, true, -1);
tree = SP_XMLVIEW_TREE(sp_xmlview_tree_new(nullptr, nullptr, nullptr));
gtk_widget_set_tooltip_text( GTK_WIDGET(tree), _("Drag to reorder nodes") );
......@@ -173,12 +172,27 @@ XmlTree::XmlTree() :
node_box.pack_start(*tree_scroller);
node_box.pack_end(status_box, false, false, 2);
/* attributes */
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool attrtoggler = prefs->getBool("/dialogs/xml/attrtoggler", true);
attributes = new AttrDialog;
attr_box.pack_start(*attributes);
flowbox_content->insert(&attr_box, _("_Attributes"), FLOWBOX_PAGE_ATTRS, false, 200);
_paned.set_orientation(attrtoggler ? Gtk::ORIENTATION_VERTICAL : Gtk::ORIENTATION_HORIZONTAL);
_paned.pack1(node_box, Gtk::SHRINK);
/* attributes */
Gtk::Box *actionsbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
Gtk::Label *attrtogglerlabel = Gtk::manage(new Gtk::Label(_("Show attributes")));
_attrswitch.property_active() = attrtoggler;
_attrswitch.property_active().signal_changed().connect(sigc::mem_fun(*this, &XmlTree::_attrtoggler));
_attrswitch.get_style_context()->add_class("directiontoggler");
_dirtogglerlabel = Gtk::manage(new Gtk::Label(_("Paned vertical")));
_direction.property_active().signal_changed().connect(sigc::mem_fun(*this, &XmlTree::_toggleDirection));
_direction.get_style_context()->add_class("directiontoggler");
actionsbox->pack_start(_attrswitch, Gtk::PACK_SHRINK);
actionsbox->pack_start(*attrtogglerlabel, Gtk::PACK_SHRINK);
actionsbox->pack_start(_direction, Gtk::PACK_SHRINK);
actionsbox->pack_start(*_dirtogglerlabel, Gtk::PACK_SHRINK);
_paned.pack2(*attributes, true, true);
contents->pack_start(*actionsbox, true, true, 0);
/* 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);
......@@ -198,6 +212,12 @@ XmlTree::XmlTree() :
/* initial show/hide */
show_all();
if (attrtoggler) {
attributes->hide();
_dirtogglerlabel->hide();
_direction.hide();
_paned.set_position(9999999);
}
tree_reset_context();
g_assert(desktop != nullptr);
......@@ -205,6 +225,33 @@ XmlTree::XmlTree() :
}
void XmlTree::_toggleDirection()
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool dir = !prefs->getBool("/dialogs/xml/updown", true);
prefs->setBool("/dialogs/xml/updown", dir);
_paned.set_position(-1);
_paned.set_orientation(dir ? Gtk::ORIENTATION_VERTICAL : Gtk::ORIENTATION_HORIZONTAL);
}
void XmlTree::_attrtoggler()
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool attrtoggler = !prefs->getBool("/dialogs/xml/attrtoggler", true);
prefs->setBool("/dialogs/xml/attrtoggler", attrtoggler);
if (prefs->getBool("/dialogs/xml/attrtoggler", true)) {
_attrbox->hide();
_dirtogglerlabel->hide();
_direction.hide();
_paned.set_position(9999999);
} else {
_attrbox->show();
_dirtogglerlabel->show();
_direction.show();
_paned.set_position(-1);
}
}
void XmlTree::present()
{
set_tree_select(get_dt_select());
......
......@@ -15,13 +15,13 @@
#include <memory>
#include "ui/widget/ink-flow-box.h"
#include "ui/widget/panel.h"
#include <gtkmm/button.h>
#include <gtkmm/entry.h>
#include <gtkmm/paned.h>
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/separatortoolitem.h>
#include <gtkmm/switch.h>
#include <gtkmm/textview.h>
#include <gtkmm/toolbar.h>
......@@ -165,7 +165,8 @@ private:
void cmd_unindent_node();
void present() override;
void _attrtoggler();
void _toggleDirection();
bool in_dt_coordsys(SPObject const &item);
/**
......@@ -178,13 +179,6 @@ private:
*/
gint blocked;
/* Each of the notebook page type (by number) */
UI::Widget::InkFlowBox *flowbox_content;
enum {
FLOWBOX_PAGE_NODES,
FLOWBOX_PAGE_ATTRS,
};
/**
* Status bar
*/
......@@ -212,14 +206,18 @@ private:
SPXMLViewTree *tree;
//SPXMLViewAttrList *attributes;
AttrDialog *attributes;
Gtk::Box *_attrbox;
/* XML Node Creation pop-up window */
Gtk::Entry *name_entry;
Gtk::Button *create_button;
Gtk::Paned _paned;
Gtk::VBox node_box;
Gtk::VBox attr_box;
Gtk::HBox status_box;
Gtk::Switch _attrswitch;
Gtk::Switch _direction;
Gtk::Label *_dirtogglerlabel;
Gtk::Label status;
Gtk::Toolbar tree_toolbar;
Gtk::ToolButton xml_element_new_button;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment