summaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/paint-servers.cpp
blob: 42f437c26f559e55c3f3b275985b10542bccf3d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
// SPDX-License-Identifier: GPL-2.0-or-later
/** @file
 * @brief Paint Servers dialog
 */
/* Authors:
 *   Valentin Ionita
 *   Rafael Siejakowski <rs@rs-math.net>
 *
 * Copyright (C) 2019 Valentin Ionita
 *
 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
 */

#include <algorithm>
#include <map>

#include <giomm/listmodel.h>
#include <glibmm/regex.h>
#include <gtkmm/drawingarea.h>
#include <gtkmm/iconview.h>
#include <gtkmm/liststore.h>
#include <gtkmm/stockid.h>
#include <gtkmm/switch.h>

#include "document.h"
#include "inkscape.h"
#include "paint-servers.h"
#include "path-prefix.h"
#include "style.h"

#include "io/resource.h"
#include "object/sp-defs.h"
#include "object/sp-hatch.h"
#include "object/sp-pattern.h"
#include "object/sp-root.h"
#include "ui/cache/svg_preview_cache.h"
#include "ui/widget/scrollprotected.h"
#include "xml/href-attribute-helper.h"

namespace Inkscape {
namespace UI {
namespace Dialog {

static Glib::ustring const wrapper = R"=====(
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
  <defs id="Defs"/>
  <rect id="Back" x="0" y="0" width="100px" height="100px" fill="lightgray"/>
  <rect id="Rect" x="0" y="0" width="100px" height="100px" stroke="black"/>
</svg>
)=====";

const char *ALLDOCS = N_("All paint servers");
const char *CURRENTDOC = N_("Current document");

PaintServersDialog::PaintServersDialog()
    : DialogBase("/dialogs/paint", "PaintServers")
    , _targetting_fill(true)
    , columns()
{
    current_store = ALLDOCS;
    store[ALLDOCS] = Gtk::ListStore::create(columns);

    // Get wrapper document (rectangle to fill with paint server).
    preview_document = SPDocument::createNewDocFromMem(wrapper.c_str(), wrapper.length(), true);
    SPObject *rect = preview_document->getObjectById("Rect");
    SPObject *defs = preview_document->getObjectById("Defs");
    if (!rect || !defs) {
        g_warn_message("Inkscape", __FILE__, __LINE__, __func__,
                       "Failed to get wrapper defs or rectangle for preview document!");
    }
    unsigned key = SPItem::display_key_new(1);
    preview_document->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
    preview_document->ensureUpToDate();
    renderDrawing.setRoot(preview_document->getRoot()->invoke_show(renderDrawing, key, SP_ITEM_SHOW_DISPLAY));

    _buildDialogWindow("dialog-paint-servers.glade");
    _loadStockPaints();
}


PaintServersDialog::~PaintServersDialog()
{
    _defs_changed.disconnect();
    _document_closed.disconnect();
}

/** Handles the replacement of the document that we edit */
void PaintServersDialog::documentReplaced()
{
    _defs_changed.disconnect();
    _document_closed.disconnect();

    auto document = getDocument();
    if (!document) {
        return;
    }
    document_map[CURRENTDOC] = document;
    _loadFromCurrentDocument();
    _regenerateAll();

    if (auto const defs = document->getDefs()) {
        _defs_changed = defs->connectModified([=](SPObject *, unsigned) -> void {
            _loadFromCurrentDocument();
            _regenerateAll();
        });
    }
    _document_closed = document->connectDestroy([=]() { _documentClosed(); });
}

/** Builds the dialog window from a Glade file and attaches event handlers */
void PaintServersDialog::_buildDialogWindow(char const *const glade_file)
{
    // Load the dialog from the Glade file
    auto file_path = get_filename_string(IO::Resource::UIS, glade_file);
    Glib::RefPtr<Gtk::Builder> builder;
    try {
        builder = Gtk::Builder::create_from_file(file_path);
    } catch (Glib::Error const &e) {
        Glib::ustring message{"Could not load the Glade file for the Paint Servers dialog: "};
        message += file_path + "\n" + e.what();
        g_warn_message("Inkscape", __FILE__, __LINE__, __func__, message.c_str());
        return;
    }

    // Place top-level grid container in the window
    Gtk::Grid *container = nullptr;
    builder->get_widget("PaintServersContainerGrid", container);
    if (container) {
        pack_start(*container, Gtk::PACK_EXPAND_WIDGET);
    } else {
        return;
    }

    builder->get_widget("ServersDropdown", dropdown);
    dropdown->append(ALLDOCS, _(ALLDOCS));
    dropdown->set_active_id(ALLDOCS);
    dropdown->signal_changed().connect([=]() { onPaintSourceDocumentChanged(); });

    builder->get_widget("PaintIcons", icon_view);
    icon_view->set_model(static_cast<Glib::RefPtr<Gtk::TreeModel>>(store[current_store]));
    icon_view->set_tooltip_column(columns.id.index());
    icon_view->set_pixbuf_column(columns.pixbuf.index());
    _item_activated = icon_view->signal_item_activated().connect([=](Gtk::TreeModel::Path const &p) {
        onPaintClicked(p);
    });

    Gtk::RadioButton *fill_radio = nullptr;
    builder->get_widget("TargetRadioFill", fill_radio);
    fill_radio->signal_toggled().connect([=]() {
        _targetting_fill = fill_radio->get_active();
        _updateActiveItem();
    });
}

/** Handles the destruction of the current document */
void PaintServersDialog::_documentClosed()
{
    _defs_changed.disconnect();
    _document_closed.disconnect();

    document_map.erase(CURRENTDOC);
    store[CURRENTDOC]->clear();
    _regenerateAll();
}

/**
 * @brief Returns the Fill and Stroke, in this order, common to a list of objects
 * @param objects - a vector of pointers to objects whose fill and stroke will be analysed
 * @return a tuple of optionals which are empty when the vector of objects is empty or
 *         when either fill or stroke are not common to all of them. Otherwise, the first
 *         element of the tuple is the common fill, as a Glib::ustring, and the second one
 *         is the common stroke.
 */
std::tuple<std::optional<Glib::ustring>, std::optional<Glib::ustring>>
PaintServersDialog::_findCommonFillAndStroke(std::vector<SPObject *> const &objects) const
{
    MaybeString common_fill, common_stroke;
    if (!objects.empty()) {
        Glib::ustring candidate_fill = objects[0]->style->fill.get_value();
        Glib::ustring candidate_stroke = objects[0]->style->stroke.get_value();
        bool fills_agree = true;
        bool strokes_agree = true;
        size_t const count = objects.size();
        for (size_t i = 1; i < count; i++) {
            if (fills_agree && candidate_fill != objects[i]->style->fill.get_value()) {
                fills_agree = false;
            }
            if (strokes_agree && candidate_stroke != objects[i]->style->stroke.get_value()) {
                strokes_agree = false;
            }
        }
        if (fills_agree) {
            common_fill = candidate_fill;
        }
        if (strokes_agree) {
            common_stroke = candidate_stroke;
        }
    }
    return std::tuple(common_fill, common_stroke);
}

/** Finds paints used by an object and (recursively) by its descendants
 *  @param in - the object whose paints to grab
 *  @param list - the paints will be added to this vector as strings usable in the `fill` CSS property
 */
void PaintServersDialog::_findPaints(SPObject *in, std::vector<Glib::ustring> &list)
{
    g_return_if_fail(in != nullptr);

    // Add paint servers in <defs> section.
    if (is<SPPaintServer>(in)) {
        if (in->getId()) {
            // Need to check as one can't construct Glib::ustring with nullptr.
            list.push_back(Glib::ustring("url(#") + in->getId() + ")");
        }
        // Don't recurse into paint servers.
        return;
    }

    // Add paint servers referenced by shapes.
    if (is<SPShape>(in)) {
        auto const style = in->style;
        list.push_back(style->fill.get_value());
        list.push_back(style->stroke.get_value());
    }

    for (auto child: in->childList(false)) {
        PaintServersDialog::_findPaints(child, list);
    }
}

/** Load stock paints from files in share/paint */
void PaintServersDialog::_loadStockPaints()
{
    std::vector<PaintDescription> paints;

    // Extract out paints from files in share/paint.
    for (auto const &path : get_filenames(Inkscape::IO::Resource::PAINT, {".svg"})) {
        try { // createNewDoc throws
            auto doc = std::unique_ptr<SPDocument>(SPDocument::createNewDoc(path.c_str(), false));
            if (!doc) {
                throw std::exception();
            }
            _loadPaintsFromDocument(doc.get(), paints);
            _stock_documents.push_back(std::move(doc)); // Ensures eventual destruction in our dtor
        } catch (std::exception &e) {
            auto message = Glib::ustring{"Cannot open paint server resource file '"} + path + "'!";
            g_warn_message("Inkscape", __FILE__, __LINE__, __func__, message.c_str());
            continue;
        }
    }

    _createPaints(paints);
}

/** Load paint servers from the <defs> of the current document */
void PaintServersDialog::_loadFromCurrentDocument()
{
    auto document = getDocument();
    if (!document) {
        return;
    }

    std::vector<PaintDescription> paints;
    _loadPaintsFromDocument(document, paints);

    // There can only be one current document, so we clear the corresponding store
    store[CURRENTDOC]->clear();
    _createPaints(paints);
}

/** Creates a collection of paints from the given vector of descriptions */
void PaintServersDialog::_createPaints(std::vector<PaintDescription> &collection)
{
    // Sort and remove duplicates.
    auto paints_cmp = [](PaintDescription const &a, PaintDescription const &b) -> bool {
        return a.url < b.url;
    };
    std::sort(collection.begin(), collection.end(), paints_cmp);
    collection.erase(std::unique(collection.begin(), collection.end()), collection.end());

    for (auto &paint : collection) {
        _instantiatePaint(paint);
    }
}

/** Create a paint from a description and generate its bitmap preview */
void PaintServersDialog::_instantiatePaint(PaintDescription &paint)
{
    if (!paint.has_preview()) {
        _generateBitmapPreview(paint);
    }
    if (paint.has_preview()) { // don't add the paint if preview generation failed.
        _addToStore(paint);
    }
}

/** Adds a paint to store */
void PaintServersDialog::_addToStore(PaintDescription &paint)
{
    if (store.find(paint.doc_title) == store.end()) {
        store[paint.doc_title] = Gtk::ListStore::create(columns);
    }

    auto iter = store[paint.doc_title]->append();
    paint.write_to_iterator(iter, &columns);

    if (document_map.find(paint.doc_title) == document_map.end()) {
        document_map[paint.doc_title] = paint.source_document;
        dropdown->append(paint.doc_title, _(paint.doc_title.c_str()));
    }
}

/** Returns a PaintDescription for a paint already present in the store */
PaintDescription PaintServersDialog::_descriptionFromIterator(Gtk::ListStore::iterator const &iter) const
{
    Glib::ustring doc_title = (*iter)[columns.document];
    SPDocument *doc_ptr;
    try {
        doc_ptr = document_map.at(doc_title);
    } catch (std::out_of_range &exception) {
        doc_ptr = nullptr;
    }
    Glib::ustring paint_url = (*iter)[columns.paint];
    PaintDescription result(doc_ptr, doc_title, std::move(paint_url));

    // Fill in fields that are set only on instantiation
    result.id = (*iter)[columns.id];
    result.bitmap = (*iter)[columns.pixbuf];
    return result;
}

/** Regenerates the list of all paint servers from the already loaded paints */
void PaintServersDialog::_regenerateAll()
{
    bool showing_all = (current_store == ALLDOCS);
    std::vector<PaintDescription> all_paints;

    for (auto const &[doc, paint_list] : store) {
        if (doc == ALLDOCS) {
            continue; // ignore the target store
        }
        paint_list->foreach_iter([&](Gtk::ListStore::iterator const &paint) -> bool
        {
            all_paints.push_back(_descriptionFromIterator(paint));
            return false;
        });
    }

    // Sort and remove duplicates. When the duplicate entry is from the current document,
    // we remove it preferentially, keeping the stock paint if available.
    std::sort(all_paints.begin(), all_paints.end(),
        [=](PaintDescription const &a, PaintDescription const &b) -> bool
        {
            int cmp = a.url.compare(b.url);
            if (cmp < 0) return true;
            if (cmp > 0) return false;

            auto external = [=] (PaintDescription const &p) { return p.doc_title != CURRENTDOC; };
            return external(a) && !external(b);
        });
    all_paints.erase(std::unique(all_paints.begin(), all_paints.end()), all_paints.end());

    store[ALLDOCS]->clear();

    // Add paints from the cleaned up list to the store
    for (auto &&paint : all_paints) {
        auto iter = store[ALLDOCS]->append();
        paint.write_to_iterator(iter, &columns);
    }

    if (showing_all) {
        selectionChanged(getSelection());
    }
}

/** Generates the bitmap preview for the given paint */
void PaintServersDialog::_generateBitmapPreview(PaintDescription &paint)
{
    SPObject *rect = preview_document->getObjectById("Rect");
    SPObject *defs = preview_document->getObjectById("Defs");

    paint.bitmap = Glib::RefPtr<Gdk::Pixbuf>(nullptr);
    if (paint.url.empty()) {
        return;
    }

    // Set style on the preview rectangle
    SPCSSAttr *css = sp_repr_css_attr_new();
    sp_repr_css_set_property(css, "fill", paint.url.c_str());
    rect->changeCSS(css, "style");
    sp_repr_css_attr_unref(css);

    // Insert paint into the defs of the preview document if required
    Glib::MatchInfo matchInfo;
    static Glib::RefPtr<Glib::Regex> regex = Glib::Regex::create("url\\(#([A-Za-z0-9#._-]*)\\)");

    regex->match(paint.url, matchInfo);
    if (!matchInfo.matches()) {
        // Currently we only show previews for hatches/patterns of the form url(#some-id)
        // TODO: handle colors, gradients, etc.
        // See https://wiki.inkscape.org/wiki/Google_Summer_of_Code#P11._Improvements_to_Paint_Server_Dialog
        return;
    }
    paint.id = matchInfo.fetch(1);

    // Delete old paints if necessary
    std::vector<SPObject *> old_paints = preview_document->getObjectsBySelector("defs > *");
    for (auto paint : old_paints) {
        paint->deleteObject(false);
    }

    // Find the new paint
    SPObject *new_paint = paint.source_document->getObjectById(paint.id);
    if (!new_paint) {
        Glib::ustring error_message = Glib::ustring{"Cannot find paint server: "} + paint.id;
        g_warn_message("Inkscape", __FILE__, __LINE__, __func__, error_message.c_str());
        return;
    }

    // Add the new paint along with all paints it refers to
    XML::Document *xml_doc = preview_document->getReprDoc();
    std::vector<SPObject *> encountered{new_paint}; ///< For the prevention of cyclic refs

    while (new_paint) {
        auto const *new_repr = new_paint->getRepr();
        if (!new_repr) {
            break;
        }

        // Create a copy repr of the paint
        defs->appendChild(new_repr->duplicate(xml_doc));

        // Check for cross-references in the paint
        auto ref = Inkscape::getHrefAttribute(*new_repr).second;
        if (ref) {
            // Paint is cross-referencing another object (probably another paint);
            // we must copy the referenced object as well
            new_paint = paint.source_document->getObjectByHref(ref);
            using namespace std;
            if (find(begin(encountered), end(encountered), new_paint) == end(encountered)) {
                encountered.push_back(new_paint);
            } else {
                break; // Break reference cycle
            }
        } else { // No more hrefs
            break;
        }
    }

    preview_document->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
    preview_document->ensureUpToDate();

    if (Geom::OptRect dbox = static_cast<SPItem *>(rect)->visualBounds())
    {
        unsigned size = std::ceil(std::max(dbox->width(), dbox->height()));
        paint.bitmap = Glib::wrap(render_pixbuf(renderDrawing, 1, *dbox, size));
    }
}

/** @brief Load paint servers from the given source document
 *  @param document - the source document
 *  @param output - the paint descriptions will be added to this vector */
void PaintServersDialog::_loadPaintsFromDocument(SPDocument *document, std::vector<PaintDescription> &output)
{
    Glib::ustring document_title;
    if (!document->getRoot()->title()) {
        document_title = CURRENTDOC;
    } else {
        document_title = Glib::ustring(document->getRoot()->title());
    }

    // Find all paints
    std::vector<Glib::ustring> urls;
    _findPaints(document->getRoot(), urls);

    for (auto const &url : urls) {
        output.emplace_back(document, document_title, std::move(url));
    }
}

/** Handles the change of the dropdown for selecting paint sources */
void PaintServersDialog::onPaintSourceDocumentChanged()
{
    current_store = dropdown->get_active_id();
    icon_view->set_model(store[current_store]);
    _updateActiveItem();
}

/** Event handler for when a paint entry in the dialog has been activated */
void PaintServersDialog::onPaintClicked(Gtk::TreeModel::Path const &path)
{
    // Get the current selected elements
    Selection *selection = getSelection();
    std::vector<SPObject *> items = _unpackSelection(selection);

    if (items.empty()) {
        return;
    }

    Gtk::ListStore::iterator iter = store[current_store]->get_iter(path);
    Glib::ustring id = (*iter)[columns.id];
    Glib::ustring paint = (*iter)[columns.paint];
    Glib::RefPtr<Gdk::Pixbuf> pixbuf = (*iter)[columns.pixbuf];
    Glib::ustring hatches_document_title = (*iter)[columns.document];
    SPDocument *hatches_document = document_map[hatches_document_title];
    SPObject *paint_server = hatches_document->getObjectById(id);

    bool paint_server_exists = false;
    for (auto const &server : store[CURRENTDOC]->children()) {
        if (server[columns.id] == id) {
            paint_server_exists = true;
            break;
        }
    }

    SPDocument *document = getDocument();
    if (!paint_server_exists) {
        // Add the paint server to the current document definition
        Inkscape::XML::Document *xml_doc = document->getReprDoc();
        Inkscape::XML::Node *repr = paint_server->getRepr()->duplicate(xml_doc);
        document->getDefs()->appendChild(repr);
        Inkscape::GC::release(repr);

        // Add the pixbuf to the current document store
        iter = store[CURRENTDOC]->append();
        (*iter)[columns.id] = id;
        (*iter)[columns.paint] = paint;
        (*iter)[columns.pixbuf] = pixbuf;
        (*iter)[columns.document] = CURRENTDOC;
    }

    for (auto item : items) {
        item->style->getFillOrStroke(_targetting_fill)->read(paint.c_str());
        item->updateRepr();
    }

    document->collectOrphans();
}

/**
 * @brief Handles the change in the selection, finding common fill or stroke for selected objects
 * @param selection - the new selection
 */
void PaintServersDialog::selectionChanged(Selection* selection)
{
    if (!selection || selection->isEmpty()) {
        _common_fill.reset();
        _common_stroke.reset();
    } else {
        auto const selected_items = _unpackSelection(selection);
        auto const &[fill, stroke] = _findCommonFillAndStroke(selected_items);
        _common_fill = std::move(fill);
        _common_stroke = std::move(stroke);
    }
    _updateActiveItem();
}

/**
 * Recursively extracts non-group elements from groups, if any
 * @param parent - the parent object which will be unpacked recursively
 * @param output - the resulting SPObject pointers will be added to this vector
 */
void PaintServersDialog::_unpackGroups(SPObject *parent, std::vector<SPObject *> &output) const
{
    std::vector<SPObject *> children = parent->childList(false);
    if (children.empty()) {
        output.push_back(parent);
    } else {
        for (auto child : children) {
            _unpackGroups(child, output);
        }
    }
}

/**
 * @brief Recursively unpacks groups in the given selection
 * @param selection - a pointer to an Inkscape::Selection object to be unpacked
 * @return a vector of SPObject pointers to the unpacked selected items.
 */
std::vector<SPObject *> PaintServersDialog::_unpackSelection(Selection *selection) const
{
    std::vector<SPObject *> result;
    if (!selection) {
        return result;
    }

    auto const &selected_range = selection->items();
    for (auto const item : selected_range) {
        _unpackGroups(static_cast<SPObject *>(item), result);
    }
    return result;
}

/**
 * @brief Updates the active item in the icon view to reflect the common paint of the
 *        fill or stroke of selected objects
 */
void PaintServersDialog::_updateActiveItem()
{
    _item_activated.block();
    MaybeString &common = (_targetting_fill ? _common_fill : _common_stroke);
    if (common) {
        bool found = false;
        store[current_store]->foreach(
            [&](Gtk::ListStore::Path const &path, Gtk::ListStore::iterator const &icon) -> bool {
                if ((*icon)[columns.paint] == *common) {
                    icon_view->select_path(path);
                    found = true;
                    return true; // Finish iterating
                }
                return false;
            });
        if (!found) {
            icon_view->unselect_all();
        }
    } else {
        icon_view->unselect_all();
    }
    _item_activated.unblock();
}

//----------------------------------------------------------------------------------------------------

PaintDescription::PaintDescription(SPDocument *source_doc, Glib::ustring title, Glib::ustring const &&paint_url)
    : source_document{source_doc}
    , doc_title{std::move(title)}
    , id{} // id will be filled in when generating the bitmap
    , url{paint_url}
    , bitmap{nullptr}
{}

/** Write the data stored in this struct to a list store
 * @param it - the iterator to the ListStore to write to
 */
void PaintDescription::write_to_iterator(Gtk::ListStore::iterator &it, PaintServersColumns const *cols) const {
    (*it)[cols->id] = id;
    (*it)[cols->paint] = url;
    (*it)[cols->pixbuf] = bitmap;
    (*it)[cols->document] = doc_title;
}

} // namespace Dialog
} // namespace UI
} // namespace Inkscape

/*
  Local Variables:
  mode:c++
  c-file-style:"stroustrup"
  c-basic-offset:2
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  indent-tabs-mode:nil
  fill-column:99
  End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :