From eaaa2ab8ad52785c074e9fe3a9ba00f99b550695 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Sat, 29 Sep 2018 21:21:38 -0400 Subject: Remove css dialog from style dialog. --- src/ui/dialog/styledialog.cpp | 335 ------------------------------------------ 1 file changed, 335 deletions(-) (limited to 'src/ui/dialog/styledialog.cpp') diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp index d20bc7b1f..2b3f531c1 100644 --- a/src/ui/dialog/styledialog.cpp +++ b/src/ui/dialog/styledialog.cpp @@ -310,27 +310,6 @@ StyleDialog::StyleDialog() : sigc::mem_fun(*this, &StyleDialog::_buttonEventsSelectObjs), false); - //_treeView.get_selection()->signal_changed().connect( - // sigc::mem_fun(*this, &StyleDialog::_selChanged)); - - _objObserver.signal_changed().connect(sigc::mem_fun(*this, &StyleDialog::_objChanged)); - - - // Add CSS dialog - _cssPane = new CssDialog; - _paned.pack2(*_cssPane, Gtk::SHRINK); - _cssPane->show_all(); - - /*_cssPane->_propRenderer->signal_edited().connect( - sigc::mem_fun(*this, &StyleDialog::_handleProp)); - _cssPane->_sheetRenderer->signal_edited().connect( - sigc::mem_fun(*this, &StyleDialog::_handleSheet)); - _cssPane->_attrRenderer->signal_edited().connect( - sigc::mem_fun(*this, &StyleDialog::_handleAttr)); - _cssPane->_treeView.signal_button_release_event().connect( - sigc::mem_fun(*this, &StyleDialog::_delProperty), - false);*/ - // Document & Desktop _desktop_changed_connection = _desktopTracker.connectDesktopChanged( sigc::mem_fun(*this, &StyleDialog::_handleDesktopChanged) ); @@ -1066,112 +1045,6 @@ private: // ------------------------------------------------------------------- -/** - * @brief StyleDialog::_updateCSSPanel - * Updates CSS panel according to row in Style panel. - */ -void StyleDialog::_updateCSSPanel() -{ - // This should probably be in a member function of CSSDialog. -#ifdef DEBUG_STYLEDIALOG - std::cout << "StyleDialog::_updateCSSPanel" << std::endl; -#endif - _updating = true; - - _cssPane->_store->clear(); - - Glib::RefPtr refTreeSelection = _treeView.get_selection(); - Gtk::TreeModel::iterator iter = refTreeSelection->get_selected(); - if (iter) { - Gtk::TreeModel::Row row = *iter; - Glib::ustring properties; - Glib::ustring sheet; - Glib::ustring attr; - if (row[_mColumns._colIsSelector]) { - //_cssPane->_propRenderer->property_editable() = true; - //_cssPane->_sheetRenderer->property_editable() = true; - //_cssPane->_sheetRenderer->property_foreground_rgba() = Gdk::RGBA("black"); - //_cssPane->_attrRenderer->property_editable() = false; - //_cssPane->_buttonAddProperty.set_sensitive(true); - - properties = row[_mColumns._colProperties]; - sheet = row[_mColumns._colProperties]; - _objObserver.set( nullptr ); - } else { - //_cssPane->_propRenderer->property_editable() = false; - //_cssPane->_sheetRenderer->property_editable() = false; - //_cssPane->_sheetRenderer->property_foreground_rgba() = Gdk::RGBA("gray"); - //_cssPane->_attrRenderer->property_editable() = false; // false for now... - //_cssPane->_buttonAddProperty.set_sensitive(false); - - std::vector objects = row[_mColumns._colObj]; - Gtk::TreeModel::iterator piter = row.parent(); - if (piter) { - Gtk::TreeModel::Row prow = *piter; - sheet = prow[_mColumns._colProperties]; - } - _objObserver.set( objects[0] ); - if (objects[0] && objects[0]->getAttribute("style") != nullptr) { - properties = objects[0]->getAttribute("style"); - attr = objects[0]->getAttribute("style"); - } - } - REMOVE_SPACES(properties); // Remove leading/trailing spaces - - std::map propMap; - - std::vector sheetList = Glib::Regex::split_simple("\\s*;\\s*", sheet); - for (auto& token: sheetList) { - - if (token.empty()) break; - - std::vector pair = - Glib::Regex::split_simple("\\s*:\\s*", token); - if( pair.size() > 1) { - PropertyData temp( pair[0] ); - temp._setSheetValue( pair[1] ); - propMap[pair[0]] = temp; - } - } - - std::vector attrList = Glib::Regex::split_simple("\\s*;\\s*", attr); - for (auto& token: attrList) { - - if (token.empty()) break; - - std::vector pair = - Glib::Regex::split_simple("\\s*:\\s*", token); - - if( pair.size() > 1) { - auto it = propMap.find(pair[0]); - if (it != propMap.end()) { - (*it).second._setAttrValue( pair[1] ); - } else { - PropertyData temp(pair[0]); - temp._setAttrValue( pair[1] ); - propMap[pair[0]] = temp; - } - } - } - - for (auto it : propMap) { - // std::cout << " " << it.first - // << " " << it.second._getName() - // << " " << it.second._getSheetValue() - // << " " << it.second._getAttrValue() - // << std::endl; - _cssPane->_propRow = *(_cssPane->_store->append()); - _cssPane->_propRow[_cssPane->_cssColumns.deleteButton] = false; - _cssPane->_propRow[_cssPane->_cssColumns.label] = it.second._getName(); - _cssPane->_propRow[_cssPane->_cssColumns._styleSheetVal] = it.second._getSheetValue(); - _cssPane->_propRow[_cssPane->_cssColumns._styleAttrVal ] = it.second._getAttrValue(); - } - } - - _updating = false; -} - - /** * Handle document replaced. (Happens when a default document is immediately replaced by another * document in a new window.) @@ -1257,13 +1130,6 @@ void StyleDialog::_buttonEventsSelectObjs(GdkEventButton* event ) int x = static_cast(event->x); int y = static_cast(event->y); _selectObjects(x, y); - //} - //else if (event->type == GDK_2BUTTON_PRESS && event->button == 1) { - //int x = static_cast(event->x); - //int y = static_cast(event->y); - //_selectObjects(x, y); - - _updateCSSPanel(); } _updating = false; } @@ -1297,7 +1163,6 @@ void StyleDialog::_selectRow() for (auto & i : objVec) { if (obj->getId() == i->getId()) { _treeView.get_selection()->select(row); - _updateCSSPanel(); return; } } @@ -1306,206 +1171,6 @@ void StyleDialog::_selectRow() // Selection empty or no row matches. _treeView.get_selection()->unselect_all(); - _updateCSSPanel(); -} - - -void StyleDialog::_objChanged() { -#ifdef DEBUG_STYLEDIALOG - std::cout << "StyleDialog::_objChanged" << std::endl; -#endif - if (_updating) return; - _updateCSSPanel(); -} - - -/** - * @brief StyleDialog::_handleProp - * @param path - * @param new_text - * Called when new text is entered into a "prop" cell.. - */ -void StyleDialog::_handleProp(const Glib::ustring& path, const Glib::ustring& new_text) -{ -#ifdef DEBUG_STYLEDIALOG - std::cout << "StyleDialog::_handleProp: path: " << path - << " new_text: " << new_text << std::endl; -#endif - - Gtk::TreeModel::iterator iterCss = _cssPane->_treeView.get_model()->get_iter(path); - if (iterCss) { - Gtk::TreeModel::Row row = *iterCss; - row[_cssPane->_cssColumns.label] = new_text; - } - - // To do: validate. -} - -/** - * @brief StyleDialog::_handleSheet - * @param path - * @param new_text - * Called when new text is entered into a "sheet" cell.. - */ -void StyleDialog::_handleSheet(const Glib::ustring& path, const Glib::ustring& new_text) -{ -#ifdef DEBUG_STYLEDIALOG - std::cout << "StyleDialog::_handleSheet: path: " << path - << " new_text: " << new_text << std::endl; -#endif - - Gtk::TreeModel::iterator iterCss = _cssPane->_treeView.get_model()->get_iter(path); - if (iterCss) { - Gtk::TreeModel::Row row = *iterCss; - row[_cssPane->_cssColumns._styleSheetVal] = new_text; - } - - // To do: validate (run through style.read()/style.write()?). - - Glib::ustring properties; - for (auto& crow: _cssPane->_store->children()) { - properties = properties + - crow[_cssPane->_cssColumns.label] + ": " + - crow[_cssPane->_cssColumns._styleSheetVal] + "; "; - } - - // Update selector data. - Glib::RefPtr refTreeSelection = _treeView.get_selection(); - Gtk::TreeModel::iterator iter = refTreeSelection->get_selected(); - if (iter) { - Gtk::TreeModel::Row row = *iter; - row[_mColumns._colProperties] = properties; - _writeStyleElement(); - } -} - -/** - * @brief StyleDialog::_handleAttr - * @param path - * @param new_text - * Called when new text is entered into an "attr" cell.. - */ -void StyleDialog::_handleAttr(const Glib::ustring& path, const Glib::ustring& new_text) -{ -#ifdef DEBUG_STYLEDIALOG - std::cout << "StyleDialog::_handleAttr: path: " << path - << " new_text: " << new_text << std::endl; -#endif - - Gtk::TreeModel::iterator iterCss = _cssPane->_treeView.get_model()->get_iter(path); - if (iterCss) { - Gtk::TreeModel::Row row = *iterCss; - row[_cssPane->_cssColumns._styleAttrVal] = new_text; - } - - // To do: validate (run through style.read()/style.write()?). - - Glib::ustring properties; - for (auto& crow: _cssPane->_store->children()) { - properties = properties + - crow[_cssPane->_cssColumns.label] + ": "; - crow[_cssPane->_cssColumns._styleAttrVal] + "; "; - } - - std::cout << "StyleDialog::_handlerAttr(): Unimplemented write." << std::endl; -} - -/** - * @brief StyleDialog::_delProperty - * @param event - * @return - * Delete a property from the CSS dialog and then update trees. - */ -bool StyleDialog::_delProperty(GdkEventButton *event) -{ -#ifdef DEBUG_STYLEDIALOG - std::cout << "StyleDialog::_delProperty" << std::endl; -#endif - - if (event->type == GDK_BUTTON_RELEASE && event->button == 1) { - Gtk::TreeViewColumn *col = nullptr; - Gtk::TreeModel::Path path; - int x = static_cast(event->x); - int y = static_cast(event->y); - int x2 = 0; - int y2 = 0; - Gtk::TreeModel::Row cssRow; - Glib::ustring toDelProperty; - if (_cssPane->_treeView.get_path_at_pos(x, y, path, col, x2, y2)) { - if (col == _cssPane->_treeView.get_column(0)) { - Gtk::TreeModel::iterator cssIter = - _cssPane->_treeView.get_selection()->get_selected(); - if (cssIter) { - - Gtk::TreeModel::Row cssRow = *cssIter; - - // Update selector data. - Glib::RefPtr refTreeSelection = _treeView.get_selection(); - Gtk::TreeModel::iterator iter = refTreeSelection->get_selected(); - if (iter) { - - Gtk::TreeModel::Row row = *iter; - - if ( row[_mColumns._colIsSelector]) { - - // We only care about style sheet for selectors so erase row in CSS pane. - _cssPane->_store->erase(cssIter); - - // Update style sheet - Glib::ustring properties; - for (auto& crow: _cssPane->_store->children()) { - Glib::ustring sheetVal = crow[_cssPane->_cssColumns._styleSheetVal]; - if (!sheetVal.empty()) { - properties = properties + - crow[_cssPane->_cssColumns.label] + ": " + - crow[_cssPane->_cssColumns._styleSheetVal] + "; "; - } - } - - row[_mColumns._colProperties] = properties; - _writeStyleElement(); - - } else { - - // We only erase row if style sheet does not contain deleted property. - // Otherwise we set style attr value to empty string. - Gtk::TreeModel::Row cssRow = *cssIter; - Glib::ustring val = cssRow[_cssPane->_cssColumns._styleSheetVal]; - if (val.empty()) { - _cssPane->_store->erase(cssIter); - } else { - cssRow[_cssPane->_cssColumns._styleAttrVal] = Glib::ustring(); - } - - // Update style attribute - std::vector objects = row[_mColumns._colObj]; - Glib::ustring properties; - for (auto& crow: _cssPane->_store->children()) { - Glib::ustring attrVal = crow[_cssPane->_cssColumns._styleAttrVal]; - if (!attrVal.empty()) { - properties = properties + - crow[_cssPane->_cssColumns.label] + ": " + - crow[_cssPane->_cssColumns._styleAttrVal] + "; "; - } - } - - if (objects[0]) { - if (properties.empty()) { - objects[0]->setAttribute("style", nullptr); - } else { - objects[0]->setAttribute("style", properties); - } - DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_STYLE, - _("Deleted property from style attribute.")); - - } - } - } - } - } - } - } - return false; } -- cgit v1.2.3