Inkscape
Vector Graphics Editor
labelled.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Authors:
4 * Carl Hetherington <inkscape@carlh.net>
5 * Derek P. Moore <derekm@hackunix.org>
6 *
7 * Copyright (C) 2004 Carl Hetherington
8 *
9 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
10 */
11
12#include "labelled.h"
13
14#include <gtkmm/enums.h>
15#include <gtkmm/image.h>
16#include <gtkmm/label.h>
17
18#include "ui/icon-loader.h"
19#include "ui/pack.h"
20
21namespace Inkscape::UI::Widget {
22
23Labelled::Labelled(Glib::ustring const &label, Glib::ustring const &tooltip,
24 Gtk::Widget *widget,
25 Glib::ustring const &icon,
26 bool mnemonic)
27 : Gtk::Box{Gtk::Orientation::HORIZONTAL, 6}
28 , _widget{widget}
29 , _label{Gtk::make_managed<Gtk::Label>(label, Gtk::Align::START, Gtk::Align::CENTER, mnemonic)}
30{
31 g_assert(widget);
32 g_assert(g_utf8_validate(icon.c_str(), -1, nullptr));
33
34 if (!icon.empty()) {
35 auto const image = sp_get_icon_image(icon, Gtk::IconSize::LARGE);
37 }
38
40 _label->set_halign(Gtk::Align::START);
41 UI::pack_start(*this, *Gtk::manage(_widget), UI::PackOptions::shrink);
42
43 if (mnemonic) {
44 _label->set_mnemonic_widget(*_widget);
45 }
46
47 set_tooltip_markup(tooltip);
48}
49
50bool Labelled::on_mnemonic_activate(bool const group_cycling)
51{
52 return _widget->mnemonic_activate(group_cycling);
53}
54
55} // namespace Inkscape::UI::Widget
56
57/*
58 Local Variables:
59 mode:c++
60 c-file-style:"stroustrup"
61 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
62 indent-tabs-mode:nil
63 fill-column:99
64 End:
65*/
66// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
Labelled(Glib::ustring const &label, Glib::ustring const &tooltip, Gtk::Widget *widget, Glib::ustring const &icon={}, bool mnemonic=true)
Construct a Labelled Widget.
Definition: labelled.cpp:23
bool on_mnemonic_activate(bool group_cycling) final
Definition: labelled.cpp:50
Gtk::Image * sp_get_icon_image(Glib::ustring const &icon_name, int size)
Definition: icon-loader.cpp:27
Icon Loader.
std::unique_ptr< Magick::Image > image
Definition: imagemagick.cpp:40
Align
Values for the <align> parameter of preserveAspectRatio.
Definition: rect.h:51
Definition: desktop.h:51
Custom widgets.
Definition: desktop.h:127
void pack_start(Gtk::Box &box, Gtk::Widget &child, bool const expand, bool const fill, unsigned const padding)
Adds child to box, packed with reference to the start of box.
Definition: pack.cpp:141
Helpers for using Gtk::Boxes, encapsulating large changes between GTK3 & GTK4.