gui/builder: Add new file for accessing the GtkBuilder
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
27e09f47a6
commit
3bc5b1db9e
|
@ -18,6 +18,7 @@ class OEnvironment(Environment):
|
|||
self.Append(CXXCOMSTR = "C++ $TARGET")
|
||||
self.Append(CCCOMSTR = "CC $TARGET")
|
||||
self.Append(LINKCOMSTR = "Linking $TARGET")
|
||||
self.Append(ENV = { "DISPLAY" : os.environ["DISPLAY"] })
|
||||
self.Debug = CONFIG_DEBUG
|
||||
self.Version = CONFIG_VERSION
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright 2016 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <gui/builder.h>
|
||||
|
||||
static GtkBuilder *gui_builder = NULL;
|
||||
|
||||
void gui_builder_init(const char *file)
|
||||
{
|
||||
gui_builder = gtk_builder_new_from_file(file);
|
||||
}
|
||||
|
||||
void gui_builder_deinit()
|
||||
{
|
||||
g_object_unref(G_OBJECT(gui_builder));
|
||||
gui_builder = NULL;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_TESTING
|
||||
GtkBuilder *test_get_gui_builder()
|
||||
{
|
||||
return gui_builder;
|
||||
}
|
||||
#endif /* CONFIG_TESTING */
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* Copyright 2016 (c) Anna Schumaker.
|
||||
*/
|
||||
#ifndef OCARINA_GUI_BUILDER_H
|
||||
#define OCARINA_GUI_BUILDER_H
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
/* Called to initialize the GTK builder. */
|
||||
void gui_builder_init(const char *);
|
||||
|
||||
/* Called to deinitialize the GTK builder. */
|
||||
void gui_builder_deinit();
|
||||
|
||||
#ifdef CONFIG_TESTING
|
||||
GtkBuilder *test_get_gui_builder();
|
||||
#endif /* CONFIG_TESTING */
|
||||
#endif /* OCARINA_GUI_BUILDER_H */
|
|
@ -26,7 +26,7 @@ test_o = env.Object("test", "test.c")
|
|||
def UnitTest(test, sources):
|
||||
name = os.path.basename(test)
|
||||
make = env.Program(name, sources + [ test_o ])
|
||||
run = Command("%s.fake" % name, [], "tests/%s" % test)
|
||||
run = Command("%s.fake" % name, [], "tests/%s" % test, ENV = os.environ)
|
||||
Depends(run, make)
|
||||
Alias("tests/%s" % test, run)
|
||||
return run
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
settings
|
||||
builder
|
||||
|
|
|
@ -24,6 +24,7 @@ def GuiTest(name):
|
|||
|
||||
|
||||
res += [ GuiTest("settings") ]
|
||||
res += [ GuiTest("builder") ]
|
||||
|
||||
ignore.close()
|
||||
Return("res")
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright 2016 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <gui/builder.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
static void test_builder()
|
||||
{
|
||||
int argc = 0;
|
||||
|
||||
test_equal((void *)test_get_gui_builder(), NULL);
|
||||
|
||||
gtk_init(&argc, NULL);
|
||||
gui_builder_init("share/ocarina/ocarina6.glade");
|
||||
test_not_equal((void *)test_get_gui_builder(), NULL);
|
||||
|
||||
gui_builder_deinit();
|
||||
test_equal((void *)test_get_gui_builder(), NULL);
|
||||
}
|
||||
|
||||
DECLARE_UNIT_TESTS(
|
||||
UNIT_TEST("GTK Builder", test_builder),
|
||||
);
|
Loading…
Reference in New Issue