From 1636c1dd1651780d01759676b194312529f211f7 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Sat, 25 Jun 2016 22:24:26 +0200 Subject: Moved next functions, added namespace, renamed range functions (bzr r14954.1.10) --- src/ui/clipboard.cpp | 6 +++--- src/ui/dialog/align-and-distribute.cpp | 16 ++++++++-------- src/ui/dialog/clonetiler.cpp | 8 ++++---- src/ui/dialog/export.cpp | 14 +++++++------- src/ui/dialog/filter-effects-dialog.cpp | 6 +++--- src/ui/dialog/find.cpp | 2 +- src/ui/dialog/glyphs.cpp | 4 ++-- src/ui/dialog/grid-arrange-tab.cpp | 12 ++++++------ src/ui/dialog/icon-preview.cpp | 2 +- src/ui/dialog/objects.cpp | 2 +- src/ui/dialog/pixelartdialog.cpp | 2 +- src/ui/dialog/polar-arrange-tab.cpp | 2 +- src/ui/dialog/svg-fonts-dialog.cpp | 4 ++-- src/ui/dialog/swatches.cpp | 2 +- src/ui/dialog/tags.cpp | 4 ++-- src/ui/dialog/text-edit.cpp | 6 +++--- src/ui/dialog/transformation.cpp | 14 +++++++------- src/ui/interface.cpp | 2 +- src/ui/tools/connector-tool.cpp | 2 +- src/ui/tools/eraser-tool.cpp | 4 ++-- src/ui/tools/gradient-tool.cpp | 14 +++++++------- src/ui/tools/lpe-tool.cpp | 2 +- src/ui/tools/mesh-tool.cpp | 12 ++++++------ src/ui/tools/node-tool.cpp | 4 ++-- src/ui/tools/select-tool.cpp | 2 +- src/ui/tools/spray-tool.cpp | 10 +++++----- src/ui/tools/tool-base.cpp | 2 +- src/ui/tools/tweak-tool.cpp | 6 +++--- src/ui/widget/style-subject.cpp | 2 +- 29 files changed, 84 insertions(+), 84 deletions(-) (limited to 'src/ui') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index d581dbf7e..b1a946db2 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -522,7 +522,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a // resize each object in the selection if (separately) { - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (item) { @@ -578,7 +578,7 @@ bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop) desktop->doc()->importDefs(tempdoc); // make sure all selected items are converted to paths first (i.e. rectangles) sp_selected_to_lpeitems(desktop); - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; _applyPathEffect(item, effectstack); @@ -661,7 +661,7 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop) void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) { // copy the defs used by all items - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); cloned_elements.clear(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 8f87932b8..b7b5b96cd 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -133,7 +133,7 @@ void ActionAlign::do_action(SPDesktop *desktop, int index) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool sel_as_group = prefs->getBool("/dialogs/align/sel-as-groups"); - std::vector selected(selection->itemList()); + std::vector selected(selection->items()); if (selected.empty()) return; const Coeffs &a = _allCoeffs[index]; @@ -293,7 +293,7 @@ private : Inkscape::Selection *selection = desktop->getSelection(); if (!selection) return; - std::vector selected(selection->itemList()); + std::vector selected(selection->items()); if (selected.empty()) return; //Check 2 or more selected objects @@ -499,7 +499,7 @@ private : // xGap and yGap are the minimum space required between bounding rectangles. double const xGap = removeOverlapXGap.get_value(); double const yGap = removeOverlapYGap.get_value(); - removeoverlap(_dialog.getDesktop()->getSelection()->itemList(), xGap, yGap); + removeoverlap(_dialog.getDesktop()->getSelection()->items(), xGap, yGap); // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); @@ -530,7 +530,7 @@ private : int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); - graphlayout(_dialog.getDesktop()->getSelection()->itemList()); + graphlayout(_dialog.getDesktop()->getSelection()->items()); // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); @@ -590,7 +590,7 @@ private : Inkscape::Selection *selection = desktop->getSelection(); if (!selection) return; - std::vector selected(selection->itemList()); + std::vector selected(selection->items()); if (selected.empty()) return; //Check 2 or more selected objects @@ -656,7 +656,7 @@ private : Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); - std::vector x(_dialog.getDesktop()->getSelection()->itemList()); + std::vector x(_dialog.getDesktop()->getSelection()->items()); unclump (x); // restore compensation setting @@ -687,7 +687,7 @@ private : Inkscape::Selection *selection = desktop->getSelection(); if (!selection) return; - std::vector selected(selection->itemList()); + std::vector selected(selection->items()); if (selected.empty()) return; //Check 2 or more selected objects @@ -785,7 +785,7 @@ private : Inkscape::Selection *selection = desktop->getSelection(); if (!selection) return; - std::vector selected(selection->itemList()); + std::vector selected(selection->items()); //Check 2 or more selected objects if (selected.size() < 2) return; diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index b727c87ee..7ce937de7 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -1376,7 +1376,7 @@ void CloneTiler::clonetiler_change_selection(Inkscape::Selection *selection, Gtk return; } - if (selection->itemList().size() > 1) { + if (selection->items().size() > 1) { gtk_widget_set_sensitive (buttons, FALSE); gtk_label_set_markup (GTK_LABEL(status), _("More than one object selected.")); return; @@ -2113,7 +2113,7 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *) Inkscape::Selection *selection = desktop->getSelection(); // check if something is selected - if (selection->isEmpty() || selection->itemList().size() > 1) { + if (selection->isEmpty() || selection->items().size() > 1) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select one object whose tiled clones to unclump.")); return; } @@ -2162,7 +2162,7 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d Inkscape::Selection *selection = desktop->getSelection(); // check if something is selected - if (selection->isEmpty() || selection->itemList().size() > 1) { + if (selection->isEmpty() || selection->items().size() > 1) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select one object whose tiled clones to remove.")); return; } @@ -2240,7 +2240,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) } // Check if more than one object is selected. - if (selection->itemList().size() > 1) { + if (selection->items().size() > 1) { desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("If you want to clone several objects, group them and clone the group.")); return; } diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 2fb5f9e3b..6d2842511 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -608,7 +608,7 @@ void Export::onBatchClicked () void Export::updateCheckbuttons () { - gint num = SP_ACTIVE_DESKTOP->getSelection()->itemList().size(); + gint num = SP_ACTIVE_DESKTOP->getSelection()->items().size(); if (num >= 2) { batch_export.set_sensitive(true); batch_export.set_label(g_strdup_printf (ngettext("B_atch export %d selected object","B_atch export %d selected objects",num), num)); @@ -820,7 +820,7 @@ void Export::onAreaToggled () one that's nice */ if (filename.empty()) { const gchar * id = "object"; - const std::vector reprlst = SP_ACTIVE_DESKTOP->getSelection()->reprList(); + const std::vector reprlst = SP_ACTIVE_DESKTOP->getSelection()->xmlNodes(); for(std::vector::const_iterator i=reprlst.begin(); reprlst.end() != i; ++i) { Inkscape::XML::Node * repr = *i; if (repr->attribute("id")) { @@ -1015,7 +1015,7 @@ void Export::onExport () if (batch_export.get_active ()) { // Batch export of selected objects - gint num = (desktop->getSelection()->itemList()).size(); + gint num = (desktop->getSelection()->items()).size(); gint n = 0; if (num < 1) { @@ -1029,7 +1029,7 @@ void Export::onExport () gint export_count = 0; - std::vector itemlist=desktop->getSelection()->itemList(); + std::vector itemlist= desktop->getSelection()->items(); for(std::vector::const_iterator i = itemlist.begin();i!=itemlist.end() && !interrupted ;++i){ SPItem *item = *i; @@ -1075,7 +1075,7 @@ void Export::onExport () nv->pagecolor, onProgressCallback, (void*)prog_dlg, TRUE, // overwrite without asking - hide ? (desktop->getSelection()->itemList()) : x + hide ? (desktop->getSelection()->items()) : x )) { gchar * error = g_strdup_printf(_("Could not export to filename %s.\n"), safeFile); @@ -1165,7 +1165,7 @@ void Export::onExport () nv->pagecolor, onProgressCallback, (void*)prog_dlg, FALSE, - hide ? (desktop->getSelection()->itemList()) : x + hide ? (desktop->getSelection()->items()) : x ); if (status == EXPORT_ERROR) { gchar * safeFile = Inkscape::IO::sanitizeString(path.c_str()); @@ -1237,7 +1237,7 @@ void Export::onExport () bool saved = DocumentUndo::getUndoSensitive(doc); DocumentUndo::setUndoSensitive(doc, false); - reprlst = desktop->getSelection()->reprList(); + reprlst = desktop->getSelection()->xmlNodes(); for(std::vector::const_iterator i=reprlst.begin(); reprlst.end() != i; ++i) { Inkscape::XML::Node * repr = *i; diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index d3ad5d1da..dfc19f3cc 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -691,7 +691,7 @@ private: void select_svg_element(){ Inkscape::Selection* sel = _desktop->getSelection(); if (sel->isEmpty()) return; - Inkscape::XML::Node* node = sel->reprList()[0]; + Inkscape::XML::Node* node = sel->xmlNodes()[0]; if (!node || !node->matchAttributeName("id")) return; std::ostringstream xlikhref; @@ -1474,7 +1474,7 @@ void FilterEffectsDialog::FilterModifier::update_selection(Selection *sel) } std::set used; - std::vector itemlist=sel->itemList(); + std::vector itemlist= sel->items(); for(std::vector::const_iterator i=itemlist.begin(); itemlist.end() != i; ++i) { SPObject *obj = *i; SPStyle *style = obj->style; @@ -1555,7 +1555,7 @@ void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustri if((*iter)[_columns.sel] == 1) filter = 0; - std::vector itemlist=sel->itemList(); + std::vector itemlist= sel->items(); for(std::vector::const_iterator i=itemlist.begin(); itemlist.end() != i; ++i) { SPItem * item = *i; SPStyle *style = item->style; diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index 0f368c5ac..8424dd7f5 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -761,7 +761,7 @@ std::vector &Find::all_items (SPObject *r, std::vector &l, boo std::vector &Find::all_selection_items (Inkscape::Selection *s, std::vector &l, SPObject *ancestor, bool hidden, bool locked) { - std::vector itemlist=s->itemList(); + std::vector itemlist= s->items(); for(std::vector::const_reverse_iterator i=itemlist.rbegin(); itemlist.rend() != i; ++i) { SPObject *obj = *i; SPItem *item = dynamic_cast(obj); diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index 56b001291..30b0f8df7 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -578,7 +578,7 @@ void GlyphsPanel::setTargetDesktop(SPDesktop *desktop) void GlyphsPanel::insertText() { SPItem *textItem = 0; - std::vector itemlist=targetDesktop->selection->itemList(); + std::vector itemlist= targetDesktop->selection->items(); for(std::vector::const_iterator i=itemlist.begin(); itemlist.end() != i; ++i) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) { textItem = *i; @@ -688,7 +688,7 @@ void GlyphsPanel::selectionModifiedCB(guint flags) void GlyphsPanel::calcCanInsert() { int items = 0; - std::vector itemlist=targetDesktop->selection->itemList(); + std::vector itemlist= targetDesktop->selection->items(); for(std::vector::const_iterator i=itemlist.begin(); itemlist.end() != i; ++i) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) { ++items; diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp index 639e463ea..ddcc20cb7 100644 --- a/src/ui/dialog/grid-arrange-tab.cpp +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -163,7 +163,7 @@ void GridArrangeTab::arrange() desktop->getDocument()->ensureUpToDate(); Inkscape::Selection *selection = desktop->getSelection(); - const std::vector items = selection ? selection->itemList() : std::vector(); + const std::vector items = selection ? selection->items() : std::vector(); for(std::vector::const_iterator i = items.begin();i!=items.end(); ++i){ SPItem *item = *i; Geom::OptRect b = item->documentVisualBounds(); @@ -192,7 +192,7 @@ void GridArrangeTab::arrange() // require the sorting done before we can calculate row heights etc. g_return_if_fail(selection); - std::vector sorted(selection->itemList()); + std::vector sorted(selection->items()); sort(sorted.begin(),sorted.end(),sp_compare_y_position); sort(sorted.begin(),sorted.end(),sp_compare_x_position); @@ -368,7 +368,7 @@ void GridArrangeTab::on_row_spinbutton_changed() Inkscape::Selection *selection = desktop ? desktop->selection : 0; g_return_if_fail( selection ); - std::vector const items = selection->itemList(); + std::vector const items = selection->items(); int selcount = items.size(); double PerCol = ceil(selcount / NoOfColsSpinner.get_value()); @@ -394,7 +394,7 @@ void GridArrangeTab::on_col_spinbutton_changed() Inkscape::Selection *selection = desktop ? desktop->selection : 0; g_return_if_fail(selection); - int selcount = selection->itemList().size(); + int selcount = selection->items().size(); double PerRow = ceil(selcount / NoOfRowsSpinner.get_value()); NoOfColsSpinner.set_value(PerRow); @@ -531,7 +531,7 @@ void GridArrangeTab::updateSelection() updating = true; SPDesktop *desktop = Parent->getDesktop(); Inkscape::Selection *selection = desktop ? desktop->selection : 0; - std::vector const items = selection ? selection->itemList() : std::vector(); + std::vector const items = selection ? selection->items() : std::vector(); if (!items.empty()) { int selcount = items.size(); @@ -602,7 +602,7 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) g_return_if_fail( selection ); int selcount = 1; if (!selection->isEmpty()) { - selcount = selection->itemList().size(); + selcount = selection->items().size(); } diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 83656a1f2..173a964e9 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -362,7 +362,7 @@ void IconPreviewPanel::refreshPreview() if ( sel ) { //g_message("found a selection to play with"); - std::vector const items = sel->itemList(); + std::vector const items = sel->items(); for(std::vector::const_iterator i=items.begin();!target && i!=items.end();++i){ SPItem* item = *i; gchar const *id = item->getId(); diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index 27694a9ac..df32f73cf 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -478,7 +478,7 @@ void ObjectsPanel::_objectsSelected( Selection *sel ) { _selectedConnection.block(); _tree.get_selection()->unselect_all(); SPItem *item = NULL; - std::vector const items = sel->itemList(); + std::vector const items = sel->items(); for(std::vector::const_iterator i=items.begin(); i!=items.end(); ++i){ item = *i; if (setOpacity) diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp index f557ff0fc..ed62e26b0 100644 --- a/src/ui/dialog/pixelartdialog.cpp +++ b/src/ui/dialog/pixelartdialog.cpp @@ -372,7 +372,7 @@ void PixelArtDialogImpl::vectorize() return; } - std::vector const items = desktop->selection->itemList(); + std::vector const items = desktop->selection->items(); for(std::vector::const_iterator i=items.begin(); i!=items.end();++i){ if ( !SP_IS_IMAGE(*i) ) continue; diff --git a/src/ui/dialog/polar-arrange-tab.cpp b/src/ui/dialog/polar-arrange-tab.cpp index 5ec1285c1..c160c269f 100644 --- a/src/ui/dialog/polar-arrange-tab.cpp +++ b/src/ui/dialog/polar-arrange-tab.cpp @@ -297,7 +297,7 @@ static void moveToPoint(int anchor, SPItem *item, Geom::Point p) void PolarArrangeTab::arrange() { Inkscape::Selection *selection = parent->getDesktop()->getSelection(); - const std::vector tmp(selection->itemList()); + const std::vector tmp(selection->items()); SPGenericEllipse *referenceEllipse = NULL; // Last ellipse in selection bool arrangeOnEllipse = !arrangeOnParametersRadio.get_active(); diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 790c0e5fb..100a620fa 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -524,7 +524,7 @@ void SvgFontsDialog::set_glyph_description_from_selected_path(){ return; } - Inkscape::XML::Node* node = sel->reprList().front(); + Inkscape::XML::Node* node = sel->xmlNodes().front(); if (!node) return;//TODO: should this be an assert? if (!node->matchAttributeName("d") || !node->attribute("d")){ char *msg = _("The selected object does not have a path description."); @@ -566,7 +566,7 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){ return; } - Inkscape::XML::Node* node = sel->reprList().front(); + Inkscape::XML::Node* node = sel->xmlNodes().front(); if (!node) return;//TODO: should this be an assert? if (!node->matchAttributeName("d") || !node->attribute("d")){ char *msg = _("The selected object does not have a path description."); diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 6577c8d4e..2573719ac 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -123,7 +123,7 @@ static void editGradientImpl( SPDesktop* desktop, SPGradient* gr ) bool shown = false; if ( desktop && desktop->doc() ) { Inkscape::Selection *selection = desktop->getSelection(); - std::vector const items = selection->itemList(); + std::vector const items = selection->items(); if (!items.empty()) { SPStyle query( desktop->doc() ); int result = objects_query_fillstroke((items), &query, true); diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp index affbe0a3b..98b0f9502 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -348,7 +348,7 @@ void TagsPanel::_objectsSelected( Selection *sel ) { _selectedConnection.block(); _tree.get_selection()->unselect_all(); - auto tmp = sel->range(); + auto tmp = sel->objects(); for(auto i = tmp.begin(); i != tmp.end(); ++i) { SPObject *obj = *i; @@ -646,7 +646,7 @@ bool TagsPanel::_handleButtonEvent(GdkEventButton* event) if (col == _tree.get_column(COL_ADD - 1) && down_at_add) { if (SP_IS_TAG(obj)) { bool wasadded = false; - std::vector items=_desktop->selection->itemList(); + std::vector items= _desktop->selection->items(); for(std::vector::const_iterator i=items.begin();i!=items.end();++i){ SPObject *newobj = *i; bool addchild = true; diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index c01da8864..355bd16d1 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -443,7 +443,7 @@ SPItem *TextEdit::getSelectedTextItem (void) if (!SP_ACTIVE_DESKTOP) return NULL; - std::vector tmp=SP_ACTIVE_DESKTOP->getSelection()->itemList(); + std::vector tmp= SP_ACTIVE_DESKTOP->getSelection()->items(); for(std::vector::const_iterator i=tmp.begin();i!=tmp.end();++i) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) @@ -461,7 +461,7 @@ unsigned TextEdit::getSelectedTextCount (void) unsigned int items = 0; - std::vector tmp=SP_ACTIVE_DESKTOP->getSelection()->itemList(); + std::vector tmp= SP_ACTIVE_DESKTOP->getSelection()->items(); for(std::vector::const_iterator i=tmp.begin();i!=tmp.end();++i) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) @@ -568,7 +568,7 @@ void TextEdit::onApply() SPDesktop *desktop = SP_ACTIVE_DESKTOP; unsigned items = 0; - const std::vector item_list = desktop->getSelection()->itemList(); + const std::vector item_list = desktop->getSelection()->items(); SPCSSAttr *css = fillTextStyle (); sp_desktop_set_style(desktop, css, true); diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index b7638e8c1..f11ac1ebe 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -650,7 +650,7 @@ void Transformation::updatePageTransform(Inkscape::Selection *selection) { if (selection && !selection->isEmpty()) { if (_check_replace_matrix.get_active()) { - Geom::Affine current (selection->itemList()[0]->transform); // take from the first item in selection + Geom::Affine current (selection->items()[0]->transform); // take from the first item in selection Geom::Affine new_displayed = current; @@ -735,7 +735,7 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) if (_check_move_relative.get_active()) { // shift each object relatively to the previous one - std::vector selected(selection->itemList()); + std::vector selected(selection->items()); if (selected.empty()) return; if (fabs(x) > 1e-6) { @@ -810,7 +810,7 @@ void Transformation::applyPageScale(Inkscape::Selection *selection) bool transform_stroke = prefs->getBool("/options/transform/stroke", true); bool preserve = prefs->getBool("/options/preservetransform/value", false); if (prefs->getBool("/dialogs/transformation/applyseparately")) { - std::vector tmp=selection->itemList(); + std::vector tmp= selection->items(); for(std::vector::const_iterator i=tmp.begin();i!=tmp.end();++i){ SPItem *item = *i; Geom::OptRect bbox_pref = item->desktopPreferredBounds(); @@ -874,7 +874,7 @@ void Transformation::applyPageRotate(Inkscape::Selection *selection) } if (prefs->getBool("/dialogs/transformation/applyseparately")) { - std::vector tmp=selection->itemList(); + std::vector tmp= selection->items(); for(std::vector::const_iterator i=tmp.begin();i!=tmp.end();++i){ SPItem *item = *i; sp_item_rotate_rel(item, Geom::Rotate (angle*M_PI/180.0)); @@ -894,7 +894,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/dialogs/transformation/applyseparately")) { - std::vector items=selection->itemList(); + std::vector items= selection->items(); for(std::vector::const_iterator i = items.begin();i!=items.end();++i){ SPItem *item = *i; @@ -996,7 +996,7 @@ void Transformation::applyPageTransform(Inkscape::Selection *selection) } if (_check_replace_matrix.get_active()) { - std::vector tmp=selection->itemList(); + std::vector tmp= selection->items(); for(std::vector::const_iterator i=tmp.begin();i!=tmp.end();++i){ SPItem *item = *i; item->set_item_transform(displayed); @@ -1149,7 +1149,7 @@ void Transformation::onReplaceMatrixToggled() double f = _scalar_transform_f.getValue(); Geom::Affine displayed (a, b, c, d, e, f); - Geom::Affine current = selection->itemList()[0]->transform; // take from the first item in selection + Geom::Affine current = selection->items()[0]->transform; // take from the first item in selection Geom::Affine new_displayed; if (_check_replace_matrix.get_active()) { diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index ab29471ed..7bbf588a7 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -2096,7 +2096,7 @@ void ContextMenu::ImageEdit(void) } #endif - std::vector itemlist=_desktop->selection->itemList(); + std::vector itemlist= _desktop->selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ Inkscape::XML::Node *ir = (*i)->getRepr(); const gchar *href = ir->attribute("xlink:href"); diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index 74f2664fe..52ddd589c 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -1306,7 +1306,7 @@ void cc_selection_set_avoid(bool const set_avoid) int changes = 0; - std::vector l = selection->itemList(); + std::vector l = selection->items(); for(std::vector::const_iterator i=l.begin();i!=l.end(); ++i) { SPItem *item = *i; diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index cb7747b2b..a81161ea9 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -692,7 +692,7 @@ void EraserTool::set_to_accumulated() { } } } else { - toWorkOn = selection->itemList(); + toWorkOn = selection->items(); } wasSelection = true; } @@ -744,7 +744,7 @@ void EraserTool::set_to_accumulated() { } if ( !selection->isEmpty() ) { // If the item was not completely erased, track the new remainder. - std::vector nowSel(selection->itemList()); + std::vector nowSel(selection->items()); for (std::vector::const_iterator i2 = nowSel.begin();i2!=nowSel.end();++i2) { remainingItems.push_back(*i2); } diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index 9d8101cc4..e2bb0dc07 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -106,7 +106,7 @@ void GradientTool::selection_changed(Inkscape::Selection*) { if (selection == NULL) { return; } - guint n_obj = selection->itemList().size(); + guint n_obj = selection->items().size(); if (!drag->isNonEmpty() || selection->isEmpty()) return; @@ -492,9 +492,9 @@ bool GradientTool::root_handler(GdkEvent* event) { if (over_line) { // we take the first item in selection, because with doubleclick, the first click // always resets selection to the single object under cursor - sp_gradient_context_add_stop_near_point(this, SP_ITEM(selection->itemList().front()), this->mousepoint_doc, event->button.time); + sp_gradient_context_add_stop_near_point(this, SP_ITEM(selection->items().front()), this->mousepoint_doc, event->button.time); } else { - std::vector items=selection->itemList(); + std::vector items= selection->items(); for (std::vector::const_iterator i = items.begin();i!=items.end();++i) { SPItem *item = *i; SPGradientType new_type = (SPGradientType) prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR); @@ -897,7 +897,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta } else { // Starting from empty space: // Sort items so that the topmost comes last - std::vector items(selection->itemList()); + std::vector items(selection->items()); sort(items.begin(),items.end(),sp_item_repr_compare_position); // take topmost vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke); @@ -907,7 +907,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta SPCSSAttr *css = sp_repr_css_attr_new(); sp_repr_css_set_property(css, "fill-opacity", "1.0"); - std::vector itemlist = selection->itemList(); + std::vector itemlist = selection->items(); for (std::vector::const_iterator i = itemlist.begin();i!=itemlist.end();++i) { //FIXME: see above @@ -931,7 +931,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta ec->_grdrag->local_change = true; // give the grab out-of-bounds values of xp/yp because we're already dragging // and therefore are already out of tolerance - ec->_grdrag->grabKnot (selection->itemList()[0], + ec->_grdrag->grabKnot (selection->items()[0], type == SP_GRADIENT_TYPE_LINEAR? POINT_LG_END : POINT_RG_R1, -1, // ignore number (though it is always 1) fill_or_stroke, 99999, 99999, etime); @@ -940,7 +940,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta // status text; we do not track coords because this branch is run once, not all the time // during drag - int n_objects = selection->itemList().size(); + int n_objects = selection->items().size(); rc.message_context->setF(Inkscape::NORMAL_MESSAGE, ngettext("Gradient for %d object; with Ctrl to snap angle", "Gradient for %d objects; with Ctrl to snap angle", n_objects), diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp index 9bbc1ac20..ebcac2279 100644 --- a/src/ui/tools/lpe-tool.cpp +++ b/src/ui/tools/lpe-tool.cpp @@ -396,7 +396,7 @@ lpetool_create_measuring_items(LpeTool *lc, Inkscape::Selection *selection) SPCanvasGroup *tmpgrp = lc->desktop->getTempGroup(); gchar *arc_length; double lengthval; - std::vector items=selection->itemList(); + std::vector items= selection->items(); for(std::vector::const_iterator i=items.begin();i!=items.end();++i){ if (SP_IS_PATH(*i)) { path = SP_PATH(*i); diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 47927667c..9aaa0c14e 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -103,7 +103,7 @@ void MeshTool::selection_changed(Inkscape::Selection* /*sel*/) { return; } - guint n_obj = selection->itemList().size(); + guint n_obj = selection->items().size(); if (!drag->isNonEmpty() || selection->isEmpty()) { return; @@ -467,10 +467,10 @@ bool MeshTool::root_handler(GdkEvent* event) { if (over_line) { // We take the first item in selection, because with doubleclick, the first click // always resets selection to the single object under cursor - sp_mesh_context_split_near_point(this, selection->itemList()[0], this->mousepoint_doc, event->button.time); + sp_mesh_context_split_near_point(this, selection->items()[0], this->mousepoint_doc, event->button.time); } else { // Create a new gradient with default coordinates. - std::vector items=selection->itemList(); + std::vector items= selection->items(); for(std::vector::const_iterator i=items.begin();i!=items.end();++i){ SPItem *item = *i; SPGradientType new_type = SP_GRADIENT_TYPE_MESH; @@ -945,7 +945,7 @@ static void sp_mesh_end_drag(MeshTool &rc) { } else { // Starting from empty space: // Sort items so that the topmost comes last - std::vector items(selection->itemList()); + std::vector items(selection->items()); sort(items.begin(),items.end(),sp_item_repr_compare_position); // take topmost vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke); @@ -955,7 +955,7 @@ static void sp_mesh_end_drag(MeshTool &rc) { SPCSSAttr *css = sp_repr_css_attr_new(); sp_repr_css_set_property(css, "fill-opacity", "1.0"); - std::vector items=selection->itemList(); + std::vector items= selection->items(); for(std::vector::const_iterator i=items.begin();i!=items.end();++i){ //FIXME: see above @@ -972,7 +972,7 @@ static void sp_mesh_end_drag(MeshTool &rc) { // status text; we do not track coords because this branch is run once, not all the time // during drag - int n_objects = selection->itemList().size(); + int n_objects = selection->items().size(); rc.message_context->setF(Inkscape::NORMAL_MESSAGE, ngettext("Gradient for %d object; with Ctrl to snap angle", "Gradient for %d objects; with Ctrl to snap angle", n_objects), diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 23aaf6bb1..f7a725794 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -407,7 +407,7 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) { std::set shapes; - std::vector items=sel->itemList(); + std::vector items= sel->items(); for(std::vector::const_iterator i=items.begin();i!=items.end();++i){ SPObject *obj = *i; @@ -444,7 +444,7 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) { } _previous_selection = _current_selection; - _current_selection = sel->itemList(); + _current_selection = sel->items(); this->_multipath->setItems(shapes); this->update_tip(NULL); diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index b5ec3d88e..676a41eaa 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -477,7 +477,7 @@ bool SelectTool::root_handler(GdkEvent* event) { case GDK_2BUTTON_PRESS: if (event->button.button == 1) { if (!selection->isEmpty()) { - SPItem *clicked_item = selection->itemList()[0]; + SPItem *clicked_item = selection->items()[0]; if (dynamic_cast(clicked_item) && !dynamic_cast(clicked_item)) { // enter group if it's not a 3D box desktop->setCurrentLayer(clicked_item); diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index 9adaf3879..4f36a827f 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -210,7 +210,7 @@ void SprayTool::update_cursor(bool /*with_shift*/) { gchar *sel_message = NULL; if (!desktop->selection->isEmpty()) { - num = desktop->selection->itemList().size(); + num = desktop->selection->items().size(); sel_message = g_strdup_printf(ngettext("%i object selected","%i objects selected",num), num); } else { sel_message = g_strdup_printf("%s", _("Nothing selected")); @@ -591,7 +591,7 @@ static bool fit_item(SPDesktop *desktop, if (selection->isEmpty()) { return false; } - std::vector const items_selected(selection->itemList()); + std::vector const items_selected(selection->items()); std::vector items_down_erased; for (std::vector::const_iterator i=items_down.begin(); i!=items_down.end(); ++i) { SPItem *item_down = *i; @@ -1002,7 +1002,7 @@ static bool sp_spray_recursive(SPDesktop *desktop, SPItem *unionResult = NULL; // Previous union int i=1; - std::vector items=selection->itemList(); + std::vector items= selection->items(); for(std::vector::const_iterator it=items.begin();it!=items.end(); ++it){ SPItem *item1 = *it; if (i == 1) { @@ -1170,7 +1170,7 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point double move_standard_deviation = get_move_standard_deviation(tc); { - std::vector const items(selection->itemList()); + std::vector const items(selection->items()); for(std::vector::const_iterator i=items.begin();i!=items.end(); ++i){ SPItem *item = *i; @@ -1299,7 +1299,7 @@ bool SprayTool::root_handler(GdkEvent* event) { guint num = 0; if (!desktop->selection->isEmpty()) { - num = desktop->selection->itemList().size(); + num = desktop->selection->items().size(); } if (num == 0) { this->message_context->flash(Inkscape::ERROR_MESSAGE, _("Nothing selected! Select objects to spray.")); diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 36fe26e76..6da6526bc 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -1158,7 +1158,7 @@ SPItem *sp_event_context_find_item(SPDesktop *desktop, Geom::Point const &p, if (select_under) { SPItem *selected_at_point = desktop->getItemFromListAtPointBottom( - desktop->selection->itemList(), p); + desktop->selection->items(), p); item = desktop->getItemAtPoint(p, into_groups, selected_at_point); if (item == NULL) { // we may have reached bottom, flip over to the top item = desktop->getItemAtPoint(p, into_groups, NULL); diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 39a7a3f0b..4da8060e2 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -153,7 +153,7 @@ void TweakTool::update_cursor (bool with_shift) { gchar *sel_message = NULL; if (!desktop->selection->isEmpty()) { - num = desktop->selection->itemList().size(); + num = desktop->selection->items().size(); sel_message = g_strdup_printf(ngettext("%i object selected","%i objects selected",num), num); } else { sel_message = g_strdup_printf("%s", _("Nothing selected")); @@ -1076,7 +1076,7 @@ sp_tweak_dilate (TweakTool *tc, Geom::Point event_p, Geom::Point p, Geom::Point double move_force = get_move_force(tc); double color_force = MIN(sqrt(path_force)/20.0, 1); - std::vector items=selection->itemList(); + std::vector items= selection->items(); for(std::vector::const_iterator i=items.begin();i!=items.end(); ++i){ SPItem *item = *i; @@ -1185,7 +1185,7 @@ bool TweakTool::root_handler(GdkEvent* event) { guint num = 0; if (!desktop->selection->isEmpty()) { - num = desktop->selection->itemList().size(); + num = desktop->selection->items().size(); } if (num == 0) { this->message_context->flash(Inkscape::ERROR_MESSAGE, _("Nothing selected! Select objects to tweak.")); diff --git a/src/ui/widget/style-subject.cpp b/src/ui/widget/style-subject.cpp index 5f697e420..059d1a4e3 100644 --- a/src/ui/widget/style-subject.cpp +++ b/src/ui/widget/style-subject.cpp @@ -58,7 +58,7 @@ Inkscape::Selection *StyleSubject::Selection::_getSelection() const { std::vector StyleSubject::Selection::list() { Inkscape::Selection *selection = _getSelection(); if(selection) { - return std::vector(selection->range().begin(), selection->range().end()); + return std::vector(selection->objects().begin(), selection->objects().end()); } return std::vector(); -- cgit v1.2.3 From 22262f2db6747eb516283b92abcfd348c700911a Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Fri, 1 Jul 2016 20:57:32 +0200 Subject: Added xmlNodes as range function (bzr r14954.1.12) --- src/ui/dialog/export.cpp | 9 ++++----- src/ui/dialog/filter-effects-dialog.cpp | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 6d2842511..dbee80af9 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -820,8 +820,8 @@ void Export::onAreaToggled () one that's nice */ if (filename.empty()) { const gchar * id = "object"; - const std::vector reprlst = SP_ACTIVE_DESKTOP->getSelection()->xmlNodes(); - for(std::vector::const_iterator i=reprlst.begin(); reprlst.end() != i; ++i) { + auto reprlst = SP_ACTIVE_DESKTOP->getSelection()->xmlNodes(); + for(auto i=reprlst.begin(); reprlst.end() != i; ++i) { Inkscape::XML::Node * repr = *i; if (repr->attribute("id")) { id = repr->attribute("id"); @@ -1231,15 +1231,14 @@ void Export::onExport () break; } case SELECTION_SELECTION: { - std::vector reprlst; SPDocument * doc = SP_ACTIVE_DOCUMENT; bool modified = false; bool saved = DocumentUndo::getUndoSensitive(doc); DocumentUndo::setUndoSensitive(doc, false); - reprlst = desktop->getSelection()->xmlNodes(); + auto reprlst = desktop->getSelection()->xmlNodes(); - for(std::vector::const_iterator i=reprlst.begin(); reprlst.end() != i; ++i) { + for(auto i=reprlst.begin(); reprlst.end() != i; ++i) { Inkscape::XML::Node * repr = *i; const gchar * temp_string; Glib::ustring dir = Glib::path_get_dirname(filename.c_str()); diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index dfc19f3cc..ccba5a278 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -691,7 +691,7 @@ private: void select_svg_element(){ Inkscape::Selection* sel = _desktop->getSelection(); if (sel->isEmpty()) return; - Inkscape::XML::Node* node = sel->xmlNodes()[0]; + Inkscape::XML::Node* node = sel->xmlNodes().front(); if (!node || !node->matchAttributeName("id")) return; std::ostringstream xlikhref; -- cgit v1.2.3 From 058e95a59ccb2ab1748392acdfdbbffd516c9c81 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Mon, 11 Jul 2016 14:24:52 +0200 Subject: First part of new SPObject children list (bzr r14954.1.17) --- src/ui/widget/layer-selector.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'src/ui') diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp index 1a9ce617f..46a0b3547 100644 --- a/src/ui/widget/layer-selector.cpp +++ b/src/ui/widget/layer-selector.cpp @@ -19,6 +19,8 @@ #include "ui/dialog/layer-properties.h" #include +#include +#include #include "desktop.h" @@ -348,27 +350,17 @@ void LayerSelector::_buildSiblingEntries( unsigned depth, SPObject &parent, Inkscape::Util::List hierarchy ) { - using Inkscape::Util::List; using Inkscape::Util::rest; - using Inkscape::Util::reverse_list_in_place; - using Inkscape::Util::filter_list; - Inkscape::Util::List siblings( - reverse_list_in_place( - filter_list( - is_layer(_desktop), parent.firstChild(), NULL - ) - ) - ); + auto siblings = parent._children | boost::adaptors::filtered(is_layer(_desktop)) | boost::adaptors::reversed; SPObject *layer( hierarchy ? &*hierarchy : NULL ); - while (siblings) { - _buildEntry(depth, *siblings); - if ( &*siblings == layer ) { + for (auto& sib: siblings) { + _buildEntry(depth, sib); + if ( &sib == layer ) { _buildSiblingEntries(depth+1, *layer, rest(hierarchy)); } - ++siblings; } } -- cgit v1.2.3 From d1947e768272c703674129d5c583204ff2b59251 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 13 Jul 2016 13:36:19 +0200 Subject: Second part of new SPObject children list (bzr r14954.1.19) --- src/ui/clipboard.cpp | 4 ++-- src/ui/dialog/clonetiler.cpp | 24 ++++++++++++------------ src/ui/dialog/filter-effects-dialog.cpp | 23 ++++++++++++----------- src/ui/dialog/find.cpp | 10 +++++----- src/ui/dialog/font-substitution.cpp | 2 +- src/ui/dialog/objects.cpp | 6 +++--- src/ui/dialog/spellcheck.cpp | 12 ++++++------ src/ui/dialog/symbols.cpp | 8 ++++---- src/ui/tools/box3d-tool.cpp | 4 ++-- src/ui/tools/connector-tool.cpp | 6 +++--- src/ui/tools/tweak-tool.cpp | 16 ++++++++-------- 11 files changed, 58 insertions(+), 57 deletions(-) (limited to 'src/ui') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 9871804f5..75c6c5bcc 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -894,8 +894,8 @@ void ClipboardManagerImpl::_copyPattern(SPPattern *pattern) _copyNode(pattern->getRepr(), _doc, _defs); // items in the pattern may also use gradients and other patterns, so recurse - for ( SPObject *child = pattern->firstChild() ; child ; child = child->getNext() ) { - SPItem *childItem = dynamic_cast(child); + for (auto& child: pattern->_children) { + SPItem *childItem = dynamic_cast(&child); if (childItem) { _copyUsedDefs(childItem); } diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index 87c90c460..11af02e3c 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -2042,12 +2042,12 @@ void CloneTiler::clonetiler_trace_hide_tiled_clones_recursively(SPObject *from) if (!trace_drawing) return; - for (SPObject *o = from->firstChild(); o != NULL; o = o->next) { - SPItem *item = dynamic_cast(o); - if (item && clonetiler_is_a_clone_of(o, NULL)) { + for (auto& o: from->_children) { + SPItem *item = dynamic_cast(&o); + if (item && clonetiler_is_a_clone_of(&o, NULL)) { item->invoke_hide(trace_visionkey); // FIXME: hide each tiled clone's original too! } - clonetiler_trace_hide_tiled_clones_recursively (o); + clonetiler_trace_hide_tiled_clones_recursively (&o); } } @@ -2123,9 +2123,9 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *) std::vector to_unclump; // not including the original - for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) { - if (clonetiler_is_a_clone_of (child, obj)) { - to_unclump.push_back((SPItem*)child); + for (auto& child: parent->_children) { + if (clonetiler_is_a_clone_of (&child, obj)) { + to_unclump.push_back((SPItem*)&child); } } @@ -2143,8 +2143,8 @@ guint CloneTiler::clonetiler_number_of_clones(SPObject *obj) guint n = 0; - for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) { - if (clonetiler_is_a_clone_of (child, obj)) { + for (auto& child: parent->_children) { + if (clonetiler_is_a_clone_of (&child, obj)) { n ++; } } @@ -2172,9 +2172,9 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d // remove old tiling GSList *to_delete = NULL; - for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) { - if (clonetiler_is_a_clone_of (child, obj)) { - to_delete = g_slist_prepend (to_delete, child); + for (auto& child: parent->_children) { + if (clonetiler_is_a_clone_of (&child, obj)) { + to_delete = g_slist_prepend (to_delete, &child); } } for (GSList *i = to_delete; i; i = i->next) { diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 78e03e2a0..a60d1ddff 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -103,9 +103,7 @@ static int input_count(const SPFilterPrimitive* prim) return 2; else if(SP_IS_FEMERGE(prim)) { // Return the number of feMergeNode connections plus an extra - int count = 1; - for(const SPObject* o = prim->firstChild(); o; o = o->next, ++count){}; - return count; + return (int) (prim->_children.size() + 1); } else return 1; @@ -2343,11 +2341,12 @@ const Gtk::TreeIter FilterEffectsDialog::PrimitiveList::find_result(const Gtk::T if(SP_IS_FEMERGE(prim)) { int c = 0; bool found = false; - for(const SPObject* o = prim->firstChild(); o; o = o->next, ++c) { - if(c == attr && SP_IS_FEMERGENODE(o)) { - image = SP_FEMERGENODE(o)->input; + for (auto& o: prim->_children) { + if(c == attr && SP_IS_FEMERGENODE(&o)) { + image = SP_FEMERGENODE(&o)->input; found = true; } + ++c; } if(!found) return target; @@ -2534,21 +2533,23 @@ bool FilterEffectsDialog::PrimitiveList::on_button_release_event(GdkEventButton* if(SP_IS_FEMERGE(prim)) { int c = 1; bool handled = false; - for(SPObject* o = prim->firstChild(); o && !handled; o = o->next, ++c) { - if(c == _in_drag && SP_IS_FEMERGENODE(o)) { + for (auto& o: prim->_children) { + if(c == _in_drag && SP_IS_FEMERGENODE(&o)) { // If input is null, delete it if(!in_val) { //XML Tree being used directly here while it shouldn't be. - sp_repr_unparent(o->getRepr()); + sp_repr_unparent(o.getRepr()); DocumentUndo::done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Remove merge node")); (*get_selection()->get_selected())[_columns.primitive] = prim; + } else { + _dialog.set_attr(&o, SP_ATTR_IN, in_val); } - else - _dialog.set_attr(o, SP_ATTR_IN, in_val); handled = true; + break; } + ++c; } // Add new input? if(!handled && c == _in_drag && in_val) { diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index 013a0ae6a..e156dfa13 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -747,14 +747,14 @@ std::vector &Find::all_items (SPObject *r, std::vector &l, boo return l; // we're not interested in metadata } - for (SPObject *child = r->firstChild(); child; child = child->getNext()) { - SPItem *item = dynamic_cast(child); - if (item && !child->cloned && !desktop->isLayer(item)) { + for (auto& child: r->_children) { + SPItem *item = dynamic_cast(&child); + if (item && !child.cloned && !desktop->isLayer(item)) { if ((hidden || !desktop->itemIsHidden(item)) && (locked || !item->isLocked())) { - l.insert(l.begin(),(SPItem*)child); + l.insert(l.begin(),(SPItem*)&child); } } - l = all_items (child, l, hidden, locked); + l = all_items (&child, l, hidden, locked); } return l; } diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp index f219f3db6..eafe5566a 100644 --- a/src/ui/dialog/font-substitution.cpp +++ b/src/ui/dialog/font-substitution.cpp @@ -182,7 +182,7 @@ std::vector FontSubstitution::getFontReplacedItems(SPDocument* doc, Gli family = SP_TEXT(parent_text)->layout.getFontFamily(0); // Add all the spans fonts to the set gint ii = 0; - for (SPObject *child = parent_text->firstChild() ; child ; child = child->getNext() ) { + for (auto& child: parent_text->_children) { family = SP_TEXT(parent_text)->layout.getFontFamily(ii); setFontSpans.insert(family); ii++; diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index 9d05c73bc..00482c573 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -1292,9 +1292,9 @@ bool ObjectsPanel::_executeAction() break; case BUTTON_COLLAPSE_ALL: { - for (SPObject* obj = _document->getRoot()->firstChild(); obj != NULL; obj = obj->next) { - if (SP_IS_GROUP(obj)) { - _setCollapsed(SP_GROUP(obj)); + for (auto& obj: _document->getRoot()->_children) { + if (SP_IS_GROUP(&obj)) { + _setCollapsed(SP_GROUP(&obj)); } } _objectsChanged(_document->getRoot()); diff --git a/src/ui/dialog/spellcheck.cpp b/src/ui/dialog/spellcheck.cpp index 6da8acb20..9338a4e8c 100644 --- a/src/ui/dialog/spellcheck.cpp +++ b/src/ui/dialog/spellcheck.cpp @@ -234,14 +234,14 @@ GSList *SpellCheck::allTextItems (SPObject *r, GSList *l, bool hidden, bool lock return l; // we're not interested in metadata } - for (SPObject *child = r->firstChild(); child; child = child->next) { - if (SP_IS_ITEM (child) && !child->cloned && !desktop->isLayer(SP_ITEM(child))) { - if ((hidden || !desktop->itemIsHidden(SP_ITEM(child))) && (locked || !SP_ITEM(child)->isLocked())) { - if (SP_IS_TEXT(child) || SP_IS_FLOWTEXT(child)) - l = g_slist_prepend (l, child); + for (auto& child: r->_children) { + if (SP_IS_ITEM (&child) && !child.cloned && !desktop->isLayer(SP_ITEM(&child))) { + if ((hidden || !desktop->itemIsHidden(SP_ITEM(&child))) && (locked || !SP_ITEM(&child)->isLocked())) { + if (SP_IS_TEXT(&child) || SP_IS_FLOWTEXT(&child)) + l = g_slist_prepend (l, &child); } } - l = allTextItems (child, l, hidden, locked); + l = allTextItems (&child, l, hidden, locked); } return l; } diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 51d81022f..1fdce34a5 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -658,8 +658,8 @@ GSList* SymbolsDialog::symbols_in_doc_recursive (SPObject *r, GSList *l) l = g_slist_prepend (l, r); } - for (SPObject *child = r->firstChild(); child; child = child->getNext()) { - l = symbols_in_doc_recursive( child, l ); + for (auto& child: r->_children) { + l = symbols_in_doc_recursive( &child, l ); } return l; @@ -680,8 +680,8 @@ GSList* SymbolsDialog::use_in_doc_recursive (SPObject *r, GSList *l) l = g_slist_prepend (l, r); } - for (SPObject *child = r->firstChild(); child; child = child->getNext()) { - l = use_in_doc_recursive( child, l ); + for (auto& child: r->_children) { + l = use_in_doc_recursive( &child, l ); } return l; diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp index 27e755add..2adba38c5 100644 --- a/src/ui/tools/box3d-tool.cpp +++ b/src/ui/tools/box3d-tool.cpp @@ -118,8 +118,8 @@ static void sp_box3d_context_ensure_persp_in_defs(SPDocument *document) { SPDefs *defs = document->getDefs(); bool has_persp = false; - for ( SPObject *child = defs->firstChild(); child; child = child->getNext() ) { - if (SP_IS_PERSP3D(child)) { + for (auto& child: defs->_children) { + if (SP_IS_PERSP3D(&child)) { has_persp = true; break; } diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index b81a630e2..be8ce6d0c 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -1114,9 +1114,9 @@ void ConnectorTool::_setActiveShape(SPItem *item) { // The idea here is to try and add a group's children to solidify // connection handling. We react to path objects with only one node. - for (SPObject *child = item->firstChild() ; child ; child = child->getNext() ) { - if (SP_IS_PATH(child) && SP_PATH(child)->nodesInPath() == 1) { - this->_activeShapeAddKnot((SPItem *) child); + for (auto& child: item->_children) { + if (SP_IS_PATH(&child) && SP_PATH(&child)->nodesInPath() == 1) { + this->_activeShapeAddKnot((SPItem *) &child); } } this->_activeShapeAddKnot(item); diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 658cf4617..d048c318b 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -385,9 +385,9 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P if (dynamic_cast(item) && !dynamic_cast(item)) { GSList *children = NULL; - for (SPObject *child = item->firstChild() ; child; child = child->getNext() ) { - if (dynamic_cast(static_cast(child))) { - children = g_slist_prepend(children, child); + for (auto& child: item->_children) { + if (dynamic_cast(static_cast(&child))) { + children = g_slist_prepend(children, &child); } } @@ -832,8 +832,8 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or double offset_l = 0; double offset_h = 0; SPObject *child_prev = NULL; - for (SPObject *child = vector->firstChild(); child; child = child->getNext()) { - SPStop *stop = dynamic_cast(child); + for (auto& child: vector->_children) { + SPStop *stop = dynamic_cast(&child); if (!stop) { continue; } @@ -878,7 +878,7 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or } offset_l = offset_h; - child_prev = child; + child_prev = &child; } } @@ -894,8 +894,8 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, bool did = false; if (dynamic_cast(item)) { - for (SPObject *child = item->firstChild() ; child; child = child->getNext() ) { - SPItem *childItem = dynamic_cast(child); + for (auto& child: item->_children) { + SPItem *childItem = dynamic_cast(&child); if (childItem) { if (sp_tweak_color_recursive (mode, childItem, item_at_point, fill_goal, do_fill, -- cgit v1.2.3 From 9e210a6d1333c3366681547e3e81593ef69ff73e Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 14 Jul 2016 12:56:49 +0200 Subject: Last part of new SPObject children list (bzr r14954.1.20) --- src/ui/clipboard.cpp | 8 ++-- src/ui/dialog/document-properties.cpp | 14 +++--- src/ui/dialog/filter-effects-dialog.cpp | 54 ++++++++++----------- src/ui/dialog/objects.cpp | 83 ++++++++++++++++++-------------- src/ui/dialog/svg-fonts-dialog.cpp | 84 +++++++++++++++------------------ src/ui/dialog/tags.cpp | 45 +++++++++--------- src/ui/tools/node-tool.cpp | 4 +- src/ui/tools/tweak-tool.cpp | 6 +-- 8 files changed, 148 insertions(+), 150 deletions(-) (limited to 'src/ui') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 75c6c5bcc..48d53857b 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -839,8 +839,8 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) SPObject *mask = item->mask_ref->getObject(); _copyNode(mask->getRepr(), _doc, _defs); // recurse into the mask for its gradients etc. - for (SPObject *o = mask->children ; o != NULL ; o = o->next) { - SPItem *childItem = dynamic_cast(o); + for(auto& o: mask->_children) { + SPItem *childItem = dynamic_cast(&o); if (childItem) { _copyUsedDefs(childItem); } @@ -857,8 +857,8 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) } // recurse - for (SPObject *o = item->children ; o != NULL ; o = o->next) { - SPItem *childItem = dynamic_cast(o); + for(auto& o: item->_children) { + SPItem *childItem = dynamic_cast(&o); if (childItem) { _copyUsedDefs(childItem); } diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 589973162..df37eb005 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -1315,12 +1315,7 @@ void DocumentProperties::changeEmbeddedScript(){ for (std::vector::const_iterator it = current.begin(); it != current.end(); ++it) { SPObject* obj = *it; if (id == obj->getId()){ - - int count=0; - for ( SPObject *child = obj->children ; child; child = child->next ) - { - count++; - } + int count = (int) obj->_children.size(); if (count>1) g_warning("TODO: Found a script element with multiple (%d) child nodes! We must implement support for that!", count); @@ -1364,8 +1359,11 @@ void DocumentProperties::editEmbeddedScript(){ //XML Tree being used directly here while it shouldn't be. Inkscape::XML::Node *repr = obj->getRepr(); if (repr){ - SPObject *child; - while (NULL != (child = obj->firstChild())) child->deleteObject(); + auto tmp = obj->_children | boost::adaptors::transformed([](SPObject& o) { return &o; }); + std::vector vec(tmp.begin(), tmp.end()); + for (auto &child: vec) { + child->deleteObject(); + } obj->appendChildRepr(xml_doc->createTextNode(_EmbeddedContent.get_buffer()->get_text().c_str())); //TODO repr->set_content(_EmbeddedContent.get_buffer()->get_text()); diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index a60d1ddff..1be5d540a 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1058,11 +1058,10 @@ public: // FuncNode can be in any order so we must search to find correct one. SPFeFuncNode* find_node(SPFeComponentTransfer* ct) { - SPObject* node = ct->children; SPFeFuncNode* funcNode = NULL; bool found = false; - for(;node;node=node->next){ - funcNode = SP_FEFUNCNODE(node); + for(auto& node: ct->_children) { + funcNode = SP_FEFUNCNODE(&node); if( funcNode->channel == _channel ) { found = true; break; @@ -1226,7 +1225,7 @@ protected: _locked = true; - SPObject* child = o->children; + SPObject* child = o->firstChild(); if(SP_IS_FEDISTANTLIGHT(child)) _light_source.set_active(0); @@ -1251,7 +1250,7 @@ private: if(prim) { _locked = true; - SPObject* child = prim->children; + SPObject* child = prim->firstChild(); const int ls = _light_source.get_active_row_number(); // Check if the light source type has changed if(!(ls == -1 && !child) && @@ -1285,8 +1284,8 @@ private: _light_box.show_all(); SPFilterPrimitive* prim = _dialog._primitive_list.get_selected(); - if(prim && prim->children) - _settings.show_and_update(_light_source.get_active_data()->id, prim->children); + if(prim && prim->firstChild()) + _settings.show_and_update(_light_source.get_active_data()->id, prim->firstChild()); } FilterEffectsDialog& _dialog; @@ -1869,26 +1868,25 @@ void FilterEffectsDialog::PrimitiveList::update() bool active_found = false; _dialog._primitive_box->set_sensitive(true); _dialog.update_filter_general_settings_view(); - for(SPObject *prim_obj = f->children; - prim_obj && SP_IS_FILTER_PRIMITIVE(prim_obj); - prim_obj = prim_obj->next) { - SPFilterPrimitive *prim = SP_FILTER_PRIMITIVE(prim_obj); - if(prim) { - Gtk::TreeModel::Row row = *_model->append(); - row[_columns.primitive] = prim; - - //XML Tree being used directly here while it shouldn't be. - row[_columns.type_id] = FPConverter.get_id_from_key(prim->getRepr()->name()); - row[_columns.type] = _(FPConverter.get_label(row[_columns.type_id]).c_str()); - - if (prim->getId()) { - row[_columns.id] = Glib::ustring(prim->getId()); - } - - if(prim == active_prim) { - get_selection()->select(row); - active_found = true; - } + for(auto& prim_obj: f->_children) { + SPFilterPrimitive *prim = SP_FILTER_PRIMITIVE(&prim_obj); + if(!prim) { + break; + } + Gtk::TreeModel::Row row = *_model->append(); + row[_columns.primitive] = prim; + + //XML Tree being used directly here while it shouldn't be. + row[_columns.type_id] = FPConverter.get_id_from_key(prim->getRepr()->name()); + row[_columns.type] = _(FPConverter.get_label(row[_columns.type_id]).c_str()); + + if (prim->getId()) { + row[_columns.id] = Glib::ustring(prim->getId()); + } + + if(prim == active_prim) { + get_selection()->select(row); + active_found = true; } } @@ -3098,7 +3096,7 @@ void FilterEffectsDialog::set_filternode_attr(const AttrWidget* input) void FilterEffectsDialog::set_child_attr_direct(const AttrWidget* input) { - set_attr(_primitive_list.get_selected()->children, input->get_attribute(), input->get_as_attribute().c_str()); + set_attr(_primitive_list.get_selected()->firstChild(), input->get_attribute(), input->get_as_attribute().c_str()); } void FilterEffectsDialog::set_attr(SPObject* o, const SPAttributeEnum attr, const gchar* val) diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index 00482c573..e4639745f 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -340,12 +340,11 @@ void ObjectsPanel::_objectsChanged(SPObject */*obj*/) void ObjectsPanel::_addObject(SPObject* obj, Gtk::TreeModel::Row* parentRow) { if ( _desktop && obj ) { - for ( SPObject *child = obj->children; child != NULL; child = child->next) { - - if (SP_IS_ITEM(child)) + for(auto& child: obj->_children) { + if (SP_IS_ITEM(&child)) { - SPItem * item = SP_ITEM(child); - SPGroup * group = SP_IS_GROUP(child) ? SP_GROUP(child) : 0; + SPItem * item = SP_ITEM(&child); + SPGroup * group = SP_IS_GROUP(&child) ? SP_GROUP(&child) : 0; //Add the item to the tree and set the column information Gtk::TreeModel::iterator iter = parentRow ? _store->prepend(parentRow->children()) : _store->prepend(); @@ -372,14 +371,14 @@ void ObjectsPanel::_addObject(SPObject* obj, Gtk::TreeModel::Row* parentRow) } //Add an object watcher to the item - ObjectsPanel::ObjectWatcher *w = new ObjectsPanel::ObjectWatcher(this, child); - child->getRepr()->addObserver(*w); + ObjectsPanel::ObjectWatcher *w = new ObjectsPanel::ObjectWatcher(this, &child); + child.getRepr()->addObserver(*w); _objectWatchers.push_back(w); //If the item is a group, recursively add its children if (group) { - _addObject( child, &row ); + _addObject( &child, &row ); } } } @@ -399,9 +398,8 @@ void ObjectsPanel::_updateObject( SPObject *obj, bool recurse ) { //end mark if (recurse) { - for (SPObject * iter = obj->children; iter != NULL; iter = iter->next) - { - _updateObject(iter, recurse); + for (auto& iter: obj->_children) { + _updateObject(&iter, recurse); } } } @@ -520,19 +518,22 @@ void ObjectsPanel::_setCompositingValues(SPItem *item) SPGaussianBlur *spblur = NULL; if (item->style->getFilter()) { - for(SPObject *primitive_obj = item->style->getFilter()->children; primitive_obj && SP_IS_FILTER_PRIMITIVE(primitive_obj); primitive_obj = primitive_obj->next) { - if(SP_IS_FEBLEND(primitive_obj) && !spblend) { - //Get the blend mode - spblend = SP_FEBLEND(primitive_obj); - } - - if(SP_IS_GAUSSIANBLUR(primitive_obj) && !spblur) { - //Get the blur value - spblur = SP_GAUSSIANBLUR(primitive_obj); - } + for (auto& primitive_obj: item->style->getFilter()->_children) { + if (!SP_IS_FILTER_PRIMITIVE(&primitive_obj)) { + break; } + if(SP_IS_FEBLEND(&primitive_obj) && !spblend) { + //Get the blend mode + spblend = SP_FEBLEND(&primitive_obj); + } + + if(SP_IS_GAUSSIANBLUR(&primitive_obj) && !spblur) { + //Get the blur value + spblur = SP_GAUSSIANBLUR(&primitive_obj); + } + } } - + //Set the blend mode _fe_cb.set_blend_mode(spblend ? spblend->blend_mode : Inkscape::Filters::BLEND_NORMAL); @@ -1404,9 +1405,10 @@ void ObjectsPanel::_setCollapsed(SPGroup * group) { group->setExpanded(false); group->updateRepr(SP_OBJECT_WRITE_NO_CHILDREN | SP_OBJECT_WRITE_EXT); - for (SPObject *iter = group->children; iter != NULL; iter = iter->next) - { - if (SP_IS_GROUP(iter)) _setCollapsed(SP_GROUP(iter)); + for (auto& iter: group->_children) { + if (SP_IS_GROUP(&iter)) { + _setCollapsed(SP_GROUP(&iter)); + } } } @@ -1521,11 +1523,14 @@ void ObjectsPanel::_blendChangedIter(const Gtk::TreeIter& iter, Glib::ustring bl if (blendmode != "normal") { gdouble radius = 0; if (item->style->getFilter()) { - for (SPObject *primitive = item->style->getFilter()->children; primitive && SP_IS_FILTER_PRIMITIVE(primitive); primitive = primitive->next) { - if (SP_IS_GAUSSIANBLUR(primitive)) { + for (auto& primitive: item->style->getFilter()->_children) { + if (!SP_IS_FILTER_PRIMITIVE(&primitive)) { + break; + } + if (SP_IS_GAUSSIANBLUR(&primitive)) { Geom::OptRect bbox = item->bounds(SPItem::GEOMETRIC_BBOX); if (bbox) { - radius = SP_GAUSSIANBLUR(primitive)->stdDeviation.getNumber(); + radius = SP_GAUSSIANBLUR(&primitive)->stdDeviation.getNumber(); } } } @@ -1533,13 +1538,16 @@ void ObjectsPanel::_blendChangedIter(const Gtk::TreeIter& iter, Glib::ustring bl SPFilter *filter = new_filter_simple_from_item(_document, item, blendmode.c_str(), radius); sp_style_set_property_url(item, "filter", filter, false); } else { - for (SPObject *primitive = item->style->getFilter()->children; primitive && SP_IS_FILTER_PRIMITIVE(primitive); primitive = primitive->next) { - if (SP_IS_FEBLEND(primitive)) { - primitive->deleteObject(); + for (auto& primitive: item->style->getFilter()->_children) { + if (!SP_IS_FILTER_PRIMITIVE(&primitive)) { + break; + } + if (SP_IS_FEBLEND(&primitive)) { + primitive.deleteObject(); break; } } - if (!item->style->getFilter()->children) { + if (!item->style->getFilter()->firstChild()) { remove_filter(item, false); } } @@ -1590,13 +1598,16 @@ void ObjectsPanel::_blurChangedIter(const Gtk::TreeIter& iter, double blur) SPFilter *filter = modify_filter_gaussian_blur_from_item(_document, item, radius); sp_style_set_property_url(item, "filter", filter, false); } else if (item->style->filter.set && item->style->getFilter()) { - for (SPObject *primitive = item->style->getFilter()->children; primitive && SP_IS_FILTER_PRIMITIVE(primitive); primitive = primitive->next) { - if (SP_IS_GAUSSIANBLUR(primitive)) { - primitive->deleteObject(); + for (auto& primitive: item->style->getFilter()->_children) { + if (!SP_IS_FILTER_PRIMITIVE(&primitive)) { + break; + } + if (SP_IS_GAUSSIANBLUR(&primitive)) { + primitive.deleteObject(); break; } } - if (!item->style->getFilter()->children) { + if (!item->style->getFilter()->firstChild()) { remove_filter(item, false); } } diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 7b256fc8f..93bd67a3d 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -115,11 +115,11 @@ void SvgFontsDialog::AttrEntry::set_text(char* t){ void SvgFontsDialog::AttrEntry::on_attr_changed(){ SPObject* o = NULL; - for(SPObject* node = this->dialog->get_selected_spfont()->children; node; node=node->next){ + for (auto& node: dialog->get_selected_spfont()->_children) { switch(this->attr){ case SP_PROP_FONT_FAMILY: - if (SP_IS_FONTFACE(node)){ - o = node; + if (SP_IS_FONTFACE(&node)){ + o = &node; continue; } break; @@ -170,9 +170,9 @@ void GlyphComboBox::update(SPFont* spfont){ this->append(""); //Gtk is refusing to clear the combobox when I comment out this line this->remove_all(); - for(SPObject* node = spfont->children; node; node=node->next){ - if (SP_IS_GLYPH(node)){ - this->append((static_cast(node))->unicode); + for (auto& node: spfont->_children) { + if (SP_IS_GLYPH(&node)){ + this->append((static_cast(&node))->unicode); } } } @@ -308,10 +308,9 @@ void SvgFontsDialog::update_global_settings_tab(){ SPFont* font = get_selected_spfont(); if (!font) return; - SPObject* obj; - for (obj=font->children; obj; obj=obj->next){ - if (SP_IS_FONTFACE(obj)){ - _familyname_entry->set_text((SP_FONTFACE(obj))->font_family); + for (auto& obj: font->_children) { + if (SP_IS_FONTFACE(&obj)){ + _familyname_entry->set_text((SP_FONTFACE(&obj))->font_family); } } } @@ -414,12 +413,12 @@ SvgFontsDialog::populate_glyphs_box() SPFont* spfont = this->get_selected_spfont(); _glyphs_observer.set(spfont); - for(SPObject* node = spfont->children; node; node=node->next){ - if (SP_IS_GLYPH(node)){ + for (auto& node: spfont->_children) { + if (SP_IS_GLYPH(&node)){ Gtk::TreeModel::Row row = *(_GlyphsListStore->append()); - row[_GlyphsListColumns.glyph_node] = static_cast(node); - row[_GlyphsListColumns.glyph_name] = (static_cast(node))->glyph_name; - row[_GlyphsListColumns.unicode] = (static_cast(node))->unicode; + row[_GlyphsListColumns.glyph_node] = static_cast(&node); + row[_GlyphsListColumns.glyph_name] = (static_cast(&node))->glyph_name; + row[_GlyphsListColumns.unicode] = (static_cast(&node))->unicode; } } } @@ -432,13 +431,13 @@ SvgFontsDialog::populate_kerning_pairs_box() SPFont* spfont = this->get_selected_spfont(); - for(SPObject* node = spfont->children; node; node=node->next){ - if (SP_IS_HKERN(node)){ + for (auto& node: spfont->_children) { + if (SP_IS_HKERN(&node)){ Gtk::TreeModel::Row row = *(_KerningPairsListStore->append()); - row[_KerningPairsListColumns.first_glyph] = (static_cast(node))->u1->attribute_string().c_str(); - row[_KerningPairsListColumns.second_glyph] = (static_cast(node))->u2->attribute_string().c_str(); - row[_KerningPairsListColumns.kerning_value] = (static_cast(node))->k; - row[_KerningPairsListColumns.spnode] = static_cast(node); + row[_KerningPairsListColumns.first_glyph] = (static_cast(&node))->u1->attribute_string().c_str(); + row[_KerningPairsListColumns.second_glyph] = (static_cast(&node))->u2->attribute_string().c_str(); + row[_KerningPairsListColumns.kerning_value] = (static_cast(&node))->k; + row[_KerningPairsListColumns.spnode] = static_cast(&node); } } } @@ -493,11 +492,10 @@ void SvgFontsDialog::add_glyph(){ Geom::PathVector SvgFontsDialog::flip_coordinate_system(Geom::PathVector pathv){ double units_per_em = 1000; - SPObject* obj; - for (obj = get_selected_spfont()->children; obj; obj=obj->next){ - if (SP_IS_FONTFACE(obj)){ + for (auto& obj: get_selected_spfont()->_children) { + if (SP_IS_FONTFACE(&obj)){ //XML Tree being directly used here while it shouldn't be. - sp_repr_get_double(obj->getRepr(), "units-per-em", &units_per_em); + sp_repr_get_double(obj.getRepr(), "units-per-em", &units_per_em); } } @@ -576,13 +574,12 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){ Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d")); - SPObject* obj; - for (obj = get_selected_spfont()->children; obj; obj=obj->next){ - if (SP_IS_MISSING_GLYPH(obj)){ + for (auto& obj: get_selected_spfont()->_children) { + if (SP_IS_MISSING_GLYPH(&obj)){ //XML Tree being directly used here while it shouldn't be. gchar *str = sp_svg_write_path (flip_coordinate_system(pathv)); - obj->getRepr()->setAttribute("d", str); + obj.getRepr()->setAttribute("d", str); g_free(str); DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); } @@ -599,11 +596,10 @@ void SvgFontsDialog::reset_missing_glyph_description(){ } SPDocument* doc = desktop->getDocument(); - SPObject* obj; - for (obj = get_selected_spfont()->children; obj; obj=obj->next){ - if (SP_IS_MISSING_GLYPH(obj)){ + for (auto& obj: get_selected_spfont()->_children) { + if (SP_IS_MISSING_GLYPH(&obj)){ //XML Tree being directly used here while it shouldn't be. - obj->getRepr()->setAttribute("d", (char*) "M0,0h1000v1024h-1000z"); + obj.getRepr()->setAttribute("d", (char*) "M0,0h1000v1024h-1000z"); DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Reset missing-glyph")); } } @@ -738,12 +734,12 @@ void SvgFontsDialog::add_kerning_pair(){ //look for this kerning pair on the currently selected font this->kerning_pair = NULL; - for(SPObject* node = this->get_selected_spfont()->children; node; node=node->next){ + for (auto& node: get_selected_spfont()->_children) { //TODO: It is not really correct to get only the first byte of each string. //TODO: We should also support vertical kerning - if (SP_IS_HKERN(node) && (static_cast(node))->u1->contains((gchar) first_glyph.get_active_text().c_str()[0]) - && (static_cast(node))->u2->contains((gchar) second_glyph.get_active_text().c_str()[0]) ){ - this->kerning_pair = static_cast(node); + if (SP_IS_HKERN(&node) && (static_cast(&node))->u1->contains((gchar) first_glyph.get_active_text().c_str()[0]) + && (static_cast(&node))->u2->contains((gchar) second_glyph.get_active_text().c_str()[0]) ){ + this->kerning_pair = static_cast(&node); continue; } } @@ -852,11 +848,10 @@ SPFont *new_font(SPDocument *document) void set_font_family(SPFont* font, char* str){ if (!font) return; - SPObject* obj; - for (obj=font->children; obj; obj=obj->next){ - if (SP_IS_FONTFACE(obj)){ + for (auto& obj: font->_children) { + if (SP_IS_FONTFACE(&obj)){ //XML Tree being directly used here while it shouldn't be. - obj->getRepr()->setAttribute("font-family", str); + obj.getRepr()->setAttribute("font-family", str); } } @@ -873,11 +868,10 @@ void SvgFontsDialog::add_font(){ font->setLabel(os.str().c_str()); os2 << "SVGFont " << count; - SPObject* obj; - for (obj=font->children; obj; obj=obj->next){ - if (SP_IS_FONTFACE(obj)){ + for (auto& obj: font->_children) { + if (SP_IS_FONTFACE(&obj)){ //XML Tree being directly used here while it shouldn't be. - obj->getRepr()->setAttribute("font-family", os2.str().c_str()); + obj.getRepr()->setAttribute("font-family", os2.str().c_str()); } } diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp index 53641c0de..61c8b5d37 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -399,26 +399,26 @@ void TagsPanel::_objectsChanged(SPObject* root) void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row* parentRow ) { if ( _desktop && obj ) { - for ( SPObject *child = obj->children; child != NULL; child = child->next) { - if (SP_IS_TAG(child)) + for (auto& child: obj->_children) { + if (SP_IS_TAG(&child)) { Gtk::TreeModel::iterator iter = parentRow ? _store->prepend(parentRow->children()) : _store->prepend(); Gtk::TreeModel::Row row = *iter; - row[_model->_colObject] = child; + row[_model->_colObject] = &child; row[_model->_colParentObject] = NULL; - row[_model->_colLabel] = child->label() ? child->label() : child->getId(); + row[_model->_colLabel] = child.label() ? child.label() : child.getId(); row[_model->_colAddRemove] = true; row[_model->_colAllowAddRemove] = true; _tree.expand_to_path( _store->get_path(iter) ); - TagsPanel::ObjectWatcher *w = new TagsPanel::ObjectWatcher(this, child); - child->getRepr()->addObserver(*w); + TagsPanel::ObjectWatcher *w = new TagsPanel::ObjectWatcher(this, &child); + child.getRepr()->addObserver(*w); _objectWatchers.push_back(w); - _addObject( doc, child, &row ); + _addObject( doc, &child, &row ); } } - if (SP_IS_TAG(obj) && obj->children) + if (SP_IS_TAG(obj) && obj->firstChild()) { Gtk::TreeModel::iterator iteritems = parentRow ? _store->append(parentRow->children()) : _store->prepend(); Gtk::TreeModel::Row rowitems = *iteritems; @@ -429,16 +429,16 @@ void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row* rowitems[_model->_colAllowAddRemove] = false; _tree.expand_to_path( _store->get_path(iteritems) ); - - for ( SPObject *child = obj->children; child != NULL; child = child->next) { - if (SP_IS_TAG_USE(child)) + + for (auto& child: obj->_children) { + if (SP_IS_TAG_USE(&child)) { - SPItem *item = SP_TAG_USE(child)->ref->getObject(); + SPItem *item = SP_TAG_USE(&child)->ref->getObject(); Gtk::TreeModel::iterator iter = _store->prepend(rowitems->children()); Gtk::TreeModel::Row row = *iter; - row[_model->_colObject] = child; + row[_model->_colObject] = &child; row[_model->_colParentObject] = NULL; - row[_model->_colLabel] = item ? (item->label() ? item->label() : item->getId()) : SP_TAG_USE(child)->href; + row[_model->_colLabel] = item ? (item->label() ? item->label() : item->getId()) : SP_TAG_USE(&child)->href; row[_model->_colAddRemove] = false; row[_model->_colAllowAddRemove] = true; @@ -447,7 +447,7 @@ void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row* } if (item) { - TagsPanel::ObjectWatcher *w = new TagsPanel::ObjectWatcher(this, child, item->getRepr()); + TagsPanel::ObjectWatcher *w = new TagsPanel::ObjectWatcher(this, &child, item->getRepr()); item->getRepr()->addObserver(*w); _objectWatchers.push_back(w); } @@ -459,12 +459,11 @@ void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row* void TagsPanel::_select_tag( SPTag * tag ) { - for (SPObject * child = tag->children; child != NULL; child = child->next) - { - if (SP_IS_TAG(child)) { - _select_tag(SP_TAG(child)); - } else if (SP_IS_TAG_USE(child)) { - SPObject * obj = SP_TAG_USE(child)->ref->getObject(); + for (auto& child: tag->_children) { + if (SP_IS_TAG(&child)) { + _select_tag(SP_TAG(&child)); + } else if (SP_IS_TAG_USE(&child)) { + SPObject * obj = SP_TAG_USE(&child)->ref->getObject(); if (obj) { if (_desktop->selection->isEmpty()) _desktop->setCurrentLayer(obj->parent); _desktop->selection->add(obj); @@ -650,8 +649,8 @@ bool TagsPanel::_handleButtonEvent(GdkEventButton* event) for(auto i=items.begin();i!=items.end();++i){ SPObject *newobj = *i; bool addchild = true; - for ( SPObject *child = obj->children; child != NULL; child = child->next) { - if (SP_IS_TAG_USE(child) && SP_TAG_USE(child)->ref->getObject() == newobj) { + for (auto& child: obj->_children) { + if (SP_IS_TAG_USE(&child) && SP_TAG_USE(&child)->ref->getObject() == newobj) { addchild = false; } } diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 736dafa50..3dfac5e3d 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -378,8 +378,8 @@ void gather_items(NodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::Shape r.role = role; s.insert(r); } else if (role != SHAPE_ROLE_NORMAL && (SP_IS_GROUP(obj) || SP_IS_OBJECTGROUP(obj))) { - for (SPObject *c = obj->children; c; c = c->next) { - gather_items(nt, base, c, role, s); + for (auto& c: obj->_children) { + gather_items(nt, base, &c, role, s); } } else if (SP_IS_ITEM(obj)) { SPItem *item = static_cast(obj); diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index d048c318b..7da0973d5 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -951,9 +951,8 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, Geom::Affine i2dt = item->i2dt_affine (); if (style->filter.set && style->getFilter()) { //cycle through filter primitives - SPObject *primitive_obj = style->getFilter()->children; - while (primitive_obj) { - SPFilterPrimitive *primitive = dynamic_cast(primitive_obj); + for (auto& primitive_obj: style->getFilter()->_children) { + SPFilterPrimitive *primitive = dynamic_cast(&primitive_obj); if (primitive) { //if primitive is gaussianblur SPGaussianBlur * spblur = dynamic_cast(primitive); @@ -962,7 +961,6 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, blur_now += num * i2dt.descrim(); // sum all blurs in the filter } } - primitive_obj = primitive_obj->next; } } double perimeter = bbox->dimensions()[Geom::X] + bbox->dimensions()[Geom::Y]; -- cgit v1.2.3 From 24d3f50003ca3cec6a03a7f5267cc4fe5588c69f Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 14 Jul 2016 13:17:21 +0200 Subject: Renamed children list in SPObject (bzr r14954.1.21) --- src/ui/clipboard.cpp | 6 +++--- src/ui/dialog/clonetiler.cpp | 8 ++++---- src/ui/dialog/document-properties.cpp | 4 ++-- src/ui/dialog/filter-effects-dialog.cpp | 10 +++++----- src/ui/dialog/find.cpp | 2 +- src/ui/dialog/font-substitution.cpp | 2 +- src/ui/dialog/objects.cpp | 16 ++++++++-------- src/ui/dialog/spellcheck.cpp | 2 +- src/ui/dialog/svg-fonts-dialog.cpp | 22 +++++++++++----------- src/ui/dialog/symbols.cpp | 4 ++-- src/ui/dialog/tags.cpp | 8 ++++---- src/ui/tools/box3d-tool.cpp | 2 +- src/ui/tools/connector-tool.cpp | 2 +- src/ui/tools/node-tool.cpp | 2 +- src/ui/tools/tweak-tool.cpp | 8 ++++---- src/ui/widget/layer-selector.cpp | 2 +- 16 files changed, 50 insertions(+), 50 deletions(-) (limited to 'src/ui') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 48d53857b..b25a70b15 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -839,7 +839,7 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) SPObject *mask = item->mask_ref->getObject(); _copyNode(mask->getRepr(), _doc, _defs); // recurse into the mask for its gradients etc. - for(auto& o: mask->_children) { + for(auto& o: mask->children) { SPItem *childItem = dynamic_cast(&o); if (childItem) { _copyUsedDefs(childItem); @@ -857,7 +857,7 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) } // recurse - for(auto& o: item->_children) { + for(auto& o: item->children) { SPItem *childItem = dynamic_cast(&o); if (childItem) { _copyUsedDefs(childItem); @@ -894,7 +894,7 @@ void ClipboardManagerImpl::_copyPattern(SPPattern *pattern) _copyNode(pattern->getRepr(), _doc, _defs); // items in the pattern may also use gradients and other patterns, so recurse - for (auto& child: pattern->_children) { + for (auto& child: pattern->children) { SPItem *childItem = dynamic_cast(&child); if (childItem) { _copyUsedDefs(childItem); diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index 11af02e3c..1e8ca4405 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -2042,7 +2042,7 @@ void CloneTiler::clonetiler_trace_hide_tiled_clones_recursively(SPObject *from) if (!trace_drawing) return; - for (auto& o: from->_children) { + for (auto& o: from->children) { SPItem *item = dynamic_cast(&o); if (item && clonetiler_is_a_clone_of(&o, NULL)) { item->invoke_hide(trace_visionkey); // FIXME: hide each tiled clone's original too! @@ -2123,7 +2123,7 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *) std::vector to_unclump; // not including the original - for (auto& child: parent->_children) { + for (auto& child: parent->children) { if (clonetiler_is_a_clone_of (&child, obj)) { to_unclump.push_back((SPItem*)&child); } @@ -2143,7 +2143,7 @@ guint CloneTiler::clonetiler_number_of_clones(SPObject *obj) guint n = 0; - for (auto& child: parent->_children) { + for (auto& child: parent->children) { if (clonetiler_is_a_clone_of (&child, obj)) { n ++; } @@ -2172,7 +2172,7 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d // remove old tiling GSList *to_delete = NULL; - for (auto& child: parent->_children) { + for (auto& child: parent->children) { if (clonetiler_is_a_clone_of (&child, obj)) { to_delete = g_slist_prepend (to_delete, &child); } diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index df37eb005..6f5f14d80 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -1315,7 +1315,7 @@ void DocumentProperties::changeEmbeddedScript(){ for (std::vector::const_iterator it = current.begin(); it != current.end(); ++it) { SPObject* obj = *it; if (id == obj->getId()){ - int count = (int) obj->_children.size(); + int count = (int) obj->children.size(); if (count>1) g_warning("TODO: Found a script element with multiple (%d) child nodes! We must implement support for that!", count); @@ -1359,7 +1359,7 @@ void DocumentProperties::editEmbeddedScript(){ //XML Tree being used directly here while it shouldn't be. Inkscape::XML::Node *repr = obj->getRepr(); if (repr){ - auto tmp = obj->_children | boost::adaptors::transformed([](SPObject& o) { return &o; }); + auto tmp = obj->children | boost::adaptors::transformed([](SPObject& o) { return &o; }); std::vector vec(tmp.begin(), tmp.end()); for (auto &child: vec) { child->deleteObject(); diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 1be5d540a..3e3ede019 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -103,7 +103,7 @@ static int input_count(const SPFilterPrimitive* prim) return 2; else if(SP_IS_FEMERGE(prim)) { // Return the number of feMergeNode connections plus an extra - return (int) (prim->_children.size() + 1); + return (int) (prim->children.size() + 1); } else return 1; @@ -1060,7 +1060,7 @@ public: { SPFeFuncNode* funcNode = NULL; bool found = false; - for(auto& node: ct->_children) { + for(auto& node: ct->children) { funcNode = SP_FEFUNCNODE(&node); if( funcNode->channel == _channel ) { found = true; @@ -1868,7 +1868,7 @@ void FilterEffectsDialog::PrimitiveList::update() bool active_found = false; _dialog._primitive_box->set_sensitive(true); _dialog.update_filter_general_settings_view(); - for(auto& prim_obj: f->_children) { + for(auto& prim_obj: f->children) { SPFilterPrimitive *prim = SP_FILTER_PRIMITIVE(&prim_obj); if(!prim) { break; @@ -2339,7 +2339,7 @@ const Gtk::TreeIter FilterEffectsDialog::PrimitiveList::find_result(const Gtk::T if(SP_IS_FEMERGE(prim)) { int c = 0; bool found = false; - for (auto& o: prim->_children) { + for (auto& o: prim->children) { if(c == attr && SP_IS_FEMERGENODE(&o)) { image = SP_FEMERGENODE(&o)->input; found = true; @@ -2531,7 +2531,7 @@ bool FilterEffectsDialog::PrimitiveList::on_button_release_event(GdkEventButton* if(SP_IS_FEMERGE(prim)) { int c = 1; bool handled = false; - for (auto& o: prim->_children) { + for (auto& o: prim->children) { if(c == _in_drag && SP_IS_FEMERGENODE(&o)) { // If input is null, delete it if(!in_val) { diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index e156dfa13..b09ce6078 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -747,7 +747,7 @@ std::vector &Find::all_items (SPObject *r, std::vector &l, boo return l; // we're not interested in metadata } - for (auto& child: r->_children) { + for (auto& child: r->children) { SPItem *item = dynamic_cast(&child); if (item && !child.cloned && !desktop->isLayer(item)) { if ((hidden || !desktop->itemIsHidden(item)) && (locked || !item->isLocked())) { diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp index eafe5566a..b927096ab 100644 --- a/src/ui/dialog/font-substitution.cpp +++ b/src/ui/dialog/font-substitution.cpp @@ -182,7 +182,7 @@ std::vector FontSubstitution::getFontReplacedItems(SPDocument* doc, Gli family = SP_TEXT(parent_text)->layout.getFontFamily(0); // Add all the spans fonts to the set gint ii = 0; - for (auto& child: parent_text->_children) { + for (auto& child: parent_text->children) { family = SP_TEXT(parent_text)->layout.getFontFamily(ii); setFontSpans.insert(family); ii++; diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index e4639745f..f4d3a3f70 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -340,7 +340,7 @@ void ObjectsPanel::_objectsChanged(SPObject */*obj*/) void ObjectsPanel::_addObject(SPObject* obj, Gtk::TreeModel::Row* parentRow) { if ( _desktop && obj ) { - for(auto& child: obj->_children) { + for(auto& child: obj->children) { if (SP_IS_ITEM(&child)) { SPItem * item = SP_ITEM(&child); @@ -398,7 +398,7 @@ void ObjectsPanel::_updateObject( SPObject *obj, bool recurse ) { //end mark if (recurse) { - for (auto& iter: obj->_children) { + for (auto& iter: obj->children) { _updateObject(&iter, recurse); } } @@ -518,7 +518,7 @@ void ObjectsPanel::_setCompositingValues(SPItem *item) SPGaussianBlur *spblur = NULL; if (item->style->getFilter()) { - for (auto& primitive_obj: item->style->getFilter()->_children) { + for (auto& primitive_obj: item->style->getFilter()->children) { if (!SP_IS_FILTER_PRIMITIVE(&primitive_obj)) { break; } @@ -1293,7 +1293,7 @@ bool ObjectsPanel::_executeAction() break; case BUTTON_COLLAPSE_ALL: { - for (auto& obj: _document->getRoot()->_children) { + for (auto& obj: _document->getRoot()->children) { if (SP_IS_GROUP(&obj)) { _setCollapsed(SP_GROUP(&obj)); } @@ -1405,7 +1405,7 @@ void ObjectsPanel::_setCollapsed(SPGroup * group) { group->setExpanded(false); group->updateRepr(SP_OBJECT_WRITE_NO_CHILDREN | SP_OBJECT_WRITE_EXT); - for (auto& iter: group->_children) { + for (auto& iter: group->children) { if (SP_IS_GROUP(&iter)) { _setCollapsed(SP_GROUP(&iter)); } @@ -1523,7 +1523,7 @@ void ObjectsPanel::_blendChangedIter(const Gtk::TreeIter& iter, Glib::ustring bl if (blendmode != "normal") { gdouble radius = 0; if (item->style->getFilter()) { - for (auto& primitive: item->style->getFilter()->_children) { + for (auto& primitive: item->style->getFilter()->children) { if (!SP_IS_FILTER_PRIMITIVE(&primitive)) { break; } @@ -1538,7 +1538,7 @@ void ObjectsPanel::_blendChangedIter(const Gtk::TreeIter& iter, Glib::ustring bl SPFilter *filter = new_filter_simple_from_item(_document, item, blendmode.c_str(), radius); sp_style_set_property_url(item, "filter", filter, false); } else { - for (auto& primitive: item->style->getFilter()->_children) { + for (auto& primitive: item->style->getFilter()->children) { if (!SP_IS_FILTER_PRIMITIVE(&primitive)) { break; } @@ -1598,7 +1598,7 @@ void ObjectsPanel::_blurChangedIter(const Gtk::TreeIter& iter, double blur) SPFilter *filter = modify_filter_gaussian_blur_from_item(_document, item, radius); sp_style_set_property_url(item, "filter", filter, false); } else if (item->style->filter.set && item->style->getFilter()) { - for (auto& primitive: item->style->getFilter()->_children) { + for (auto& primitive: item->style->getFilter()->children) { if (!SP_IS_FILTER_PRIMITIVE(&primitive)) { break; } diff --git a/src/ui/dialog/spellcheck.cpp b/src/ui/dialog/spellcheck.cpp index 9338a4e8c..ac8ef5c15 100644 --- a/src/ui/dialog/spellcheck.cpp +++ b/src/ui/dialog/spellcheck.cpp @@ -234,7 +234,7 @@ GSList *SpellCheck::allTextItems (SPObject *r, GSList *l, bool hidden, bool lock return l; // we're not interested in metadata } - for (auto& child: r->_children) { + for (auto& child: r->children) { if (SP_IS_ITEM (&child) && !child.cloned && !desktop->isLayer(SP_ITEM(&child))) { if ((hidden || !desktop->itemIsHidden(SP_ITEM(&child))) && (locked || !SP_ITEM(&child)->isLocked())) { if (SP_IS_TEXT(&child) || SP_IS_FLOWTEXT(&child)) diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 93bd67a3d..a723c86d8 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -115,7 +115,7 @@ void SvgFontsDialog::AttrEntry::set_text(char* t){ void SvgFontsDialog::AttrEntry::on_attr_changed(){ SPObject* o = NULL; - for (auto& node: dialog->get_selected_spfont()->_children) { + for (auto& node: dialog->get_selected_spfont()->children) { switch(this->attr){ case SP_PROP_FONT_FAMILY: if (SP_IS_FONTFACE(&node)){ @@ -170,7 +170,7 @@ void GlyphComboBox::update(SPFont* spfont){ this->append(""); //Gtk is refusing to clear the combobox when I comment out this line this->remove_all(); - for (auto& node: spfont->_children) { + for (auto& node: spfont->children) { if (SP_IS_GLYPH(&node)){ this->append((static_cast(&node))->unicode); } @@ -308,7 +308,7 @@ void SvgFontsDialog::update_global_settings_tab(){ SPFont* font = get_selected_spfont(); if (!font) return; - for (auto& obj: font->_children) { + for (auto& obj: font->children) { if (SP_IS_FONTFACE(&obj)){ _familyname_entry->set_text((SP_FONTFACE(&obj))->font_family); } @@ -413,7 +413,7 @@ SvgFontsDialog::populate_glyphs_box() SPFont* spfont = this->get_selected_spfont(); _glyphs_observer.set(spfont); - for (auto& node: spfont->_children) { + for (auto& node: spfont->children) { if (SP_IS_GLYPH(&node)){ Gtk::TreeModel::Row row = *(_GlyphsListStore->append()); row[_GlyphsListColumns.glyph_node] = static_cast(&node); @@ -431,7 +431,7 @@ SvgFontsDialog::populate_kerning_pairs_box() SPFont* spfont = this->get_selected_spfont(); - for (auto& node: spfont->_children) { + for (auto& node: spfont->children) { if (SP_IS_HKERN(&node)){ Gtk::TreeModel::Row row = *(_KerningPairsListStore->append()); row[_KerningPairsListColumns.first_glyph] = (static_cast(&node))->u1->attribute_string().c_str(); @@ -492,7 +492,7 @@ void SvgFontsDialog::add_glyph(){ Geom::PathVector SvgFontsDialog::flip_coordinate_system(Geom::PathVector pathv){ double units_per_em = 1000; - for (auto& obj: get_selected_spfont()->_children) { + for (auto& obj: get_selected_spfont()->children) { if (SP_IS_FONTFACE(&obj)){ //XML Tree being directly used here while it shouldn't be. sp_repr_get_double(obj.getRepr(), "units-per-em", &units_per_em); @@ -574,7 +574,7 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){ Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d")); - for (auto& obj: get_selected_spfont()->_children) { + for (auto& obj: get_selected_spfont()->children) { if (SP_IS_MISSING_GLYPH(&obj)){ //XML Tree being directly used here while it shouldn't be. @@ -596,7 +596,7 @@ void SvgFontsDialog::reset_missing_glyph_description(){ } SPDocument* doc = desktop->getDocument(); - for (auto& obj: get_selected_spfont()->_children) { + for (auto& obj: get_selected_spfont()->children) { if (SP_IS_MISSING_GLYPH(&obj)){ //XML Tree being directly used here while it shouldn't be. obj.getRepr()->setAttribute("d", (char*) "M0,0h1000v1024h-1000z"); @@ -734,7 +734,7 @@ void SvgFontsDialog::add_kerning_pair(){ //look for this kerning pair on the currently selected font this->kerning_pair = NULL; - for (auto& node: get_selected_spfont()->_children) { + for (auto& node: get_selected_spfont()->children) { //TODO: It is not really correct to get only the first byte of each string. //TODO: We should also support vertical kerning if (SP_IS_HKERN(&node) && (static_cast(&node))->u1->contains((gchar) first_glyph.get_active_text().c_str()[0]) @@ -848,7 +848,7 @@ SPFont *new_font(SPDocument *document) void set_font_family(SPFont* font, char* str){ if (!font) return; - for (auto& obj: font->_children) { + for (auto& obj: font->children) { if (SP_IS_FONTFACE(&obj)){ //XML Tree being directly used here while it shouldn't be. obj.getRepr()->setAttribute("font-family", str); @@ -868,7 +868,7 @@ void SvgFontsDialog::add_font(){ font->setLabel(os.str().c_str()); os2 << "SVGFont " << count; - for (auto& obj: font->_children) { + for (auto& obj: font->children) { if (SP_IS_FONTFACE(&obj)){ //XML Tree being directly used here while it shouldn't be. obj.getRepr()->setAttribute("font-family", os2.str().c_str()); diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 1fdce34a5..84088052e 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -658,7 +658,7 @@ GSList* SymbolsDialog::symbols_in_doc_recursive (SPObject *r, GSList *l) l = g_slist_prepend (l, r); } - for (auto& child: r->_children) { + for (auto& child: r->children) { l = symbols_in_doc_recursive( &child, l ); } @@ -680,7 +680,7 @@ GSList* SymbolsDialog::use_in_doc_recursive (SPObject *r, GSList *l) l = g_slist_prepend (l, r); } - for (auto& child: r->_children) { + for (auto& child: r->children) { l = use_in_doc_recursive( &child, l ); } diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp index 61c8b5d37..fcc9b804c 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -399,7 +399,7 @@ void TagsPanel::_objectsChanged(SPObject* root) void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row* parentRow ) { if ( _desktop && obj ) { - for (auto& child: obj->_children) { + for (auto& child: obj->children) { if (SP_IS_TAG(&child)) { Gtk::TreeModel::iterator iter = parentRow ? _store->prepend(parentRow->children()) : _store->prepend(); @@ -430,7 +430,7 @@ void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row* _tree.expand_to_path( _store->get_path(iteritems) ); - for (auto& child: obj->_children) { + for (auto& child: obj->children) { if (SP_IS_TAG_USE(&child)) { SPItem *item = SP_TAG_USE(&child)->ref->getObject(); @@ -459,7 +459,7 @@ void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row* void TagsPanel::_select_tag( SPTag * tag ) { - for (auto& child: tag->_children) { + for (auto& child: tag->children) { if (SP_IS_TAG(&child)) { _select_tag(SP_TAG(&child)); } else if (SP_IS_TAG_USE(&child)) { @@ -649,7 +649,7 @@ bool TagsPanel::_handleButtonEvent(GdkEventButton* event) for(auto i=items.begin();i!=items.end();++i){ SPObject *newobj = *i; bool addchild = true; - for (auto& child: obj->_children) { + for (auto& child: obj->children) { if (SP_IS_TAG_USE(&child) && SP_TAG_USE(&child)->ref->getObject() == newobj) { addchild = false; } diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp index 2adba38c5..9a0b37913 100644 --- a/src/ui/tools/box3d-tool.cpp +++ b/src/ui/tools/box3d-tool.cpp @@ -118,7 +118,7 @@ static void sp_box3d_context_ensure_persp_in_defs(SPDocument *document) { SPDefs *defs = document->getDefs(); bool has_persp = false; - for (auto& child: defs->_children) { + for (auto& child: defs->children) { if (SP_IS_PERSP3D(&child)) { has_persp = true; break; diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index be8ce6d0c..11752726b 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -1114,7 +1114,7 @@ void ConnectorTool::_setActiveShape(SPItem *item) { // The idea here is to try and add a group's children to solidify // connection handling. We react to path objects with only one node. - for (auto& child: item->_children) { + for (auto& child: item->children) { if (SP_IS_PATH(&child) && SP_PATH(&child)->nodesInPath() == 1) { this->_activeShapeAddKnot((SPItem *) &child); } diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 3dfac5e3d..87b7bf7e3 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -378,7 +378,7 @@ void gather_items(NodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::Shape r.role = role; s.insert(r); } else if (role != SHAPE_ROLE_NORMAL && (SP_IS_GROUP(obj) || SP_IS_OBJECTGROUP(obj))) { - for (auto& c: obj->_children) { + for (auto& c: obj->children) { gather_items(nt, base, &c, role, s); } } else if (SP_IS_ITEM(obj)) { diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 7da0973d5..361986d0c 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -385,7 +385,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P if (dynamic_cast(item) && !dynamic_cast(item)) { GSList *children = NULL; - for (auto& child: item->_children) { + for (auto& child: item->children) { if (dynamic_cast(static_cast(&child))) { children = g_slist_prepend(children, &child); } @@ -832,7 +832,7 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or double offset_l = 0; double offset_h = 0; SPObject *child_prev = NULL; - for (auto& child: vector->_children) { + for (auto& child: vector->children) { SPStop *stop = dynamic_cast(&child); if (!stop) { continue; @@ -894,7 +894,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, bool did = false; if (dynamic_cast(item)) { - for (auto& child: item->_children) { + for (auto& child: item->children) { SPItem *childItem = dynamic_cast(&child); if (childItem) { if (sp_tweak_color_recursive (mode, childItem, item_at_point, @@ -951,7 +951,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, Geom::Affine i2dt = item->i2dt_affine (); if (style->filter.set && style->getFilter()) { //cycle through filter primitives - for (auto& primitive_obj: style->getFilter()->_children) { + for (auto& primitive_obj: style->getFilter()->children) { SPFilterPrimitive *primitive = dynamic_cast(&primitive_obj); if (primitive) { //if primitive is gaussianblur diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp index 46a0b3547..c080579f1 100644 --- a/src/ui/widget/layer-selector.cpp +++ b/src/ui/widget/layer-selector.cpp @@ -352,7 +352,7 @@ void LayerSelector::_buildSiblingEntries( ) { using Inkscape::Util::rest; - auto siblings = parent._children | boost::adaptors::filtered(is_layer(_desktop)) | boost::adaptors::reversed; + auto siblings = parent.children | boost::adaptors::filtered(is_layer(_desktop)) | boost::adaptors::reversed; SPObject *layer( hierarchy ? &*hierarchy : NULL ); -- cgit v1.2.3 From 3c593bb8da3357514ff5b4f3154d08c4508ad47e Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 20 Jul 2016 11:01:17 +0200 Subject: Changed arguments and names of selection chemistry functions (bzr r14954.1.22) --- src/ui/interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index bcf055654..d19526105 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -1916,7 +1916,7 @@ void ContextMenu::MakeGroupMenu(void) void ContextMenu::ActivateGroup(void) { - sp_selection_group(_desktop->selection, _desktop); + sp_selection_group_ui(_desktop->selection, _desktop); } void ContextMenu::ActivateUngroup(void) -- cgit v1.2.3 From a227e8d45e7eaa6bf25d8ab65fbd404bc4597306 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 20 Jul 2016 13:45:05 +0200 Subject: Changed signatures of boolean functions (bzr r14954.1.24) --- src/ui/tools/calligraphic-tool.cpp | 4 ++-- src/ui/tools/eraser-tool.cpp | 6 +++--- src/ui/tools/flood-tool.cpp | 2 +- src/ui/tools/spray-tool.cpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp index 28195eb75..12dcedd21 100644 --- a/src/ui/tools/calligraphic-tool.cpp +++ b/src/ui/tools/calligraphic-tool.cpp @@ -930,10 +930,10 @@ void CalligraphicTool::set_to_accumulated(bool unionize, bool subtract) { if (unionize) { desktop->getSelection()->add(this->repr); - sp_selected_path_union_skip_undo(desktop->getSelection(), desktop); + sp_selected_path_union_skip_undo(desktop->getSelection()); } else if (subtract) { desktop->getSelection()->add(this->repr); - sp_selected_path_diff_skip_undo(desktop->getSelection(), desktop); + sp_selected_path_diff_skip_undo(desktop->getSelection()); } else { if (this->keep_selected) { desktop->getSelection()->set(this->repr); diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 534123e90..8ed75fbdb 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -718,7 +718,7 @@ void EraserTool::set_to_accumulated() { Inkscape::GC::release(dup); // parent takes over selection->set(dup); if (!this->nowidth) { - sp_selected_path_union_skip_undo(selection, desktop); + sp_selected_path_union_skip_undo(selection); } selection->add(item); if(item->style->fill_rule.value == SP_WIND_RULE_EVENODD){ @@ -729,9 +729,9 @@ void EraserTool::set_to_accumulated() { css = 0; } if (this->nowidth) { - sp_selected_path_cut_skip_undo(selection, desktop); + sp_selected_path_cut_skip_undo(selection); } else { - sp_selected_path_diff_skip_undo(selection, desktop); + sp_selected_path_diff_skip_undo(selection); } workDone = true; // TODO set this only if something was cut. bool break_apart = prefs->getBool("/tools/eraser/break_apart", false); diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp index 748c82717..b5a2fd871 100644 --- a/src/ui/tools/flood-tool.cpp +++ b/src/ui/tools/flood-tool.cpp @@ -456,7 +456,7 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto ngettext("Area filled, path with %d node created and unioned with selection.","Area filled, path with %d nodes created and unioned with selection.", SP_PATH(reprobj)->nodesInPath()), SP_PATH(reprobj)->nodesInPath() ); selection->add(reprobj); - sp_selected_path_union_skip_undo(desktop->getSelection(), desktop); + sp_selected_path_union_skip_undo(desktop->getSelection()); } else { desktop->messageStack()->flashF( Inkscape::WARNING_MESSAGE, ngettext("Area filled, path with %d node created.","Area filled, path with %d nodes created.", diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index 5d804a9bd..a95e5aa96 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -1050,7 +1050,7 @@ static bool sp_spray_recursive(SPDesktop *desktop, if (unionResult) { // No need to add the very first item (initialized with NULL). selection->add(unionResult); } - sp_selected_path_union_skip_undo(selection, selection->desktop()); + sp_selected_path_union_skip_undo(selection); selection->add(parent_item); Inkscape::GC::release(copy); did = true; -- cgit v1.2.3 From d31923a399f3c7cde85aae8406191e37ad877eb7 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Fri, 22 Jul 2016 11:32:35 +0200 Subject: Improved spray tool, changed selection to object set (bzr r14954.1.25) --- src/ui/tools/spray-tool.cpp | 54 +++++++++++++++++++++------------------------ src/ui/tools/spray-tool.h | 9 +++++++- 2 files changed, 33 insertions(+), 30 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index a95e5aa96..49ff50428 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -13,6 +13,7 @@ * Jon A. Cruz * Abhishek Sharma * Jabiertxo Arraiza + * Adrian Boguszewski * * Copyright (C) 2009 authors * @@ -196,6 +197,7 @@ SprayTool::SprayTool() } SprayTool::~SprayTool() { + object_set.clear(); this->enableGrDrag(false); this->style_set_connection.disconnect(); @@ -862,7 +864,7 @@ static bool fit_item(SPDesktop *desktop, } static bool sp_spray_recursive(SPDesktop *desktop, - Inkscape::Selection *selection, + Inkscape::ObjectSet *set, SPItem *item, Geom::Point p, Geom::Point /*vector*/, @@ -907,7 +909,7 @@ static bool sp_spray_recursive(SPDesktop *desktop, if (box) { // convert 3D boxes to ordinary groups before spraying their shapes item = box3d_convert_to_group(box); - selection->add(item); + set->add(item); } } @@ -996,23 +998,11 @@ static bool sp_spray_recursive(SPDesktop *desktop, } #ifdef ENABLE_SPRAY_MODE_SINGLE_PATH } else if (mode == SPRAY_MODE_SINGLE_PATH) { + long setSize = boost::distance(set->items()); + SPItem *parent_item = setSize > 0 ? set->items().front() : nullptr; // Initial object + SPItem *unionResult = setSize > 1 ? *(++set->items().begin()) : nullptr; // Previous union + SPItem *item_copied = nullptr; // Projected object - SPItem *parent_item = NULL; // Initial object - SPItem *item_copied = NULL; // Projected object - SPItem *unionResult = NULL; // Previous union - - int i=1; - auto items= selection->items(); - for(auto it=items.begin();it!=items.end(); ++it){ - SPItem *item1 = *it; - if (i == 1) { - parent_item = item1; - } - if (i == 2) { - unionResult = item1; - } - i++; - } if (parent_item) { SPDocument *doc = parent_item->document; Inkscape::XML::Document* xml_doc = doc->getReprDoc(); @@ -1045,13 +1035,13 @@ static bool sp_spray_recursive(SPDesktop *desktop, sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y])); // Union and duplication - selection->clear(); - selection->add(item_copied); + set->clear(); + set->add(item_copied); if (unionResult) { // No need to add the very first item (initialized with NULL). - selection->add(unionResult); + set->add(unionResult); } - sp_selected_path_union_skip_undo(selection); - selection->add(parent_item); + sp_selected_path_union_skip_undo(set); + set->add(parent_item); Inkscape::GC::release(copy); did = true; } @@ -1146,9 +1136,8 @@ static bool sp_spray_recursive(SPDesktop *desktop, static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point p, Geom::Point vector, bool reverse) { SPDesktop *desktop = tc->desktop; - Inkscape::Selection *selection = desktop->getSelection(); - - if (selection->isEmpty()) { + Inkscape::ObjectSet *set = tc->objectSet(); + if (set->isEmpty()) { return false; } @@ -1170,7 +1159,7 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point double move_standard_deviation = get_move_standard_deviation(tc); { - std::vector const items(selection->items().begin(), selection->items().end()); + std::vector const items(set->items().begin(), set->items().end()); for(std::vector::const_iterator i=items.begin();i!=items.end(); ++i){ SPItem *item = *i; @@ -1182,7 +1171,7 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point SPItem *item = *i; g_assert(item != NULL); if (sp_spray_recursive(desktop - , selection + , set , item , p, vector , tc->mode @@ -1276,6 +1265,11 @@ bool SprayTool::root_handler(GdkEvent* event) { this->is_dilating = true; this->has_dilated = false; + object_set = *desktop->getSelection(); + if (mode == SPRAY_MODE_SINGLE_PATH) { + desktop->getSelection()->clear(); + } + if(this->is_dilating && event->button.button == 1 && !this->space_panning) { sp_spray_dilate(this, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT(event)); } @@ -1299,7 +1293,7 @@ bool SprayTool::root_handler(GdkEvent* event) { guint num = 0; if (!desktop->selection->isEmpty()) { - num = boost::distance(desktop->selection->items() ); + num = (guint) boost::distance(desktop->selection->items()); } if (num == 0) { this->message_context->flash(Inkscape::ERROR_MESSAGE, _("Nothing selected! Select objects to spray.")); @@ -1384,6 +1378,8 @@ bool SprayTool::root_handler(GdkEvent* event) { SP_VERB_CONTEXT_SPRAY, _("Spray with clones")); break; case SPRAY_MODE_SINGLE_PATH: + sp_selected_path_union_skip_undo(objectSet()); + desktop->getSelection()->add(object_set.objects().begin(), object_set.objects().end()); DocumentUndo::done(this->desktop->getDocument(), SP_VERB_CONTEXT_SPRAY, _("Spray in single path")); break; diff --git a/src/ui/tools/spray-tool.h b/src/ui/tools/spray-tool.h index c81110b37..d5504d565 100644 --- a/src/ui/tools/spray-tool.h +++ b/src/ui/tools/spray-tool.h @@ -13,6 +13,7 @@ * Vincent MONTAGNE * Pierre BARBRY-BLOT * Jabiertxo ARRAIZA + * Adrian Boguszewski * * Copyright (C) 2009 authors * @@ -120,8 +121,14 @@ public: virtual const std::string& getPrefsPath(); - void update_cursor(bool /*with_shift*/); + + ObjectSet* objectSet() { + return &object_set; + } + +private: + ObjectSet object_set; }; } -- cgit v1.2.3 From ff4fbbc93f67afd6cbf851691833a50d6c76b350 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 27 Jul 2016 12:19:03 +0200 Subject: Renamed some functions, fixed tests (bzr r14954.1.28) --- src/ui/clipboard.cpp | 4 ++-- src/ui/dialog/export.cpp | 2 +- src/ui/dialog/transformation.cpp | 22 +++++++++++----------- src/ui/interface.cpp | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src/ui') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index b25a70b15..504a5e2ce 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -539,8 +539,8 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a else { Geom::OptRect sel_size = selection->visualBounds(); if ( sel_size ) { - sp_selection_scale_relative(selection, sel_size->midpoint(), - _getScale(desktop, min, max, *sel_size, apply_x, apply_y)); + sp_object_set_scale_relative(selection, sel_size->midpoint(), + _getScale(desktop, min, max, *sel_size, apply_x, apply_y)); } } pasted = true; diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 4ab007408..08fc25464 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -814,7 +814,7 @@ void Export::onAreaToggled () case SELECTION_SELECTION: if ((SP_ACTIVE_DESKTOP->getSelection())->isEmpty() == false) { - sp_selection_get_export_hints (SP_ACTIVE_DESKTOP->getSelection(), filename, &xdpi, &ydpi); + sp_object_set_get_export_hints(SP_ACTIVE_DESKTOP->getSelection(), filename, &xdpi, &ydpi); /* If we still don't have a filename -- let's build one that's nice */ diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index d4a0ffd68..d82b5ded3 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -723,12 +723,12 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) if (!prefs->getBool("/dialogs/transformation/applyseparately")) { // move selection as a whole if (_check_move_relative.get_active()) { - sp_selection_move_relative(selection, x, y); + sp_object_set_move_relative(selection, x, y); } else { Geom::OptRect bbox = selection->preferredBounds(); if (bbox) { - sp_selection_move_relative(selection, - x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]); + sp_object_set_move_relative(selection, + x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]); } } } else { @@ -791,8 +791,8 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) } else { Geom::OptRect bbox = selection->preferredBounds(); if (bbox) { - sp_selection_move_relative(selection, - x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]); + sp_object_set_move_relative(selection, + x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]); } } } @@ -856,7 +856,7 @@ void Transformation::applyPageScale(Inkscape::Selection *selection) double y1 = bbox_pref->midpoint()[Geom::Y] + new_height/2; Geom::Affine scaler = get_scale_transform_for_variable_stroke (*bbox_pref, *bbox_geom, transform_stroke, preserve, x0, y0, x1, y1); - sp_selection_apply_affine(selection, scaler); + sp_object_set_apply_affine(selection, scaler); } } @@ -882,7 +882,7 @@ void Transformation::applyPageRotate(Inkscape::Selection *selection) } else { boost::optional center = selection->center(); if (center) { - sp_selection_rotate_relative(selection, *center, angle); + sp_object_set_rotate_relative(selection, *center, angle); } } @@ -949,7 +949,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection) getDesktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, not used.")); return; } - sp_selection_skew_relative(selection, *center, 0.01*skewX, 0.01*skewY); + sp_object_set_skew_relative(selection, *center, 0.01 * skewX, 0.01 * skewY); } else if (_units_skew.isRadial()) { //deg or rad double angleX = _scalar_skew_horizontal.getValue("rad"); double angleY = _scalar_skew_vertical.getValue("rad"); @@ -962,7 +962,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection) } double skewX = tan(-angleX); double skewY = tan(angleY); - sp_selection_skew_relative(selection, *center, skewX, skewY); + sp_object_set_skew_relative(selection, *center, skewX, skewY); } else { // absolute displacement double skewX = _scalar_skew_horizontal.getValue("px"); double skewY = _scalar_skew_vertical.getValue("px"); @@ -970,7 +970,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection) getDesktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, not used.")); return; } - sp_selection_skew_relative(selection, *center, skewX/height, skewY/width); + sp_object_set_skew_relative(selection, *center, skewX / height, skewY / width); } } } @@ -1003,7 +1003,7 @@ void Transformation::applyPageTransform(Inkscape::Selection *selection) item->updateRepr(); } } else { - sp_selection_apply_affine(selection, displayed); // post-multiply each object's transform + sp_object_set_apply_affine(selection, displayed); // post-multiply each object's transform } DocumentUndo::done(selection->desktop()->getDocument(), SP_VERB_DIALOG_TRANSFORM, diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index d19526105..eb3034ca3 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -1250,7 +1250,7 @@ sp_ui_drag_data_received(GtkWidget *widget, Geom::OptRect sel_bbox = selection->visualBounds(); if (sel_bbox) { Geom::Point m( desktop->point() - sel_bbox->midpoint() ); - sp_selection_move_relative(selection, m, false); + sp_object_set_move_relative(selection, m, false); } } @@ -1916,7 +1916,7 @@ void ContextMenu::MakeGroupMenu(void) void ContextMenu::ActivateGroup(void) { - sp_selection_group_ui(_desktop->selection, _desktop); + sp_selection_group(_desktop->selection, _desktop); } void ContextMenu::ActivateUngroup(void) -- cgit v1.2.3 From 58111034d09da960cf9982b703c6ab2647422e0b Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 28 Jul 2016 13:19:42 +0100 Subject: ui/widgets: Drop GTK2 fallbacks (bzr r15023.2.6) --- src/ui/widget/addtoicon.cpp | 33 ----- src/ui/widget/addtoicon.h | 14 -- src/ui/widget/anchor-selector.cpp | 10 -- src/ui/widget/anchor-selector.h | 12 +- src/ui/widget/clipmaskicon.cpp | 33 ----- src/ui/widget/clipmaskicon.h | 13 -- src/ui/widget/color-icc-selector.cpp | 23 --- src/ui/widget/color-icc-selector.h | 8 - src/ui/widget/color-notebook.cpp | 30 ---- src/ui/widget/color-notebook.h | 8 - src/ui/widget/color-picker.cpp | 5 - src/ui/widget/color-preview.cpp | 26 ---- src/ui/widget/color-preview.h | 6 - src/ui/widget/color-scales.cpp | 27 ---- src/ui/widget/color-scales.h | 8 - src/ui/widget/color-slider.cpp | 122 +--------------- src/ui/widget/color-slider.h | 18 --- src/ui/widget/color-wheel-selector.cpp | 46 +----- src/ui/widget/color-wheel-selector.h | 12 -- src/ui/widget/dock-item.cpp | 8 - src/ui/widget/dock.cpp | 12 -- src/ui/widget/gimpspinscale.c | 260 +-------------------------------- src/ui/widget/highlight-picker.cpp | 33 ----- src/ui/widget/highlight-picker.h | 14 -- src/ui/widget/imagetoggler.cpp | 33 ----- src/ui/widget/imagetoggler.h | 14 -- src/ui/widget/insertordericon.cpp | 32 ---- src/ui/widget/insertordericon.h | 13 -- src/ui/widget/layertypeicon.cpp | 33 ----- src/ui/widget/layertypeicon.h | 14 -- src/ui/widget/licensor.cpp | 8 - src/ui/widget/notebook-page.cpp | 12 -- src/ui/widget/notebook-page.h | 13 -- src/ui/widget/page-sizer.cpp | 43 ------ src/ui/widget/page-sizer.h | 26 +--- src/ui/widget/panel.cpp | 6 - src/ui/widget/panel.h | 18 +-- src/ui/widget/point.cpp | 4 - src/ui/widget/point.h | 4 - src/ui/widget/preferences-widget.cpp | 80 +--------- src/ui/widget/preferences-widget.h | 25 ---- src/ui/widget/random.cpp | 4 - src/ui/widget/random.h | 4 - src/ui/widget/scalar.cpp | 10 +- src/ui/widget/scalar.h | 4 - src/ui/widget/selected-style.cpp | 37 ----- src/ui/widget/selected-style.h | 15 +- src/ui/widget/spin-scale.cpp | 28 +--- src/ui/widget/spin-scale.h | 25 +--- src/ui/widget/spin-slider.cpp | 61 +------- src/ui/widget/spin-slider.h | 18 +-- src/ui/widget/style-swatch.cpp | 23 +-- src/ui/widget/style-swatch.h | 8 - src/ui/widget/tolerance-slider.cpp | 10 +- src/ui/widget/tolerance-slider.h | 10 -- 55 files changed, 41 insertions(+), 1375 deletions(-) (limited to 'src/ui') diff --git a/src/ui/widget/addtoicon.cpp b/src/ui/widget/addtoicon.cpp index 10294125d..ab50fcd8f 100644 --- a/src/ui/widget/addtoicon.cpp +++ b/src/ui/widget/addtoicon.cpp @@ -51,8 +51,6 @@ AddToIcon::AddToIcon() : set_pixbuf(); } - -#if WITH_GTKMM_3_0 void AddToIcon::get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const @@ -82,47 +80,16 @@ void AddToIcon::get_preferred_width_vfunc(Gtk::Widget& widget, nat_w += (nat_w) >> 1; } } -#else -void AddToIcon::get_size_vfunc(Gtk::Widget& widget, - const Gdk::Rectangle* cell_area, - int* x_offset, - int* y_offset, - int* width, - int* height ) const -{ - Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height ); - - if ( width ) { - *width = phys;//+= (*width) >> 1; - } - if ( height ) { - *height =phys;//+= (*height) >> 1; - } -} -#endif -#if WITH_GTKMM_3_0 void AddToIcon::render_vfunc( const Cairo::RefPtr& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, Gtk::CellRendererState flags ) -#else -void AddToIcon::render_vfunc( const Glib::RefPtr& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags ) -#endif { set_pixbuf(); -#if WITH_GTKMM_3_0 Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags ); -#else - Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags ); -#endif } bool AddToIcon::activate_vfunc(GdkEvent* /*event*/, diff --git a/src/ui/widget/addtoicon.h b/src/ui/widget/addtoicon.h index a8d900d1f..3b2228754 100644 --- a/src/ui/widget/addtoicon.h +++ b/src/ui/widget/addtoicon.h @@ -31,8 +31,6 @@ public: Glib::PropertyProxy< Glib::RefPtr > property_pixbuf_off(); protected: - -#if WITH_GTKMM_3_0 virtual void render_vfunc( const Cairo::RefPtr& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, @@ -46,18 +44,6 @@ protected: virtual void get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const; -#else - virtual void render_vfunc( const Glib::RefPtr& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags ); - - virtual void get_size_vfunc( Gtk::Widget &widget, - Gdk::Rectangle const *cell_area, - int *x_offset, int *y_offset, int *width, int *height ) const; -#endif virtual bool activate_vfunc(GdkEvent *event, Gtk::Widget &widget, diff --git a/src/ui/widget/anchor-selector.cpp b/src/ui/widget/anchor-selector.cpp index df00b786a..0d6030ac6 100644 --- a/src/ui/widget/anchor-selector.cpp +++ b/src/ui/widget/anchor-selector.cpp @@ -28,11 +28,7 @@ void AnchorSelector::setupButton(const Glib::ustring& icon, Gtk::ToggleButton& b AnchorSelector::AnchorSelector() : Gtk::Alignment(0.5, 0, 0, 0), -#if WITH_GTKMM_3_0 _container() -#else - _container(3, 3, true) -#endif { setupButton(INKSCAPE_ICON("boundingbox_top_left"), _buttons[0]); setupButton(INKSCAPE_ICON("boundingbox_top"), _buttons[1]); @@ -44,20 +40,14 @@ AnchorSelector::AnchorSelector() setupButton(INKSCAPE_ICON("boundingbox_bottom"), _buttons[7]); setupButton(INKSCAPE_ICON("boundingbox_bottom_right"), _buttons[8]); -#if WITH_GTKMM_3_0 _container.set_row_homogeneous(); _container.set_column_homogeneous(true); -#endif for(int i = 0; i < 9; ++i) { _buttons[i].signal_clicked().connect( sigc::bind(sigc::mem_fun(*this, &AnchorSelector::btn_activated), i)); -#if WITH_GTKMM_3_0 _container.attach(_buttons[i], i % 3, i / 3, 1, 1); -#else - _container.attach(_buttons[i], i % 3, i % 3+1, i / 3, i / 3+1, Gtk::FILL, Gtk::FILL); -#endif } _selection = 4; _buttons[4].set_active(); diff --git a/src/ui/widget/anchor-selector.h b/src/ui/widget/anchor-selector.h index 0a702d296..96331fae3 100644 --- a/src/ui/widget/anchor-selector.h +++ b/src/ui/widget/anchor-selector.h @@ -16,12 +16,7 @@ #include #include - -#if WITH_GTKMM_3_0 - #include -#else - #include -#endif +#include namespace Inkscape { namespace UI { @@ -32,12 +27,7 @@ class AnchorSelector : public Gtk::Alignment private: Gtk::ToggleButton _buttons[9]; int _selection; - -#if WITH_GTKMM_3_0 Gtk::Grid _container; -#else - Gtk::Table _container; -#endif sigc::signal _selectionChanged; diff --git a/src/ui/widget/clipmaskicon.cpp b/src/ui/widget/clipmaskicon.cpp index 421f1df1e..b914eeb2d 100644 --- a/src/ui/widget/clipmaskicon.cpp +++ b/src/ui/widget/clipmaskicon.cpp @@ -63,8 +63,6 @@ ClipMaskIcon::ClipMaskIcon() : property_pixbuf() = Glib::RefPtr(0); } - -#if WITH_GTKMM_3_0 void ClipMaskIcon::get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const @@ -94,39 +92,12 @@ void ClipMaskIcon::get_preferred_width_vfunc(Gtk::Widget& widget, nat_w += (nat_w) >> 1; } } -#else -void ClipMaskIcon::get_size_vfunc(Gtk::Widget& widget, - const Gdk::Rectangle* cell_area, - int* x_offset, - int* y_offset, - int* width, - int* height ) const -{ - Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height ); - - if ( width ) { - *width = phys;//+= (*width) >> 1; - } - if ( height ) { - *height =phys;//+= (*height) >> 1; - } -} -#endif -#if WITH_GTKMM_3_0 void ClipMaskIcon::render_vfunc( const Cairo::RefPtr& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, Gtk::CellRendererState flags ) -#else -void ClipMaskIcon::render_vfunc( const Glib::RefPtr& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags ) -#endif { switch (_property_active.get_value()) { @@ -143,11 +114,7 @@ void ClipMaskIcon::render_vfunc( const Glib::RefPtr& window, property_pixbuf() = Glib::RefPtr(0); break; } -#if WITH_GTKMM_3_0 Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags ); -#else - Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags ); -#endif } bool ClipMaskIcon::activate_vfunc(GdkEvent* /*event*/, diff --git a/src/ui/widget/clipmaskicon.h b/src/ui/widget/clipmaskicon.h index eca852a83..0d149edb8 100644 --- a/src/ui/widget/clipmaskicon.h +++ b/src/ui/widget/clipmaskicon.h @@ -32,7 +32,6 @@ public: protected: -#if WITH_GTKMM_3_0 virtual void render_vfunc( const Cairo::RefPtr& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, @@ -46,18 +45,6 @@ protected: virtual void get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const; -#else - virtual void render_vfunc( const Glib::RefPtr& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags ); - - virtual void get_size_vfunc( Gtk::Widget &widget, - Gdk::Rectangle const *cell_area, - int *x_offset, int *y_offset, int *width, int *height ) const; -#endif virtual bool activate_vfunc(GdkEvent *event, Gtk::Widget &widget, diff --git a/src/ui/widget/color-icc-selector.cpp b/src/ui/widget/color-icc-selector.cpp index e4f58fe8a..04a5ab368 100644 --- a/src/ui/widget/color-icc-selector.cpp +++ b/src/ui/widget/color-icc-selector.cpp @@ -87,7 +87,6 @@ GtkAttachOptions operator|(GtkAttachOptions lhs, GtkAttachOptions rhs) void attachToGridOrTable(GtkWidget *parent, GtkWidget *child, guint left, guint top, guint width, guint height, bool hexpand = false, bool centered = false, guint xpadding = XPAD, guint ypadding = YPAD) { -#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 12, 0) gtk_widget_set_margin_start(child, xpadding); gtk_widget_set_margin_end(child, xpadding); @@ -106,14 +105,6 @@ void attachToGridOrTable(GtkWidget *parent, GtkWidget *child, guint left, guint gtk_widget_set_valign(child, GTK_ALIGN_CENTER); } gtk_grid_attach(GTK_GRID(parent), child, left, top, width, height); -#else - GtkAttachOptions xoptions = - centered ? static_cast(0) : hexpand ? (GTK_EXPAND | GTK_FILL) : GTK_FILL; - GtkAttachOptions yoptions = centered ? static_cast(0) : GTK_FILL; - - gtk_table_attach(GTK_TABLE(parent), child, left, left + width, top, top + height, xoptions, yoptions, xpadding, - ypadding); -#endif } } // namespace @@ -431,12 +422,7 @@ void ColorICCSelector::init() _impl->_compUI[i]._label = gtk_label_new_with_mnemonic(labelStr.c_str()); -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(_impl->_compUI[i]._label, GTK_ALIGN_END); -#else - gtk_misc_set_alignment(GTK_MISC(_impl->_compUI[i]._label), 1.0, 0.5); -#endif - gtk_widget_show(_impl->_compUI[i]._label); gtk_widget_set_no_show_all(_impl->_compUI[i]._label, TRUE); @@ -495,12 +481,7 @@ void ColorICCSelector::init() // Label _impl->_label = gtk_label_new_with_mnemonic(_("_A:")); -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(_impl->_label, GTK_ALIGN_END); -#else - gtk_misc_set_alignment(GTK_MISC(_impl->_label), 1.0, 0.5); -#endif - gtk_widget_show(_impl->_label); attachToGridOrTable(t, _impl->_label, 0, row, 1, 1); @@ -727,11 +708,7 @@ void ColorICCSelectorImpl::_profilesChanged(std::string const & /*name*/) {} void ColorICCSelector::on_show() { -#if GTK_CHECK_VERSION(3, 0, 0) Gtk::Grid::on_show(); -#else - Gtk::Table::on_show(); -#endif _colorChanged(); } diff --git a/src/ui/widget/color-icc-selector.h b/src/ui/widget/color-icc-selector.h index 1bcb0a540..aaa8372b8 100644 --- a/src/ui/widget/color-icc-selector.h +++ b/src/ui/widget/color-icc-selector.h @@ -6,11 +6,7 @@ #endif #include -#if WITH_GTKMM_3_0 #include -#else -#include -#endif #include "ui/selected-color.h" @@ -24,11 +20,7 @@ namespace Widget { class ColorICCSelectorImpl; class ColorICCSelector -#if GTK_CHECK_VERSION(3, 0, 0) : public Gtk::Grid -#else - : public Gtk::Table -#endif { public: static const gchar *MODE_NAME; diff --git a/src/ui/widget/color-notebook.cpp b/src/ui/widget/color-notebook.cpp index 6d7ada734..d2c4efc74 100644 --- a/src/ui/widget/color-notebook.cpp +++ b/src/ui/widget/color-notebook.cpp @@ -56,13 +56,8 @@ namespace Widget { ColorNotebook::ColorNotebook(SelectedColor &color) -#if GTK_CHECK_VERSION(3, 0, 0) : Gtk::Grid() -#else - : Gtk::Table(2, 3, false) -#endif , _selected_color(color) - { Page *page; @@ -110,12 +105,8 @@ void ColorNotebook::_initUI() notebook->set_show_tabs(false); _book = GTK_WIDGET(notebook->gobj()); -#if GTK_CHECK_VERSION(3, 0, 0) _buttonbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_set_homogeneous(GTK_BOX(_buttonbox), TRUE); -#else - _buttonbox = gtk_hbox_new(TRUE, 2); -#endif gtk_widget_show(_buttonbox); _buttons = new GtkWidget *[_available_pages.size()]; @@ -126,7 +117,6 @@ void ColorNotebook::_initUI() sp_set_font_size_smaller(_buttonbox); -#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 12, 0) gtk_widget_set_margin_start(_buttonbox, XPAD); gtk_widget_set_margin_end(_buttonbox, XPAD); @@ -139,14 +129,9 @@ void ColorNotebook::_initUI() gtk_widget_set_hexpand(_buttonbox, TRUE); gtk_widget_set_valign(_buttonbox, GTK_ALIGN_CENTER); attach(*Glib::wrap(_buttonbox), 0, row, 2, 1); -#else - attach(*Glib::wrap(_buttonbox), 0, 2, row, row + 1, Gtk::EXPAND | Gtk::FILL, static_cast(0), - XPAD, YPAD); -#endif row++; -#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 12, 0) gtk_widget_set_margin_start(_book, XPAD * 2); gtk_widget_set_margin_end(_book, XPAD * 2); @@ -159,20 +144,13 @@ void ColorNotebook::_initUI() gtk_widget_set_hexpand(_book, TRUE); gtk_widget_set_vexpand(_book, TRUE); attach(*notebook, 0, row, 2, 1); -#else - attach(*notebook, 0, 2, row, row + 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, XPAD * 2, YPAD); -#endif // restore the last active page Inkscape::Preferences *prefs = Inkscape::Preferences::get(); _setCurrentPage(prefs->getInt("/colorselector/page", 0)); row++; -#if GTK_CHECK_VERSION(3, 0, 0) GtkWidget *rgbabox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); -#else - GtkWidget *rgbabox = gtk_hbox_new(FALSE, 0); -#endif #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) /* Create color management icons */ @@ -210,11 +188,7 @@ void ColorNotebook::_initUI() /* Create RGBA entry and color preview */ _rgbal = gtk_label_new_with_mnemonic(_("RGBA_:")); -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(_rgbal, GTK_ALIGN_END); -#else - gtk_misc_set_alignment(GTK_MISC(_rgbal), 1.0, 0.5); -#endif gtk_box_pack_start(GTK_BOX(rgbabox), _rgbal, TRUE, TRUE, 2); ColorEntry *rgba_entry = Gtk::manage(new ColorEntry(_selected_color)); @@ -230,7 +204,6 @@ void ColorNotebook::_initUI() gtk_widget_hide(GTK_WIDGET(_box_toomuchink)); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) -#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 12, 0) gtk_widget_set_margin_start(rgbabox, XPAD); gtk_widget_set_margin_end(rgbabox, XPAD); @@ -241,9 +214,6 @@ void ColorNotebook::_initUI() gtk_widget_set_margin_top(rgbabox, YPAD); gtk_widget_set_margin_bottom(rgbabox, YPAD); attach(*Glib::wrap(rgbabox), 0, row, 2, 1); -#else - attach(*Glib::wrap(rgbabox), 0, 2, row, row + 1, Gtk::FILL, Gtk::SHRINK, XPAD, YPAD); -#endif #ifdef SPCS_PREVIEW _p = sp_color_preview_new(0xffffffff); diff --git a/src/ui/widget/color-notebook.h b/src/ui/widget/color-notebook.h index d28028c72..35e46ef14 100644 --- a/src/ui/widget/color-notebook.h +++ b/src/ui/widget/color-notebook.h @@ -19,11 +19,7 @@ #endif #include -#if WITH_GTKMM_3_0 #include -#else -#include -#endif #include #include @@ -35,11 +31,7 @@ namespace UI { namespace Widget { class ColorNotebook -#if GTK_CHECK_VERSION(3, 0, 0) : public Gtk::Grid -#else - : public Gtk::Table -#endif { public: ColorNotebook(SelectedColor &color); diff --git a/src/ui/widget/color-picker.cpp b/src/ui/widget/color-picker.cpp index a66fbfc9c..5a62c3c98 100644 --- a/src/ui/widget/color-picker.cpp +++ b/src/ui/widget/color-picker.cpp @@ -59,13 +59,8 @@ void ColorPicker::setupDialog(const Glib::ustring &title) _color_selector = Gtk::manage(new ColorNotebook(_selected_color)); -#if WITH_GTKMM_3_0 _colorSelectorDialog.get_content_area()->pack_start ( *_color_selector, true, true, 0); -#else - _colorSelectorDialog.get_vbox()->pack_start ( - *_color_selector, true, true, 0); -#endif _color_selector->show(); } diff --git a/src/ui/widget/color-preview.cpp b/src/ui/widget/color-preview.cpp index 62c7cca1d..c9b6e56d2 100644 --- a/src/ui/widget/color-preview.cpp +++ b/src/ui/widget/color-preview.cpp @@ -34,7 +34,6 @@ ColorPreview::on_size_allocate (Gtk::Allocation &all) queue_draw(); } -#if WITH_GTKMM_3_0 void ColorPreview::get_preferred_height_vfunc(int& minimum_height, int& natural_height) const { @@ -58,31 +57,6 @@ ColorPreview::get_preferred_width_for_height_vfunc(int /* height */, int& minimu { minimum_width = natural_width = SPCP_DEFAULT_WIDTH; } -#else -void -ColorPreview::on_size_request (Gtk::Requisition *req) -{ - req->width = SPCP_DEFAULT_WIDTH; - req->height = SPCP_DEFAULT_HEIGHT; -} - -bool -ColorPreview::on_expose_event (GdkEventExpose *event) -{ - bool result = true; - - if (get_is_drawable()) - { - Cairo::RefPtr cr = get_window()->create_cairo_context(); - cr->rectangle(event->area.x, event->area.y, - event->area.width, event->area.height); - cr->clip(); - result = on_draw(cr); - } - - return result; -} -#endif void ColorPreview::setRgba32 (guint32 rgba) diff --git a/src/ui/widget/color-preview.h b/src/ui/widget/color-preview.h index caddfb9a2..1276cf42b 100644 --- a/src/ui/widget/color-preview.h +++ b/src/ui/widget/color-preview.h @@ -33,16 +33,10 @@ public: protected: virtual void on_size_allocate (Gtk::Allocation &all); -#if WITH_GTKMM_3_0 virtual void get_preferred_height_vfunc(int& minimum_height, int& natural_height) const; virtual void get_preferred_height_for_width_vfunc(int width, int& minimum_height, int& natural_height) const; virtual void get_preferred_width_vfunc(int& minimum_width, int& natural_width) const; virtual void get_preferred_width_for_height_vfunc(int height, int& minimum_width, int& natural_width) const; -#else - virtual void on_size_request (Gtk::Requisition *req); - virtual bool on_expose_event(GdkEventExpose *event); -#endif - virtual bool on_draw(const Cairo::RefPtr& cr); guint32 _rgba; diff --git a/src/ui/widget/color-scales.cpp b/src/ui/widget/color-scales.cpp index 48a2693bc..6afa7f939 100644 --- a/src/ui/widget/color-scales.cpp +++ b/src/ui/widget/color-scales.cpp @@ -46,11 +46,7 @@ static const gchar *sp_color_scales_hue_map(); const gchar *ColorScales::SUBMODE_NAMES[] = { N_("None"), N_("RGB"), N_("HSL"), N_("CMYK") }; ColorScales::ColorScales(SelectedColor &color, SPColorScalesMode mode) -#if GTK_CHECK_VERSION(3, 0, 0) : Gtk::Grid() -#else - : Gtk::Table(5, 3, false) -#endif , _color(color) , _rangeLimit(255.0) , _updating(FALSE) @@ -93,15 +89,9 @@ void ColorScales::_initUI(SPColorScalesMode mode) /* Label */ _l[i] = gtk_label_new(""); -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(_l[i], GTK_ALIGN_END); -#else - gtk_misc_set_alignment(GTK_MISC(_l[i]), 1.0, 0.5); -#endif - gtk_widget_show(_l[i]); -#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 12, 0) gtk_widget_set_margin_start(_l[i], XPAD); gtk_widget_set_margin_end(_l[i], XPAD); @@ -112,9 +102,6 @@ void ColorScales::_initUI(SPColorScalesMode mode) gtk_widget_set_margin_top(_l[i], YPAD); gtk_widget_set_margin_bottom(_l[i], YPAD); gtk_grid_attach(GTK_GRID(t), _l[i], 0, i, 1, 1); -#else - gtk_table_attach(GTK_TABLE(t), _l[i], 0, 1, i, i + 1, GTK_FILL, GTK_FILL, XPAD, YPAD); -#endif /* Adjustment */ _a[i] = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, _rangeLimit, 1.0, 10.0, 10.0)); @@ -122,7 +109,6 @@ void ColorScales::_initUI(SPColorScalesMode mode) _s[i] = Gtk::manage(new Inkscape::UI::Widget::ColorSlider(Glib::wrap(_a[i], true))); _s[i]->show(); -#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 12, 0) _s[i]->set_margin_start(XPAD); _s[i]->set_margin_end(XPAD); @@ -134,10 +120,6 @@ void ColorScales::_initUI(SPColorScalesMode mode) _s[i]->set_margin_bottom(YPAD); _s[i]->set_hexpand(true); gtk_grid_attach(GTK_GRID(t), _s[i]->gobj(), 1, i, 1, 1); -#else - gtk_table_attach(GTK_TABLE(t), _s[i]->gobj(), 1, 2, i, i + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), - GTK_FILL, XPAD, YPAD); -#endif /* Spinbutton */ _b[i] = gtk_spin_button_new(GTK_ADJUSTMENT(_a[i]), 1.0, 0); @@ -145,7 +127,6 @@ void ColorScales::_initUI(SPColorScalesMode mode) gtk_label_set_mnemonic_widget(GTK_LABEL(_l[i]), _b[i]); gtk_widget_show(_b[i]); -#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 12, 0) gtk_widget_set_margin_start(_b[i], XPAD); gtk_widget_set_margin_end(_b[i], XPAD); @@ -158,9 +139,6 @@ void ColorScales::_initUI(SPColorScalesMode mode) gtk_widget_set_halign(_b[i], GTK_ALIGN_CENTER); gtk_widget_set_valign(_b[i], GTK_ALIGN_CENTER); gtk_grid_attach(GTK_GRID(t), _b[i], 2, i, 1, 1); -#else - gtk_table_attach(GTK_TABLE(t), _b[i], 2, 3, i, i + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD); -#endif /* Attach channel value to adjustment */ g_object_set_data(G_OBJECT(_a[i]), "channel", GINT_TO_POINTER(i)); @@ -272,7 +250,6 @@ void ColorScales::_setRangeLimit(gdouble upper) _rangeLimit = upper; for (gint i = 0; i < static_cast(G_N_ELEMENTS(_a)); i++) { gtk_adjustment_set_upper(_a[i], upper); - gtk_adjustment_changed(_a[i]); } } @@ -286,11 +263,7 @@ void ColorScales::_onColorChanged() void ColorScales::on_show() { -#if GTK_CHECK_VERSION(3, 0, 0) Gtk::Grid::on_show(); -#else - Gtk::Table::on_show(); -#endif _updateDisplay(); } diff --git a/src/ui/widget/color-scales.h b/src/ui/widget/color-scales.h index aeacfbcc1..1e86d762d 100644 --- a/src/ui/widget/color-scales.h +++ b/src/ui/widget/color-scales.h @@ -5,11 +5,7 @@ #include #endif -#if WITH_GTKMM_3_0 #include -#else -#include -#endif #include "ui/selected-color.h" @@ -27,11 +23,7 @@ typedef enum { } SPColorScalesMode; class ColorScales -#if GTK_CHECK_VERSION(3, 0, 0) : public Gtk::Grid -#else - : public Gtk::Table -#endif { public: static const gchar *SUBMODE_NAMES[]; diff --git a/src/ui/widget/color-slider.cpp b/src/ui/widget/color-slider.cpp index 0c9586a67..2a8b6a7a2 100644 --- a/src/ui/widget/color-slider.cpp +++ b/src/ui/widget/color-slider.cpp @@ -19,12 +19,7 @@ #include #include #include -#if WITH_GTKMM_3_0 #include -#else -#include -#endif -#include #include "ui/widget/color-scales.h" #include "ui/widget/color-slider.h" @@ -43,14 +38,8 @@ namespace Inkscape { namespace UI { namespace Widget { -#if GTK_CHECK_VERSION(3, 0, 0) ColorSlider::ColorSlider(Glib::RefPtr adjustment) : _dragging(false) -#else -ColorSlider::ColorSlider(Gtk::Adjustment *adjustment) - : _dragging(false) - , _adjustment(NULL) -#endif , _value(0.0) , _oldvalue(0.0) , _mapsize(0) @@ -83,12 +72,7 @@ ColorSlider::~ColorSlider() if (_adjustment) { _adjustment_changed_connection.disconnect(); _adjustment_value_changed_connection.disconnect(); -#if GTK_CHECK_VERSION(3, 0, 0) _adjustment.reset(); -#else - _adjustment->unreference(); - _adjustment = NULL; -#endif } } @@ -109,26 +93,15 @@ void ColorSlider::on_realize() attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gdk_screen_get_system_visual(gdk_screen_get_default()); -#if !GTK_CHECK_VERSION(3, 0, 0) - attributes.colormap = gdk_screen_get_system_colormap(gdk_screen_get_default()); -#endif attributes.event_mask = get_events(); attributes.event_mask |= (Gdk::EXPOSURE_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::POINTER_MOTION_MASK | Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK); -#if GTK_CHECK_VERSION(3, 0, 0) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; -#else - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; -#endif _gdk_window = Gdk::Window::create(get_parent_window(), &attributes, attributes_mask); set_window(_gdk_window); _gdk_window->set_user_data(gobj()); - -#if !GTK_CHECK_VERSION(3, 0, 0) - style_attach(); -#endif } } @@ -149,8 +122,6 @@ void ColorSlider::on_size_allocate(Gtk::Allocation &allocation) } } -#if GTK_CHECK_VERSION(3, 0, 0) - void ColorSlider::get_preferred_width_vfunc(int &minimum_width, int &natural_width) const { Glib::RefPtr style_context = get_style_context(); @@ -177,38 +148,12 @@ void ColorSlider::get_preferred_height_for_width_vfunc(int /*width*/, int &minim get_preferred_height(minimum_height, natural_height); } -#else - -void ColorSlider::on_size_request(Gtk::Requisition *requisition) -{ - GtkStyle *style = gtk_widget_get_style(gobj()); - requisition->width = SLIDER_WIDTH + style->xthickness * 2; - requisition->height = SLIDER_HEIGHT + style->ythickness * 2; -} - -bool ColorSlider::on_expose_event(GdkEventExpose *event) -{ - bool result = false; - - if (get_is_drawable()) { - Cairo::RefPtr cr = _gdk_window->create_cairo_context(); - result = on_draw(cr); - } - return result; -} - -#endif - bool ColorSlider::on_button_press_event(GdkEventButton *event) { if (event->button == 1) { Gtk::Allocation allocation = get_allocation(); gint cx, cw; -#if GTK_CHECK_VERSION(3, 0, 0) cx = get_style_context()->get_padding(get_state_flags()).get_left(); -#else - cx = get_style()->get_xthickness(); -#endif cw = allocation.get_width() - 2 * cx; signal_grabbed.emit(); _dragging = true; @@ -216,15 +161,9 @@ bool ColorSlider::on_button_press_event(GdkEventButton *event) ColorScales::setScaled(_adjustment->gobj(), CLAMP((gfloat)(event->x - cx) / cw, 0.0, 1.0)); signal_dragged.emit(); -#if GTK_CHECK_VERSION(3, 0, 0) gdk_device_grab( gdk_event_get_device(reinterpret_cast(event)), _gdk_window->gobj(), GDK_OWNERSHIP_NONE, FALSE, static_cast(GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK), NULL, event->time); -#else - gdk_pointer_grab(get_window()->gobj(), FALSE, - static_cast(GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK), NULL, NULL, - event->time); -#endif } return false; @@ -233,13 +172,8 @@ bool ColorSlider::on_button_press_event(GdkEventButton *event) bool ColorSlider::on_button_release_event(GdkEventButton *event) { if (event->button == 1) { - -#if GTK_CHECK_VERSION(3, 0, 0) gdk_device_ungrab(gdk_event_get_device(reinterpret_cast(event)), gdk_event_get_time(reinterpret_cast(event))); -#else - get_window()->pointer_ungrab(event->time); -#endif _dragging = false; signal_released.emit(); @@ -256,11 +190,7 @@ bool ColorSlider::on_motion_notify_event(GdkEventMotion *event) if (_dragging) { gint cx, cw; Gtk::Allocation allocation = get_allocation(); -#if GTK_CHECK_VERSION(3, 0, 0) cx = get_style_context()->get_padding(get_state_flags()).get_left(); -#else - cx = get_style()->get_xthickness(); -#endif cw = allocation.get_width() - 2 * cx; ColorScales::setScaled(_adjustment->gobj(), CLAMP((gfloat)(event->x - cx) / cw, 0.0, 1.0)); signal_dragged.emit(); @@ -269,19 +199,10 @@ bool ColorSlider::on_motion_notify_event(GdkEventMotion *event) return false; } -#if GTK_CHECK_VERSION(3, 0, 0) void ColorSlider::setAdjustment(Glib::RefPtr adjustment) { -#else -void ColorSlider::setAdjustment(Gtk::Adjustment *adjustment) -{ -#endif if (!adjustment) { -#if GTK_CHECK_VERSION(3, 0, 0) _adjustment = Gtk::Adjustment::create(0.0, 0.0, 1.0, 0.01, 0.0, 0.0); -#else - _adjustment = Gtk::manage(new Gtk::Adjustment(0.0, 0.0, 1.0, 0.01, 0.0, 0.0)); -#endif } else { adjustment->set_page_increment(0.0); @@ -292,9 +213,6 @@ void ColorSlider::setAdjustment(Gtk::Adjustment *adjustment) if (_adjustment) { _adjustment_changed_connection.disconnect(); _adjustment_value_changed_connection.disconnect(); -#if !GTK_CHECK_VERSION(3, 0, 0) - _adjustment->unreference(); -#endif } _adjustment = adjustment; @@ -315,18 +233,11 @@ void ColorSlider::_onAdjustmentValueChanged() { if (_value != ColorScales::getScaled(_adjustment->gobj())) { gint cx, cy, cw, ch; -#if GTK_CHECK_VERSION(3, 0, 0) - Glib::RefPtr style_context = get_style_context(); - Gtk::Allocation allocation = get_allocation(); - Gtk::Border padding = style_context->get_padding(get_state_flags()); + auto style_context = get_style_context(); + auto allocation = get_allocation(); + auto padding = style_context->get_padding(get_state_flags()); cx = padding.get_left(); cy = padding.get_top(); -#else - Glib::RefPtr style = get_style(); - Gtk::Allocation allocation = get_allocation(); - cx = style->get_xthickness(); - cy = style->get_ythickness(); -#endif cw = allocation.get_width() - 2 * cx; ch = allocation.get_height() - 2 * cy; if ((gint)(ColorScales::getScaled(_adjustment->gobj()) * cw) != (gint)(_value * cw)) { @@ -390,40 +301,22 @@ bool ColorSlider::on_draw(const Cairo::RefPtr &cr) { gboolean colorsOnTop = Inkscape::Preferences::get()->getBool("/options/workarounds/colorsontop", false); - Gtk::Allocation allocation = get_allocation(); - -#if GTK_CHECK_VERSION(3, 0, 0) - Glib::RefPtr style_context = get_style_context(); -#else - Glib::RefPtr window = get_window(); - Glib::RefPtr style = get_style(); -#endif + auto allocation = get_allocation(); + auto style_context = get_style_context(); // Draw shadow if (colorsOnTop) { -#if GTK_CHECK_VERSION(3, 0, 0) style_context->render_frame(cr, 0, 0, allocation.get_width(), allocation.get_height()); -#else - gtk_paint_shadow(style->gobj(), window->gobj(), gtk_widget_get_state(gobj()), GTK_SHADOW_IN, NULL, gobj(), - "colorslider", 0, 0, allocation.get_width(), allocation.get_height()); -#endif } /* Paintable part of color gradient area */ Gdk::Rectangle carea; - -#if GTK_CHECK_VERSION(3, 0, 0) Gtk::Border padding; padding = style_context->get_padding(get_state_flags()); carea.set_x(padding.get_left()); carea.set_y(padding.get_top()); - ; -#else - carea.set_x(style->get_xthickness()); - carea.set_y(style->get_ythickness()); -#endif carea.set_width(allocation.get_width() - 2 * carea.get_x()); carea.set_height(allocation.get_height() - 2 * carea.get_y()); @@ -491,12 +384,7 @@ bool ColorSlider::on_draw(const Cairo::RefPtr &cr) /* Draw shadow */ if (!colorsOnTop) { -#if GTK_CHECK_VERSION(3, 0, 0) style_context->render_frame(cr, 0, 0, allocation.get_width(), allocation.get_height()); -#else - gtk_paint_shadow(style->gobj(), window->gobj(), gtk_widget_get_state(gobj()), GTK_SHADOW_IN, NULL, gobj(), - "colorslider", 0, 0, allocation.get_width(), allocation.get_height()); -#endif } /* Draw arrow */ diff --git a/src/ui/widget/color-slider.h b/src/ui/widget/color-slider.h index 253f3123c..9be6c356a 100644 --- a/src/ui/widget/color-slider.h +++ b/src/ui/widget/color-slider.h @@ -24,18 +24,10 @@ namespace Widget { */ class ColorSlider : public Gtk::Widget { public: -#if GTK_CHECK_VERSION(3, 0, 0) ColorSlider(Glib::RefPtr adjustment); -#else - ColorSlider(Gtk::Adjustment *adjustment); -#endif ~ColorSlider(); -#if GTK_CHECK_VERSION(3, 0, 0) void setAdjustment(Glib::RefPtr adjustment); -#else - void setAdjustment(Gtk::Adjustment *adjustment); -#endif void setColors(guint32 start, guint32 mid, guint32 end); @@ -56,16 +48,10 @@ protected: bool on_button_release_event(GdkEventButton *event); bool on_motion_notify_event(GdkEventMotion *event); bool on_draw(const Cairo::RefPtr &cr); - -#if GTK_CHECK_VERSION(3, 0, 0) void get_preferred_width_vfunc(int &minimum_width, int &natural_width) const; void get_preferred_width_for_height_vfunc(int height, int &minimum_width, int &natural_width) const; void get_preferred_height_vfunc(int &minimum_height, int &natural_height) const; void get_preferred_height_for_width_vfunc(int width, int &minimum_height, int &natural_height) const; -#else - void on_size_request(Gtk::Requisition *requisition); - bool on_expose_event(GdkEventExpose *event); -#endif private: void _onAdjustmentChanged(); @@ -73,11 +59,7 @@ private: bool _dragging; -#if GTK_CHECK_VERSION(3, 0, 0) Glib::RefPtr _adjustment; -#else - Gtk::Adjustment *_adjustment; -#endif sigc::connection _adjustment_changed_connection; sigc::connection _adjustment_value_changed_connection; diff --git a/src/ui/widget/color-wheel-selector.cpp b/src/ui/widget/color-wheel-selector.cpp index 22c616325..9b4119572 100644 --- a/src/ui/widget/color-wheel-selector.cpp +++ b/src/ui/widget/color-wheel-selector.cpp @@ -29,16 +29,9 @@ namespace Widget { const gchar *ColorWheelSelector::MODE_NAME = N_("Wheel"); ColorWheelSelector::ColorWheelSelector(SelectedColor &color) -#if GTK_CHECK_VERSION(3, 0, 0) : Gtk::Grid() -#else - : Gtk::Table(5, 3, false) -#endif , _color(color) , _updating(false) -#if !GTK_CHECK_VERSION(3, 0, 0) - , _alpha_adjustment(NULL) -#endif , _wheel(0) , _slider(0) { @@ -50,9 +43,6 @@ ColorWheelSelector::ColorWheelSelector(SelectedColor &color) ColorWheelSelector::~ColorWheelSelector() { _wheel = 0; -#if !GTK_CHECK_VERSION(3, 0, 0) - delete _alpha_adjustment; -#endif _color_changed_connection.disconnect(); _color_dragged_connection.disconnect(); @@ -66,16 +56,11 @@ void ColorWheelSelector::_initUI() _wheel = gimp_color_wheel_new(); gtk_widget_show(_wheel); -#if GTK_CHECK_VERSION(3, 0, 0) gtk_widget_set_halign(_wheel, GTK_ALIGN_FILL); gtk_widget_set_valign(_wheel, GTK_ALIGN_FILL); gtk_widget_set_hexpand(_wheel, TRUE); gtk_widget_set_vexpand(_wheel, TRUE); gtk_grid_attach(GTK_GRID(gobj()), _wheel, 0, row, 3, 1); -#else - gtk_table_attach(GTK_TABLE(gobj()), _wheel, 0, 3, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0); -#endif row++; @@ -84,7 +69,6 @@ void ColorWheelSelector::_initUI() label->set_alignment(1.0, 0.5); label->show(); -#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 12, 0) label->set_margin_start(XPAD); label->set_margin_end(XPAD); @@ -97,22 +81,15 @@ void ColorWheelSelector::_initUI() label->set_halign(Gtk::ALIGN_FILL); label->set_valign(Gtk::ALIGN_FILL); attach(*label, 0, row, 1, 1); -#else - attach(*label, 0, 1, row, row + 1, Gtk::FILL, Gtk::FILL, XPAD, YPAD); -#endif -/* Adjustment */ -#if GTK_CHECK_VERSION(3, 0, 0) + /* Adjustment */ _alpha_adjustment = Gtk::Adjustment::create(0.0, 0.0, 255.0, 1.0, 10.0, 10.0); -#else - _alpha_adjustment = new Gtk::Adjustment(0.0, 0.0, 255.0, 1.0, 10.0, 10.0); -#endif + /* Slider */ _slider = Gtk::manage(new Inkscape::UI::Widget::ColorSlider(_alpha_adjustment)); _slider->set_tooltip_text(_("Alpha (opacity)")); _slider->show(); -#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 12, 0) _slider->set_margin_start(XPAD); _slider->set_margin_end(XPAD); @@ -126,25 +103,17 @@ void ColorWheelSelector::_initUI() _slider->set_halign(Gtk::ALIGN_FILL); _slider->set_valign(Gtk::ALIGN_FILL); attach(*_slider, 1, row, 1, 1); -#else - attach(*_slider, 1, 2, row, row + 1, Gtk::EXPAND | Gtk::FILL, Gtk::FILL, XPAD, YPAD); -#endif _slider->setColors(SP_RGBA32_F_COMPOSE(1.0, 1.0, 1.0, 0.0), SP_RGBA32_F_COMPOSE(1.0, 1.0, 1.0, 0.5), SP_RGBA32_F_COMPOSE(1.0, 1.0, 1.0, 1.0)); -/* Spinbutton */ -#if GTK_CHECK_VERSION(3, 0, 0) - Gtk::SpinButton *spin_button = Gtk::manage(new Gtk::SpinButton(_alpha_adjustment, 1.0, 0)); -#else - Gtk::SpinButton *spin_button = Gtk::manage(new Gtk::SpinButton(*_alpha_adjustment, 1.0, 0)); -#endif + /* Spinbutton */ + auto spin_button = Gtk::manage(new Gtk::SpinButton(_alpha_adjustment, 1.0, 0)); spin_button->set_tooltip_text(_("Alpha (opacity)")); sp_dialog_defocus_on_enter(GTK_WIDGET(spin_button->gobj())); label->set_mnemonic_widget(*spin_button); spin_button->show(); -#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 12, 0) spin_button->set_margin_start(XPAD); spin_button->set_margin_end(XPAD); @@ -157,9 +126,6 @@ void ColorWheelSelector::_initUI() spin_button->set_halign(Gtk::ALIGN_CENTER); spin_button->set_valign(Gtk::ALIGN_CENTER); attach(*spin_button, 2, row, 1, 1); -#else - attach(*spin_button, 2, 3, row, row + 1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0, XPAD, YPAD); -#endif /* Signals */ _alpha_adjustment->signal_value_changed().connect(sigc::mem_fun(this, &ColorWheelSelector::_adjustmentChanged)); @@ -172,11 +138,7 @@ void ColorWheelSelector::_initUI() void ColorWheelSelector::on_show() { -#if GTK_CHECK_VERSION(3, 0, 0) Gtk::Grid::on_show(); -#else - Gtk::Table::on_show(); -#endif _updateDisplay(); } diff --git a/src/ui/widget/color-wheel-selector.h b/src/ui/widget/color-wheel-selector.h index 5711d417c..ee7bd9b83 100644 --- a/src/ui/widget/color-wheel-selector.h +++ b/src/ui/widget/color-wheel-selector.h @@ -16,11 +16,7 @@ #include #endif -#if WITH_GTKMM_3_0 #include -#else -#include -#endif #include "ui/selected-color.h" @@ -33,11 +29,7 @@ namespace Widget { class ColorSlider; class ColorWheelSelector -#if GTK_CHECK_VERSION(3, 0, 0) : public Gtk::Grid -#else - : public Gtk::Table -#endif { public: static const gchar *MODE_NAME; @@ -61,11 +53,7 @@ protected: SelectedColor &_color; bool _updating; -#if GTK_CHECK_VERSION(3, 0, 0) Glib::RefPtr _alpha_adjustment; -#else - Gtk::Adjustment *_alpha_adjustment; -#endif GtkWidget *_wheel; Inkscape::UI::Widget::ColorSlider *_slider; diff --git a/src/ui/widget/dock-item.cpp b/src/ui/widget/dock-item.cpp index 8d960ddc3..fc41efe52 100644 --- a/src/ui/widget/dock-item.cpp +++ b/src/ui/widget/dock-item.cpp @@ -59,11 +59,7 @@ DockItem::DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& l Gtk::StockItem item; Gtk::StockID stockId(icon_name); if ( Gtk::StockItem::lookup(stockId, item) ) { -#if WITH_GTKMM_3_0 _icon_pixbuf = _dock.getWidget().render_icon_pixbuf( stockId, Gtk::ICON_SIZE_MENU ); -#else - _icon_pixbuf = _dock.getWidget().render_icon( stockId, Gtk::ICON_SIZE_MENU ); -#endif } } } @@ -175,12 +171,8 @@ DockItem::set_size_request(int width, int height) void DockItem::size_request(Gtk::Requisition& requisition) { -#if WITH_GTKMM_3_0 Gtk::Requisition req_natural; getWidget().get_preferred_size(req_natural, requisition); -#else - requisition = getWidget().size_request(); -#endif } void diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp index fda647182..7744cb695 100644 --- a/src/ui/widget/dock.cpp +++ b/src/ui/widget/dock.cpp @@ -65,7 +65,6 @@ Dock::Dock(Gtk::Orientation orientation) static_cast(orientation)); #endif -#if WITH_GTKMM_3_0 switch(orientation) { case Gtk::ORIENTATION_VERTICAL: _dock_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL)); @@ -75,17 +74,6 @@ Dock::Dock(Gtk::Orientation orientation) } _paned = Gtk::manage(new Gtk::Paned(orientation)); -#else - switch (orientation) { - case Gtk::ORIENTATION_VERTICAL: - _dock_box = Gtk::manage(new Gtk::HBox()); - _paned = Gtk::manage(new Gtk::VPaned()); - break; - case Gtk::ORIENTATION_HORIZONTAL: - _dock_box = Gtk::manage(new Gtk::VBox()); - _paned = Gtk::manage(new Gtk::HPaned()); - } -#endif _scrolled_window->add(*_dock_box); _scrolled_window->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); diff --git a/src/ui/widget/gimpspinscale.c b/src/ui/widget/gimpspinscale.c index d99646a64..8d8c6c935 100644 --- a/src/ui/widget/gimpspinscale.c +++ b/src/ui/widget/gimpspinscale.c @@ -41,10 +41,8 @@ typedef enum { TARGET_NUMBER, TARGET_UPPER, - TARGET_LOWER -#if WITH_GTKMM_3_0 - ,TARGET_NONE -#endif + TARGET_LOWER, + TARGET_NONE } SpinScaleTarget; typedef enum @@ -94,7 +92,6 @@ static void gimp_spin_scale_get_property (GObject *object, static void gimp_spin_scale_style_set (GtkWidget *widget, GtkStyle *prev_style); -#if WITH_GTKMM_3_0 static void gimp_spin_scale_get_preferred_width (GtkWidget *widget, gint *minimum_width, gint *natural_width); @@ -103,13 +100,6 @@ static void gimp_spin_scale_get_preferred_height (GtkWidget *widget gint *natural_width); static gboolean gimp_spin_scale_draw (GtkWidget *widget, cairo_t *cr); -#else -static void gimp_spin_scale_size_request (GtkWidget *widget, - GtkRequisition *requisition); - -static gboolean gimp_spin_scale_expose (GtkWidget *widget, - GdkEventExpose *event); -#endif static gboolean gimp_spin_scale_button_press (GtkWidget *widget, GdkEventButton *event); @@ -145,14 +135,9 @@ gimp_spin_scale_class_init (GimpSpinScaleClass *klass) object_class->get_property = gimp_spin_scale_get_property; widget_class->style_set = gimp_spin_scale_style_set; -#if WITH_GTKMM_3_0 widget_class->get_preferred_width = gimp_spin_scale_get_preferred_width; widget_class->get_preferred_height = gimp_spin_scale_get_preferred_height; widget_class->draw = gimp_spin_scale_draw; -#else - widget_class->size_request = gimp_spin_scale_size_request; - widget_class->expose_event = gimp_spin_scale_expose; -#endif widget_class->button_press_event = gimp_spin_scale_button_press; widget_class->button_release_event = gimp_spin_scale_button_release; widget_class->motion_notify_event = gimp_spin_scale_motion_notify; @@ -294,7 +279,6 @@ gimp_spin_scale_set_appearance( GtkWidget *widget, const gchar *appearance) } } -#if GTK_CHECK_VERSION(3,0,0) static void gimp_spin_scale_get_preferred_width (GtkWidget *widget, gint *minimum_width, @@ -355,48 +339,6 @@ gimp_spin_scale_get_preferred_height (GtkWidget *widget, pango_font_metrics_unref (metrics); } -#else -static void -gimp_spin_scale_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GimpSpinScalePrivate *private = GET_PRIVATE (widget); - GtkStyle *style = gtk_widget_get_style (widget); - PangoContext *context = gtk_widget_get_pango_context (widget); - PangoFontMetrics *metrics; - gint height; - - GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition); - - metrics = pango_context_get_metrics (context, style->font_desc, - pango_context_get_language (context)); - - height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) + - pango_font_metrics_get_descent (metrics)); - - if (private->appearanceMode == APPEARANCE_COMPACT) { - requisition->height += 1; - } else { - requisition->height += height; - } - - if (private->label) - { - gint char_width; - gint digit_width; - gint char_pixels; - - char_width = pango_font_metrics_get_approximate_char_width (metrics); - digit_width = pango_font_metrics_get_approximate_digit_width (metrics); - char_pixels = PANGO_PIXELS (MAX (char_width, digit_width)); - - /* ~3 chars for the ellipses */ - requisition->width += char_pixels * 3; - } - - pango_font_metrics_unref (metrics); -} -#endif static void gimp_spin_scale_style_set (GtkWidget *widget, @@ -415,16 +357,10 @@ gimp_spin_scale_style_set (GtkWidget *widget, static gboolean -#if GTK_CHECK_VERSION(3,0,0) gimp_spin_scale_draw (GtkWidget *widget, cairo_t *cr) -#else - gimp_spin_scale_expose (GtkWidget *widget, - GdkEventExpose *event) -#endif { GimpSpinScalePrivate *private = GET_PRIVATE (widget); -#if GTK_CHECK_VERSION(3,0,0) GtkStyleContext *style = gtk_widget_get_style_context(widget); GtkAllocation allocation; GdkRGBA color; @@ -434,66 +370,31 @@ static gboolean cairo_restore (cr); gtk_widget_get_allocation (widget, &allocation); -#else - GtkStyle *style = gtk_widget_get_style (widget); - cairo_t *cr; - gint w; - - GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); - - cr = gdk_cairo_create (event->window); - gdk_cairo_region (cr, event->region); - cairo_clip (cr); - - w = gdk_window_get_width (event->window); -#endif cairo_set_line_width (cr, 1.0); -#if GTK_CHECK_VERSION(3,0,0) if (private->label) { GdkRectangle text_area; gint minimum_width; gint natural_width; -#else - if (private->label && - gtk_widget_is_drawable (widget) && - event->window == gtk_entry_get_text_window (GTK_ENTRY (widget))) - { - GtkRequisition requisition; - GtkAllocation allocation; -#endif PangoRectangle logical; gint layout_offset_x; gint layout_offset_y; -#if GTK_CHECK_VERSION(3,0,0) GtkStateFlags state; GdkRGBA text_color; GdkRGBA bar_text_color; -#else - GtkStateType state; - GdkColor text_color; - GdkColor bar_text_color; - gint window_width; - gint window_height; -#endif gdouble progress_fraction; gint progress_x; gint progress_y; gint progress_width; gint progress_height; -#if GTK_CHECK_VERSION(3,0,0) gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area); GTK_WIDGET_CLASS (parent_class)->get_preferred_width (widget, &minimum_width, &natural_width); -#else - GTK_WIDGET_CLASS (parent_class)->size_request (widget, &requisition); - gtk_widget_get_allocation (widget, &allocation); -#endif if (! private->layout) { @@ -504,27 +405,18 @@ static gboolean pango_layout_set_width (private->layout, PANGO_SCALE * -#if GTK_CHECK_VERSION(3,0,0) (allocation.width - minimum_width)); -#else - (allocation.width - requisition.width)); -#endif pango_layout_get_pixel_extents (private->layout, NULL, &logical); gtk_entry_get_layout_offsets (GTK_ENTRY (widget), NULL, &layout_offset_y); if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) -#if GTK_CHECK_VERSION(3,0,0) layout_offset_x = text_area.x + text_area.width - logical.width - 4; -#else - layout_offset_x = w - logical.width - 4; -#endif else layout_offset_x = 4; layout_offset_x -= logical.x; -#if GTK_CHECK_VERSION(3,0,0) state = gtk_widget_get_state_flags (widget); gtk_style_context_get_color (style, state, &text_color); @@ -533,16 +425,6 @@ static gboolean gtk_style_context_add_class (style, GTK_STYLE_CLASS_PROGRESSBAR); gtk_style_context_get_color (style, state, &bar_text_color); gtk_style_context_restore (style); -#else - state = GTK_STATE_SELECTED; - if (! gtk_widget_get_sensitive (widget)) - state = GTK_STATE_INSENSITIVE; - text_color = style->text[gtk_widget_get_state (widget)]; - bar_text_color = style->fg[state]; - - window_width = gdk_window_get_width (event->window); - window_height = gdk_window_get_height (event->window); -#endif progress_fraction = gtk_entry_get_progress_fraction (GTK_ENTRY (widget)); @@ -550,53 +432,30 @@ static gboolean { progress_fraction = 1.0 - progress_fraction; -#if GTK_CHECK_VERSION(3,0,0) progress_x = text_area.width * progress_fraction; -#else - progress_x = window_width * progress_fraction; -#endif progress_y = 0; -#if GTK_CHECK_VERSION(3,0,0) progress_width = text_area.width - progress_x; progress_height = text_area.height; -#else - progress_width = window_width - progress_x; - progress_height = window_height; -#endif } else { progress_x = 0; progress_y = 0; -#if GTK_CHECK_VERSION(3,0,0) progress_width = text_area.width * progress_fraction; progress_height = text_area.height; -#else - progress_width = window_width * progress_fraction; - progress_height = window_height; -#endif } cairo_save (cr); cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); -#if GTK_CHECK_VERSION(3,0,0) cairo_rectangle (cr, 0, 0, text_area.width, text_area.height); -#else - cairo_rectangle (cr, 0, 0, window_width, window_height); -#endif cairo_rectangle (cr, progress_x, progress_y, progress_width, progress_height); cairo_clip (cr); cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING); -#if GTK_CHECK_VERSION(3,0,0) cairo_move_to (cr, layout_offset_x, text_area.y + layout_offset_y-3); gdk_cairo_set_source_rgba (cr, &text_color); -#else - cairo_move_to (cr, layout_offset_x, layout_offset_y-3); - gdk_cairo_set_source_color (cr, &text_color); -#endif pango_cairo_show_layout (cr, private->layout); cairo_restore (cr); @@ -604,24 +463,14 @@ static gboolean progress_width, progress_height); cairo_clip (cr); -#if GTK_CHECK_VERSION(3,0,0) cairo_move_to (cr, layout_offset_x, text_area.y + layout_offset_y-3); gdk_cairo_set_source_rgba (cr, &bar_text_color); -#else - cairo_move_to (cr, layout_offset_x, layout_offset_y-3); - gdk_cairo_set_source_color (cr, &bar_text_color); -#endif pango_cairo_show_layout (cr, private->layout); } -#if !GTK_CHECK_VERSION(3,0,0) - cairo_destroy (cr); -#endif - return FALSE; } -#if WITH_GTKMM_3_0 /* Returns TRUE if a translation should be done */ static gboolean gtk_widget_get_translation_to_window (GtkWidget *widget, @@ -685,7 +534,6 @@ gimp_spin_scale_event_to_widget_coords (GtkWidget *widget, *widget_x = event_x; *widget_y = event_y; } -#endif static SpinScaleTarget gimp_spin_scale_get_target (GtkWidget *widget, @@ -702,7 +550,6 @@ gimp_spin_scale_get_target (GtkWidget *widget, pango_layout_get_pixel_extents (gtk_entry_get_layout (GTK_ENTRY (widget)), NULL, &logical); -#if WITH_GTKMM_3_0 GdkRectangle text_area; gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area); @@ -726,19 +573,6 @@ gimp_spin_scale_get_target (GtkWidget *widget, } return TARGET_NONE; -#else - if (x > layout_x && x < layout_x + logical.width && - y > layout_y && y < layout_y + logical.height) - { - return TARGET_NUMBER; - } - - else if (y > allocation.height / 2) - { - return TARGET_LOWER; - } - return TARGET_UPPER; -#endif } static void @@ -773,49 +607,21 @@ gimp_spin_scale_change_value (GtkWidget *widget, gdouble lower; gdouble upper; gdouble value; -#if WITH_GTKMM_3_0 -#else -#endif -#if WITH_GTKMM_3_0 GdkRectangle text_area; gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area); gimp_spin_scale_get_limits (GIMP_SPIN_SCALE (widget), &lower, &upper); -#else - GdkWindow *text_window = gtk_entry_get_text_window (GTK_ENTRY (widget)); - gint width; - - gimp_spin_scale_get_limits (GIMP_SPIN_SCALE (widget), &lower, &upper); - - width = gdk_window_get_width (text_window); -#endif - if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) -#if WITH_GTKMM_3_0 x = text_area.width - x; -#else - x = width - x; -#endif - if (private->relative_change) { gdouble diff; gdouble step; - -#if WITH_GTKMM_3_0 step = (upper - lower) / text_area.width / 10.0; -#else - step = (upper - lower) / width / 10.0; -#endif if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - -#if WITH_GTKMM_3_0 diff = x - (text_area.width - private->start_x); -#else - diff = x - (width - private->start_x); -#endif else diff = x - private->start_x; @@ -825,12 +631,7 @@ gimp_spin_scale_change_value (GtkWidget *widget, { gdouble fraction; - -#if WITH_GTKMM_3_0 fraction = x / (gdouble) text_area.width; -#else - fraction = x / (gdouble) width; -#endif if (fraction > 0.0) fraction = pow (fraction, private->gamma); @@ -849,7 +650,6 @@ gimp_spin_scale_button_press (GtkWidget *widget, private->changing_value = FALSE; private->relative_change = FALSE; -#if WITH_GTKMM_3_0 gint x, y; gimp_spin_scale_event_to_widget_coords (widget, event->window, event->x, event->y, @@ -879,36 +679,6 @@ gimp_spin_scale_button_press (GtkWidget *widget, default: break; } -#else - if (event->window == gtk_entry_get_text_window (GTK_ENTRY (widget))) - { - switch (gimp_spin_scale_get_target (widget, event->x, event->y)) - { - case TARGET_UPPER: - private->changing_value = TRUE; - - gtk_widget_grab_focus (widget); - - gimp_spin_scale_change_value (widget, event->x); - - return TRUE; - - case TARGET_LOWER: - private->changing_value = TRUE; - - gtk_widget_grab_focus (widget); - - private->relative_change = TRUE; - private->start_x = event->x; - private->start_value = gtk_adjustment_get_value (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget))); - - return TRUE; - - default: - break; - } - } -#endif return GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, event); } @@ -918,22 +688,16 @@ gimp_spin_scale_button_release (GtkWidget *widget, GdkEventButton *event) { GimpSpinScalePrivate *private = GET_PRIVATE (widget); -#if WITH_GTKMM_3_0 gint x, y; gimp_spin_scale_event_to_widget_coords (widget, event->window, event->x, event->y, &x, &y); -#endif if (private->changing_value) { private->changing_value = FALSE; -#if WITH_GTKMM_3_0 gimp_spin_scale_change_value (widget, x); -#else - gimp_spin_scale_change_value (widget, event->x); -#endif return TRUE; } @@ -948,21 +712,15 @@ gimp_spin_scale_motion_notify (GtkWidget *widget, gdk_event_request_motions (event); -#if WITH_GTKMM_3_0 gint x, y; gimp_spin_scale_event_to_widget_coords (widget, event->window, event->x, event->y, &x, &y); -#endif if (private->changing_value) { -#if WITH_GTKMM_3_0 gimp_spin_scale_change_value (widget, x); -#else - gimp_spin_scale_change_value (widget, event->x); -#endif return TRUE; } @@ -971,20 +729,12 @@ gimp_spin_scale_motion_notify (GtkWidget *widget, if (! (event->state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) -#if WITH_GTKMM_3_0 -#else - && event->window == gtk_entry_get_text_window (GTK_ENTRY (widget)) -#endif ) { GdkDisplay *display = gtk_widget_get_display (widget); GdkCursor *cursor = NULL; -#if WITH_GTKMM_3_0 switch (gimp_spin_scale_get_target (widget, x, y)) -#else - switch (gimp_spin_scale_get_target (widget, event->x, event->y)) -#endif { case TARGET_NUMBER: cursor = gdk_cursor_new_for_display (display, GDK_XTERM); @@ -1002,17 +752,11 @@ gimp_spin_scale_motion_notify (GtkWidget *widget, break; } - -#if WITH_GTKMM_3_0 if (cursor) { gdk_window_set_cursor (event->window, cursor); g_object_unref (cursor); } -#else - gdk_window_set_cursor (event->window, cursor); - gdk_cursor_unref (cursor); -#endif } return FALSE; diff --git a/src/ui/widget/highlight-picker.cpp b/src/ui/widget/highlight-picker.cpp index 09999b52d..e4447cb9e 100644 --- a/src/ui/widget/highlight-picker.cpp +++ b/src/ui/widget/highlight-picker.cpp @@ -35,8 +35,6 @@ HighlightPicker::~HighlightPicker() { } - -#if WITH_GTKMM_3_0 void HighlightPicker::get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const @@ -66,39 +64,12 @@ void HighlightPicker::get_preferred_width_vfunc(Gtk::Widget& widget, nat_w += (nat_w) >> 1; } } -#else -void HighlightPicker::get_size_vfunc(Gtk::Widget& widget, - const Gdk::Rectangle* cell_area, - int* x_offset, - int* y_offset, - int* width, - int* height ) const -{ - Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height ); - - if ( width ) { - *width = 10;//+= (*width) >> 1; - } - if ( height ) { - *height = 20; //cell_area ? cell_area->get_height() / 2 : 50; //+= (*height) >> 1; - } -} -#endif -#if WITH_GTKMM_3_0 void HighlightPicker::render_vfunc( const Cairo::RefPtr& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, Gtk::CellRendererState flags ) -#else -void HighlightPicker::render_vfunc( const Glib::RefPtr& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags ) -#endif { GdkRectangle carea; @@ -140,11 +111,7 @@ void HighlightPicker::render_vfunc( const Glib::RefPtr& window, convert_pixbuf_argb32_to_normal(pixbuf); property_pixbuf() = Glib::wrap(pixbuf); -#if WITH_GTKMM_3_0 Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags ); -#else - Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags ); -#endif } bool HighlightPicker::activate_vfunc(GdkEvent* /*event*/, diff --git a/src/ui/widget/highlight-picker.h b/src/ui/widget/highlight-picker.h index c5fe4c02c..c459b0dcd 100644 --- a/src/ui/widget/highlight-picker.h +++ b/src/ui/widget/highlight-picker.h @@ -29,8 +29,6 @@ public: Glib::PropertyProxy property_active() { return _property_active.get_proxy(); } protected: - -#if WITH_GTKMM_3_0 virtual void render_vfunc( const Cairo::RefPtr& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, @@ -44,18 +42,6 @@ protected: virtual void get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const; -#else - virtual void render_vfunc( const Glib::RefPtr& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags ); - - virtual void get_size_vfunc( Gtk::Widget &widget, - Gdk::Rectangle const *cell_area, - int *x_offset, int *y_offset, int *width, int *height ) const; -#endif virtual bool activate_vfunc(GdkEvent *event, Gtk::Widget &widget, diff --git a/src/ui/widget/imagetoggler.cpp b/src/ui/widget/imagetoggler.cpp index 29907f4c9..987cc67bb 100644 --- a/src/ui/widget/imagetoggler.cpp +++ b/src/ui/widget/imagetoggler.cpp @@ -53,8 +53,6 @@ ImageToggler::ImageToggler( char const* on, char const* off) : property_pixbuf() = _property_pixbuf_off.get_value(); } - -#if WITH_GTKMM_3_0 void ImageToggler::get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const @@ -84,46 +82,15 @@ void ImageToggler::get_preferred_width_vfunc(Gtk::Widget& widget, nat_w += (nat_w) >> 1; } } -#else -void ImageToggler::get_size_vfunc(Gtk::Widget& widget, - const Gdk::Rectangle* cell_area, - int* x_offset, - int* y_offset, - int* width, - int* height ) const -{ - Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height ); - - if ( width ) { - *width += (*width) >> 1; - } - if ( height ) { - *height += (*height) >> 1; - } -} -#endif -#if WITH_GTKMM_3_0 void ImageToggler::render_vfunc( const Cairo::RefPtr& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, Gtk::CellRendererState flags ) -#else -void ImageToggler::render_vfunc( const Glib::RefPtr& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags ) -#endif { property_pixbuf() = _property_active.get_value() ? _property_pixbuf_on : _property_pixbuf_off; -#if WITH_GTKMM_3_0 Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags ); -#else - Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags ); -#endif } bool diff --git a/src/ui/widget/imagetoggler.h b/src/ui/widget/imagetoggler.h index 7b02fa4dc..d4f27cf11 100644 --- a/src/ui/widget/imagetoggler.h +++ b/src/ui/widget/imagetoggler.h @@ -36,8 +36,6 @@ public: Glib::PropertyProxy< Glib::RefPtr > property_pixbuf_off(); protected: - -#if WITH_GTKMM_3_0 virtual void render_vfunc( const Cairo::RefPtr& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, @@ -51,18 +49,6 @@ protected: virtual void get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const; -#else - virtual void render_vfunc( const Glib::RefPtr& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags ); - - virtual void get_size_vfunc( Gtk::Widget &widget, - Gdk::Rectangle const *cell_area, - int *x_offset, int *y_offset, int *width, int *height ) const; -#endif virtual bool activate_vfunc(GdkEvent *event, Gtk::Widget &widget, diff --git a/src/ui/widget/insertordericon.cpp b/src/ui/widget/insertordericon.cpp index 9aec7d135..7ed1ed2e2 100644 --- a/src/ui/widget/insertordericon.cpp +++ b/src/ui/widget/insertordericon.cpp @@ -52,7 +52,6 @@ InsertOrderIcon::InsertOrderIcon() : } -#if WITH_GTKMM_3_0 void InsertOrderIcon::get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const @@ -82,39 +81,12 @@ void InsertOrderIcon::get_preferred_width_vfunc(Gtk::Widget& widget, nat_w += (nat_w) >> 1; } } -#else -void InsertOrderIcon::get_size_vfunc(Gtk::Widget& widget, - const Gdk::Rectangle* cell_area, - int* x_offset, - int* y_offset, - int* width, - int* height ) const -{ - Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height ); - - if ( width ) { - *width = phys;//+= (*width) >> 1; - } - if ( height ) { - *height =phys;//+= (*height) >> 1; - } -} -#endif -#if WITH_GTKMM_3_0 void InsertOrderIcon::render_vfunc( const Cairo::RefPtr& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, Gtk::CellRendererState flags ) -#else -void InsertOrderIcon::render_vfunc( const Glib::RefPtr& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags ) -#endif { switch (_property_active.get_value()) { @@ -128,11 +100,7 @@ void InsertOrderIcon::render_vfunc( const Glib::RefPtr& window, property_pixbuf() = Glib::RefPtr(0); break; } -#if WITH_GTKMM_3_0 Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags ); -#else - Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags ); -#endif } bool InsertOrderIcon::activate_vfunc(GdkEvent* /*event*/, diff --git a/src/ui/widget/insertordericon.h b/src/ui/widget/insertordericon.h index bf8ac4fa7..43188fa5b 100644 --- a/src/ui/widget/insertordericon.h +++ b/src/ui/widget/insertordericon.h @@ -33,7 +33,6 @@ public: protected: -#if WITH_GTKMM_3_0 virtual void render_vfunc( const Cairo::RefPtr& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, @@ -47,18 +46,6 @@ protected: virtual void get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const; -#else - virtual void render_vfunc( const Glib::RefPtr& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags ); - - virtual void get_size_vfunc( Gtk::Widget &widget, - Gdk::Rectangle const *cell_area, - int *x_offset, int *y_offset, int *width, int *height ) const; -#endif virtual bool activate_vfunc(GdkEvent *event, Gtk::Widget &widget, diff --git a/src/ui/widget/layertypeicon.cpp b/src/ui/widget/layertypeicon.cpp index 672c607e5..36742b953 100644 --- a/src/ui/widget/layertypeicon.cpp +++ b/src/ui/widget/layertypeicon.cpp @@ -64,8 +64,6 @@ LayerTypeIcon::LayerTypeIcon() : property_pixbuf() = _property_pixbuf_path.get_value(); } - -#if WITH_GTKMM_3_0 void LayerTypeIcon::get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const @@ -95,46 +93,15 @@ void LayerTypeIcon::get_preferred_width_vfunc(Gtk::Widget& widget, nat_w += (nat_w) >> 1; } } -#else -void LayerTypeIcon::get_size_vfunc(Gtk::Widget& widget, - const Gdk::Rectangle* cell_area, - int* x_offset, - int* y_offset, - int* width, - int* height ) const -{ - Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height ); - - if ( width ) { - *width += (*width) >> 1; - } - if ( height ) { - *height += (*height) >> 1; - } -} -#endif -#if WITH_GTKMM_3_0 void LayerTypeIcon::render_vfunc( const Cairo::RefPtr& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, Gtk::CellRendererState flags ) -#else -void LayerTypeIcon::render_vfunc( const Glib::RefPtr& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags ) -#endif { property_pixbuf() = _property_active.get_value() == 1 ? _property_pixbuf_group : (_property_active.get_value() == 2 ? _property_pixbuf_layer : _property_pixbuf_path); -#if WITH_GTKMM_3_0 Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags ); -#else - Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags ); -#endif } bool diff --git a/src/ui/widget/layertypeicon.h b/src/ui/widget/layertypeicon.h index 6c71ce361..f12029c12 100644 --- a/src/ui/widget/layertypeicon.h +++ b/src/ui/widget/layertypeicon.h @@ -35,8 +35,6 @@ public: Glib::PropertyProxy< Glib::RefPtr > property_pixbuf_off(); protected: - -#if WITH_GTKMM_3_0 virtual void render_vfunc( const Cairo::RefPtr& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, @@ -50,18 +48,6 @@ protected: virtual void get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const; -#else - virtual void render_vfunc( const Glib::RefPtr& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags ); - - virtual void get_size_vfunc( Gtk::Widget &widget, - Gdk::Rectangle const *cell_area, - int *x_offset, int *y_offset, int *width, int *height ) const; -#endif virtual bool activate_vfunc(GdkEvent *event, Gtk::Widget &widget, diff --git a/src/ui/widget/licensor.cpp b/src/ui/widget/licensor.cpp index d21e848f2..66ee612bf 100644 --- a/src/ui/widget/licensor.cpp +++ b/src/ui/widget/licensor.cpp @@ -134,18 +134,10 @@ void Licensor::update (SPDocument *doc) for (i=0; rdf_licenses[i].name; i++) if (license == &rdf_licenses[i]) break; -#if WITH_GTKMM_3_0 static_cast(get_children()[i+1])->set_active(); -#else - static_cast(children()[i+1].get_widget())->set_active(); -#endif } else { -#if WITH_GTKMM_3_0 static_cast(get_children()[0])->set_active(); -#else - static_cast(children()[0].get_widget())->set_active(); -#endif } /* update the URI */ diff --git a/src/ui/widget/notebook-page.cpp b/src/ui/widget/notebook-page.cpp index 2f03ed23b..6d8ff1d75 100644 --- a/src/ui/widget/notebook-page.cpp +++ b/src/ui/widget/notebook-page.cpp @@ -11,31 +11,19 @@ #include "notebook-page.h" -#if WITH_GTKMM_3_0 # include -#else -# include -#endif namespace Inkscape { namespace UI { namespace Widget { NotebookPage::NotebookPage(int n_rows, int n_columns, bool expand, bool fill, guint padding) -#if WITH_GTKMM_3_0 :_table(Gtk::manage(new Gtk::Grid())) -#else - :_table(Gtk::manage(new Gtk::Table(n_rows, n_columns))) -#endif { set_border_width(2); -#if WITH_GTKMM_3_0 _table->set_row_spacing(2); _table->set_column_spacing(2); -#else - _table->set_spacings(2); -#endif pack_start(*_table, expand, fill, padding); } diff --git a/src/ui/widget/notebook-page.h b/src/ui/widget/notebook-page.h index c11de1b5b..6eb23907c 100644 --- a/src/ui/widget/notebook-page.h +++ b/src/ui/widget/notebook-page.h @@ -17,11 +17,7 @@ #include namespace Gtk { -#if WITH_GTKMM_3_0 class Grid; -#else -class Table; -#endif } namespace Inkscape { @@ -42,19 +38,10 @@ public: */ NotebookPage(int n_rows, int n_columns, bool expand=false, bool fill=false, guint padding=0); -#if WITH_GTKMM_3_0 Gtk::Grid& table() { return *_table; } -#else - Gtk::Table& table() { return *_table; } -#endif protected: - -#if WITH_GTKMM_3_0 Gtk::Grid *_table; -#else - Gtk::Table *_table; -#endif }; } // namespace Widget diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 19ab1a280..c71130586 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -353,7 +353,6 @@ PageSizer::PageSizer(Registry & _wr) _customDimTable.set_border_width(4); -#if WITH_GTKMM_3_0 _customDimTable.set_row_spacing(4); _customDimTable.set_column_spacing(4); @@ -372,15 +371,6 @@ PageSizer::PageSizer(Registry & _wr) _fitPageMarginExpander.set_hexpand(); _fitPageMarginExpander.set_vexpand(); _customDimTable.attach(_fitPageMarginExpander, 0, 2, 2, 1); -#else - _customDimTable.resize(3, 2); - _customDimTable.set_row_spacings(4); - _customDimTable.set_col_spacings(4); - _customDimTable.attach(_dimensionWidth, 0,1, 0,1); - _customDimTable.attach(_dimensionUnits, 1,2, 0,1); - _customDimTable.attach(_dimensionHeight, 0,1, 1,2); - _customDimTable.attach(_fitPageMarginExpander, 0,2, 2,3); -#endif _dimTabOrderGList = NULL; _dimTabOrderGList = g_list_append(_dimTabOrderGList, _dimensionWidth.gobj()); @@ -398,7 +388,6 @@ PageSizer::PageSizer(Registry & _wr) //## Set up margin settings _marginTable.set_border_width(4); -#if WITH_GTKMM_3_0 _marginTable.set_row_spacing(4); _marginTable.set_column_spacing(4); @@ -421,16 +410,6 @@ PageSizer::PageSizer(Registry & _wr) _fitPageButtonAlign.set_hexpand(); _fitPageButtonAlign.set_vexpand(); _marginTable.attach(_fitPageButtonAlign, 0, 3, 2, 1); -#else - _marginTable.set_border_width(4); - _marginTable.set_row_spacings(4); - _marginTable.set_col_spacings(4); - _marginTable.attach(_marginTopAlign, 0,2, 0,1); - _marginTable.attach(_marginLeftAlign, 0,1, 1,2); - _marginTable.attach(_marginRightAlign, 1,2, 1,2); - _marginTable.attach(_marginBottomAlign, 0,2, 2,3); - _marginTable.attach(_fitPageButtonAlign, 0,2, 3,4); -#endif _marginTopAlign.set(0.5, 0.5, 0.0, 1.0); _marginTopAlign.add(_marginTop); @@ -453,7 +432,6 @@ PageSizer::PageSizer(Registry & _wr) _scaleTable.set_border_width(4); -#if WITH_GTKMM_3_0 _scaleTable.set_row_spacing(4); _scaleTable.set_column_spacing(4); @@ -465,16 +443,6 @@ PageSizer::PageSizer(Registry & _wr) _viewboxExpander.set_hexpand(); _viewboxExpander.set_vexpand(); _scaleTable.attach(_viewboxExpander, 0, 2, 2, 1); -#else - _scaleTable.resize(3, 2); - _scaleTable.set_row_spacings(4); - _scaleTable.set_col_spacings(4); - _scaleTable.attach(_scaleX, 0,1, 0,1); - _scaleTable.attach(_scaleY, 1,2, 0,1); - _scaleTable.attach(_scaleLabel, 2,3, 0,1); - _scaleTable.attach(_scaleWarning, 0,3, 1,2, Gtk::FILL); - _scaleTable.attach(_viewboxExpander, 0,3, 2,3); -#endif _scaleWarning.set_label(_("While SVG allows non-uniform scaling it is recommended to use only uniform scaling in Inkscape. To set a non-uniform scaling, set the 'viewBox' directly.")); _scaleWarning.set_line_wrap( true ); @@ -483,7 +451,6 @@ PageSizer::PageSizer(Registry & _wr) _viewboxExpander.set_label(_("_Viewbox...")); _viewboxExpander.add(_viewboxTable); -#if WITH_GTKMM_3_0 _viewboxTable.set_row_spacing(2); _viewboxTable.set_column_spacing(2); @@ -503,16 +470,6 @@ PageSizer::PageSizer(Registry & _wr) _viewboxH.set_vexpand(); _viewboxTable.attach(_viewboxH, 1, 1, 1, 1); -#else - _viewboxTable.set_border_width(4); - _viewboxTable.set_row_spacings(2); - _viewboxTable.set_col_spacings(2); - _viewboxTable.attach(_viewboxX, 0,1, 0,1); - _viewboxTable.attach(_viewboxY, 1,2, 0,1); - _viewboxTable.attach(_viewboxW, 0,1, 1,2); - _viewboxTable.attach(_viewboxH, 1,2, 1,2); -#endif - _wr.setUpdating (true); updateScaleUI(); _wr.setUpdating (false); diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index 0eea28e61..f1966f848 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -23,15 +23,9 @@ #include #include #include +#include #include #include - -#if WITH_GTKMM_3_0 -# include -#else -# include -#endif - #include namespace Inkscape { @@ -222,12 +216,7 @@ protected: //### Custom size frame Gtk::Frame _customFrame; - -#if WITH_GTKMM_3_0 Gtk::Grid _customDimTable; -#else - Gtk::Table _customDimTable; -#endif RegisteredUnitMenu _dimensionUnits; RegisteredScalarUnit _dimensionWidth; @@ -237,12 +226,7 @@ protected: //### Fit Page options Gtk::Expander _fitPageMarginExpander; -#if WITH_GTKMM_3_0 Gtk::Grid _marginTable; -#else - Gtk::Table _marginTable; -#endif - Gtk::Alignment _marginTopAlign; Gtk::Alignment _marginLeftAlign; Gtk::Alignment _marginRightAlign; @@ -257,11 +241,7 @@ protected: // Document scale Gtk::Frame _scaleFrame; -#if WITH_GTKMM_3_0 Gtk::Grid _scaleTable; -#else - Gtk::Table _scaleTable; -#endif Gtk::Label _scaleLabel; Gtk::Label _scaleWarning; @@ -271,11 +251,7 @@ protected: // Viewbox Gtk::Expander _viewboxExpander; -#if WITH_GTKMM_3_0 Gtk::Grid _viewboxTable; -#else - Gtk::Table _viewboxTable; -#endif RegisteredScalar _viewboxX; RegisteredScalar _viewboxY; diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp index ab13577d7..8f695013d 100644 --- a/src/ui/widget/panel.cpp +++ b/src/ui/widget/panel.cpp @@ -74,9 +74,7 @@ Panel::Panel(Glib::ustring const &label, gchar const *prefs_path, _fillable(0) { set_name( "InkscapePanel" ); -#if WITH_GTKMM_3_0 set_orientation( Gtk::ORIENTATION_VERTICAL ); -#endif _init(); } @@ -598,13 +596,9 @@ void Panel::_addResponseButton(Gtk::Button *button, int response_id, bool pack_s { // Create a button box for the response buttons if it's the first button to be added if (!_action_area) { -#if WITH_GTKMM_3_0 _action_area = new Gtk::ButtonBox(); _action_area->set_layout(Gtk::BUTTONBOX_END); _action_area->set_spacing(6); -#else - _action_area = new Gtk::HButtonBox(Gtk::BUTTONBOX_END, 6); -#endif _action_area->set_border_width(4); pack_end(*_action_area, Gtk::PACK_SHRINK, 0); } diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h index 7b2836fe8..370779586 100644 --- a/src/ui/widget/panel.h +++ b/src/ui/widget/panel.h @@ -31,13 +31,7 @@ class SPDocument; namespace Gtk { class CheckMenuItem; - -#if WITH_GTKMM_3_0 class ButtonBox; -#else - class HButtonBox; -#endif - class MenuItem; } @@ -64,12 +58,7 @@ namespace Widget { * @see UI::Dialog::DesktopTracker to handle desktop change, selection change and selected object modifications. * @see UI::Dialog::DialogManager manages the dialogs within inkscape. */ -#if WITH_GTKMM_3_0 class Panel : public Gtk::Box { -#else -class Panel : public Gtk::VBox { -#endif - public: static void prep(); @@ -172,12 +161,7 @@ private: Gtk::EventBox _menu_popper; Gtk::Button _close_button; Gtk::Menu *_menu; - -#if WITH_GTKMM_3_0 - Gtk::ButtonBox *_action_area; //< stores response buttons -#else - Gtk::HButtonBox *_action_area; //< stores response buttons -#endif + Gtk::ButtonBox *_action_area; //< stores response buttons std::vector _non_horizontal; std::vector _non_vertical; diff --git a/src/ui/widget/point.cpp b/src/ui/widget/point.cpp index 6aa6196bb..66f5e41a3 100644 --- a/src/ui/widget/point.cpp +++ b/src/ui/widget/point.cpp @@ -53,11 +53,7 @@ Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip, } Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip, -#if WITH_GTKMM_3_0 Glib::RefPtr &adjust, -#else - Gtk::Adjustment &adjust, -#endif unsigned digits, Glib::ustring const &suffix, Glib::ustring const &icon, diff --git a/src/ui/widget/point.h b/src/ui/widget/point.h index 17078df8f..71bfd8473 100644 --- a/src/ui/widget/point.h +++ b/src/ui/widget/point.h @@ -82,11 +82,7 @@ public: */ Point( Glib::ustring const &label, Glib::ustring const &tooltip, -#if WITH_GTKMM_3_0 Glib::RefPtr &adjust, -#else - Gtk::Adjustment &adjust, -#endif unsigned digits = 0, Glib::ustring const &suffix = "", Glib::ustring const &icon = "", diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp index d56506d62..2e6e3f0db 100644 --- a/src/ui/widget/preferences-widget.cpp +++ b/src/ui/widget/preferences-widget.cpp @@ -55,14 +55,9 @@ DialogPage::DialogPage() { set_border_width(12); -#if WITH_GTKMM_3_0 set_orientation(Gtk::ORIENTATION_VERTICAL); set_column_spacing(12); set_row_spacing(6); -#else - set_col_spacings(12); - set_row_spacings(6); -#endif } /** @@ -101,12 +96,7 @@ void DialogPage::add_line(bool indent, // be indented if desired Gtk::Alignment* w_alignment = Gtk::manage(new Gtk::Alignment()); w_alignment->add(*hb); - -#if WITH_GTKMM_3_0 w_alignment->set_valign(Gtk::ALIGN_CENTER); -#else - guint row = property_n_rows(); -#endif // Add a label in the first column if provided if (label != "") @@ -122,17 +112,12 @@ void DialogPage::add_line(bool indent, if (indent) label_alignment->set_padding(0, 0, 12, 0); -#if WITH_GTKMM_3_0 label_alignment->set_valign(Gtk::ALIGN_CENTER); add(*label_alignment); attach_next_to(*w_alignment, *label_alignment, Gtk::POS_RIGHT, 1, 1); -#else - attach(*label_alignment, 0, 1, row, row + 1, Gtk::FILL, Gtk::AttachOptions(), 0, 0); -#endif } // Now add the widget to the bottom of the dialog -#if WITH_GTKMM_3_0 if (label == "") { if (indent) @@ -145,17 +130,6 @@ void DialogPage::add_line(bool indent, g_value_set_int(&width, 2); gtk_container_child_set_property(GTK_CONTAINER(gobj()), GTK_WIDGET(w_alignment->gobj()), "width", &width); } -#else - // The widget should span two columns if there is no label - int w_col_span = 1; - if (label == "") - w_col_span = 2; - - attach(*w_alignment, 2 - w_col_span, 2, row, row + 1, - Gtk::FILL | Gtk::EXPAND, - Gtk::AttachOptions(), - 0, 0); -#endif // Add a label on the right of the widget if desired if (suffix != "") @@ -174,18 +148,8 @@ void DialogPage::add_group_header(Glib::ustring name) Glib::ustring(""/*"*/) , Gtk::ALIGN_START , Gtk::ALIGN_CENTER, true)); label_widget->set_use_markup(true); - -#if WITH_GTKMM_3_0 label_widget->set_valign(Gtk::ALIGN_CENTER); add(*label_widget); -// if (row != 1) - // set_row_spacing(row - 1, 18); -#else - int row = property_n_rows(); - attach(*label_widget , 0, 4, row, row + 1, Gtk::FILL, Gtk::AttachOptions(), 0, 0); - if (row != 1) - set_row_spacing(row - 1, 18); -#endif } } @@ -427,24 +391,6 @@ ZoomCorrRuler::draw_marks(Cairo::RefPtr cr, double dist, int maj } } -#if !WITH_GTKMM_3_0 -bool -ZoomCorrRuler::on_expose_event(GdkEventExpose *event) { - bool result = false; - - if(get_is_drawable()) - { - Cairo::RefPtr cr = get_window()->create_cairo_context(); - cr->rectangle(event->area.x, event->area.y, - event->area.width, event->area.height); - cr->clip(); - result = on_draw(cr); - } - - return result; -} -#endif - bool ZoomCorrRuler::on_draw(const Cairo::RefPtr& cr) { Glib::RefPtr window = get_window(); @@ -548,11 +494,7 @@ ZoomCorrRulerSlider::init(int ruler_width, int ruler_height, double lower, doubl _ruler.set_size(ruler_width, ruler_height); -#if WITH_GTKMM_3_0 _slider = Gtk::manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL)); -#else - _slider = Gtk::manage(new Gtk::HScale()); -#endif _slider->set_size_request(_ruler.width(), -1); _slider->set_range (lower, upper); @@ -579,21 +521,13 @@ ZoomCorrRulerSlider::init(int ruler_width, int ruler_height, double lower, doubl alignment1->add(_sb); alignment2->add(_unit); -#if WITH_GTKMM_3_0 - Gtk::Grid *table = Gtk::manage(new Gtk::Grid()); + auto table = Gtk::manage(new Gtk::Grid()); table->attach(*_slider, 0, 0, 1, 1); alignment1->set_halign(Gtk::ALIGN_CENTER); table->attach(*alignment1, 1, 0, 1, 1); table->attach(_ruler, 0, 1, 1, 1); alignment2->set_halign(Gtk::ALIGN_CENTER); table->attach(*alignment2, 1, 1, 1, 1); -#else - Gtk::Table *table = Gtk::manage(new Gtk::Table()); - table->attach(*_slider, 0, 1, 0, 1); - table->attach(*alignment1, 1, 2, 0, 1, static_cast(0)); - table->attach(_ruler, 0, 1, 1, 2); - table->attach(*alignment2, 1, 2, 1, 2, static_cast(0)); -#endif pack_start(*table, Gtk::PACK_SHRINK); } @@ -640,11 +574,7 @@ PrefSlider::init(Glib::ustring const &prefs_path, freeze = false; -#if WITH_GTKMM_3_0 _slider = Gtk::manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL)); -#else - _slider = Gtk::manage(new Gtk::HScale()); -#endif _slider->set_range (lower, upper); _slider->set_increments (step_increment, page_increment); @@ -661,17 +591,11 @@ PrefSlider::init(Glib::ustring const &prefs_path, Gtk::Alignment *alignment1 = Gtk::manage(new Gtk::Alignment(0.5,1,0,0)); alignment1->add(_sb); -#if WITH_GTKMM_3_0 - Gtk::Grid *table = Gtk::manage(new Gtk::Grid()); + auto table = Gtk::manage(new Gtk::Grid()); _slider->set_hexpand(); table->attach(*_slider, 0, 0, 1, 1); alignment1->set_halign(Gtk::ALIGN_CENTER); table->attach(*alignment1, 1, 0, 1, 1); -#else - Gtk::Table *table = Gtk::manage(new Gtk::Table()); - table->attach(*_slider, 0, 1, 0, 1); - table->attach(*alignment1, 1, 2, 0, 1, static_cast(0)); -#endif this->pack_start(*table, Gtk::PACK_EXPAND_WIDGET); } diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h index 1d2d77699..142793509 100644 --- a/src/ui/widget/preferences-widget.h +++ b/src/ui/widget/preferences-widget.h @@ -30,12 +30,7 @@ #include #include #include - -#if WITH_GTKMM_3_0 #include -#else -#include -#endif #include "ui/widget/color-picker.h" #include "ui/widget/unit-menu.h" @@ -43,11 +38,7 @@ #include "ui/widget/scalar-unit.h" namespace Gtk { -#if WITH_GTKMM_3_0 class Scale; -#else -class HScale; -#endif } namespace Inkscape { @@ -126,10 +117,6 @@ public: static const double textpadding; private: -#if !WITH_GTKMM_3_0 - bool on_expose_event(GdkEventExpose *event); -#endif - bool on_draw(const Cairo::RefPtr& cr); void draw_marks(Cairo::RefPtr cr, double dist, int major_interval); @@ -155,11 +142,7 @@ private: Inkscape::UI::Widget::SpinButton _sb; UnitMenu _unit; -#if WITH_GTKMM_3_0 Gtk::Scale* _slider; -#else - Gtk::HScale* _slider; -#endif ZoomCorrRuler _ruler; bool freeze; // used to block recursive updates of slider and spinbutton }; @@ -178,11 +161,7 @@ private: Glib::ustring _prefs_path; Inkscape::UI::Widget::SpinButton _sb; -#if WITH_GTKMM_3_0 Gtk::Scale* _slider; -#else - Gtk::HScale* _slider; -#endif bool freeze; // used to block recursive updates of slider and spinbutton }; @@ -279,11 +258,7 @@ protected: void on_changed(); }; -#if WITH_GTKMM_3_0 class DialogPage : public Gtk::Grid -#else -class DialogPage : public Gtk::Table -#endif { public: DialogPage(); diff --git a/src/ui/widget/random.cpp b/src/ui/widget/random.cpp index 0a646b6fb..8551e2add 100644 --- a/src/ui/widget/random.cpp +++ b/src/ui/widget/random.cpp @@ -47,11 +47,7 @@ Random::Random(Glib::ustring const &label, Glib::ustring const &tooltip, } Random::Random(Glib::ustring const &label, Glib::ustring const &tooltip, -#if WITH_GTKMM_3_0 Glib::RefPtr &adjust, -#else - Gtk::Adjustment &adjust, -#endif unsigned digits, Glib::ustring const &suffix, Glib::ustring const &icon, diff --git a/src/ui/widget/random.h b/src/ui/widget/random.h index dc2b457c2..d86ab6246 100644 --- a/src/ui/widget/random.h +++ b/src/ui/widget/random.h @@ -75,11 +75,7 @@ public: */ Random(Glib::ustring const &label, Glib::ustring const &tooltip, -#if WITH_GTKMM_3_0 Glib::RefPtr &adjust, -#else - Gtk::Adjustment &adjust, -#endif unsigned digits = 0, Glib::ustring const &suffix = "", Glib::ustring const &icon = "", diff --git a/src/ui/widget/scalar.cpp b/src/ui/widget/scalar.cpp index fca8a7974..434c2c0bb 100644 --- a/src/ui/widget/scalar.cpp +++ b/src/ui/widget/scalar.cpp @@ -43,11 +43,7 @@ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, } Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, -#if WITH_GTKMM_3_0 Glib::RefPtr &adjust, -#else - Gtk::Adjustment &adjust, -#endif unsigned digits, Glib::ustring const &suffix, Glib::ustring const &icon, @@ -141,11 +137,7 @@ void Scalar::update() void Scalar::addSlider() { -#if WITH_GTKMM_3_0 - Gtk::Scale *scale = new Gtk::Scale(static_cast(_widget)->get_adjustment()); -#else - Gtk::HScale *scale = new Gtk::HScale( * static_cast(_widget)->get_adjustment() ); -#endif + auto scale = new Gtk::Scale(static_cast(_widget)->get_adjustment()); scale->set_draw_value(false); add (*manage (scale)); } diff --git a/src/ui/widget/scalar.h b/src/ui/widget/scalar.h index 86d7aee28..847790b96 100644 --- a/src/ui/widget/scalar.h +++ b/src/ui/widget/scalar.h @@ -73,11 +73,7 @@ public: */ Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, -#if WITH_GTKMM_3_0 Glib::RefPtr &adjust, -#else - Gtk::Adjustment &adjust, -#endif unsigned digits = 0, Glib::ustring const &suffix = "", Glib::ustring const &icon = "", diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index f7fd63f51..7679fadb4 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -123,11 +123,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/) current_stroke_width(0), _desktop (NULL), -#if WITH_GTKMM_3_0 _table(), -#else - _table(2, 6), -#endif _fill_label (_("Fill:")), _stroke_label (_("Stroke:")), _opacity_label (_("O:")), @@ -139,11 +135,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _stroke_flag_place (), _opacity_place (), -#if WITH_GTKMM_3_0 _opacity_adjustment(Gtk::Adjustment::create(100, 0.0, 100, 1.0, 10.0)), -#else - _opacity_adjustment (100, 0.0, 100, 1.0, 10.0), -#endif _opacity_sb (0.02, 0), _stroke (), @@ -166,13 +158,8 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _opacity_label.set_alignment(0.0, 0.5); _opacity_label.set_padding(0, 0); -#if WITH_GTKMM_3_0 _table.set_column_spacing(2); _table.set_row_spacing(0); -#else - _table.set_col_spacings (2); - _table.set_row_spacings (0); -#endif for (int i = SS_FILL; i <= SS_STROKE; i++) { @@ -379,7 +366,6 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _opacity_sb.set_size_request (SELECTED_STYLE_SB_WIDTH, -1); _opacity_sb.set_sensitive (false); -#if WITH_GTKMM_3_0 _table.attach(_fill_label, 0, 0, 1, 1); _table.attach(_stroke_label, 0, 1, 1, 1); @@ -388,26 +374,11 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _table.attach(_fill_place, 2, 0, 1, 1); _table.attach(_stroke, 2, 1, 1, 1); -#else - _table.attach(_fill_label, 0,1, 0,1, Gtk::FILL, Gtk::SHRINK); - _table.attach(_stroke_label, 0,1, 1,2, Gtk::FILL, Gtk::SHRINK); - - _table.attach(_fill_flag_place, 1,2, 0,1, Gtk::SHRINK, Gtk::SHRINK); - _table.attach(_stroke_flag_place, 1,2, 1,2, Gtk::SHRINK, Gtk::SHRINK); - - _table.attach(_fill_place, 2,3, 0,1); - _table.attach(_stroke, 2,3, 1,2); -#endif _opacity_place.add(_opacity_label); -#if WITH_GTKMM_3_0 _table.attach(_opacity_place, 4, 0, 1, 2); _table.attach(_opacity_sb, 5, 0, 1, 2); -#else - _table.attach(_opacity_place, 4,5, 0,2, Gtk::SHRINK, Gtk::SHRINK); - _table.attach(_opacity_sb, 5,6, 0,2, Gtk::SHRINK, Gtk::SHRINK); -#endif pack_start(_table, true, true, 2); @@ -1120,11 +1091,7 @@ SelectedStyle::update() if (_opacity_blocked) break; _opacity_blocked = true; _opacity_sb.set_sensitive(true); -#if WITH_GTKMM_3_0 _opacity_adjustment->set_value(SP_SCALE24_TO_FLOAT(query.opacity.value) * 100); -#else - _opacity_adjustment.set_value(SP_SCALE24_TO_FLOAT(query.opacity.value) * 100); -#endif _opacity_blocked = false; break; } @@ -1224,11 +1191,7 @@ void SelectedStyle::on_opacity_changed () _opacity_blocked = true; SPCSSAttr *css = sp_repr_css_attr_new (); Inkscape::CSSOStringStream os; -#if WITH_GTKMM_3_0 os << CLAMP ((_opacity_adjustment->get_value() / 100), 0.0, 1.0); -#else - os << CLAMP ((_opacity_adjustment.get_value() / 100), 0.0, 1.0); -#endif sp_repr_css_set_property (css, "opacity", os.str().c_str()); // FIXME: workaround for GTK breakage: display interruptibility sometimes results in GTK // sending multiple value-changed events. As if when Inkscape interrupts redraw for main loop diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h index 804a6fef6..efac29f73 100644 --- a/src/ui/widget/selected-style.h +++ b/src/ui/widget/selected-style.h @@ -16,12 +16,7 @@ #endif #include - -#if WITH_GTKMM_3_0 -# include -#else -# include -#endif +#include #include #include @@ -140,11 +135,7 @@ public: protected: SPDesktop *_desktop; -#if WITH_GTKMM_3_0 Gtk::Grid _table; -#else - Gtk::Table _table; -#endif Gtk::Label _fill_label; Gtk::Label _stroke_label; @@ -157,11 +148,7 @@ protected: Gtk::EventBox _stroke_flag_place; Gtk::EventBox _opacity_place; -#if WITH_GTKMM_3_0 Glib::RefPtr _opacity_adjustment; -#else - Gtk::Adjustment _opacity_adjustment; -#endif Inkscape::UI::Widget::SpinButton _opacity_sb; Gtk::Label _na[2]; diff --git a/src/ui/widget/spin-scale.cpp b/src/ui/widget/spin-scale.cpp index bb08d67df..f2a163c84 100644 --- a/src/ui/widget/spin-scale.cpp +++ b/src/ui/widget/spin-scale.cpp @@ -22,13 +22,8 @@ SpinScale::SpinScale(const char* label, double value, double lower, double upper double /*climb_rate*/, int digits, const SPAttributeEnum a, const char* tip_text) : AttrWidget(a, value) { -#if WITH_GTKMM_3_0 _adjustment = Gtk::Adjustment::create(value, lower, upper, step_inc); _spinscale = gimp_spin_scale_new (_adjustment->gobj(), label, digits); -#else - _adjustment = new Gtk::Adjustment(value, lower, upper, step_inc); - _spinscale = gimp_spin_scale_new (_adjustment->gobj(), label, digits); -#endif signal_value_changed().connect(signal_attr_changed().make_slot()); @@ -42,12 +37,10 @@ SpinScale::SpinScale(const char* label, double value, double lower, double upper } SpinScale::SpinScale(const char* label, -#if WITH_GTKMM_3_0 - Glib::RefPtr adj, -#else - Gtk::Adjustment *adj, -#endif - int digits, const SPAttributeEnum a, const char* tip_text) + Glib::RefPtr adj, + int digits, + const SPAttributeEnum a, + const char* tip_text) : AttrWidget(a, 0.0), _adjustment(adj) @@ -111,19 +104,12 @@ void SpinScale::set_appearance(const gchar* appearance) gimp_spin_scale_set_appearance(_spinscale, appearance); } -#if WITH_GTKMM_3_0 -const Glib::RefPtr SpinScale::get_adjustment() const -#else -const Gtk::Adjustment *SpinScale::get_adjustment() const -#endif +const decltype(SpinScale::_adjustment) SpinScale::get_adjustment() const { return _adjustment; } -#if WITH_GTKMM_3_0 -Glib::RefPtr SpinScale::get_adjustment() -#else -Gtk::Adjustment *SpinScale::get_adjustment() -#endif + +decltype(SpinScale::_adjustment) SpinScale::get_adjustment() { return _adjustment; } diff --git a/src/ui/widget/spin-scale.h b/src/ui/widget/spin-scale.h index 50e4fc953..d7030bed3 100644 --- a/src/ui/widget/spin-scale.h +++ b/src/ui/widget/spin-scale.h @@ -36,12 +36,8 @@ public: int digits, const SPAttributeEnum a = SP_ATTR_INVALID, const char* tip_text = NULL); SpinScale(const char* label, -#if WITH_GTKMM_3_0 - Glib::RefPtr adj, -#else - Gtk::Adjustment *adj, -#endif - int digits, const SPAttributeEnum a = SP_ATTR_INVALID, const char* tip_text = NULL); + Glib::RefPtr adj, + int digits, const SPAttributeEnum a = SP_ATTR_INVALID, const char* tip_text = NULL); virtual Glib::ustring get_as_attribute() const; virtual void set_from_attribute(SPObject*); @@ -52,23 +48,14 @@ public: void set_value(const double); void set_focuswidget(GtkWidget *widget); void set_appearance(const gchar* appearance); - -#if WITH_GTKMM_3_0 - const Glib::RefPtr get_adjustment() const; - Glib::RefPtr get_adjustment(); -#else - const Gtk::Adjustment *get_adjustment() const; - Gtk::Adjustment *get_adjustment(); -#endif private: -#if WITH_GTKMM_3_0 Glib::RefPtr _adjustment; -#else - Gtk::Adjustment *_adjustment; -#endif - GtkWidget *_spinscale; + +public: + const decltype(_adjustment) get_adjustment() const; + decltype(_adjustment) get_adjustment(); }; diff --git a/src/ui/widget/spin-slider.cpp b/src/ui/widget/spin-slider.cpp index 9b361ae78..f17b9b26c 100644 --- a/src/ui/widget/spin-slider.cpp +++ b/src/ui/widget/spin-slider.cpp @@ -20,11 +20,7 @@ namespace Widget { SpinSlider::SpinSlider(double value, double lower, double upper, double step_inc, double climb_rate, int digits, const SPAttributeEnum a, const char* tip_text) : AttrWidget(a, value), -#if WITH_GTKMM_3_0 _adjustment(Gtk::Adjustment::create(value, lower, upper, step_inc)), -#else - _adjustment(value, lower, upper, step_inc), -#endif _scale(_adjustment), _spin(_adjustment, climb_rate, digits) { signal_value_changed().connect(signal_attr_changed().make_slot()); @@ -43,11 +39,7 @@ SpinSlider::SpinSlider(double value, double lower, double upper, double step_inc Glib::ustring SpinSlider::get_as_attribute() const { -#if WITH_GTKMM_3_0 - const double val = _adjustment->get_value(); -#else - const double val = _adjustment.get_value(); -#endif + const auto val = _adjustment->get_value(); if(_spin.get_digits() == 0) return Glib::Ascii::dtostr((int)val); @@ -58,77 +50,43 @@ Glib::ustring SpinSlider::get_as_attribute() const void SpinSlider::set_from_attribute(SPObject* o) { const gchar* val = attribute_value(o); -#if WITH_GTKMM_3_0 if(val) _adjustment->set_value(Glib::Ascii::strtod(val)); else _adjustment->set_value(get_default()->as_double()); -#else - if(val) - _adjustment.set_value(Glib::Ascii::strtod(val)); - else - _adjustment.set_value(get_default()->as_double()); -#endif } Glib::SignalProxy0 SpinSlider::signal_value_changed() { -#if WITH_GTKMM_3_0 return _adjustment->signal_value_changed(); -#else - return _adjustment.signal_value_changed(); -#endif } double SpinSlider::get_value() const { -#if WITH_GTKMM_3_0 return _adjustment->get_value(); -#else - return _adjustment.get_value(); -#endif } void SpinSlider::set_value(const double val) { -#if WITH_GTKMM_3_0 _adjustment->set_value(val); -#else - _adjustment.set_value(val); -#endif } -#if WITH_GTKMM_3_0 -const Glib::RefPtr SpinSlider::get_adjustment() const -#else -const Gtk::Adjustment& SpinSlider::get_adjustment() const -#endif +const decltype(SpinSlider::_adjustment) SpinSlider::get_adjustment() const { return _adjustment; } -#if WITH_GTKMM_3_0 -Glib::RefPtr SpinSlider::get_adjustment() -#else -Gtk::Adjustment& SpinSlider::get_adjustment() -#endif + +decltype(SpinSlider::_adjustment) SpinSlider::get_adjustment() { return _adjustment; } -#if WITH_GTKMM_3_0 const Gtk::Scale& SpinSlider::get_scale() const -#else -const Gtk::HScale& SpinSlider::get_scale() const -#endif { return _scale; } -#if WITH_GTKMM_3_0 Gtk::Scale& SpinSlider::get_scale() -#else -Gtk::HScale& SpinSlider::get_scale() -#endif { return _scale; } @@ -157,15 +115,9 @@ DualSpinSlider::DualSpinSlider(double value, double lower, double upper, double { signal_value_changed().connect(signal_attr_changed().make_slot()); -#if WITH_GTKMM_3_0 _s1.get_adjustment()->signal_value_changed().connect(_signal_value_changed.make_slot()); _s2.get_adjustment()->signal_value_changed().connect(_signal_value_changed.make_slot()); _s1.get_adjustment()->signal_value_changed().connect(sigc::mem_fun(*this, &DualSpinSlider::update_linked)); -#else - _s1.get_adjustment().signal_value_changed().connect(_signal_value_changed.make_slot()); - _s2.get_adjustment().signal_value_changed().connect(_signal_value_changed.make_slot()); - _s1.get_adjustment().signal_value_changed().connect(sigc::mem_fun(*this, &DualSpinSlider::update_linked)); -#endif _link.signal_toggled().connect(sigc::mem_fun(*this, &DualSpinSlider::link_toggled)); Gtk::VBox* vb = Gtk::manage(new Gtk::VBox); @@ -202,13 +154,8 @@ void DualSpinSlider::set_from_attribute(SPObject* o) _link.set_active(toks[1] == 0); -#if WITH_GTKMM_3_0 _s1.get_adjustment()->set_value(v1); _s2.get_adjustment()->set_value(v2); -#else - _s1.get_adjustment().set_value(v1); - _s2.get_adjustment().set_value(v2); -#endif g_strfreev(toks); } diff --git a/src/ui/widget/spin-slider.h b/src/ui/widget/spin-slider.h index a5999f14f..5a29c1b67 100644 --- a/src/ui/widget/spin-slider.h +++ b/src/ui/widget/spin-slider.h @@ -42,17 +42,8 @@ public: double get_value() const; void set_value(const double); -#if WITH_GTKMM_3_0 - const Glib::RefPtr get_adjustment() const; - Glib::RefPtr get_adjustment(); const Gtk::Scale& get_scale() const; Gtk::Scale& get_scale(); -#else - const Gtk::Adjustment& get_adjustment() const; - Gtk::Adjustment& get_adjustment(); - const Gtk::HScale& get_scale() const; - Gtk::HScale& get_scale(); -#endif const Inkscape::UI::Widget::SpinButton& get_spin_button() const; Inkscape::UI::Widget::SpinButton& get_spin_button(); @@ -60,14 +51,13 @@ public: // Change the SpinSlider into a SpinButton with AttrWidget support) void remove_scale(); private: -#if WITH_GTKMM_3_0 Glib::RefPtr _adjustment; Gtk::Scale _scale; -#else - Gtk::Adjustment _adjustment; - Gtk::HScale _scale; -#endif Inkscape::UI::Widget::SpinButton _spin; + +public: + const decltype(_adjustment) get_adjustment() const; + decltype(_adjustment) get_adjustment(); }; /** diff --git a/src/ui/widget/style-swatch.cpp b/src/ui/widget/style-swatch.cpp index 188be705d..21701c4c0 100644 --- a/src/ui/widget/style-swatch.cpp +++ b/src/ui/widget/style-swatch.cpp @@ -34,11 +34,7 @@ #include "verbs.h" #include -#if WITH_GTKMM_3_0 -# include -#else -# include -#endif +#include enum { SS_FILL, @@ -117,11 +113,7 @@ StyleSwatch::StyleSwatch(SPCSSAttr *css, gchar const *main_tip) _css(NULL), _tool_obs(NULL), _style_obs(NULL), -#if WITH_GTKMM_3_0 _table(Gtk::manage(new Gtk::Grid())), -#else - _table(Gtk::manage(new Gtk::Table(2, 6))), -#endif _sw_unit(NULL) { set_name("StyleSwatch"); @@ -139,13 +131,8 @@ StyleSwatch::StyleSwatch(SPCSSAttr *css, gchar const *main_tip) _opacity_value.set_alignment(0.0, 0.5); _opacity_value.set_padding(0, 0); -#if WITH_GTKMM_3_0 _table->set_column_spacing(2); _table->set_row_spacing(0); -#else - _table->set_col_spacings(2); - _table->set_row_spacings(0); -#endif _stroke.pack_start(_place[SS_STROKE]); _stroke_width_place.add(_stroke_width); @@ -153,19 +140,11 @@ StyleSwatch::StyleSwatch(SPCSSAttr *css, gchar const *main_tip) _opacity_place.add(_opacity_value); -#if WITH_GTKMM_3_0 _table->attach(_label[SS_FILL], 0, 0, 1, 1); _table->attach(_label[SS_STROKE], 0, 1, 1, 1); _table->attach(_place[SS_FILL], 1, 0, 1, 1); _table->attach(_stroke, 1, 1, 1, 1); _table->attach(_opacity_place, 2, 0, 1, 2); -#else - _table->attach(_label[SS_FILL], 0,1, 0,1, Gtk::FILL, Gtk::SHRINK); - _table->attach(_label[SS_STROKE], 0,1, 1,2, Gtk::FILL, Gtk::SHRINK); - _table->attach(_place[SS_FILL], 1,2, 0,1); - _table->attach(_stroke, 1,2, 1,2); - _table->attach(_opacity_place, 2,3, 0,2, Gtk::SHRINK, Gtk::SHRINK); -#endif _swatch.add(*_table); pack_start(_swatch, true, true, 0); diff --git a/src/ui/widget/style-swatch.h b/src/ui/widget/style-swatch.h index 0016e0256..81a907d16 100644 --- a/src/ui/widget/style-swatch.h +++ b/src/ui/widget/style-swatch.h @@ -29,11 +29,7 @@ class SPStyle; class SPCSSAttr; namespace Gtk { -#if WITH_GTKMM_3_0 class Grid; -#else -class Table; -#endif } namespace Inkscape { @@ -75,11 +71,7 @@ private: Gtk::EventBox _swatch; -#if WITH_GTKMM_3_0 Gtk::Grid *_table; -#else - Gtk::Table *_table; -#endif Gtk::Label _label[2]; Gtk::EventBox _place[2]; diff --git a/src/ui/widget/tolerance-slider.cpp b/src/ui/widget/tolerance-slider.cpp index ced811c57..a87ed7c0f 100644 --- a/src/ui/widget/tolerance-slider.cpp +++ b/src/ui/widget/tolerance-slider.cpp @@ -76,12 +76,8 @@ void ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& la // align the label with the checkbox text above by indenting 22 px. _hbox->pack_start(*theLabel1, Gtk::PACK_EXPAND_WIDGET, 22); -#if WITH_GTKMM_3_0 _hscale = Gtk::manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL)); _hscale->set_range(1.0, 51.0); -#else - _hscale = Gtk::manage (new Gtk::HScale (1.0, 51, 1.0)); -#endif theLabel1->set_mnemonic_widget (*_hscale); _hscale->set_draw_value (true); @@ -121,11 +117,7 @@ void ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& la void ToleranceSlider::setValue (double val) { -#if WITH_GTKMM_3_0 - Glib::RefPtr adj = _hscale->get_adjustment(); -#else - Gtk::Adjustment *adj = _hscale->get_adjustment(); -#endif + auto adj = _hscale->get_adjustment(); adj->set_lower (1.0); adj->set_upper (51.0); diff --git a/src/ui/widget/tolerance-slider.h b/src/ui/widget/tolerance-slider.h index 7ae8e4712..3d2548ebe 100644 --- a/src/ui/widget/tolerance-slider.h +++ b/src/ui/widget/tolerance-slider.h @@ -14,11 +14,7 @@ namespace Gtk { class RadioButton; -#if WITH_GTKMM_3_0 class Scale; -#else -class HScale; -#endif } namespace Inkscape { @@ -60,13 +56,7 @@ protected: void on_toggled(); void update (double val); Gtk::HBox *_hbox; - -#if WITH_GTKMM_3_0 Gtk::Scale *_hscale; -#else - Gtk::HScale *_hscale; -#endif - Gtk::RadioButtonGroup _radio_button_group; Gtk::RadioButton *_button1; Gtk::RadioButton *_button2; -- cgit v1.2.3 From dcd91f59f597ab4af07cee5929ce0e2e1f9104d5 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 28 Jul 2016 16:16:18 +0100 Subject: Drop remaining GTKMM 2 fallback support (bzr r15023.2.7) --- src/ui/clipboard.cpp | 11 +- src/ui/dialog/aboutbox.cpp | 14 +- src/ui/dialog/align-and-distribute.cpp | 38 +---- src/ui/dialog/align-and-distribute.h | 38 +---- src/ui/dialog/calligraphic-profile-rename.cpp | 25 +-- src/ui/dialog/calligraphic-profile-rename.h | 9 -- src/ui/dialog/clonetiler.cpp | 217 ++++---------------------- src/ui/dialog/clonetiler.h | 5 - src/ui/dialog/debug.cpp | 7 +- src/ui/dialog/document-metadata.cpp | 31 ---- src/ui/dialog/document-metadata.h | 12 +- src/ui/dialog/document-properties.cpp | 129 +-------------- src/ui/dialog/document-properties.h | 6 +- src/ui/dialog/export.cpp | 90 +---------- src/ui/dialog/export.h | 40 ----- src/ui/dialog/filedialogimpl-gtkmm.cpp | 86 ++-------- src/ui/dialog/filedialogimpl-win32.cpp | 4 - src/ui/dialog/fill-and-stroke.cpp | 19 --- src/ui/dialog/fill-and-stroke.h | 4 - src/ui/dialog/filter-effects-dialog.cpp | 164 ++----------------- src/ui/dialog/filter-effects-dialog.h | 12 -- src/ui/dialog/find.h | 6 - src/ui/dialog/floating-behavior.cpp | 8 - src/ui/dialog/glyphs.cpp | 79 +--------- src/ui/dialog/grid-arrange-tab.cpp | 20 +-- src/ui/dialog/grid-arrange-tab.h | 5 - src/ui/dialog/guides.cpp | 58 +------ src/ui/dialog/guides.h | 12 +- src/ui/dialog/icon-preview.h | 6 - src/ui/dialog/inkscape-preferences.cpp | 42 +---- src/ui/dialog/inkscape-preferences.h | 8 - src/ui/dialog/input.cpp | 131 +--------------- src/ui/dialog/layer-properties.cpp | 31 +--- src/ui/dialog/layer-properties.h | 10 -- src/ui/dialog/layers.cpp | 4 - src/ui/dialog/layers.h | 6 - src/ui/dialog/livepatheffect-add.cpp | 6 +- src/ui/dialog/livepatheffect-editor.cpp | 7 - src/ui/dialog/livepatheffect-editor.h | 4 - src/ui/dialog/new-from-template.cpp | 8 - src/ui/dialog/object-properties.cpp | 94 +---------- src/ui/dialog/object-properties.h | 4 - src/ui/dialog/objects.cpp | 21 --- src/ui/dialog/objects.h | 10 -- src/ui/dialog/ocaldialogs.cpp | 162 +------------------ src/ui/dialog/ocaldialogs.h | 41 +---- src/ui/dialog/polar-arrange-tab.cpp | 31 ---- src/ui/dialog/polar-arrange-tab.h | 11 +- src/ui/dialog/spellcheck.h | 15 -- src/ui/dialog/svg-fonts-dialog.cpp | 5 - src/ui/dialog/svg-fonts-dialog.h | 9 -- src/ui/dialog/swatches.cpp | 4 - src/ui/dialog/symbols.cpp | 49 +----- src/ui/dialog/tags.cpp | 4 - src/ui/dialog/tags.h | 6 - src/ui/dialog/text-edit.cpp | 25 +-- src/ui/dialog/text-edit.h | 11 -- src/ui/dialog/tile.h | 5 - src/ui/dialog/transformation.cpp | 102 ------------ src/ui/dialog/transformation.h | 4 - src/ui/dialog/undo-history.cpp | 33 ---- src/ui/dialog/undo-history.h | 18 --- src/ui/dialog/xml-tree.cpp | 18 --- src/ui/dialog/xml-tree.h | 11 -- src/ui/previewholder.cpp | 119 +++----------- src/ui/previewholder.h | 9 -- src/ui/tools/tool-base.cpp | 6 - 67 files changed, 129 insertions(+), 2110 deletions(-) (limited to 'src/ui') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index d581dbf7e..6b24c5a2d 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -1300,11 +1300,7 @@ Geom::Scale ClipboardManagerImpl::_getScale(SPDesktop *desktop, Geom::Point cons */ Glib::ustring ClipboardManagerImpl::_getBestTarget() { -#if WITH_GTKMM_3_0 - std::vector targets = _clipboard->wait_for_targets(); -#else - std::list targets = _clipboard->wait_for_targets(); -#endif + auto targets = _clipboard->wait_for_targets(); // clipboard target debugging snippet /* @@ -1363,12 +1359,7 @@ void ClipboardManagerImpl::_setClipboardTargets() { Inkscape::Extension::DB::OutputList outlist; Inkscape::Extension::db.get_output_list(outlist); - -#if WITH_GTKMM_3_0 std::vector target_list; -#else - std::list target_list; -#endif bool plaintextSet = false; for (Inkscape::Extension::DB::OutputList::const_iterator out = outlist.begin() ; out != outlist.end() ; ++out) { diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp index 6276d3391..ffb46fd1b 100644 --- a/src/ui/dialog/aboutbox.cpp +++ b/src/ui/dialog/aboutbox.cpp @@ -98,11 +98,7 @@ AboutBox::AboutBox() : Gtk::Dialog(_("About Inkscape")) { tabs->append_page(*manage( make_scrolled_text(license_text)), _("_License"), true); -#if WITH_GTKMM_3_0 get_content_area()->pack_end(*manage(tabs), true, true); -#else - get_vbox()->pack_end(*manage(tabs), true, true); -#endif tabs->show_all(); @@ -130,20 +126,12 @@ AboutBox::AboutBox() : Gtk::Dialog(_("About Inkscape")) { link->set_selectable(true); link->show(); -#if WITH_GTKMM_3_0 get_content_area()->pack_start(*manage(label), false, false); get_content_area()->pack_start(*manage(link), false, false); -#else - get_vbox()->pack_start(*manage(label), false, false); - get_vbox()->pack_start(*manage(link), false, false); -#endif Gtk::Requisition requisition; -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_get_preferred_size(reinterpret_cast(gobj()), &requisition, NULL); -#else - gtk_widget_size_request (reinterpret_cast(gobj()), &requisition); -#endif + // allow window to shrink set_size_request(0, 0); set_default_size(requisition.width, requisition.height); diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 8f87932b8..971275e59 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -61,11 +61,7 @@ namespace Dialog { Action::Action(const Glib::ustring &id, const Glib::ustring &tiptext, guint row, guint column, -#if WITH_GTKMM_3_0 - Gtk::Grid &parent, -#else - Gtk::Table &parent, -#endif + Gtk::Grid &parent, AlignAndDistribute &dialog): _dialog(dialog), _id(id), @@ -81,11 +77,7 @@ Action::Action(const Glib::ustring &id, pButton->signal_clicked() .connect(sigc::mem_fun(*this, &Action::on_button_click)); pButton->set_tooltip_text(tiptext); -#if WITH_GTKMM_3_0 parent.attach(*pButton, column, row, 1, 1); -#else - parent.attach(*pButton, column, column+1, row, row+1, Gtk::FILL, Gtk::FILL); -#endif } @@ -447,11 +439,7 @@ public: Action(id, tiptext, row, column + 4, dialog.removeOverlap_table(), dialog) { -#if WITH_GTKMM_3_0 dialog.removeOverlap_table().set_column_spacing(3); -#else - dialog.removeOverlap_table().set_col_spacings(3); -#endif removeOverlapXGap.set_digits(1); removeOverlapXGap.set_size_request(60, -1); @@ -473,17 +461,10 @@ public: removeOverlapYGapLabel.set_text_with_mnemonic(C_("Gap", "_V:")); removeOverlapYGapLabel.set_mnemonic_widget(removeOverlapYGap); -#if WITH_GTKMM_3_0 dialog.removeOverlap_table().attach(removeOverlapXGapLabel, column, row, 1, 1); dialog.removeOverlap_table().attach(removeOverlapXGap, column+1, row, 1, 1); dialog.removeOverlap_table().attach(removeOverlapYGapLabel, column+2, row, 1, 1); dialog.removeOverlap_table().attach(removeOverlapYGap, column+3, row, 1, 1); -#else - dialog.removeOverlap_table().attach(removeOverlapXGapLabel, column, column+1, row, row+1, Gtk::FILL, Gtk::FILL); - dialog.removeOverlap_table().attach(removeOverlapXGap, column+1, column+2, row, row+1, Gtk::FILL, Gtk::FILL); - dialog.removeOverlap_table().attach(removeOverlapYGapLabel, column+2, column+3, row, row+1, Gtk::FILL, Gtk::FILL); - dialog.removeOverlap_table().attach(removeOverlapYGap, column+3, column+4, row, row+1, Gtk::FILL, Gtk::FILL); -#endif } private : @@ -762,11 +743,7 @@ public : guint row, guint column, AlignAndDistribute &dialog, -#if WITH_GTKMM_3_0 Gtk::Grid &table, -#else - Gtk::Table &table, -#endif Geom::Dim2 orientation, bool distribute): Action(id, tiptext, row, column, table, dialog), @@ -939,19 +916,11 @@ AlignAndDistribute::AlignAndDistribute() _rearrangeFrame(_("Rearrange")), _removeOverlapFrame(_("Remove overlaps")), _nodesFrame(_("Nodes")), -#if WITH_GTKMM_3_0 _alignTable(), _distributeTable(), _rearrangeTable(), _removeOverlapTable(), _nodesTable(), -#else - _alignTable(2, 6, true), - _distributeTable(2, 6, true), - _rearrangeTable(1, 5, false), - _removeOverlapTable(1, 5, false), - _nodesTable(1, 4, true), -#endif _anchorLabel(_("Relative to: ")), _anchorLabelNode(_("Relative to: ")), _selgrpLabel(_("_Treat selection as group: "), 1) @@ -1316,13 +1285,8 @@ void AlignAndDistribute::addRandomizeButton(const Glib::ustring &id, const Glib: ); } -#if WITH_GTKMM_3_0 void AlignAndDistribute::addBaselineButton(const Glib::ustring &id, const Glib::ustring tiptext, guint row, guint col, Gtk::Grid &table, Geom::Dim2 orientation, bool distribute) -#else -void AlignAndDistribute::addBaselineButton(const Glib::ustring &id, const Glib::ustring tiptext, - guint row, guint col, Gtk::Table &table, Geom::Dim2 orientation, bool distribute) -#endif { _actionList.push_back( new ActionBaseline( diff --git a/src/ui/dialog/align-and-distribute.h b/src/ui/dialog/align-and-distribute.h index f8cc61af2..acb3d02ed 100644 --- a/src/ui/dialog/align-and-distribute.h +++ b/src/ui/dialog/align-and-distribute.h @@ -22,15 +22,11 @@ #include #include #include -#include "2geom/rect.h" -#include "ui/dialog/desktop-tracker.h" - -#if WITH_GTKMM_3_0 #include #include -#else -#include -#endif + +#include "2geom/rect.h" +#include "ui/dialog/desktop-tracker.h" class SPItem; @@ -51,19 +47,11 @@ public: static AlignAndDistribute &getInstance() { return *new AlignAndDistribute(); } -#if WITH_GTKMM_3_0 Gtk::Grid &align_table(){return _alignTable;} Gtk::Grid &distribute_table(){return _distributeTable;} Gtk::Grid &rearrange_table(){return _rearrangeTable;} Gtk::Grid &removeOverlap_table(){return _removeOverlapTable;} Gtk::Grid &nodes_table(){return _nodesTable;} -#else - Gtk::Table &align_table(){return _alignTable;} - Gtk::Table &distribute_table(){return _distributeTable;} - Gtk::Table &rearrange_table(){return _rearrangeTable;} - Gtk::Table &removeOverlap_table(){return _removeOverlapTable;} - Gtk::Table &nodes_table(){return _nodesTable;} -#endif void setMode(bool nodeEdit); @@ -100,22 +88,13 @@ protected: guint row, guint col); void addRandomizeButton(const Glib::ustring &id, const Glib::ustring tiptext, guint row, guint col); -#if WITH_GTKMM_3_0 void addBaselineButton(const Glib::ustring &id, const Glib::ustring tiptext, guint row, guint col, Gtk::Grid &table, Geom::Dim2 orientation, bool distribute); -#else - void addBaselineButton(const Glib::ustring &id, const Glib::ustring tiptext, - guint row, guint col, Gtk::Table &table, Geom::Dim2 orientation, bool distribute); -#endif void setTargetDesktop(SPDesktop *desktop); std::list _actionList; UI::Widget::Frame _alignFrame, _distributeFrame, _rearrangeFrame, _removeOverlapFrame, _nodesFrame; -#if WITH_GTKMM_3_0 Gtk::Grid _alignTable, _distributeTable, _rearrangeTable, _removeOverlapTable, _nodesTable; -#else - Gtk::Table _alignTable, _distributeTable, _rearrangeTable, _removeOverlapTable, _nodesTable; -#endif Gtk::HBox _anchorBox; Gtk::HBox _selgrpBox; Gtk::VBox _alignBox; @@ -163,11 +142,7 @@ public : Action(const Glib::ustring &id, const Glib::ustring &tiptext, guint row, guint column, - #if WITH_GTKMM_3_0 - Gtk::Grid &parent, - #else - Gtk::Table &parent, - #endif + Gtk::Grid &parent, AlignAndDistribute &dialog); virtual ~Action(){} @@ -178,12 +153,7 @@ private : virtual void on_button_click(){} Glib::ustring _id; - -#if WITH_GTKMM_3_0 Gtk::Grid &_parent; -#else - Gtk::Table &_parent; -#endif }; diff --git a/src/ui/dialog/calligraphic-profile-rename.cpp b/src/ui/dialog/calligraphic-profile-rename.cpp index 9ae22db2d..50dae0fd8 100644 --- a/src/ui/dialog/calligraphic-profile-rename.cpp +++ b/src/ui/dialog/calligraphic-profile-rename.cpp @@ -16,12 +16,7 @@ #include "calligraphic-profile-rename.h" #include #include - -#if WITH_GTKMM_3_0 -# include -#else -# include -#endif +#include #include "desktop.h" @@ -30,40 +25,24 @@ namespace UI { namespace Dialog { CalligraphicProfileRename::CalligraphicProfileRename() : -#if WITH_GTKMM_3_0 _layout_table(Gtk::manage(new Gtk::Grid())), -#else - _layout_table(Gtk::manage(new Gtk::Table(1, 2))), -#endif _applied(false) { set_title(_("Edit profile")); -#if WITH_GTKMM_3_0 - Gtk::Box *mainVBox = get_content_area(); + auto mainVBox = get_content_area(); _layout_table->set_column_spacing(4); _layout_table->set_row_spacing(4); -#else - Gtk::Box *mainVBox = get_vbox(); - _layout_table->set_spacings(4); -#endif _profile_name_entry.set_activates_default(true); _profile_name_label.set_label(_("Profile name:")); _profile_name_label.set_alignment(1.0, 0.5); -#if WITH_GTKMM_3_0 _layout_table->attach(_profile_name_label, 0, 0, 1, 1); _profile_name_entry.set_hexpand(); _layout_table->attach(_profile_name_entry, 1, 0, 1, 1); -#else - _layout_table->attach(_profile_name_label, - 0, 1, 0, 1, Gtk::FILL, Gtk::FILL); - _layout_table->attach(_profile_name_entry, - 1, 2, 0, 1, Gtk::FILL | Gtk::EXPAND, Gtk::FILL); -#endif mainVBox->pack_start(*_layout_table, false, false, 4); // Buttons diff --git a/src/ui/dialog/calligraphic-profile-rename.h b/src/ui/dialog/calligraphic-profile-rename.h index 4ef71900b..b7a97a1e7 100644 --- a/src/ui/dialog/calligraphic-profile-rename.h +++ b/src/ui/dialog/calligraphic-profile-rename.h @@ -20,11 +20,7 @@ #include namespace Gtk { -#if WITH_GTKMM_3_0 class Grid; -#else -class Table; -#endif } class SPDesktop; @@ -59,12 +55,7 @@ protected: Gtk::Label _profile_name_label; Gtk::Entry _profile_name_entry; - -#if WITH_GTKMM_3_0 Gtk::Grid* _layout_table; -#else - Gtk::Table* _layout_table; -#endif Gtk::Button _close_button; Gtk::Button _delete_button; diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index b727c87ee..da00b7b00 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -91,12 +91,8 @@ CloneTiler::CloneTiler () : dlg = GTK_WIDGET(gobj()); -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); + auto mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); gtk_box_set_homogeneous(GTK_BOX(mainbox), FALSE); -#else - GtkWidget *mainbox = gtk_vbox_new(FALSE, 4); -#endif gtk_container_set_border_width (GTK_CONTAINER (mainbox), 6); contents->pack_start (*Gtk::manage(Glib::wrap(mainbox)), true, true, 0); @@ -651,12 +647,8 @@ CloneTiler::CloneTiler () : GtkWidget *vb = clonetiler_new_tab (nb, _("Co_lor")); { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new (FALSE, 0); -#endif GtkWidget *l = gtk_label_new (_("Initial color: ")); gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0); @@ -777,12 +769,8 @@ CloneTiler::CloneTiler () : { GtkWidget *vb = clonetiler_new_tab (nb, _("_Trace")); { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); -#endif gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0); b = gtk_check_button_new_with_label (_("Trace the drawing under the clones/sprayed items")); @@ -797,12 +785,8 @@ CloneTiler::CloneTiler () : } { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *vvb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + auto vvb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_box_set_homogeneous(GTK_BOX(vvb), FALSE); -#else - GtkWidget *vvb = gtk_vbox_new (FALSE, 0); -#endif gtk_box_pack_start (GTK_BOX (vb), vvb, FALSE, FALSE, 0); g_object_set_data (G_OBJECT(dlg), "dotrace", (gpointer) vvb); @@ -811,15 +795,9 @@ CloneTiler::CloneTiler () : GtkWidget *frame = gtk_frame_new (_("1. Pick from the drawing:")); gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, 0); -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *table = gtk_grid_new(); + auto table = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(table), 4); gtk_grid_set_column_spacing(GTK_GRID(table), 6); -#else - GtkWidget *table = gtk_table_new (3, 3, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (table), 4); - gtk_table_set_col_spacings (GTK_TABLE (table), 6); -#endif gtk_container_add(GTK_CONTAINER(frame), table); @@ -895,15 +873,9 @@ CloneTiler::CloneTiler () : GtkWidget *frame = gtk_frame_new (_("2. Tweak the picked value:")); gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, VB_MARGIN); -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *table = gtk_grid_new(); + auto table = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(table), 4); gtk_grid_set_column_spacing(GTK_GRID(table), 6); -#else - GtkWidget *table = gtk_table_new (4, 2, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (table), 4); - gtk_table_set_col_spacings (GTK_TABLE (table), 6); -#endif gtk_container_add(GTK_CONTAINER(frame), table); @@ -944,15 +916,9 @@ CloneTiler::CloneTiler () : GtkWidget *frame = gtk_frame_new (_("3. Apply the value to the clones':")); gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, 0); -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *table = gtk_grid_new(); + auto table = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(table), 4); gtk_grid_set_column_spacing(GTK_GRID(table), 6); -#else - GtkWidget *table = gtk_table_new (2, 2, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (table), 4); - gtk_table_set_col_spacings (GTK_TABLE (table), 6); -#endif gtk_container_add(GTK_CONTAINER(frame), table); { @@ -1000,12 +966,8 @@ CloneTiler::CloneTiler () : } { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); -#endif gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); GtkWidget *l = gtk_label_new(_("")); gtk_label_set_markup (GTK_LABEL(l), _("Apply to tiled clones:")); @@ -1013,42 +975,24 @@ CloneTiler::CloneTiler () : } // Rows/columns, width/height { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *table = gtk_grid_new(); + auto table = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(table), 4); gtk_grid_set_column_spacing(GTK_GRID(table), 6); -#else - GtkWidget *table = gtk_table_new (2, 2, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (table), 4); - gtk_table_set_col_spacings (GTK_TABLE (table), 6); -#endif gtk_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN); gtk_box_pack_start (GTK_BOX (mainbox), table, FALSE, FALSE, 0); { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); -#endif g_object_set_data (G_OBJECT(dlg), "rowscols", (gpointer) hb); { -#if WITH_GTKMM_3_0 - Glib::RefPtra = Gtk::Adjustment::create(0.0, 1, 500, 1, 10, 0); -#else - Gtk::Adjustment *a = new Gtk::Adjustment (0.0, 1, 500, 1, 10, 0); -#endif + auto a = Gtk::Adjustment::create(0.0, 1, 500, 1, 10, 0); int value = prefs->getInt(prefs_path + "jmax", 2); a->set_value (value); -#if WITH_GTKMM_3_0 - Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton(a, 1.0, 0); -#else - Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton (*a, 1.0, 0); -#endif + auto sb = new Inkscape::UI::Widget::SpinButton(a, 1.0, 0); sb->set_tooltip_text (_("How many rows in the tiling")); sb->set_width_chars (7); gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(sb->gobj()), TRUE, TRUE, 0); @@ -1061,28 +1005,16 @@ CloneTiler::CloneTiler () : { GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), "×"); -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(l, GTK_ALIGN_END); -#else - gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5); -#endif gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0); } { -#if WITH_GTKMM_3_0 - Glib::RefPtr a = Gtk::Adjustment::create(0.0, 1, 500, 1, 10, 0); -#else - Gtk::Adjustment *a = new Gtk::Adjustment (0.0, 1, 500, 1, 10, 0); -#endif + auto a = Gtk::Adjustment::create(0.0, 1, 500, 1, 10, 0); int value = prefs->getInt(prefs_path + "imax", 2); a->set_value (value); -#if WITH_GTKMM_3_0 - Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton(a, 1.0, 0); -#else - Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton (*a, 1.0, 0); -#endif + auto sb = new Inkscape::UI::Widget::SpinButton(a, 1.0, 0); sb->set_tooltip_text (_("How many columns in the tiling")); sb->set_width_chars (7); gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(sb->gobj()), TRUE, TRUE, 0); @@ -1096,12 +1028,8 @@ CloneTiler::CloneTiler () : } { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); -#endif g_object_set_data (G_OBJECT(dlg), "widthheight", (gpointer) hb); // unitmenu @@ -1112,59 +1040,39 @@ CloneTiler::CloneTiler () : { // Width spinbutton -#if WITH_GTKMM_3_0 fill_width = Gtk::Adjustment::create(0.0, -1e6, 1e6, 1.0, 10.0, 0); -#else - fill_width = new Gtk::Adjustment (0.0, -1e6, 1e6, 1.0, 10.0, 0); -#endif double value = prefs->getDouble(prefs_path + "fillwidth", 50.0); Inkscape::Util::Unit const *unit = unit_menu->getUnit(); gdouble const units = Inkscape::Util::Quantity::convert(value, "px", unit); fill_width->set_value (units); -#if WITH_GTKMM_3_0 - Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton(fill_width, 1.0, 2); -#else - Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton (*fill_width, 1.0, 2); -#endif + auto e = new Inkscape::UI::Widget::SpinButton(fill_width, 1.0, 2); e->set_tooltip_text (_("Width of the rectangle to be filled")); e->set_width_chars (7); e->set_digits (4); gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(e->gobj()), TRUE, TRUE, 0); // TODO: C++ification - g_signal_connect(G_OBJECT(fill_width->gobj()), "value_changed", + g_signal_connect(G_OBJECT(fill_width->gobj()), "value_changed", G_CALLBACK(clonetiler_fill_width_changed), unit_menu); } { GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), "×"); -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(l, GTK_ALIGN_END); -#else - gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5); -#endif gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0); } { // Height spinbutton -#if WITH_GTKMM_3_0 fill_height = Gtk::Adjustment::create(0.0, -1e6, 1e6, 1.0, 10.0, 0); -#else - fill_height = new Gtk::Adjustment (0.0, -1e6, 1e6, 1.0, 10.0, 0); -#endif double value = prefs->getDouble(prefs_path + "fillheight", 50.0); Inkscape::Util::Unit const *unit = unit_menu->getUnit(); gdouble const units = Inkscape::Util::Quantity::convert(value, "px", unit); fill_height->set_value (units); -#if WITH_GTKMM_3_0 - Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton(fill_height, 1.0, 2); -#else - Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton (*fill_height, 1.0, 2); -#endif + auto e = new Inkscape::UI::Widget::SpinButton(fill_height, 1.0, 2); e->set_tooltip_text (_("Height of the rectangle to be filled")); e->set_width_chars (7); e->set_digits (4); @@ -1206,12 +1114,8 @@ CloneTiler::CloneTiler () : // Use saved pos { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); -#endif gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); GtkWidget *b = gtk_check_button_new_with_label (_("Use saved size and position of the tile")); @@ -1226,12 +1130,8 @@ CloneTiler::CloneTiler () : // Statusbar { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); -#endif gtk_box_pack_end (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); GtkWidget *l = gtk_label_new(""); g_object_set_data (G_OBJECT(dlg), "status", (gpointer) l); @@ -1240,12 +1140,8 @@ CloneTiler::CloneTiler () : // Buttons { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); -#endif gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); { @@ -1259,12 +1155,8 @@ CloneTiler::CloneTiler () : } { // buttons which are enabled only when there are tiled clones -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *sb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + auto sb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(sb), FALSE); -#else - GtkWidget *sb = gtk_hbox_new(FALSE, 0); -#endif gtk_box_pack_end (GTK_BOX (hb), sb, FALSE, FALSE, 0); g_object_set_data (G_OBJECT(dlg), "buttons_on_tiles", (gpointer) sb); { @@ -2673,12 +2565,8 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) GtkWidget * CloneTiler::clonetiler_new_tab(GtkWidget *nb, const gchar *label) { GtkWidget *l = gtk_label_new_with_mnemonic (label); -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, VB_MARGIN); + auto vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(vb), FALSE); -#else - GtkWidget *vb = gtk_vbox_new (FALSE, VB_MARGIN); -#endif gtk_container_set_border_width (GTK_CONTAINER (vb), VB_MARGIN); gtk_notebook_append_page (GTK_NOTEBOOK (nb), vb, l); return vb; @@ -2693,12 +2581,8 @@ void CloneTiler::clonetiler_checkbox_toggled(GtkToggleButton *tb, gpointer *data GtkWidget * CloneTiler::clonetiler_checkbox(const char *tip, const char *attr) { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); -#endif GtkWidget *b = gtk_check_button_new (); gtk_widget_set_tooltip_text (b, tip); @@ -2725,44 +2609,23 @@ void CloneTiler::clonetiler_value_changed(GtkAdjustment *adj, gpointer data) GtkWidget * CloneTiler::clonetiler_spinbox(const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent/* = false*/) { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, 0); -#endif { -#if WITH_GTKMM_3_0 Glib::RefPtr a; if (exponent) { a = Gtk::Adjustment::create(1.0, lower, upper, 0.01, 0.05, 0); } else { a = Gtk::Adjustment::create(0.0, lower, upper, 0.1, 0.5, 0); } -#else - Gtk::Adjustment *a; - if (exponent) { - a = new Gtk::Adjustment (1.0, lower, upper, 0.01, 0.05, 0); - } else { - a = new Gtk::Adjustment (0.0, lower, upper, 0.1, 0.5, 0); - } -#endif Inkscape::UI::Widget::SpinButton *sb; -#if WITH_GTKMM_3_0 if (exponent) { sb = new Inkscape::UI::Widget::SpinButton(a, 0.01, 2); } else { sb = new Inkscape::UI::Widget::SpinButton(a, 0.1, 1); } -#else - if (exponent) { - sb = new Inkscape::UI::Widget::SpinButton (*a, 0.01, 2); - } else { - sb = new Inkscape::UI::Widget::SpinButton (*a, 0.1, 1); - } -#endif sb->set_tooltip_text (tip); sb->set_width_chars (5); @@ -2786,12 +2649,8 @@ GtkWidget * CloneTiler::clonetiler_spinbox(const char *tip, const char *attr, do { GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), suffix); -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(l, GTK_ALIGN_END); gtk_widget_set_valign(l, GTK_ALIGN_START); -#else - gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0); -#endif gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0); } @@ -2867,38 +2726,22 @@ void CloneTiler::clonetiler_reset(GtkWidget */*widget*/, GtkWidget *dlg) void CloneTiler::clonetiler_table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col) { -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(widget, GTK_ALIGN_FILL); gtk_widget_set_valign(widget, GTK_ALIGN_START); gtk_grid_attach(GTK_GRID(table), widget, col, row, 1, 1); -#else - GtkWidget *a = gtk_alignment_new (align, 0, 0, 0); - gtk_container_add(GTK_CONTAINER(a), widget); - gtk_table_attach ( GTK_TABLE (table), a, col, col + 1, row, row + 1, GTK_FILL, (GtkAttachOptions)0, 0, 0 ); -#endif } GtkWidget * CloneTiler::clonetiler_table_x_y_rand(int values) { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *table = gtk_grid_new(); + auto table = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(table), 6); gtk_grid_set_column_spacing(GTK_GRID(table), 8); -#else - GtkWidget *table = gtk_table_new (values + 2, 5, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (table), 6); - gtk_table_set_col_spacings (GTK_TABLE (table), 8); -#endif gtk_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN); { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new (FALSE, 0); -#endif GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON("object-rows")); gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2); @@ -2911,12 +2754,8 @@ GtkWidget * CloneTiler::clonetiler_table_x_y_rand(int values) } { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new (FALSE, 0); -#endif GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON("object-columns")); gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2); diff --git a/src/ui/dialog/clonetiler.h b/src/ui/dialog/clonetiler.h index a8f1df0a0..e76ad028e 100644 --- a/src/ui/dialog/clonetiler.h +++ b/src/ui/dialog/clonetiler.h @@ -121,13 +121,8 @@ private: GtkSizeGroup* table_row_labels; Inkscape::UI::Widget::UnitMenu *unit_menu; -#if WITH_GTKMM_3_0 Glib::RefPtr fill_width; Glib::RefPtr fill_height; -#else - Gtk::Adjustment *fill_width; - Gtk::Adjustment *fill_height; -#endif sigc::connection desktopChangeConn; sigc::connection selectChangedConn; diff --git a/src/ui/dialog/debug.cpp b/src/ui/dialog/debug.cpp index d127261c0..48d7abbdd 100644 --- a/src/ui/dialog/debug.cpp +++ b/src/ui/dialog/debug.cpp @@ -68,12 +68,7 @@ DebugDialogImpl::DebugDialogImpl() { set_title(_("Messages")); set_size_request(300, 400); - -#if WITH_GTKMM_3_0 - Gtk::Box *mainVBox = get_content_area(); -#else - Gtk::Box *mainVBox = get_vbox(); -#endif + auto mainVBox = get_content_area(); //## Add a menu for clear() Gtk::MenuItem* item = Gtk::manage(new Gtk::MenuItem(_("_File"), true)); diff --git a/src/ui/dialog/document-metadata.cpp b/src/ui/dialog/document-metadata.cpp index da1facc08..602c3d6be 100644 --- a/src/ui/dialog/document-metadata.cpp +++ b/src/ui/dialog/document-metadata.cpp @@ -61,12 +61,7 @@ DocumentMetadata::getInstance() DocumentMetadata::DocumentMetadata() -#if WITH_GTKMM_3_0 : UI::Widget::Panel ("", "/dialogs/documentmetadata", SP_VERB_DIALOG_METADATA) -#else - : UI::Widget::Panel ("", "/dialogs/documentmetadata", SP_VERB_DIALOG_METADATA), - _page_metadata1(1, 1), _page_metadata2(1, 1) -#endif { hide(); _getContents()->set_spacing (4); @@ -75,15 +70,10 @@ DocumentMetadata::DocumentMetadata() _page_metadata1.set_border_width(2); _page_metadata2.set_border_width(2); -#if WITH_GTKMM_3_0 _page_metadata1.set_column_spacing(2); _page_metadata2.set_column_spacing(2); _page_metadata1.set_row_spacing(2); _page_metadata2.set_row_spacing(2); -#else - _page_metadata1.set_spacings(2); - _page_metadata2.set_spacings(2); -#endif _notebook.append_page(_page_metadata1, _("Metadata")); _notebook.append_page(_page_metadata2, _("License")); @@ -126,12 +116,8 @@ DocumentMetadata::build_metadata() label->set_markup (_("Dublin Core Entities")); label->set_alignment (0.0); -#if WITH_GTKMM_3_0 label->set_valign(Gtk::ALIGN_CENTER); _page_metadata1.attach(*label, 0, 0, 3, 1); -#else - _page_metadata1.attach(*label, 0,3,0,1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); -#endif /* add generic metadata entry areas */ struct rdf_work_entity_t * entity; @@ -143,7 +129,6 @@ DocumentMetadata::build_metadata() Gtk::HBox *space = Gtk::manage (new Gtk::HBox); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); -#if WITH_GTKMM_3_0 space->set_valign(Gtk::ALIGN_CENTER); _page_metadata1.attach(*space, 0, row, 1, 1); @@ -153,11 +138,6 @@ DocumentMetadata::build_metadata() w->_packable->set_hexpand(); w->_packable->set_valign(Gtk::ALIGN_CENTER); _page_metadata1.attach(*w->_packable, 2, row, 1, 1); -#else - _page_metadata1.attach(*space, 0,1, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); - _page_metadata1.attach(w->_label, 1,2, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); - _page_metadata1.attach(*w->_packable, 2,3, row, row+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); -#endif } } @@ -167,31 +147,20 @@ DocumentMetadata::build_metadata() Gtk::Label *llabel = Gtk::manage (new Gtk::Label); llabel->set_markup (_("License")); llabel->set_alignment (0.0); - -#if WITH_GTKMM_3_0 llabel->set_valign(Gtk::ALIGN_CENTER); _page_metadata2.attach(*llabel, 0, row, 3, 1); -#else - _page_metadata2.attach(*llabel, 0,3, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); -#endif /* add license selector pull-down and URI */ ++row; _licensor.init (_wr); Gtk::HBox *space = Gtk::manage (new Gtk::HBox); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); - -#if WITH_GTKMM_3_0 space->set_valign(Gtk::ALIGN_CENTER); _page_metadata2.attach(*space, 0, row, 1, 1); _licensor.set_hexpand(); _licensor.set_valign(Gtk::ALIGN_CENTER); _page_metadata2.attach(_licensor, 1, row, 2, 1); -#else - _page_metadata2.attach(*space, 0,1, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); - _page_metadata2.attach(_licensor, 1,3, row, row+1, Gtk::EXPAND|Gtk::FILL, (Gtk::AttachOptions)0,0,0); -#endif } /** diff --git a/src/ui/dialog/document-metadata.h b/src/ui/dialog/document-metadata.h index cde5d92fd..2c56e9317 100644 --- a/src/ui/dialog/document-metadata.h +++ b/src/ui/dialog/document-metadata.h @@ -21,12 +21,7 @@ #include #include "ui/widget/panel.h" #include - -#if WITH_GTKMM_3_0 -# include -#else -# include -#endif +#include #include "inkscape.h" #include "ui/widget/licensor.h" @@ -62,13 +57,8 @@ protected: Gtk::Notebook _notebook; -#if WITH_GTKMM_3_0 Gtk::Grid _page_metadata1; Gtk::Grid _page_metadata2; -#else - Gtk::Table _page_metadata1; - Gtk::Table _page_metadata2; -#endif //--------------------------------------------------------------- RDElist _rdflist; diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 589973162..33f134c11 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -223,25 +223,16 @@ DocumentProperties::~DocumentProperties() * widget in columns 2-3; (non-0, 0) means label in columns 1-3; and * (non-0, non-0) means two widgets in columns 2 and 3. */ -#if WITH_GTKMM_3_0 inline void attach_all(Gtk::Grid &table, Gtk::Widget *const arr[], unsigned const n, int start = 0, int docum_prop_flag = 0) -#else -inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned const n, int start = 0, int docum_prop_flag = 0) -#endif { for (unsigned i = 0, r = start; i < n; i += 2) { if (arr[i] && arr[i+1]) { -#if WITH_GTKMM_3_0 arr[i]->set_hexpand(); arr[i+1]->set_hexpand(); arr[i]->set_valign(Gtk::ALIGN_CENTER); arr[i+1]->set_valign(Gtk::ALIGN_CENTER); table.attach(*arr[i], 1, r, 1, 1); table.attach(*arr[i+1], 2, r, 1, 1); -#else - table.attach(*arr[i], 1, 2, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); - table.attach(*arr[i+1], 2, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); -#endif } else { if (arr[i+1]) { Gtk::AttachOptions yoptions = (Gtk::AttachOptions)0; @@ -252,7 +243,6 @@ inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned con if (docum_prop_flag) { // this sets the padding for subordinate widgets on the "Page" page if( i==(n-8) || i==(n-10) ) { -#if WITH_GTKMM_3_0 arr[i+1]->set_hexpand(); arr[i+1]->set_margin_left(20); arr[i+1]->set_margin_right(20); @@ -263,11 +253,7 @@ inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned con arr[i+1]->set_valign(Gtk::ALIGN_CENTER); table.attach(*arr[i+1], 1, r, 2, 1); -#else - table.attach(*arr[i+1], 1, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, yoptions, 20,0); -#endif } else { -#if WITH_GTKMM_3_0 arr[i+1]->set_hexpand(); if (yoptions & Gtk::EXPAND) @@ -276,12 +262,8 @@ inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned con arr[i+1]->set_valign(Gtk::ALIGN_CENTER); table.attach(*arr[i+1], 1, r, 2, 1); -#else - table.attach(*arr[i+1], 1, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, yoptions, 0,0); -#endif } } else { -#if WITH_GTKMM_3_0 arr[i+1]->set_hexpand(); if (yoptions & Gtk::EXPAND) @@ -290,32 +272,21 @@ inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned con arr[i+1]->set_valign(Gtk::ALIGN_CENTER); table.attach(*arr[i+1], 1, r, 2, 1); -#else - table.attach(*arr[i+1], 1, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, yoptions, 0,0); -#endif } } else if (arr[i]) { Gtk::Label& label = reinterpret_cast(*arr[i]); label.set_alignment (0.0); -#if WITH_GTKMM_3_0 label.set_hexpand(); label.set_valign(Gtk::ALIGN_CENTER); table.attach(label, 0, r, 3, 1); -#else - table.attach (label, 0, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); -#endif } else { Gtk::HBox *space = Gtk::manage (new Gtk::HBox); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); -#if WITH_GTKMM_3_0 space->set_halign(Gtk::ALIGN_CENTER); space->set_valign(Gtk::ALIGN_CENTER); table.attach(*space, 0, r, 1, 1); -#else - table.attach (*space, 0, 1, r, r+1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0); -#endif } } ++r; @@ -685,52 +656,35 @@ void DocumentProperties::build_cms() label_link->set_alignment(0.0); -#if WITH_GTKMM_3_0 label_link->set_hexpand(); label_link->set_valign(Gtk::ALIGN_CENTER); _page_cms->table().attach(*label_link, 0, row, 3, 1); -#else - _page_cms->table().attach(*label_link, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif row++; -#if WITH_GTKMM_3_0 _LinkedProfilesListScroller.set_hexpand(); _LinkedProfilesListScroller.set_valign(Gtk::ALIGN_CENTER); _page_cms->table().attach(_LinkedProfilesListScroller, 0, row, 3, 1); -#else - _page_cms->table().attach(_LinkedProfilesListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif row++; Gtk::HBox* spacer = Gtk::manage(new Gtk::HBox()); spacer->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y); -#if WITH_GTKMM_3_0 spacer->set_hexpand(); spacer->set_valign(Gtk::ALIGN_CENTER); _page_cms->table().attach(*spacer, 0, row, 3, 1); -#else - _page_cms->table().attach(*spacer, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif row++; label_avail->set_alignment(0.0); -#if WITH_GTKMM_3_0 label_avail->set_hexpand(); label_avail->set_valign(Gtk::ALIGN_CENTER); _page_cms->table().attach(*label_avail, 0, row, 3, 1); -#else - _page_cms->table().attach(*label_avail, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif row++; -#if WITH_GTKMM_3_0 _AvailableProfilesList.set_hexpand(); _AvailableProfilesList.set_valign(Gtk::ALIGN_CENTER); _page_cms->table().attach(_AvailableProfilesList, 0, row, 1, 1); @@ -744,11 +698,6 @@ void DocumentProperties::build_cms() _unlink_btn.set_halign(Gtk::ALIGN_CENTER); _unlink_btn.set_valign(Gtk::ALIGN_CENTER); _page_cms->table().attach(_unlink_btn, 2, row, 1, 1); -#else - _page_cms->table().attach(_AvailableProfilesList, 0, 1, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); - _page_cms->table().attach(_link_btn, 1, 2, row, row + 1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0, 2, 0); - _page_cms->table().attach(_unlink_btn, 2, 3, row, row + 1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0, 0, 0); -#endif // Set up the Avialable Profiles combo box _AvailableProfilesListStore = Gtk::ListStore::create(_AvailableProfilesListColumns); @@ -815,41 +764,27 @@ void DocumentProperties::build_scripting() gint row = 0; label_external->set_alignment(0.0); - -#if WITH_GTKMM_3_0 label_external->set_hexpand(); label_external->set_valign(Gtk::ALIGN_CENTER); _page_external_scripts->table().attach(*label_external, 0, row, 3, 1); -#else - _page_external_scripts->table().attach(*label_external, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif row++; -#if WITH_GTKMM_3_0 _ExternalScriptsListScroller.set_hexpand(); _ExternalScriptsListScroller.set_valign(Gtk::ALIGN_CENTER); _page_external_scripts->table().attach(_ExternalScriptsListScroller, 0, row, 3, 1); -#else - _page_external_scripts->table().attach(_ExternalScriptsListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif row++; Gtk::HBox* spacer_external = Gtk::manage(new Gtk::HBox()); spacer_external->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y); -#if WITH_GTKMM_3_0 spacer_external->set_hexpand(); spacer_external->set_valign(Gtk::ALIGN_CENTER); _page_external_scripts->table().attach(*spacer_external, 0, row, 3, 1); -#else - _page_external_scripts->table().attach(*spacer_external, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif row++; -#if WITH_GTKMM_3_0 _script_entry.set_hexpand(); _script_entry.set_valign(Gtk::ALIGN_CENTER); _page_external_scripts->table().attach(_script_entry, 0, row, 1, 1); @@ -863,11 +798,6 @@ void DocumentProperties::build_scripting() _external_remove_btn.set_halign(Gtk::ALIGN_CENTER); _external_remove_btn.set_valign(Gtk::ALIGN_CENTER); _page_external_scripts->table().attach(_external_remove_btn, 2, row, 1, 1); -#else - _page_external_scripts->table().attach(_script_entry, 0, 1, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); - _page_external_scripts->table().attach(_external_add_btn, 1, 2, row, row + 1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0, 2, 0); - _page_external_scripts->table().attach(_external_remove_btn, 2, 3, row, row + 1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0, 0, 0); -#endif //# Set up the External Scripts box _ExternalScriptsListStore = Gtk::ListStore::create(_ExternalScriptsListColumns); @@ -888,12 +818,6 @@ void DocumentProperties::build_scripting() _embed_remove_btn.set_tooltip_text(_("Remove")); docprops_style_button(_embed_remove_btn, INKSCAPE_ICON("list-remove")); -#if !WITH_GTKMM_3_0 - // TODO: This has been removed from Gtkmm 3.0. Check that - // everything still looks OK! - _embed_button_box.set_child_min_width( 16 ); - _embed_button_box.set_spacing( 4 ); -#endif _embed_button_box.set_layout (Gtk::BUTTONBOX_START); _embed_button_box.add(_embed_new_btn); _embed_button_box.add(_embed_remove_btn); @@ -902,47 +826,29 @@ void DocumentProperties::build_scripting() row = 0; label_embedded->set_alignment(0.0); - -#if WITH_GTKMM_3_0 label_embedded->set_hexpand(); label_embedded->set_valign(Gtk::ALIGN_CENTER); _page_embedded_scripts->table().attach(*label_embedded, 0, row, 3, 1); -#else - _page_embedded_scripts->table().attach(*label_embedded, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif row++; -#if WITH_GTKMM_3_0 _EmbeddedScriptsListScroller.set_hexpand(); _EmbeddedScriptsListScroller.set_valign(Gtk::ALIGN_CENTER); _page_embedded_scripts->table().attach(_EmbeddedScriptsListScroller, 0, row, 3, 1); -#else - _page_embedded_scripts->table().attach(_EmbeddedScriptsListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif row++; -#if WITH_GTKMM_3_0 _embed_button_box.set_hexpand(); _embed_button_box.set_valign(Gtk::ALIGN_CENTER); _page_embedded_scripts->table().attach(_embed_button_box, 0, row, 1, 1); -#else - _page_embedded_scripts->table().attach(_embed_button_box, 0, 1, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif row++; Gtk::HBox* spacer_embedded = Gtk::manage(new Gtk::HBox()); spacer_embedded->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y); - -#if WITH_GTKMM_3_0 spacer_embedded->set_hexpand(); spacer_embedded->set_valign(Gtk::ALIGN_CENTER); _page_embedded_scripts->table().attach(*spacer_embedded, 0, row, 3, 1); -#else - _page_embedded_scripts->table().attach(*spacer_embedded, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif row++; @@ -958,24 +864,15 @@ void DocumentProperties::build_scripting() label_embedded_content->set_markup (_("Content:")); label_embedded_content->set_alignment(0.0); - -#if WITH_GTKMM_3_0 label_embedded_content->set_hexpand(); label_embedded_content->set_valign(Gtk::ALIGN_CENTER); _page_embedded_scripts->table().attach(*label_embedded_content, 0, row, 3, 1); -#else - _page_embedded_scripts->table().attach(*label_embedded_content, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif row++; -#if WITH_GTKMM_3_0 _EmbeddedContentScroller.set_hexpand(); _EmbeddedContentScroller.set_valign(Gtk::ALIGN_CENTER); _page_embedded_scripts->table().attach(_EmbeddedContentScroller, 0, row, 3, 1); -#else - _page_embedded_scripts->table().attach(_EmbeddedContentScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif _EmbeddedContentScroller.add(_EmbeddedContent); _EmbeddedContentScroller.set_shadow_type(Gtk::SHADOW_IN); @@ -1037,12 +934,8 @@ void DocumentProperties::build_metadata() label->set_markup (_("Dublin Core Entities")); label->set_alignment (0.0); -#if WITH_GTKMM_3_0 label->set_valign(Gtk::ALIGN_CENTER); _page_metadata1->table().attach (*label, 0,0,3,1); -#else - _page_metadata1->table().attach (*label, 0,3,0,1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); -#endif /* add generic metadata entry areas */ struct rdf_work_entity_t * entity; @@ -1053,8 +946,6 @@ void DocumentProperties::build_metadata() _rdflist.push_back (w); Gtk::HBox *space = Gtk::manage (new Gtk::HBox); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); - -#if WITH_GTKMM_3_0 space->set_valign(Gtk::ALIGN_CENTER); _page_metadata1->table().attach(*space, 0, row, 1, 1); @@ -1064,11 +955,6 @@ void DocumentProperties::build_metadata() w->_packable->set_hexpand(); w->_packable->set_valign(Gtk::ALIGN_CENTER); _page_metadata1->table().attach(*w->_packable, 2, row, 1, 1); -#else - _page_metadata1->table().attach (*space, 0,1, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); - _page_metadata1->table().attach (w->_label, 1,2, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); - _page_metadata1->table().attach (*w->_packable, 2,3, row, row+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); -#endif } } @@ -1077,11 +963,7 @@ void DocumentProperties::build_metadata() Gtk::Button *button_load = Gtk::manage (new Gtk::Button(_("Use _default"),1)); button_load->set_tooltip_text(_("Use the previously saved default metadata here")); -#if WITH_GTKMM_3_0 - Gtk::ButtonBox *box_buttons = Gtk::manage (new Gtk::ButtonBox); -#else - Gtk::HButtonBox *box_buttons = Gtk::manage (new Gtk::HButtonBox); -#endif + auto box_buttons = Gtk::manage (new Gtk::ButtonBox); box_buttons->set_layout(Gtk::BUTTONBOX_END); box_buttons->set_spacing(4); @@ -1099,12 +981,8 @@ void DocumentProperties::build_metadata() llabel->set_markup (_("License")); llabel->set_alignment (0.0); -#if WITH_GTKMM_3_0 llabel->set_valign(Gtk::ALIGN_CENTER); _page_metadata2->table().attach(*llabel, 0, row, 3, 1); -#else - _page_metadata2->table().attach (*llabel, 0,3, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); -#endif /* add license selector pull-down and URI */ ++row; @@ -1112,17 +990,12 @@ void DocumentProperties::build_metadata() Gtk::HBox *space = Gtk::manage (new Gtk::HBox); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); -#if WITH_GTKMM_3_0 space->set_valign(Gtk::ALIGN_CENTER); _page_metadata2->table().attach(*space, 0, row, 1, 1); _licensor.set_hexpand(); _licensor.set_valign(Gtk::ALIGN_CENTER); _page_metadata2->table().attach(_licensor, 1, row, 3, 1); -#else - _page_metadata2->table().attach (*space, 0,1, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); - _page_metadata2->table().attach (_licensor, 1,3, row, row+1, Gtk::EXPAND|Gtk::FILL, (Gtk::AttachOptions)0,0,0); -#endif } void DocumentProperties::addExternalScript(){ diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h index 7f91d9ea0..8d1c6b38a 100644 --- a/src/ui/dialog/document-properties.h +++ b/src/ui/dialog/document-properties.h @@ -173,11 +173,7 @@ protected: Gtk::Button _external_remove_btn; Gtk::Button _embed_new_btn; Gtk::Button _embed_remove_btn; -#if WITH_GTKMM_3_0 - Gtk::ButtonBox _embed_button_box; -#else - Gtk::HButtonBox _embed_button_box; -#endif + Gtk::ButtonBox _embed_button_box; class ExternalScriptsColumns : public Gtk::TreeModel::ColumnRecord { diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 2fb5f9e3b..5e7c68985 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -29,11 +29,7 @@ #include #include #include -#if WITH_GTKMM_3_0 -# include -#else -# include -#endif +#include #include #include @@ -218,15 +214,9 @@ Export::Export (void) : selectiontype_buttons[i]->signal_clicked().connect(sigc::mem_fun(*this, &Export::onAreaToggled)); } -#if WITH_GTKMM_3_0 - Gtk::Grid* t = new Gtk::Grid(); + auto t = new Gtk::Grid(); t->set_row_spacing(4); t->set_column_spacing(4); -#else - Gtk::Table* t = new Gtk::Table(3, 4, false); - t->set_row_spacings (4); - t->set_col_spacings (4); -#endif x0_adj = createSpinbutton ( "x0", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, t, 0, 0, _("_x0:"), "", EXPORT_COORD_PRECISION, 1, @@ -268,15 +258,9 @@ Export::Export (void) : bm_label->set_use_markup(true); size_box.pack_start(*bm_label, false, false, 0); -#if WITH_GTKMM_3_0 - Gtk::Grid *t = new Gtk::Grid(); + auto t = new Gtk::Grid(); t->set_row_spacing(4); t->set_column_spacing(4); -#else - Gtk::Table *t = new Gtk::Table(2, 5, false); - t->set_row_spacings (4); - t->set_col_spacings (4); -#endif size_box.pack_start(*t); @@ -484,27 +468,14 @@ void Export::set_default_filename () { } } -#if WITH_GTKMM_3_0 Glib::RefPtr Export::createSpinbutton( gchar const * /*key*/, float val, float min, float max, float step, float page, Gtk::Grid *t, int x, int y, const Glib::ustring& ll, const Glib::ustring& lr, int digits, unsigned int sensitive, void (Export::*cb)() ) -#else -Gtk::Adjustment * Export::createSpinbutton( gchar const * /*key*/, float val, float min, float max, - float step, float page, - Gtk::Table *t, int x, int y, - const Glib::ustring& ll, const Glib::ustring& lr, - int digits, unsigned int sensitive, - void (Export::*cb)() ) -#endif { -#if WITH_GTKMM_3_0 - Glib::RefPtr adj = Gtk::Adjustment::create(val, min, max, step, page, 0); -#else - Gtk::Adjustment *adj = new Gtk::Adjustment ( val, min, max, step, page, 0 ); -#endif + auto adj = Gtk::Adjustment::create(val, min, max, step, page, 0); int pos = 0; Gtk::Label *l = NULL; @@ -512,28 +483,17 @@ Gtk::Adjustment * Export::createSpinbutton( gchar const * /*key*/, float val, fl if (!ll.empty()) { l = new Gtk::Label(ll,true); l->set_alignment (1.0, 0.5); - -#if WITH_GTKMM_3_0 l->set_hexpand(); l->set_vexpand(); t->attach(*l, x + pos, y, 1, 1); -#else - t->attach (*l, x + pos, x + pos + 1, y, y + 1, Gtk::EXPAND, Gtk::EXPAND, 0, 0 ); -#endif - l->set_sensitive(sensitive); pos++; } -#if WITH_GTKMM_3_0 - Gtk::SpinButton *sb = new Gtk::SpinButton(adj, 1.0, digits); + auto sb = new Gtk::SpinButton(adj, 1.0, digits); sb->set_hexpand(); sb->set_vexpand(); t->attach(*sb, x + pos, y, 1, 1); -#else - Gtk::SpinButton *sb = new Gtk::SpinButton(*adj, 1.0, digits); - t->attach (*sb, x + pos, x + pos + 1, y, y + 1, Gtk::EXPAND, Gtk::EXPAND, 0, 0 ); -#endif sb->set_width_chars(7); sb->set_sensitive (sensitive); @@ -546,15 +506,9 @@ Gtk::Adjustment * Export::createSpinbutton( gchar const * /*key*/, float val, fl if (!lr.empty()) { l = new Gtk::Label(lr,true); l->set_alignment (0.0, 0.5); - -#if WITH_GTKMM_3_0 l->set_hexpand(); l->set_vexpand(); t->attach(*l, x + pos, y, 1, 1); -#else - t->attach (*l, x + pos, x + pos + 1, y, y + 1, Gtk::EXPAND, Gtk::EXPAND, 0, 0 ); -#endif - l->set_sensitive (sensitive); pos++; l->set_mnemonic_widget (*sb); @@ -932,11 +886,7 @@ Gtk::Dialog * Export::create_progress_dialog (Glib::ustring progress_text) { Gtk::ProgressBar *prg = new Gtk::ProgressBar (); prg->set_text(progress_text); dlg->set_data ("progress", prg); -#if GTK_CHECK_VERSION(3,0,0) - Gtk::Box* CA = dlg->get_content_area(); -#else - Gtk::Box* CA = dlg->get_vbox(); -#endif + auto CA = dlg->get_content_area(); CA->pack_start(*prg, FALSE, FALSE, 4); Gtk::Button* btn = dlg->add_button (Gtk::Stock::CANCEL,Gtk::RESPONSE_CANCEL ); @@ -1357,11 +1307,7 @@ void Export::onBrowse () Glib::RefPtr parentWindow = desktop->getToplevel()->get_window(); g_assert(parentWindow->gobj() != NULL); -#if WITH_GTKMM_3_0 opf.hwndOwner = (HWND)gdk_win32_window_get_handle((GdkWindow*)parentWindow->gobj()); -#else - opf.hwndOwner = (HWND)gdk_win32_drawable_get_handle((GdkDrawable*)parentWindow->gobj()); -#endif opf.lpstrFilter = filter_string; opf.lpstrCustomFilter = 0; opf.nMaxCustFilter = 0L; @@ -1521,11 +1467,7 @@ void Export::detectSize() { } /* sp_export_detect_size */ /// Called when area x0 value is changed -#if WITH_GTKMM_3_0 void Export::areaXChange(Glib::RefPtr& adj) -#else -void Export::areaXChange (Gtk::Adjustment *adj) -#endif { float x0, x1, xdpi, width; @@ -1564,11 +1506,7 @@ void Export::areaXChange (Gtk::Adjustment *adj) } // end of sp_export_area_x_value_changed() /// Called when area y0 value is changed. -#if WITH_GTKMM_3_0 void Export::areaYChange(Glib::RefPtr& adj) -#else -void Export::areaYChange (Gtk::Adjustment *adj) -#endif { float y0, y1, ydpi, height; @@ -1875,11 +1813,7 @@ void Export::setArea( double x0, double y0, double x1, double y1 ) * @param adj The adjustment widget * @param val What value to set it to. */ -#if WITH_GTKMM_3_0 void Export::setValue(Glib::RefPtr& adj, double val ) -#else -void Export::setValue( Gtk::Adjustment *adj, double val ) -#endif { if (adj) { adj->set_value(val); @@ -1897,11 +1831,7 @@ void Export::setValue( Gtk::Adjustment *adj, double val ) * @param adj The adjustment widget * @param val What the value should be in points. */ -#if WITH_GTKMM_3_0 void Export::setValuePx(Glib::RefPtr& adj, double val) -#else -void Export::setValuePx( Gtk::Adjustment *adj, double val) -#endif { Unit const *unit = unit_selector.getUnit(); @@ -1920,11 +1850,7 @@ void Export::setValuePx( Gtk::Adjustment *adj, double val) * * @return The value in the specified adjustment. */ -#if WITH_GTKMM_3_0 float Export::getValue(Glib::RefPtr& adj) -#else -float Export::getValue( Gtk::Adjustment *adj ) -#endif { if (!adj) { g_message("sp_export_value_get : adj is NULL"); @@ -1946,11 +1872,7 @@ float Export::getValue( Gtk::Adjustment *adj ) * * @return The value in the adjustment in points. */ -#if WITH_GTKMM_3_0 float Export::getValuePx(Glib::RefPtr& adj) -#else -float Export::getValuePx( Gtk::Adjustment *adj ) -#endif { float value = getValue( adj); Unit const *unit = unit_selector.getUnit(); diff --git a/src/ui/dialog/export.h b/src/ui/dialog/export.h index 23af0109b..a1c44714b 100644 --- a/src/ui/dialog/export.h +++ b/src/ui/dialog/export.h @@ -79,17 +79,10 @@ private: /* * Getter/setter style functions for the spinbuttons */ -#if WITH_GTKMM_3_0 void setValue(Glib::RefPtr& adj, double val); void setValuePx(Glib::RefPtr& adj, double val); float getValue(Glib::RefPtr& adj); float getValuePx(Glib::RefPtr& adj); -#else - void setValue (Gtk::Adjustment *adj, double val); - void setValuePx (Gtk::Adjustment *adj, double val); - float getValue (Gtk::Adjustment *adj); - float getValuePx (Gtk::Adjustment *adj); -#endif /** * Helper function to create, style and pack spinbuttons for the export dialog. @@ -112,21 +105,12 @@ private: * * No unit_selector is stored in the created spinbutton, relies on external unit management */ -#if WITH_GTKMM_3_0 Glib::RefPtr createSpinbutton( gchar const *key, float val, float min, float max, float step, float page, Gtk::Grid *t, int x, int y, const Glib::ustring& ll, const Glib::ustring& lr, int digits, unsigned int sensitive, void (Export::*cb)() ); -#else - Gtk::Adjustment * createSpinbutton( gchar const *key, float val, float min, float max, - float step, float page, - Gtk::Table *t, int x, int y, - const Glib::ustring& ll, const Glib::ustring& lr, - int digits, unsigned int sensitive, - void (Export::*cb)() ); -#endif /** * One of the area select radio buttons was pressed @@ -152,11 +136,7 @@ private: void onAreaX1Change() { areaXChange(x1_adj); } ; -#if WITH_GTKMM_3_0 void areaXChange(Glib::RefPtr& adj); -#else - void areaXChange ( Gtk::Adjustment *adj); -#endif /** * Area Y value changed callback @@ -167,11 +147,7 @@ private: void onAreaY1Change() { areaYChange(y1_adj); } ; -#if WITH_GTKMM_3_0 void areaYChange(Glib::RefPtr& adj); -#else - void areaYChange ( Gtk::Adjustment *adj); -#endif /** * Unit changed callback @@ -298,7 +274,6 @@ private: Gtk::VBox area_box; Gtk::VBox singleexport_box; -#if WITH_GTKMM_3_0 /* Custom size widgets */ Glib::RefPtr x0_adj; Glib::RefPtr x1_adj; @@ -312,21 +287,6 @@ private: Glib::RefPtr bmheight_adj; Glib::RefPtr xdpi_adj; Glib::RefPtr ydpi_adj; -#else - /* Custom size widgets */ - Gtk::Adjustment *x0_adj; - Gtk::Adjustment *x1_adj; - Gtk::Adjustment *y0_adj; - Gtk::Adjustment *y1_adj; - Gtk::Adjustment *width_adj; - Gtk::Adjustment *height_adj; - - /* Bitmap size widgets */ - Gtk::Adjustment *bmwidth_adj; - Gtk::Adjustment *bmheight_adj; - Gtk::Adjustment *xdpi_adj; - Gtk::Adjustment *ydpi_adj; -#endif Gtk::VBox size_box; Gtk::Label* bm_label; diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index 042637d22..e8c1bf723 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -754,16 +754,9 @@ FileOpenDialogImplGtk::~FileOpenDialogImplGtk() void FileOpenDialogImplGtk::addFilterMenu(Glib::ustring name, Glib::ustring pattern) { - -#if WITH_GTKMM_3_0 - Glib::RefPtr allFilter = Gtk::FileFilter::create(); + auto allFilter = Gtk::FileFilter::create(); allFilter->set_name(_(name.c_str())); allFilter->add_pattern(pattern); -#else - Gtk::FileFilter allFilter; - allFilter.set_name(_(name.c_str())); - allFilter.add_pattern(pattern); -#endif extensionMap[Glib::ustring(_("All Files"))] = NULL; add_filter(allFilter); } @@ -775,51 +768,27 @@ void FileOpenDialogImplGtk::createFilterMenu() } if (_dialogType == EXE_TYPES) { -#if WITH_GTKMM_3_0 - Glib::RefPtr allFilter = Gtk::FileFilter::create(); + auto allFilter = Gtk::FileFilter::create(); allFilter->set_name(_("All Files")); allFilter->add_pattern("*"); -#else - Gtk::FileFilter allFilter; - allFilter.set_name(_("All Files")); - allFilter.add_pattern("*"); -#endif extensionMap[Glib::ustring(_("All Files"))] = NULL; add_filter(allFilter); } else { -#if WITH_GTKMM_3_0 - Glib::RefPtr allInkscapeFilter = Gtk::FileFilter::create(); + auto allInkscapeFilter = Gtk::FileFilter::create(); allInkscapeFilter->set_name(_("All Inkscape Files")); - Glib::RefPtr allFilter = Gtk::FileFilter::create(); + auto allFilter = Gtk::FileFilter::create(); allFilter->set_name(_("All Files")); allFilter->add_pattern("*"); - Glib::RefPtr allImageFilter = Gtk::FileFilter::create(); + auto allImageFilter = Gtk::FileFilter::create(); allImageFilter->set_name(_("All Images")); - Glib::RefPtr allVectorFilter = Gtk::FileFilter::create(); + auto allVectorFilter = Gtk::FileFilter::create(); allVectorFilter->set_name(_("All Vectors")); - Glib::RefPtr allBitmapFilter = Gtk::FileFilter::create(); + auto allBitmapFilter = Gtk::FileFilter::create(); allBitmapFilter->set_name(_("All Bitmaps")); -#else - Gtk::FileFilter allInkscapeFilter; - allInkscapeFilter.set_name(_("All Inkscape Files")); - - Gtk::FileFilter allFilter; - allFilter.set_name(_("All Files")); - allFilter.add_pattern("*"); - - Gtk::FileFilter allImageFilter; - allImageFilter.set_name(_("All Images")); - - Gtk::FileFilter allVectorFilter; - allVectorFilter.set_name(_("All Vectors")); - - Gtk::FileFilter allBitmapFilter; - allBitmapFilter.set_name(_("All Bitmaps")); -#endif extensionMap[Glib::ustring(_("All Inkscape Files"))] = NULL; add_filter(allInkscapeFilter); @@ -854,29 +823,16 @@ void FileOpenDialogImplGtk::createFilterMenu() Glib::ustring uname(_(imod->get_filetypename())); -#if WITH_GTKMM_3_0 - Glib::RefPtr filter = Gtk::FileFilter::create(); + auto filter = Gtk::FileFilter::create(); filter->set_name(uname); filter->add_pattern(upattern); -#else - Gtk::FileFilter filter; - filter.set_name(uname); - filter.add_pattern(upattern); -#endif - add_filter(filter); extensionMap[uname] = imod; // g_message("ext %s:%s '%s'\n", ioext->name, ioext->mimetype, upattern.c_str()); -#if WITH_GTKMM_3_0 allInkscapeFilter->add_pattern(upattern); if (strncmp("image", imod->get_mimetype(), 5) == 0) allImageFilter->add_pattern(upattern); -#else - allInkscapeFilter.add_pattern(upattern); - if (strncmp("image", imod->get_mimetype(), 5) == 0) - allImageFilter.add_pattern(upattern); -#endif // uncomment this to find out all mime types supported by Inkscape import/open // g_print ("%s\n", imod->get_mimetype()); @@ -896,17 +852,9 @@ void FileOpenDialogImplGtk::createFilterMenu() strncmp("image/x-tga", imod->get_mimetype(), 11) == 0 || strncmp("image/x-pcx", imod->get_mimetype(), 11) == 0) { -#if WITH_GTKMM_3_0 allBitmapFilter->add_pattern(upattern); -#else - allBitmapFilter.add_pattern(upattern); -#endif } else { -#if WITH_GTKMM_3_0 allVectorFilter->add_pattern(upattern); -#else - allVectorFilter.add_pattern(upattern); -#endif } } } @@ -972,18 +920,13 @@ Glib::ustring FileOpenDialogImplGtk::getFilename(void) */ std::vector FileOpenDialogImplGtk::getFilenames() { -#if WITH_GTKMM_3_0 - std::vector result_tmp = get_filenames(); + auto result_tmp = get_filenames(); // Copy filenames to a vector of type Glib::ustring std::vector result; - for (std::vector::iterator it = result_tmp.begin(); it != result_tmp.end(); ++it) - result.push_back(*it); - -#else - std::vector result = get_filenames(); -#endif + for (auto it : result_tmp) + result.push_back(it); #ifdef WITH_GNOME_VFS if (result.empty() && gnome_vfs_initialized()) @@ -1170,13 +1113,8 @@ void FileSaveDialogImplGtk::fileTypeChangedCallback() // g_message("selected: %s\n", type.name.c_str()); extension = type.extension; -#if WITH_GTKMM_3_0 - Glib::RefPtr filter = Gtk::FileFilter::create(); + auto filter = Gtk::FileFilter::create(); filter->add_pattern(type.pattern); -#else - Gtk::FileFilter filter; - filter.add_pattern(type.pattern); -#endif set_filter(filter); updateNameAndExtension(); diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index cafc3be4f..02d77cba1 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -128,11 +128,7 @@ FileDialogBaseWin32::FileDialogBaseWin32(Gtk::Window &parent, Glib::RefPtr parentWindow = parent.get_window(); g_assert(parentWindow->gobj() != NULL); -#if WITH_GTKMM_3_0 _ownerHwnd = (HWND)gdk_win32_window_get_handle((GdkWindow*)parentWindow->gobj()); -#else - _ownerHwnd = (HWND)gdk_win32_drawable_get_handle((GdkDrawable*)parentWindow->gobj()); -#endif } FileDialogBaseWin32::~FileDialogBaseWin32() diff --git a/src/ui/dialog/fill-and-stroke.cpp b/src/ui/dialog/fill-and-stroke.cpp index 8141f7696..923993514 100644 --- a/src/ui/dialog/fill-and-stroke.cpp +++ b/src/ui/dialog/fill-and-stroke.cpp @@ -111,11 +111,7 @@ void FillAndStroke::setTargetDesktop(SPDesktop *desktop) } } -#if WITH_GTKMM_3_0 void FillAndStroke::_onSwitchPage(Gtk::Widget * /*page*/, guint pagenum) -#else -void FillAndStroke::_onSwitchPage(GtkNotebookPage * /*page*/, guint pagenum) -#endif { _savePagePref(pagenum); } @@ -132,24 +128,14 @@ void FillAndStroke::_layoutPageFill() { fillWdgt = Gtk::manage(sp_fill_style_widget_new()); - -#if WITH_GTKMM_3_0 _page_fill->table().attach(*fillWdgt, 0, 0, 1, 1); -#else - _page_fill->table().attach(*fillWdgt, 0, 1, 0, 1); -#endif } void FillAndStroke::_layoutPageStrokePaint() { strokeWdgt = Gtk::manage(sp_stroke_style_paint_widget_new()); - -#if WITH_GTKMM_3_0 _page_stroke_paint->table().attach(*strokeWdgt, 0, 0, 1, 1); -#else - _page_stroke_paint->table().attach(*strokeWdgt, 0, 1, 0, 1); -#endif } void @@ -158,12 +144,7 @@ FillAndStroke::_layoutPageStrokeStyle() //Gtk::Widget *strokeStyleWdgt = manage(Glib::wrap(sp_stroke_style_line_widget_new())); //Gtk::Widget *strokeStyleWdgt = static_cast(sp_stroke_style_line_widget_new()); strokeStyleWdgt = sp_stroke_style_line_widget_new(); - -#if WITH_GTKMM_3_0 _page_stroke_style->table().attach(*strokeStyleWdgt, 0, 0, 1, 1); -#else - _page_stroke_style->table().attach(*strokeStyleWdgt, 0, 1, 0, 1); -#endif } void diff --git a/src/ui/dialog/fill-and-stroke.h b/src/ui/dialog/fill-and-stroke.h index f2a6bf39d..67e9d60ed 100644 --- a/src/ui/dialog/fill-and-stroke.h +++ b/src/ui/dialog/fill-and-stroke.h @@ -64,11 +64,7 @@ protected: void _layoutPageStrokePaint(); void _layoutPageStrokeStyle(); void _savePagePref(guint page_num); -#if WITH_GTKMM_3_0 void _onSwitchPage(Gtk::Widget *page, guint pagenum); -#else - void _onSwitchPage(GtkNotebookPage *page, guint pagenum); -#endif private: FillAndStroke(FillAndStroke const &d); diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index d3ad5d1da..acf230b7f 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -22,9 +22,7 @@ #include "dialog-manager.h" #include -#if GTK_CHECK_VERSION(3,0,0) -# include -#endif +#include #include "ui/widget/spinbutton.h" @@ -319,15 +317,9 @@ public: set_tooltip_text(tip_text); } -#if WITH_GTKMM_3_0 Gdk::RGBA col; col.set_rgba_u(65535, 65535, 65535); set_rgba(col); -#else - Gdk::Color col; - col.set_rgb(65535, 65535, 65535); - set_color(col); -#endif } // Returns the color in 'rgb(r,g,b)' form. @@ -336,13 +328,8 @@ public: // no doubles here, so we can use the standard string stream. std::ostringstream os; -#if WITH_GTKMM_3_0 - const Gdk::RGBA c = get_rgba(); - const int r = c.get_red_u() / 257, g = c.get_green_u() / 257, b = c.get_blue_u() / 257;//TO-DO: verify this. This sounds a lot strange! shouldn't it be 256? -#else - const Gdk::Color c = get_color(); - const int r = c.get_red() / 257, g = c.get_green() / 257, b = c.get_blue() / 257;//TO-DO: verify this. This sounds a lot strange! shouldn't it be 256? -#endif + const auto c = get_rgba(); + const int r = c.get_red_u() / 257, g = c.get_green_u() / 257, b = c.get_blue_u() / 257;//TO-DO: verify this. This sounds a lot strange! shouldn't it be 256? os << "rgb(" << r << "," << g << "," << b << ")"; return os.str(); } @@ -359,15 +346,9 @@ public: } const int r = SP_RGBA32_R_U(i), g = SP_RGBA32_G_U(i), b = SP_RGBA32_B_U(i); -#if WITH_GTKMM_3_0 Gdk::RGBA col; col.set_rgba_u(r * 256, g * 256, b * 256); set_rgba(col); -#else - Gdk::Color col; - col.set_rgb(r * 256, g * 256, b * 256); - set_color(col); -#endif } }; @@ -1730,7 +1711,6 @@ Glib::PropertyProxy FilterEffectsDialog::CellRendererConnection::property return _primitive.get_proxy(); } -#if WITH_GTKMM_3_0 void FilterEffectsDialog::CellRendererConnection::get_preferred_width_vfunc(Gtk::Widget& widget, int& minimum_width, int& natural_width) const @@ -1764,27 +1744,6 @@ void FilterEffectsDialog::CellRendererConnection::get_preferred_height_for_width { get_preferred_height(widget, minimum_height, natural_height); } -#else -void FilterEffectsDialog::CellRendererConnection::get_size_vfunc( - Gtk::Widget& widget, const Gdk::Rectangle* /*cell_area*/, - int* x_offset, int* y_offset, int* width, int* height) const -{ - PrimitiveList& primlist = dynamic_cast(widget); - - if(x_offset) - (*x_offset) = 0; - if(y_offset) - (*y_offset) = 0; - if(width) - (*width) = size * primlist.primitive_count() + (primlist.get_input_type_width()) * 6; - if(height) { - // Scale the height depending on the number of inputs, unless it's - // the first primitive, in which case there are no connections - SPFilterPrimitive* prim = SP_FILTER_PRIMITIVE(_primitive.get_value()); - (*height) = size * input_count(prim); - } -} -#endif /*** PrimitiveList ***/ FilterEffectsDialog::PrimitiveList::PrimitiveList(FilterEffectsDialog& d) @@ -1792,13 +1751,8 @@ FilterEffectsDialog::PrimitiveList::PrimitiveList(FilterEffectsDialog& d) _in_drag(0), _observer(new Inkscape::XML::SignalObserver) { -#if WITH_GTKMM_3_0 d.signal_draw().connect(sigc::mem_fun(*this, &PrimitiveList::on_draw_signal)); signal_draw().connect(sigc::mem_fun(*this, &PrimitiveList::on_draw_signal)); -#else - d.signal_expose_event().connect(sigc::mem_fun(*this, &PrimitiveList::on_expose_signal)); - signal_expose_event().connect(sigc::mem_fun(*this, &PrimitiveList::on_expose_signal)); -#endif add_events(Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK); @@ -1961,25 +1915,9 @@ void FilterEffectsDialog::PrimitiveList::remove_selected() } } -#if !WITH_GTKMM_3_0 -bool FilterEffectsDialog::PrimitiveList::on_expose_signal(GdkEventExpose * /*evt*/) -{ - bool result = false; - - if (get_is_drawable()) - { - Cairo::RefPtr cr = get_bin_window()->create_cairo_context(); - result = on_draw_signal(cr); - } - - return result; -} -#endif - bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr & cr) { cr->set_line_width(1.0); -#if GTK_CHECK_VERSION(3,0,0) // In GTK+ 3, the draw function receives the widget window, not the // bin_window (i.e., just the area under the column headers). We // therefore translate the origin of our coordinate system to account for this @@ -1987,7 +1925,7 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtrtranslate(x_origin, y_origin); - GtkStyleContext *sc = gtk_widget_get_style_context(GTK_WIDGET(gobj())); + auto sc = gtk_widget_get_style_context(GTK_WIDGET(gobj())); GdkRGBA bg_color, fg_color; gtk_style_context_get_background_color(sc, GTK_STATE_FLAG_NORMAL, &bg_color); gtk_style_context_get_color(sc, GTK_STATE_FLAG_NORMAL, &fg_color); @@ -2005,9 +1943,6 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtrchildren().size(); @@ -2026,25 +1961,15 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtrsave(); cr->rectangle(x, 0, get_input_type_width(), vis.get_height()); -#if GTK_CHECK_VERSION(3,0,0) gdk_cairo_set_source_rgba(cr->cobj(), &bg_color); cr->fill_preserve(); gdk_cairo_set_source_rgba(cr->cobj(), &fg_color); -#else - gdk_cairo_set_source_color(cr->cobj(), &(style->bg[GTK_STATE_NORMAL])); - cr->fill_preserve(); - gdk_cairo_set_source_color(cr->cobj(), &(style->text[GTK_STATE_NORMAL])); -#endif cr->move_to(x+get_input_type_width(), 0); cr->rotate_degrees(90); _vertical_layout->show_in_cairo_context(cr); -#if GTK_CHECK_VERSION(3,0,0) gdk_cairo_set_source_rgba(cr->cobj(), &mid_color); -#else - gdk_cairo_set_source_color(cr->cobj(), &(style->dark[GTK_STATE_NORMAL])); -#endif cr->move_to(x, 0); cr->line_to(x, vis.get_height()); cr->stroke(); @@ -2061,24 +1986,16 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr display = get_bin_window()->get_display(); - Glib::RefPtr dm = display->get_device_manager(); - Glib::RefPtr device = dm->get_client_pointer(); + auto display = get_bin_window()->get_display(); + auto dm = display->get_device_manager(); + auto device = dm->get_client_pointer(); get_bin_window()->get_device_position(device, mx, my, mask); -#else - get_bin_window()->get_pointer(mx, my, mask); -#endif // Outline the bottom of the connection area const int outline_x = x + fheight * (row_count - row_index); cr->save(); -#if GTK_CHECK_VERSION(3,0,0) gdk_cairo_set_source_rgba(cr->cobj(), &mid_color); -#else - gdk_cairo_set_source_color(cr->cobj(), &(style->dark[GTK_STATE_NORMAL])); -#endif cr->move_to(x, y + h); cr->line_to(outline_x, y + h); @@ -2101,17 +2018,10 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtrsave(); -#if GTK_CHECK_VERSION(3,0,0) gdk_cairo_set_source_rgba(cr->cobj(), inside && mask & GDK_BUTTON1_MASK ? &mid_color : &mid_color_active); -#else - gdk_cairo_set_source_color(cr->cobj(), - inside && mask & GDK_BUTTON1_MASK ? - &(style->dark[GTK_STATE_NORMAL]) : - &(style->dark[GTK_STATE_ACTIVE])); -#endif draw_connection_node(cr, con_poly, inside); @@ -2137,17 +2047,10 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtrsave(); -#if GTK_CHECK_VERSION(3,0,0) gdk_cairo_set_source_rgba(cr->cobj(), inside && mask & GDK_BUTTON1_MASK ? &mid_color : &mid_color_active); -#else - gdk_cairo_set_source_color(cr->cobj(), - inside && mask & GDK_BUTTON1_MASK ? - &(style->dark[GTK_STATE_NORMAL]) : - &(style->dark[GTK_STATE_ACTIVE])); -#endif draw_connection_node(cr, con_poly, inside); @@ -2170,17 +2073,10 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtrsave(); -#if GTK_CHECK_VERSION(3,0,0) gdk_cairo_set_source_rgba(cr->cobj(), inside && mask & GDK_BUTTON1_MASK ? &mid_color : &mid_color_active); -#else - gdk_cairo_set_source_color(cr->cobj(), - inside && mask & GDK_BUTTON1_MASK ? - &(style->dark[GTK_STATE_NORMAL]) : - &(style->dark[GTK_STATE_ACTIVE])); -#endif draw_connection_node(cr, con_poly, inside); @@ -2216,8 +2112,7 @@ void FilterEffectsDialog::PrimitiveList::draw_connection(const Cairo::RefPtrsave(); -#if GTK_CHECK_VERSION(3,0,0) - GtkStyleContext *sc = gtk_widget_get_style_context(GTK_WIDGET(gobj())); + auto sc = gtk_widget_get_style_context(GTK_WIDGET(gobj())); GdkRGBA bg_color, fg_color; gtk_style_context_get_background_color(sc, GTK_STATE_FLAG_NORMAL, &bg_color); @@ -2227,9 +2122,6 @@ void FilterEffectsDialog::PrimitiveList::draw_connection(const Cairo::RefPtrcobj(), &mid_color); -#else - gdk_cairo_set_source_color(cr->cobj(), &(style->dark[GTK_STATE_NORMAL])); -#endif else cr->set_source_rgb(0.0, 0.0, 0.0); @@ -2669,8 +2557,7 @@ void FilterEffectsDialog::PrimitiveList::on_drag_end(const Glib::RefPtr a = dynamic_cast(get_parent())->get_vadjustment(); + auto a = dynamic_cast(get_parent())->get_vadjustment(); double v = a->get_value() + _autoscroll_y; if(v < 0) @@ -2679,25 +2566,13 @@ bool FilterEffectsDialog::PrimitiveList::on_scroll_timeout() v = a->get_upper() - a->get_page_size(); a->set_value(v); -#else - Gtk::Adjustment& a = *dynamic_cast(get_parent())->get_vadjustment(); - double v = a.get_value() + _autoscroll_y; - - if(v < 0) - v = 0; - if(v > a.get_upper() - a.get_page_size()) - v = a.get_upper() - a.get_page_size(); - - a.set_value(v); -#endif queue_draw(); } if(_autoscroll_x) { -#if WITH_GTKMM_3_0 - Glib::RefPtr a_h = dynamic_cast(get_parent())->get_hadjustment(); + auto a_h = dynamic_cast(get_parent())->get_hadjustment(); double h = a_h->get_value() + _autoscroll_x; if(h < 0) @@ -2706,18 +2581,6 @@ bool FilterEffectsDialog::PrimitiveList::on_scroll_timeout() h = a_h->get_upper() - a_h->get_page_size(); a_h->set_value(h); -#else - Gtk::Adjustment& a_h = *dynamic_cast(get_parent())->get_hadjustment(); - double h = a_h.get_value() + _autoscroll_x; - - if(h < 0) - h = 0; - if(h > a_h.get_upper() - a_h.get_page_size()) - h = a_h.get_upper() - a_h.get_page_size(); - - a_h.set_value(h); - -#endif queue_draw(); } @@ -2759,13 +2622,8 @@ FilterEffectsDialog::FilterEffectsDialog() _sizegroup->set_ignore_hidden(); // Initialize widget hierarchy -#if WITH_GTKMM_3_0 - Gtk::Paned* hpaned = Gtk::manage(new Gtk::Paned); + auto hpaned = Gtk::manage(new Gtk::Paned); _primitive_box = Gtk::manage(new Gtk::Paned); -#else - Gtk::HPaned* hpaned = Gtk::manage(new Gtk::HPaned); - _primitive_box = Gtk::manage(new Gtk::VPaned); -#endif _sw_infobox = Gtk::manage(new Gtk::ScrolledWindow); Gtk::ScrolledWindow* sw_prims = Gtk::manage(new Gtk::ScrolledWindow); diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h index 7c715327e..eae0fc317 100644 --- a/src/ui/dialog/filter-effects-dialog.h +++ b/src/ui/dialog/filter-effects-dialog.h @@ -163,7 +163,6 @@ private: static const int size = 24; protected: -#if WITH_GTKMM_3_0 virtual void get_preferred_width_vfunc(Gtk::Widget& widget, int& minimum_width, int& natural_width) const; @@ -181,10 +180,6 @@ private: int width, int& minimum_height, int& natural_height) const; -#else - virtual void get_size_vfunc(Gtk::Widget& widget, const Gdk::Rectangle* cell_area, - int* x_offset, int* y_offset, int* width, int* height) const; -#endif private: // void* should be SPFilterPrimitive*, some weirdness with properties prevents this Glib::Property _primitive; @@ -211,9 +206,6 @@ private: protected: bool on_draw_signal(const Cairo::RefPtr &cr); -#if !WITH_GTKMM_3_0 - bool on_expose_signal(GdkEventExpose*); -#endif bool on_button_press_event(GdkEventButton*); bool on_motion_notify_event(GdkEventMotion*); @@ -283,11 +275,7 @@ private: Gtk::ScrolledWindow* _sw_infobox; // View/add primitives -#if WITH_GTKMM_3_0 Gtk::Paned* _primitive_box; -#else - Gtk::VPaned* _primitive_box; -#endif UI::Widget::ComboBoxEnum _add_primitive_type; Gtk::Button _add_primitive; diff --git a/src/ui/dialog/find.h b/src/ui/dialog/find.h index 4bcb900b6..94d635037 100644 --- a/src/ui/dialog/find.h +++ b/src/ui/dialog/find.h @@ -286,13 +286,7 @@ private: Gtk::Label status; UI::Widget::Button button_find; UI::Widget::Button button_replace; - -#if WITH_GTKMM_3_0 Gtk::ButtonBox box_buttons; -#else - Gtk::HButtonBox box_buttons; -#endif - Gtk::HBox hboxbutton_row; /** diff --git a/src/ui/dialog/floating-behavior.cpp b/src/ui/dialog/floating-behavior.cpp index 55ef0c5bb..20209e2c9 100644 --- a/src/ui/dialog/floating-behavior.cpp +++ b/src/ui/dialog/floating-behavior.cpp @@ -140,11 +140,7 @@ FloatingBehavior::create(Dialog &dialog) inline FloatingBehavior::operator Gtk::Widget &() { return *_d; } inline GtkWidget *FloatingBehavior::gobj() { return GTK_WIDGET(_d->gobj()); } inline Gtk::Box* FloatingBehavior::get_vbox() { -#if WITH_GTKMM_3_0 return _d->get_content_area(); -#else - return _d->get_vbox(); -#endif } inline void FloatingBehavior::present() { _d->present(); } inline void FloatingBehavior::hide() { _d->hide(); } @@ -155,12 +151,8 @@ inline void FloatingBehavior::move(int x, int y) { _d-> inline void FloatingBehavior::set_position(Gtk::WindowPosition position) { _d->set_position(position); } inline void FloatingBehavior::set_size_request(int width, int height) { _d->set_size_request(width, height); } inline void FloatingBehavior::size_request(Gtk::Requisition &requisition) { -#if WITH_GTKMM_3_0 Gtk::Requisition requisition_natural; _d->get_preferred_size(requisition, requisition_natural); -#else - requisition = _d->size_request(); -#endif } inline void FloatingBehavior::get_position(int &x, int &y) { _d->get_position(x, y); } inline void FloatingBehavior::get_size(int &width, int &height) { _d->get_size(width, height); } diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index 56b001291..1453797de 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -19,13 +19,7 @@ #include #include #include - -#if WITH_GTKMM_3_0 -# include -#else -# include -#endif - +#include #include #include @@ -342,12 +336,7 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : instanceConns(), desktopConns() { -#if WITH_GTKMM_3_0 - Gtk::Grid *table = new Gtk::Grid(); -#else - Gtk::Table *table = new Gtk::Table(3, 1, false); -#endif - + auto table = new Gtk::Grid(); _getContents()->pack_start(*Gtk::manage(table), Gtk::PACK_EXPAND_WIDGET); guint row = 0; @@ -360,29 +349,16 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : gtk_widget_set_size_request (fontsel, 0, 150); g_signal_connect( G_OBJECT(fontsel), "font_set", G_CALLBACK(fontChangeCB), this ); -#if WITH_GTKMM_3_0 table->attach(*Gtk::manage(Glib::wrap(fontsel)), 0, row, 3, 1); -#else - table->attach(*Gtk::manage(Glib::wrap(fontsel)), - 0, 3, row, row + 1, - Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL); -#endif - row++; // ------------------------------- { - Gtk::Label *label = new Gtk::Label(_("Script: ")); + auto label = new Gtk::Label(_("Script: ")); -#if WITH_GTKMM_3_0 table->attach( *Gtk::manage(label), 0, row, 1, 1); -#else - table->attach( *Gtk::manage(label), - 0, 1, row, row + 1, - Gtk::SHRINK, Gtk::SHRINK); -#endif scriptCombo = new Gtk::ComboBoxText(); for (std::map::iterator it = getScriptToName().begin(); it != getScriptToName().end(); ++it) @@ -396,14 +372,8 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : Gtk::Alignment *align = Gtk::manage(new Gtk::Alignment(Gtk::ALIGN_START, Gtk::ALIGN_START, 0.0, 0.0)); align->add(*Gtk::manage(scriptCombo)); -#if WITH_GTKMM_3_0 align->set_hexpand(); table->attach( *align, 1, row, 1, 1); -#else - table->attach( *align, - 1, 2, row, row + 1, - Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK); -#endif } row++; @@ -411,15 +381,8 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : // ------------------------------- { - Gtk::Label *label = new Gtk::Label(_("Range: ")); - -#if WITH_GTKMM_3_0 + auto label = new Gtk::Label(_("Range: ")); table->attach( *Gtk::manage(label), 0, row, 1, 1); -#else - table->attach( *Gtk::manage(label), - 0, 1, row, row + 1, - Gtk::SHRINK, Gtk::SHRINK); -#endif rangeCombo = new Gtk::ComboBoxText(); for ( std::vector::iterator it = getRanges().begin(); it != getRanges().end(); ++it ) { @@ -431,15 +394,8 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : instanceConns.push_back(conn); Gtk::Alignment *align = new Gtk::Alignment(Gtk::ALIGN_START, Gtk::ALIGN_START, 0.0, 0.0); align->add(*Gtk::manage(rangeCombo)); - -#if WITH_GTKMM_3_0 align->set_hexpand(); table->attach( *Gtk::manage(align), 1, row, 1, 1); -#else - table->attach( *Gtk::manage(align), - 1, 2, row, row + 1, - Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK); -#endif } row++; @@ -462,16 +418,9 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : Gtk::ScrolledWindow *scroller = new Gtk::ScrolledWindow(); scroller->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS); scroller->add(*Gtk::manage(iconView)); - -#if WITH_GTKMM_3_0 scroller->set_hexpand(); scroller->set_vexpand(); table->attach(*Gtk::manage(scroller), 0, row, 3, 1); -#else - table->attach(*Gtk::manage(scroller), - 0, 3, row, row + 1, - Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL); -#endif row++; @@ -501,15 +450,8 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : insertBtn->set_sensitive(false); box->pack_end(*Gtk::manage(insertBtn), Gtk::PACK_SHRINK); - -#if WITH_GTKMM_3_0 box->set_hexpand(); table->attach( *Gtk::manage(box), 0, row, 3, 1); -#else - table->attach( *Gtk::manage(box), - 0, 3, row, row + 1, - Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); -#endif row++; @@ -591,12 +533,7 @@ void GlyphsPanel::insertText() if (entry->get_text_length() > 0) { glyphs = entry->get_text(); } else { - -#if WITH_GTKMM_3_0 - std::vector itemArray = iconView->get_selected_items(); -#else - Gtk::IconView::ArrayHandle_TreePaths itemArray = iconView->get_selected_items(); -#endif + auto itemArray = iconView->get_selected_items(); if (!itemArray.empty()) { Gtk::TreeModel::Path const & path = *itemArray.begin(); @@ -641,11 +578,7 @@ void GlyphsPanel::glyphActivated(Gtk::TreeModel::Path const & path) void GlyphsPanel::glyphSelectionChanged() { -#if WITH_GTKMM_3_0 - std::vector itemArray = iconView->get_selected_items(); -#else - Gtk::IconView::ArrayHandle_TreePaths itemArray = iconView->get_selected_items(); -#endif + auto itemArray = iconView->get_selected_items(); if (itemArray.empty()) { label->set_text(" "); diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp index 639e463ea..eaf4e8ec0 100644 --- a/src/ui/dialog/grid-arrange-tab.cpp +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -19,12 +19,7 @@ #include //for GTK_RESPONSE* types #include #include - -#if WITH_GTKMM_3_0 -# include -#else -# include -#endif +#include #include <2geom/transforms.h> @@ -570,11 +565,7 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) : Parent(parent), XPadding(_("X:"), _("Horizontal spacing between columns."), UNIT_TYPE_LINEAR, "", "object-columns", &PaddingUnitMenu), YPadding(_("Y:"), _("Vertical spacing between rows."), XPadding, "", "object-rows", &PaddingUnitMenu), -#if WITH_GTKMM_3_0 PaddingTable(Gtk::manage(new Gtk::Grid())) -#else - PaddingTable(Gtk::manage(new Gtk::Table(2, 2, false))) -#endif { // bool used by spin button callbacks to stop loops where they change each other. updating = false; @@ -736,20 +727,11 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) } PaddingTable->set_border_width(MARGIN); - -#if WITH_GTKMM_3_0 PaddingTable->set_row_spacing(MARGIN); PaddingTable->set_column_spacing(MARGIN); PaddingTable->attach(XPadding, 0, 0, 1, 1); PaddingTable->attach(PaddingUnitMenu, 1, 0, 1, 1); PaddingTable->attach(YPadding, 0, 1, 1, 1); -#else - PaddingTable->set_row_spacings(MARGIN); - PaddingTable->set_col_spacings(MARGIN); - PaddingTable->attach(XPadding, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK); - PaddingTable->attach(PaddingUnitMenu, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK); - PaddingTable->attach(YPadding, 0, 1, 1, 2, Gtk::SHRINK, Gtk::SHRINK); -#endif TileBox.pack_start(*PaddingTable, false, false, MARGIN); diff --git a/src/ui/dialog/grid-arrange-tab.h b/src/ui/dialog/grid-arrange-tab.h index a137d1694..891849f1a 100644 --- a/src/ui/dialog/grid-arrange-tab.h +++ b/src/ui/dialog/grid-arrange-tab.h @@ -111,12 +111,7 @@ private: Inkscape::UI::Widget::UnitMenu PaddingUnitMenu; Inkscape::UI::Widget::ScalarUnit XPadding; Inkscape::UI::Widget::ScalarUnit YPadding; - -#if WITH_GTKMM_3_0 Gtk::Grid *PaddingTable; -#else - Gtk::Table *PaddingTable; -#endif // BBox or manual spacing Gtk::VBox SpacingVBox; diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index 556d77a28..eb0fce978 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -124,13 +124,8 @@ void GuidelinePropertiesDialog::_onOK() g_free((gpointer) name); -#if WITH_GTKMM_3_0 - const Gdk::RGBA c = _color.get_rgba(); + const auto c = _color.get_rgba(); unsigned r = c.get_red_u()/257, g = c.get_green_u()/257, b = c.get_blue_u()/257; -#else - const Gdk::Color c = _color.get_color(); - unsigned r = c.get_red()/257, g = c.get_green()/257, b = c.get_blue()/257; -#endif //TODO: why 257? verify this! _guide->set_color(r, g, b, true); @@ -171,15 +166,9 @@ void GuidelinePropertiesDialog::_setup() { add_button(Gtk::Stock::DELETE, -12); add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); -#if WITH_GTKMM_3_0 - Gtk::Box *mainVBox = get_content_area(); + auto mainVBox = get_content_area(); _layout_table.set_row_spacing(4); _layout_table.set_column_spacing(4); -#else - Gtk::Box *mainVBox = get_vbox(); - _layout_table.set_spacings(4); - _layout_table.resize (3, 4); -#endif mainVBox->pack_start(_layout_table, false, false, 0); @@ -189,7 +178,6 @@ void GuidelinePropertiesDialog::_setup() { _label_descr.set_label("foo1"); _label_descr.set_alignment(0, 0.5); -#if WITH_GTKMM_3_0 _label_name.set_halign(Gtk::ALIGN_FILL); _label_name.set_valign(Gtk::ALIGN_FILL); _layout_table.attach(_label_name, 0, 0, 3, 1); @@ -207,19 +195,6 @@ void GuidelinePropertiesDialog::_setup() { _color.set_valign(Gtk::ALIGN_FILL); _color.set_hexpand(); _layout_table.attach(_color, 1, 3, 2, 1); -#else - _layout_table.attach(_label_name, - 0, 3, 0, 1, Gtk::FILL, Gtk::FILL); - - _layout_table.attach(_label_descr, - 0, 3, 1, 2, Gtk::FILL, Gtk::FILL); - - _layout_table.attach(_label_entry, - 1, 3, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - - _layout_table.attach(_color, - 1, 3, 3, 4, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); -#endif // unitmenus /* fixme: We should allow percents here too, as percents of the canvas size */ @@ -238,7 +213,6 @@ void GuidelinePropertiesDialog::_setup() { _spin_button_y.setIncrements(1.0, 10.0); _spin_button_y.setRange(-1e6, 1e6); -#if WITH_GTKMM_3_0 _spin_button_x.set_halign(Gtk::ALIGN_FILL); _spin_button_x.set_valign(Gtk::ALIGN_FILL); _spin_button_x.set_hexpand(); @@ -252,22 +226,12 @@ void GuidelinePropertiesDialog::_setup() { _unit_menu.set_halign(Gtk::ALIGN_FILL); _unit_menu.set_valign(Gtk::ALIGN_FILL); _layout_table.attach(_unit_menu, 2, 4, 1, 1); -#else - _layout_table.attach(_spin_button_x, - 1, 2, 4, 5, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - _layout_table.attach(_spin_button_y, - 1, 2, 5, 6, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - - _layout_table.attach(_unit_menu, - 2, 3, 4, 5, Gtk::FILL, Gtk::FILL); -#endif // angle spinbutton _spin_angle.setDigits(3); _spin_angle.setIncrements(1.0, 10.0); _spin_angle.setRange(-3600., 3600.); -#if WITH_GTKMM_3_0 _spin_angle.set_halign(Gtk::ALIGN_FILL); _spin_angle.set_valign(Gtk::ALIGN_FILL); _spin_angle.set_hexpand(); @@ -284,18 +248,6 @@ void GuidelinePropertiesDialog::_setup() { _locked_toggle.set_valign(Gtk::ALIGN_FILL); _locked_toggle.set_hexpand(); _layout_table.attach(_locked_toggle, 1, 8, 2, 1); -#else - _layout_table.attach(_spin_angle, - 1, 3, 6, 7, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - - // mode radio button - _layout_table.attach(_relative_toggle, - 1, 3, 7, 8, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - - // locked radio button - _layout_table.attach(_locked_toggle, - 1, 3, 8, 9, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); -#endif _relative_toggle.signal_toggled().connect(sigc::mem_fun(*this, &GuidelinePropertiesDialog::_modeChanged)); _relative_toggle.set_active(_relative_toggle_status); @@ -348,15 +300,9 @@ void GuidelinePropertiesDialog::_setup() { // init name entry _label_entry.getEntry()->set_text(_guide->getLabel() ? _guide->getLabel() : ""); -#if WITH_GTKMM_3_0 Gdk::RGBA c; c.set_rgba(((_guide->getColor()>>24)&0xff) / 255.0, ((_guide->getColor()>>16)&0xff) / 255.0, ((_guide->getColor()>>8)&0xff) / 255.0); _color.set_rgba(c); -#else - Gdk::Color c; - c.set_rgb_p(((_guide->getColor()>>24)&0xff) / 255.0, ((_guide->getColor()>>16)&0xff) / 255.0, ((_guide->getColor()>>8)&0xff) / 255.0); - _color.set_color(c); -#endif _modeChanged(); // sets values of spinboxes. diff --git a/src/ui/dialog/guides.h b/src/ui/dialog/guides.h index 5dce0d6ed..25d32015c 100644 --- a/src/ui/dialog/guides.h +++ b/src/ui/dialog/guides.h @@ -16,12 +16,7 @@ #endif #include - -#if WITH_GTKMM_3_0 #include -#else -#include -#endif #include #include @@ -71,12 +66,7 @@ private: SPDesktop *_desktop; SPGuide *_guide; -#if WITH_GTKMM_3_0 - Gtk::Grid _layout_table; -#else - Gtk::Table _layout_table; -#endif - + Gtk::Grid _layout_table; Gtk::Label _label_name; Gtk::Label _label_descr; Inkscape::UI::Widget::CheckButton _locked_toggle; diff --git a/src/ui/dialog/icon-preview.h b/src/ui/dialog/icon-preview.h index 8a6e19a25..caec7e3b5 100644 --- a/src/ui/dialog/icon-preview.h +++ b/src/ui/dialog/icon-preview.h @@ -66,13 +66,7 @@ private: gdouble minDelay; Gtk::VBox iconBox; - -#if WITH_GTKMM_3_0 Gtk::Paned splitter; -#else - Gtk::HPaned splitter; -#endif - Glib::ustring targetId; int hot; int numEntries; diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 6dd62d3bb..8a69ef8e1 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -86,12 +86,8 @@ InkscapePreferences::InkscapePreferences() _getContents()->add(*sb); show_all_children(); Gtk::Requisition sreq; -#if WITH_GTKMM_3_0 Gtk::Requisition sreq_natural; sb->get_preferred_size(sreq_natural, sreq); -#else - sreq = sb->size_request(); -#endif _sb_width = sreq.width; _getContents()->remove(*sb); delete sb; @@ -863,17 +859,10 @@ static void proofComboChanged( Gtk::ComboBoxText* combo ) } static void gamutColorChanged( Gtk::ColorButton* btn ) { -#if WITH_GTKMM_3_0 - Gdk::RGBA rgba = btn->get_rgba(); - gushort r = rgba.get_red_u(); - gushort g = rgba.get_green_u(); - gushort b = rgba.get_blue_u(); -#else - Gdk::Color color = btn->get_color(); - gushort r = color.get_red(); - gushort g = color.get_green(); - gushort b = color.get_blue(); -#endif + auto rgba = btn->get_rgba(); + auto r = rgba.get_red_u(); + auto g = rgba.get_green_u(); + auto b = rgba.get_blue_u(); gchar* tmp = g_strdup_printf("#%02x%02x%02x", (r >> 8), (g >> 8), (b >> 8) ); @@ -1043,13 +1032,8 @@ void InkscapePreferences::initPageIO() Glib::ustring colorStr = prefs->getString("/options/softproof/gamutcolor"); -#if WITH_GTKMM_3_0 Gdk::RGBA tmpColor( colorStr.empty() ? "#00ff00" : colorStr); _cms_gamutcolor.set_rgba( tmpColor ); -#else - Gdk::Color tmpColor( colorStr.empty() ? "#00ff00" : colorStr); - _cms_gamutcolor.set_color( tmpColor ); -#endif _page_cms.add_line( true, _("Out of gamut warning color:"), _cms_gamutcolor, "", _("Selects the color used for out of gamut warning"), false); @@ -1594,31 +1578,19 @@ void InkscapePreferences::initKeyboardShortcuts(Gtk::TreeModel::iterator iter_ui int row = 3; -#if WITH_GTKMM_3_0 scroller->set_hexpand(); scroller->set_vexpand(); _page_keyshortcuts.attach(*scroller, 0, row, 2, 1); -#else - _page_keyshortcuts.attach(*scroller, 0, 2, row, row+1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL); -#endif row++; -#if WITH_GTKMM_3_0 - Gtk::ButtonBox *box_buttons = Gtk::manage(new Gtk::ButtonBox); -#else - Gtk::HButtonBox *box_buttons = Gtk::manage (new Gtk::HButtonBox); -#endif + auto box_buttons = Gtk::manage(new Gtk::ButtonBox); box_buttons->set_layout(Gtk::BUTTONBOX_END); box_buttons->set_spacing(4); -#if WITH_GTKMM_3_0 box_buttons->set_hexpand(); _page_keyshortcuts.attach(*box_buttons, 0, row, 3, 1); -#else - _page_keyshortcuts.attach(*box_buttons, 0, 3, row, row+1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK); -#endif UI::Widget::Button *kb_reset = Gtk::manage(new UI::Widget::Button(_("Reset"), _("Remove all your customized keyboard shortcuts, and revert to the shortcuts in the shortcut file listed above"))); box_buttons->pack_start(*kb_reset, true, true, 6); @@ -2051,12 +2023,8 @@ bool InkscapePreferences::SetMaxDialogSize(const Gtk::TreeModel::iterator& iter) _page_frame.add(*page); this->show_all_children(); Gtk::Requisition sreq; -#if WITH_GTKMM_3_0 Gtk::Requisition sreq_natural; this->get_preferred_size(sreq_natural, sreq); -#else - sreq = this->size_request(); -#endif _max_dialog_width=std::max(_max_dialog_width, sreq.width); _max_dialog_height=std::max(_max_dialog_height, sreq.height); _page_frame.remove(); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index d1abcfc58..781b5e48e 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -97,11 +97,7 @@ enum { }; namespace Gtk { -#if WITH_GTKMM_3_0 class Scale; -#else -class HScale; -#endif } namespace Inkscape { @@ -206,11 +202,7 @@ protected: UI::Widget::PrefCheckButton _scroll_space; UI::Widget::PrefCheckButton _wheel_zoom; -#if WITH_GTKMM_3_0 Gtk::Scale *_slider_snapping_delay; -#else - Gtk::HScale *_slider_snapping_delay; -#endif UI::Widget::PrefCheckButton _snap_indicator; UI::Widget::PrefCheckButton _snap_closest_only; diff --git a/src/ui/dialog/input.cpp b/src/ui/dialog/input.cpp index 8343cd6fe..e731ed3ff 100644 --- a/src/ui/dialog/input.cpp +++ b/src/ui/dialog/input.cpp @@ -33,13 +33,7 @@ #include #include #include - -#if WITH_GTKMM_3_0 -# include -#else -# include -#endif - +#include #include #include #include @@ -431,13 +425,7 @@ private: Blink watcher; Gtk::CheckButton useExt; Gtk::Button save; - -#if WITH_GTKMM_3_0 Gtk::Paned pane; -#else - Gtk::HPaned pane; -#endif - Gtk::VBox detailsBox; Gtk::HBox titleFrame; Gtk::Label titleLabel; @@ -498,27 +486,14 @@ private: Inkscape::UI::Widget::Frame axisFrame; Gtk::ScrolledWindow treeScroller; Gtk::ScrolledWindow detailScroller; - -#if WITH_GTKMM_3_0 Gtk::Paned splitter; Gtk::Paned split2; -#else - Gtk::HPaned splitter; - Gtk::VPaned split2; -#endif - Gtk::Label devName; Gtk::Label devKeyCount; Gtk::Label devAxesCount; Gtk::ComboBoxText axesCombo; Gtk::ProgressBar axesValues[6]; - -#if WITH_GTKMM_3_0 Gtk::Grid axisTable; -#else - Gtk::Table axisTable; -#endif - Gtk::ComboBoxText buttonCombo; Gtk::ComboBoxText linkCombo; sigc::connection linkConnection; @@ -528,13 +503,7 @@ private: Gtk::Image testThumb; Gtk::Image testButtons[24]; Gtk::Image testAxes[8]; - -#if WITH_GTKMM_3_0 Gtk::Grid imageTable; -#else - Gtk::Table imageTable; -#endif - Gtk::EventBox testDetector; ConfPanel cfgPanel; @@ -620,20 +589,11 @@ InputDialogImpl::InputDialogImpl() : treeScroller(), detailScroller(), splitter(), -#if WITH_GTKMM_3_0 split2(Gtk::ORIENTATION_VERTICAL), axisTable(), -#else - split2(), - axisTable(11, 2), -#endif linkCombo(), topHolder(), -#if WITH_GTKMM_3_0 imageTable(), -#else - imageTable(8, 7), -#endif testDetector(), cfgPanel() { @@ -655,27 +615,16 @@ InputDialogImpl::InputDialogImpl() : testFrame.add(testDetector); testThumb.set(getPix(PIX_TABLET)); testThumb.set_padding(24, 24); - -#if WITH_GTKMM_3_0 testThumb.set_hexpand(); testThumb.set_vexpand(); imageTable.attach(testThumb, 0, 0, 8, 1); -#else - imageTable.attach(testThumb, 0, 8, 0, 1, ::Gtk::EXPAND, ::Gtk::EXPAND); -#endif { guint col = 0; guint row = 1; for ( guint num = 0; num < G_N_ELEMENTS(testButtons); num++ ) { testButtons[num].set(getPix(PIX_BUTTONS_NONE)); - -#if WITH_GTKMM_3_0 imageTable.attach(testButtons[num], col, row, 1, 1); -#else - imageTable.attach(testButtons[num], col, col + 1, row, row + 1, ::Gtk::FILL, ::Gtk::FILL); -#endif - col++; if (col > 7) { col = 0; @@ -686,13 +635,7 @@ InputDialogImpl::InputDialogImpl() : col = 0; for ( guint num = 0; num < G_N_ELEMENTS(testAxes); num++ ) { testAxes[num].set(getPix(PIX_AXIS_NONE)); - -#if WITH_GTKMM_3_0 imageTable.attach(testAxes[num], col * 2, row, 2, 1); -#else - imageTable.attach(testAxes[num], col * 2, (col + 1) * 2, row, row + 1, ::Gtk::FILL, ::Gtk::FILL); -#endif - col++; if (col > 3) { col = 0; @@ -730,45 +673,17 @@ InputDialogImpl::InputDialogImpl() : axisFrame.add(axisTable); Gtk::Label *lbl = Gtk::manage(new Gtk::Label(_("Link:"))); - -#if WITH_GTKMM_3_0 axisTable.attach(*lbl, 0, rowNum, 1, 1); -#else - axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1, - ::Gtk::FILL, - ::Gtk::SHRINK); -#endif - linkCombo.append(_("None")); linkCombo.set_active_text(_("None")); linkCombo.set_sensitive(false); linkConnection = linkCombo.signal_changed().connect(sigc::mem_fun(*this, &InputDialogImpl::linkComboChanged)); - -#if WITH_GTKMM_3_0 axisTable.attach(linkCombo, 1, rowNum, 1, 1); -#else - axisTable.attach(linkCombo, 1, 2, rowNum, rowNum + 1, - ::Gtk::FILL, - ::Gtk::SHRINK); -#endif - rowNum++; - lbl = Gtk::manage(new Gtk::Label(_("Axes count:"))); - -#if WITH_GTKMM_3_0 axisTable.attach(*lbl, 0, rowNum, 1, 1); axisTable.attach(devAxesCount, 1, rowNum, 1, 1); -#else - axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1, - ::Gtk::FILL, - ::Gtk::SHRINK); - axisTable.attach(devAxesCount, 1, 2, rowNum, rowNum + 1, - ::Gtk::SHRINK, - ::Gtk::SHRINK); -#endif - rowNum++; @@ -786,22 +701,11 @@ InputDialogImpl::InputDialogImpl() : for ( guint barNum = 0; barNum < static_cast(G_N_ELEMENTS(axesValues)); barNum++ ) { lbl = Gtk::manage(new Gtk::Label(_("axis:"))); - -#if WITH_GTKMM_3_0 lbl->set_hexpand(); axisTable.attach(*lbl, 0, rowNum, 1, 1); axesValues[barNum].set_hexpand(); axisTable.attach(axesValues[barNum], 1, rowNum, 1, 1); -#else - axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1, - ::Gtk::EXPAND, - ::Gtk::SHRINK); - axisTable.attach(axesValues[barNum], 1, 2, rowNum, rowNum + 1, - ::Gtk::EXPAND, - ::Gtk::SHRINK); -#endif - axesValues[barNum].set_sensitive(false); rowNum++; @@ -811,17 +715,8 @@ InputDialogImpl::InputDialogImpl() : lbl = Gtk::manage(new Gtk::Label(_("Button count:"))); -#if WITH_GTKMM_3_0 axisTable.attach(*lbl, 0, rowNum, 1, 1); axisTable.attach(devKeyCount, 1, rowNum, 1, 1); -#else - axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1, - ::Gtk::FILL, - ::Gtk::SHRINK); - axisTable.attach(devKeyCount, 1, 2, rowNum, rowNum + 1, - ::Gtk::SHRINK, - ::Gtk::SHRINK); -#endif rowNum++; @@ -837,13 +732,7 @@ InputDialogImpl::InputDialogImpl() : rowNum++; */ -#if WITH_GTKMM_3_0 axisTable.attach(keyVal, 0, rowNum, 2, 1); -#else - axisTable.attach(keyVal, 0, 2, rowNum, rowNum + 1, - ::Gtk::FILL, - ::Gtk::SHRINK); -#endif rowNum++; @@ -857,18 +746,9 @@ InputDialogImpl::InputDialogImpl() : // TODO: Extension event stuff has been removed from public API in GTK+ 3 // Need to check that this hasn't broken anything -#if !GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_extension_events( GTK_WIDGET(testDetector.gobj()), GDK_EXTENSION_EVENTS_ALL ); -#endif testDetector.add_events(Gdk::POINTER_MOTION_MASK|Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK |Gdk::PROXIMITY_IN_MASK|Gdk::PROXIMITY_OUT_MASK|Gdk::SCROLL_MASK); -#if WITH_GTKMM_3_0 axisTable.attach(keyEntry, 0, rowNum, 2, 1); -#else - axisTable.attach(keyEntry, 0, 2, rowNum, rowNum + 1, - ::Gtk::FILL, - ::Gtk::SHRINK); -#endif rowNum++; @@ -1150,12 +1030,7 @@ InputDialogImpl::ConfPanel::ConfPanel() : useExt.set_active(Preferences::get()->getBool("/options/useextinput/value")); useExt.signal_toggled().connect(sigc::mem_fun(*this, &InputDialogImpl::ConfPanel::useExtToggled)); -#if WITH_GTKMM_3_0 - Gtk::ButtonBox *buttonBox = Gtk::manage(new Gtk::ButtonBox); -#else - Gtk::HButtonBox *buttonBox = Gtk::manage (new Gtk::HButtonBox); -#endif - + auto buttonBox = Gtk::manage(new Gtk::ButtonBox); buttonBox->set_layout (Gtk::BUTTONBOX_END); //Gtk::Alignment *align = new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_START, 0, 0); buttonBox->add(save); @@ -1939,7 +1814,6 @@ bool InputDialogImpl::eventSnoop(GdkEvent* event) testThumb.set(getPix(PIX_ERASER)); break; } -#if WITH_GTKMM_3_0 /// \fixme GTK3 added new GDK_SOURCEs that should be handled here! case GDK_SOURCE_KEYBOARD: case GDK_SOURCE_TOUCHSCREEN: @@ -1947,7 +1821,6 @@ bool InputDialogImpl::eventSnoop(GdkEvent* event) g_warning("InputDialogImpl::eventSnoop : unhandled GDK_SOURCE type!"); break; } -#endif } updateTestButtons(key, hotButton); diff --git a/src/ui/dialog/layer-properties.cpp b/src/ui/dialog/layer-properties.cpp index 5d550ed48..6f5def886 100644 --- a/src/ui/dialog/layer-properties.cpp +++ b/src/ui/dialog/layer-properties.cpp @@ -40,22 +40,15 @@ namespace Dialogs { LayerPropertiesDialog::LayerPropertiesDialog() : _strategy(NULL), _desktop(NULL), _layer(NULL), _position_visible(false) { -#if WITH_GTKMM_3_0 - Gtk::Box *mainVBox = get_content_area(); + auto mainVBox = get_content_area(); _layout_table.set_row_spacing(4); _layout_table.set_column_spacing(4); -#else - Gtk::Box *mainVBox = get_vbox(); - _layout_table.set_spacings(4); - _layout_table.resize (1, 2); -#endif // Layer name widgets _layer_name_entry.set_activates_default(true); _layer_name_label.set_label(_("Layer name:")); _layer_name_label.set_alignment(1.0, 0.5); -#if WITH_GTKMM_3_0 _layer_name_label.set_halign(Gtk::ALIGN_FILL); _layer_name_label.set_valign(Gtk::ALIGN_FILL); _layout_table.attach(_layer_name_label, 0, 0, 1, 1); @@ -64,12 +57,6 @@ LayerPropertiesDialog::LayerPropertiesDialog() _layer_name_entry.set_valign(Gtk::ALIGN_FILL); _layer_name_entry.set_hexpand(); _layout_table.attach(_layer_name_entry, 1, 0, 1, 1); -#else - _layout_table.attach(_layer_name_label, - 0, 1, 0, 1, Gtk::FILL, Gtk::FILL); - _layout_table.attach(_layer_name_entry, - 1, 2, 0, 1, Gtk::FILL | Gtk::EXPAND, Gtk::FILL); -#endif mainVBox->pack_start(_layout_table, true, true, 4); @@ -166,10 +153,6 @@ LayerPropertiesDialog::_setup_position_controls() { _layer_position_combo.set_cell_data_func(_label_renderer, sigc::mem_fun(*this, &LayerPropertiesDialog::_prepareLabelRenderer)); -#if !WITH_GTKMM_3_0 - _layout_table.resize (2, 2); -#endif - Gtk::ListStore::iterator row; row = _dropdown_list->append(); row->set_value(_dropdown_columns.position, LPOS_ABOVE); @@ -185,7 +168,6 @@ LayerPropertiesDialog::_setup_position_controls() { _layer_position_label.set_label(_("Position:")); _layer_position_label.set_alignment(1.0, 0.5); -#if WITH_GTKMM_3_0 _layer_position_combo.set_halign(Gtk::ALIGN_FILL); _layer_position_combo.set_valign(Gtk::ALIGN_FILL); _layer_position_combo.set_hexpand(); @@ -194,12 +176,6 @@ LayerPropertiesDialog::_setup_position_controls() { _layer_position_label.set_halign(Gtk::ALIGN_FILL); _layer_position_label.set_valign(Gtk::ALIGN_FILL); _layout_table.attach(_layer_position_label, 0, 1, 1, 1); -#else - _layout_table.attach(_layer_position_combo, - 1, 2, 1, 2, Gtk::FILL | Gtk::EXPAND, Gtk::FILL); - _layout_table.attach(_layer_position_label, - 0, 1, 1, 2, Gtk::FILL, Gtk::FILL); -#endif show_all_children(); } @@ -254,16 +230,11 @@ LayerPropertiesDialog::_setup_layers_controls() { _layout_table.remove(_layer_name_entry); _layout_table.remove(_layer_name_label); -#if WITH_GTKMM_3_0 _scroller.set_halign(Gtk::ALIGN_FILL); _scroller.set_valign(Gtk::ALIGN_FILL); _scroller.set_hexpand(); _scroller.set_vexpand(); _layout_table.attach(_scroller, 0, 1, 2, 1); -#else - _layout_table.attach(_scroller, - 0, 2, 1, 2, Gtk::FILL | Gtk::EXPAND, Gtk::FILL | Gtk::EXPAND); -#endif show_all_children(); } diff --git a/src/ui/dialog/layer-properties.h b/src/ui/dialog/layer-properties.h index c75a7f190..f62f22782 100644 --- a/src/ui/dialog/layer-properties.h +++ b/src/ui/dialog/layer-properties.h @@ -19,12 +19,7 @@ #include #include #include - -#if WITH_GTKMM_3_0 #include -#else -#include -#endif #include #include @@ -102,12 +97,7 @@ protected: Gtk::Entry _layer_name_entry; Gtk::Label _layer_position_label; Gtk::ComboBox _layer_position_combo; - -#if WITH_GTKMM_3_0 Gtk::Grid _layout_table; -#else - Gtk::Table _layout_table; -#endif bool _position_visible; diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index 1c022ecad..77ced6d71 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -866,12 +866,8 @@ LayersPanel::LayersPanel() : _scroller.set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC ); _scroller.set_shadow_type(Gtk::SHADOW_IN); Gtk::Requisition sreq; -#if WITH_GTKMM_3_0 Gtk::Requisition sreq_natural; _scroller.get_preferred_size(sreq_natural, sreq); -#else - sreq = _scroller.size_request(); -#endif int minHeight = 70; if (sreq.height < minHeight) { // Set a min height to see the layers when used with Ubuntu liboverlay-scrollbar diff --git a/src/ui/dialog/layers.h b/src/ui/dialog/layers.h index 9cd2c3b92..893b31557 100644 --- a/src/ui/dialog/layers.h +++ b/src/ui/dialog/layers.h @@ -124,15 +124,9 @@ private: Gtk::TreeView _tree; Gtk::CellRendererText *_text_renderer; Gtk::TreeView::Column *_name_column; -#if WITH_GTKMM_3_0 Gtk::Box _buttonsRow; Gtk::Box _buttonsPrimary; Gtk::Box _buttonsSecondary; -#else - Gtk::HBox _buttonsRow; - Gtk::HBox _buttonsPrimary; - Gtk::HBox _buttonsSecondary; -#endif Gtk::ScrolledWindow _scroller; Gtk::Menu _popupMenu; Inkscape::UI::Widget::SpinButton _spinBtn; diff --git a/src/ui/dialog/livepatheffect-add.cpp b/src/ui/dialog/livepatheffect-add.cpp index c558eddaf..4346ebd3d 100644 --- a/src/ui/dialog/livepatheffect-add.cpp +++ b/src/ui/dialog/livepatheffect-add.cpp @@ -74,11 +74,7 @@ LivePathEffectAdd::LivePathEffectAdd() : add_button.set_use_underline(true); add_button.set_can_default(); -#if WITH_GTKMM_3_0 - Gtk::Box *mainVBox = get_content_area(); -#else - Gtk::Box *mainVBox = get_vbox(); -#endif + auto mainVBox = get_content_area(); mainVBox->pack_start(scrolled_window, true, true); add_action_widget(close_button, Gtk::RESPONSE_CLOSE); diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 422ec10ae..f19652746 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -134,13 +134,6 @@ LivePathEffectEditor::LivePathEffectEditor() // Add toolbar items to toolbar toolbar_hbox.set_layout (Gtk::BUTTONBOX_END); - -#if !WITH_GTKMM_3_0 - // TODO: This has been removed from Gtkmm 3.0. Check that - // everything still looks OK! - toolbar_hbox.set_child_min_width( 16 ); -#endif - toolbar_hbox.add( button_add ); toolbar_hbox.set_child_secondary( button_add , true); toolbar_hbox.add( button_remove ); diff --git a/src/ui/dialog/livepatheffect-editor.h b/src/ui/dialog/livepatheffect-editor.h index 4aac25eaa..b69ee007a 100644 --- a/src/ui/dialog/livepatheffect-editor.h +++ b/src/ui/dialog/livepatheffect-editor.h @@ -112,11 +112,7 @@ private: void on_visibility_toggled( Glib::ustring const& str ); -#if WITH_GTKMM_3_0 Gtk::ButtonBox toolbar_hbox; -#else - Gtk::HButtonBox toolbar_hbox; -#endif Gtk::Button button_add; Gtk::Button button_remove; Gtk::Button button_up; diff --git a/src/ui/dialog/new-from-template.cpp b/src/ui/dialog/new-from-template.cpp index 74ec7111e..aed57871a 100644 --- a/src/ui/dialog/new-from-template.cpp +++ b/src/ui/dialog/new-from-template.cpp @@ -31,20 +31,12 @@ NewFromTemplate::NewFromTemplate() _main_widget = new TemplateLoadTab(this); -#if WITH_GTKMM_3_0 get_content_area()->pack_start(*_main_widget); -#else - get_vbox()->pack_start(*_main_widget); -#endif Gtk::Alignment *align; align = Gtk::manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); -#if WITH_GTKMM_3_0 get_content_area()->pack_end(*align, Gtk::PACK_SHRINK); -#else - get_vbox()->pack_end(*align, Gtk::PACK_SHRINK); -#endif align->set_padding(0, 0, 0, 15); align->add(_create_template_button); diff --git a/src/ui/dialog/object-properties.cpp b/src/ui/dialog/object-properties.cpp index be46129c4..9e10bbbeb 100644 --- a/src/ui/dialog/object-properties.cpp +++ b/src/ui/dialog/object-properties.cpp @@ -40,12 +40,7 @@ #include "xml/repr.h" #include -#if WITH_GTKMM_3_0 -# include -#else -# include -#endif - +#include namespace Inkscape { namespace UI { @@ -106,16 +101,9 @@ void ObjectProperties::_init() Gtk::Box *contents = _getContents(); contents->set_spacing(0); -#if WITH_GTKMM_3_0 - Gtk::Grid *grid_top = Gtk::manage(new Gtk::Grid()); + auto grid_top = Gtk::manage(new Gtk::Grid()); grid_top->set_row_spacing(4); grid_top->set_column_spacing(0); -#else - Gtk::Table *grid_top = Gtk::manage(new Gtk::Table(4, 4)); - grid_top->set_row_spacings(4); - grid_top->set_col_spacings(0); -#endif - grid_top->set_border_width(4); contents->pack_start(*grid_top, false, false, 0); @@ -124,29 +112,14 @@ void ObjectProperties::_init() /* Create the label for the object id */ _label_id.set_label(_label_id.get_label() + " "); _label_id.set_alignment(1, 0.5); - -#if WITH_GTKMM_3_0 _label_id.set_valign(Gtk::ALIGN_CENTER); grid_top->attach(_label_id, 0, 0, 1, 1); -#else - grid_top->attach(_label_id, 0, 1, 0, 1, - Gtk::SHRINK | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); -#endif - /* Create the entry box for the object id */ _entry_id.set_tooltip_text(_("The id= attribute (only letters, digits, and the characters .-_: allowed)")); _entry_id.set_max_length(64); - -#if WITH_GTKMM_3_0 _entry_id.set_valign(Gtk::ALIGN_CENTER); grid_top->attach(_entry_id, 1, 0, 1, 1); -#else - grid_top->attach(_entry_id, 1, 2, 0, 1, - Gtk::EXPAND | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); -#endif _label_id.set_mnemonic_widget(_entry_id); @@ -160,29 +133,16 @@ void ObjectProperties::_init() _label_label.set_label(_label_label.get_label() + " "); _label_label.set_alignment(1, 0.5); -#if WITH_GTKMM_3_0 _label_label.set_valign(Gtk::ALIGN_CENTER); grid_top->attach(_label_label, 0, 1, 1, 1); -#else - grid_top->attach(_label_label, 0, 1, 1, 2, - Gtk::SHRINK | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); -#endif - /* Create the entry box for the object label */ _entry_label.set_tooltip_text(_("A freeform label for the object")); _entry_label.set_max_length(256); -#if WITH_GTKMM_3_0 _entry_label.set_hexpand(); _entry_label.set_valign(Gtk::ALIGN_CENTER); grid_top->attach(_entry_label, 1, 1, 1, 1); -#else - grid_top->attach(_entry_label, 1, 2, 1, 2, - Gtk::EXPAND | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); -#endif _label_label.set_mnemonic_widget(_entry_label); @@ -194,28 +154,16 @@ void ObjectProperties::_init() _label_title.set_label(_label_title.get_label() + " "); _label_title.set_alignment (1, 0.5); -#if WITH_GTKMM_3_0 _label_title.set_valign(Gtk::ALIGN_CENTER); grid_top->attach(_label_title, 0, 2, 1, 1); -#else - grid_top->attach(_label_title, 0, 1, 2, 3, - Gtk::SHRINK | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); -#endif /* Create the entry box for the object title */ _entry_title.set_sensitive (FALSE); _entry_title.set_max_length (256); -#if WITH_GTKMM_3_0 _entry_title.set_hexpand(); _entry_title.set_valign(Gtk::ALIGN_CENTER); grid_top->attach(_entry_title, 1, 2, 1, 1); -#else - grid_top->attach(_entry_title, 1, 2, 2, 3, - Gtk::EXPAND | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); -#endif _label_title.set_mnemonic_widget(_entry_title); // pressing enter in the label field is the same as clicking Set: @@ -244,14 +192,8 @@ void ObjectProperties::_init() _label_image_rendering.set_label(_label_image_rendering.get_label() + " "); _label_image_rendering.set_alignment(1, 0.5); -#if WITH_GTKMM_3_0 _label_image_rendering.set_valign(Gtk::ALIGN_CENTER); grid_top->attach(_label_image_rendering, 0, 3, 1, 1); -#else - grid_top->attach(_label_image_rendering, 0, 1, 3, 4, - Gtk::SHRINK | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); -#endif /* Create the combo box text for the 'image-rendering' property */ _combo_image_rendering.append( "auto" ); @@ -259,14 +201,8 @@ void ObjectProperties::_init() _combo_image_rendering.append( "optimizeSpeed" ); _combo_image_rendering.set_tooltip_text(_("The 'image-rendering' property can influence how a bitmap is up-scaled:\n\t'auto' no preference;\n\t'optimizeQuality' smooth;\n\t'optimizeSpeed' blocky.\nNote that this behaviour is not defined in the SVG 1.1 specification and not all browsers follow this interpretation.")); -#if WITH_GTKMM_3_0 _combo_image_rendering.set_valign(Gtk::ALIGN_CENTER); grid_top->attach(_combo_image_rendering, 1, 3, 1, 1); -#else - grid_top->attach(_combo_image_rendering, 1, 2, 3, 4, - Gtk::EXPAND | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); -#endif _label_image_rendering.set_mnemonic_widget(_combo_image_rendering); @@ -278,60 +214,36 @@ void ObjectProperties::_init() Gtk::HBox *hb_checkboxes = Gtk::manage(new Gtk::HBox()); contents->pack_start(*hb_checkboxes, FALSE, FALSE, 0); -#if WITH_GTKMM_3_0 - Gtk::Grid *grid_cb = Gtk::manage(new Gtk::Grid()); + auto grid_cb = Gtk::manage(new Gtk::Grid()); grid_cb->set_row_homogeneous(); grid_cb->set_column_homogeneous(true); -#else - Gtk::Table *grid_cb = Gtk::manage(new Gtk::Table(1, 2, true)); -#endif grid_cb->set_border_width(4); hb_checkboxes->pack_start(*grid_cb, true, true, 0); /* Hide */ _cb_hide.set_tooltip_text (_("Check to make the object invisible")); - -#if WITH_GTKMM_3_0 _cb_hide.set_hexpand(); _cb_hide.set_valign(Gtk::ALIGN_CENTER); grid_cb->attach(_cb_hide, 0, 0, 1, 1); -#else - grid_cb->attach(_cb_hide, 0, 1, 0, 1, - Gtk::EXPAND | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); -#endif _cb_hide.signal_toggled().connect(sigc::mem_fun(this, &ObjectProperties::_hiddenToggled)); /* Lock */ // TRANSLATORS: "Lock" is a verb here _cb_lock.set_tooltip_text(_("Check to make the object insensitive (not selectable by mouse)")); - -#if WITH_GTKMM_3_0 _cb_lock.set_hexpand(); _cb_lock.set_valign(Gtk::ALIGN_CENTER); grid_cb->attach(_cb_lock, 1, 0, 1, 1); -#else - grid_cb->attach(_cb_lock, 1, 2, 0, 1, - Gtk::EXPAND | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); -#endif _cb_lock.signal_toggled().connect(sigc::mem_fun(this, &ObjectProperties::_sensitivityToggled)); /* Button for setting the object's id, label, title and description. */ Gtk::Button *btn_set = Gtk::manage(new Gtk::Button(_("_Set"), 1)); -#if WITH_GTKMM_3_0 btn_set->set_hexpand(); btn_set->set_valign(Gtk::ALIGN_CENTER); grid_cb->attach(*btn_set, 2, 0, 1, 1); -#else - grid_cb->attach(*btn_set, 2, 3, 0, 1, - Gtk::EXPAND | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); -#endif btn_set->signal_clicked().connect(sigc::mem_fun(this, &ObjectProperties::_labelChanged)); diff --git a/src/ui/dialog/object-properties.h b/src/ui/dialog/object-properties.h index dc28c0bad..8551d5fca 100644 --- a/src/ui/dialog/object-properties.h +++ b/src/ui/dialog/object-properties.h @@ -50,11 +50,7 @@ class SPDesktop; class SPItem; namespace Gtk { -#if WITH_GTKMM_3_0 class Grid; -#else -class Table; -#endif } namespace Inkscape { diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index 27694a9ac..e4b48d10b 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -511,11 +511,7 @@ void ObjectsPanel::_setCompositingValues(SPItem *item) _blurConnection.block(); //Set the opacity -#if WITH_GTKMM_3_0 _opacity_adjustment->set_value((item->style->opacity.set ? SP_SCALE24_TO_FLOAT(item->style->opacity.value) : 1) * _opacity_adjustment->get_upper()); -#else - _opacity_adjustment.set_value((item->style->opacity.set ? SP_SCALE24_TO_FLOAT(item->style->opacity.value) : 1) * _opacity_adjustment.get_upper()); -#endif SPFeBlend *spblend = NULL; SPGaussianBlur *spblur = NULL; if (item->style->getFilter()) @@ -1481,11 +1477,7 @@ void ObjectsPanel::_opacityChangedIter(const Gtk::TreeIter& iter) if (item) { item->style->opacity.set = TRUE; -#if WITH_GTKMM_3_0 item->style->opacity.value = SP_SCALE24_FROM_FLOAT(_opacity_adjustment->get_value() / _opacity_adjustment->get_upper()); -#else - item->style->opacity.value = SP_SCALE24_FROM_FLOAT(_opacity_adjustment.get_value() / _opacity_adjustment.get_upper()); -#endif item->updateRepr(SP_OBJECT_WRITE_NO_CHILDREN | SP_OBJECT_WRITE_EXT); } } @@ -1628,11 +1620,7 @@ ObjectsPanel::ObjectsPanel() : _opacity_vbox(false, 0), _opacity_label(_("Opacity:")), _opacity_label_unit(_("%")), -#if WITH_GTKMM_3_0 _opacity_adjustment(Gtk::Adjustment::create(100.0, 0.0, 100.0, 1.0, 1.0, 0.0)), -#else - _opacity_adjustment(100.0, 0.0, 100.0, 1.0, 1.0, 0.0), -#endif _opacity_hscale(_opacity_adjustment), _opacity_spin_button(_opacity_adjustment, 0.01, 1), _fe_cb(UI::Widget::SimpleFilterModifier::BLEND), @@ -1762,12 +1750,8 @@ ObjectsPanel::ObjectsPanel() : _scroller.set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC ); _scroller.set_shadow_type(Gtk::SHADOW_IN); Gtk::Requisition sreq; -#if WITH_GTKMM_3_0 Gtk::Requisition sreq_natural; _scroller.get_preferred_size(sreq_natural, sreq); -#else - sreq = _scroller.size_request(); -#endif int minHeight = 70; if (sreq.height < minHeight) { // Set a min height to see the layers when used with Ubuntu liboverlay-scrollbar @@ -1800,13 +1784,8 @@ ObjectsPanel::ObjectsPanel() : _opacity_hbox.pack_start(_opacity_spin_button, false, false, 0); _opacity_hbox.pack_start(_opacity_label_unit, false, false, 3); _opacity_hscale.set_draw_value(false); -#if WITH_GTKMM_3_0 _opacityConnection = _opacity_adjustment->signal_value_changed().connect(sigc::mem_fun(*this, &ObjectsPanel::_opacityValueChanged)); _opacity_label.set_mnemonic_widget(_opacity_hscale); -#else - _opacityConnection = _opacity_adjustment.signal_value_changed().connect(sigc::mem_fun(*this, &ObjectsPanel::_opacityValueChanged)); - _opacity_label.set_mnemonic_widget(_opacity_hscale); -#endif //Keep the labels aligned GtkSizeGroup *labels = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); diff --git a/src/ui/dialog/objects.h b/src/ui/dialog/objects.h index 9b9a6025a..018f9191f 100644 --- a/src/ui/dialog/objects.h +++ b/src/ui/dialog/objects.h @@ -134,15 +134,9 @@ private: Gtk::TreeView _tree; Gtk::CellRendererText *_text_renderer; Gtk::TreeView::Column *_name_column; -#if WITH_GTKMM_3_0 Gtk::Box _buttonsRow; Gtk::Box _buttonsPrimary; Gtk::Box _buttonsSecondary; -#else - Gtk::HBox _buttonsRow; - Gtk::HBox _buttonsPrimary; - Gtk::HBox _buttonsSecondary; -#endif Gtk::ScrolledWindow _scroller; Gtk::Menu _popupMenu; Inkscape::UI::Widget::SpinButton _spinBtn; @@ -161,11 +155,7 @@ private: Gtk::HBox _opacity_hbox; Gtk::Label _opacity_label; Gtk::Label _opacity_label_unit; -#if WITH_GTKMM_3_0 Glib::RefPtr _opacity_adjustment; -#else - Gtk::Adjustment _opacity_adjustment; -#endif Gtk::HScale _opacity_hscale; Inkscape::UI::Widget::SpinButton _opacity_spin_button; diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp index f2ee79d06..9e9037fdd 100644 --- a/src/ui/dialog/ocaldialogs.cpp +++ b/src/ui/dialog/ocaldialogs.cpp @@ -316,27 +316,10 @@ LoadingBox::LoadingBox() : Gtk::EventBox() draw_spinner = false; spinner_step = 0; -#if WITH_GTKMM_3_0 signal_draw().connect(sigc::mem_fun(*this, &LoadingBox::_on_draw), false); -#else - signal_expose_event().connect(sigc::mem_fun(*this, &LoadingBox::_on_expose_event), false); -#endif -} - -#if !WITH_GTKMM_3_0 -bool LoadingBox::_on_expose_event(GdkEventExpose* /*event*/) -{ - Cairo::RefPtr cr = get_window()->create_cairo_context(); - - return _on_draw(cr); } -#endif -bool LoadingBox::_on_draw(const Cairo::RefPtr & -#if WITH_GTKMM_3_0 -cr -#endif -) +bool LoadingBox::_on_draw(const Cairo::RefPtr &cr) { // Draw shadow int x = get_allocation().get_x(); @@ -344,27 +327,14 @@ cr int width = get_allocation().get_width(); int height = get_allocation().get_height(); -#if WITH_GTKMM_3_0 get_style_context()->render_frame(cr, x, y, width, height); -#else - get_style()->paint_shadow(get_window(), get_state(), Gtk::SHADOW_IN, - Gdk::Rectangle(x, y, width, height), - *this, Glib::ustring("viewport"), x, y, width, height); -#endif if (draw_spinner) { int spinner_size = 16; int spinner_x = x + (width - spinner_size) / 2; int spinner_y = y + (height - spinner_size) / 2; -#if WITH_GTKMM_3_0 get_style_context()->render_activity(cr, spinner_x, spinner_y, spinner_size, spinner_size); -#else - gtk_paint_spinner(gtk_widget_get_style(GTK_WIDGET(gobj())), - gtk_widget_get_window(GTK_WIDGET(gobj())), - gtk_widget_get_state(GTK_WIDGET(gobj())), NULL, GTK_WIDGET(gobj()), - NULL, spinner_step, spinner_x, spinner_y, spinner_size, spinner_size); -#endif } return false; @@ -434,11 +404,7 @@ PreviewWidget::PreviewWidget() : Gtk::VBox(false, 12) box_loading->set_size_request(90, 90); set_border_width(12); -#if WITH_GTKMM_3_0 signal_draw().connect(sigc::mem_fun(*this, &PreviewWidget::_on_draw), false); -#else - signal_expose_event().connect(sigc::mem_fun(*this, &PreviewWidget::_on_expose_event), false); -#endif clear(); } @@ -482,15 +448,6 @@ void PreviewWidget::clear() image->hide(); } -#if !WITH_GTKMM_3_0 -bool PreviewWidget::_on_expose_event(GdkEventExpose* /*event*/) -{ - Cairo::RefPtr cr = get_window()->create_cairo_context(); - - return _on_draw(cr); -} -#endif - bool PreviewWidget::_on_draw(const Cairo::RefPtr& cr) { // Draw background @@ -499,16 +456,10 @@ bool PreviewWidget::_on_draw(const Cairo::RefPtr& cr) int width = get_allocation().get_width(); int height = get_allocation().get_height(); -#if WITH_GTKMM_3_0 Gdk::RGBA background_fill; get_style_context()->lookup_color("base_color", background_fill); cr->rectangle(x, y, width, height); Gdk::Cairo::set_source_rgba(cr, background_fill); -#else - Gdk::Color background_fill = get_style()->get_base(get_state()); - cr->rectangle(x, y, width, height); - Gdk::Cairo::set_source_color(cr, background_fill); -#endif cr->fill(); @@ -573,57 +524,12 @@ void StatusWidget::end_process() clear(); } -#if !GTK_CHECK_VERSION(3,0,0) -SearchEntry::SearchEntry() : Gtk::Entry() -{ - signal_changed().connect(sigc::mem_fun(*this, &SearchEntry::_on_changed)); - signal_icon_press().connect(sigc::mem_fun(*this, &SearchEntry::_on_icon_pressed)); - - set_icon_from_icon_name(INKSCAPE_ICON("edit-find"), Gtk::ENTRY_ICON_PRIMARY); - gtk_entry_set_icon_from_icon_name(gobj(), GTK_ENTRY_ICON_SECONDARY, NULL); -} - -void SearchEntry::_on_icon_pressed(Gtk::EntryIconPosition icon_position, const GdkEventButton* /*event*/) -{ - if (icon_position == Gtk::ENTRY_ICON_SECONDARY) { - grab_focus(); - delete_text(0, -1); - } else if (icon_position == Gtk::ENTRY_ICON_PRIMARY) { - select_region(0, -1); - grab_focus(); - } -} - -void SearchEntry::_on_changed() -{ - if (get_text().empty()) { - gtk_entry_set_icon_from_icon_name(gobj(), GTK_ENTRY_ICON_SECONDARY, NULL); - } else { - set_icon_from_icon_name(INKSCAPE_ICON("edit-clear"), Gtk::ENTRY_ICON_SECONDARY); - } -} -#endif - - BaseBox::BaseBox() : Gtk::EventBox() { -#if WITH_GTKMM_3_0 signal_draw().connect(sigc::mem_fun(*this, &BaseBox::_on_draw), false); -#else - signal_expose_event().connect(sigc::mem_fun(*this, &BaseBox::_on_expose_event), false); -#endif set_visible_window(false); } -#if !WITH_GTKMM_3_0 -bool BaseBox::_on_expose_event(GdkEventExpose* /*event*/) -{ - Cairo::RefPtr cr = get_window()->create_cairo_context(); - - return _on_draw(cr); -} -#endif - bool BaseBox::_on_draw(const Cairo::RefPtr& cr) { // Draw background and shadow @@ -632,23 +538,12 @@ bool BaseBox::_on_draw(const Cairo::RefPtr& cr) int width = get_allocation().get_width(); int height = get_allocation().get_height(); -#if WITH_GTKMM_3_0 Gdk::RGBA background_fill; get_style_context()->lookup_color("base_color", background_fill); cr->rectangle(x, y, width, height); Gdk::Cairo::set_source_rgba(cr, background_fill); cr->fill(); get_style_context()->render_frame(cr, x, y, width, height); -#else - Gdk::Color background_fill = get_style()->get_base(get_state()); - cr->rectangle(x, y, width, height); - Gdk::Cairo::set_source_color(cr, background_fill); - cr->fill(); - - get_style()->paint_shadow(get_window(), get_state(), Gtk::SHADOW_IN, - Gdk::Rectangle(x, y, width, height), - *this, Glib::ustring("viewport"), x, y, width, height); -#endif return false; } @@ -665,23 +560,10 @@ LogoArea::LogoArea() : Gtk::EventBox() draw_logo = false; } -#if WITH_GTKMM_3_0 signal_draw().connect(sigc::mem_fun(*this, &LogoArea::_on_draw)); -#else - signal_expose_event().connect(sigc::mem_fun(*this, &LogoArea::_on_expose_event)); -#endif set_visible_window(false); } -#if !WITH_GTKMM_3_0 -bool LogoArea::_on_expose_event(GdkEventExpose* /*event*/) -{ - Cairo::RefPtr cr = get_window()->create_cairo_context(); - - return _on_draw(cr); -} -#endif - bool LogoArea::_on_draw(const Cairo::RefPtr& cr) { if (draw_logo) { @@ -692,16 +574,9 @@ bool LogoArea::_on_draw(const Cairo::RefPtr& cr) int x_logo = x + (width - 220) / 2; int y_logo = y + (height - 76) / 2; - // Draw logo, we mask [read fill] it with the mid colour from the - // user's GTK theme -#if WITH_GTKMM_3_0 - // For GTK+ 3, use grey + // Draw logo, we mask [read fill] it with grey Gdk::RGBA logo_fill("grey"); Gdk::Cairo::set_source_rgba(cr, logo_fill); -#else - Gdk::Color logo_fill = get_style()->get_mid(get_state()); - Gdk::Cairo::set_source_color(cr, logo_fill); -#endif cr->mask(logo_mask, x_logo, y_logo); } @@ -1179,16 +1054,9 @@ void ImportDialog::update_label_no_search_results() Glib::ustring msg_two = _("Please make sure all keywords are spelled correctly," " or try again with different keywords."); -#if WITH_GTKMM_3_0 - Glib::ustring markup = Glib::ustring::compose( + auto markup = Glib::ustring::compose( "%1\n%2", msg_one, msg_two); -#else - Gdk::Color grey = entry_search->get_style()->get_text_aa(entry_search->get_state()); - Glib::ustring markup = Glib::ustring::compose( - "%1\n%3", - msg_one, grey.to_string(), msg_two); -#endif label_not_found->set_markup(markup); } @@ -1208,33 +1076,17 @@ ImportDialog::ImportDialog(Gtk::Window& parent_window, FileDialogType file_types dialogType = file_types; // Creation - Gtk::VBox *vbox = new Gtk::VBox(false, 0); - -#if WITH_GTKMM_3_0 - Gtk::ButtonBox *hbuttonbox_bottom = new Gtk::ButtonBox(); -#else - Gtk::HButtonBox *hbuttonbox_bottom = new Gtk::HButtonBox(); -#endif - - Gtk::HBox *hbox_bottom = new Gtk::HBox(false, 12); + auto vbox = new Gtk::VBox(false, 0); + auto hbuttonbox_bottom = new Gtk::ButtonBox(); + auto hbox_bottom = new Gtk::HBox(false, 12); BaseBox *basebox_logo = new BaseBox(); BaseBox *basebox_no_search_results = new BaseBox(); label_not_found = new Gtk::Label(); label_description = new Gtk::Label(); - -#if GTK_CHECK_VERSION(3,0,0) entry_search = new Gtk::SearchEntry(); -#else - entry_search = new SearchEntry(); -#endif - button_search = new Gtk::Button(_("Search")); -#if WITH_GTKMM_3_0 - Gtk::ButtonBox* hbuttonbox_search = new Gtk::ButtonBox(); -#else - Gtk::HButtonBox* hbuttonbox_search = new Gtk::HButtonBox(); -#endif + auto hbuttonbox_search = new Gtk::ButtonBox(); Gtk::ScrolledWindow* scrolledwindow_preview = new Gtk::ScrolledWindow(); preview_files = new PreviewWidget(); diff --git a/src/ui/dialog/ocaldialogs.h b/src/ui/dialog/ocaldialogs.h index 9de24d821..db3c60786 100644 --- a/src/ui/dialog/ocaldialogs.h +++ b/src/ui/dialog/ocaldialogs.h @@ -17,19 +17,16 @@ # include #endif -//Gtk includes +// Gtkmm includes #include #include #include #include +#include #include #include -#if GTK_CHECK_VERSION(3,0,0) -# include -#endif - #include //Inkscape includes @@ -283,10 +280,6 @@ private: sigc::connection timeout; bool draw_spinner; -#if !WITH_GTKMM_3_0 - bool _on_expose_event(GdkEventExpose* event); -#endif - bool _on_draw(const Cairo::RefPtr& cr); bool on_timeout(); }; @@ -310,10 +303,6 @@ private: WrapLabel* label_description; WrapLabel* label_time; -#if !WITH_GTKMM_3_0 - bool _on_expose_event(GdkEventExpose* event); -#endif - bool _on_draw(const Cairo::RefPtr& cr); }; @@ -336,21 +325,6 @@ public: Gtk::Label* label; }; -#if !GTK_CHECK_VERSION(3,0,0) -/** - * A Gtk::Entry with search & clear icons - */ -class SearchEntry : public Gtk::Entry -{ -public: - SearchEntry(); - -private: - void _on_icon_pressed(Gtk::EntryIconPosition icon_position, const GdkEventButton* event); - void _on_changed(); -}; -#endif - /** * A box which paints an overlay of the OCAL logo */ @@ -359,9 +333,6 @@ class LogoArea : public Gtk::EventBox public: LogoArea(); private: -#if !WITH_GTKMM_3_0 - bool _on_expose_event(GdkEventExpose* event); -#endif bool _on_draw(const Cairo::RefPtr& cr); bool draw_logo; Cairo::RefPtr logo_mask; @@ -375,9 +346,6 @@ class BaseBox : public Gtk::EventBox public: BaseBox(); private: -#if !WITH_GTKMM_3_0 - bool _on_expose_event(GdkEventExpose* event); -#endif bool _on_draw(const Cairo::RefPtr& cr); }; @@ -459,12 +427,7 @@ protected: private: Glib::ustring filename_image; Glib::ustring filename_thumbnail; - -#if GTK_CHECK_VERSION(3,0,0) Gtk::SearchEntry *entry_search; -#else - SearchEntry *entry_search; -#endif LogoArea *drawingarea_logo; SearchResultList *list_results; diff --git a/src/ui/dialog/polar-arrange-tab.cpp b/src/ui/dialog/polar-arrange-tab.cpp index 5ec1285c1..5c588ebac 100644 --- a/src/ui/dialog/polar-arrange-tab.cpp +++ b/src/ui/dialog/polar-arrange-tab.cpp @@ -33,11 +33,7 @@ namespace Dialog { PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) : parent(parent_), -#if WITH_GTKMM_3_0 parametersTable(), -#else - parametersTable(3, 3, false), -#endif centerY("", C_("Polar arrange tab", "Y coordinate of the center"), UNIT_TYPE_LINEAR), centerX("", C_("Polar arrange tab", "X coordinate of the center"), centerY), radiusY("", C_("Polar arrange tab", "Y coordinate of the radius"), UNIT_TYPE_LINEAR), @@ -81,11 +77,7 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) pack_start(arrangeOnParametersRadio, false, false); centerLabel.set_text(C_("Polar arrange tab", "Center X/Y:")); -#if WITH_GTKMM_3_0 parametersTable.attach(centerLabel, 0, 0, 1, 1); -#else - parametersTable.attach(centerLabel, 0, 1, 0, 1, Gtk::FILL); -#endif centerX.setDigits(2); centerX.setIncrements(0.2, 0); centerX.setRange(-10000, 10000); @@ -94,20 +86,11 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) centerY.setIncrements(0.2, 0); centerY.setRange(-10000, 10000); centerY.setValue(0, "px"); -#if WITH_GTKMM_3_0 parametersTable.attach(centerX, 1, 0, 1, 1); parametersTable.attach(centerY, 2, 0, 1, 1); -#else - parametersTable.attach(centerX, 1, 2, 0, 1, Gtk::FILL); - parametersTable.attach(centerY, 2, 3, 0, 1, Gtk::FILL); -#endif radiusLabel.set_text(C_("Polar arrange tab", "Radius X/Y:")); -#if WITH_GTKMM_3_0 parametersTable.attach(radiusLabel, 0, 1, 1, 1); -#else - parametersTable.attach(radiusLabel, 0, 1, 1, 2, Gtk::FILL); -#endif radiusX.setDigits(2); radiusX.setIncrements(0.2, 0); radiusX.setRange(0.001, 10000); @@ -116,20 +99,11 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) radiusY.setIncrements(0.2, 0); radiusY.setRange(0.001, 10000); radiusY.setValue(100, "px"); -#if WITH_GTKMM_3_0 parametersTable.attach(radiusX, 1, 1, 1, 1); parametersTable.attach(radiusY, 2, 1, 1, 1); -#else - parametersTable.attach(radiusX, 1, 2, 1, 2, Gtk::FILL); - parametersTable.attach(radiusY, 2, 3, 1, 2, Gtk::FILL); -#endif angleLabel.set_text(_("Angle X/Y:")); -#if WITH_GTKMM_3_0 parametersTable.attach(angleLabel, 0, 2, 1, 1); -#else - parametersTable.attach(angleLabel, 0, 1, 2, 3, Gtk::FILL); -#endif angleX.setDigits(2); angleX.setIncrements(0.2, 0); angleX.setRange(-10000, 10000); @@ -138,13 +112,8 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) angleY.setIncrements(0.2, 0); angleY.setRange(-10000, 10000); angleY.setValue(180, "°"); -#if WITH_GTKMM_3_0 parametersTable.attach(angleX, 1, 2, 1, 1); parametersTable.attach(angleY, 2, 2, 1, 1); -#else - parametersTable.attach(angleX, 1, 2, 2, 3, Gtk::FILL); - parametersTable.attach(angleY, 2, 3, 2, 3, Gtk::FILL); -#endif pack_start(parametersTable, false, false); rotateObjectsCheckBox.set_label(_("Rotate objects")); diff --git a/src/ui/dialog/polar-arrange-tab.h b/src/ui/dialog/polar-arrange-tab.h index f7d7bf11f..1a4e04eda 100644 --- a/src/ui/dialog/polar-arrange-tab.h +++ b/src/ui/dialog/polar-arrange-tab.h @@ -20,12 +20,7 @@ #include #include - -#if WITH_GTKMM_3_0 - #include -#else - #include -#endif +#include namespace Inkscape { namespace UI { @@ -75,11 +70,7 @@ private: Gtk::RadioButton arrangeOnLastCircleRadio; Gtk::RadioButton arrangeOnParametersRadio; -#if WITH_GTKMM_3_0 Gtk::Grid parametersTable; -#else - Gtk::Table parametersTable; -#endif Gtk::Label centerLabel; Inkscape::UI::Widget::ScalarUnit centerY; diff --git a/src/ui/dialog/spellcheck.h b/src/ui/dialog/spellcheck.h index e98a9d80e..834f23c24 100644 --- a/src/ui/dialog/spellcheck.h +++ b/src/ui/dialog/spellcheck.h @@ -225,11 +225,7 @@ private: * Dialogs widgets */ Gtk::Label banner_label; -#if WITH_GTKMM_3_0 Gtk::ButtonBox banner_hbox; -#else - Gtk::HButtonBox banner_hbox; -#endif Gtk::ScrolledWindow scrolled_window; Gtk::TreeView tree_view; Glib::RefPtr model; @@ -243,21 +239,10 @@ private: Gtk::Button add_button; GtkWidget * dictionary_combo; Gtk::HBox dictionary_hbox; - -#if WITH_GTKMM_3_0 Gtk::Separator action_sep; -#else - Gtk::HSeparator action_sep; -#endif - Gtk::Button stop_button; Gtk::Button start_button; - -#if WITH_GTKMM_3_0 Gtk::ButtonBox actionbutton_hbox; -#else - Gtk::HButtonBox actionbutton_hbox; -#endif SPDesktop * desktop; DesktopTracker deskTrack; diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 08ebbcf14..58ac62cb0 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -890,12 +890,7 @@ void SvgFontsDialog::add_font(){ SvgFontsDialog::SvgFontsDialog() : UI::Widget::Panel("", "/dialogs/svgfonts", SP_VERB_DIALOG_SVG_FONTS), _add(Gtk::Stock::NEW) { -#if WITH_GTKMM_3_0 kerning_slider = Gtk::manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL)); -#else - kerning_slider = Gtk::manage(new Gtk::HScale); -#endif - _add.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::add_font)); Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox()); diff --git a/src/ui/dialog/svg-fonts-dialog.h b/src/ui/dialog/svg-fonts-dialog.h index e80bbfd39..1588c0fc2 100644 --- a/src/ui/dialog/svg-fonts-dialog.h +++ b/src/ui/dialog/svg-fonts-dialog.h @@ -27,11 +27,7 @@ #include "xml/helper-observer.h" namespace Gtk { -#if WITH_GTKMM_3_0 class Scale; -#else -class HScale; -#endif } class SPGlyph; @@ -216,12 +212,7 @@ private: GlyphComboBox first_glyph, second_glyph; SPGlyphKerning* kerning_pair; Inkscape::UI::Widget::SpinButton setwidth_spin; - -#if WITH_GTKMM_3_0 Gtk::Scale* kerning_slider; -#else - Gtk::HScale* kerning_slider; -#endif class EntryWidget : public Gtk::HBox { diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 6577c8d4e..964e844b2 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -658,12 +658,8 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) : if (Glib::ustring(prefsPath) == "/dialogs/swatches") { Gtk::Requisition sreq; -#if WITH_GTKMM_3_0 Gtk::Requisition sreq_natural; get_preferred_size(sreq_natural, sreq); -#else - sreq = size_request(); -#endif int minHeight = 60; if (sreq.height < minHeight) { set_size_request(70, minHeight); diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 06c17611f..597f90e95 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -20,14 +20,8 @@ #include #include - -#if WITH_GTKMM_3_0 -# include -# include -#else -# include -#endif - +#include +#include #include #include #include @@ -121,11 +115,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : { /******************** Table *************************/ -#if WITH_GTKMM_3_0 - Gtk::Grid *table = new Gtk::Grid(); -#else - Gtk::Table *table = new Gtk::Table(2, 4, false); -#endif + auto table = new Gtk::Grid(); // panel is a cloked Gtk::VBox _getContents()->pack_start(*Gtk::manage(table), Gtk::PACK_EXPAND_WIDGET); @@ -133,24 +123,12 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : /******************** Symbol Sets *************************/ Gtk::Label* labelSet = new Gtk::Label(_("Symbol set: ")); - -#if WITH_GTKMM_3_0 table->attach(*Gtk::manage(labelSet),0,row,1,1); -#else - table->attach(*Gtk::manage(labelSet),0,1,row,row+1,Gtk::SHRINK,Gtk::SHRINK); -#endif - symbolSet = new Gtk::ComboBoxText(); // Fill in later symbolSet->append(_("Current Document")); symbolSet->set_active_text(_("Current Document")); - -#if WITH_GTKMM_3_0 symbolSet->set_hexpand(); table->attach(*Gtk::manage(symbolSet),1,row,1,1); -#else - table->attach(*Gtk::manage(symbolSet),1,2,row,row+1,Gtk::FILL|Gtk::EXPAND,Gtk::SHRINK); -#endif - sigc::connection connSet = symbolSet->signal_changed().connect( sigc::mem_fun(*this, &SymbolsDialog::rebuild)); instanceConns.push_back(connSet); @@ -183,14 +161,9 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : Gtk::ScrolledWindow *scroller = new Gtk::ScrolledWindow(); scroller->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS); scroller->add(*Gtk::manage(iconView)); - -#if WITH_GTKMM_3_0 scroller->set_hexpand(); scroller->set_vexpand(); table->attach(*Gtk::manage(scroller),0,row,2,1); -#else - table->attach(*Gtk::manage(scroller),0,2,row,row+1,Gtk::EXPAND|Gtk::FILL,Gtk::EXPAND|Gtk::FILL); -#endif ++row; @@ -199,12 +172,8 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : Gtk::HBox* tools = new Gtk::HBox(); //tools->set_layout( Gtk::BUTTONBOX_END ); -#if WITH_GTKMM_3_0 scroller->set_hexpand(); table->attach(*Gtk::manage(tools),0,row,2,1); -#else - table->attach(*Gtk::manage(tools),0,2,row,row+1,Gtk::EXPAND|Gtk::FILL,Gtk::FILL); -#endif addSymbol = Gtk::manage(new Gtk::Button()); addSymbol->add(*Gtk::manage(Glib::wrap( @@ -398,11 +367,7 @@ void SymbolsDialog::revertSymbol() { void SymbolsDialog::iconDragDataGet(const Glib::RefPtr& /*context*/, Gtk::SelectionData& data, guint /*info*/, guint /*time*/) { -#if WITH_GTKMM_3_0 - std::vector iconArray = iconView->get_selected_items(); -#else - Gtk::IconView::ArrayHandle_TreePaths iconArray = iconView->get_selected_items(); -#endif + auto iconArray = iconView->get_selected_items(); if( iconArray.empty() ) { //std::cout << " iconArray empty: huh? " << std::endl; @@ -455,11 +420,7 @@ SPDocument* SymbolsDialog::selectedSymbols() { Glib::ustring SymbolsDialog::selectedSymbolId() { -#if WITH_GTKMM_3_0 - std::vector iconArray = iconView->get_selected_items(); -#else - Gtk::IconView::ArrayHandle_TreePaths iconArray = iconView->get_selected_items(); -#endif + auto iconArray = iconView->get_selected_items(); if( !iconArray.empty() ) { Gtk::TreeModel::Path const & path = *iconArray.begin(); diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp index c99c1bff3..be91ca8af 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -980,12 +980,8 @@ TagsPanel::TagsPanel() : _scroller.set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC ); _scroller.set_shadow_type(Gtk::SHADOW_IN); Gtk::Requisition sreq; -#if WITH_GTKMM_3_0 Gtk::Requisition sreq_natural; _scroller.get_preferred_size(sreq_natural, sreq); -#else - sreq = _scroller.size_request(); -#endif int minHeight = 70; if (sreq.height < minHeight) { // Set a min height to see the layers when used with Ubuntu liboverlay-scrollbar diff --git a/src/ui/dialog/tags.h b/src/ui/dialog/tags.h index 3576bd111..bdda22dd4 100644 --- a/src/ui/dialog/tags.h +++ b/src/ui/dialog/tags.h @@ -141,15 +141,9 @@ private: Gtk::TreeView _tree; Gtk::CellRendererText *_text_renderer; Gtk::TreeView::Column *_name_column; -#if WITH_GTKMM_3_0 Gtk::Box _buttonsRow; Gtk::Box _buttonsPrimary; Gtk::Box _buttonsSecondary; -#else - Gtk::HBox _buttonsRow; - Gtk::HBox _buttonsPrimary; - Gtk::HBox _buttonsSecondary; -#endif Gtk::ScrolledWindow _scroller; Gtk::Menu _popupMenu; Inkscape::UI::Widget::SpinButton _spinBtn; diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index c01da8864..83b636ae2 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -99,9 +99,7 @@ TextEdit::TextEdit() styleButton(&align_right, _("Align right"), INKSCAPE_ICON("format-justify-right"), &align_left); styleButton(&align_justify, _("Justify (only flowed text)"), INKSCAPE_ICON("format-justify-fill"), &align_left); -#if WITH_GTKMM_3_0 align_sep.set_orientation(Gtk::ORIENTATION_VERTICAL); -#endif layout_hbox.pack_start(align_sep, false, false, 10); @@ -109,9 +107,7 @@ TextEdit::TextEdit() styleButton(&text_horizontal, _("Horizontal text"), INKSCAPE_ICON("format-text-direction-horizontal"), NULL); styleButton(&text_vertical, _("Vertical text"), INKSCAPE_ICON("format-text-direction-vertical"), &text_horizontal); -#if WITH_GTKMM_3_0 text_sep.set_orientation(Gtk::ORIENTATION_VERTICAL); -#endif layout_hbox.pack_start(text_sep, false, false, 10); @@ -146,12 +142,8 @@ TextEdit::TextEdit() gtk_widget_set_tooltip_text(startOffset, _("Text path offset")); -#if WITH_GTKMM_3_0 - Gtk::Separator *sep = Gtk::manage(new Gtk::Separator()); + auto sep = Gtk::manage(new Gtk::Separator()); sep->set_orientation(Gtk::ORIENTATION_VERTICAL); -#else - Gtk::VSeparator *sep = Gtk::manage(new Gtk::VSeparator); -#endif layout_hbox.pack_start(*sep, false, false, 10); layout_hbox.pack_start(*Gtk::manage(Glib::wrap(startOffset)), false, false); @@ -175,7 +167,6 @@ TextEdit::TextEdit() gtk_text_view_set_wrap_mode ((GtkTextView *) text_view, GTK_WRAP_WORD); #ifdef WITH_GTKSPELL -#ifdef WITH_GTKMM_3_0 /* TODO: Use computed xml:lang attribute of relevant element, if present, to specify the language (either as 2nd arg of gtkspell_new_attach, or with explicit @@ -187,20 +178,6 @@ TextEdit::TextEdit() if (! gtk_spell_checker_attach(speller, GTK_TEXT_VIEW(text_view))) { g_print("gtkspell error:\n"); } -#else - GError *error = NULL; - -/* - TODO: Use computed xml:lang attribute of relevant element, if present, to specify the - language (either as 2nd arg of gtkspell_new_attach, or with explicit - gtkspell_set_language call in; see advanced.c example in gtkspell docs). - onReadSelection looks like a suitable place. -*/ - if (gtkspell_new_attach(GTK_TEXT_VIEW(text_view), NULL, &error) == NULL) { - g_print("gtkspell error: %s\n", error->message); - g_error_free(error); - } -#endif #endif gtk_widget_set_size_request (text_view, -1, 64); diff --git a/src/ui/dialog/text-edit.h b/src/ui/dialog/text-edit.h index cfe612268..e974874d2 100644 --- a/src/ui/dialog/text-edit.h +++ b/src/ui/dialog/text-edit.h @@ -198,21 +198,10 @@ private: Gtk::RadioButton align_center; Gtk::RadioButton align_right; Gtk::RadioButton align_justify; - -#if WITH_GTKMM_3_0 Gtk::Separator align_sep; -#else - Gtk::VSeparator align_sep; -#endif - Gtk::RadioButton text_vertical; Gtk::RadioButton text_horizontal; - -#if WITH_GTKMM_3_0 Gtk::Separator text_sep; -#else - Gtk::VSeparator text_sep; -#endif GtkWidget *spacing_combo; diff --git a/src/ui/dialog/tile.h b/src/ui/dialog/tile.h index de1d3028b..2c29f85b8 100644 --- a/src/ui/dialog/tile.h +++ b/src/ui/dialog/tile.h @@ -29,12 +29,7 @@ namespace Gtk { class Button; - -#if WITH_GTKMM_3_0 class Grid; -#else -class Table; -#endif } namespace Inkscape { diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index b7638e8c1..72133f448 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -216,38 +216,20 @@ void Transformation::layoutPageMove() //_scalar_move_vertical.set_label_image( INKSCAPE_STOCK_ARROWS_HOR ); -#if WITH_GTKMM_3_0 _page_move.table().attach(_scalar_move_horizontal, 0, 0, 2, 1); _page_move.table().attach(_units_move, 2, 0, 1, 1); -#else - _page_move.table() - .attach(_scalar_move_horizontal, 0, 2, 0, 1, Gtk::FILL, Gtk::SHRINK); - - _page_move.table() - .attach(_units_move, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK); -#endif _scalar_move_horizontal.signal_value_changed() .connect(sigc::mem_fun(*this, &Transformation::onMoveValueChanged)); //_scalar_move_vertical.set_label_image( INKSCAPE_STOCK_ARROWS_VER ); -#if WITH_GTKMM_3_0 _page_move.table().attach(_scalar_move_vertical, 0, 1, 2, 1); -#else - _page_move.table() - .attach(_scalar_move_vertical, 0, 2, 1, 2, Gtk::FILL, Gtk::SHRINK); -#endif _scalar_move_vertical.signal_value_changed() .connect(sigc::mem_fun(*this, &Transformation::onMoveValueChanged)); // Relative moves -#if WITH_GTKMM_3_0 _page_move.table().attach(_check_move_relative, 0, 2, 2, 1); -#else - _page_move.table() - .attach(_check_move_relative, 0, 2, 2, 3, Gtk::FILL, Gtk::SHRINK); -#endif _check_move_relative.set_active(true); _check_move_relative.signal_toggled() @@ -273,36 +255,18 @@ void Transformation::layoutPageScale() _scalar_scale_vertical.setAbsoluteIsIncrement(true); _scalar_scale_vertical.setPercentageIsIncrement(true); -#if WITH_GTKMM_3_0 _page_scale.table().attach(_scalar_scale_horizontal, 0, 0, 2, 1); -#else - _page_scale.table() - .attach(_scalar_scale_horizontal, 0, 2, 0, 1, Gtk::FILL, Gtk::SHRINK); -#endif _scalar_scale_horizontal.signal_value_changed() .connect(sigc::mem_fun(*this, &Transformation::onScaleXValueChanged)); -#if WITH_GTKMM_3_0 _page_scale.table().attach(_units_scale, 2, 0, 1, 1); _page_scale.table().attach(_scalar_scale_vertical, 0, 1, 2, 1); -#else - _page_scale.table() - .attach(_units_scale, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK); - - _page_scale.table() - .attach(_scalar_scale_vertical, 0, 2, 1, 2, Gtk::FILL, Gtk::SHRINK); -#endif _scalar_scale_vertical.signal_value_changed() .connect(sigc::mem_fun(*this, &Transformation::onScaleYValueChanged)); -#if WITH_GTKMM_3_0 _page_scale.table().attach(_check_scale_proportional, 0, 2, 2, 1); -#else - _page_scale.table() - .attach(_check_scale_proportional, 0, 2, 2, 3, Gtk::FILL, Gtk::SHRINK); -#endif _check_scale_proportional.set_active(false); _check_scale_proportional.signal_toggled() @@ -334,24 +298,10 @@ void Transformation::layoutPageRotate() Gtk::RadioButton::Group group = _counterclockwise_rotate.get_group(); _clockwise_rotate.set_group(group); -#if WITH_GTKMM_3_0 _page_rotate.table().attach(_scalar_rotate, 0, 0, 2, 1); _page_rotate.table().attach(_units_rotate, 2, 0, 1, 1); _page_rotate.table().attach(_counterclockwise_rotate, 3, 0, 1, 1); _page_rotate.table().attach(_clockwise_rotate, 4, 0, 1, 1); -#else - _page_rotate.table() - .attach(_scalar_rotate, 0, 2, 0, 1, Gtk::FILL, Gtk::SHRINK); - - _page_rotate.table() - .attach(_units_rotate, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK); - - _page_rotate.table() - .attach(_counterclockwise_rotate, 3, 4, 0, 1, Gtk::SHRINK, Gtk::SHRINK); - - _page_rotate.table() - .attach(_clockwise_rotate, 4, 5, 0, 1, Gtk::SHRINK, Gtk::SHRINK); -#endif Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/dialogs/transformation/rotateCounterClockwise", TRUE)) { @@ -385,26 +335,13 @@ void Transformation::layoutPageSkew() _scalar_skew_vertical.setDigits(3); _scalar_skew_vertical.setIncrements(0.1, 1.0); -#if WITH_GTKMM_3_0 _page_skew.table().attach(_scalar_skew_horizontal, 0, 0, 2, 1); -#else - _page_skew.table() - .attach(_scalar_skew_horizontal, 0, 2, 0, 1, Gtk::FILL, Gtk::SHRINK); -#endif _scalar_skew_horizontal.signal_value_changed() .connect(sigc::mem_fun(*this, &Transformation::onSkewValueChanged)); -#if WITH_GTKMM_3_0 _page_skew.table().attach(_units_skew, 2, 0, 1, 1); _page_skew.table().attach(_scalar_skew_vertical, 0, 1, 2, 1); -#else - _page_skew.table() - .attach(_units_skew, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK); - - _page_skew.table() - .attach(_scalar_skew_vertical, 0, 2, 1, 2, Gtk::FILL, Gtk::SHRINK); -#endif _scalar_skew_vertical.signal_value_changed() .connect(sigc::mem_fun(*this, &Transformation::onSkewValueChanged)); @@ -422,12 +359,7 @@ void Transformation::layoutPageTransform() _scalar_transform_a.setIncrements(0.1, 1.0); _scalar_transform_a.setValue(1.0); -#if WITH_GTKMM_3_0 _page_transform.table().attach(_scalar_transform_a, 0, 0, 1, 1); -#else - _page_transform.table() - .attach(_scalar_transform_a, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK); -#endif _scalar_transform_a.signal_value_changed() .connect(sigc::mem_fun(*this, &Transformation::onTransformValueChanged)); @@ -438,12 +370,7 @@ void Transformation::layoutPageTransform() _scalar_transform_b.setIncrements(0.1, 1.0); _scalar_transform_b.setValue(0.0); -#if WITH_GTKMM_3_0 _page_transform.table().attach(_scalar_transform_b, 0, 1, 1, 1); -#else - _page_transform.table() - .attach(_scalar_transform_b, 0, 1, 1, 2, Gtk::SHRINK, Gtk::SHRINK); -#endif _scalar_transform_b.signal_value_changed() .connect(sigc::mem_fun(*this, &Transformation::onTransformValueChanged)); @@ -454,12 +381,7 @@ void Transformation::layoutPageTransform() _scalar_transform_c.setIncrements(0.1, 1.0); _scalar_transform_c.setValue(0.0); -#if WITH_GTKMM_3_0 _page_transform.table().attach(_scalar_transform_c, 1, 0, 1, 1); -#else - _page_transform.table() - .attach(_scalar_transform_c, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK); -#endif _scalar_transform_c.signal_value_changed() .connect(sigc::mem_fun(*this, &Transformation::onTransformValueChanged)); @@ -471,12 +393,7 @@ void Transformation::layoutPageTransform() _scalar_transform_d.setIncrements(0.1, 1.0); _scalar_transform_d.setValue(1.0); -#if WITH_GTKMM_3_0 _page_transform.table().attach(_scalar_transform_d, 1, 1, 1, 1); -#else - _page_transform.table() - .attach(_scalar_transform_d, 1, 2, 1, 2, Gtk::SHRINK, Gtk::SHRINK); -#endif _scalar_transform_d.signal_value_changed() .connect(sigc::mem_fun(*this, &Transformation::onTransformValueChanged)); @@ -488,12 +405,7 @@ void Transformation::layoutPageTransform() _scalar_transform_e.setIncrements(0.1, 1.0); _scalar_transform_e.setValue(0.0); -#if WITH_GTKMM_3_0 _page_transform.table().attach(_scalar_transform_e, 2, 0, 1, 1); -#else - _page_transform.table() - .attach(_scalar_transform_e, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK); -#endif _scalar_transform_e.signal_value_changed() .connect(sigc::mem_fun(*this, &Transformation::onTransformValueChanged)); @@ -505,23 +417,13 @@ void Transformation::layoutPageTransform() _scalar_transform_f.setIncrements(0.1, 1.0); _scalar_transform_f.setValue(0.0); -#if WITH_GTKMM_3_0 _page_transform.table().attach(_scalar_transform_f, 2, 1, 1, 1); -#else - _page_transform.table() - .attach(_scalar_transform_f, 2, 3, 1, 2, Gtk::SHRINK, Gtk::SHRINK); -#endif _scalar_transform_f.signal_value_changed() .connect(sigc::mem_fun(*this, &Transformation::onTransformValueChanged)); // Edit existing matrix -#if WITH_GTKMM_3_0 _page_transform.table().attach(_check_replace_matrix, 0, 2, 2, 1); -#else - _page_transform.table() - .attach(_check_replace_matrix, 0, 2, 2, 3, Gtk::FILL, Gtk::SHRINK); -#endif _check_replace_matrix.set_active(false); _check_replace_matrix.signal_toggled() @@ -568,11 +470,7 @@ void Transformation::updateSelection(PageType page, Inkscape::Selection *selecti selection && !selection->isEmpty()); } -#if WITH_GTKMM_3_0 void Transformation::onSwitchPage(Gtk::Widget * /*page*/, guint pagenum) -#else -void Transformation::onSwitchPage(GtkNotebookPage * /*page*/, guint pagenum) -#endif { updateSelection((PageType)pagenum, getDesktop()->getSelection()); } diff --git a/src/ui/dialog/transformation.h b/src/ui/dialog/transformation.h index 89aa95d90..9595e87bc 100644 --- a/src/ui/dialog/transformation.h +++ b/src/ui/dialog/transformation.h @@ -169,11 +169,7 @@ protected: virtual void _apply(); void presentPage(PageType page); -#if WITH_GTKMM_3_0 void onSwitchPage(Gtk::Widget *page, guint pagenum); -#else - void onSwitchPage(GtkNotebookPage *page, guint pagenum); -#endif /** * Callbacks for when a user changes values on the panels diff --git a/src/ui/dialog/undo-history.cpp b/src/ui/dialog/undo-history.cpp index a50a169eb..e7e68ed87 100644 --- a/src/ui/dialog/undo-history.cpp +++ b/src/ui/dialog/undo-history.cpp @@ -35,20 +35,11 @@ namespace UI { namespace Dialog { /* Rendering functions for custom cell renderers */ -#if WITH_GTKMM_3_0 void CellRendererSPIcon::render_vfunc(const Cairo::RefPtr& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, Gtk::CellRendererState flags) -#else -void CellRendererSPIcon::render_vfunc(const Glib::RefPtr& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags) -#endif { // if this event type doesn't have an icon... if ( !Inkscape::Verb::get(_property_event_type)->get_image() ) return; @@ -67,13 +58,8 @@ void CellRendererSPIcon::render_vfunc(const Glib::RefPtr& window, sp_icon_fetch_pixbuf(sp_icon); _property_icon = Glib::wrap(sp_icon->pb, true); } else if ( GTK_IS_IMAGE(icon->gobj()) ) { -#if WITH_GTKMM_3_0 _property_icon = Gtk::Invisible().render_icon_pixbuf(Gtk::StockID(image), Gtk::ICON_SIZE_MENU); -#else - _property_icon = Gtk::Invisible().render_icon(Gtk::StockID(image), - Gtk::ICON_SIZE_MENU); -#endif } else { delete icon; return; @@ -87,42 +73,23 @@ void CellRendererSPIcon::render_vfunc(const Glib::RefPtr& window, property_pixbuf() = _icon_cache[_property_event_type]; } -#if WITH_GTKMM_3_0 Gtk::CellRendererPixbuf::render_vfunc(cr, widget, background_area, cell_area, flags); -#else - Gtk::CellRendererPixbuf::render_vfunc(window, widget, background_area, - cell_area, expose_area, flags); -#endif } -#if WITH_GTKMM_3_0 void CellRendererInt::render_vfunc(const Cairo::RefPtr& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, Gtk::CellRendererState flags) -#else -void CellRendererInt::render_vfunc(const Glib::RefPtr& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags) -#endif { if( _filter(_property_number) ) { std::ostringstream s; s << _property_number << std::flush; property_text() = s.str(); -#if WITH_GTKMM_3_0 Gtk::CellRendererText::render_vfunc(cr, widget, background_area, cell_area, flags); -#else - Gtk::CellRendererText::render_vfunc(window, widget, background_area, - cell_area, expose_area, flags); -#endif } } diff --git a/src/ui/dialog/undo-history.h b/src/ui/dialog/undo-history.h index b0cc283cf..48929a0d0 100644 --- a/src/ui/dialog/undo-history.h +++ b/src/ui/dialog/undo-history.h @@ -50,20 +50,11 @@ public: property_event_type() { return _property_event_type.get_proxy(); } protected: -#if WITH_GTKMM_3_0 virtual void render_vfunc(const Cairo::RefPtr& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, Gtk::CellRendererState flags); -#else - virtual void render_vfunc(const Glib::RefPtr& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags); -#endif private: Glib::Property > _property_icon; @@ -95,20 +86,11 @@ public: static const Filter& no_filter; protected: -#if WITH_GTKMM_3_0 virtual void render_vfunc(const Cairo::RefPtr& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, Gtk::CellRendererState flags); -#else - virtual void render_vfunc(const Glib::RefPtr& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags); -#endif private: diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp index 99a4acc69..714d59c50 100644 --- a/src/ui/dialog/xml-tree.cpp +++ b/src/ui/dialog/xml-tree.cpp @@ -79,11 +79,7 @@ XmlTree::XmlTree (void) : xml_attribute_delete_button (_("Delete attribute")), text_container (), attr_container (), -#if WITH_GTKMM_3_0 attr_subpaned_container(Gtk::ORIENTATION_VERTICAL), -#else - attr_subpaned_container(), -#endif set_attr (_("Set")), new_window(NULL) { @@ -100,9 +96,7 @@ XmlTree::XmlTree (void) : status.set_alignment( 0.0, 0.5); status.set_size_request(1, -1); status.set_markup(""); -#if WITH_GTKMM_3_0 status.set_line_wrap(true); -#endif status_box.pack_start( status, TRUE, TRUE, 0); contents->pack_end(status_box, false, false, 2); @@ -881,31 +875,19 @@ void XmlTree::cmd_new_element_node() g_signal_connect(G_OBJECT(new_window), "destroy", gtk_main_quit, NULL); g_signal_connect(G_OBJECT(new_window), "key-press-event", G_CALLBACK(quit_on_esc), new_window); -#if GTK_CHECK_VERSION(3,0,0) vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); gtk_box_set_homogeneous(GTK_BOX(vbox), FALSE); -#else - vbox = gtk_vbox_new(FALSE, 4); -#endif gtk_container_add(GTK_CONTAINER(new_window), vbox); name_entry = new Gtk::Entry(); gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(name_entry->gobj()), FALSE, TRUE, 0); -#if GTK_CHECK_VERSION(3,0,0) sep = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); -#else - sep = gtk_hseparator_new(); -#endif gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, TRUE, 0); -#if GTK_CHECK_VERSION(3,0,0) bbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL); -#else - bbox = gtk_hbutton_box_new(); -#endif gtk_container_set_border_width(GTK_CONTAINER(bbox), 4); gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); diff --git a/src/ui/dialog/xml-tree.h b/src/ui/dialog/xml-tree.h index 58ef3aef8..a4c3fffcb 100644 --- a/src/ui/dialog/xml-tree.h +++ b/src/ui/dialog/xml-tree.h @@ -218,13 +218,7 @@ private: Gtk::Button *create_button; Gtk::Entry *name_entry; - -#if WITH_GTKMM_3_0 Gtk::Paned paned; -#else - Gtk::HPaned paned; -#endif - Gtk::VBox left_box; Gtk::VBox right_box; Gtk::HBox status_box; @@ -248,12 +242,7 @@ private: Gtk::ScrolledWindow text_container; Gtk::HBox attr_hbox; Gtk::VBox attr_container; - -#if WITH_GTKMM_3_0 Gtk::Paned attr_subpaned_container; -#else - Gtk::VPaned attr_subpaned_container; -#endif Gtk::Button set_attr; diff --git a/src/ui/previewholder.cpp b/src/ui/previewholder.cpp index 5e75179a3..8336467c4 100644 --- a/src/ui/previewholder.cpp +++ b/src/ui/previewholder.cpp @@ -18,12 +18,7 @@ #include #include #include - -#if WITH_GTKMM_3_0 -# include -#else -# include -#endif +#include #define COLUMNS_FOR_SMALL 16 #define COLUMNS_FOR_LARGE 8 @@ -55,7 +50,6 @@ PreviewHolder::PreviewHolder() : ((Gtk::ScrolledWindow *)_scroller)->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); -#if WITH_GTKMM_3_0 _insides = Gtk::manage(new Gtk::Grid()); _insides->set_name( "PreviewHolderGrid" ); _insides->set_column_spacing(8); @@ -66,21 +60,9 @@ PreviewHolder::PreviewHolder() : _scroller->set_hexpand(); _scroller->set_vexpand(); -#else - _insides = Gtk::manage(new Gtk::Table( 1, 2 )); - _insides->set_col_spacings( 8 ); - - // Add a container with the scroller and a spacer - Gtk::Table* spaceHolder = Gtk::manage( new Gtk::Table(1, 2) ); -#endif - _scroller->add( *_insides ); -#if WITH_GTKMM_3_0 spaceHolder->attach( *_scroller, 0, 0, 1, 1); -#else - spaceHolder->attach( *_scroller, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); -#endif pack_start(*spaceHolder, Gtk::PACK_EXPAND_WIDGET); } @@ -93,11 +75,7 @@ PreviewHolder::~PreviewHolder() bool PreviewHolder::on_scroll_event(GdkEventScroll *event) { // Scroll horizontally by page on mouse wheel -#if WITH_GTKMM_3_0 - Glib::RefPtr adj = dynamic_cast(_scroller)->get_hadjustment(); -#else - Gtk::Adjustment *adj = dynamic_cast(_scroller)->get_hadjustment(); -#endif + auto adj = dynamic_cast(_scroller)->get_hadjustment(); if (!adj) { return FALSE; @@ -141,7 +119,6 @@ void PreviewHolder::addPreview( Previewable* preview ) Gtk::Widget* label = Gtk::manage(preview->getPreview(PREVIEW_STYLE_BLURB, VIEW_TYPE_LIST, _baseSize, _ratio, _border)); Gtk::Widget* thing = Gtk::manage(preview->getPreview(PREVIEW_STYLE_PREVIEW, VIEW_TYPE_LIST, _baseSize, _ratio, _border)); -#if WITH_GTKMM_3_0 thing->set_hexpand(); thing->set_vexpand(); _insides->attach(*thing, 0, i, 1, 1); @@ -149,10 +126,6 @@ void PreviewHolder::addPreview( Previewable* preview ) label->set_hexpand(); label->set_valign(Gtk::ALIGN_CENTER); _insides->attach(*label, 1, i, 1, 1); -#else - _insides->attach( *thing, 0, 1, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); - _insides->attach( *label, 1, 2, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK ); -#endif } break; @@ -168,44 +141,25 @@ void PreviewHolder::addPreview( Previewable* preview ) int col = i % width; int row = i / width; -#if !WITH_GTKMM_3_0 - // If the existing grid isn't wide enough, we need to resize - // it and re-pack the existing widgets - if ( _insides && width > (int)_insides->property_n_columns() ) { - _insides->resize( height, width ); -#endif - std::vectorkids = _insides->get_children(); - int childCount = (int)kids.size(); - // g_message(" %3d resize from %d to %d (r:%d, c:%d) with %d children", i, oldWidth, width, row, col, childCount ); - - // Loop through the existing widgets and move them to new location - for ( int j = 1; j < childCount; j++ ) { - Gtk::Widget* target = kids[childCount - (j + 1)]; - int col2 = j % width; - int row2 = j / width; - Glib::RefPtr handle(target); - _insides->remove( *target ); - -#if WITH_GTKMM_3_0 - target->set_hexpand(); - target->set_vexpand(); - _insides->attach( *target, col2, row2, 1, 1); -#else - _insides->attach( *target, col2, col2+1, row2, row2+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); -#endif - } -#if WITH_GTKMM_3_0 - thing->set_hexpand(); - thing->set_vexpand(); - _insides->attach(*thing, col, row, 1, 1); -#else - } else if ( col == 0 ) { - // we just started a new row - _insides->resize( row + 1, width ); - } - - _insides->attach( *thing, col, col+1, row, row+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); -#endif + auto kids = _insides->get_children(); + int childCount = (int)kids.size(); + // g_message(" %3d resize from %d to %d (r:%d, c:%d) with %d children", i, oldWidth, width, row, col, childCount ); + + // Loop through the existing widgets and move them to new location + for ( int j = 1; j < childCount; j++ ) { + auto target = kids[childCount - (j + 1)]; + int col2 = j % width; + int row2 = j / width; + Glib::RefPtr handle(target); + _insides->remove( *target ); + + target->set_hexpand(); + target->set_vexpand(); + _insides->attach( *target, col2, row2, 1, 1); + } + thing->set_hexpand(); + thing->set_vexpand(); + _insides->attach(*thing, col, row, 1, 1); } } @@ -416,21 +370,11 @@ void PreviewHolder::rebuildUI() switch(_view) { case VIEW_TYPE_LIST: { - -#if WITH_GTKMM_3_0 _insides = Gtk::manage(new Gtk::Grid()); _insides->set_column_spacing(8); -#else - _insides = Gtk::manage(new Gtk::Table( 1, 2 )); - _insides->set_col_spacings( 8 ); -#endif if (_border == BORDER_WIDE) { -#if WITH_GTKMM_3_0 _insides->set_row_spacing(1); -#else - _insides->set_row_spacings( 1 ); -#endif } for ( unsigned int i = 0; i < items.size(); i++ ) { @@ -439,7 +383,6 @@ void PreviewHolder::rebuildUI() Gtk::Widget* thing = Gtk::manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, _view, _baseSize, _ratio, _border)); -#if WITH_GTKMM_3_0 thing->set_hexpand(); thing->set_vexpand(); _insides->attach(*thing, 0, i, 1, 1); @@ -447,10 +390,6 @@ void PreviewHolder::rebuildUI() label->set_hexpand(); label->set_valign(Gtk::ALIGN_CENTER); _insides->attach(*label, 1, i, 1, 1); -#else - _insides->attach( *thing, 0, 1, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); - _insides->attach( *label, 1, 2, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK ); -#endif } _scroller->add( *_insides ); @@ -473,28 +412,16 @@ void PreviewHolder::rebuildUI() if ( !_insides ) { calcGridSize( thing, items.size(), width, height ); -#if WITH_GTKMM_3_0 _insides = Gtk::manage(new Gtk::Grid()); if (_border == BORDER_WIDE) { _insides->set_column_spacing(1); _insides->set_row_spacing(1); } -#else - _insides = Gtk::manage(new Gtk::Table( height, width )); - if (_border == BORDER_WIDE) { - _insides->set_col_spacings( 1 ); - _insides->set_row_spacings( 1 ); - } -#endif } -#if WITH_GTKMM_3_0 thing->set_hexpand(); thing->set_vexpand(); _insides->attach( *thing, col, row, 1, 1); -#else - _insides->attach( *thing, col, col+1, row, row+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); -#endif if ( ++col >= width ) { col = 0; @@ -502,11 +429,7 @@ void PreviewHolder::rebuildUI() } } if ( !_insides ) { -#if WITH_GTKMM_3_0 _insides = Gtk::manage(new Gtk::Grid()); -#else - _insides = Gtk::manage(new Gtk::Table( 1, 2 )); -#endif } _scroller->add( *_insides ); diff --git a/src/ui/previewholder.h b/src/ui/previewholder.h index 28c0fd865..d370e8fc8 100644 --- a/src/ui/previewholder.h +++ b/src/ui/previewholder.h @@ -21,11 +21,7 @@ #include namespace Gtk { -#if WITH_GTKMM_3_0 class Grid; -#else -class Table; -#endif } #include "previewfillable.h" @@ -68,12 +64,7 @@ private: std::vector items; Gtk::Bin *_scroller; - -#if WITH_GTKMM_3_0 Gtk::Grid *_insides; -#else - Gtk::Table *_insides; -#endif int _prefCols; bool _updatesFrozen; diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 72ba499de..17debb59c 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -149,16 +149,10 @@ void ToolBase::sp_event_context_set_cursor(GdkCursorType cursor_type) { GdkDisplay *display = gdk_display_get_default(); GdkCursor *cursor = gdk_cursor_new_for_display(display, cursor_type); -#if WITH_GTKMM_3_0 if (cursor) { gdk_window_set_cursor (gtk_widget_get_window (w), cursor); g_object_unref (cursor); } -#else - gdk_window_set_cursor (gtk_widget_get_window (w), cursor); - gdk_cursor_unref (cursor); -#endif - } /** -- cgit v1.2.3 From 49a7927ecf31ace696e9e5770e8d6543c356db7a Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 28 Jul 2016 19:15:34 +0100 Subject: Finish removing GTK+ 2 fallbacks (bzr r15023.2.8) --- src/ui/dialog/export.cpp | 5 -- src/ui/dialog/font-substitution.cpp | 6 +- src/ui/interface.cpp | 32 +-------- src/ui/previewholder.cpp | 22 +----- src/ui/tools/dropper-tool.cpp | 8 --- src/ui/tools/select-tool.cpp | 8 --- src/ui/tools/tool-base.cpp | 16 ----- src/ui/widget/dock-item.h | 4 -- src/ui/widget/gimpcolorwheel.c | 137 ------------------------------------ src/ui/widget/selected-style.cpp | 8 --- src/ui/widget/spinbutton.h | 4 -- 11 files changed, 3 insertions(+), 247 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 5e7c68985..5167ca2a2 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -67,12 +67,7 @@ #include "helper/png-write.h" -#if WITH_EXT_GDL #include -#else -#include "libgdl/gdl-dock-item.h" -#endif - // required to set status message after export #include "desktop.h" diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp index f219f3db6..18a7241a4 100644 --- a/src/ui/dialog/font-substitution.cpp +++ b/src/ui/dialog/font-substitution.cpp @@ -106,11 +106,7 @@ FontSubstitution::show(Glib::ustring out, std::vector &l) cbWarning->set_label(_("Don't show this warning again")); cbWarning->show(); -#if GTK_CHECK_VERSION(3,0,0) - Gtk::Box * box = warning.get_content_area(); -#else - Gtk::Box * box = warning.get_vbox(); -#endif + auto box = warning.get_content_area(); box->set_spacing(2); box->pack_start(*scrollwindow, true, true, 4); box->pack_start(*cbSelect, false, false, 0); diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index ab29471ed..1d2fa5b34 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -79,9 +79,7 @@ #include "message-stack.h" #include "ui/dialog/layer-properties.h" -#if GTK_CHECK_VERSION(3,0,0) - #include "widgets/image-menu-item.h" -#endif +#include "widgets/image-menu-item.h" #include @@ -417,11 +415,7 @@ sp_ui_menuitem_add_icon( GtkWidget *item, gchar *icon_name ) icon = sp_icon_new( Inkscape::ICON_SIZE_MENU, icon_name ); gtk_widget_show(icon); -#if GTK_CHECK_VERSION(3,0,0) image_menu_item_set_image((ImageMenuItem *) item, icon); -#else - gtk_image_menu_item_set_image((GtkImageMenuItem *) item, icon); -#endif } // end of sp_ui_menu_add_icon void @@ -475,11 +469,7 @@ static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb if (radio) { item = gtk_radio_menu_item_new_with_mnemonic(group, action->name); } else { -#if GTK_CHECK_VERSION(3,0,0) item = image_menu_item_new_with_mnemonic(action->name); -#else - item = gtk_image_menu_item_new_with_mnemonic(action->name); -#endif } gtk_label_set_markup_with_mnemonic( GTK_LABEL(gtk_bin_get_child(GTK_BIN (item))), action->name); @@ -570,11 +560,7 @@ static bool getViewStateFromPref(Inkscape::UI::View::View *view, gchar const *pr return prefs->getBool(pref_path, true); } -#if GTK_CHECK_VERSION(3,0,0) static gboolean checkitem_update(GtkWidget *widget, cairo_t * /*cr*/, gpointer user_data) -#else -static gboolean checkitem_update(GtkWidget *widget, GdkEventExpose * /*event*/, gpointer user_data) -#endif { GtkCheckMenuItem *menuitem=GTK_CHECK_MENU_ITEM(widget); @@ -631,11 +617,7 @@ static void taskToggled(GtkCheckMenuItem *menuitem, gpointer userData) /** * Callback function to update the status of the radio buttons in the View -> Display mode menu (Normal, No Filters, Outline) and Color display mode. */ -#if GTK_CHECK_VERSION(3,0,0) static gboolean update_view_menu(GtkWidget *widget, cairo_t * /*cr*/, gpointer user_data) -#else -static gboolean update_view_menu(GtkWidget *widget, GdkEventExpose * /*event*/, gpointer user_data) -#endif { SPAction *action = (SPAction *) user_data; g_assert(action->id != NULL); @@ -679,11 +661,7 @@ static gboolean update_view_menu(GtkWidget *widget, GdkEventExpose * /*event*/, static void sp_ui_menu_append_check_item_from_verb(GtkMenu *menu, Inkscape::UI::View::View *view, gchar const *label, gchar const *tip, gchar const *pref, void (*callback_toggle)(GtkCheckMenuItem *, gpointer user_data), -#if GTK_CHECK_VERSION(3,0,0) gboolean (*callback_update)(GtkWidget *widget, cairo_t *cr, gpointer user_data), -#else - gboolean (*callback_update)(GtkWidget *widget, GdkEventExpose *event, gpointer user_data), -#endif Inkscape::Verb *verb) { unsigned int shortcut = (verb) ? sp_shortcut_get_primary(verb) : 0; @@ -707,11 +685,7 @@ sp_ui_menu_append_check_item_from_verb(GtkMenu *menu, Inkscape::UI::View::View * g_signal_connect( G_OBJECT(item), "toggled", (GCallback) callback_toggle, (void *) pref); -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect( G_OBJECT(item), "draw", (GCallback) callback_update, (void *) pref); -#else - g_signal_connect( G_OBJECT(item), "expose_event", (GCallback) callback_update, (void *) pref); -#endif (*callback_update)(item, NULL, (void *)pref); @@ -854,11 +828,7 @@ static void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, I } if (verb->get_code() != SP_VERB_NONE) { SPAction *action = verb->get_action(Inkscape::ActionContext(view)); -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect( G_OBJECT(item), "draw", (GCallback) update_view_menu, (void *) action); -#else - g_signal_connect( G_OBJECT(item), "expose_event", (GCallback) update_view_menu, (void *) action); -#endif } } else if (menu_pntr->attribute("check") != NULL) { if (verb->get_code() != SP_VERB_NONE) { diff --git a/src/ui/previewholder.cpp b/src/ui/previewholder.cpp index 8336467c4..bb7f077b0 100644 --- a/src/ui/previewholder.cpp +++ b/src/ui/previewholder.cpp @@ -259,12 +259,8 @@ void PreviewHolder::on_size_allocate( Gtk::Allocation& allocation ) if ( _insides && !_wrap && (_view != VIEW_TYPE_LIST) && (_anchor == SP_ANCHOR_NORTH || _anchor == SP_ANCHOR_SOUTH) ) { Gtk::Requisition req; -#if GTK_CHECK_VERSION(3,0,0) Gtk::Requisition req_natural; _insides->get_preferred_size(req, req_natural); -#else - req = _insides->size_request(); -#endif gint delta = allocation.get_width() - req.width; if ( (delta > 4) && req.height < allocation.get_height() ) { @@ -306,43 +302,27 @@ void PreviewHolder::calcGridSize( const Gtk::Widget* thing, int itemCount, int& if ( _anchor == SP_ANCHOR_SOUTH || _anchor == SP_ANCHOR_NORTH ) { Gtk::Requisition req; -#if GTK_CHECK_VERSION(3,0,0) Gtk::Requisition req_natural; _scroller->get_preferred_size(req, req_natural); -#else - req = _scroller->size_request(); -#endif int currW = _scroller->get_width(); if ( currW > req.width ) { req.width = currW; } -#if GTK_CHECK_VERSION(3,0,0) - Gtk::Scrollbar* hs = dynamic_cast(_scroller)->get_hscrollbar(); -#else - Gtk::HScrollbar* hs = dynamic_cast(_scroller)->get_hscrollbar(); -#endif + auto hs = dynamic_cast(_scroller)->get_hscrollbar(); if ( hs ) { Gtk::Requisition scrollReq; -#if GTK_CHECK_VERSION(3,0,0) Gtk::Requisition scrollReq_natural; hs->get_preferred_size(scrollReq, scrollReq_natural); -#else - scrollReq = hs->size_request(); -#endif // the +8 is a temporary hack req.height -= scrollReq.height + 8; } Gtk::Requisition req2; -#if GTK_CHECK_VERSION(3,0,0) Gtk::Requisition req2_natural; const_cast(thing)->get_preferred_size(req2, req2_natural); -#else - req2 = const_cast(thing)->size_request(); -#endif int h2 = ((req2.height > 0) && (req.height > req2.height)) ? (req.height / req2.height) : 1; int w2 = ((req2.width > 0) && (req.width > req2.width)) ? (req.width / req2.width) : 1; diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp index c838c27d5..fbc5f088c 100644 --- a/src/ui/tools/dropper-tool.cpp +++ b/src/ui/tools/dropper-tool.cpp @@ -121,20 +121,12 @@ void DropperTool::finish() { } if (cursor_dropper_fill) { -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(cursor_dropper_fill); -#else - gdk_cursor_unref (cursor_dropper_fill); -#endif cursor_dropper_fill = NULL; } if (cursor_dropper_stroke) { -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(cursor_dropper_stroke); -#else - gdk_cursor_unref (cursor_dropper_stroke); -#endif cursor_dropper_fill = NULL; } diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index b5ec3d88e..b29fb6979 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -128,20 +128,12 @@ SelectTool::~SelectTool() { this->_describer = NULL; if (CursorSelectDragging) { -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(CursorSelectDragging); -#else - gdk_cursor_unref (CursorSelectDragging); -#endif CursorSelectDragging = NULL; } if (CursorSelectMouseover) { -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(CursorSelectMouseover); -#else - gdk_cursor_unref (CursorSelectMouseover); -#endif CursorSelectMouseover = NULL; } } diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 17debb59c..d504d82eb 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -118,11 +118,7 @@ ToolBase::~ToolBase() { } if (this->cursor != NULL) { -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(this->cursor); -#else - gdk_cursor_unref(this->cursor); -#endif this->cursor = NULL; } @@ -182,11 +178,7 @@ void ToolBase::sp_event_context_update_cursor() { ); if (pixbuf != NULL) { if (this->cursor) { -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(this->cursor); -#else - gdk_cursor_unref(this->cursor); -#endif } this->cursor = gdk_cursor_new_from_pixbuf(display, pixbuf, this->hot_x, this->hot_y); g_object_unref(pixbuf); @@ -196,11 +188,7 @@ void ToolBase::sp_event_context_update_cursor() { if (pixbuf) { if (this->cursor) { -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(this->cursor); -#else - gdk_cursor_unref(this->cursor); -#endif } this->cursor = gdk_cursor_new_from_pixbuf(display, pixbuf, this->hot_x, this->hot_y); @@ -771,11 +759,9 @@ bool ToolBase::root_handler(GdkEvent* event) { int const wheel_scroll = prefs->getIntLimited( "/options/wheelscroll/value", 40, 0, 1000); -#if GTK_CHECK_VERSION(3,0,0) // Size of smooth-scrolls (only used in GTK+ 3) gdouble delta_x = 0; gdouble delta_y = 0; -#endif /* shift + wheel, pan left--right */ if (event->scroll.state & GDK_SHIFT_MASK) { @@ -836,12 +822,10 @@ bool ToolBase::root_handler(GdkEvent* event) { desktop->scroll_world(-wheel_scroll, 0); break; -#if GTK_CHECK_VERSION(3,0,0) case GDK_SCROLL_SMOOTH: gdk_event_get_scroll_deltas(event, &delta_x, &delta_y); desktop->scroll_world(delta_x, delta_y); break; -#endif } } break; diff --git a/src/ui/widget/dock-item.h b/src/ui/widget/dock-item.h index 25a69d94c..2df45b207 100644 --- a/src/ui/widget/dock-item.h +++ b/src/ui/widget/dock-item.h @@ -19,11 +19,7 @@ #include #include -#if WITH_EXT_GDL #include -#else -#include "libgdl/gdl.h" -#endif namespace Gtk { class HButtonBox; diff --git a/src/ui/widget/gimpcolorwheel.c b/src/ui/widget/gimpcolorwheel.c index d54486505..212391497 100644 --- a/src/ui/widget/gimpcolorwheel.c +++ b/src/ui/widget/gimpcolorwheel.c @@ -110,7 +110,6 @@ static gboolean gimp_color_wheel_button_release (GtkWidget *widget, GdkEventButton *event); static gboolean gimp_color_wheel_motion (GtkWidget *widget, GdkEventMotion *event); -#if GTK_CHECK_VERSION(3,0,0) static gboolean gimp_color_wheel_draw (GtkWidget *widget, cairo_t *cr); static void gimp_color_wheel_get_preferred_width (GtkWidget *widget, @@ -119,13 +118,6 @@ static void gimp_color_wheel_get_preferred_width (GtkWidget *widget, static void gimp_color_wheel_get_preferred_height (GtkWidget *widget, gint *minimum_height, gint *natural_height); -#else -static gboolean gimp_color_wheel_expose (GtkWidget *widget, - GdkEventExpose *event); -static void gimp_color_wheel_size_request (GtkWidget *widget, - GtkRequisition *requisition); -#endif - static gboolean gimp_color_wheel_grab_broken (GtkWidget *widget, GdkEventGrabBroken *event); static gboolean gimp_color_wheel_focus (GtkWidget *widget, @@ -157,16 +149,9 @@ gimp_color_wheel_class_init (GimpColorWheelClass *class) widget_class->button_press_event = gimp_color_wheel_button_press; widget_class->button_release_event = gimp_color_wheel_button_release; widget_class->motion_notify_event = gimp_color_wheel_motion; - -#if GTK_CHECK_VERSION(3,0,0) widget_class->get_preferred_width = gimp_color_wheel_get_preferred_width; widget_class->get_preferred_height = gimp_color_wheel_get_preferred_height; widget_class->draw = gimp_color_wheel_draw; -#else - widget_class->size_request = gimp_color_wheel_size_request; - widget_class->expose_event = gimp_color_wheel_expose; -#endif - widget_class->focus = gimp_color_wheel_focus; widget_class->grab_broken_event = gimp_color_wheel_grab_broken; @@ -302,10 +287,6 @@ gimp_color_wheel_realize (GtkWidget *widget) priv->window = gdk_window_new (parent_window, &attr, attr_mask); gdk_window_set_user_data (priv->window, wheel); - -#if !GTK_CHECK_VERSION(3,0,0) - gtk_widget_style_attach (widget); -#endif } static void @@ -321,7 +302,6 @@ gimp_color_wheel_unrealize (GtkWidget *widget) GTK_WIDGET_CLASS (parent_class)->unrealize (widget); } -#if GTK_CHECK_VERSION(3,0,0) static void gimp_color_wheel_get_preferred_width (GtkWidget *widget, gint *minimum_width, @@ -353,23 +333,6 @@ gimp_color_wheel_get_preferred_height (GtkWidget *widget, *minimum_height = *natural_height = DEFAULT_SIZE + 2 * (focus_width + focus_pad); } -#else -static void -gimp_color_wheel_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - gint focus_width; - gint focus_pad; - - gtk_widget_style_get (widget, - "focus-line-width", &focus_width, - "focus-padding", &focus_pad, - NULL); - - requisition->width = DEFAULT_SIZE + 2 * (focus_width + focus_pad); - requisition->height = DEFAULT_SIZE + 2 * (focus_width + focus_pad); -} -#endif static void gimp_color_wheel_size_allocate (GtkWidget *widget, @@ -688,7 +651,6 @@ set_cross_grab (GimpColorWheel *wheel, gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (wheel)), GDK_CROSSHAIR); -#if GTK_CHECK_VERSION(3,0,0) gdk_device_grab (gtk_get_current_event_device(), priv->window, GDK_OWNERSHIP_NONE, @@ -698,14 +660,6 @@ set_cross_grab (GimpColorWheel *wheel, GDK_BUTTON_RELEASE_MASK, cursor, time); g_object_unref (cursor); -#else - gdk_pointer_grab (priv->window, FALSE, - GDK_POINTER_MOTION_MASK | - GDK_POINTER_MOTION_HINT_MASK | - GDK_BUTTON_RELEASE_MASK, - NULL, cursor, time); - gdk_cursor_unref (cursor); -#endif } static gboolean gimp_color_wheel_grab_broken(GtkWidget *widget, GdkEventGrabBroken *event) @@ -805,13 +759,8 @@ gimp_color_wheel_button_release (GtkWidget *widget, else g_assert_not_reached (); -#if GTK_CHECK_VERSION(3,0,0) gdk_device_ungrab (gtk_get_current_event_device(), event->time); -#else - gdk_display_pointer_ungrab (gdk_window_get_display (event->window), - event->time); -#endif return TRUE; } @@ -859,11 +808,7 @@ static void paint_ring (GimpColorWheel *wheel, cairo_t *cr) { -#if GTK_CHECK_VERSION(3,0,0) GtkWidget *widget = GTK_WIDGET (wheel); -#else - GtkAllocation allocation; -#endif GimpColorWheelPrivate *priv = wheel->priv; gint width, height; gint xx, yy; @@ -879,14 +824,8 @@ paint_ring (GimpColorWheel *wheel, cairo_t *source_cr; gint stride; -#if GTK_CHECK_VERSION(3,0,0) width = gtk_widget_get_allocated_width (widget); height = gtk_widget_get_allocated_height (widget); -#else - gtk_widget_get_allocation (GTK_WIDGET (wheel), &allocation); - width = allocation.width; - height = allocation.height; -#endif center_x = width / 2.0; center_y = height / 2.0; @@ -1027,19 +966,10 @@ paint_triangle (GimpColorWheel *wheel, gdouble r, g, b; gint stride; gint width, height; -#if GTK_CHECK_VERSION(3,0,0) GtkStyleContext *context; width = gtk_widget_get_allocated_width (widget); height = gtk_widget_get_allocated_height (widget); -#else - gchar *detail; - - GtkAllocation allocation; - gtk_widget_get_allocation (widget, &allocation); - width = allocation.width; - height = allocation.height; -#endif /* Compute triangle's vertices */ @@ -1180,28 +1110,18 @@ paint_triangle (GimpColorWheel *wheel, b = priv->v; hsv_to_rgb (&r, &g, &b); -#if GTK_CHECK_VERSION(3,0,0) context = gtk_widget_get_style_context (widget); gtk_style_context_save (context); -#endif if (INTENSITY (r, g, b) > 0.5) { -#if GTK_CHECK_VERSION(3,0,0) gtk_style_context_add_class (context, "light-area-focus"); -#else - detail = "colorwheel_light"; -#endif cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); } else { -#if GTK_CHECK_VERSION(3,0,0) gtk_style_context_add_class (context, "dark-area-focus"); -#else - detail = "colorwheel_dark"; -#endif cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); } @@ -1224,31 +1144,16 @@ paint_triangle (GimpColorWheel *wheel, "focus-padding", &focus_pad, NULL); -#if GTK_CHECK_VERSION(3,0,0) gtk_render_focus (context, cr, xx - FOCUS_RADIUS - focus_width - focus_pad, yy - FOCUS_RADIUS - focus_width - focus_pad, 2 * (FOCUS_RADIUS + focus_width + focus_pad), 2 * (FOCUS_RADIUS + focus_width + focus_pad)); -#else - gtk_widget_get_allocation (widget, &allocation); - gtk_paint_focus (gtk_widget_get_style (widget), - gtk_widget_get_window (widget), - gtk_widget_get_state (widget), - NULL, widget, detail, - allocation.x + xx - FOCUS_RADIUS - focus_width - focus_pad, - allocation.y + yy - FOCUS_RADIUS - focus_width - focus_pad, - 2 * (FOCUS_RADIUS + focus_width + focus_pad), - 2 * (FOCUS_RADIUS + focus_width + focus_pad)); -#endif } -#if GTK_CHECK_VERSION(3,0,0) gtk_style_context_restore (context); -#endif } -#if GTK_CHECK_VERSION(3,0,0) static gboolean gimp_color_wheel_draw (GtkWidget *widget, cairo_t *cr) @@ -1273,48 +1178,6 @@ gimp_color_wheel_draw (GtkWidget *widget, return FALSE; } -#else -static gint -gimp_color_wheel_expose (GtkWidget *widget, - GdkEventExpose *event) -{ - cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget)); - - GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget); - GimpColorWheelPrivate *priv = wheel->priv; - gboolean draw_focus; - GtkAllocation allocation; - - if (! (event->window == gtk_widget_get_window (widget) && - gtk_widget_is_drawable (widget))) - return FALSE; - - gdk_cairo_region (cr, event->region); - cairo_clip (cr); - - gtk_widget_get_allocation (widget, &allocation); - cairo_translate (cr, allocation.x, allocation.y); - - draw_focus = gtk_widget_has_focus (widget); - - paint_ring (wheel, cr); - paint_triangle (wheel, cr, draw_focus); - - cairo_destroy (cr); - - if (draw_focus && priv->focus_on_ring) - gtk_paint_focus (gtk_widget_get_style (widget), - gtk_widget_get_window (widget), - gtk_widget_get_state (widget), - &event->area, widget, NULL, - allocation.x, - allocation.y, - allocation.width, - allocation.height); - - return FALSE; -} -#endif static gboolean gimp_color_wheel_focus (GtkWidget *widget, diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 7679fadb4..418cd13ae 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -1320,11 +1320,7 @@ RotateableSwatch::do_motion(double by, guint modifier) { g_object_unref(pixbuf); gdk_window_set_cursor(gtk_widget_get_window(w), cr); -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(cr); -#else - gdk_cursor_unref(cr); -#endif cr = NULL; cr_set = true; } @@ -1388,11 +1384,7 @@ RotateableSwatch::do_release(double by, guint modifier) { GtkWidget *w = GTK_WIDGET(gobj()); gdk_window_set_cursor(gtk_widget_get_window(w), NULL); if (cr) { -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(cr); -#else - gdk_cursor_unref (cr); -#endif cr = NULL; } cr_set = false; diff --git a/src/ui/widget/spinbutton.h b/src/ui/widget/spinbutton.h index 30ffc7d77..ae571994b 100644 --- a/src/ui/widget/spinbutton.h +++ b/src/ui/widget/spinbutton.h @@ -36,11 +36,7 @@ public: { connect_signals(); }; -#if GTK_CHECK_VERSION(3,0,0) explicit SpinButton(Glib::RefPtr& adjustment, double climb_rate = 0.0, guint digits = 0) -#else - explicit SpinButton(Gtk::Adjustment& adjustment, double climb_rate = 0.0, guint digits = 0) -#endif : Gtk::SpinButton(adjustment, climb_rate, digits), _unit_menu(NULL), _unit_tracker(NULL), -- cgit v1.2.3 From cc54d0bc9da8aafcb3d4a6529d829f76f218dc29 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 4 Aug 2016 10:22:20 +0100 Subject: Fix Win32 build Fixed bugs: - https://launchpad.net/bugs/1609572 (bzr r15037) --- src/ui/dialog/filedialog.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/filedialog.cpp b/src/ui/dialog/filedialog.cpp index ee673aecf..0d4fa5c84 100644 --- a/src/ui/dialog/filedialog.cpp +++ b/src/ui/dialog/filedialog.cpp @@ -15,7 +15,11 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "filedialogimpl-win32.h" +#ifdef WIN32 +# include "filedialogimpl-win32.h" +# include "preferences.h" +#endif + #include "filedialogimpl-gtkmm.h" #include "ui/dialog-events.h" -- cgit v1.2.3 From 4f02d390a622c0e95f52c850e07578abbe0ddf7d Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 7 Aug 2016 14:41:48 +0100 Subject: aboutbox: Gtkmmify (bzr r15043.1.1) --- src/ui/dialog/aboutbox.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp index ffb46fd1b..04cf9d02a 100644 --- a/src/ui/dialog/aboutbox.cpp +++ b/src/ui/dialog/aboutbox.cpp @@ -129,12 +129,13 @@ AboutBox::AboutBox() : Gtk::Dialog(_("About Inkscape")) { get_content_area()->pack_start(*manage(label), false, false); get_content_area()->pack_start(*manage(link), false, false); - Gtk::Requisition requisition; - gtk_widget_get_preferred_size(reinterpret_cast(gobj()), &requisition, NULL); + Gtk::Requisition minimum_size; + Gtk::Requisition natural_size; + get_preferred_size(minimum_size, natural_size); // allow window to shrink set_size_request(0, 0); - set_default_size(requisition.width, requisition.height); + set_default_size(minimum_size.width, minimum_size.height); } -- cgit v1.2.3 From 56fa2433ef69a260f68b8c3147ad3769ee5c8fdb Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 8 Aug 2016 11:01:15 +0100 Subject: Move GIMP widgets to their own folder (bzr r15043.1.2) --- src/ui/CMakeLists.txt | 4 - src/ui/dialog-events.h | 1 + src/ui/widget/color-icc-selector.cpp | 1 - src/ui/widget/color-notebook.h | 1 - src/ui/widget/color-scales.cpp | 1 - src/ui/widget/color-wheel-selector.cpp | 2 +- src/ui/widget/gimpcolorwheel.c | 1467 -------------------------------- src/ui/widget/gimpcolorwheel.h | 95 --- src/ui/widget/gimpspinscale.c | 969 --------------------- src/ui/widget/gimpspinscale.h | 82 -- src/ui/widget/spin-scale.cpp | 2 +- 11 files changed, 3 insertions(+), 2622 deletions(-) delete mode 100644 src/ui/widget/gimpcolorwheel.c delete mode 100644 src/ui/widget/gimpcolorwheel.h delete mode 100644 src/ui/widget/gimpspinscale.c delete mode 100644 src/ui/widget/gimpspinscale.h (limited to 'src/ui') diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 587974b90..edcc41cd2 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -130,8 +130,6 @@ set(ui_SRC widget/filter-effect-chooser.cpp widget/font-variants.cpp widget/frame.cpp - widget/gimpcolorwheel.c - widget/gimpspinscale.c widget/highlight-picker.cpp widget/imageicon.cpp widget/imagetoggler.cpp @@ -314,8 +312,6 @@ set(ui_SRC widget/filter-effect-chooser.h widget/font-variants.h widget/frame.h - widget/gimpspinscale.h - widget/gimpcolorwheel.h widget/highlight-picker.h widget/insertordericon.h widget/imageicon.h diff --git a/src/ui/dialog-events.h b/src/ui/dialog-events.h index b4a5d7c35..547cfb95d 100644 --- a/src/ui/dialog-events.h +++ b/src/ui/dialog-events.h @@ -12,6 +12,7 @@ #ifndef SEEN_DIALOG_EVENTS_H #define SEEN_DIALOG_EVENTS_H +#include /* * event callback can only accept one argument, but we need two, diff --git a/src/ui/widget/color-icc-selector.cpp b/src/ui/widget/color-icc-selector.cpp index fea6543ea..616e9afa8 100644 --- a/src/ui/widget/color-icc-selector.cpp +++ b/src/ui/widget/color-icc-selector.cpp @@ -5,7 +5,6 @@ #include #include -#include #include #include "ui/dialog-events.h" diff --git a/src/ui/widget/color-notebook.h b/src/ui/widget/color-notebook.h index 35e46ef14..0948e3d46 100644 --- a/src/ui/widget/color-notebook.h +++ b/src/ui/widget/color-notebook.h @@ -20,7 +20,6 @@ #include #include -#include #include #include "color.h" diff --git a/src/ui/widget/color-scales.cpp b/src/ui/widget/color-scales.cpp index 7fcca215f..89913b01b 100644 --- a/src/ui/widget/color-scales.cpp +++ b/src/ui/widget/color-scales.cpp @@ -8,7 +8,6 @@ #include #include -#include #include "ui/dialog-events.h" #include "ui/widget/color-scales.h" diff --git a/src/ui/widget/color-wheel-selector.cpp b/src/ui/widget/color-wheel-selector.cpp index 18f932f10..4f011c6c3 100644 --- a/src/ui/widget/color-wheel-selector.cpp +++ b/src/ui/widget/color-wheel-selector.cpp @@ -11,7 +11,7 @@ #include "ui/dialog-events.h" #include "ui/widget/color-scales.h" #include "ui/widget/color-slider.h" -#include "ui/widget/gimpcolorwheel.h" +#include "widgets/gimp/gimpcolorwheel.h" namespace Inkscape { namespace UI { diff --git a/src/ui/widget/gimpcolorwheel.c b/src/ui/widget/gimpcolorwheel.c deleted file mode 100644 index 212391497..000000000 --- a/src/ui/widget/gimpcolorwheel.c +++ /dev/null @@ -1,1467 +0,0 @@ -/* HSV color selector for GTK+ - * - * Copyright (C) 1999 The Free Software Foundation - * - * Authors: Simon Budig (original code) - * Federico Mena-Quintero (cleanup for GTK+) - * Jonathan Blandford (cleanup for GTK+) - * Michael Natterer (ported back to GIMP) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -/* - * This widget was adopted by Inkscape by Alex Valavanis - * on 2013-01-08. Last merges with GIMP code were applied using the following - * commits from the GIMP git repository at - * http://git.gnome.org/browse/gimp/tree/modules/gimpcolorwheel.c - * - * Gtk+ 2 code merge: commit 632c5 (2013-01-06) - * Gtk+ 3 code merge: commit bcfc6, gtk3-port branch (2013-01-06) - */ - -#include "config.h" - -#include -#include - -#include "gimpcolorwheel.h" -#include - - -/* Default ring fraction */ -#define DEFAULT_FRACTION 0.1 - -/* Default width/height */ -#define DEFAULT_SIZE 100 - -/* Default ring width */ -#define DEFAULT_RING_WIDTH 10 - - -/* Dragging modes */ -typedef enum -{ - DRAG_NONE, - DRAG_H, - DRAG_SV -} DragMode; - -/* Private part of the GimpColorWheel structure */ -typedef struct -{ - /* Color value */ - gdouble h; - gdouble s; - gdouble v; - - /* ring_width is this fraction of size */ - gdouble ring_fraction; - - /* Size and ring width */ - gint size; - gint ring_width; - - /* Window for capturing events */ - GdkWindow *window; - - /* Dragging mode */ - DragMode mode; - - guint focus_on_ring : 1; -} GimpColorWheelPrivate; - -enum -{ - CHANGED, - MOVE, - LAST_SIGNAL -}; - -static void gimp_color_wheel_map (GtkWidget *widget); -static void gimp_color_wheel_unmap (GtkWidget *widget); -static void gimp_color_wheel_realize (GtkWidget *widget); -static void gimp_color_wheel_unrealize (GtkWidget *widget); -static void gimp_color_wheel_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static gboolean gimp_color_wheel_button_press (GtkWidget *widget, - GdkEventButton *event); -static gboolean gimp_color_wheel_button_release (GtkWidget *widget, - GdkEventButton *event); -static gboolean gimp_color_wheel_motion (GtkWidget *widget, - GdkEventMotion *event); -static gboolean gimp_color_wheel_draw (GtkWidget *widget, - cairo_t *cr); -static void gimp_color_wheel_get_preferred_width (GtkWidget *widget, - gint *minimum_width, - gint *natural_width); -static void gimp_color_wheel_get_preferred_height (GtkWidget *widget, - gint *minimum_height, - gint *natural_height); -static gboolean gimp_color_wheel_grab_broken (GtkWidget *widget, - GdkEventGrabBroken *event); -static gboolean gimp_color_wheel_focus (GtkWidget *widget, - GtkDirectionType direction); -static void gimp_color_wheel_move (GimpColorWheel *wheel, - GtkDirectionType dir); - - -static guint wheel_signals[LAST_SIGNAL]; - -G_DEFINE_TYPE (GimpColorWheel, gimp_color_wheel, GTK_TYPE_WIDGET) - -#define parent_class gimp_color_wheel_parent_class - - -static void -gimp_color_wheel_class_init (GimpColorWheelClass *class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (class); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); - GimpColorWheelClass *wheel_class = GIMP_COLOR_WHEEL_CLASS (class); - GtkBindingSet *binding_set; - - widget_class->map = gimp_color_wheel_map; - widget_class->unmap = gimp_color_wheel_unmap; - widget_class->realize = gimp_color_wheel_realize; - widget_class->unrealize = gimp_color_wheel_unrealize; - widget_class->size_allocate = gimp_color_wheel_size_allocate; - widget_class->button_press_event = gimp_color_wheel_button_press; - widget_class->button_release_event = gimp_color_wheel_button_release; - widget_class->motion_notify_event = gimp_color_wheel_motion; - widget_class->get_preferred_width = gimp_color_wheel_get_preferred_width; - widget_class->get_preferred_height = gimp_color_wheel_get_preferred_height; - widget_class->draw = gimp_color_wheel_draw; - widget_class->focus = gimp_color_wheel_focus; - widget_class->grab_broken_event = gimp_color_wheel_grab_broken; - - wheel_class->move = gimp_color_wheel_move; - - wheel_signals[CHANGED] = - g_signal_new ("changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GimpColorWheelClass, changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - wheel_signals[MOVE] = - g_signal_new ("move", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (GimpColorWheelClass, move), - NULL, NULL, - g_cclosure_marshal_VOID__ENUM, - G_TYPE_NONE, 1, - GTK_TYPE_DIRECTION_TYPE); - - binding_set = gtk_binding_set_by_class (class); - - gtk_binding_entry_add_signal (binding_set, GDK_KEY_Up, 0, - "move", 1, - G_TYPE_ENUM, GTK_DIR_UP); - gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Up, 0, - "move", 1, - G_TYPE_ENUM, GTK_DIR_UP); - - gtk_binding_entry_add_signal (binding_set, GDK_KEY_Down, 0, - "move", 1, - G_TYPE_ENUM, GTK_DIR_DOWN); - gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Down, 0, - "move", 1, - G_TYPE_ENUM, GTK_DIR_DOWN); - - - gtk_binding_entry_add_signal (binding_set, GDK_KEY_Right, 0, - "move", 1, - G_TYPE_ENUM, GTK_DIR_RIGHT); - gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Right, 0, - "move", 1, - G_TYPE_ENUM, GTK_DIR_RIGHT); - - gtk_binding_entry_add_signal (binding_set, GDK_KEY_Left, 0, - "move", 1, - G_TYPE_ENUM, GTK_DIR_LEFT); - gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Left, 0, - "move", 1, - G_TYPE_ENUM, GTK_DIR_LEFT); - - g_type_class_add_private (object_class, sizeof (GimpColorWheelPrivate)); -} - -static void -gimp_color_wheel_init (GimpColorWheel *wheel) -{ - GimpColorWheelPrivate *priv; - - priv = G_TYPE_INSTANCE_GET_PRIVATE (wheel, GIMP_TYPE_COLOR_WHEEL, - GimpColorWheelPrivate); - - wheel->priv = priv; - - gtk_widget_set_has_window (GTK_WIDGET (wheel), FALSE); - gtk_widget_set_can_focus (GTK_WIDGET (wheel), TRUE); - - priv->ring_fraction = DEFAULT_FRACTION; - priv->size = DEFAULT_SIZE; - priv->ring_width = DEFAULT_RING_WIDTH; -} - -static void -gimp_color_wheel_map (GtkWidget *widget) -{ - GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget); - GimpColorWheelPrivate *priv = wheel->priv; - - GTK_WIDGET_CLASS (parent_class)->map (widget); - - gdk_window_show (priv->window); -} - -static void -gimp_color_wheel_unmap (GtkWidget *widget) -{ - GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget); - GimpColorWheelPrivate *priv = wheel->priv; - - gdk_window_hide (priv->window); - - GTK_WIDGET_CLASS (parent_class)->unmap (widget); -} - -static void -gimp_color_wheel_realize (GtkWidget *widget) -{ - GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget); - GimpColorWheelPrivate *priv = wheel->priv; - GtkAllocation allocation; - GdkWindowAttr attr; - gint attr_mask; - GdkWindow *parent_window; - - gtk_widget_get_allocation (widget, &allocation); - - gtk_widget_set_realized (widget, TRUE); - - attr.window_type = GDK_WINDOW_CHILD; - attr.x = allocation.x; - attr.y = allocation.y; - attr.width = allocation.width; - attr.height = allocation.height; - attr.wclass = GDK_INPUT_ONLY; - attr.event_mask = (gtk_widget_get_events (widget) | - GDK_KEY_PRESS_MASK | - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_POINTER_MOTION_MASK | - GDK_ENTER_NOTIFY_MASK | - GDK_LEAVE_NOTIFY_MASK); - - attr_mask = GDK_WA_X | GDK_WA_Y; - - parent_window = gtk_widget_get_parent_window (widget); - - gtk_widget_set_window (widget, parent_window); - g_object_ref (parent_window); - - priv->window = gdk_window_new (parent_window, &attr, attr_mask); - gdk_window_set_user_data (priv->window, wheel); -} - -static void -gimp_color_wheel_unrealize (GtkWidget *widget) -{ - GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget); - GimpColorWheelPrivate *priv = wheel->priv; - - gdk_window_set_user_data (priv->window, NULL); - gdk_window_destroy (priv->window); - priv->window = NULL; - - GTK_WIDGET_CLASS (parent_class)->unrealize (widget); -} - -static void -gimp_color_wheel_get_preferred_width (GtkWidget *widget, - gint *minimum_width, - gint *natural_width) -{ - gint focus_width; - gint focus_pad; - - gtk_widget_style_get (widget, - "focus-line-width", &focus_width, - "focus-padding", &focus_pad, - NULL); - - *minimum_width = *natural_width = DEFAULT_SIZE + 2 * (focus_width + focus_pad); -} - -static void -gimp_color_wheel_get_preferred_height (GtkWidget *widget, - gint *minimum_height, - gint *natural_height) -{ - gint focus_width; - gint focus_pad; - - gtk_widget_style_get (widget, - "focus-line-width", &focus_width, - "focus-padding", &focus_pad, - NULL); - - *minimum_height = *natural_height = DEFAULT_SIZE + 2 * (focus_width + focus_pad); -} - -static void -gimp_color_wheel_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget); - GimpColorWheelPrivate *priv = wheel->priv; - gint focus_width; - gint focus_pad; - - gtk_widget_set_allocation (widget, allocation); - - gtk_widget_style_get (widget, - "focus-line-width", &focus_width, - "focus-padding", &focus_pad, - NULL); - - priv->size = MIN (allocation->width - 2 * (focus_width + focus_pad), - allocation->height - 2 * (focus_width + focus_pad)); - - priv->ring_width = priv->size * priv->ring_fraction; - - if (gtk_widget_get_realized (widget)) - gdk_window_move_resize (priv->window, - allocation->x, - allocation->y, - allocation->width, - allocation->height); -} - - -/* Utility functions */ - -#define INTENSITY(r, g, b) ((r) * 0.30 + (g) * 0.59 + (b) * 0.11) - -/* Converts from HSV to RGB */ -static void -hsv_to_rgb (gdouble *h, - gdouble *s, - gdouble *v) -{ - gdouble hue, saturation, value; - gdouble f, p, q, t; - - if (*s == 0.0) - { - *h = *v; - *s = *v; - *v = *v; /* heh */ - } - else - { - hue = *h * 6.0; - saturation = *s; - value = *v; - - if (hue == 6.0) - hue = 0.0; - - f = hue - (int) hue; - p = value * (1.0 - saturation); - q = value * (1.0 - saturation * f); - t = value * (1.0 - saturation * (1.0 - f)); - - switch ((int) hue) - { - case 0: - *h = value; - *s = t; - *v = p; - break; - - case 1: - *h = q; - *s = value; - *v = p; - break; - - case 2: - *h = p; - *s = value; - *v = t; - break; - - case 3: - *h = p; - *s = q; - *v = value; - break; - - case 4: - *h = t; - *s = p; - *v = value; - break; - - case 5: - *h = value; - *s = p; - *v = q; - break; - - default: - g_assert_not_reached (); - } - } -} - -/* Computes the vertices of the saturation/value triangle */ -static void -compute_triangle (GimpColorWheel *wheel, - gint *hx, - gint *hy, - gint *sx, - gint *sy, - gint *vx, - gint *vy) -{ - GimpColorWheelPrivate *priv = wheel->priv; - GtkAllocation allocation; - gdouble center_x; - gdouble center_y; - gdouble inner, outer; - gdouble angle; - - gtk_widget_get_allocation (GTK_WIDGET (wheel), &allocation); - - center_x = allocation.width / 2.0; - center_y = allocation.height / 2.0; - - outer = priv->size / 2.0; - inner = outer - priv->ring_width; - angle = priv->h * 2.0 * G_PI; - - *hx = floor (center_x + cos (angle) * inner + 0.5); - *hy = floor (center_y - sin (angle) * inner + 0.5); - *sx = floor (center_x + cos (angle + 2.0 * G_PI / 3.0) * inner + 0.5); - *sy = floor (center_y - sin (angle + 2.0 * G_PI / 3.0) * inner + 0.5); - *vx = floor (center_x + cos (angle + 4.0 * G_PI / 3.0) * inner + 0.5); - *vy = floor (center_y - sin (angle + 4.0 * G_PI / 3.0) * inner + 0.5); -} - -/* Computes whether a point is inside the hue ring */ -static gboolean -is_in_ring (GimpColorWheel *wheel, - gdouble x, - gdouble y) -{ - GimpColorWheelPrivate *priv = wheel->priv; - GtkAllocation allocation; - gdouble dx, dy, dist; - gdouble center_x; - gdouble center_y; - gdouble inner, outer; - - gtk_widget_get_allocation (GTK_WIDGET (wheel), &allocation); - - center_x = allocation.width / 2.0; - center_y = allocation.height / 2.0; - - outer = priv->size / 2.0; - inner = outer - priv->ring_width; - - dx = x - center_x; - dy = center_y - y; - dist = dx * dx + dy * dy; - - return (dist >= inner * inner && dist <= outer * outer); -} - -/* Computes a saturation/value pair based on the mouse coordinates */ -static void -compute_sv (GimpColorWheel *wheel, - gdouble x, - gdouble y, - gdouble *s, - gdouble *v) -{ - GtkAllocation allocation; - gint ihx, ihy, isx, isy, ivx, ivy; - gdouble hx, hy, sx, sy, vx, vy; - gdouble center_x; - gdouble center_y; - - gtk_widget_get_allocation (GTK_WIDGET (wheel), &allocation); - - compute_triangle (wheel, &ihx, &ihy, &isx, &isy, &ivx, &ivy); - - center_x = allocation.width / 2.0; - center_y = allocation.height / 2.0; - - hx = ihx - center_x; - hy = center_y - ihy; - sx = isx - center_x; - sy = center_y - isy; - vx = ivx - center_x; - vy = center_y - ivy; - x -= center_x; - y = center_y - y; - - if (vx * (x - sx) + vy * (y - sy) < 0.0) - { - *s = 1.0; - *v = (((x - sx) * (hx - sx) + (y - sy) * (hy-sy)) - / ((hx - sx) * (hx - sx) + (hy - sy) * (hy - sy))); - - if (*v < 0.0) - *v = 0.0; - else if (*v > 1.0) - *v = 1.0; - } - else if (hx * (x - sx) + hy * (y - sy) < 0.0) - { - *s = 0.0; - *v = (((x - sx) * (vx - sx) + (y - sy) * (vy - sy)) - / ((vx - sx) * (vx - sx) + (vy - sy) * (vy - sy))); - - if (*v < 0.0) - *v = 0.0; - else if (*v > 1.0) - *v = 1.0; - } - else if (sx * (x - hx) + sy * (y - hy) < 0.0) - { - *v = 1.0; - *s = (((x - vx) * (hx - vx) + (y - vy) * (hy - vy)) / - ((hx - vx) * (hx - vx) + (hy - vy) * (hy - vy))); - - if (*s < 0.0) - *s = 0.0; - else if (*s > 1.0) - *s = 1.0; - } - else - { - *v = (((x - sx) * (hy - vy) - (y - sy) * (hx - vx)) - / ((vx - sx) * (hy - vy) - (vy - sy) * (hx - vx))); - - if (*v<= 0.0) - { - *v = 0.0; - *s = 0.0; - } - else - { - if (*v > 1.0) - *v = 1.0; - - if (fabs (hy - vy) < fabs (hx - vx)) - *s = (x - sx - *v * (vx - sx)) / (*v * (hx - vx)); - else - *s = (y - sy - *v * (vy - sy)) / (*v * (hy - vy)); - - if (*s < 0.0) - *s = 0.0; - else if (*s > 1.0) - *s = 1.0; - } - } -} - -/* Computes whether a point is inside the saturation/value triangle */ -static gboolean -is_in_triangle (GimpColorWheel *wheel, - gdouble x, - gdouble y) -{ - gint hx, hy, sx, sy, vx, vy; - gdouble det, s, v; - - compute_triangle (wheel, &hx, &hy, &sx, &sy, &vx, &vy); - - det = (vx - sx) * (hy - sy) - (vy - sy) * (hx - sx); - - s = ((x - sx) * (hy - sy) - (y - sy) * (hx - sx)) / det; - v = ((vx - sx) * (y - sy) - (vy - sy) * (x - sx)) / det; - - return (s >= 0.0 && v >= 0.0 && s + v <= 1.0); -} - -/* Computes a value based on the mouse coordinates */ -static double -compute_v (GimpColorWheel *wheel, - gdouble x, - gdouble y) -{ - GtkAllocation allocation; - gdouble center_x; - gdouble center_y; - gdouble dx, dy; - gdouble angle; - - gtk_widget_get_allocation (GTK_WIDGET (wheel), &allocation); - - center_x = allocation.width / 2.0; - center_y = allocation.height / 2.0; - - dx = x - center_x; - dy = center_y - y; - - angle = atan2 (dy, dx); - if (angle < 0.0) - angle += 2.0 * G_PI; - - return angle / (2.0 * G_PI); -} - -static void -set_cross_grab (GimpColorWheel *wheel, - guint32 time) -{ - GimpColorWheelPrivate *priv = wheel->priv; - GdkCursor *cursor; - - cursor = - gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (wheel)), - GDK_CROSSHAIR); - - gdk_device_grab (gtk_get_current_event_device(), - priv->window, - GDK_OWNERSHIP_NONE, - FALSE, - GDK_POINTER_MOTION_MASK | - GDK_POINTER_MOTION_HINT_MASK | - GDK_BUTTON_RELEASE_MASK, - cursor, time); - g_object_unref (cursor); -} - -static gboolean gimp_color_wheel_grab_broken(GtkWidget *widget, GdkEventGrabBroken *event) -{ - (void)event; - GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget); - GimpColorWheelPrivate *priv = wheel->priv; - - priv->mode = DRAG_NONE; - - return TRUE; -} - -static gboolean -gimp_color_wheel_button_press (GtkWidget *widget, - GdkEventButton *event) -{ - GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget); - GimpColorWheelPrivate *priv = wheel->priv; - gdouble x, y; - - if (priv->mode != DRAG_NONE || event->button != 1) - return FALSE; - - x = event->x; - y = event->y; - - if (is_in_ring (wheel, x, y)) - { - priv->mode = DRAG_H; - set_cross_grab (wheel, event->time); - - gimp_color_wheel_set_color (wheel, - compute_v (wheel, x, y), - priv->s, - priv->v); - - gtk_widget_grab_focus (widget); - priv->focus_on_ring = TRUE; - - return TRUE; - } - - if (is_in_triangle (wheel, x, y)) - { - gdouble s, v; - - priv->mode = DRAG_SV; - set_cross_grab (wheel, event->time); - - compute_sv (wheel, x, y, &s, &v); - gimp_color_wheel_set_color (wheel, priv->h, s, v); - - gtk_widget_grab_focus (widget); - priv->focus_on_ring = FALSE; - - return TRUE; - } - - return FALSE; -} - -static gboolean -gimp_color_wheel_button_release (GtkWidget *widget, - GdkEventButton *event) -{ - GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget); - GimpColorWheelPrivate *priv = wheel->priv; - DragMode mode; - gdouble x, y; - - if (priv->mode == DRAG_NONE || event->button != 1) - return FALSE; - - /* Set the drag mode to DRAG_NONE so that signal handlers for "catched" - * can see that this is the final color state. - */ - - mode = priv->mode; - priv->mode = DRAG_NONE; - - x = event->x; - y = event->y; - - if (mode == DRAG_H) - { - gimp_color_wheel_set_color (wheel, - compute_v (wheel, x, y), priv->s, priv->v); - } - else if (mode == DRAG_SV) - { - gdouble s, v; - - compute_sv (wheel, x, y, &s, &v); - gimp_color_wheel_set_color (wheel, priv->h, s, v); - } - else - g_assert_not_reached (); - - gdk_device_ungrab (gtk_get_current_event_device(), - event->time); - - return TRUE; -} - -static gboolean -gimp_color_wheel_motion (GtkWidget *widget, - GdkEventMotion *event) -{ - GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget); - GimpColorWheelPrivate *priv = wheel->priv; - gdouble x, y; - - if (priv->mode == DRAG_NONE) - return FALSE; - - gdk_event_request_motions (event); - x = event->x; - y = event->y; - - if (priv->mode == DRAG_H) - { - gimp_color_wheel_set_color (wheel, - compute_v (wheel, x, y), priv->s, priv->v); - return TRUE; - } - else if (priv->mode == DRAG_SV) - { - gdouble s, v; - - compute_sv (wheel, x, y, &s, &v); - gimp_color_wheel_set_color (wheel, priv->h, s, v); - return TRUE; - } - - g_assert_not_reached (); - - return FALSE; -} - - -/* Redrawing */ - -/* Paints the hue ring */ -static void -paint_ring (GimpColorWheel *wheel, - cairo_t *cr) -{ - GtkWidget *widget = GTK_WIDGET (wheel); - GimpColorWheelPrivate *priv = wheel->priv; - gint width, height; - gint xx, yy; - gdouble dx, dy, dist; - gdouble center_x; - gdouble center_y; - gdouble inner, outer; - guint32 *buf, *p; - gdouble angle; - gdouble hue; - gdouble r, g, b; - cairo_surface_t *source; - cairo_t *source_cr; - gint stride; - - width = gtk_widget_get_allocated_width (widget); - height = gtk_widget_get_allocated_height (widget); - - center_x = width / 2.0; - center_y = height / 2.0; - - outer = priv->size / 2.0; - inner = outer - priv->ring_width; - - /* Create an image initialized with the ring colors */ - - stride = cairo_format_stride_for_width (CAIRO_FORMAT_RGB24, width); - buf = g_new (guint32, height * stride / 4); - - for (yy = 0; yy < height; yy++) - { - p = buf + yy * width; - dy = -(yy - center_y); - - for (xx = 0; xx < width; xx++) - { - dx = xx - center_x; - - dist = dx * dx + dy * dy; - if (dist < ((inner-1) * (inner-1)) || dist > ((outer+1) * (outer+1))) - { - *p++ = 0; - continue; - } - - angle = atan2 (dy, dx); - if (angle < 0.0) - angle += 2.0 * G_PI; - - hue = angle / (2.0 * G_PI); - - r = hue; - g = 1.0; - b = 1.0; - hsv_to_rgb (&r, &g, &b); - - *p++ = (((int)floor (r * 255 + 0.5) << 16) | - ((int)floor (g * 255 + 0.5) << 8) | - (int)floor (b * 255 + 0.5)); - } - } - - source = cairo_image_surface_create_for_data ((unsigned char *)buf, - CAIRO_FORMAT_RGB24, - width, height, stride); - - /* Now draw the value marker onto the source image, so that it - * will get properly clipped at the edges of the ring - */ - source_cr = cairo_create (source); - - r = priv->h; - g = 1.0; - b = 1.0; - hsv_to_rgb (&r, &g, &b); - - if (INTENSITY (r, g, b) > 0.5) - cairo_set_source_rgb (source_cr, 0.0, 0.0, 0.0); - else - cairo_set_source_rgb (source_cr, 1.0, 1.0, 1.0); - - cairo_move_to (source_cr, center_x, center_y); - cairo_line_to (source_cr, - center_x + cos (priv->h * 2.0 * G_PI) * priv->size / 2, - center_y - sin (priv->h * 2.0 * G_PI) * priv->size / 2); - cairo_stroke (source_cr); - cairo_destroy (source_cr); - - /* Draw the ring using the source image */ - - cairo_save (cr); - - cairo_set_source_surface (cr, source, 0, 0); - cairo_surface_destroy (source); - - cairo_set_line_width (cr, priv->ring_width); - cairo_new_path (cr); - cairo_arc (cr, - center_x, center_y, - priv->size / 2.0 - priv->ring_width / 2.0, - 0, 2 * G_PI); - cairo_stroke (cr); - - cairo_restore (cr); - - g_free (buf); -} - -/* Converts an HSV triplet to an integer RGB triplet */ -static void -get_color (gdouble h, - gdouble s, - gdouble v, - gint *r, - gint *g, - gint *b) -{ - hsv_to_rgb (&h, &s, &v); - - *r = floor (h * 255 + 0.5); - *g = floor (s * 255 + 0.5); - *b = floor (v * 255 + 0.5); -} - -#define SWAP(a, b, t) ((t) = (a), (a) = (b), (b) = (t)) - -#define LERP(a, b, v1, v2, i) (((v2) - (v1) != 0) \ - ? ((a) + ((b) - (a)) * ((i) - (v1)) / ((v2) - (v1))) \ - : (a)) - -/* Number of pixels we extend out from the edges when creating - * color source to avoid artifacts - */ -#define PAD 3 - -/* Paints the HSV triangle */ -static void -paint_triangle (GimpColorWheel *wheel, - cairo_t *cr, - gboolean draw_focus) -{ - GtkWidget *widget = GTK_WIDGET (wheel); - GimpColorWheelPrivate *priv = wheel->priv; - gint hx, hy, sx, sy, vx, vy; /* HSV vertices */ - gint x1, y1, r1, g1, b1; /* First vertex in scanline order */ - gint x2, y2, r2, g2, b2; /* Second vertex */ - gint x3, y3, r3, g3, b3; /* Third vertex */ - gint t; - guint32 *buf, *p, c; - gint xl, xr, rl, rr, gl, gr, bl, br; /* Scanline data */ - gint xx, yy; - gint x_interp, y_interp; - gint x_start, x_end; - cairo_surface_t *source; - gdouble r, g, b; - gint stride; - gint width, height; - GtkStyleContext *context; - - width = gtk_widget_get_allocated_width (widget); - height = gtk_widget_get_allocated_height (widget); - - /* Compute triangle's vertices */ - - compute_triangle (wheel, &hx, &hy, &sx, &sy, &vx, &vy); - - x1 = hx; - y1 = hy; - get_color (priv->h, 1.0, 1.0, &r1, &g1, &b1); - - x2 = sx; - y2 = sy; - get_color (priv->h, 1.0, 0.0, &r2, &g2, &b2); - - x3 = vx; - y3 = vy; - get_color (priv->h, 0.0, 1.0, &r3, &g3, &b3); - - if (y2 > y3) - { - SWAP (x2, x3, t); - SWAP (y2, y3, t); - SWAP (r2, r3, t); - SWAP (g2, g3, t); - SWAP (b2, b3, t); - } - - if (y1 > y3) - { - SWAP (x1, x3, t); - SWAP (y1, y3, t); - SWAP (r1, r3, t); - SWAP (g1, g3, t); - SWAP (b1, b3, t); - } - - if (y1 > y2) - { - SWAP (x1, x2, t); - SWAP (y1, y2, t); - SWAP (r1, r2, t); - SWAP (g1, g2, t); - SWAP (b1, b2, t); - } - - /* Shade the triangle */ - - stride = cairo_format_stride_for_width (CAIRO_FORMAT_RGB24, width); - buf = g_new (guint32, height * stride / 4); - - for (yy = 0; yy < height; yy++) - { - p = buf + yy * width; - - if (yy >= y1 - PAD && yy < y3 + PAD) - { - y_interp = CLAMP (yy, y1, y3); - - if (y_interp < y2) - { - xl = LERP (x1, x2, y1, y2, y_interp); - - rl = LERP (r1, r2, y1, y2, y_interp); - gl = LERP (g1, g2, y1, y2, y_interp); - bl = LERP (b1, b2, y1, y2, y_interp); - } - else - { - xl = LERP (x2, x3, y2, y3, y_interp); - - rl = LERP (r2, r3, y2, y3, y_interp); - gl = LERP (g2, g3, y2, y3, y_interp); - bl = LERP (b2, b3, y2, y3, y_interp); - } - - xr = LERP (x1, x3, y1, y3, y_interp); - - rr = LERP (r1, r3, y1, y3, y_interp); - gr = LERP (g1, g3, y1, y3, y_interp); - br = LERP (b1, b3, y1, y3, y_interp); - - if (xl > xr) - { - SWAP (xl, xr, t); - SWAP (rl, rr, t); - SWAP (gl, gr, t); - SWAP (bl, br, t); - } - - x_start = MAX (xl - PAD, 0); - x_end = MIN (xr + PAD, width); - x_start = MIN (x_start, x_end); - - c = (rl << 16) | (gl << 8) | bl; - - for (xx = 0; xx < x_start; xx++) - *p++ = c; - - for (; xx < x_end; xx++) - { - x_interp = CLAMP (xx, xl, xr); - - *p++ = ((LERP (rl, rr, xl, xr, x_interp) << 16) | - (LERP (gl, gr, xl, xr, x_interp) << 8) | - LERP (bl, br, xl, xr, x_interp)); - } - - c = (rr << 16) | (gr << 8) | br; - - for (; xx < width; xx++) - *p++ = c; - } - } - - source = cairo_image_surface_create_for_data ((unsigned char *)buf, - CAIRO_FORMAT_RGB24, - width, height, stride); - - /* Draw a triangle with the image as a source */ - - cairo_set_source_surface (cr, source, 0, 0); - cairo_surface_destroy (source); - - cairo_move_to (cr, x1, y1); - cairo_line_to (cr, x2, y2); - cairo_line_to (cr, x3, y3); - cairo_close_path (cr); - cairo_fill (cr); - - g_free (buf); - - /* Draw value marker */ - - xx = floor (sx + (vx - sx) * priv->v + (hx - vx) * priv->s * priv->v + 0.5); - yy = floor (sy + (vy - sy) * priv->v + (hy - vy) * priv->s * priv->v + 0.5); - - r = priv->h; - g = priv->s; - b = priv->v; - hsv_to_rgb (&r, &g, &b); - - context = gtk_widget_get_style_context (widget); - - gtk_style_context_save (context); - - if (INTENSITY (r, g, b) > 0.5) - { - gtk_style_context_add_class (context, "light-area-focus"); - cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); - } - else - { - gtk_style_context_add_class (context, "dark-area-focus"); - cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); - } - -#define RADIUS 4 -#define FOCUS_RADIUS 6 - - cairo_new_path (cr); - cairo_arc (cr, xx, yy, RADIUS, 0, 2 * G_PI); - cairo_stroke (cr); - - /* Draw focus outline */ - - if (draw_focus && ! priv->focus_on_ring) - { - gint focus_width; - gint focus_pad; - - gtk_widget_style_get (widget, - "focus-line-width", &focus_width, - "focus-padding", &focus_pad, - NULL); - - gtk_render_focus (context, cr, - xx - FOCUS_RADIUS - focus_width - focus_pad, - yy - FOCUS_RADIUS - focus_width - focus_pad, - 2 * (FOCUS_RADIUS + focus_width + focus_pad), - 2 * (FOCUS_RADIUS + focus_width + focus_pad)); - } - - gtk_style_context_restore (context); -} - -static gboolean -gimp_color_wheel_draw (GtkWidget *widget, - cairo_t *cr) -{ - GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget); - GimpColorWheelPrivate *priv = wheel->priv; - gboolean draw_focus; - - draw_focus = gtk_widget_has_visible_focus (widget); - - paint_ring (wheel, cr); - paint_triangle (wheel, cr, draw_focus); - - if (draw_focus && priv->focus_on_ring) - { - GtkStyleContext *context = gtk_widget_get_style_context (widget); - - gtk_render_focus (context, cr, 0, 0, - gtk_widget_get_allocated_width (widget), - gtk_widget_get_allocated_height (widget)); - } - - return FALSE; -} - -static gboolean -gimp_color_wheel_focus (GtkWidget *widget, - GtkDirectionType dir) -{ - GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget); - GimpColorWheelPrivate *priv = wheel->priv; - - if (!gtk_widget_has_focus (widget)) - { - if (dir == GTK_DIR_TAB_BACKWARD) - priv->focus_on_ring = FALSE; - else - priv->focus_on_ring = TRUE; - - gtk_widget_grab_focus (widget); - return TRUE; - } - - switch (dir) - { - case GTK_DIR_UP: - if (priv->focus_on_ring) - return FALSE; - else - priv->focus_on_ring = TRUE; - break; - - case GTK_DIR_DOWN: - if (priv->focus_on_ring) - priv->focus_on_ring = FALSE; - else - return FALSE; - break; - - case GTK_DIR_LEFT: - case GTK_DIR_TAB_BACKWARD: - if (priv->focus_on_ring) - return FALSE; - else - priv->focus_on_ring = TRUE; - break; - - case GTK_DIR_RIGHT: - case GTK_DIR_TAB_FORWARD: - if (priv->focus_on_ring) - priv->focus_on_ring = FALSE; - else - return FALSE; - break; - } - - gtk_widget_queue_draw (widget); - - return TRUE; -} - -/** - * gimp_color_wheel_new: - * - * Creates a new HSV color selector. - * - * Return value: A newly-created HSV color selector. - * - * Since: 2.14 - */ -GtkWidget* -gimp_color_wheel_new (void) -{ - return g_object_new (GIMP_TYPE_COLOR_WHEEL, NULL); -} - -/** - * gimp_color_wheel_set_color: - * @hsv: An HSV color selector - * @h: Hue - * @s: Saturation - * @v: Value - * - * Sets the current color in an HSV color selector. - * Color component values must be in the [0.0, 1.0] range. - * - * Since: 2.14 - */ -void -gimp_color_wheel_set_color (GimpColorWheel *wheel, - gdouble h, - gdouble s, - gdouble v) -{ - GimpColorWheelPrivate *priv; - - g_return_if_fail (GIMP_IS_COLOR_WHEEL (wheel)); - g_return_if_fail (h >= 0.0 && h <= 1.0); - g_return_if_fail (s >= 0.0 && s <= 1.0); - g_return_if_fail (v >= 0.0 && v <= 1.0); - - priv = wheel->priv; - - if(h == 0.0 && s == 0.0) { - h = priv->h; - } - - priv->h = h; - priv->s = s; - priv->v = v; - - g_signal_emit (wheel, wheel_signals[CHANGED], 0); - - gtk_widget_queue_draw (GTK_WIDGET (wheel)); -} - -/** - * gimp_color_wheel_get_color: - * @hsv: An HSV color selector - * @h: (out): Return value for the hue - * @s: (out): Return value for the saturation - * @v: (out): Return value for the value - * - * Queries the current color in an HSV color selector. - * Returned values will be in the [0.0, 1.0] range. - * - * Since: 2.14 - */ -void -gimp_color_wheel_get_color (GimpColorWheel *wheel, - gdouble *h, - gdouble *s, - gdouble *v) -{ - GimpColorWheelPrivate *priv; - - g_return_if_fail (GIMP_IS_COLOR_WHEEL (wheel)); - - priv = wheel->priv; - - if (h) *h = priv->h; - if (s) *s = priv->s; - if (v) *v = priv->v; -} - -/** - * gimp_color_wheel_set_ring_fraction: - * @ring: A wheel color selector - * @fraction: Ring fraction - * - * Sets the ring fraction of a wheel color selector. - * - * Since: GIMP 2.10 - */ -void -gimp_color_wheel_set_ring_fraction (GimpColorWheel *hsv, - gdouble fraction) -{ - GimpColorWheelPrivate *priv; - - g_return_if_fail (GIMP_IS_COLOR_WHEEL (hsv)); - - priv = hsv->priv; - - priv->ring_fraction = CLAMP (fraction, 0.01, 0.99); - - gtk_widget_queue_draw (GTK_WIDGET (hsv)); -} - -/** - * gimp_color_wheel_get_ring_fraction: - * @ring: A wheel color selector - * - * Returns value: The ring fraction of the wheel color selector. - * - * Since: GIMP 2.10 - */ -gdouble -gimp_color_wheel_get_ring_fraction (GimpColorWheel *wheel) -{ - GimpColorWheelPrivate *priv; - - g_return_val_if_fail (GIMP_IS_COLOR_WHEEL (wheel), DEFAULT_FRACTION); - - priv = wheel->priv; - - return priv->ring_fraction; -} - -/** - * gimp_color_wheel_is_adjusting: - * @hsv: A #GimpColorWheel - * - * An HSV color selector can be said to be adjusting if multiple rapid - * changes are being made to its value, for example, when the user is - * adjusting the value with the mouse. This function queries whether - * the HSV color selector is being adjusted or not. - * - * Return value: %TRUE if clients can ignore changes to the color value, - * since they may be transitory, or %FALSE if they should consider - * the color value status to be final. - * - * Since: 2.14 - */ -gboolean -gimp_color_wheel_is_adjusting (GimpColorWheel *wheel) -{ - GimpColorWheelPrivate *priv; - - g_return_val_if_fail (GIMP_IS_COLOR_WHEEL (wheel), FALSE); - - priv = wheel->priv; - - return priv->mode != DRAG_NONE; -} - -static void -gimp_color_wheel_move (GimpColorWheel *wheel, - GtkDirectionType dir) -{ - GimpColorWheelPrivate *priv = wheel->priv; - gdouble hue, sat, val; - gint hx, hy, sx, sy, vx, vy; /* HSV vertices */ - gint x, y; /* position in triangle */ - - hue = priv->h; - sat = priv->s; - val = priv->v; - - compute_triangle (wheel, &hx, &hy, &sx, &sy, &vx, &vy); - - x = floor (sx + (vx - sx) * priv->v + (hx - vx) * priv->s * priv->v + 0.5); - y = floor (sy + (vy - sy) * priv->v + (hy - vy) * priv->s * priv->v + 0.5); - -#define HUE_DELTA 0.002 - switch (dir) - { - case GTK_DIR_UP: - if (priv->focus_on_ring) - hue += HUE_DELTA; - else - { - y -= 1; - compute_sv (wheel, x, y, &sat, &val); - } - break; - - case GTK_DIR_DOWN: - if (priv->focus_on_ring) - hue -= HUE_DELTA; - else - { - y += 1; - compute_sv (wheel, x, y, &sat, &val); - } - break; - - case GTK_DIR_LEFT: - if (priv->focus_on_ring) - hue += HUE_DELTA; - else - { - x -= 1; - compute_sv (wheel, x, y, &sat, &val); - } - break; - - case GTK_DIR_RIGHT: - if (priv->focus_on_ring) - hue -= HUE_DELTA - ; - else - { - x += 1; - compute_sv (wheel, x, y, &sat, &val); - } - break; - - default: - /* we don't care about the tab directions */ - break; - } - - /* Wrap */ - if (hue < 0.0) - hue = 1.0; - else if (hue > 1.0) - hue = 0.0; - - gimp_color_wheel_set_color (wheel, hue, sat, val); -} diff --git a/src/ui/widget/gimpcolorwheel.h b/src/ui/widget/gimpcolorwheel.h deleted file mode 100644 index 016fb593f..000000000 --- a/src/ui/widget/gimpcolorwheel.h +++ /dev/null @@ -1,95 +0,0 @@ -/* HSV color selector for GTK+ - * - * Copyright (C) 1999 The Free Software Foundation - * - * Authors: Simon Budig (original code) - * Federico Mena-Quintero (cleanup for GTK+) - * Jonathan Blandford (cleanup for GTK+) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __GIMP_COLOR_WHEEL_H__ -#define __GIMP_COLOR_WHEEL_H__ - -G_BEGIN_DECLS - -#define GIMP_TYPE_COLOR_WHEEL (gimp_color_wheel_get_type ()) -#define GIMP_COLOR_WHEEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COLOR_WHEEL, GimpColorWheel)) -#define GIMP_COLOR_WHEEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_WHEEL, GimpColorWheelClass)) -#define GIMP_IS_COLOR_WHEEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_COLOR_WHEEL)) -#define GIMP_IS_COLOR_WHEEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_WHEEL)) -#define GIMP_COLOR_WHEEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_WHEEL, GimpColorWheelClass)) - - -typedef struct _GimpColorWheel GimpColorWheel; -typedef struct _GimpColorWheelClass GimpColorWheelClass; - -struct _GimpColorWheel -{ - GtkWidget parent_instance; - - /* Private data */ - gpointer priv; -}; - -struct _GimpColorWheelClass -{ - GtkWidgetClass parent_class; - - /* Notification signals */ - void (* changed) (GimpColorWheel *wheel); - - /* Keybindings */ - void (* move) (GimpColorWheel *wheel, - GtkDirectionType type); - - /* Padding for future expansion */ - void (*_gimp_reserved1) (void); - void (*_gimp_reserved2) (void); - void (*_gimp_reserved3) (void); - void (*_gimp_reserved4) (void); -}; - - -GType gimp_color_wheel_get_type (void) G_GNUC_CONST; -GtkWidget * gimp_color_wheel_new (void); - -void gimp_color_wheel_set_color (GimpColorWheel *wheel, - double h, - double s, - double v); -void gimp_color_wheel_get_color (GimpColorWheel *wheel, - gdouble *h, - gdouble *s, - gdouble *v); - -void gimp_color_wheel_set_ring_fraction (GimpColorWheel *wheel, - gdouble fraction); -gdouble gimp_color_wheel_get_ring_fraction (GimpColorWheel *wheel); - -gboolean gimp_color_wheel_is_adjusting (GimpColorWheel *wheel); - -G_END_DECLS - -#endif /* __GIMP_COLOR_WHEEL_H__ */ diff --git a/src/ui/widget/gimpspinscale.c b/src/ui/widget/gimpspinscale.c deleted file mode 100644 index 8d8c6c935..000000000 --- a/src/ui/widget/gimpspinscale.c +++ /dev/null @@ -1,969 +0,0 @@ -/* GIMP - The GNU Image Manipulation Program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * gimpspinscale.c - * Copyright (C) 2010 Michael Natterer - * 2012 Øyvind KolÃ¥s - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include - -#include "gimpspinscale.h" - - -enum -{ - PROP_0, - PROP_LABEL, - PROP_FOCUS_WIDGET -}; - -typedef enum -{ - TARGET_NUMBER, - TARGET_UPPER, - TARGET_LOWER, - TARGET_NONE -} SpinScaleTarget; - -typedef enum -{ - APPEARANCE_FULL = 1, /* Full size suitable for tablets */ - APPEARANCE_COMPACT, /* Compact, suitable for desktops with mouse control */ -} SpinScaleAppearance; - -typedef struct _GimpSpinScalePrivate GimpSpinScalePrivate; - -struct _GimpSpinScalePrivate -{ - gchar *label; - - gboolean scale_limits_set; - gdouble scale_lower; - gdouble scale_upper; - gdouble gamma; - - PangoLayout *layout; - gboolean changing_value; - gboolean relative_change; - gdouble start_x; - gdouble start_value; - - GtkWidget* focusWidget; - gboolean transferFocus; - SpinScaleAppearance appearanceMode; -}; - -#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ - GIMP_TYPE_SPIN_SCALE, \ - GimpSpinScalePrivate)) - - -static void gimp_spin_scale_dispose (GObject *object); -static void gimp_spin_scale_finalize (GObject *object); -static void gimp_spin_scale_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); -static void gimp_spin_scale_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec); - -static void gimp_spin_scale_style_set (GtkWidget *widget, - GtkStyle *prev_style); - -static void gimp_spin_scale_get_preferred_width (GtkWidget *widget, - gint *minimum_width, - gint *natural_width); -static void gimp_spin_scale_get_preferred_height (GtkWidget *widget, - gint *minimum_width, - gint *natural_width); -static gboolean gimp_spin_scale_draw (GtkWidget *widget, - cairo_t *cr); - -static gboolean gimp_spin_scale_button_press (GtkWidget *widget, - GdkEventButton *event); -static gboolean gimp_spin_scale_button_release (GtkWidget *widget, - GdkEventButton *event); -static gboolean gimp_spin_scale_motion_notify (GtkWidget *widget, - GdkEventMotion *event); -static gboolean gimp_spin_scale_leave_notify (GtkWidget *widget, - GdkEventCrossing *event); -static gboolean gimp_spin_scale_keypress( GtkWidget *widget, - GdkEventKey *event); - -static void gimp_spin_scale_defocus( GtkSpinButton *spin_button ); - -static void gimp_spin_scale_value_changed (GtkSpinButton *spin_button); - - -G_DEFINE_TYPE (GimpSpinScale, gimp_spin_scale, GTK_TYPE_SPIN_BUTTON); - -#define parent_class gimp_spin_scale_parent_class - - -static void -gimp_spin_scale_class_init (GimpSpinScaleClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - GtkSpinButtonClass *spin_button_class = GTK_SPIN_BUTTON_CLASS (klass); - - object_class->dispose = gimp_spin_scale_dispose; - object_class->finalize = gimp_spin_scale_finalize; - object_class->set_property = gimp_spin_scale_set_property; - object_class->get_property = gimp_spin_scale_get_property; - - widget_class->style_set = gimp_spin_scale_style_set; - widget_class->get_preferred_width = gimp_spin_scale_get_preferred_width; - widget_class->get_preferred_height = gimp_spin_scale_get_preferred_height; - widget_class->draw = gimp_spin_scale_draw; - widget_class->button_press_event = gimp_spin_scale_button_press; - widget_class->button_release_event = gimp_spin_scale_button_release; - widget_class->motion_notify_event = gimp_spin_scale_motion_notify; - widget_class->leave_notify_event = gimp_spin_scale_leave_notify; - widget_class->key_press_event = gimp_spin_scale_keypress; - - spin_button_class->value_changed = gimp_spin_scale_value_changed; - - g_object_class_install_property (object_class, PROP_LABEL, - g_param_spec_string ("label", NULL, NULL, - NULL, - G_PARAM_READWRITE)); - - g_type_class_add_private (klass, sizeof (GimpSpinScalePrivate)); -} - -static void -gimp_spin_scale_init (GimpSpinScale *scale) -{ - GimpSpinScalePrivate *private = GET_PRIVATE (scale); - - gtk_widget_add_events (GTK_WIDGET (scale), - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_POINTER_MOTION_MASK | - GDK_BUTTON1_MOTION_MASK | - GDK_LEAVE_NOTIFY_MASK); - - gtk_entry_set_alignment (GTK_ENTRY (scale), 1.0); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (scale), TRUE); - - private->gamma = 1.0; - private->focusWidget = NULL; - private->transferFocus = FALSE; - private->appearanceMode = APPEARANCE_COMPACT; -} - -static void -gimp_spin_scale_dispose (GObject *object) -{ - GimpSpinScalePrivate *private = GET_PRIVATE (object); - - if (private->layout) - { - g_object_unref (private->layout); - private->layout = NULL; - } - - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -gimp_spin_scale_finalize (GObject *object) -{ - GimpSpinScalePrivate *private = GET_PRIVATE (object); - - if (private->label) - { - g_free (private->label); - private->label = NULL; - } - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -gimp_spin_scale_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - GimpSpinScalePrivate *private = GET_PRIVATE (object); - GimpSpinScale *scale = GIMP_SPIN_SCALE (object); - - switch (property_id) - { - case PROP_LABEL: - gimp_spin_scale_set_label (scale, g_value_get_string (value)); - break; - - case PROP_FOCUS_WIDGET: - { - /* TODO unhook prior */ - private->focusWidget = GTK_WIDGET (g_value_get_pointer (value)); - } - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -gimp_spin_scale_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - GimpSpinScalePrivate *private = GET_PRIVATE (object); - GimpSpinScale *scale = GIMP_SPIN_SCALE (object); - - switch (property_id) - { - case PROP_LABEL: - g_value_set_string (value, gimp_spin_scale_get_label (scale)); - break; - - case PROP_FOCUS_WIDGET: - g_value_set_pointer (value, private->focusWidget); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - - -void -gimp_spin_scale_set_focuswidget( GtkWidget *scale, GtkWidget* widget ) -{ - GimpSpinScalePrivate *private = GET_PRIVATE (scale); - - /* TODO unhook prior */ - - private->focusWidget = widget; -} - -void -gimp_spin_scale_set_appearance( GtkWidget *widget, const gchar *appearance) -{ - GimpSpinScalePrivate *private = GET_PRIVATE (widget); - - if ( strcmp("full", appearance) == 0 ) { - private->appearanceMode = APPEARANCE_FULL; - } else if ( strcmp("compact", appearance) == 0 ) { - private->appearanceMode = APPEARANCE_COMPACT; - } -} - -static void -gimp_spin_scale_get_preferred_width (GtkWidget *widget, - gint *minimum_width, - gint *natural_width) -{ - GimpSpinScalePrivate *private = GET_PRIVATE (widget); - PangoContext *context = gtk_widget_get_pango_context (widget); - PangoFontMetrics *metrics; - - GTK_WIDGET_CLASS (parent_class)->get_preferred_width (widget, - minimum_width, - natural_width); - - metrics = pango_context_get_metrics (context, - pango_context_get_font_description (context), - pango_context_get_language (context)); - - if (private->label) - { - gint char_width; - gint digit_width; - gint char_pixels; - - char_width = pango_font_metrics_get_approximate_char_width (metrics); - digit_width = pango_font_metrics_get_approximate_digit_width (metrics); - char_pixels = PANGO_PIXELS (MAX (char_width, digit_width)); - - /* ~3 chars for the ellipse */ - *minimum_width += char_pixels * 3; - *natural_width += char_pixels * 3; - } - - pango_font_metrics_unref (metrics); -} - -static void -gimp_spin_scale_get_preferred_height (GtkWidget *widget, - gint *minimum_height, - gint *natural_height) -{ - PangoContext *context = gtk_widget_get_pango_context (widget); - PangoFontMetrics *metrics; - //gint height; - - GTK_WIDGET_CLASS (parent_class)->get_preferred_height (widget, - minimum_height, - natural_height); - - metrics = pango_context_get_metrics (context, - pango_context_get_font_description (context), - pango_context_get_language (context)); - - //height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) + - // pango_font_metrics_get_descent (metrics)); - - *minimum_height += 1; - *natural_height += 1; - - pango_font_metrics_unref (metrics); -} - -static void -gimp_spin_scale_style_set (GtkWidget *widget, - GtkStyle *prev_style) -{ - GimpSpinScalePrivate *private = GET_PRIVATE (widget); - - GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style); - - if (private->layout) - { - g_object_unref (private->layout); - private->layout = NULL; - } -} - - -static gboolean - gimp_spin_scale_draw (GtkWidget *widget, - cairo_t *cr) -{ - GimpSpinScalePrivate *private = GET_PRIVATE (widget); - GtkStyleContext *style = gtk_widget_get_style_context(widget); - GtkAllocation allocation; - GdkRGBA color; - - cairo_save (cr); - GTK_WIDGET_CLASS (parent_class)->draw (widget, cr); - cairo_restore (cr); - - gtk_widget_get_allocation (widget, &allocation); - - cairo_set_line_width (cr, 1.0); - - if (private->label) - { - GdkRectangle text_area; - gint minimum_width; - gint natural_width; - PangoRectangle logical; - gint layout_offset_x; - gint layout_offset_y; - GtkStateFlags state; - GdkRGBA text_color; - GdkRGBA bar_text_color; - gdouble progress_fraction; - gint progress_x; - gint progress_y; - gint progress_width; - gint progress_height; - - gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area); - - GTK_WIDGET_CLASS (parent_class)->get_preferred_width (widget, - &minimum_width, - &natural_width); - - if (! private->layout) - { - private->layout = gtk_widget_create_pango_layout (widget, - private->label); - pango_layout_set_ellipsize (private->layout, PANGO_ELLIPSIZE_END); - } - - pango_layout_set_width (private->layout, - PANGO_SCALE * - (allocation.width - minimum_width)); - pango_layout_get_pixel_extents (private->layout, NULL, &logical); - - gtk_entry_get_layout_offsets (GTK_ENTRY (widget), NULL, &layout_offset_y); - - if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - layout_offset_x = text_area.x + text_area.width - logical.width - 4; - else - layout_offset_x = 4; - - layout_offset_x -= logical.x; - - state = gtk_widget_get_state_flags (widget); - - gtk_style_context_get_color (style, state, &text_color); - - gtk_style_context_save (style); - gtk_style_context_add_class (style, GTK_STYLE_CLASS_PROGRESSBAR); - gtk_style_context_get_color (style, state, &bar_text_color); - gtk_style_context_restore (style); - - progress_fraction = gtk_entry_get_progress_fraction (GTK_ENTRY (widget)); - - if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - { - progress_fraction = 1.0 - progress_fraction; - - progress_x = text_area.width * progress_fraction; - progress_y = 0; - progress_width = text_area.width - progress_x; - progress_height = text_area.height; - } - else - { - progress_x = 0; - progress_y = 0; - progress_width = text_area.width * progress_fraction; - progress_height = text_area.height; - } - - cairo_save (cr); - - cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); - cairo_rectangle (cr, 0, 0, text_area.width, text_area.height); - cairo_rectangle (cr, progress_x, progress_y, - progress_width, progress_height); - cairo_clip (cr); - cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING); - - cairo_move_to (cr, layout_offset_x, text_area.y + layout_offset_y-3); - gdk_cairo_set_source_rgba (cr, &text_color); - pango_cairo_show_layout (cr, private->layout); - cairo_restore (cr); - - cairo_rectangle (cr, progress_x, progress_y, - progress_width, progress_height); - cairo_clip (cr); - - cairo_move_to (cr, layout_offset_x, text_area.y + layout_offset_y-3); - gdk_cairo_set_source_rgba (cr, &bar_text_color); - pango_cairo_show_layout (cr, private->layout); - } - - return FALSE; -} - -/* Returns TRUE if a translation should be done */ -static gboolean -gtk_widget_get_translation_to_window (GtkWidget *widget, - GdkWindow *window, - int *x, - int *y) -{ - GdkWindow *w, *widget_window; - - if (!gtk_widget_get_has_window (widget)) - { - GtkAllocation allocation; - - gtk_widget_get_allocation (widget, &allocation); - - *x = -allocation.x; - *y = -allocation.y; - } - else - { - *x = 0; - *y = 0; - } - - widget_window = gtk_widget_get_window (widget); - - for (w = window; w && w != widget_window; w = gdk_window_get_parent (w)) - { - int wx, wy; - gdk_window_get_position (w, &wx, &wy); - *x += wx; - *y += wy; - } - - if (w == NULL) - { - *x = 0; - *y = 0; - return FALSE; - } - - return TRUE; -} - -static void -gimp_spin_scale_event_to_widget_coords (GtkWidget *widget, - GdkWindow *window, - gdouble event_x, - gdouble event_y, - gint *widget_x, - gint *widget_y) -{ - gint tx, ty; - - if (gtk_widget_get_translation_to_window (widget, window, &tx, &ty)) - { - event_x += tx; - event_y += ty; - } - - *widget_x = event_x; - *widget_y = event_y; -} - -static SpinScaleTarget -gimp_spin_scale_get_target (GtkWidget *widget, - gdouble x, - gdouble y) -{ - GtkAllocation allocation; - PangoRectangle logical; - gint layout_x; - gint layout_y; - - gtk_widget_get_allocation (widget, &allocation); - gtk_entry_get_layout_offsets (GTK_ENTRY (widget), &layout_x, &layout_y); - pango_layout_get_pixel_extents (gtk_entry_get_layout (GTK_ENTRY (widget)), - NULL, &logical); - - GdkRectangle text_area; - gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area); - - if (x >= text_area.x && x < text_area.width && - y >= text_area.y && y < text_area.height) - { - x -= text_area.x; - y -= text_area.y; - - if (x > layout_x && x < layout_x + logical.width && - y > layout_y && y < layout_y + logical.height) - { - return TARGET_NUMBER; - } - else if (y > text_area.height / 2) - { - return TARGET_LOWER; - } - - return TARGET_UPPER; - } - - return TARGET_NONE; -} - -static void -gimp_spin_scale_get_limits (GimpSpinScale *scale, - gdouble *lower, - gdouble *upper) -{ - GimpSpinScalePrivate *private = GET_PRIVATE (scale); - - if (private->scale_limits_set) - { - *lower = private->scale_lower; - *upper = private->scale_upper; - } - else - { - GtkSpinButton *spin_button = GTK_SPIN_BUTTON (scale); - GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (spin_button); - - *lower = gtk_adjustment_get_lower (adjustment); - *upper = gtk_adjustment_get_upper (adjustment); - } -} - -static void -gimp_spin_scale_change_value (GtkWidget *widget, - gdouble x) -{ - GimpSpinScalePrivate *private = GET_PRIVATE (widget); - GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget); - GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (spin_button); - gdouble lower; - gdouble upper; - gdouble value; - GdkRectangle text_area; - gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area); - gimp_spin_scale_get_limits (GIMP_SPIN_SCALE (widget), &lower, &upper); - - if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - x = text_area.width - x; - - if (private->relative_change) - { - gdouble diff; - gdouble step; - - step = (upper - lower) / text_area.width / 10.0; - if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - diff = x - (text_area.width - private->start_x); - else - diff = x - private->start_x; - - value = (private->start_value + diff * step); - } - else - { - gdouble fraction; - - fraction = x / (gdouble) text_area.width; - if (fraction > 0.0) - fraction = pow (fraction, private->gamma); - - value = fraction * (upper - lower) + lower; - } - - gtk_adjustment_set_value (adjustment, value); -} - -static gboolean -gimp_spin_scale_button_press (GtkWidget *widget, - GdkEventButton *event) -{ - GimpSpinScalePrivate *private = GET_PRIVATE (widget); - - private->changing_value = FALSE; - private->relative_change = FALSE; - - gint x, y; - gimp_spin_scale_event_to_widget_coords (widget, event->window, - event->x, event->y, - &x, &y); - switch (gimp_spin_scale_get_target (widget, x, y)) - { - case TARGET_UPPER: - private->changing_value = TRUE; - - gtk_widget_grab_focus (widget); - - gimp_spin_scale_change_value (widget, x); - - return TRUE; - - case TARGET_LOWER: - private->changing_value = TRUE; - - gtk_widget_grab_focus (widget); - - private->relative_change = TRUE; - private->start_x = x; - private->start_value = gtk_adjustment_get_value (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget))); - - return TRUE; - - default: - break; - } - - return GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, event); -} - -static gboolean -gimp_spin_scale_button_release (GtkWidget *widget, - GdkEventButton *event) -{ - GimpSpinScalePrivate *private = GET_PRIVATE (widget); - gint x, y; - - gimp_spin_scale_event_to_widget_coords (widget, event->window, - event->x, event->y, - &x, &y); - - if (private->changing_value) - { - private->changing_value = FALSE; - gimp_spin_scale_change_value (widget, x); - return TRUE; - } - - return GTK_WIDGET_CLASS (parent_class)->button_release_event (widget, event); -} - -static gboolean -gimp_spin_scale_motion_notify (GtkWidget *widget, - GdkEventMotion *event) -{ - GimpSpinScalePrivate *private = GET_PRIVATE (widget); - - gdk_event_request_motions (event); - - gint x, y; - - gimp_spin_scale_event_to_widget_coords (widget, event->window, - event->x, event->y, - &x, &y); - - if (private->changing_value) - { - gimp_spin_scale_change_value (widget, x); - - return TRUE; - } - - GTK_WIDGET_CLASS (parent_class)->motion_notify_event (widget, event); - - if (! (event->state & - (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) - ) - { - GdkDisplay *display = gtk_widget_get_display (widget); - GdkCursor *cursor = NULL; - - switch (gimp_spin_scale_get_target (widget, x, y)) - { - case TARGET_NUMBER: - cursor = gdk_cursor_new_for_display (display, GDK_XTERM); - break; - - case TARGET_UPPER: - cursor = gdk_cursor_new_for_display (display, GDK_SB_UP_ARROW); - break; - - case TARGET_LOWER: - cursor = gdk_cursor_new_for_display (display, GDK_SB_H_DOUBLE_ARROW); - break; - - default: - break; - } - - if (cursor) - { - gdk_window_set_cursor (event->window, cursor); - g_object_unref (cursor); - } - } - - return FALSE; -} - -static gboolean -gimp_spin_scale_leave_notify (GtkWidget *widget, - GdkEventCrossing *event) -{ - gdk_window_set_cursor (event->window, NULL); - - return GTK_WIDGET_CLASS (parent_class)->leave_notify_event (widget, event); -} - -gboolean gimp_spin_scale_keypress( GtkWidget *widget, GdkEventKey *event) -{ - GimpSpinScalePrivate *private = GET_PRIVATE (widget); - guint key = 0; - gdk_keymap_translate_keyboard_state( gdk_keymap_get_for_display( gdk_display_get_default() ), - event->hardware_keycode, (GdkModifierType)event->state, - 0, &key, 0, 0, 0 ); - - switch ( key ) { - - case GDK_KEY_Escape: - case GDK_KEY_Return: - case GDK_KEY_KP_Enter: - { - private->transferFocus = TRUE; - gimp_spin_scale_defocus( GTK_SPIN_BUTTON(widget) ); - } - break; - - } - - return GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event); -} - -static void -gimp_spin_scale_defocus( GtkSpinButton *spin_button ) -{ - GimpSpinScalePrivate *private = GET_PRIVATE (spin_button); - - if ( private->transferFocus ) { - if ( private->focusWidget ) { - gtk_widget_grab_focus( private->focusWidget ); - } - } -} - -static void -gimp_spin_scale_value_changed (GtkSpinButton *spin_button) -{ - GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (spin_button); - GimpSpinScalePrivate *private = GET_PRIVATE (spin_button); - gdouble lower; - gdouble upper; - gdouble value; - - gimp_spin_scale_get_limits (GIMP_SPIN_SCALE (spin_button), &lower, &upper); - - value = CLAMP (gtk_adjustment_get_value (adjustment), lower, upper); - - gtk_entry_set_progress_fraction (GTK_ENTRY (spin_button), - pow ((value - lower) / (upper - lower), - 1.0 / private->gamma)); - - // TODO - Allow scrollwheel to change value then return focus, - // but clicks/keypress should keep focus in the control - //if ( gtk_widget_has_focus( GTK_WIDGET(spin_button) ) ) { - // gimp_spin_scale_defocus( spin_button ); - //} -} - - -/* public functions */ - -GtkWidget * -gimp_spin_scale_new (GtkAdjustment *adjustment, - const gchar *label, - gint digits) -{ - g_return_val_if_fail (GTK_IS_ADJUSTMENT (adjustment), NULL); - - return g_object_new (GIMP_TYPE_SPIN_SCALE, - "adjustment", adjustment, - "label", label, - "digits", digits, - NULL); -} - -void -gimp_spin_scale_set_label (GimpSpinScale *scale, - const gchar *label) -{ - GimpSpinScalePrivate *private; - - g_return_if_fail (GIMP_IS_SPIN_SCALE (scale)); - - private = GET_PRIVATE (scale); - - if (label == private->label) - return; - - g_free (private->label); - private->label = g_strdup (label); - - if (private->layout) - { - g_object_unref (private->layout); - private->layout = NULL; - } - - gtk_widget_queue_resize (GTK_WIDGET (scale)); - - g_object_notify (G_OBJECT (scale), "label"); -} - -const gchar * -gimp_spin_scale_get_label (GimpSpinScale *scale) -{ - g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), NULL); - - return GET_PRIVATE (scale)->label; -} - -void -gimp_spin_scale_set_scale_limits (GimpSpinScale *scale, - gdouble lower, - gdouble upper) -{ - GimpSpinScalePrivate *private; - GtkSpinButton *spin_button; - GtkAdjustment *adjustment; - - g_return_if_fail (GIMP_IS_SPIN_SCALE (scale)); - - private = GET_PRIVATE (scale); - spin_button = GTK_SPIN_BUTTON (scale); - adjustment = gtk_spin_button_get_adjustment (spin_button); - - g_return_if_fail (lower >= gtk_adjustment_get_lower (adjustment)); - g_return_if_fail (upper <= gtk_adjustment_get_upper (adjustment)); - - private->scale_limits_set = TRUE; - private->scale_lower = lower; - private->scale_upper = upper; - private->gamma = 1.0; - - gimp_spin_scale_value_changed (spin_button); -} - -void -gimp_spin_scale_unset_scale_limits (GimpSpinScale *scale) -{ - GimpSpinScalePrivate *private; - - g_return_if_fail (GIMP_IS_SPIN_SCALE (scale)); - - private = GET_PRIVATE (scale); - - private->scale_limits_set = FALSE; - private->scale_lower = 0.0; - private->scale_upper = 0.0; - - gimp_spin_scale_value_changed (GTK_SPIN_BUTTON (scale)); -} - -gboolean -gimp_spin_scale_get_scale_limits (GimpSpinScale *scale, - gdouble *lower, - gdouble *upper) -{ - GimpSpinScalePrivate *private; - - g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), FALSE); - - private = GET_PRIVATE (scale); - - if (lower) - *lower = private->scale_lower; - - if (upper) - *upper = private->scale_upper; - - return private->scale_limits_set; -} - -void -gimp_spin_scale_set_gamma (GimpSpinScale *scale, - gdouble gamma) -{ - GimpSpinScalePrivate *private; - - g_return_if_fail (GIMP_IS_SPIN_SCALE (scale)); - - private = GET_PRIVATE (scale); - - private->gamma = gamma; - - gimp_spin_scale_value_changed (GTK_SPIN_BUTTON (scale)); -} - -gdouble -gimp_spin_scale_get_gamma (GimpSpinScale *scale) -{ - g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), 1.0); - - return GET_PRIVATE(scale)->gamma; -} diff --git a/src/ui/widget/gimpspinscale.h b/src/ui/widget/gimpspinscale.h deleted file mode 100644 index b42a0faf8..000000000 --- a/src/ui/widget/gimpspinscale.h +++ /dev/null @@ -1,82 +0,0 @@ -/* GIMP - The GNU Image Manipulation Program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * gimpspinscale.h - * Copyright (C) 2010 Michael Natterer - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef __GIMP_SPIN_SCALE_H__ -#define __GIMP_SPIN_SCALE_H__ - -#ifndef WITH_GIMP -#include -#endif - -G_BEGIN_DECLS - -#define GIMP_TYPE_SPIN_SCALE (gimp_spin_scale_get_type ()) -#define GIMP_SPIN_SCALE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_SPIN_SCALE, GimpSpinScale)) -#define GIMP_SPIN_SCALE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_SPIN_SCALE, GimpSpinScaleClass)) -#define GIMP_IS_SPIN_SCALE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_SPIN_SCALE)) -#define GIMP_IS_SPIN_SCALE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_SPIN_SCALE)) -#define GIMP_SPIN_SCALE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_SPIN_SCALE, GimpSpinScaleClass)) - - -typedef struct _GimpSpinScale GimpSpinScale; -typedef struct _GimpSpinScaleClass GimpSpinScaleClass; - -struct _GimpSpinScale -{ - GtkSpinButton parent_instance; -}; - -struct _GimpSpinScaleClass -{ - GtkSpinButtonClass parent_class; -}; - - -GType gimp_spin_scale_get_type (void) G_GNUC_CONST; - -GtkWidget * gimp_spin_scale_new (GtkAdjustment *adjustment, - const gchar *label, - gint digits); - -void gimp_spin_scale_set_label (GimpSpinScale *scale, - const gchar *label); -const gchar * gimp_spin_scale_get_label (GimpSpinScale *scale); - -void gimp_spin_scale_set_scale_limits (GimpSpinScale *scale, - gdouble lower, - gdouble upper); -void gimp_spin_scale_unset_scale_limits (GimpSpinScale *scale); -gboolean gimp_spin_scale_get_scale_limits (GimpSpinScale *scale, - gdouble *lower, - gdouble *upper); - -void gimp_spin_scale_set_gamma (GimpSpinScale *scale, - gdouble gamma); -gdouble gimp_spin_scale_get_gamma (GimpSpinScale *scale); - -void gimp_spin_scale_set_focuswidget (GtkWidget *scale, - GtkWidget *widget); - -void gimp_spin_scale_set_appearance (GtkWidget *scale, - const gchar *appearance); - -G_END_DECLS - -#endif /* __GIMP_SPIN_SCALE_H__ */ diff --git a/src/ui/widget/spin-scale.cpp b/src/ui/widget/spin-scale.cpp index eb91aaf39..f74626d9b 100644 --- a/src/ui/widget/spin-scale.cpp +++ b/src/ui/widget/spin-scale.cpp @@ -11,7 +11,7 @@ #include #include -#include "ui/widget/gimpspinscale.h" +#include "widgets/gimp/gimpspinscale.h" namespace Inkscape { namespace UI { -- cgit v1.2.3 From 41e0cdaf25ae70d09f1283e74dd3c47d64bf0ec0 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 8 Aug 2016 11:35:00 +0100 Subject: Fix autotools build (bzr r15045) --- src/ui/widget/Makefile_insert | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/ui') diff --git a/src/ui/widget/Makefile_insert b/src/ui/widget/Makefile_insert index eb98e6872..b22e4bd74 100644 --- a/src/ui/widget/Makefile_insert +++ b/src/ui/widget/Makefile_insert @@ -35,10 +35,6 @@ ink_common_sources += \ ui/widget/filter-effect-chooser.cpp \ ui/widget/font-variants.h \ ui/widget/font-variants.cpp \ - ui/widget/gimpspinscale.c \ - ui/widget/gimpspinscale.h \ - ui/widget/gimpcolorwheel.c \ - ui/widget/gimpcolorwheel.h \ ui/widget/frame.cpp \ ui/widget/frame.h \ ui/widget/imageicon.cpp \ -- cgit v1.2.3 From e471a664f923f517b68071f2e33fbb6ce070f8b7 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 8 Aug 2016 13:56:40 +0100 Subject: Remove deprecated Autotools and btool files. Please use CMake instead (bzr r15046) --- src/ui/Makefile_insert | 31 ---------- src/ui/cache/Makefile_insert | 6 -- src/ui/dialog/Makefile_insert | 133 ------------------------------------------ src/ui/tool/Makefile_insert | 30 ---------- src/ui/tools/Makefile_insert | 34 ----------- src/ui/view/Makefile_insert | 9 --- src/ui/widget/Makefile_insert | 106 --------------------------------- 7 files changed, 349 deletions(-) delete mode 100644 src/ui/Makefile_insert delete mode 100644 src/ui/cache/Makefile_insert delete mode 100644 src/ui/dialog/Makefile_insert delete mode 100644 src/ui/tool/Makefile_insert delete mode 100644 src/ui/tools/Makefile_insert delete mode 100644 src/ui/view/Makefile_insert delete mode 100644 src/ui/widget/Makefile_insert (limited to 'src/ui') diff --git a/src/ui/Makefile_insert b/src/ui/Makefile_insert deleted file mode 100644 index bbfdb532c..000000000 --- a/src/ui/Makefile_insert +++ /dev/null @@ -1,31 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - ui/clipboard.cpp \ - ui/clipboard.h \ - ui/control-manager.cpp \ - ui/control-manager.h \ - ui/control-types.h \ - ui/dialog-events.cpp \ - ui/dialog-events.h \ - ui/draw-anchor.cpp \ - ui/draw-anchor.h \ - ui/icon-names.h \ - ui/interface.cpp \ - ui/interface.h \ - ui/object-edit.cpp \ - ui/object-edit.h \ - ui/previewable.h \ - ui/previewfillable.h \ - ui/previewholder.cpp \ - ui/previewholder.h \ - ui/selected-color.h \ - ui/selected-color.cpp \ - ui/shape-editor.cpp \ - ui/shape-editor.h \ - ui/tool-factory.cpp \ - ui/tool-factory.h \ - ui/tools-switch.cpp \ - ui/tools-switch.h \ - ui/uxmanager.cpp \ - ui/uxmanager.h diff --git a/src/ui/cache/Makefile_insert b/src/ui/cache/Makefile_insert deleted file mode 100644 index c648777f8..000000000 --- a/src/ui/cache/Makefile_insert +++ /dev/null @@ -1,6 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - ui/cache/svg_preview_cache.h \ - ui/cache/svg_preview_cache.cpp - diff --git a/src/ui/dialog/Makefile_insert b/src/ui/dialog/Makefile_insert deleted file mode 100644 index 71628973e..000000000 --- a/src/ui/dialog/Makefile_insert +++ /dev/null @@ -1,133 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - ui/dialog/aboutbox.cpp \ - ui/dialog/aboutbox.h \ - ui/dialog/align-and-distribute.cpp \ - ui/dialog/align-and-distribute.h \ - ui/dialog/arrange-tab.h \ - ui/dialog/behavior.h \ - ui/dialog/calligraphic-profile-rename.h \ - ui/dialog/calligraphic-profile-rename.cpp \ - ui/dialog/clonetiler.cpp \ - ui/dialog/clonetiler.h \ - ui/dialog/color-item.cpp \ - ui/dialog/color-item.h \ - ui/dialog/debug.cpp \ - ui/dialog/debug.h \ - ui/dialog/desktop-tracker.cpp \ - ui/dialog/desktop-tracker.h \ - ui/dialog/dialog.cpp \ - ui/dialog/dialog.h \ - ui/dialog/dialog-manager.cpp \ - ui/dialog/dialog-manager.h \ - ui/dialog/dock-behavior.cpp \ - ui/dialog/dock-behavior.h \ - ui/dialog/document-metadata.cpp \ - ui/dialog/document-metadata.h \ - ui/dialog/document-properties.cpp \ - ui/dialog/document-properties.h \ - ui/dialog/export.cpp \ - ui/dialog/export.h \ - ui/dialog/extension-editor.cpp \ - ui/dialog/extension-editor.h \ - ui/dialog/extensions.cpp \ - ui/dialog/extensions.h \ - ui/dialog/filedialog.cpp \ - ui/dialog/filedialog.h \ - ui/dialog/filedialogimpl-gtkmm.cpp \ - ui/dialog/filedialogimpl-gtkmm.h \ - ui/dialog/filedialogimpl-win32.cpp \ - ui/dialog/filedialogimpl-win32.h \ - ui/dialog/fill-and-stroke.cpp \ - ui/dialog/fill-and-stroke.h \ - ui/dialog/filter-effects-dialog.cpp \ - ui/dialog/filter-effects-dialog.h \ - ui/dialog/find.cpp \ - ui/dialog/find.h \ - ui/dialog/font-substitution.cpp \ - ui/dialog/font-substitution.h \ - ui/dialog/floating-behavior.cpp \ - ui/dialog/floating-behavior.h \ - ui/dialog/glyphs.cpp \ - ui/dialog/glyphs.h \ - ui/dialog/grid-arrange-tab.h \ - ui/dialog/grid-arrange-tab.cpp \ - ui/dialog/guides.cpp \ - ui/dialog/guides.h \ - ui/dialog/icon-preview.cpp \ - ui/dialog/icon-preview.h \ - ui/dialog/inkscape-preferences.cpp \ - ui/dialog/inkscape-preferences.h \ - ui/dialog/input.cpp \ - ui/dialog/input.h \ - ui/dialog/knot-properties.cpp \ - ui/dialog/knot-properties.h \ - ui/dialog/layer-properties.cpp \ - ui/dialog/layer-properties.h \ - ui/dialog/layers.cpp \ - ui/dialog/layers.h \ - ui/dialog/livepatheffect-add.cpp \ - ui/dialog/livepatheffect-add.h \ - ui/dialog/livepatheffect-editor.cpp \ - ui/dialog/livepatheffect-editor.h \ - ui/dialog/memory.cpp \ - ui/dialog/memory.h \ - ui/dialog/messages.cpp \ - ui/dialog/messages.h \ - ui/dialog/new-from-template.cpp \ - ui/dialog/new-from-template.h \ - ui/dialog/ocaldialogs.cpp \ - ui/dialog/ocaldialogs.h \ - ui/dialog/object-attributes.cpp \ - ui/dialog/object-attributes.h \ - ui/dialog/object-properties.cpp \ - ui/dialog/object-properties.h \ - ui/dialog/panel-dialog.h \ - ui/dialog/polar-arrange-tab.cpp \ - ui/dialog/polar-arrange-tab.h \ - ui/dialog/print.cpp \ - ui/dialog/print.h \ - ui/dialog/print-colors-preview-dialog.cpp \ - ui/dialog/print-colors-preview-dialog.h \ - ui/dialog/spellcheck.cpp \ - ui/dialog/spellcheck.h \ - ui/dialog/svg-fonts-dialog.cpp \ - ui/dialog/svg-fonts-dialog.h \ - ui/dialog/swatches.cpp \ - ui/dialog/swatches.h \ - ui/dialog/symbols.cpp \ - ui/dialog/symbols.h \ - ui/dialog/template-load-tab.cpp \ - ui/dialog/template-load-tab.h \ - ui/dialog/template-widget.cpp \ - ui/dialog/template-widget.h \ - ui/dialog/tags.cpp \ - ui/dialog/tags.h \ - ui/dialog/text-edit.cpp \ - ui/dialog/text-edit.h \ - ui/dialog/tile.cpp \ - ui/dialog/tile.h \ - ui/dialog/pixelartdialog.cpp \ - ui/dialog/pixelartdialog.h \ - ui/dialog/transformation.cpp \ - ui/dialog/transformation.h \ - ui/dialog/undo-history.cpp \ - ui/dialog/undo-history.h \ - ui/dialog/xml-tree.cpp \ - ui/dialog/xml-tree.h \ - ui/dialog/lpe-powerstroke-properties.cpp \ - ui/dialog/lpe-powerstroke-properties.h \ - ui/dialog/objects.cpp \ - ui/dialog/objects.h \ - ui/dialog/lpe-fillet-chamfer-properties.cpp \ - ui/dialog/lpe-fillet-chamfer-properties.h \ - $(inkboard_dialogs) - -if HAVE_POTRACE - -ink_common_sources += \ - ui/dialog/tracedialog.cpp \ - ui/dialog/tracedialog.h - -endif diff --git a/src/ui/tool/Makefile_insert b/src/ui/tool/Makefile_insert deleted file mode 100644 index f46f48b72..000000000 --- a/src/ui/tool/Makefile_insert +++ /dev/null @@ -1,30 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - ui/tool/control-point.cpp \ - ui/tool/control-point.h \ - ui/tool/control-point-selection.cpp \ - ui/tool/control-point-selection.h \ - ui/tool/commit-events.h \ - ui/tool/curve-drag-point.cpp \ - ui/tool/curve-drag-point.h \ - ui/tool/event-utils.cpp \ - ui/tool/event-utils.h \ - ui/tool/manipulator.cpp \ - ui/tool/manipulator.h \ - ui/tool/modifier-tracker.cpp \ - ui/tool/modifier-tracker.h \ - ui/tool/multi-path-manipulator.cpp \ - ui/tool/multi-path-manipulator.h \ - ui/tool/node.cpp \ - ui/tool/node.h \ - ui/tool/node-types.h \ - ui/tool/path-manipulator.cpp \ - ui/tool/path-manipulator.h \ - ui/tool/selectable-control-point.cpp \ - ui/tool/selectable-control-point.h \ - ui/tool/selector.cpp \ - ui/tool/selector.h \ - ui/tool/shape-record.h \ - ui/tool/transform-handle-set.cpp \ - ui/tool/transform-handle-set.h diff --git a/src/ui/tools/Makefile_insert b/src/ui/tools/Makefile_insert deleted file mode 100644 index 686dfedd8..000000000 --- a/src/ui/tools/Makefile_insert +++ /dev/null @@ -1,34 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - ui/tools/arc-tool.cpp ui/tools/arc-tool.h \ - ui/tools/box3d-tool.cpp ui/tools/box3d-tool.h \ - ui/tools/calligraphic-tool.cpp ui/tools/calligraphic-tool.h \ - ui/tools/connector-tool.cpp ui/tools/connector-tool.h \ - ui/tools/dropper-tool.cpp ui/tools/dropper-tool.h \ - ui/tools/dynamic-base.cpp ui/tools/dynamic-base.h \ - ui/tools/eraser-tool.cpp ui/tools/eraser-tool.h \ - ui/tools/freehand-base.cpp ui/tools/freehand-base.h \ - ui/tools/gradient-tool.cpp ui/tools/gradient-tool.h \ - ui/tools/lpe-tool.cpp ui/tools/lpe-tool.h \ - ui/tools/measure-tool.cpp ui/tools/measure-tool.h \ - ui/tools/mesh-tool.cpp ui/tools/mesh-tool.h \ - ui/tools/node-tool.cpp ui/tools/node-tool.h \ - ui/tools/pen-tool.cpp ui/tools/pen-tool.h \ - ui/tools/pencil-tool.cpp ui/tools/pencil-tool.h \ - ui/tools/rect-tool.cpp ui/tools/rect-tool.h \ - ui/tools/select-tool.cpp ui/tools/select-tool.h \ - ui/tools/spiral-tool.cpp ui/tools/spiral-tool.h \ - ui/tools/spray-tool.cpp ui/tools/spray-tool.h \ - ui/tools/star-tool.cpp ui/tools/star-tool.h \ - ui/tools/text-tool.cpp ui/tools/text-tool.h \ - ui/tools/tool-base.cpp ui/tools/tool-base.h \ - ui/tools/tweak-tool.cpp ui/tools/tweak-tool.h \ - ui/tools/zoom-tool.cpp ui/tools/zoom-tool.h - -if HAVE_POTRACE - -ink_common_sources += \ - ui/tools/flood-tool.cpp ui/tools/flood-tool.h - -endif diff --git a/src/ui/view/Makefile_insert b/src/ui/view/Makefile_insert deleted file mode 100644 index b3ab598d4..000000000 --- a/src/ui/view/Makefile_insert +++ /dev/null @@ -1,9 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - ui/view/edit-widget-interface.h \ - ui/view/view.h \ - ui/view/view.cpp \ - ui/view/view-widget.cpp \ - ui/view/view-widget.h - diff --git a/src/ui/widget/Makefile_insert b/src/ui/widget/Makefile_insert deleted file mode 100644 index b22e4bd74..000000000 --- a/src/ui/widget/Makefile_insert +++ /dev/null @@ -1,106 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - ui/widget/anchor-selector.h \ - ui/widget/anchor-selector.cpp \ - ui/widget/attr-widget.h \ - ui/widget/button.h \ - ui/widget/button.cpp \ - ui/widget/color-entry.cpp \ - ui/widget/color-entry.h \ - ui/widget/color-icc-selector.cpp \ - ui/widget/color-icc-selector.h \ - ui/widget/color-notebook.cpp \ - ui/widget/color-notebook.h \ - ui/widget/color-wheel-selector.cpp \ - ui/widget/color-wheel-selector.h \ - ui/widget/color-picker.cpp \ - ui/widget/color-picker.h \ - ui/widget/color-preview.cpp \ - ui/widget/color-preview.h \ - ui/widget/color-slider.cpp \ - ui/widget/color-slider.h \ - ui/widget/color-scales.cpp \ - ui/widget/color-scales.h \ - ui/widget/combo-enums.h \ - ui/widget/dock.h \ - ui/widget/dock.cpp \ - ui/widget/dock-item.h \ - ui/widget/dock-item.cpp \ - ui/widget/entity-entry.cpp \ - ui/widget/entity-entry.h \ - ui/widget/entry.cpp \ - ui/widget/entry.h \ - ui/widget/filter-effect-chooser.h \ - ui/widget/filter-effect-chooser.cpp \ - ui/widget/font-variants.h \ - ui/widget/font-variants.cpp \ - ui/widget/frame.cpp \ - ui/widget/frame.h \ - ui/widget/imageicon.cpp \ - ui/widget/imageicon.h \ - ui/widget/imagetoggler.cpp \ - ui/widget/imagetoggler.h \ - ui/widget/labelled.cpp \ - ui/widget/labelled.h \ - ui/widget/layer-selector.cpp \ - ui/widget/layer-selector.h \ - ui/widget/licensor.cpp \ - ui/widget/licensor.h \ - ui/widget/notebook-page.cpp \ - ui/widget/notebook-page.h \ - ui/widget/object-composite-settings.cpp \ - ui/widget/object-composite-settings.h \ - ui/widget/page-sizer.cpp \ - ui/widget/page-sizer.h \ - ui/widget/panel.cpp \ - ui/widget/panel.h \ - ui/widget/point.cpp \ - ui/widget/point.h \ - ui/widget/preferences-widget.cpp \ - ui/widget/preferences-widget.h \ - ui/widget/random.cpp \ - ui/widget/random.h \ - ui/widget/registered-widget.cpp \ - ui/widget/registered-widget.h \ - ui/widget/registered-enums.h \ - ui/widget/registry.cpp \ - ui/widget/registry.h \ - ui/widget/rendering-options.cpp \ - ui/widget/rendering-options.h \ - ui/widget/rotateable.h \ - ui/widget/rotateable.cpp \ - ui/widget/scalar-unit.cpp \ - ui/widget/scalar-unit.h \ - ui/widget/scalar.cpp \ - ui/widget/scalar.h \ - ui/widget/selected-style.h \ - ui/widget/selected-style.cpp \ - ui/widget/spinbutton.h \ - ui/widget/spinbutton.cpp \ - ui/widget/spin-scale.h \ - ui/widget/spin-scale.cpp \ - ui/widget/spin-slider.h \ - ui/widget/spin-slider.cpp \ - ui/widget/style-subject.h \ - ui/widget/style-subject.cpp \ - ui/widget/style-swatch.h \ - ui/widget/style-swatch.cpp \ - ui/widget/text.cpp \ - ui/widget/text.h \ - ui/widget/tolerance-slider.cpp \ - ui/widget/tolerance-slider.h \ - ui/widget/unit-menu.cpp \ - ui/widget/unit-menu.h \ - ui/widget/unit-tracker.h \ - ui/widget/unit-tracker.cpp \ - ui/widget/clipmaskicon.cpp \ - ui/widget/clipmaskicon.h \ - ui/widget/highlight-picker.cpp \ - ui/widget/highlight-picker.h \ - ui/widget/layertypeicon.cpp \ - ui/widget/layertypeicon.h \ - ui/widget/insertordericon.cpp \ - ui/widget/insertordericon.h \ - ui/widget/addtoicon.cpp \ - ui/widget/addtoicon.h -- cgit v1.2.3 From d975ffe7b06db18ba418207270f58ec79eb07ae1 Mon Sep 17 00:00:00 2001 From: Alex Henrie Date: Mon, 8 Aug 2016 17:57:01 -0600 Subject: Use Gdk::Seat instead of Gdk::DeviceManager (bzr r15046.1.1) --- src/ui/dialog/filter-effects-dialog.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 97fa47f2f..676dcf31f 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -22,7 +22,12 @@ #include "dialog-manager.h" #include -#include +#include +#if GTK_CHECK_VERSION(3, 20, 0) +# include +#else +# include +#endif #include "ui/widget/spinbutton.h" @@ -1970,8 +1975,13 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtrget_display(); +#if GTK_CHECK_VERSION(3, 20, 0) + auto seat = display->get_default_seat(); + auto device = seat->get_pointer(); +#else auto dm = display->get_device_manager(); auto device = dm->get_client_pointer(); +#endif get_bin_window()->get_device_position(device, mx, my, mask); // Outline the bottom of the connection area -- cgit v1.2.3 From 860883afa75a3a2f60ed5ffc299447409138736f Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Wed, 10 Aug 2016 11:39:55 +0100 Subject: CloneTiler: C++ify (bzr r15050) --- src/ui/dialog/clonetiler.cpp | 116 ++++++++++++++++--------------------------- src/ui/dialog/clonetiler.h | 18 ++++--- 2 files changed, 56 insertions(+), 78 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index 1fa7a6c71..eb55e06c6 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -66,7 +66,6 @@ static SPDocument *trace_doc = NULL; CloneTiler::CloneTiler () : UI::Widget::Panel ("", "/dialogs/clonetiler/", SP_VERB_DIALOG_CLONETILER), - dlg(NULL), desktop(NULL), deskTrack(), table_row_labels(NULL) @@ -75,9 +74,7 @@ CloneTiler::CloneTiler () : contents->set_spacing(0); { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - - dlg = GTK_WIDGET(gobj()); + auto prefs = Inkscape::Preferences::get(); auto mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); gtk_box_set_homogeneous(GTK_BOX(mainbox), FALSE); @@ -769,15 +766,14 @@ CloneTiler::CloneTiler () : gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_do_pick_toggled), (gpointer)dlg); + G_CALLBACK(clonetiler_do_pick_toggled), (gpointer)this); } { auto vvb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_box_set_homogeneous(GTK_BOX(vvb), FALSE); gtk_box_pack_start (GTK_BOX (vb), vvb, FALSE, FALSE, 0); - g_object_set_data (G_OBJECT(dlg), "dotrace", (gpointer) vvb); - + _dotrace = vvb; { GtkWidget *frame = gtk_frame_new (_("1. Pick from the drawing:")); @@ -973,7 +969,7 @@ CloneTiler::CloneTiler () : { auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); - g_object_set_data (G_OBJECT(dlg), "rowscols", (gpointer) hb); + _rowscols = hb; { auto a = Gtk::Adjustment::create(0.0, 1, 500, 1, 10, 0); @@ -1018,7 +1014,7 @@ CloneTiler::CloneTiler () : { auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); - g_object_set_data (G_OBJECT(dlg), "widthheight", (gpointer) hb); + _widthheight = hb; // unitmenu unit_menu = new Inkscape::UI::Widget::UnitMenu(); @@ -1081,7 +1077,7 @@ CloneTiler::CloneTiler () : radio = gtk_radio_button_new_with_label (NULL, _("Rows, columns: ")); gtk_widget_set_tooltip_text (radio, _("Create the specified number of rows and columns")); clonetiler_table_attach (table, radio, 0.0, 1, 1); - g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_create), (gpointer) dlg); + g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_create), (gpointer) this); } if (!prefs->getBool(prefs_path + "fillrect")) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); @@ -1091,7 +1087,7 @@ CloneTiler::CloneTiler () : radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Width, height: ")); gtk_widget_set_tooltip_text (radio, _("Fill the specified width and height with the tiling")); clonetiler_table_attach (table, radio, 0.0, 2, 1); - g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_fill), (gpointer) dlg); + g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_fill), (gpointer) this); } if (prefs->getBool(prefs_path + "fillrect")) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); @@ -1122,7 +1118,7 @@ CloneTiler::CloneTiler () : gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); gtk_box_pack_end (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); GtkWidget *l = gtk_label_new(""); - g_object_set_data (G_OBJECT(dlg), "status", (gpointer) l); + _status = l; gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0); } @@ -1133,20 +1129,20 @@ CloneTiler::CloneTiler () : gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); { - GtkWidget *b = gtk_button_new (); - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup_with_mnemonic (GTK_LABEL(l), _(" _Create ")); - gtk_container_add (GTK_CONTAINER(b), l); - gtk_widget_set_tooltip_text (b, _("Create and tile the clones of the selection")); - g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_apply), dlg); - gtk_box_pack_end (GTK_BOX (hb), b, FALSE, FALSE, 0); + auto b = Gtk::manage(new Gtk::Button()); + auto l = Gtk::manage(new Gtk::Label("")); + l->set_markup_with_mnemonic(_(" _Create ")); + b->add(*l); + b->set_tooltip_text(_("Create and tile the clones of the selection")); + b->signal_clicked().connect(sigc::mem_fun(*this, &CloneTiler::apply)); + gtk_box_pack_end (GTK_BOX (hb), GTK_WIDGET(b->gobj()), FALSE, FALSE, 0); } { // buttons which are enabled only when there are tiled clones auto sb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(sb), FALSE); gtk_box_pack_end (GTK_BOX (hb), sb, FALSE, FALSE, 0); - g_object_set_data (G_OBJECT(dlg), "buttons_on_tiles", (gpointer) sb); + _buttons_on_tiles = sb; { // TRANSLATORS: if a group of objects are "clumped" together, then they // are unevenly spread in the given amount of space - as shown in the @@ -1160,28 +1156,26 @@ CloneTiler::CloneTiler () : } { - GtkWidget *b = gtk_button_new_with_mnemonic (_(" Re_move ")); - gtk_widget_set_tooltip_text (b, _("Remove existing tiled clones of the selected object (siblings only)")); - g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_remove), gpointer(dlg)); - gtk_box_pack_end (GTK_BOX (sb), b, FALSE, FALSE, 0); + auto b = Gtk::manage(new Gtk::Button(_(" Re_move "), true)); + b->set_tooltip_text(_("Remove existing tiled clones of the selected object (siblings only)")); + b->signal_clicked().connect(sigc::mem_fun(*this, &CloneTiler::on_remove_button_clicked)); + gtk_box_pack_end (GTK_BOX (sb), GTK_WIDGET(b->gobj()), FALSE, FALSE, 0); } // connect to global selection changed signal (so we can change desktops) and // external_change (so we're not fooled by undo) - selectChangedConn = INKSCAPE.signal_selection_changed.connect(sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_change_selection), dlg)); - externChangedConn = INKSCAPE.signal_external_change.connect (sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_external_change), dlg)); - - g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(clonetiler_disconnect_gsignal), this); + selectChangedConn = INKSCAPE.signal_selection_changed.connect(sigc::mem_fun(*this, &CloneTiler::change_selection)); + externChangedConn = INKSCAPE.signal_external_change.connect(sigc::mem_fun(*this, &CloneTiler::external_change)); // update now - clonetiler_change_selection (SP_ACTIVE_DESKTOP->getSelection(), dlg); + change_selection(SP_ACTIVE_DESKTOP->getSelection()); } { GtkWidget *b = gtk_button_new_with_mnemonic (_(" R_eset ")); // TRANSLATORS: "change" is a noun here gtk_widget_set_tooltip_text (b, _("Reset all shifts, scales, rotates, opacity and color changes in the dialog to zero")); - g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_reset), dlg); + g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_reset), this); gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); } } @@ -1199,8 +1193,9 @@ CloneTiler::CloneTiler () : CloneTiler::~CloneTiler (void) { //subselChangedConn.disconnect(); - //selectChangedConn.disconnect(); //selectModifiedConn.disconnect(); + selectChangedConn.disconnect(); + externChangedConn.disconnect(); desktopChangeConn.disconnect(); deskTrack.disconnect(); color_changed_connection.disconnect(); @@ -1215,17 +1210,7 @@ void CloneTiler::setDesktop(SPDesktop *desktop) void CloneTiler::setTargetDesktop(SPDesktop *desktop) { if (this->desktop != desktop) { - if (this->desktop) { - //selectModifiedConn.disconnect(); - //subselChangedConn.disconnect(); - //selectChangedConn.disconnect(); - } this->desktop = desktop; - if (desktop && desktop->selection) { - //selectChangedConn = desktop->selection->connectChanged(sigc::hide(sigc::mem_fun(*this, &CloneTiler::clonetiler_change_selection))); - //subselChangedConn = desktop->connectToolSubselectionChanged(sigc::hide(sigc::mem_fun(*this, &CloneTiler::clonetiler_change_selection))); - //selectModifiedConn = desktop->selection->connectModified(sigc::hide<0>(sigc::mem_fun(*this, &CloneTiler::clonetiler_change_selection))); - } } } @@ -1245,47 +1230,35 @@ void CloneTiler::on_picker_color_changed(guint rgba) is_updating = false; } -void CloneTiler::clonetiler_change_selection(Inkscape::Selection *selection, GtkWidget *dlg) +void CloneTiler::change_selection(Inkscape::Selection *selection) { - GtkWidget *buttons = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "buttons_on_tiles")); - GtkWidget *status = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "status")); - if (selection->isEmpty()) { - gtk_widget_set_sensitive (buttons, FALSE); - gtk_label_set_markup (GTK_LABEL(status), _("Nothing selected.")); + gtk_widget_set_sensitive (_buttons_on_tiles, FALSE); + gtk_label_set_markup (GTK_LABEL(_status), _("Nothing selected.")); return; } if (boost::distance(selection->items()) > 1) { - gtk_widget_set_sensitive (buttons, FALSE); - gtk_label_set_markup (GTK_LABEL(status), _("More than one object selected.")); + gtk_widget_set_sensitive (_buttons_on_tiles, FALSE); + gtk_label_set_markup (GTK_LABEL(_status), _("More than one object selected.")); return; } guint n = clonetiler_number_of_clones(selection->singleItem()); if (n > 0) { - gtk_widget_set_sensitive (buttons, TRUE); + gtk_widget_set_sensitive (_buttons_on_tiles, TRUE); gchar *sta = g_strdup_printf (_("Object has %d tiled clones."), n); - gtk_label_set_markup (GTK_LABEL(status), sta); + gtk_label_set_markup (GTK_LABEL(_status), sta); g_free (sta); } else { - gtk_widget_set_sensitive (buttons, FALSE); - gtk_label_set_markup (GTK_LABEL(status), _("Object has no tiled clones.")); + gtk_widget_set_sensitive (_buttons_on_tiles, FALSE); + gtk_label_set_markup (GTK_LABEL(_status), _("Object has no tiled clones.")); } } -void CloneTiler::clonetiler_external_change(GtkWidget *dlg) -{ - clonetiler_change_selection (SP_ACTIVE_DESKTOP->getSelection(), dlg); -} - -void CloneTiler::clonetiler_disconnect_gsignal(GObject *, gpointer source) +void CloneTiler::external_change() { - g_return_if_fail(source != NULL); - - CloneTiler* dlg = reinterpret_cast(source); - dlg->selectChangedConn.disconnect(); - dlg->externChangedConn.disconnect(); + change_selection(SP_ACTIVE_DESKTOP->getSelection()); } Geom::Affine CloneTiler::clonetiler_get_transform( @@ -2032,7 +2005,7 @@ guint CloneTiler::clonetiler_number_of_clones(SPObject *obj) return n; } -void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool do_undo/* = true*/) +void CloneTiler::remove(bool do_undo/* = true*/) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop == NULL) { @@ -2064,7 +2037,7 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d } g_slist_free (to_delete); - clonetiler_change_selection (selection, dlg); + change_selection (selection); if (do_undo) { DocumentUndo::done(desktop->getDocument(), SP_VERB_DIALOG_CLONETILER, @@ -2104,7 +2077,7 @@ double CloneTiler::randomize01(double val, double rand) } -void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) +void CloneTiler::apply() { SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop == NULL) { @@ -2129,9 +2102,8 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) desktop->setWaitingCursor(); // set statusbar text - GtkWidget *status = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "status")); - gtk_label_set_markup (GTK_LABEL(status), _("Creating tiled clones...")); - gtk_widget_queue_draw(GTK_WIDGET(status)); + gtk_label_set_markup (GTK_LABEL(_status), _("Creating tiled clones...")); + gtk_widget_queue_draw(GTK_WIDGET(_status)); gdk_window_process_all_updates(); SPObject *obj = selection->singleItem(); @@ -2144,7 +2116,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) const char *id_href = g_strdup_printf("#%s", obj_repr->attribute("id")); SPObject *parent = obj->parent; - clonetiler_remove (NULL, dlg, false); + remove(false); Geom::Scale scale = desktop->getDocument()->getDocumentScale().inverse(); double scale_units = scale[Geom::X]; // Use just x direction.... @@ -2542,7 +2514,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) clonetiler_trace_finish (); } - clonetiler_change_selection (selection, dlg); + change_selection(selection); desktop->clearWaitingCursor(); diff --git a/src/ui/dialog/clonetiler.h b/src/ui/dialog/clonetiler.h index e76ad028e..9ad3fa878 100644 --- a/src/ui/dialog/clonetiler.h +++ b/src/ui/dialog/clonetiler.h @@ -41,7 +41,6 @@ protected: void clonetiler_table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col); static void clonetiler_symgroup_changed(GtkComboBox *cb, gpointer /*data*/); - static void clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool do_undo = true); static void on_picker_color_changed(guint rgba); static void clonetiler_trace_hide_tiled_clones_recursively(SPObject *from); static void clonetiler_checkbox_toggled(GtkToggleButton *tb, gpointer *data); @@ -55,11 +54,7 @@ protected: static void clonetiler_switch_to_create(GtkToggleButton */*tb*/, GtkWidget *dlg); static void clonetiler_switch_to_fill(GtkToggleButton */*tb*/, GtkWidget *dlg); static void clonetiler_keep_bbox_toggled(GtkToggleButton *tb, gpointer /*data*/); - static void clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg); static void clonetiler_unclump(GtkWidget */*widget*/, void *); - static void clonetiler_change_selection(Inkscape::Selection *selection, GtkWidget *dlg); - static void clonetiler_external_change(GtkWidget *dlg); - static void clonetiler_disconnect_gsignal(GObject *widget, gpointer source); static void clonetiler_reset(GtkWidget */*widget*/, GtkWidget *dlg); static guint clonetiler_number_of_clones(SPObject *obj); static void clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *original); @@ -71,6 +66,12 @@ protected: static void clonetiler_value_changed(GtkAdjustment *adj, gpointer data); static void clonetiler_reset_recursive(GtkWidget *w); + void apply(); + void change_selection(Inkscape::Selection *selection); + void external_change(); + void remove(bool do_undo = true); + void on_remove_button_clicked() {remove();} + static Geom::Affine clonetiler_get_transform( // symmetry group int type, @@ -112,7 +113,6 @@ private: CloneTiler(CloneTiler const &d); CloneTiler& operator=(CloneTiler const &d); - GtkWidget *dlg; GtkWidget *nb; GtkWidget *b; SPDesktop *desktop; @@ -142,6 +142,12 @@ private: */ void setTargetDesktop(SPDesktop *desktop); + // Variables that used to be set using GObject + GtkWidget *_buttons_on_tiles; + GtkWidget *_dotrace; + GtkWidget *_status; + GtkWidget *_rowscols; + GtkWidget *_widthheight; }; -- cgit v1.2.3 From 349e2e3bc0b11c89a0a791e7feedfc9e0c457e5d Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Wed, 10 Aug 2016 12:39:30 +0100 Subject: CloneTiler: Further C++ification (bzr r15051) --- src/ui/dialog/clonetiler.cpp | 511 ++++++++++++++++++++++--------------------- src/ui/dialog/clonetiler.h | 65 +++--- 2 files changed, 292 insertions(+), 284 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index eb55e06c6..8bd5cd5f6 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -22,7 +22,9 @@ #include #include <2geom/transforms.h> + #include +#include #include "desktop.h" @@ -88,7 +90,7 @@ CloneTiler::CloneTiler () : // Symmetry { - GtkWidget *vb = clonetiler_new_tab (nb, _("_Symmetry")); + GtkWidget *vb = new_tab (nb, _("_Symmetry")); /* TRANSLATORS: For the following 17 symmetry groups, see * http://www.bib.ulb.ac.be/coursmath/doc/17.htm (visual examples); @@ -149,16 +151,16 @@ CloneTiler::CloneTiler () : gtk_combo_box_set_active (GTK_COMBO_BOX (combo), current); g_signal_connect(G_OBJECT(combo), "changed", - G_CALLBACK(clonetiler_symgroup_changed), NULL); + G_CALLBACK(symgroup_changed), NULL); } table_row_labels = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); // Shift { - GtkWidget *vb = clonetiler_new_tab (nb, _("S_hift")); + GtkWidget *vb = new_tab (nb, _("S_hift")); - GtkWidget *table = clonetiler_table_x_y_rand (3); + GtkWidget *table = table_x_y_rand (3); gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); // X @@ -168,29 +170,29 @@ CloneTiler::CloneTiler () : // xgettext:no-c-format gtk_label_set_markup (GTK_LABEL(l), _("Shift X:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 2, 1); + table_attach (table, l, 1, 2, 1); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( // xgettext:no-c-format _("Horizontal shift per row (in % of tile width)"), "shiftx_per_j", -10000, 10000, "%"); - clonetiler_table_attach (table, l, 0, 2, 2); + table_attach (table, l, 0, 2, 2); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( // xgettext:no-c-format _("Horizontal shift per column (in % of tile width)"), "shiftx_per_i", -10000, 10000, "%"); - clonetiler_table_attach (table, l, 0, 2, 3); + table_attach (table, l, 0, 2, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the horizontal shift by this percentage"), "shiftx_rand", + GtkWidget *l = spinbox (_("Randomize the horizontal shift by this percentage"), "shiftx_rand", 0, 1000, "%"); - clonetiler_table_attach (table, l, 0, 2, 4); + table_attach (table, l, 0, 2, 4); } // Y @@ -200,30 +202,30 @@ CloneTiler::CloneTiler () : // xgettext:no-c-format gtk_label_set_markup (GTK_LABEL(l), _("Shift Y:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 3, 1); + table_attach (table, l, 1, 3, 1); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( // xgettext:no-c-format _("Vertical shift per row (in % of tile height)"), "shifty_per_j", -10000, 10000, "%"); - clonetiler_table_attach (table, l, 0, 3, 2); + table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( // xgettext:no-c-format _("Vertical shift per column (in % of tile height)"), "shifty_per_i", -10000, 10000, "%"); - clonetiler_table_attach (table, l, 0, 3, 3); + table_attach (table, l, 0, 3, 3); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( _("Randomize the vertical shift by this percentage"), "shifty_rand", 0, 1000, "%"); - clonetiler_table_attach (table, l, 0, 3, 4); + table_attach (table, l, 0, 3, 4); } // Exponent @@ -231,21 +233,21 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Exponent:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 4, 1); + table_attach (table, l, 1, 4, 1); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( _("Whether rows are spaced evenly (1), converge (<1) or diverge (>1)"), "shifty_exp", 0, 10, "", true); - clonetiler_table_attach (table, l, 0, 4, 2); + table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( _("Whether columns are spaced evenly (1), converge (<1) or diverge (>1)"), "shiftx_exp", 0, 10, "", true); - clonetiler_table_attach (table, l, 0, 4, 3); + table_attach (table, l, 0, 4, 3); } { // alternates @@ -253,17 +255,17 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Alternate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("Alternate:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 5, 1); + table_attach (table, l, 1, 5, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of shifts for each row"), "shifty_alternate"); - clonetiler_table_attach (table, l, 0, 5, 2); + GtkWidget *l = checkbox (_("Alternate the sign of shifts for each row"), "shifty_alternate"); + table_attach (table, l, 0, 5, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of shifts for each column"), "shiftx_alternate"); - clonetiler_table_attach (table, l, 0, 5, 3); + GtkWidget *l = checkbox (_("Alternate the sign of shifts for each column"), "shiftx_alternate"); + table_attach (table, l, 0, 5, 3); } { // Cumulate @@ -271,17 +273,17 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Cumulate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("Cumulate:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 6, 1); + table_attach (table, l, 1, 6, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Cumulate the shifts for each row"), "shifty_cumulate"); - clonetiler_table_attach (table, l, 0, 6, 2); + GtkWidget *l = checkbox (_("Cumulate the shifts for each row"), "shifty_cumulate"); + table_attach (table, l, 0, 6, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Cumulate the shifts for each column"), "shiftx_cumulate"); - clonetiler_table_attach (table, l, 0, 6, 3); + GtkWidget *l = checkbox (_("Cumulate the shifts for each column"), "shiftx_cumulate"); + table_attach (table, l, 0, 6, 3); } { // Exclude tile width and height in shift @@ -289,17 +291,17 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Cumulate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("Exclude tile:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 7, 1); + table_attach (table, l, 1, 7, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Exclude tile height in shift"), "shifty_excludeh"); - clonetiler_table_attach (table, l, 0, 7, 2); + GtkWidget *l = checkbox (_("Exclude tile height in shift"), "shifty_excludeh"); + table_attach (table, l, 0, 7, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Exclude tile width in shift"), "shiftx_excludew"); - clonetiler_table_attach (table, l, 0, 7, 3); + GtkWidget *l = checkbox (_("Exclude tile width in shift"), "shiftx_excludew"); + table_attach (table, l, 0, 7, 3); } } @@ -307,9 +309,9 @@ CloneTiler::CloneTiler () : // Scale { - GtkWidget *vb = clonetiler_new_tab (nb, _("Sc_ale")); + GtkWidget *vb = new_tab (nb, _("Sc_ale")); - GtkWidget *table = clonetiler_table_x_y_rand (2); + GtkWidget *table = table_x_y_rand (2); gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); // X @@ -317,29 +319,29 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Scale X:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 2, 1); + table_attach (table, l, 1, 2, 1); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( // xgettext:no-c-format _("Horizontal scale per row (in % of tile width)"), "scalex_per_j", -100, 1000, "%"); - clonetiler_table_attach (table, l, 0, 2, 2); + table_attach (table, l, 0, 2, 2); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( // xgettext:no-c-format _("Horizontal scale per column (in % of tile width)"), "scalex_per_i", -100, 1000, "%"); - clonetiler_table_attach (table, l, 0, 2, 3); + table_attach (table, l, 0, 2, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the horizontal scale by this percentage"), "scalex_rand", + GtkWidget *l = spinbox (_("Randomize the horizontal scale by this percentage"), "scalex_rand", 0, 1000, "%"); - clonetiler_table_attach (table, l, 0, 2, 4); + table_attach (table, l, 0, 2, 4); } // Y @@ -347,29 +349,29 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Scale Y:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 3, 1); + table_attach (table, l, 1, 3, 1); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( // xgettext:no-c-format _("Vertical scale per row (in % of tile height)"), "scaley_per_j", -100, 1000, "%"); - clonetiler_table_attach (table, l, 0, 3, 2); + table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( // xgettext:no-c-format _("Vertical scale per column (in % of tile height)"), "scaley_per_i", -100, 1000, "%"); - clonetiler_table_attach (table, l, 0, 3, 3); + table_attach (table, l, 0, 3, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the vertical scale by this percentage"), "scaley_rand", + GtkWidget *l = spinbox (_("Randomize the vertical scale by this percentage"), "scaley_rand", 0, 1000, "%"); - clonetiler_table_attach (table, l, 0, 3, 4); + table_attach (table, l, 0, 3, 4); } // Exponent @@ -377,19 +379,19 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Exponent:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 4, 1); + table_attach (table, l, 1, 4, 1); } { - GtkWidget *l = clonetiler_spinbox (_("Whether row scaling is uniform (1), converge (<1) or diverge (>1)"), "scaley_exp", + GtkWidget *l = spinbox (_("Whether row scaling is uniform (1), converge (<1) or diverge (>1)"), "scaley_exp", 0, 10, "", true); - clonetiler_table_attach (table, l, 0, 4, 2); + table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = clonetiler_spinbox (_("Whether column scaling is uniform (1), converge (<1) or diverge (>1)"), "scalex_exp", + GtkWidget *l = spinbox (_("Whether column scaling is uniform (1), converge (<1) or diverge (>1)"), "scalex_exp", 0, 10, "", true); - clonetiler_table_attach (table, l, 0, 4, 3); + table_attach (table, l, 0, 4, 3); } // Logarithmic (as in logarithmic spiral) @@ -397,19 +399,19 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Base:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 5, 1); + table_attach (table, l, 1, 5, 1); } { - GtkWidget *l = clonetiler_spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scaley_log", + GtkWidget *l = spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scaley_log", 0, 10, "", false); - clonetiler_table_attach (table, l, 0, 5, 2); + table_attach (table, l, 0, 5, 2); } { - GtkWidget *l = clonetiler_spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scalex_log", + GtkWidget *l = spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scalex_log", 0, 10, "", false); - clonetiler_table_attach (table, l, 0, 5, 3); + table_attach (table, l, 0, 5, 3); } { // alternates @@ -417,17 +419,17 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Alternate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("Alternate:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 6, 1); + table_attach (table, l, 1, 6, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of scales for each row"), "scaley_alternate"); - clonetiler_table_attach (table, l, 0, 6, 2); + GtkWidget *l = checkbox (_("Alternate the sign of scales for each row"), "scaley_alternate"); + table_attach (table, l, 0, 6, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of scales for each column"), "scalex_alternate"); - clonetiler_table_attach (table, l, 0, 6, 3); + GtkWidget *l = checkbox (_("Alternate the sign of scales for each column"), "scalex_alternate"); + table_attach (table, l, 0, 6, 3); } { // Cumulate @@ -435,17 +437,17 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Cumulate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("Cumulate:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 7, 1); + table_attach (table, l, 1, 7, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Cumulate the scales for each row"), "scaley_cumulate"); - clonetiler_table_attach (table, l, 0, 7, 2); + GtkWidget *l = checkbox (_("Cumulate the scales for each row"), "scaley_cumulate"); + table_attach (table, l, 0, 7, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Cumulate the scales for each column"), "scalex_cumulate"); - clonetiler_table_attach (table, l, 0, 7, 3); + GtkWidget *l = checkbox (_("Cumulate the scales for each column"), "scalex_cumulate"); + table_attach (table, l, 0, 7, 3); } } @@ -453,9 +455,9 @@ CloneTiler::CloneTiler () : // Rotation { - GtkWidget *vb = clonetiler_new_tab (nb, _("_Rotation")); + GtkWidget *vb = new_tab (nb, _("_Rotation")); - GtkWidget *table = clonetiler_table_x_y_rand (1); + GtkWidget *table = table_x_y_rand (1); gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); // Angle @@ -463,29 +465,29 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Angle:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 2, 1); + table_attach (table, l, 1, 2, 1); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( // xgettext:no-c-format _("Rotate tiles by this angle for each row"), "rotate_per_j", -180, 180, "°"); - clonetiler_table_attach (table, l, 0, 2, 2); + table_attach (table, l, 0, 2, 2); } { - GtkWidget *l = clonetiler_spinbox ( + GtkWidget *l = spinbox ( // xgettext:no-c-format _("Rotate tiles by this angle for each column"), "rotate_per_i", -180, 180, "°"); - clonetiler_table_attach (table, l, 0, 2, 3); + table_attach (table, l, 0, 2, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the rotation angle by this percentage"), "rotate_rand", + GtkWidget *l = spinbox (_("Randomize the rotation angle by this percentage"), "rotate_rand", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 4); + table_attach (table, l, 0, 2, 4); } { // alternates @@ -493,17 +495,17 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Alternate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("Alternate:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 3, 1); + table_attach (table, l, 1, 3, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the rotation direction for each row"), "rotate_alternatej"); - clonetiler_table_attach (table, l, 0, 3, 2); + GtkWidget *l = checkbox (_("Alternate the rotation direction for each row"), "rotate_alternatej"); + table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the rotation direction for each column"), "rotate_alternatei"); - clonetiler_table_attach (table, l, 0, 3, 3); + GtkWidget *l = checkbox (_("Alternate the rotation direction for each column"), "rotate_alternatei"); + table_attach (table, l, 0, 3, 3); } { // Cumulate @@ -511,17 +513,17 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Cumulate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("Cumulate:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 4, 1); + table_attach (table, l, 1, 4, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Cumulate the rotation for each row"), "rotate_cumulatej"); - clonetiler_table_attach (table, l, 0, 4, 2); + GtkWidget *l = checkbox (_("Cumulate the rotation for each row"), "rotate_cumulatej"); + table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Cumulate the rotation for each column"), "rotate_cumulatei"); - clonetiler_table_attach (table, l, 0, 4, 3); + GtkWidget *l = checkbox (_("Cumulate the rotation for each column"), "rotate_cumulatei"); + table_attach (table, l, 0, 4, 3); } } @@ -529,9 +531,9 @@ CloneTiler::CloneTiler () : // Blur and opacity { - GtkWidget *vb = clonetiler_new_tab (nb, _("_Blur & opacity")); + GtkWidget *vb = new_tab (nb, _("_Blur & opacity")); - GtkWidget *table = clonetiler_table_x_y_rand (1); + GtkWidget *table = table_x_y_rand (1); gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); @@ -540,25 +542,25 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Blur:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 2, 1); + table_attach (table, l, 1, 2, 1); } { - GtkWidget *l = clonetiler_spinbox (_("Blur tiles by this percentage for each row"), "blur_per_j", + GtkWidget *l = spinbox (_("Blur tiles by this percentage for each row"), "blur_per_j", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 2); + table_attach (table, l, 0, 2, 2); } { - GtkWidget *l = clonetiler_spinbox (_("Blur tiles by this percentage for each column"), "blur_per_i", + GtkWidget *l = spinbox (_("Blur tiles by this percentage for each column"), "blur_per_i", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 3); + table_attach (table, l, 0, 2, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the tile blur by this percentage"), "blur_rand", + GtkWidget *l = spinbox (_("Randomize the tile blur by this percentage"), "blur_rand", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 4); + table_attach (table, l, 0, 2, 4); } { // alternates @@ -566,17 +568,17 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Alternate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("Alternate:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 3, 1); + table_attach (table, l, 1, 3, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of blur change for each row"), "blur_alternatej"); - clonetiler_table_attach (table, l, 0, 3, 2); + GtkWidget *l = checkbox (_("Alternate the sign of blur change for each row"), "blur_alternatej"); + table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of blur change for each column"), "blur_alternatei"); - clonetiler_table_attach (table, l, 0, 3, 3); + GtkWidget *l = checkbox (_("Alternate the sign of blur change for each column"), "blur_alternatei"); + table_attach (table, l, 0, 3, 3); } @@ -586,25 +588,25 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Opacity:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 4, 1); + table_attach (table, l, 1, 4, 1); } { - GtkWidget *l = clonetiler_spinbox (_("Decrease tile opacity by this percentage for each row"), "opacity_per_j", + GtkWidget *l = spinbox (_("Decrease tile opacity by this percentage for each row"), "opacity_per_j", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 4, 2); + table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = clonetiler_spinbox (_("Decrease tile opacity by this percentage for each column"), "opacity_per_i", + GtkWidget *l = spinbox (_("Decrease tile opacity by this percentage for each column"), "opacity_per_i", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 4, 3); + table_attach (table, l, 0, 4, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the tile opacity by this percentage"), "opacity_rand", + GtkWidget *l = spinbox (_("Randomize the tile opacity by this percentage"), "opacity_rand", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 4, 4); + table_attach (table, l, 0, 4, 4); } { // alternates @@ -612,24 +614,24 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Alternate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("Alternate:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 5, 1); + table_attach (table, l, 1, 5, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of opacity change for each row"), "opacity_alternatej"); - clonetiler_table_attach (table, l, 0, 5, 2); + GtkWidget *l = checkbox (_("Alternate the sign of opacity change for each row"), "opacity_alternatej"); + table_attach (table, l, 0, 5, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of opacity change for each column"), "opacity_alternatei"); - clonetiler_table_attach (table, l, 0, 5, 3); + GtkWidget *l = checkbox (_("Alternate the sign of opacity change for each column"), "opacity_alternatei"); + table_attach (table, l, 0, 5, 3); } } // Color { - GtkWidget *vb = clonetiler_new_tab (nb, _("Co_lor")); + GtkWidget *vb = new_tab (nb, _("Co_lor")); { auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); @@ -648,7 +650,7 @@ CloneTiler::CloneTiler () : } - GtkWidget *table = clonetiler_table_x_y_rand (3); + GtkWidget *table = table_x_y_rand (3); gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); // Hue @@ -656,25 +658,25 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("H:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 2, 1); + table_attach (table, l, 1, 2, 1); } { - GtkWidget *l = clonetiler_spinbox (_("Change the tile hue by this percentage for each row"), "hue_per_j", + GtkWidget *l = spinbox (_("Change the tile hue by this percentage for each row"), "hue_per_j", -100, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 2); + table_attach (table, l, 0, 2, 2); } { - GtkWidget *l = clonetiler_spinbox (_("Change the tile hue by this percentage for each column"), "hue_per_i", + GtkWidget *l = spinbox (_("Change the tile hue by this percentage for each column"), "hue_per_i", -100, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 3); + table_attach (table, l, 0, 2, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the tile hue by this percentage"), "hue_rand", + GtkWidget *l = spinbox (_("Randomize the tile hue by this percentage"), "hue_rand", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 4); + table_attach (table, l, 0, 2, 4); } @@ -683,25 +685,25 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("S:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 3, 1); + table_attach (table, l, 1, 3, 1); } { - GtkWidget *l = clonetiler_spinbox (_("Change the color saturation by this percentage for each row"), "saturation_per_j", + GtkWidget *l = spinbox (_("Change the color saturation by this percentage for each row"), "saturation_per_j", -100, 100, "%"); - clonetiler_table_attach (table, l, 0, 3, 2); + table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = clonetiler_spinbox (_("Change the color saturation by this percentage for each column"), "saturation_per_i", + GtkWidget *l = spinbox (_("Change the color saturation by this percentage for each column"), "saturation_per_i", -100, 100, "%"); - clonetiler_table_attach (table, l, 0, 3, 3); + table_attach (table, l, 0, 3, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the color saturation by this percentage"), "saturation_rand", + GtkWidget *l = spinbox (_("Randomize the color saturation by this percentage"), "saturation_rand", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 3, 4); + table_attach (table, l, 0, 3, 4); } // Lightness @@ -709,25 +711,25 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("L:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 4, 1); + table_attach (table, l, 1, 4, 1); } { - GtkWidget *l = clonetiler_spinbox (_("Change the color lightness by this percentage for each row"), "lightness_per_j", + GtkWidget *l = spinbox (_("Change the color lightness by this percentage for each row"), "lightness_per_j", -100, 100, "%"); - clonetiler_table_attach (table, l, 0, 4, 2); + table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = clonetiler_spinbox (_("Change the color lightness by this percentage for each column"), "lightness_per_i", + GtkWidget *l = spinbox (_("Change the color lightness by this percentage for each column"), "lightness_per_i", -100, 100, "%"); - clonetiler_table_attach (table, l, 0, 4, 3); + table_attach (table, l, 0, 4, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the color lightness by this percentage"), "lightness_rand", + GtkWidget *l = spinbox (_("Randomize the color lightness by this percentage"), "lightness_rand", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 4, 4); + table_attach (table, l, 0, 4, 4); } @@ -735,38 +737,36 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Alternate:")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 5, 1); + table_attach (table, l, 1, 5, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of color changes for each row"), "color_alternatej"); - clonetiler_table_attach (table, l, 0, 5, 2); + GtkWidget *l = checkbox (_("Alternate the sign of color changes for each row"), "color_alternatej"); + table_attach (table, l, 0, 5, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of color changes for each column"), "color_alternatei"); - clonetiler_table_attach (table, l, 0, 5, 3); + GtkWidget *l = checkbox (_("Alternate the sign of color changes for each column"), "color_alternatei"); + table_attach (table, l, 0, 5, 3); } } // Trace { - GtkWidget *vb = clonetiler_new_tab (nb, _("_Trace")); + GtkWidget *vb = new_tab (nb, _("_Trace")); { auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0); - b = gtk_check_button_new_with_label (_("Trace the drawing under the clones/sprayed items")); - g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE)); + _b = Gtk::manage(new Gtk::CheckButton(_("Trace the drawing under the clones/sprayed items"))); + _b->set_data("uncheckable", GINT_TO_POINTER(TRUE)); bool old = prefs->getBool(prefs_path + "dotrace"); - gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_widget_set_tooltip_text (b, _("For each clone/sprayed item, pick a value from the drawing in its location and apply it")); - gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); - - g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_do_pick_toggled), (gpointer)this); + _b->set_active(old); + _b->set_tooltip_text(_("For each clone/sprayed item, pick a value from the drawing in its location and apply it")); + gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(_b->gobj()), FALSE, FALSE, 0); + _b->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::do_pick_toggled),_b)); } { @@ -789,65 +789,65 @@ CloneTiler::CloneTiler () : { radio = gtk_radio_button_new_with_label (NULL, _("Color")); gtk_widget_set_tooltip_text (radio, _("Pick the visible color and opacity")); - clonetiler_table_attach (table, radio, 0.0, 1, 1); + table_attach (table, radio, 0.0, 1, 1); g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_COLOR)); + G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_COLOR)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_COLOR); } { radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Opacity")); gtk_widget_set_tooltip_text (radio, _("Pick the total accumulated opacity")); - clonetiler_table_attach (table, radio, 0.0, 2, 1); + table_attach (table, radio, 0.0, 2, 1); g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_OPACITY)); + G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_OPACITY)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_OPACITY); } { radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("R")); gtk_widget_set_tooltip_text (radio, _("Pick the Red component of the color")); - clonetiler_table_attach (table, radio, 0.0, 1, 2); + table_attach (table, radio, 0.0, 1, 2); g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_R)); + G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_R)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_R); } { radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("G")); gtk_widget_set_tooltip_text (radio, _("Pick the Green component of the color")); - clonetiler_table_attach (table, radio, 0.0, 2, 2); + table_attach (table, radio, 0.0, 2, 2); g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_G)); + G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_G)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_G); } { radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("B")); gtk_widget_set_tooltip_text (radio, _("Pick the Blue component of the color")); - clonetiler_table_attach (table, radio, 0.0, 3, 2); + table_attach (table, radio, 0.0, 3, 2); g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_B)); + G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_B)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_B); } { radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color hue", "H")); gtk_widget_set_tooltip_text (radio, _("Pick the hue of the color")); - clonetiler_table_attach (table, radio, 0.0, 1, 3); + table_attach (table, radio, 0.0, 1, 3); g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_H)); + G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_H)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_H); } { radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color saturation", "S")); gtk_widget_set_tooltip_text (radio, _("Pick the saturation of the color")); - clonetiler_table_attach (table, radio, 0.0, 2, 3); + table_attach (table, radio, 0.0, 2, 3); g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_S)); + G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_S)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_S); } { radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color lightness", "L")); gtk_widget_set_tooltip_text (radio, _("Pick the lightness of the color")); - clonetiler_table_attach (table, radio, 0.0, 3, 3); + table_attach (table, radio, 0.0, 3, 3); g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_L)); + G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_L)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_L); } @@ -866,33 +866,33 @@ CloneTiler::CloneTiler () : { GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Gamma-correct:")); - clonetiler_table_attach (table, l, 1.0, 1, 1); + table_attach (table, l, 1.0, 1, 1); } { - GtkWidget *l = clonetiler_spinbox (_("Shift the mid-range of the picked value upwards (>0) or downwards (<0)"), "gamma_picked", + GtkWidget *l = spinbox (_("Shift the mid-range of the picked value upwards (>0) or downwards (<0)"), "gamma_picked", -10, 10, ""); - clonetiler_table_attach (table, l, 0.0, 1, 2); + table_attach (table, l, 0.0, 1, 2); } { GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Randomize:")); - clonetiler_table_attach (table, l, 1.0, 1, 3); + table_attach (table, l, 1.0, 1, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the picked value by this percentage"), "rand_picked", + GtkWidget *l = spinbox (_("Randomize the picked value by this percentage"), "rand_picked", 0, 100, "%"); - clonetiler_table_attach (table, l, 0.0, 1, 4); + table_attach (table, l, 0.0, 1, 4); } { GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Invert:")); - clonetiler_table_attach (table, l, 1.0, 2, 1); + table_attach (table, l, 1.0, 2, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Invert the picked value"), "invert_picked"); - clonetiler_table_attach (table, l, 0.0, 2, 2); + GtkWidget *l = checkbox (_("Invert the picked value"), "invert_picked"); + table_attach (table, l, 0.0, 2, 2); } } @@ -910,9 +910,9 @@ CloneTiler::CloneTiler () : bool old = prefs->getBool(prefs_path + "pick_to_presence", true); gtk_toggle_button_set_active ((GtkToggleButton *) b, old); gtk_widget_set_tooltip_text (b, _("Each clone is created with the probability determined by the picked value in that point")); - clonetiler_table_attach (table, b, 0.0, 1, 1); + table_attach (table, b, 0.0, 1, 1); g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_presence"); + G_CALLBACK(pick_to), (gpointer) "pick_to_presence"); } { @@ -920,9 +920,9 @@ CloneTiler::CloneTiler () : bool old = prefs->getBool(prefs_path + "pick_to_size"); gtk_toggle_button_set_active ((GtkToggleButton *) b, old); gtk_widget_set_tooltip_text (b, _("Each clone's size is determined by the picked value in that point")); - clonetiler_table_attach (table, b, 0.0, 2, 1); + table_attach (table, b, 0.0, 2, 1); g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_size"); + G_CALLBACK(pick_to), (gpointer) "pick_to_size"); } { @@ -930,9 +930,9 @@ CloneTiler::CloneTiler () : bool old = prefs->getBool(prefs_path + "pick_to_color", 0); gtk_toggle_button_set_active ((GtkToggleButton *) b, old); gtk_widget_set_tooltip_text (b, _("Each clone is painted by the picked color (the original must have unset fill or stroke)")); - clonetiler_table_attach (table, b, 0.0, 1, 2); + table_attach (table, b, 0.0, 1, 2); g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_color"); + G_CALLBACK(pick_to), (gpointer) "pick_to_color"); } { @@ -940,9 +940,9 @@ CloneTiler::CloneTiler () : bool old = prefs->getBool(prefs_path + "pick_to_opacity", 0); gtk_toggle_button_set_active ((GtkToggleButton *) b, old); gtk_widget_set_tooltip_text (b, _("Each clone's opacity is determined by the picked value in that point")); - clonetiler_table_attach (table, b, 0.0, 2, 2); + table_attach (table, b, 0.0, 2, 2); g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_opacity"); + G_CALLBACK(pick_to), (gpointer) "pick_to_opacity"); } } gtk_widget_set_sensitive (vvb, prefs->getBool(prefs_path + "dotrace")); @@ -983,7 +983,7 @@ CloneTiler::CloneTiler () : // TODO: C++ification g_signal_connect(G_OBJECT(a->gobj()), "value_changed", - G_CALLBACK(clonetiler_xy_changed), (gpointer) "jmax"); + G_CALLBACK(xy_changed), (gpointer) "jmax"); } { @@ -1005,10 +1005,10 @@ CloneTiler::CloneTiler () : // TODO: C++ification g_signal_connect(G_OBJECT(a->gobj()), "value_changed", - G_CALLBACK(clonetiler_xy_changed), (gpointer) "imax"); + G_CALLBACK(xy_changed), (gpointer) "imax"); } - clonetiler_table_attach (table, hb, 0.0, 1, 2); + table_attach (table, hb, 0.0, 1, 2); } { @@ -1020,7 +1020,7 @@ CloneTiler::CloneTiler () : unit_menu = new Inkscape::UI::Widget::UnitMenu(); unit_menu->setUnitType(Inkscape::Util::UNIT_TYPE_LINEAR); unit_menu->setUnit(SP_ACTIVE_DESKTOP->getNamedView()->display_units->abbr); - unitChangedConn = unit_menu->signal_changed().connect(sigc::mem_fun(*this, &CloneTiler::clonetiler_unit_changed)); + unitChangedConn = unit_menu->signal_changed().connect(sigc::mem_fun(*this, &CloneTiler::unit_changed)); { // Width spinbutton @@ -1038,7 +1038,7 @@ CloneTiler::CloneTiler () : gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(e->gobj()), TRUE, TRUE, 0); // TODO: C++ification g_signal_connect(G_OBJECT(fill_width->gobj()), "value_changed", - G_CALLBACK(clonetiler_fill_width_changed), unit_menu); + G_CALLBACK(fill_width_changed), unit_menu); } { GtkWidget *l = gtk_label_new (""); @@ -1063,11 +1063,11 @@ CloneTiler::CloneTiler () : gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(e->gobj()), TRUE, TRUE, 0); // TODO: C++ification g_signal_connect(G_OBJECT(fill_height->gobj()), "value_changed", - G_CALLBACK(clonetiler_fill_height_changed), unit_menu); + G_CALLBACK(fill_height_changed), unit_menu); } gtk_box_pack_start (GTK_BOX (hb), (GtkWidget*) unit_menu->gobj(), TRUE, TRUE, 0); - clonetiler_table_attach (table, hb, 0.0, 2, 2); + table_attach (table, hb, 0.0, 2, 2); } @@ -1076,8 +1076,8 @@ CloneTiler::CloneTiler () : { radio = gtk_radio_button_new_with_label (NULL, _("Rows, columns: ")); gtk_widget_set_tooltip_text (radio, _("Create the specified number of rows and columns")); - clonetiler_table_attach (table, radio, 0.0, 1, 1); - g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_create), (gpointer) this); + table_attach (table, radio, 0.0, 1, 1); + g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (switch_to_create), (gpointer) this); } if (!prefs->getBool(prefs_path + "fillrect")) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); @@ -1086,8 +1086,8 @@ CloneTiler::CloneTiler () : { radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Width, height: ")); gtk_widget_set_tooltip_text (radio, _("Fill the specified width and height with the tiling")); - clonetiler_table_attach (table, radio, 0.0, 2, 1); - g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_fill), (gpointer) this); + table_attach (table, radio, 0.0, 2, 1); + g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (switch_to_fill), (gpointer) this); } if (prefs->getBool(prefs_path + "fillrect")) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); @@ -1109,7 +1109,7 @@ CloneTiler::CloneTiler () : gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_keep_bbox_toggled), NULL); + G_CALLBACK(keep_bbox_toggled), NULL); } // Statusbar @@ -1151,7 +1151,7 @@ CloneTiler::CloneTiler () : // So unclumping is the process of spreading a number of objects out more evenly. GtkWidget *b = gtk_button_new_with_mnemonic (_(" _Unclump ")); gtk_widget_set_tooltip_text (b, _("Spread out clones to reduce clumping; can be applied repeatedly")); - g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_unclump), NULL); + g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (unclump), NULL); gtk_box_pack_end (GTK_BOX (sb), b, FALSE, FALSE, 0); } @@ -1175,7 +1175,7 @@ CloneTiler::CloneTiler () : GtkWidget *b = gtk_button_new_with_mnemonic (_(" R_eset ")); // TRANSLATORS: "change" is a noun here gtk_widget_set_tooltip_text (b, _("Reset all shifts, scales, rotates, opacity and color changes in the dialog to zero")); - g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_reset), this); + g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (reset), this); gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); } } @@ -1244,7 +1244,7 @@ void CloneTiler::change_selection(Inkscape::Selection *selection) return; } - guint n = clonetiler_number_of_clones(selection->singleItem()); + guint n = number_of_clones(selection->singleItem()); if (n > 0) { gtk_widget_set_sensitive (_buttons_on_tiles, TRUE); gchar *sta = g_strdup_printf (_("Object has %d tiled clones."), n); @@ -1261,7 +1261,7 @@ void CloneTiler::external_change() change_selection(SP_ACTIVE_DESKTOP->getSelection()); } -Geom::Affine CloneTiler::clonetiler_get_transform( +Geom::Affine CloneTiler::get_transform( // symmetry group int type, @@ -1863,7 +1863,7 @@ Geom::Affine CloneTiler::clonetiler_get_transform( return Geom::identity(); } -bool CloneTiler::clonetiler_is_a_clone_of(SPObject *tile, SPObject *obj) +bool CloneTiler::is_a_clone_of(SPObject *tile, SPObject *obj) { bool result = false; char *id_href = NULL; @@ -1890,21 +1890,21 @@ bool CloneTiler::clonetiler_is_a_clone_of(SPObject *tile, SPObject *obj) return result; } -void CloneTiler::clonetiler_trace_hide_tiled_clones_recursively(SPObject *from) +void CloneTiler::trace_hide_tiled_clones_recursively(SPObject *from) { if (!trace_drawing) return; for (auto& o: from->children) { SPItem *item = dynamic_cast(&o); - if (item && clonetiler_is_a_clone_of(&o, NULL)) { + if (item && is_a_clone_of(&o, NULL)) { item->invoke_hide(trace_visionkey); // FIXME: hide each tiled clone's original too! } - clonetiler_trace_hide_tiled_clones_recursively (&o); + trace_hide_tiled_clones_recursively (&o); } } -void CloneTiler::clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *original) +void CloneTiler::trace_setup(SPDocument *doc, gdouble zoom, SPItem *original) { trace_drawing = new Inkscape::Drawing(); /* Create ArenaItem and set transform */ @@ -1914,7 +1914,7 @@ void CloneTiler::clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *o // hide the (current) original and any tiled clones, we only want to pick the background original->invoke_hide(trace_visionkey); - clonetiler_trace_hide_tiled_clones_recursively(trace_doc->getRoot()); + trace_hide_tiled_clones_recursively(trace_doc->getRoot()); trace_doc->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); trace_doc->ensureUpToDate(); @@ -1922,7 +1922,7 @@ void CloneTiler::clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *o trace_zoom = zoom; } -guint32 CloneTiler::clonetiler_trace_pick(Geom::Rect box) +guint32 CloneTiler::trace_pick(Geom::Rect box) { if (!trace_drawing) { return 0; @@ -1946,7 +1946,7 @@ guint32 CloneTiler::clonetiler_trace_pick(Geom::Rect box) return SP_RGBA32_F_COMPOSE (R, G, B, A); } -void CloneTiler::clonetiler_trace_finish() +void CloneTiler::trace_finish() { if (trace_doc) { trace_doc->getRoot()->invoke_hide(trace_visionkey); @@ -1956,7 +1956,7 @@ void CloneTiler::clonetiler_trace_finish() } } -void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *) +void CloneTiler::unclump(GtkWidget */*widget*/, void *) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop == NULL) { @@ -1977,27 +1977,27 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *) std::vector to_unclump; // not including the original for (auto& child: parent->children) { - if (clonetiler_is_a_clone_of (&child, obj)) { + if (is_a_clone_of (&child, obj)) { to_unclump.push_back((SPItem*)&child); } } desktop->getDocument()->ensureUpToDate(); reverse(to_unclump.begin(),to_unclump.end()); - unclump (to_unclump); + ::unclump (to_unclump); DocumentUndo::done(desktop->getDocument(), SP_VERB_DIALOG_CLONETILER, _("Unclump tiled clones")); } -guint CloneTiler::clonetiler_number_of_clones(SPObject *obj) +guint CloneTiler::number_of_clones(SPObject *obj) { SPObject *parent = obj->parent; guint n = 0; for (auto& child: parent->children) { - if (clonetiler_is_a_clone_of (&child, obj)) { + if (is_a_clone_of (&child, obj)) { n ++; } } @@ -2026,7 +2026,7 @@ void CloneTiler::remove(bool do_undo/* = true*/) // remove old tiling GSList *to_delete = NULL; for (auto& child: parent->children) { - if (clonetiler_is_a_clone_of (&child, obj)) { + if (is_a_clone_of (&child, obj)) { to_delete = g_slist_prepend (to_delete, &child); } } @@ -2205,7 +2205,7 @@ void CloneTiler::apply() SPItem *item = dynamic_cast(obj); if (dotrace) { - clonetiler_trace_setup (desktop->getDocument(), 1.0, item); + trace_setup (desktop->getDocument(), 1.0, item); } Geom::Point center; @@ -2277,7 +2277,7 @@ void CloneTiler::apply() // Note: We create a clone at 0,0 too, right over the original, in case our clones are colored // Get transform from symmetry, shift, scale, rotation - Geom::Affine orig_t = clonetiler_get_transform (type, i, j, center[Geom::X], center[Geom::Y], w, h, + Geom::Affine orig_t = get_transform (type, i, j, center[Geom::X], center[Geom::Y], w, h, shiftx_per_i, shifty_per_i, shiftx_per_j, shifty_per_j, shiftx_rand, shifty_rand, @@ -2351,7 +2351,7 @@ void CloneTiler::apply() if (dotrace) { Geom::Rect bbox_t = transform_rect (bbox_original, t*Geom::Scale(1.0/scale_units)); - guint32 rgba = clonetiler_trace_pick (bbox_t); + guint32 rgba = trace_pick (bbox_t); float r = SP_RGBA32_R_F(rgba); float g = SP_RGBA32_G_F(rgba); float b = SP_RGBA32_B_F(rgba); @@ -2511,7 +2511,7 @@ void CloneTiler::apply() } if (dotrace) { - clonetiler_trace_finish (); + trace_finish (); } change_selection(selection); @@ -2522,7 +2522,7 @@ void CloneTiler::apply() _("Create tiled clones")); } -GtkWidget * CloneTiler::clonetiler_new_tab(GtkWidget *nb, const gchar *label) +GtkWidget * CloneTiler::new_tab(GtkWidget *nb, const gchar *label) { GtkWidget *l = gtk_label_new_with_mnemonic (label); auto vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, VB_MARGIN); @@ -2532,14 +2532,14 @@ GtkWidget * CloneTiler::clonetiler_new_tab(GtkWidget *nb, const gchar *label) return vb; } -void CloneTiler::clonetiler_checkbox_toggled(GtkToggleButton *tb, gpointer *data) +void CloneTiler::checkbox_toggled(GtkToggleButton *tb, gpointer *data) { const gchar *attr = (const gchar *) data; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setBool(prefs_path + attr, gtk_toggle_button_get_active(tb)); } -GtkWidget * CloneTiler::clonetiler_checkbox(const char *tip, const char *attr) +GtkWidget * CloneTiler::checkbox(const char *tip, const char *attr) { auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); @@ -2553,21 +2553,21 @@ GtkWidget * CloneTiler::clonetiler_checkbox(const char *tip, const char *attr) gtk_box_pack_end (GTK_BOX (hb), b, FALSE, TRUE, 0); g_signal_connect ( G_OBJECT (b), "clicked", - G_CALLBACK (clonetiler_checkbox_toggled), (gpointer) attr); + G_CALLBACK (checkbox_toggled), (gpointer) attr); g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE)); return hb; } -void CloneTiler::clonetiler_value_changed(GtkAdjustment *adj, gpointer data) +void CloneTiler::value_changed(GtkAdjustment *adj, gpointer data) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); const gchar *pref = (const gchar *) data; prefs->setDouble(prefs_path + pref, gtk_adjustment_get_value (adj)); } -GtkWidget * CloneTiler::clonetiler_spinbox(const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent/* = false*/) +GtkWidget * CloneTiler::spinbox(const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent/* = false*/) { auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); @@ -2597,7 +2597,7 @@ GtkWidget * CloneTiler::clonetiler_spinbox(const char *tip, const char *attr, do a->set_value (value); // TODO: C++ification g_signal_connect(G_OBJECT(a->gobj()), "value_changed", - G_CALLBACK(clonetiler_value_changed), (gpointer) attr); + G_CALLBACK(value_changed), (gpointer) attr); if (exponent) { sb->set_data ("oneable", GINT_TO_POINTER(TRUE)); @@ -2617,27 +2617,27 @@ GtkWidget * CloneTiler::clonetiler_spinbox(const char *tip, const char *attr, do return hb; } -void CloneTiler::clonetiler_symgroup_changed(GtkComboBox *cb, gpointer /*data*/) +void CloneTiler::symgroup_changed(GtkComboBox *cb, gpointer /*data*/) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gint group_new = gtk_combo_box_get_active (cb); prefs->setInt(prefs_path + "symmetrygroup", group_new); } -void CloneTiler::clonetiler_xy_changed(GtkAdjustment *adj, gpointer data) +void CloneTiler::xy_changed(GtkAdjustment *adj, gpointer data) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); const gchar *pref = (const gchar *) data; prefs->setInt(prefs_path + pref, (int) floor(gtk_adjustment_get_value (adj) + 0.5)); } -void CloneTiler::clonetiler_keep_bbox_toggled(GtkToggleButton *tb, gpointer /*data*/) +void CloneTiler::keep_bbox_toggled(GtkToggleButton *tb, gpointer /*data*/) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setBool(prefs_path + "keepbbox", gtk_toggle_button_get_active(tb)); } -void CloneTiler::clonetiler_pick_to(GtkToggleButton *tb, gpointer data) +void CloneTiler::pick_to(GtkToggleButton *tb, gpointer data) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); const gchar *pref = (const gchar *) data; @@ -2645,7 +2645,7 @@ void CloneTiler::clonetiler_pick_to(GtkToggleButton *tb, gpointer data) } -void CloneTiler::clonetiler_reset_recursive(GtkWidget *w) +void CloneTiler::reset_recursive(GtkWidget *w) { if (w && G_IS_OBJECT(w)) { { @@ -2673,25 +2673,25 @@ void CloneTiler::clonetiler_reset_recursive(GtkWidget *w) if (GTK_IS_CONTAINER(w)) { GList *ch = gtk_container_get_children (GTK_CONTAINER(w)); for (GList *i = ch; i != NULL; i = i->next) { - clonetiler_reset_recursive (GTK_WIDGET(i->data)); + reset_recursive (GTK_WIDGET(i->data)); } g_list_free (ch); } } -void CloneTiler::clonetiler_reset(GtkWidget */*widget*/, GtkWidget *dlg) +void CloneTiler::reset(GtkWidget */*widget*/, GtkWidget *dlg) { - clonetiler_reset_recursive (dlg); + reset_recursive (dlg); } -void CloneTiler::clonetiler_table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col) +void CloneTiler::table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col) { gtk_widget_set_halign(widget, GTK_ALIGN_FILL); gtk_widget_set_valign(widget, GTK_ALIGN_START); gtk_grid_attach(GTK_GRID(table), widget, col, row, 1, 1); } -GtkWidget * CloneTiler::clonetiler_table_x_y_rand(int values) +GtkWidget * CloneTiler::table_x_y_rand(int values) { auto table = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(table), 6); @@ -2710,7 +2710,7 @@ GtkWidget * CloneTiler::clonetiler_table_x_y_rand(int values) gtk_label_set_markup (GTK_LABEL(l), _("Per row:")); gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 2); - clonetiler_table_attach (table, hb, 0, 1, 2); + table_attach (table, hb, 0, 1, 2); } { @@ -2724,19 +2724,19 @@ GtkWidget * CloneTiler::clonetiler_table_x_y_rand(int values) gtk_label_set_markup (GTK_LABEL(l), _("Per column:")); gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 2); - clonetiler_table_attach (table, hb, 0, 1, 3); + table_attach (table, hb, 0, 1, 3); } { GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Randomize:")); - clonetiler_table_attach (table, l, 0, 1, 4); + table_attach (table, l, 0, 1, 4); } return table; } -void CloneTiler::clonetiler_pick_switched(GtkToggleButton */*tb*/, gpointer data) +void CloneTiler::pick_switched(GtkToggleButton */*tb*/, gpointer data) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint v = GPOINTER_TO_INT (data); @@ -2744,7 +2744,7 @@ void CloneTiler::clonetiler_pick_switched(GtkToggleButton */*tb*/, gpointer data } -void CloneTiler::clonetiler_switch_to_create(GtkToggleButton * /*tb*/, GtkWidget *dlg) +void CloneTiler::switch_to_create(GtkToggleButton * /*tb*/, GtkWidget *dlg) { GtkWidget *rowscols = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "rowscols")); GtkWidget *widthheight = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "widthheight")); @@ -2761,7 +2761,7 @@ void CloneTiler::clonetiler_switch_to_create(GtkToggleButton * /*tb*/, GtkWidget } -void CloneTiler::clonetiler_switch_to_fill(GtkToggleButton * /*tb*/, GtkWidget *dlg) +void CloneTiler::switch_to_fill(GtkToggleButton * /*tb*/, GtkWidget *dlg) { GtkWidget *rowscols = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "rowscols")); GtkWidget *widthheight = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "widthheight")); @@ -2780,7 +2780,7 @@ void CloneTiler::clonetiler_switch_to_fill(GtkToggleButton * /*tb*/, GtkWidget * -void CloneTiler::clonetiler_fill_width_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u) +void CloneTiler::fill_width_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u) { gdouble const raw_dist = gtk_adjustment_get_value (adj); Inkscape::Util::Unit const *unit = u->getUnit(); @@ -2790,7 +2790,7 @@ void CloneTiler::clonetiler_fill_width_changed(GtkAdjustment *adj, Inkscape::UI: prefs->setDouble(prefs_path + "fillwidth", pixels); } -void CloneTiler::clonetiler_fill_height_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u) +void CloneTiler::fill_height_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u) { gdouble const raw_dist = gtk_adjustment_get_value (adj); Inkscape::Util::Unit const *unit = u->getUnit(); @@ -2800,7 +2800,7 @@ void CloneTiler::clonetiler_fill_height_changed(GtkAdjustment *adj, Inkscape::UI prefs->setDouble(prefs_path + "fillheight", pixels); } -void CloneTiler::clonetiler_unit_changed() +void CloneTiler::unit_changed() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gdouble width_pixels = prefs->getDouble(prefs_path + "fillwidth"); @@ -2814,22 +2814,23 @@ void CloneTiler::clonetiler_unit_changed() gtk_adjustment_set_value(fill_height->gobj(), height_value); } -void CloneTiler::clonetiler_do_pick_toggled(GtkToggleButton *tb, GtkWidget *dlg) +void CloneTiler::do_pick_toggled(Gtk::ToggleButton *tb) { - GtkWidget *vvb = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "dotrace")); + GtkWidget *vvb = GTK_WIDGET(_dotrace); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setBool(prefs_path + "dotrace", gtk_toggle_button_get_active (tb)); + auto prefs = Inkscape::Preferences::get(); + auto active = tb->get_active(); + prefs->setBool(prefs_path + "dotrace", active); if (vvb) { - gtk_widget_set_sensitive (vvb, gtk_toggle_button_get_active (tb)); + gtk_widget_set_sensitive (vvb, active); } } void CloneTiler::show_page_trace() { gtk_notebook_set_current_page(GTK_NOTEBOOK(nb),6); - gtk_toggle_button_set_active ((GtkToggleButton *) b, false); + _b->set_active(false); } diff --git a/src/ui/dialog/clonetiler.h b/src/ui/dialog/clonetiler.h index 9ad3fa878..e1c8bab35 100644 --- a/src/ui/dialog/clonetiler.h +++ b/src/ui/dialog/clonetiler.h @@ -16,6 +16,11 @@ #include "ui/widget/color-picker.h" #include "sp-root.h" +namespace Gtk { + class CheckButton; + class ToggleButton; +} + namespace Inkscape { namespace UI { @@ -34,45 +39,47 @@ public: void show_page_trace(); protected: - GtkWidget * clonetiler_new_tab(GtkWidget *nb, const gchar *label); - GtkWidget * clonetiler_table_x_y_rand(int values); - GtkWidget * clonetiler_spinbox(const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent = false); - GtkWidget * clonetiler_checkbox(const char *tip, const char *attr); - void clonetiler_table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col); + GtkWidget * new_tab(GtkWidget *nb, const gchar *label); + GtkWidget * table_x_y_rand(int values); + GtkWidget * spinbox(const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent = false); + GtkWidget * checkbox(const char *tip, const char *attr); + void table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col); - static void clonetiler_symgroup_changed(GtkComboBox *cb, gpointer /*data*/); + // TODO: Improve encapsulation by using SigC++ signal handling, and convert all of these into + // non-static member functions + static void symgroup_changed(GtkComboBox *cb, gpointer /*data*/); static void on_picker_color_changed(guint rgba); - static void clonetiler_trace_hide_tiled_clones_recursively(SPObject *from); - static void clonetiler_checkbox_toggled(GtkToggleButton *tb, gpointer *data); - static void clonetiler_pick_switched(GtkToggleButton */*tb*/, gpointer data); - static void clonetiler_do_pick_toggled(GtkToggleButton *tb, GtkWidget *dlg); - static void clonetiler_pick_to(GtkToggleButton *tb, gpointer data); - static void clonetiler_xy_changed(GtkAdjustment *adj, gpointer data); - static void clonetiler_fill_width_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u); - static void clonetiler_fill_height_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u); - void clonetiler_unit_changed(); - static void clonetiler_switch_to_create(GtkToggleButton */*tb*/, GtkWidget *dlg); - static void clonetiler_switch_to_fill(GtkToggleButton */*tb*/, GtkWidget *dlg); - static void clonetiler_keep_bbox_toggled(GtkToggleButton *tb, gpointer /*data*/); - static void clonetiler_unclump(GtkWidget */*widget*/, void *); - static void clonetiler_reset(GtkWidget */*widget*/, GtkWidget *dlg); - static guint clonetiler_number_of_clones(SPObject *obj); - static void clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *original); - static guint32 clonetiler_trace_pick(Geom::Rect box); - static void clonetiler_trace_finish(); - static bool clonetiler_is_a_clone_of(SPObject *tile, SPObject *obj); + static void trace_hide_tiled_clones_recursively(SPObject *from); + static void checkbox_toggled(GtkToggleButton *tb, gpointer *data); + static void pick_switched(GtkToggleButton */*tb*/, gpointer data); + static void pick_to(GtkToggleButton *tb, gpointer data); + static void xy_changed(GtkAdjustment *adj, gpointer data); + static void fill_width_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u); + static void fill_height_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u); + static void switch_to_create(GtkToggleButton */*tb*/, GtkWidget *dlg); + static void switch_to_fill(GtkToggleButton */*tb*/, GtkWidget *dlg); + static void keep_bbox_toggled(GtkToggleButton *tb, gpointer /*data*/); + static void unclump(GtkWidget */*widget*/, void *); + static void reset(GtkWidget */*widget*/, GtkWidget *dlg); + static guint number_of_clones(SPObject *obj); + static void trace_setup(SPDocument *doc, gdouble zoom, SPItem *original); + static guint32 trace_pick(Geom::Rect box); + static void trace_finish(); + static bool is_a_clone_of(SPObject *tile, SPObject *obj); static Geom::Rect transform_rect(Geom::Rect const &r, Geom::Affine const &m); static double randomize01(double val, double rand); - static void clonetiler_value_changed(GtkAdjustment *adj, gpointer data); - static void clonetiler_reset_recursive(GtkWidget *w); + static void value_changed(GtkAdjustment *adj, gpointer data); + static void reset_recursive(GtkWidget *w); void apply(); void change_selection(Inkscape::Selection *selection); + void do_pick_toggled(Gtk::ToggleButton *tb); void external_change(); void remove(bool do_undo = true); void on_remove_button_clicked() {remove();} + void unit_changed(); - static Geom::Affine clonetiler_get_transform( // symmetry group + static Geom::Affine get_transform( // symmetry group int type, // row, column @@ -113,8 +120,8 @@ private: CloneTiler(CloneTiler const &d); CloneTiler& operator=(CloneTiler const &d); + Gtk::CheckButton *_b; GtkWidget *nb; - GtkWidget *b; SPDesktop *desktop; DesktopTracker deskTrack; Inkscape::UI::Widget::ColorPicker *color_picker; -- cgit v1.2.3 From 93a6d057d8b8dac9e4d81d84511dbae60a958788 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Fri, 12 Aug 2016 00:31:53 +0100 Subject: CloneTiler: Further C++ification (bzr r15052) --- src/ui/dialog/clonetiler.cpp | 177 +++++++++++++++++++------------------------ src/ui/dialog/clonetiler.h | 17 +++-- 2 files changed, 88 insertions(+), 106 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index 8bd5cd5f6..a9bec8227 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -25,6 +25,7 @@ #include #include +#include #include "desktop.h" @@ -766,7 +767,7 @@ CloneTiler::CloneTiler () : _b->set_active(old); _b->set_tooltip_text(_("For each clone/sprayed item, pick a value from the drawing in its location and apply it")); gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(_b->gobj()), FALSE, FALSE, 0); - _b->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::do_pick_toggled),_b)); + _b->signal_toggled().connect(sigc::mem_fun(*this, &CloneTiler::do_pick_toggled)); } { @@ -967,9 +968,7 @@ CloneTiler::CloneTiler () : gtk_box_pack_start (GTK_BOX (mainbox), table, FALSE, FALSE, 0); { - auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); - gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); - _rowscols = hb; + _rowscols = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, VB_MARGIN)); { auto a = Gtk::Adjustment::create(0.0, 1, 500, 1, 10, 0); @@ -979,7 +978,7 @@ CloneTiler::CloneTiler () : auto sb = new Inkscape::UI::Widget::SpinButton(a, 1.0, 0); sb->set_tooltip_text (_("How many rows in the tiling")); sb->set_width_chars (7); - gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(sb->gobj()), TRUE, TRUE, 0); + _rowscols->pack_start(*sb, true, true, 0); // TODO: C++ification g_signal_connect(G_OBJECT(a->gobj()), "value_changed", @@ -987,10 +986,10 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), "×"); - gtk_widget_set_halign(l, GTK_ALIGN_END); - gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0); + auto l = Gtk::manage(new Gtk::Label("")); + l->set_markup("×"); + l->set_halign(Gtk::ALIGN_END); + _rowscols->pack_start(*l, true, true, 0); } { @@ -1001,20 +1000,18 @@ CloneTiler::CloneTiler () : auto sb = new Inkscape::UI::Widget::SpinButton(a, 1.0, 0); sb->set_tooltip_text (_("How many columns in the tiling")); sb->set_width_chars (7); - gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(sb->gobj()), TRUE, TRUE, 0); + _rowscols->pack_start(*sb, true, true, 0); // TODO: C++ification g_signal_connect(G_OBJECT(a->gobj()), "value_changed", G_CALLBACK(xy_changed), (gpointer) "imax"); } - table_attach (table, hb, 0.0, 1, 2); + table_attach (table, GTK_WIDGET(_rowscols->gobj()), 0.0, 1, 2); } { - auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); - gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); - _widthheight = hb; + _widthheight = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, VB_MARGIN)); // unitmenu unit_menu = new Inkscape::UI::Widget::UnitMenu(); @@ -1035,16 +1032,14 @@ CloneTiler::CloneTiler () : e->set_tooltip_text (_("Width of the rectangle to be filled")); e->set_width_chars (7); e->set_digits (4); - gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(e->gobj()), TRUE, TRUE, 0); - // TODO: C++ification - g_signal_connect(G_OBJECT(fill_width->gobj()), "value_changed", - G_CALLBACK(fill_width_changed), unit_menu); + _widthheight->pack_start(*e, true, true, 0); + fill_width->signal_value_changed().connect(sigc::mem_fun(*this, &CloneTiler::fill_width_changed)); } { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), "×"); - gtk_widget_set_halign(l, GTK_ALIGN_END); - gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0); + auto l = Gtk::manage(new Gtk::Label("")); + l->set_markup("×"); + l->set_halign(Gtk::ALIGN_END); + _widthheight->pack_start(*l, true, true, 0); } { @@ -1060,56 +1055,53 @@ CloneTiler::CloneTiler () : e->set_tooltip_text (_("Height of the rectangle to be filled")); e->set_width_chars (7); e->set_digits (4); - gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(e->gobj()), TRUE, TRUE, 0); - // TODO: C++ification - g_signal_connect(G_OBJECT(fill_height->gobj()), "value_changed", - G_CALLBACK(fill_height_changed), unit_menu); + _widthheight->pack_start(*e, true, true, 0); + fill_height->signal_value_changed().connect(sigc::mem_fun(*this, &CloneTiler::fill_height_changed)); } - gtk_box_pack_start (GTK_BOX (hb), (GtkWidget*) unit_menu->gobj(), TRUE, TRUE, 0); - table_attach (table, hb, 0.0, 2, 2); + _widthheight->pack_start(*unit_menu, true, true, 0); + table_attach (table, GTK_WIDGET(_widthheight->gobj()), 0.0, 2, 2); } // Switch - GtkWidget* radio; + Gtk::RadioButtonGroup rb_group; { - radio = gtk_radio_button_new_with_label (NULL, _("Rows, columns: ")); - gtk_widget_set_tooltip_text (radio, _("Create the specified number of rows and columns")); - table_attach (table, radio, 0.0, 1, 1); - g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (switch_to_create), (gpointer) this); - } - if (!prefs->getBool(prefs_path + "fillrect")) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); - gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio)); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("Rows, columns: "))); + radio->set_tooltip_text(_("Create the specified number of rows and columns")); + table_attach (table, GTK_WIDGET(radio->gobj()), 0.0, 1, 1); + radio->signal_toggled().connect(sigc::mem_fun(*this, &CloneTiler::switch_to_create)); + + if (!prefs->getBool(prefs_path + "fillrect")) { + radio->set_active(true); + } } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Width, height: ")); - gtk_widget_set_tooltip_text (radio, _("Fill the specified width and height with the tiling")); - table_attach (table, radio, 0.0, 2, 1); - g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (switch_to_fill), (gpointer) this); - } - if (prefs->getBool(prefs_path + "fillrect")) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); - gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio)); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("Width, height: "))); + radio->set_tooltip_text(_("Fill the specified width and height with the tiling")); + table_attach (table, GTK_WIDGET(radio->gobj()), 0.0, 2, 1); + radio->signal_toggled().connect(sigc::mem_fun(*this, &CloneTiler::switch_to_fill)); + + if (prefs->getBool(prefs_path + "fillrect")) { + radio->set_active(true); + } } } // Use saved pos { - auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); - gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); - gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); - - GtkWidget *b = gtk_check_button_new_with_label (_("Use saved size and position of the tile")); - bool keepbbox = prefs->getBool(prefs_path + "keepbbox", true); - gtk_toggle_button_set_active ((GtkToggleButton *) b, keepbbox); - gtk_widget_set_tooltip_text (b, _("Pretend that the size and position of the tile are the same as the last time you tiled it (if any), instead of using the current size")); - gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); - - g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(keep_bbox_toggled), NULL); + auto hb = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, VB_MARGIN)); + gtk_box_pack_start (GTK_BOX (mainbox), GTK_WIDGET(hb->gobj()), FALSE, FALSE, 0); + + _cb_keep_bbox = Gtk::manage(new Gtk::CheckButton(_("Use saved size and position of the tile"))); + auto keepbbox = prefs->getBool(prefs_path + "keepbbox", true); + _cb_keep_bbox->set_active(keepbbox); + _cb_keep_bbox->set_tooltip_text(_("Pretend that the size and position of the tile are the same " + "as the last time you tiled it (if any), instead of using the " + "current size")); + hb->pack_start(*_cb_keep_bbox, false, false, 0); + _cb_keep_bbox->signal_toggled().connect(sigc::mem_fun(*this, &CloneTiler::keep_bbox_toggled)); } // Statusbar @@ -2631,10 +2623,10 @@ void CloneTiler::xy_changed(GtkAdjustment *adj, gpointer data) prefs->setInt(prefs_path + pref, (int) floor(gtk_adjustment_get_value (adj) + 0.5)); } -void CloneTiler::keep_bbox_toggled(GtkToggleButton *tb, gpointer /*data*/) +void CloneTiler::keep_bbox_toggled() { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setBool(prefs_path + "keepbbox", gtk_toggle_button_get_active(tb)); + auto prefs = Inkscape::Preferences::get(); + prefs->setBool(prefs_path + "keepbbox", _cb_keep_bbox->get_active()); } void CloneTiler::pick_to(GtkToggleButton *tb, gpointer data) @@ -2744,59 +2736,50 @@ void CloneTiler::pick_switched(GtkToggleButton */*tb*/, gpointer data) } -void CloneTiler::switch_to_create(GtkToggleButton * /*tb*/, GtkWidget *dlg) +void CloneTiler::switch_to_create() { - GtkWidget *rowscols = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "rowscols")); - GtkWidget *widthheight = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "widthheight")); - - if (rowscols) { - gtk_widget_set_sensitive (rowscols, TRUE); + if (_rowscols) { + _rowscols->set_sensitive(true); } - if (widthheight) { - gtk_widget_set_sensitive (widthheight, FALSE); + if (_widthheight) { + _widthheight->set_sensitive(false); } - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + auto prefs = Inkscape::Preferences::get(); prefs->setBool(prefs_path + "fillrect", false); } -void CloneTiler::switch_to_fill(GtkToggleButton * /*tb*/, GtkWidget *dlg) +void CloneTiler::switch_to_fill() { - GtkWidget *rowscols = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "rowscols")); - GtkWidget *widthheight = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "widthheight")); - - if (rowscols) { - gtk_widget_set_sensitive (rowscols, FALSE); + if (_rowscols) { + _rowscols->set_sensitive(false); } - if (widthheight) { - gtk_widget_set_sensitive (widthheight, TRUE); + if (_widthheight) { + _widthheight->set_sensitive(true); } - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + auto prefs = Inkscape::Preferences::get(); prefs->setBool(prefs_path + "fillrect", true); } - - - -void CloneTiler::fill_width_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u) +void CloneTiler::fill_width_changed() { - gdouble const raw_dist = gtk_adjustment_get_value (adj); - Inkscape::Util::Unit const *unit = u->getUnit(); - gdouble const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px"); + auto const raw_dist = fill_width->get_value(); + auto const unit = unit_menu->getUnit(); + auto const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px"); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + auto prefs = Inkscape::Preferences::get(); prefs->setDouble(prefs_path + "fillwidth", pixels); } -void CloneTiler::fill_height_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u) +void CloneTiler::fill_height_changed() { - gdouble const raw_dist = gtk_adjustment_get_value (adj); - Inkscape::Util::Unit const *unit = u->getUnit(); - gdouble const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px"); + auto const raw_dist = fill_height->get_value(); + auto const unit = unit_menu->getUnit(); + auto const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px"); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + auto prefs = Inkscape::Preferences::get(); prefs->setDouble(prefs_path + "fillheight", pixels); } @@ -2814,16 +2797,14 @@ void CloneTiler::unit_changed() gtk_adjustment_set_value(fill_height->gobj(), height_value); } -void CloneTiler::do_pick_toggled(Gtk::ToggleButton *tb) +void CloneTiler::do_pick_toggled() { - GtkWidget *vvb = GTK_WIDGET(_dotrace); - - auto prefs = Inkscape::Preferences::get(); - auto active = tb->get_active(); + auto prefs = Inkscape::Preferences::get(); + auto active = _b->get_active(); prefs->setBool(prefs_path + "dotrace", active); - if (vvb) { - gtk_widget_set_sensitive (vvb, active); + if (_dotrace) { + gtk_widget_set_sensitive (_dotrace, active); } } diff --git a/src/ui/dialog/clonetiler.h b/src/ui/dialog/clonetiler.h index e1c8bab35..70a22d3d0 100644 --- a/src/ui/dialog/clonetiler.h +++ b/src/ui/dialog/clonetiler.h @@ -54,11 +54,9 @@ protected: static void pick_switched(GtkToggleButton */*tb*/, gpointer data); static void pick_to(GtkToggleButton *tb, gpointer data); static void xy_changed(GtkAdjustment *adj, gpointer data); - static void fill_width_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u); - static void fill_height_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u); - static void switch_to_create(GtkToggleButton */*tb*/, GtkWidget *dlg); - static void switch_to_fill(GtkToggleButton */*tb*/, GtkWidget *dlg); - static void keep_bbox_toggled(GtkToggleButton *tb, gpointer /*data*/); + void switch_to_create(); + void switch_to_fill(); + void keep_bbox_toggled(); static void unclump(GtkWidget */*widget*/, void *); static void reset(GtkWidget */*widget*/, GtkWidget *dlg); static guint number_of_clones(SPObject *obj); @@ -73,8 +71,10 @@ protected: void apply(); void change_selection(Inkscape::Selection *selection); - void do_pick_toggled(Gtk::ToggleButton *tb); + void do_pick_toggled(); void external_change(); + void fill_width_changed(); + void fill_height_changed(); void remove(bool do_undo = true); void on_remove_button_clicked() {remove();} void unit_changed(); @@ -121,6 +121,7 @@ private: CloneTiler& operator=(CloneTiler const &d); Gtk::CheckButton *_b; + Gtk::CheckButton *_cb_keep_bbox; GtkWidget *nb; SPDesktop *desktop; DesktopTracker deskTrack; @@ -153,8 +154,8 @@ private: GtkWidget *_buttons_on_tiles; GtkWidget *_dotrace; GtkWidget *_status; - GtkWidget *_rowscols; - GtkWidget *_widthheight; + Gtk::Box *_rowscols; + Gtk::Box *_widthheight; }; -- cgit v1.2.3 From ded71e7f2330ae5abbb0b09e12f89a8fefc2820a Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Fri, 12 Aug 2016 00:45:47 +0100 Subject: CloneTiler: Further C++ification (bzr r15053) --- src/ui/dialog/clonetiler.cpp | 18 +++++++++--------- src/ui/dialog/clonetiler.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index a9bec8227..c27d5d35a 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -1141,10 +1141,10 @@ CloneTiler::CloneTiler () : // diagrams on the left in the following screenshot: // http://www.inkscape.org/screenshots/gallery/inkscape-0.42-CVS-tiles-unclump.png // So unclumping is the process of spreading a number of objects out more evenly. - GtkWidget *b = gtk_button_new_with_mnemonic (_(" _Unclump ")); - gtk_widget_set_tooltip_text (b, _("Spread out clones to reduce clumping; can be applied repeatedly")); - g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (unclump), NULL); - gtk_box_pack_end (GTK_BOX (sb), b, FALSE, FALSE, 0); + auto b = Gtk::manage(new Gtk::Button(_(" _Unclump "), true)); + b->set_tooltip_text(_("Spread out clones to reduce clumping; can be applied repeatedly")); + b->signal_clicked().connect(sigc::mem_fun(*this, &CloneTiler::unclump)); + gtk_box_pack_end (GTK_BOX (sb), GTK_WIDGET(b->gobj()), FALSE, FALSE, 0); } { @@ -1948,14 +1948,14 @@ void CloneTiler::trace_finish() } } -void CloneTiler::unclump(GtkWidget */*widget*/, void *) +void CloneTiler::unclump() { - SPDesktop *desktop = SP_ACTIVE_DESKTOP; + auto desktop = SP_ACTIVE_DESKTOP; if (desktop == NULL) { return; } - Inkscape::Selection *selection = desktop->getSelection(); + auto selection = desktop->getSelection(); // check if something is selected if (selection->isEmpty() || boost::distance(selection->items()) > 1) { @@ -1963,8 +1963,8 @@ void CloneTiler::unclump(GtkWidget */*widget*/, void *) return; } - SPObject *obj = selection->singleItem(); - SPObject *parent = obj->parent; + auto obj = selection->singleItem(); + auto parent = obj->parent; std::vector to_unclump; // not including the original diff --git a/src/ui/dialog/clonetiler.h b/src/ui/dialog/clonetiler.h index 70a22d3d0..04f676800 100644 --- a/src/ui/dialog/clonetiler.h +++ b/src/ui/dialog/clonetiler.h @@ -57,7 +57,7 @@ protected: void switch_to_create(); void switch_to_fill(); void keep_bbox_toggled(); - static void unclump(GtkWidget */*widget*/, void *); + void unclump(); static void reset(GtkWidget */*widget*/, GtkWidget *dlg); static guint number_of_clones(SPObject *obj); static void trace_setup(SPDocument *doc, gdouble zoom, SPItem *original); -- cgit v1.2.3 From dffaf2ab2ab1cd1ca21c0ff9e9cc9f077faf17f1 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Fri, 12 Aug 2016 21:10:12 +0100 Subject: CloneTiler: Replace all remaining g_signal usage (bzr r15055) --- src/ui/dialog/clonetiler.cpp | 425 +++++++++++++++++++++---------------------- src/ui/dialog/clonetiler.h | 87 +++++---- 2 files changed, 251 insertions(+), 261 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index c27d5d35a..8e9d3dbbf 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -25,6 +25,8 @@ #include #include +#include +#include #include #include "desktop.h" @@ -66,7 +68,6 @@ static unsigned trace_visionkey; static gdouble trace_zoom; static SPDocument *trace_doc = NULL; - CloneTiler::CloneTiler () : UI::Widget::Panel ("", "/dialogs/clonetiler/", SP_VERB_DIALOG_CLONETILER), desktop(NULL), @@ -100,7 +101,7 @@ CloneTiler::CloneTiler () : */ struct SymGroups { gint group; - gchar const *label; + Glib::ustring label; } const sym_groups[] = { // TRANSLATORS: "translation" means "shift" / "displacement" here. {TILE_P1, _("P1: simple translation")}, @@ -126,33 +127,27 @@ CloneTiler::CloneTiler () : gint current = prefs->getInt(prefs_path + "symmetrygroup", 0); - // Create a list structure containing all the data to be displayed in - // the symmetry group combo box. - GtkListStore *store = gtk_list_store_new (1, G_TYPE_STRING); - GtkTreeIter iter; - - for (unsigned j = 0; j < G_N_ELEMENTS(sym_groups); ++j) { - SymGroups const &sg = sym_groups[j]; + // Add a new combo box widget with the list of symmetry groups to the vbox + auto combo = Gtk::manage(new Gtk::ComboBoxText()); + combo->set_tooltip_text(_("Select one of the 17 symmetry groups for the tiling")); - // Add the description of the symgroup to a new row - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, 0, sg.label, -1); - } + // Hack to add markup support + auto cell_list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(combo->gobj())); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo->gobj()), + GTK_CELL_RENDERER(cell_list->data), + "markup", 0, NULL); - // Add a new combo box widget with the list of symmetry groups to the vbox - GtkWidget *combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); - gtk_widget_set_tooltip_text (combo, _("Select one of the 17 symmetry groups for the tiling")); - gtk_box_pack_start (GTK_BOX (vb), combo, FALSE, FALSE, SB_MARGIN); + for (unsigned j = 0; j < G_N_ELEMENTS(sym_groups); ++j) { + SymGroups const &sg = sym_groups[j]; - // Specify the rendering of data from the list in a combo box cell - GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "markup", 0, NULL); + // Add the description of the symgroup to a new row + combo->append(sg.label); + } - gtk_combo_box_set_active (GTK_COMBO_BOX (combo), current); + gtk_box_pack_start (GTK_BOX (vb), GTK_WIDGET(combo->gobj()), FALSE, FALSE, SB_MARGIN); - g_signal_connect(G_OBJECT(combo), "changed", - G_CALLBACK(symgroup_changed), NULL); + combo->set_active(current); + combo->signal_changed().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::symgroup_changed), combo)); } table_row_labels = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); @@ -175,7 +170,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Horizontal shift per row (in % of tile width)"), "shiftx_per_j", -10000, 10000, "%"); @@ -183,7 +178,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Horizontal shift per column (in % of tile width)"), "shiftx_per_i", -10000, 10000, "%"); @@ -191,7 +186,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox (_("Randomize the horizontal shift by this percentage"), "shiftx_rand", + auto l = spinbox (_("Randomize the horizontal shift by this percentage"), "shiftx_rand", 0, 1000, "%"); table_attach (table, l, 0, 2, 4); } @@ -207,7 +202,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Vertical shift per row (in % of tile height)"), "shifty_per_j", -10000, 10000, "%"); @@ -215,7 +210,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Vertical shift per column (in % of tile height)"), "shifty_per_i", -10000, 10000, "%"); @@ -223,7 +218,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox ( + auto l = spinbox ( _("Randomize the vertical shift by this percentage"), "shifty_rand", 0, 1000, "%"); table_attach (table, l, 0, 3, 4); @@ -238,14 +233,14 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox ( + auto l = spinbox ( _("Whether rows are spaced evenly (1), converge (<1) or diverge (>1)"), "shifty_exp", 0, 10, "", true); table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = spinbox ( + auto l = spinbox ( _("Whether columns are spaced evenly (1), converge (<1) or diverge (>1)"), "shiftx_exp", 0, 10, "", true); table_attach (table, l, 0, 4, 3); @@ -260,12 +255,12 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = checkbox (_("Alternate the sign of shifts for each row"), "shifty_alternate"); + auto l = checkbox (_("Alternate the sign of shifts for each row"), "shifty_alternate"); table_attach (table, l, 0, 5, 2); } { - GtkWidget *l = checkbox (_("Alternate the sign of shifts for each column"), "shiftx_alternate"); + auto l = checkbox (_("Alternate the sign of shifts for each column"), "shiftx_alternate"); table_attach (table, l, 0, 5, 3); } @@ -278,12 +273,12 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = checkbox (_("Cumulate the shifts for each row"), "shifty_cumulate"); + auto l = checkbox (_("Cumulate the shifts for each row"), "shifty_cumulate"); table_attach (table, l, 0, 6, 2); } { - GtkWidget *l = checkbox (_("Cumulate the shifts for each column"), "shiftx_cumulate"); + auto l = checkbox (_("Cumulate the shifts for each column"), "shiftx_cumulate"); table_attach (table, l, 0, 6, 3); } @@ -296,12 +291,12 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = checkbox (_("Exclude tile height in shift"), "shifty_excludeh"); + auto l = checkbox (_("Exclude tile height in shift"), "shifty_excludeh"); table_attach (table, l, 0, 7, 2); } { - GtkWidget *l = checkbox (_("Exclude tile width in shift"), "shiftx_excludew"); + auto l = checkbox (_("Exclude tile width in shift"), "shiftx_excludew"); table_attach (table, l, 0, 7, 3); } @@ -324,7 +319,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Horizontal scale per row (in % of tile width)"), "scalex_per_j", -100, 1000, "%"); @@ -332,7 +327,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Horizontal scale per column (in % of tile width)"), "scalex_per_i", -100, 1000, "%"); @@ -340,7 +335,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox (_("Randomize the horizontal scale by this percentage"), "scalex_rand", + auto l = spinbox (_("Randomize the horizontal scale by this percentage"), "scalex_rand", 0, 1000, "%"); table_attach (table, l, 0, 2, 4); } @@ -354,7 +349,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Vertical scale per row (in % of tile height)"), "scaley_per_j", -100, 1000, "%"); @@ -362,7 +357,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Vertical scale per column (in % of tile height)"), "scaley_per_i", -100, 1000, "%"); @@ -370,7 +365,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox (_("Randomize the vertical scale by this percentage"), "scaley_rand", + auto l = spinbox (_("Randomize the vertical scale by this percentage"), "scaley_rand", 0, 1000, "%"); table_attach (table, l, 0, 3, 4); } @@ -384,13 +379,13 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox (_("Whether row scaling is uniform (1), converge (<1) or diverge (>1)"), "scaley_exp", + auto l = spinbox (_("Whether row scaling is uniform (1), converge (<1) or diverge (>1)"), "scaley_exp", 0, 10, "", true); table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = spinbox (_("Whether column scaling is uniform (1), converge (<1) or diverge (>1)"), "scalex_exp", + auto l = spinbox (_("Whether column scaling is uniform (1), converge (<1) or diverge (>1)"), "scalex_exp", 0, 10, "", true); table_attach (table, l, 0, 4, 3); } @@ -404,13 +399,13 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scaley_log", + auto l = spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scaley_log", 0, 10, "", false); table_attach (table, l, 0, 5, 2); } { - GtkWidget *l = spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scalex_log", + auto l = spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scalex_log", 0, 10, "", false); table_attach (table, l, 0, 5, 3); } @@ -424,12 +419,12 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = checkbox (_("Alternate the sign of scales for each row"), "scaley_alternate"); + auto l = checkbox (_("Alternate the sign of scales for each row"), "scaley_alternate"); table_attach (table, l, 0, 6, 2); } { - GtkWidget *l = checkbox (_("Alternate the sign of scales for each column"), "scalex_alternate"); + auto l = checkbox (_("Alternate the sign of scales for each column"), "scalex_alternate"); table_attach (table, l, 0, 6, 3); } @@ -442,12 +437,12 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = checkbox (_("Cumulate the scales for each row"), "scaley_cumulate"); + auto l = checkbox (_("Cumulate the scales for each row"), "scaley_cumulate"); table_attach (table, l, 0, 7, 2); } { - GtkWidget *l = checkbox (_("Cumulate the scales for each column"), "scalex_cumulate"); + auto l = checkbox (_("Cumulate the scales for each column"), "scalex_cumulate"); table_attach (table, l, 0, 7, 3); } @@ -470,7 +465,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Rotate tiles by this angle for each row"), "rotate_per_j", -180, 180, "°"); @@ -478,7 +473,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Rotate tiles by this angle for each column"), "rotate_per_i", -180, 180, "°"); @@ -486,7 +481,7 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox (_("Randomize the rotation angle by this percentage"), "rotate_rand", + auto l = spinbox (_("Randomize the rotation angle by this percentage"), "rotate_rand", 0, 100, "%"); table_attach (table, l, 0, 2, 4); } @@ -500,12 +495,12 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = checkbox (_("Alternate the rotation direction for each row"), "rotate_alternatej"); + auto l = checkbox (_("Alternate the rotation direction for each row"), "rotate_alternatej"); table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = checkbox (_("Alternate the rotation direction for each column"), "rotate_alternatei"); + auto l = checkbox (_("Alternate the rotation direction for each column"), "rotate_alternatei"); table_attach (table, l, 0, 3, 3); } @@ -518,12 +513,12 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = checkbox (_("Cumulate the rotation for each row"), "rotate_cumulatej"); + auto l = checkbox (_("Cumulate the rotation for each row"), "rotate_cumulatej"); table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = checkbox (_("Cumulate the rotation for each column"), "rotate_cumulatei"); + auto l = checkbox (_("Cumulate the rotation for each column"), "rotate_cumulatei"); table_attach (table, l, 0, 4, 3); } @@ -547,19 +542,19 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox (_("Blur tiles by this percentage for each row"), "blur_per_j", + auto l = spinbox (_("Blur tiles by this percentage for each row"), "blur_per_j", 0, 100, "%"); table_attach (table, l, 0, 2, 2); } { - GtkWidget *l = spinbox (_("Blur tiles by this percentage for each column"), "blur_per_i", + auto l = spinbox (_("Blur tiles by this percentage for each column"), "blur_per_i", 0, 100, "%"); table_attach (table, l, 0, 2, 3); } { - GtkWidget *l = spinbox (_("Randomize the tile blur by this percentage"), "blur_rand", + auto l = spinbox (_("Randomize the tile blur by this percentage"), "blur_rand", 0, 100, "%"); table_attach (table, l, 0, 2, 4); } @@ -573,12 +568,12 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = checkbox (_("Alternate the sign of blur change for each row"), "blur_alternatej"); + auto l = checkbox (_("Alternate the sign of blur change for each row"), "blur_alternatej"); table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = checkbox (_("Alternate the sign of blur change for each column"), "blur_alternatei"); + auto l = checkbox (_("Alternate the sign of blur change for each column"), "blur_alternatei"); table_attach (table, l, 0, 3, 3); } @@ -593,19 +588,19 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox (_("Decrease tile opacity by this percentage for each row"), "opacity_per_j", + auto l = spinbox (_("Decrease tile opacity by this percentage for each row"), "opacity_per_j", 0, 100, "%"); table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = spinbox (_("Decrease tile opacity by this percentage for each column"), "opacity_per_i", + auto l = spinbox (_("Decrease tile opacity by this percentage for each column"), "opacity_per_i", 0, 100, "%"); table_attach (table, l, 0, 4, 3); } { - GtkWidget *l = spinbox (_("Randomize the tile opacity by this percentage"), "opacity_rand", + auto l = spinbox (_("Randomize the tile opacity by this percentage"), "opacity_rand", 0, 100, "%"); table_attach (table, l, 0, 4, 4); } @@ -619,12 +614,12 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = checkbox (_("Alternate the sign of opacity change for each row"), "opacity_alternatej"); + auto l = checkbox (_("Alternate the sign of opacity change for each row"), "opacity_alternatej"); table_attach (table, l, 0, 5, 2); } { - GtkWidget *l = checkbox (_("Alternate the sign of opacity change for each column"), "opacity_alternatei"); + auto l = checkbox (_("Alternate the sign of opacity change for each column"), "opacity_alternatei"); table_attach (table, l, 0, 5, 3); } } @@ -643,7 +638,7 @@ CloneTiler::CloneTiler () : guint32 rgba = 0x000000ff | sp_svg_read_color (prefs->getString(prefs_path + "initial_color").data(), 0x000000ff); color_picker = new Inkscape::UI::Widget::ColorPicker (*new Glib::ustring(_("Initial color of tiled clones")), *new Glib::ustring(_("Initial color for clones (works only if the original has unset fill or stroke or on spray tool in copy mode)")), rgba, false); - color_changed_connection = color_picker->connectChanged (sigc::ptr_fun(on_picker_color_changed)); + color_changed_connection = color_picker->connectChanged(sigc::mem_fun(*this, &CloneTiler::on_picker_color_changed)); gtk_box_pack_start (GTK_BOX (hb), reinterpret_cast(color_picker->gobj()), FALSE, FALSE, 0); @@ -663,19 +658,19 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox (_("Change the tile hue by this percentage for each row"), "hue_per_j", + auto l = spinbox (_("Change the tile hue by this percentage for each row"), "hue_per_j", -100, 100, "%"); table_attach (table, l, 0, 2, 2); } { - GtkWidget *l = spinbox (_("Change the tile hue by this percentage for each column"), "hue_per_i", + auto l = spinbox (_("Change the tile hue by this percentage for each column"), "hue_per_i", -100, 100, "%"); table_attach (table, l, 0, 2, 3); } { - GtkWidget *l = spinbox (_("Randomize the tile hue by this percentage"), "hue_rand", + auto l = spinbox (_("Randomize the tile hue by this percentage"), "hue_rand", 0, 100, "%"); table_attach (table, l, 0, 2, 4); } @@ -690,19 +685,19 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox (_("Change the color saturation by this percentage for each row"), "saturation_per_j", + auto l = spinbox (_("Change the color saturation by this percentage for each row"), "saturation_per_j", -100, 100, "%"); table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = spinbox (_("Change the color saturation by this percentage for each column"), "saturation_per_i", + auto l = spinbox (_("Change the color saturation by this percentage for each column"), "saturation_per_i", -100, 100, "%"); table_attach (table, l, 0, 3, 3); } { - GtkWidget *l = spinbox (_("Randomize the color saturation by this percentage"), "saturation_rand", + auto l = spinbox (_("Randomize the color saturation by this percentage"), "saturation_rand", 0, 100, "%"); table_attach (table, l, 0, 3, 4); } @@ -716,19 +711,19 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = spinbox (_("Change the color lightness by this percentage for each row"), "lightness_per_j", + auto l = spinbox (_("Change the color lightness by this percentage for each row"), "lightness_per_j", -100, 100, "%"); table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = spinbox (_("Change the color lightness by this percentage for each column"), "lightness_per_i", + auto l = spinbox (_("Change the color lightness by this percentage for each column"), "lightness_per_i", -100, 100, "%"); table_attach (table, l, 0, 4, 3); } { - GtkWidget *l = spinbox (_("Randomize the color lightness by this percentage"), "lightness_rand", + auto l = spinbox (_("Randomize the color lightness by this percentage"), "lightness_rand", 0, 100, "%"); table_attach (table, l, 0, 4, 4); } @@ -742,12 +737,12 @@ CloneTiler::CloneTiler () : } { - GtkWidget *l = checkbox (_("Alternate the sign of color changes for each row"), "color_alternatej"); + auto l = checkbox (_("Alternate the sign of color changes for each row"), "color_alternatej"); table_attach (table, l, 0, 5, 2); } { - GtkWidget *l = checkbox (_("Alternate the sign of color changes for each column"), "color_alternatei"); + auto l = checkbox (_("Alternate the sign of color changes for each column"), "color_alternatei"); table_attach (table, l, 0, 5, 3); } @@ -785,71 +780,62 @@ CloneTiler::CloneTiler () : gtk_grid_set_column_spacing(GTK_GRID(table), 6); gtk_container_add(GTK_CONTAINER(frame), table); - - GtkWidget* radio; + Gtk::RadioButtonGroup rb_group; { - radio = gtk_radio_button_new_with_label (NULL, _("Color")); - gtk_widget_set_tooltip_text (radio, _("Pick the visible color and opacity")); - table_attach (table, radio, 0.0, 1, 1); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_COLOR)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_COLOR); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("Color"))); + radio->set_tooltip_text(_("Pick the visible color and opacity")); + table_attach(table, radio, 0.0, 1, 1); + radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_COLOR)); + radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_COLOR); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Opacity")); - gtk_widget_set_tooltip_text (radio, _("Pick the total accumulated opacity")); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("Opacity"))); + radio->set_tooltip_text(_("Pick the total accumulated opacity")); table_attach (table, radio, 0.0, 2, 1); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_OPACITY)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_OPACITY); + radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_OPACITY)); + radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_OPACITY); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("R")); - gtk_widget_set_tooltip_text (radio, _("Pick the Red component of the color")); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("R"))); + radio->set_tooltip_text(_("Pick the Red component of the color")); table_attach (table, radio, 0.0, 1, 2); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_R)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_R); + radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_R)); + radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_R); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("G")); - gtk_widget_set_tooltip_text (radio, _("Pick the Green component of the color")); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("G"))); + radio->set_tooltip_text(_("Pick the Green component of the color")); table_attach (table, radio, 0.0, 2, 2); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_G)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_G); + radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_G)); + radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_G); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("B")); - gtk_widget_set_tooltip_text (radio, _("Pick the Blue component of the color")); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("B"))); + radio->set_tooltip_text(_("Pick the Blue component of the color")); table_attach (table, radio, 0.0, 3, 2); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_B)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_B); + radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_B)); + radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_B); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color hue", "H")); - gtk_widget_set_tooltip_text (radio, _("Pick the hue of the color")); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, C_("Clonetiler color hue", "H"))); + radio->set_tooltip_text(_("Pick the hue of the color")); table_attach (table, radio, 0.0, 1, 3); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_H)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_H); + radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_H)); + radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_H); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color saturation", "S")); - gtk_widget_set_tooltip_text (radio, _("Pick the saturation of the color")); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, C_("Clonetiler color saturation", "S"))); + radio->set_tooltip_text(_("Pick the saturation of the color")); table_attach (table, radio, 0.0, 2, 3); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_S)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_S); + radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_S)); + radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_S); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color lightness", "L")); - gtk_widget_set_tooltip_text (radio, _("Pick the lightness of the color")); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, C_("Clonetiler color lightness", "L"))); + radio->set_tooltip_text(_("Pick the lightness of the color")); table_attach (table, radio, 0.0, 3, 3); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (pick_switched), GINT_TO_POINTER(PICK_L)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_L); + radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_L)); + radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_L); } } @@ -870,7 +856,7 @@ CloneTiler::CloneTiler () : table_attach (table, l, 1.0, 1, 1); } { - GtkWidget *l = spinbox (_("Shift the mid-range of the picked value upwards (>0) or downwards (<0)"), "gamma_picked", + auto l = spinbox (_("Shift the mid-range of the picked value upwards (>0) or downwards (<0)"), "gamma_picked", -10, 10, ""); table_attach (table, l, 0.0, 1, 2); } @@ -881,7 +867,7 @@ CloneTiler::CloneTiler () : table_attach (table, l, 1.0, 1, 3); } { - GtkWidget *l = spinbox (_("Randomize the picked value by this percentage"), "rand_picked", + auto l = spinbox (_("Randomize the picked value by this percentage"), "rand_picked", 0, 100, "%"); table_attach (table, l, 0.0, 1, 4); } @@ -892,7 +878,7 @@ CloneTiler::CloneTiler () : table_attach (table, l, 1.0, 2, 1); } { - GtkWidget *l = checkbox (_("Invert the picked value"), "invert_picked"); + auto l = checkbox (_("Invert the picked value"), "invert_picked"); table_attach (table, l, 0.0, 2, 2); } } @@ -907,43 +893,39 @@ CloneTiler::CloneTiler () : gtk_container_add(GTK_CONTAINER(frame), table); { - GtkWidget *b = gtk_check_button_new_with_label (_("Presence")); + auto b = Gtk::manage(new Gtk::CheckButton(_("Presence"))); bool old = prefs->getBool(prefs_path + "pick_to_presence", true); - gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_widget_set_tooltip_text (b, _("Each clone is created with the probability determined by the picked value in that point")); + b->set_active(old); + b->set_tooltip_text(_("Each clone is created with the probability determined by the picked value in that point")); table_attach (table, b, 0.0, 1, 1); - g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(pick_to), (gpointer) "pick_to_presence"); + b->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_to), b, "pick_to_presence")); } { - GtkWidget *b = gtk_check_button_new_with_label (_("Size")); + auto b = Gtk::manage(new Gtk::CheckButton(_("Size"))); bool old = prefs->getBool(prefs_path + "pick_to_size"); - gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_widget_set_tooltip_text (b, _("Each clone's size is determined by the picked value in that point")); + b->set_active(old); + b->set_tooltip_text(_("Each clone's size is determined by the picked value in that point")); table_attach (table, b, 0.0, 2, 1); - g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(pick_to), (gpointer) "pick_to_size"); + b->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_to), b, "pick_to_size")); } { - GtkWidget *b = gtk_check_button_new_with_label (_("Color")); + auto b = Gtk::manage(new Gtk::CheckButton(_("Color"))); bool old = prefs->getBool(prefs_path + "pick_to_color", 0); - gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_widget_set_tooltip_text (b, _("Each clone is painted by the picked color (the original must have unset fill or stroke)")); + b->set_active(old); + b->set_tooltip_text(_("Each clone is painted by the picked color (the original must have unset fill or stroke)")); table_attach (table, b, 0.0, 1, 2); - g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(pick_to), (gpointer) "pick_to_color"); + b->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_to), b, "pick_to_color")); } { - GtkWidget *b = gtk_check_button_new_with_label (_("Opacity")); + auto b = Gtk::manage(new Gtk::CheckButton(_("Opacity"))); bool old = prefs->getBool(prefs_path + "pick_to_opacity", 0); - gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_widget_set_tooltip_text (b, _("Each clone's opacity is determined by the picked value in that point")); + b->set_active(old); + b->set_tooltip_text(_("Each clone's opacity is determined by the picked value in that point")); table_attach (table, b, 0.0, 2, 2); - g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(pick_to), (gpointer) "pick_to_opacity"); + b->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_to), b, "pick_to_opacity")); } } gtk_widget_set_sensitive (vvb, prefs->getBool(prefs_path + "dotrace")); @@ -980,9 +962,7 @@ CloneTiler::CloneTiler () : sb->set_width_chars (7); _rowscols->pack_start(*sb, true, true, 0); - // TODO: C++ification - g_signal_connect(G_OBJECT(a->gobj()), "value_changed", - G_CALLBACK(xy_changed), (gpointer) "jmax"); + a->signal_value_changed().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::xy_changed), a, "jmax")); } { @@ -1002,9 +982,7 @@ CloneTiler::CloneTiler () : sb->set_width_chars (7); _rowscols->pack_start(*sb, true, true, 0); - // TODO: C++ification - g_signal_connect(G_OBJECT(a->gobj()), "value_changed", - G_CALLBACK(xy_changed), (gpointer) "imax"); + a->signal_value_changed().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::xy_changed), a, "imax")); } table_attach (table, GTK_WIDGET(_rowscols->gobj()), 0.0, 1, 2); @@ -1164,11 +1142,11 @@ CloneTiler::CloneTiler () : } { - GtkWidget *b = gtk_button_new_with_mnemonic (_(" R_eset ")); + auto b = Gtk::manage(new Gtk::Button(_(" R_eset "), true)); // TRANSLATORS: "change" is a noun here - gtk_widget_set_tooltip_text (b, _("Reset all shifts, scales, rotates, opacity and color changes in the dialog to zero")); - g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (reset), this); - gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); + b->set_tooltip_text(_("Reset all shifts, scales, rotates, opacity and color changes in the dialog to zero")); + b->signal_clicked().connect(sigc::mem_fun(*this, &CloneTiler::reset)); + gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(b->gobj()), FALSE, FALSE, 0); } } @@ -2197,7 +2175,7 @@ void CloneTiler::apply() SPItem *item = dynamic_cast(obj); if (dotrace) { - trace_setup (desktop->getDocument(), 1.0, item); + trace_setup(desktop->getDocument(), 1.0, item); } Geom::Point center; @@ -2524,72 +2502,74 @@ GtkWidget * CloneTiler::new_tab(GtkWidget *nb, const gchar *label) return vb; } -void CloneTiler::checkbox_toggled(GtkToggleButton *tb, gpointer *data) +void CloneTiler::checkbox_toggled(Gtk::ToggleButton *tb, + const Glib::ustring &attr) { - const gchar *attr = (const gchar *) data; - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setBool(prefs_path + attr, gtk_toggle_button_get_active(tb)); + auto prefs = Inkscape::Preferences::get(); + prefs->setBool(prefs_path + attr, tb->get_active()); } -GtkWidget * CloneTiler::checkbox(const char *tip, const char *attr) +Gtk::Widget * CloneTiler::checkbox(const char *tip, + const Glib::ustring &attr) { - auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); - gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); - - GtkWidget *b = gtk_check_button_new (); - gtk_widget_set_tooltip_text (b, tip); + auto hb = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, VB_MARGIN)); + auto b = Gtk::manage(new Gtk::CheckButton()); + b->set_tooltip_text(tip); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - bool value = prefs->getBool(prefs_path + attr); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(b), value); + auto const prefs = Inkscape::Preferences::get(); + auto const value = prefs->getBool(prefs_path + attr); + b->set_active(value); - gtk_box_pack_end (GTK_BOX (hb), b, FALSE, TRUE, 0); - g_signal_connect ( G_OBJECT (b), "clicked", - G_CALLBACK (checkbox_toggled), (gpointer) attr); + hb->pack_end(*b, false, true); + b->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::checkbox_toggled), b, attr)); - g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE)); + b->set_data("uncheckable", GINT_TO_POINTER(true)); return hb; } -void CloneTiler::value_changed(GtkAdjustment *adj, gpointer data) +void CloneTiler::value_changed(Glib::RefPtr &adj, + Glib::ustring const &pref) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - const gchar *pref = (const gchar *) data; - prefs->setDouble(prefs_path + pref, gtk_adjustment_get_value (adj)); + auto prefs = Inkscape::Preferences::get(); + prefs->setDouble(prefs_path + pref, adj->get_value()); } -GtkWidget * CloneTiler::spinbox(const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent/* = false*/) +Gtk::Widget * CloneTiler::spinbox(const char *tip, + const Glib::ustring &attr, + double lower, + double upper, + const gchar *suffix, + bool exponent/* = false*/) { - auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); - gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); + auto hb = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 0)); { - Glib::RefPtr a; - if (exponent) { - a = Gtk::Adjustment::create(1.0, lower, upper, 0.01, 0.05, 0); - } else { - a = Gtk::Adjustment::create(0.0, lower, upper, 0.1, 0.5, 0); - } + // Parameters for adjustment + auto const initial_value = (exponent ? 1.0 : 0.0); + auto const step_increment = (exponent ? 0.01 : 0.1); + auto const page_increment = (exponent ? 0.05 : 0.4); - Inkscape::UI::Widget::SpinButton *sb; - if (exponent) { - sb = new Inkscape::UI::Widget::SpinButton(a, 0.01, 2); - } else { - sb = new Inkscape::UI::Widget::SpinButton(a, 0.1, 1); - } + auto a = Gtk::Adjustment::create(initial_value, + lower, + upper, + step_increment, + page_increment); + + auto const climb_rate = (exponent ? 0.01 : 0.1); + auto const digits = (exponent ? 2 : 1); + + auto sb = new Inkscape::UI::Widget::SpinButton(a, climb_rate, digits); sb->set_tooltip_text (tip); sb->set_width_chars (5); sb->set_digits(3); - gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(sb->gobj()), FALSE, FALSE, SB_MARGIN); + hb->pack_start(*sb, false, false, SB_MARGIN); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - double value = prefs->getDoubleLimited(prefs_path + attr, exponent? 1.0 : 0.0, lower, upper); + auto prefs = Inkscape::Preferences::get(); + auto value = prefs->getDoubleLimited(prefs_path + attr, exponent? 1.0 : 0.0, lower, upper); a->set_value (value); - // TODO: C++ification - g_signal_connect(G_OBJECT(a->gobj()), "value_changed", - G_CALLBACK(value_changed), (gpointer) attr); + a->signal_value_changed().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::value_changed), a, attr)); if (exponent) { sb->set_data ("oneable", GINT_TO_POINTER(TRUE)); @@ -2599,28 +2579,27 @@ GtkWidget * CloneTiler::spinbox(const char *tip, const char *attr, double lower, } { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), suffix); - gtk_widget_set_halign(l, GTK_ALIGN_END); - gtk_widget_set_valign(l, GTK_ALIGN_START); - gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0); + auto l = Gtk::manage(new Gtk::Label("")); + l->set_markup(suffix); + l->set_halign(Gtk::ALIGN_END); + l->set_valign(Gtk::ALIGN_START); + hb->pack_start(*l); } return hb; } -void CloneTiler::symgroup_changed(GtkComboBox *cb, gpointer /*data*/) +void CloneTiler::symgroup_changed(Gtk::ComboBox *cb) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - gint group_new = gtk_combo_box_get_active (cb); + auto prefs = Inkscape::Preferences::get(); + auto group_new = cb->get_active_row_number(); prefs->setInt(prefs_path + "symmetrygroup", group_new); } -void CloneTiler::xy_changed(GtkAdjustment *adj, gpointer data) +void CloneTiler::xy_changed(Glib::RefPtr &adj, Glib::ustring const &pref) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - const gchar *pref = (const gchar *) data; - prefs->setInt(prefs_path + pref, (int) floor(gtk_adjustment_get_value (adj) + 0.5)); + auto prefs = Inkscape::Preferences::get(); + prefs->setInt(prefs_path + pref, (int) floor(adj->get_value() + 0.5)); } void CloneTiler::keep_bbox_toggled() @@ -2629,11 +2608,10 @@ void CloneTiler::keep_bbox_toggled() prefs->setBool(prefs_path + "keepbbox", _cb_keep_bbox->get_active()); } -void CloneTiler::pick_to(GtkToggleButton *tb, gpointer data) +void CloneTiler::pick_to(Gtk::ToggleButton *tb, Glib::ustring const &pref) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - const gchar *pref = (const gchar *) data; - prefs->setBool(prefs_path + pref, gtk_toggle_button_get_active(tb)); + auto prefs = Inkscape::Preferences::get(); + prefs->setBool(prefs_path + pref, tb->get_active()); } @@ -2671,9 +2649,14 @@ void CloneTiler::reset_recursive(GtkWidget *w) } } -void CloneTiler::reset(GtkWidget */*widget*/, GtkWidget *dlg) +void CloneTiler::reset() +{ + reset_recursive(GTK_WIDGET(this->gobj())); +} + +void CloneTiler::table_attach(GtkWidget *table, Gtk::Widget *widget, float align, int row, int col) { - reset_recursive (dlg); + table_attach(table, GTK_WIDGET(widget->gobj()), align, row, col); } void CloneTiler::table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col) @@ -2728,14 +2711,12 @@ GtkWidget * CloneTiler::table_x_y_rand(int values) return table; } -void CloneTiler::pick_switched(GtkToggleButton */*tb*/, gpointer data) +void CloneTiler::pick_switched(PickType v) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - guint v = GPOINTER_TO_INT (data); + auto prefs = Inkscape::Preferences::get(); prefs->setInt(prefs_path + "pick", v); } - void CloneTiler::switch_to_create() { if (_rowscols) { diff --git a/src/ui/dialog/clonetiler.h b/src/ui/dialog/clonetiler.h index 04f676800..db3049ef1 100644 --- a/src/ui/dialog/clonetiler.h +++ b/src/ui/dialog/clonetiler.h @@ -18,6 +18,7 @@ namespace Gtk { class CheckButton; + class ComboBox; class ToggleButton; } @@ -38,48 +39,66 @@ public: static CloneTiler &getInstance() { return *new CloneTiler(); } void show_page_trace(); protected: + enum PickType { + PICK_COLOR, + PICK_OPACITY, + PICK_R, + PICK_G, + PICK_B, + PICK_H, + PICK_S, + PICK_L + }; GtkWidget * new_tab(GtkWidget *nb, const gchar *label); GtkWidget * table_x_y_rand(int values); - GtkWidget * spinbox(const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent = false); - GtkWidget * checkbox(const char *tip, const char *attr); + Gtk::Widget * spinbox(const char *tip, + const Glib::ustring &attr, + double lower, + double upper, + const gchar *suffix, + bool exponent = false); + Gtk::Widget * checkbox(const char *tip, + const Glib::ustring &attr); void table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col); - - // TODO: Improve encapsulation by using SigC++ signal handling, and convert all of these into - // non-static member functions - static void symgroup_changed(GtkComboBox *cb, gpointer /*data*/); - static void on_picker_color_changed(guint rgba); - static void trace_hide_tiled_clones_recursively(SPObject *from); - static void checkbox_toggled(GtkToggleButton *tb, gpointer *data); - static void pick_switched(GtkToggleButton */*tb*/, gpointer data); - static void pick_to(GtkToggleButton *tb, gpointer data); - static void xy_changed(GtkAdjustment *adj, gpointer data); - void switch_to_create(); - void switch_to_fill(); - void keep_bbox_toggled(); - void unclump(); - static void reset(GtkWidget */*widget*/, GtkWidget *dlg); - static guint number_of_clones(SPObject *obj); - static void trace_setup(SPDocument *doc, gdouble zoom, SPItem *original); - static guint32 trace_pick(Geom::Rect box); - static void trace_finish(); - static bool is_a_clone_of(SPObject *tile, SPObject *obj); - static Geom::Rect transform_rect(Geom::Rect const &r, Geom::Affine const &m); - static double randomize01(double val, double rand); - static void value_changed(GtkAdjustment *adj, gpointer data); - static void reset_recursive(GtkWidget *w); + void table_attach(GtkWidget *table, Gtk::Widget *widget, float align, int row, int col); + + void symgroup_changed(Gtk::ComboBox *cb); + void on_picker_color_changed(guint rgba); + void trace_hide_tiled_clones_recursively(SPObject *from); + guint number_of_clones(SPObject *obj); + void trace_setup(SPDocument *doc, gdouble zoom, SPItem *original); + guint32 trace_pick(Geom::Rect box); + void trace_finish(); + bool is_a_clone_of(SPObject *tile, SPObject *obj); + Geom::Rect transform_rect(Geom::Rect const &r, Geom::Affine const &m); + double randomize01(double val, double rand); void apply(); void change_selection(Inkscape::Selection *selection); + void checkbox_toggled(Gtk::ToggleButton *tb, + Glib::ustring const &attr); void do_pick_toggled(); void external_change(); void fill_width_changed(); void fill_height_changed(); - void remove(bool do_undo = true); + void keep_bbox_toggled(); void on_remove_button_clicked() {remove();} + void pick_switched(PickType); + void pick_to(Gtk::ToggleButton *tb, + Glib::ustring const &pref); + void remove(bool do_undo = true); + void reset(); + void reset_recursive(GtkWidget *w); + void switch_to_create(); + void switch_to_fill(); + void unclump(); void unit_changed(); + void value_changed(Glib::RefPtr &adj, Glib::ustring const &pref); + void xy_changed(Glib::RefPtr &adj, Glib::ustring const &pref); - static Geom::Affine get_transform( // symmetry group + Geom::Affine get_transform( + // symmetry group int type, // row, column @@ -156,20 +175,10 @@ private: GtkWidget *_status; Gtk::Box *_rowscols; Gtk::Box *_widthheight; + }; -enum { - PICK_COLOR, - PICK_OPACITY, - PICK_R, - PICK_G, - PICK_B, - PICK_H, - PICK_S, - PICK_L -}; - enum { TILE_P1, TILE_P2, -- cgit v1.2.3