summaryrefslogtreecommitdiffstats
path: root/src/ui/builder-utils.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
commitcca66b9ec4e494c1d919bff0f71a820d8afab1fa (patch)
tree146f39ded1c938019e1ed42d30923c2ac9e86789 /src/ui/builder-utils.h
parentInitial commit. (diff)
downloadinkscape-upstream/1.2.2.tar.xz
inkscape-upstream/1.2.2.zip
Adding upstream version 1.2.2.upstream/1.2.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/ui/builder-utils.h')
-rw-r--r--src/ui/builder-utils.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/ui/builder-utils.h b/src/ui/builder-utils.h
new file mode 100644
index 0000000..ef6d181
--- /dev/null
+++ b/src/ui/builder-utils.h
@@ -0,0 +1,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 \ No newline at end of file