]> git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/brushexport/support.cpp
reformat code! now the code is only ugly on the *inside*
[xonotic/netradiant.git] / contrib / brushexport / support.cpp
1 #include <gtk/gtk.h>
2 #include <uilib/uilib.h>
3
4 #include "support.h"
5
6 ui::Widget
7 lookup_widget(ui::Widget widget,
8               const gchar *widget_name)
9 {
10     ui::Widget parent{ui::null};
11
12     for (;;) {
13         if (GTK_IS_MENU(widget)) {
14             parent = ui::Widget::from(gtk_menu_get_attach_widget(GTK_MENU(widget)));
15         } else {
16             parent = ui::Widget::from(gtk_widget_get_parent(widget));
17         }
18         if (!parent) {
19             parent = ui::Widget::from(g_object_get_data(G_OBJECT(widget), "GladeParentKey"));
20         }
21         if (parent == NULL) {
22             break;
23         }
24         widget = parent;
25     }
26
27     auto found_widget = ui::Widget::from(g_object_get_data(G_OBJECT(widget), widget_name));
28     if (!found_widget) {
29         g_warning("Widget not found: %s", widget_name);
30     }
31     return found_widget;
32 }