// SPDX-License-Identifier: GPL-2.0-or-later /* * Authors: * Carl Hetherington * Derek P. Moore * * Copyright (C) 2004 Carl Hetherington * * Released under GNU GPL v2+, read the file 'COPYING' for more information. */ #include "ui/icon-loader.h" #include "labelled.h" #include #include namespace Inkscape { namespace UI { namespace Widget { Labelled::Labelled(Glib::ustring const &label, Glib::ustring const &tooltip, Gtk::Widget *widget, Glib::ustring const &suffix, Glib::ustring const &icon, bool mnemonic) : _widget(widget), _label(new Gtk::Label(label, Gtk::ALIGN_END, Gtk::ALIGN_CENTER, mnemonic)), _suffix(new Gtk::Label(suffix, Gtk::ALIGN_START)) { g_assert(g_utf8_validate(icon.c_str(), -1, nullptr)); if (icon != "") { _icon = Gtk::manage(sp_get_icon_image(icon, Gtk::ICON_SIZE_LARGE_TOOLBAR)); pack_start(*_icon, Gtk::PACK_SHRINK); } pack_start(*Gtk::manage(_label), Gtk::PACK_EXPAND_WIDGET, 6); pack_start(*Gtk::manage(_widget), Gtk::PACK_SHRINK, 6); if (mnemonic) { _label->set_mnemonic_widget(*_widget); } widget->set_tooltip_text(tooltip); } void Labelled::setWidgetSizeRequest(int width, int height) { if (_widget) _widget->set_size_request(width, height); } Gtk::Widget const * Labelled::getWidget() const { return _widget; } Gtk::Label const * Labelled::getLabel() const { return _label; } void Labelled::setLabelText(const Glib::ustring &str) { _label->set_text(str); } void Labelled::setTooltipText(const Glib::ustring &tooltip) { _label->set_tooltip_text(tooltip); _widget->set_tooltip_text(tooltip); } void Labelled::flipIconVertically() { _icon->set(_icon->get_pixbuf()->flip(false)); } bool Labelled::on_mnemonic_activate ( bool group_cycling ) { return _widget->mnemonic_activate ( group_cycling ); } } // namespace Widget } // namespace UI } // namespace Inkscape /* Local Variables: mode:c++ c-file-style:"stroustrup" 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 :