gui/builder: Get an object from the builder
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
961659bc66
commit
d4b27316c0
|
@ -17,6 +17,13 @@ void gui_builder_deinit()
|
|||
gui_builder = NULL;
|
||||
}
|
||||
|
||||
GObject *gui_builder_object(const char *name)
|
||||
{
|
||||
if (gui_builder)
|
||||
return gtk_builder_get_object(gui_builder, name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_TESTING
|
||||
GtkBuilder *test_get_gui_builder()
|
||||
{
|
||||
|
|
|
@ -11,6 +11,9 @@ void gui_builder_init(const char *);
|
|||
/* Called to deinitialize the GTK builder. */
|
||||
void gui_builder_deinit();
|
||||
|
||||
/* Called to get an object from the GTK builder. */
|
||||
GObject *gui_builder_object(const char *);
|
||||
|
||||
#ifdef CONFIG_TESTING
|
||||
GtkBuilder *test_get_gui_builder();
|
||||
#endif /* CONFIG_TESTING */
|
||||
|
|
|
@ -14,15 +14,22 @@ void test_builder_clicked()
|
|||
static void test_builder()
|
||||
{
|
||||
int argc = 0;
|
||||
GObject *object;
|
||||
|
||||
test_equal((void *)test_get_gui_builder(), NULL);
|
||||
test_equal((void *)gui_builder_object("button1"), NULL);
|
||||
|
||||
gtk_init(&argc, NULL);
|
||||
gui_builder_init("tests/gui/builder.ui");
|
||||
test_not_equal((void *)test_get_gui_builder(), NULL);
|
||||
|
||||
object = gui_builder_object("button1");
|
||||
test_not_equal((void *)object, NULL);
|
||||
test_equal(G_IS_OBJECT(object), true);
|
||||
|
||||
gui_builder_deinit();
|
||||
test_equal((void *)test_get_gui_builder(), NULL);
|
||||
test_equal((void *)gui_builder_object("button1"), NULL);
|
||||
}
|
||||
|
||||
DECLARE_UNIT_TESTS(
|
||||
|
|
Loading…
Reference in New Issue