diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/selection-chemistry.cpp | 52 | ||||
| -rw-r--r-- | src/ui/clipboard.cpp | 7 | ||||
| -rw-r--r-- | src/ui/dialog/symbols.cpp | 128 | ||||
| -rw-r--r-- | src/ui/dialog/symbols.h | 5 | ||||
| -rw-r--r-- | src/ui/widget/dock-item.cpp | 7 | ||||
| -rw-r--r-- | src/ui/widget/imagetoggler.cpp | 11 | ||||
| -rw-r--r-- | src/ui/widget/page-sizer.cpp | 53 | ||||
| -rw-r--r-- | src/ui/widget/page-sizer.h | 22 |
8 files changed, 175 insertions, 110 deletions
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index efc378845..b18cea034 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -3149,17 +3149,35 @@ void ObjectSet::toSymbol() // Create new <symbol> Inkscape::XML::Node *defsrepr = doc->getDefs()->getRepr(); Inkscape::XML::Node *symbol_repr = xml_doc->createElement("svg:symbol"); + Inkscape::XML::Node *title_repr = xml_doc->createElement("svg:title"); + defsrepr->appendChild(symbol_repr); - + bool settitle = false; // For a single group, copy relevant attributes. if( single_group ) { + Glib::ustring id = the_group->getAttribute("id"); symbol_repr->setAttribute("style", the_group->getAttribute("style")); - symbol_repr->setAttribute("title", the_group->getAttribute("title")); - if (!the_group->getAttribute("title")) { - symbol_repr->setAttribute("title", _("Symbol without title")); + + gchar * title = the_group->title(); + if (title) { + symbol_repr->appendChild(title_repr); + title_repr->appendChild(xml_doc->createTextNode(title)); + title_repr->setPosition(0); + Inkscape::GC::release(title_repr); + } + g_free(title); + + gchar * desc = the_group->desc(); + if (desc) { + Inkscape::XML::Node *desc_repr = xml_doc->createElement("svg:desc"); + desc_repr->setContent(desc); + desc_repr->appendChild(xml_doc->createTextNode(desc)); + symbol_repr->appendChild(desc_repr); + desc_repr->setPosition(1); + Inkscape::GC::release(desc_repr); } + g_free(desc); symbol_repr->setAttribute("class", the_group->getAttribute("class")); - Glib::ustring id = the_group->getAttribute("id"); the_group->setAttribute("id", id + "_transform"); symbol_repr->setAttribute("id", id); @@ -3176,9 +3194,27 @@ void ObjectSet::toSymbol() // Move selected items to new <symbol> for (std::vector<SPObject*>::const_reverse_iterator i=items_.rbegin();i!=items_.rend();++i){ - Inkscape::XML::Node *repr = (*i)->getRepr(); - repr->parent()->removeChild(repr); - symbol_repr->addChild(repr,NULL); + gchar* title = (*i)->title(); + if (!single_group && !settitle && title) { + symbol_repr->appendChild(title_repr); + title_repr->appendChild(xml_doc->createTextNode(title)); + title_repr->setPosition(0); + Inkscape::GC::release(title_repr); + gchar * desc = (*i)->desc(); + if (desc) { + Inkscape::XML::Node *desc_repr = xml_doc->createElement("svg:desc"); + desc_repr->appendChild(xml_doc->createTextNode(desc)); + symbol_repr->appendChild(desc_repr); + Inkscape::GC::release(desc_repr); + desc_repr->setPosition(1); + } + g_free(desc); + settitle = true; + } + g_free(title); + Inkscape::XML::Node *repr = (*i)->getRepr(); + repr->parent()->removeChild(repr); + symbol_repr->addChild(repr, NULL); } if( single_group && transform.isTranslation() ) { diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index dbeee644c..118d7ae1f 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -1049,9 +1049,12 @@ bool ClipboardManagerImpl::_pasteText(SPDesktop *desktop) SPCSSAttr *css = take_style_from_item(tc->text); for (int i = 0; i < nr_blocks; ++i) { - gchar const *w = sp_repr_css_property(css, "font-size", "40px"); - if (w) + gchar const *w = sp_repr_css_property(css, "font-size", "0px"); + + // Don't set font-size if it wasn't set. + if (w && strcmp(w, "0px") != 0) { sp_repr_css_set_property(te_selected_style[i], "font-size", w); + } } for (int i = 0; i < text.length(); ++i) diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 1fcede8f1..3a15813c1 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -25,6 +25,7 @@ #include "io/sys.h" #include "io/resource.h" +#include "display/cairo-utils.h" #include "ui/cache/svg_preview_cache.h" #include "ui/clipboard.h" #include "ui/icon-names.h" @@ -69,8 +70,8 @@ namespace Inkscape { namespace UI { namespace Dialog { -const Glib::ustring CURRENTDOC = _("Current Document"); -const Glib::ustring ALLDOCS = _("All symbols sets"); +const Glib::ustring CURRENTDOC = _("Current document"); +const Glib::ustring ALLDOCS = _("All symbol sets"); // See: http://developer.gnome.org/gtkmm/stable/classGtk_1_1TreeModelColumnRecord.html class SymbolColumns : public Gtk::TreeModel::ColumnRecord { @@ -102,6 +103,7 @@ SymbolColumns* SymbolsDialog::getColumns() SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : UI::Widget::Panel("", prefsPath, SP_VERB_DIALOG_SYMBOLS), store(Gtk::ListStore::create(*getColumns())), + all_docs_processed(0), icon_view(0), current_desktop(0), desk_track(), @@ -225,6 +227,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : #else table->attach(*Gtk::manage(scroller),0,row,2,1); #endif + previous_height = 0; ++row; /******************** Progress *******************************/ @@ -348,9 +351,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : // This might need to be a global variable so setTargetDesktop can modify it SPDefs *defs = current_document->getDefs(); -#if GTK_CHECK_VERSION(3,2,4) - overlay_opacity->set(getOverlay(overlay_opacity, "overlay", 1000)); -#endif + sigc::connection defsModifiedConn = defs->connectModified(sigc::mem_fun(*this, &SymbolsDialog::defsModified)); instanceConns.push_back(defsModifiedConn); @@ -431,6 +432,7 @@ void SymbolsDialog::rebuild() { SPDocument* symbol_document = selectedSymbols(); icons_found = false; //We are not in search all docs + if (search->get_text() != _("Searching...") && search->get_text() != _("Loading all symbols...") && search->get_text() != _("Searching....") ) @@ -448,41 +450,37 @@ void SymbolsDialog::showOverlay() { #if GTK_CHECK_VERSION(3,2,4) Glib::ustring current = Glib::Markup::escape_text(symbol_set->get_active_text()); overlay_icon->set_from_icon_name("none", iconsize); - if (current == ALLDOCS && - search->get_text() != _("Loading all symbols...") && - !l.size()) + if (current == ALLDOCS && !l.size()) { if (!all_docs_processed ) { overlay_icon->set_from_icon_name("searching", iconsize); - overlay_title->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"large\">") + Glib::ustring(_("Search in all symbol sets ...")) + Glib::ustring("</span>")); + overlay_title->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"large\">") + Glib::ustring(_("Search in all symbol sets...")) + Glib::ustring("</span>")); overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"small\">") + Glib::ustring(_("First search can be slow.")) + Glib::ustring("</span>")); } else if (!icons_found && !search_str.empty()) { overlay_title->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"large\">") + Glib::ustring(_("No results found")) + Glib::ustring("</span>")); overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"small\">") + Glib::ustring(_("Try a different search term.")) + Glib::ustring("</span>")); } else { overlay_icon->set_from_icon_name("searching", iconsize); - overlay_title->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"large\">") + Glib::ustring(_("Search in all symbol sets ...")) + Glib::ustring("</span>")); + overlay_title->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"large\">") + Glib::ustring(_("Search in all symbol sets...")) + Glib::ustring("</span>")); overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"small\">") + Glib::ustring(_("")) + Glib::ustring("</span>")); } - } else if (current == ALLDOCS && search->get_text() == _("Loading all symbols...")) { - if (!all_docs_processed) { - overlay_title->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"large\">") + Glib::ustring(_("Loading all symbol sets ...")) + Glib::ustring("</span>")); - overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"small\">")+ Glib::ustring(_("When run for the first time, search will be slow.\nPlease wait ...")) + Glib::ustring("</span>")); - overlay_icon->show(); - overlay_title->show(); - overlay_icon->set_from_icon_name("searching", iconsize); - overlay_desc->show(); - } } else if (!number_symbols && (current != CURRENTDOC || !search_str.empty())) { overlay_title->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"large\">") + Glib::ustring(_("No results found")) + Glib::ustring("</span>")); overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"small\">") + Glib::ustring(_("Try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("</span>")); } else if (!number_symbols && current == CURRENTDOC) { overlay_title->set_markup(Glib::ustring("<span foreground=\"#333333\"size=\"large\">") + Glib::ustring(_("No symbols found")) + Glib::ustring("</span>")); - overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"small\">") + Glib::ustring(_("No symbols in current document\nChoose a different symbol set\nor add a new symbol.")) + Glib::ustring("</span>")); + overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"small\">") + Glib::ustring(_("No symbols in current document.\nChoose a different symbol set\nor add a new symbol.")) + Glib::ustring("</span>")); } else if (!icons_found && !search_str.empty()) { overlay_title->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"large\">") + Glib::ustring(_("No results found")) + Glib::ustring("</span>")); - overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"small\">") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("</span>")); - } + overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"small\">") + Glib::ustring(_("Try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("</span>")); + } + gint width = scroller->get_allocated_width(); + gint height = scroller->get_allocated_height(); + if (previous_height != height) { + previous_height = height; + overlay_opacity->set_size_request(width, height); + overlay_opacity->set(getOverlay(width, height)); + } overlay_opacity->show(); overlay_icon->show(); overlay_title->show(); @@ -888,12 +886,17 @@ void SymbolsDialog::symbolsInDocRecursive (SPObject *r, std::map<Glib::ustring, return; } - if ( dynamic_cast<SPSymbol *>(r) && r->title()) { - Glib::ustring current = symbol_set->get_active_text(); - if (current == ALLDOCS) { - l[doc_title + r->title()] = std::make_pair(doc_title,dynamic_cast<SPSymbol *>(r)); + if ( dynamic_cast<SPSymbol *>(r)) { + if(r->title()) { + Glib::ustring current = symbol_set->get_active_text(); + if (current == ALLDOCS) { + l[doc_title + r->title()] = std::make_pair(doc_title,dynamic_cast<SPSymbol *>(r)); + } else { + l[r->title()] = std::make_pair(doc_title,dynamic_cast<SPSymbol *>(r)); + } } else { - l[r->title()] = std::make_pair(doc_title,dynamic_cast<SPSymbol *>(r)); + Glib::ustring id = r->getAttribute("id"); + l[Glib::ustring(_("Symbol without title ")) + id] = std::make_pair(doc_title,dynamic_cast<SPSymbol *>(r)); } } for (auto& child: r->children) { @@ -1030,7 +1033,7 @@ bool SymbolsDialog::callbackSymbols(){ } } } - if (symbol && (search_str.empty() || found || (search_str.empty() && !symbol_title_char))) { + if (symbol && (search_str.empty() || found)) { addSymbol( symbol, doc_title); icons_found = true; } @@ -1081,7 +1084,7 @@ bool SymbolsDialog::callbackAllSymbols(){ progress_bar->set_fraction(1.0); all_docs_processed = true; addSymbols(); - search->set_text("Searching...."); + search->set_text("Searching..."); return false; } return true; @@ -1154,16 +1157,17 @@ void SymbolsDialog::addSymbol( SPObject* symbol, Glib::ustring doc_title) { SymbolColumns* columns = getColumns(); gchar const *id = symbol->getRepr()->attribute("id"); - gchar const *title = symbol->title(); // From title element - if( !title ) { - title = id; - } + gchar * title = symbol->title(); // From title element if (doc_title.empty()) { doc_title = CURRENTDOC; } - Glib::ustring symbol_title = Glib::ustring(title) + Glib::ustring(" (") + doc_title + Glib::ustring(")"); + Glib::ustring symbol_title = ""; + if(title) { + symbol_title = Glib::ustring(title) + Glib::ustring(" (") + doc_title + Glib::ustring(")"); + } else { + symbol_title = Glib::ustring(_("Symbol without title ")) + Glib::ustring(id) + Glib::ustring(" (") + doc_title + Glib::ustring(")"); + } Glib::RefPtr<Gdk::Pixbuf> pixbuf = drawSymbol( symbol ); - if( pixbuf ) { Gtk::ListStore::iterator row = store->append(); (*row)[columns->symbol_id] = Glib::ustring( id ); @@ -1171,7 +1175,7 @@ void SymbolsDialog::addSymbol( SPObject* symbol, Glib::ustring doc_title) { (*row)[columns->symbol_doc_title] = Glib::Markup::escape_text(Glib::ustring( g_dpgettext2(NULL, "SymbolDoc", doc_title.c_str()) )); (*row)[columns->symbol_image] = pixbuf; } - + g_free(title); delete columns; } @@ -1185,7 +1189,7 @@ void SymbolsDialog::addSymbol( SPObject* symbol, Glib::ustring doc_title) { * the temporary document is rendered. */ Glib::RefPtr<Gdk::Pixbuf> -SymbolsDialog::drawSymbol(SPObject *symbol, unsigned force_psize) +SymbolsDialog::drawSymbol(SPObject *symbol) { // Create a copy repr of the symbol with id="the_symbol" Inkscape::XML::Document *xml_doc = preview_document->getReprDoc(); @@ -1263,11 +1267,6 @@ SymbolsDialog::drawSymbol(SPObject *symbol, unsigned force_psize) else scale = pow( 2.0, scale_factor/2.0 ) * psize / 32.0; - if (force_psize > 0) { - psize = force_psize; - scale = psize / ceil(std::max(width, height)); - } - pixbuf = Glib::wrap(render_pixbuf(renderDrawing, scale, *dbox, psize)); } @@ -1299,41 +1298,18 @@ SPDocument* SymbolsDialog::symbolsPreviewDoc() * Update image widgets */ Glib::RefPtr<Gdk::Pixbuf> -SymbolsDialog::getOverlay(Gtk::Image* image, gchar const * icon_title, unsigned psize) +SymbolsDialog::getOverlay(gint width, gint height) { -gchar const *buffer = -"<svg xmlns=\"http://www.w3.org/2000/svg\"" -" xmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\"" -" xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"" -" xmlns:xlink=\"http://www.w3.org/1999/xlink\">" -" <title>Inkscape</title> " -" <defs id=\"defs\">" -" <symbol" -" id=\"overlay\">" -" <title" -" id=\"overlay_title\">Overlay</title>" -" <desc" -" id=\"overlay_desc\">Overlay Square</desc>" -" <path" -" style=\"fill:#ffffff;opacity:0.75;stroke:none\"" -" d=\"M 0,1 H 1 V 2 H 0 Z\"" -" id=\"overlay_shape_1\" />" -" </symbol>" -" </defs>" -"</svg>"; - - SPDocument* doc = SPDocument::createNewDocFromMem( buffer, strlen(buffer), FALSE ); - std::map<Glib::ustring, std::pair<Glib::ustring, SPSymbol*> > symbols_data = symbolsInDoc(doc, "Overlay Doc"); - Glib::RefPtr<Gdk::Pixbuf> pixbuf(NULL); - for(auto data:symbols_data) { - Glib::ustring doc_title = data.second.first; - SPSymbol * symbol = data.second.second; - if (!strcmp(symbol->getId(), icon_title)) { - pixbuf = drawSymbol(symbol, psize); - return pixbuf; - } - } - return pixbuf; + cairo_surface_t *surface; + cairo_t *cr; + surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); + cr = cairo_create (surface); + cairo_set_source_rgba(cr, 1, 1, 1, 0.75); + cairo_rectangle (cr, 0, 0, width, height); + cairo_fill (cr); + GdkPixbuf* pixbuf = ink_pixbuf_create_from_cairo_surface(surface); + cairo_destroy (cr); + return Glib::wrap(pixbuf); } void SymbolsDialog::setTargetDesktop(SPDesktop *desktop) diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index f387dde51..6e49939af 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -102,8 +102,8 @@ private: void enableWidgets(bool enable); Glib::ustring ellipsize(Glib::ustring data, size_t limit); gchar const* styleFromUse( gchar const* id, SPDocument* document); - Glib::RefPtr<Gdk::Pixbuf> drawSymbol(SPObject *symbol, unsigned force_psize = 0); - Glib::RefPtr<Gdk::Pixbuf> getOverlay(Gtk::Image* image, gchar const * icon_title, unsigned psize); + Glib::RefPtr<Gdk::Pixbuf> drawSymbol(SPObject *symbol); + Glib::RefPtr<Gdk::Pixbuf> getOverlay(gint width, gint height); /* Keep track of all symbol template documents */ std::map<Glib::ustring, SPDocument*> symbol_sets; std::map<Glib::ustring, std::pair<Glib::ustring, SPSymbol*> > l; @@ -112,6 +112,7 @@ private: // Scale factor int scale_factor; bool sensitive; + double previous_height; bool all_docs_processed; size_t number_docs; size_t number_symbols; diff --git a/src/ui/widget/dock-item.cpp b/src/ui/widget/dock-item.cpp index 18ab70eb4..4a06163e1 100644 --- a/src/ui/widget/dock-item.cpp +++ b/src/ui/widget/dock-item.cpp @@ -45,7 +45,12 @@ DockItem::DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& l int width = 0; int height = 0; Gtk::IconSize::lookup(Gtk::ICON_SIZE_MENU, width, height); - _icon_pixbuf = iconTheme->load_icon(icon_name, width); + try { + _icon_pixbuf = iconTheme->load_icon(icon_name, width); + } + catch (const Gtk::IconThemeError& e) { + std::cerr << "DocItem::DocItem(): " << e.what() << std::endl; + } } if ( _icon_pixbuf ) { diff --git a/src/ui/widget/imagetoggler.cpp b/src/ui/widget/imagetoggler.cpp index a2783ecb1..38c84ca51 100644 --- a/src/ui/widget/imagetoggler.cpp +++ b/src/ui/widget/imagetoggler.cpp @@ -16,6 +16,8 @@ #include "widgets/toolbox.h" #include "ui/icon-names.h" +#include <iostream> + namespace Inkscape { namespace UI { namespace Widget { @@ -37,8 +39,13 @@ ImageToggler::ImageToggler( char const* on, char const* off) : int phys = width; Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default(); - _property_pixbuf_on = icon_theme->load_icon(_pixOnName, phys, (Gtk::IconLookupFlags)0); - _property_pixbuf_off = icon_theme->load_icon(_pixOffName, phys, (Gtk::IconLookupFlags)0); + try { + _property_pixbuf_on = icon_theme->load_icon(_pixOnName, phys, (Gtk::IconLookupFlags)0); + _property_pixbuf_off = icon_theme->load_icon(_pixOffName, phys, (Gtk::IconLookupFlags)0); + } + catch (const Gtk::IconThemeError& e) { + std::cerr << "ImageToggler::ImageToggler(): " << e.what() << std::endl; + } property_pixbuf() = _property_pixbuf_off.get_value(); } diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 06d54b682..7a3909975 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -219,7 +219,8 @@ PageSizer::PageSizer(Registry & _wr) _dimensionUnits( _("U_nits:"), "units", _wr ), _dimensionWidth( _("_Width:"), _("Width of paper"), "width", _dimensionUnits, _wr ), _dimensionHeight( _("_Height:"), _("Height of paper"), "height", _dimensionUnits, _wr ), - _marginLock( _("L_ock"), _("Lock margins"), "lock-margins", _wr ), + _marginLock( _("Loc_k margins"), _("Lock margins"), "lock-margins", _wr, false, NULL, NULL), + _lock_icon(), _marginTop( _("T_op margin:"), _("Top margin"), "fit-margin-top", _wr ), _marginLeft( _("L_eft:"), _("Left margin"), "fit-margin-left", _wr), _marginRight( _("Ri_ght:"), _("Right margin"), "fit-margin-right", _wr), @@ -249,7 +250,6 @@ PageSizer::PageSizer(Registry & _wr) _viewboxY.setDigits(2); _viewboxW.setDigits(2); _viewboxH.setDigits(2); - _dimensionWidth.setRange( 0.00001, 10000000 ); _dimensionHeight.setRange( 0.00001, 10000000 ); _scaleX.setRange( 0.00001, 100000 ); @@ -370,7 +370,6 @@ PageSizer::PageSizer(Registry & _wr) //## Set up margin settings _marginTable.set_border_width(4); - _marginTable.set_row_spacing(4); _marginTable.set_column_spacing(4); @@ -384,10 +383,19 @@ PageSizer::PageSizer(Registry & _wr) _marginLeft.set_hexpand(); _marginLeft.set_vexpand(); _marginTable.attach(_marginLeft, 0, 1, 1, 1); - + + _marginLock.set_active(false); _marginLock.set_halign(Gtk::ALIGN_CENTER); _marginLock.set_hexpand(); _marginLock.set_vexpand(); + + //_lock_icon = new Gtk::Image(); + _lock_icon.set_halign(Gtk::ALIGN_CENTER); + _lock_icon.set_valign(Gtk::ALIGN_START); + _lock_icon.set_from_icon_name("object-unlocked", Gtk::ICON_SIZE_LARGE_TOOLBAR); + _lock_icon.show(); + _marginLock.add(_lock_icon); + _marginTable.attach(_marginLock, 1, 1, 1, 1); _marginRight.set_halign(Gtk::ALIGN_CENTER); @@ -481,6 +489,7 @@ PageSizer::init () _changedvy_connection = _viewboxY.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_viewbox_changed)); _changedvw_connection = _viewboxW.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_viewbox_changed)); _changedvh_connection = _viewboxH.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_viewbox_changed)); + _changedlk_connection = _marginLock.signal_toggled().connect (sigc::mem_fun (*this, &PageSizer::on_margin_lock_changed)); _changedmt_connection = _marginTop.signal_value_changed().connect (sigc::bind<RegisteredScalar*>(sigc::mem_fun (*this, &PageSizer::on_margin_changed), &_marginTop)); _changedmb_connection = _marginBottom.signal_value_changed().connect (sigc::bind<RegisteredScalar*>(sigc::mem_fun (*this, &PageSizer::on_margin_changed), &_marginBottom)); _changedml_connection = _marginLeft.signal_value_changed().connect (sigc::bind<RegisteredScalar*>(sigc::mem_fun (*this, &PageSizer::on_margin_changed), &_marginLeft)); @@ -903,21 +912,45 @@ PageSizer::on_viewbox_changed() } } -/** - * Callback for viewbox widgets - */ +void +PageSizer::on_margin_lock_changed() +{ + if (_marginLock.get_active()) { + _lock_icon.set_from_icon_name("object-locked", Gtk::ICON_SIZE_LARGE_TOOLBAR); + double left = _marginLeft.getValue(); + double right = _marginRight.getValue(); + double top = _marginTop.getValue(); + double bottom = _marginBottom.getValue(); + if (Geom::are_near(left,right)) { + if (Geom::are_near(left, top)) { + on_margin_changed(&_marginBottom); + } else { + on_margin_changed(&_marginTop); + } + } else { + if (Geom::are_near(left, top)) { + on_margin_changed(&_marginRight); + } else { + on_margin_changed(&_marginLeft); + } + } + } else { + _lock_icon.set_from_icon_name("object-unlocked", Gtk::ICON_SIZE_LARGE_TOOLBAR); + } +} + void PageSizer::on_margin_changed(RegisteredScalar* widg) { double value = widg->getValue(); if (_widgetRegistry->isUpdating()) return; - if (_marginLock.get_active() && !_marginLocked) { - _marginLocked = true; + if (_marginLock.get_active() && !_lockMarginUpdate) { + _lockMarginUpdate = true; _marginLeft.setValue(value); _marginRight.setValue(value); _marginTop.setValue(value); _marginBottom.setValue(value); - _marginLocked = false; + _lockMarginUpdate = false; } } diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index 7cf8bacfd..29cd204b9 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -166,6 +166,9 @@ public: * Updates the margin widgets. If lock widget is active */ void on_margin_changed(RegisteredScalar* widg); + + void on_margin_lock_changed(); + /** * Updates the scale widgets. (Just changes the values of the ui widgets.) */ @@ -229,15 +232,15 @@ protected: //### Fit Page options Gtk::Expander _fitPageMarginExpander; - Gtk::Grid _marginTable; - RegisteredCheckButton _marginLock; - RegisteredScalar _marginTop; - RegisteredScalar _marginLeft; - RegisteredScalar _marginRight; - RegisteredScalar _marginBottom; - Gtk::Button _fitPageButton; - bool _lockMarginUpdate; - bool _marginLocked; + Gtk::Grid _marginTable; + RegisteredToggleButton _marginLock; + Gtk::Image _lock_icon; + RegisteredScalar _marginTop; + RegisteredScalar _marginLeft; + RegisteredScalar _marginRight; + RegisteredScalar _marginBottom; + Gtk::Button _fitPageButton; + bool _lockMarginUpdate; // Document scale Gtk::Frame _scaleFrame; @@ -271,6 +274,7 @@ protected: sigc::connection _changedvy_connection; sigc::connection _changedvw_connection; sigc::connection _changedvh_connection; + sigc::connection _changedlk_connection; sigc::connection _changedmt_connection; sigc::connection _changedmb_connection; sigc::connection _changedml_connection; |
