summaryrefslogtreecommitdiffstats
path: root/src/ui/toolbar/booleans-toolbar.cpp
blob: e3172c8437ecc3668c53ebed896906f20957b048 (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
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * A toolbar for the Builder tool.
 *
 * Authors:
 *   Martin Owens
 *
 * Copyright (C) 2022 authors
 *
 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
 */

#include "desktop.h"
#include "ui/builder-utils.h"
#include "ui/toolbar/booleans-toolbar.h"
#include "ui/tools/booleans-tool.h"

namespace Inkscape {
namespace UI {
namespace Toolbar {

BooleansToolbar::BooleansToolbar(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &builder, SPDesktop *desktop)
    : Gtk::Toolbar(cobject)
    , _builder(builder)
    , _btn_confirm(get_widget<Gtk::ToolButton>(builder, "confirm"))
    , _btn_cancel(get_widget<Gtk::ToolButton>(builder, "cancel"))
{
    _btn_confirm.signal_clicked().connect([=]{
        auto ec = dynamic_cast<Tools::InteractiveBooleansTool *>(desktop->event_context);
        ec->shape_commit();
    });
    _btn_cancel.signal_clicked().connect([=]{
        auto ec = dynamic_cast<Tools::InteractiveBooleansTool *>(desktop->event_context);
        ec->shape_cancel();
    });
}

void BooleansToolbar::on_parent_changed(Gtk::Widget *) {
    _builder.reset();
}

GtkWidget *
BooleansToolbar::create(SPDesktop *desktop)
{
    BooleansToolbar *toolbar;
    auto builder = Inkscape::UI::create_builder("toolbar-booleans.ui");
    builder->get_widget_derived("booleans-toolbar", toolbar, desktop);
    return GTK_WIDGET(toolbar->gobj());
}

} // namespace Toolbar
} // namespace UI
} // namespace Inkscape