blob: ef6d1810e3b0f170ca267e723033641b5ce09cb5 (
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
|
// SPDX-License-Identifier: GPL-2.0-or-later
/** @file
* @brief Gtk builder utilities
*/
/* Authors:
* Michael Kowalski
*
* Copyright (C) 2021 Michael Kowalski
* Released under GNU GPL v2+, read the file 'COPYING' for more information.
*/
#ifndef SEEN_BUILDER_UTILS_H
#define SEEN_BUILDER_UTILS_H
#include <gtkmm/builder.h>
namespace Inkscape {
namespace UI {
// get widget from builder or throw
template<class W> W& get_widget(Glib::RefPtr<Gtk::Builder>& builder, const char* id) {
W* widget;
builder->get_widget(id, widget);
if (!widget) {
throw std::runtime_error("Missing widget in a glade resource file");
}
return *widget;
}
// load glade file from share/ui folder and return builder; throws on errors
Glib::RefPtr<Gtk::Builder> create_builder(const char* filename);
} } // namespace
#endif // SEEN_BUILDER_UTILS_H
|