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(CXXCOMSTR = "C++ $TARGET")
|
||||||
self.Append(CCCOMSTR = "CC $TARGET")
|
self.Append(CCCOMSTR = "CC $TARGET")
|
||||||
self.Append(LINKCOMSTR = "Linking $TARGET")
|
self.Append(LINKCOMSTR = "Linking $TARGET")
|
||||||
|
self.Append(ENV = { "DISPLAY" : os.environ["DISPLAY"] })
|
||||||
self.Debug = CONFIG_DEBUG
|
self.Debug = CONFIG_DEBUG
|
||||||
self.Version = CONFIG_VERSION
|
self.Version = CONFIG_VERSION
|
||||||
|
|
||||||
|
|
24
gui/builder.c
Normal file
24
gui/builder.c
Normal file
|
@ -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 */
|
17
include/gui/builder.h
Normal file
17
include/gui/builder.h
Normal file
|
@ -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):
|
def UnitTest(test, sources):
|
||||||
name = os.path.basename(test)
|
name = os.path.basename(test)
|
||||||
make = env.Program(name, sources + [ test_o ])
|
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)
|
Depends(run, make)
|
||||||
Alias("tests/%s" % test, run)
|
Alias("tests/%s" % test, run)
|
||||||
return run
|
return run
|
||||||
|
|
1
tests/gui/.gitignore
vendored
1
tests/gui/.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
settings
|
settings
|
||||||
|
builder
|
||||||
|
|
|
@ -24,6 +24,7 @@ def GuiTest(name):
|
||||||
|
|
||||||
|
|
||||||
res += [ GuiTest("settings") ]
|
res += [ GuiTest("settings") ]
|
||||||
|
res += [ GuiTest("builder") ]
|
||||||
|
|
||||||
ignore.close()
|
ignore.close()
|
||||||
Return("res")
|
Return("res")
|
||||||
|
|
23
tests/gui/builder.c
Normal file
23
tests/gui/builder.c
Normal file
|
@ -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
Block a user