diff --git a/Sconstruct b/Sconstruct index d65792b6..dbdf3117 100644 --- a/Sconstruct +++ b/Sconstruct @@ -29,14 +29,13 @@ Export("env", "test_env") include = SConscript("include/Sconscript") core = SConscript("core/Sconscript") -lib = SConscript("lib/Sconscript") gui = SConscript("gui/Sconscript") if os.path.isdir("tests"): tests = SConscript("tests/Sconscript") -ocarina = env.Program("bin/ocarina", core + lib + gui) +ocarina = env.Program("bin/ocarina", core + gui) Default(ocarina) Clean(ocarina, "bin/") diff --git a/gui/Sconscript b/gui/Sconscript index dbe37649..3cd9e189 100644 --- a/gui/Sconscript +++ b/gui/Sconscript @@ -1,6 +1,7 @@ #!/usr/bin/python Import("env") +env.UsePackage("gtkmm-3.0") env.UsePackage("gstreamer-1.0") res = Glob("*.cpp") diff --git a/gui/collection.cpp b/gui/collection.cpp index 1233bf9f..8a5ddeba 100644 --- a/gui/collection.cpp +++ b/gui/collection.cpp @@ -5,7 +5,6 @@ #include #include #include -#include class CollectionTab : public Tab { diff --git a/gui/main.cpp b/gui/main.cpp index 4a3728a0..6a5f15ef 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -3,25 +3,45 @@ */ #include #include -#include #include #include +static std::string share_dir = ""; + namespace gui { Glib::RefPtr __O_BUILDER; + + const std::string share_file(const std::string &f) + { + return share_dir + f; + } } +static void setup_share(const std::string &path) +{ + char buf[1024]; + ssize_t len = readlink("/proc/self/exe", buf, sizeof(buf) - 1); + + if (len == -1) + return; + buf[len] = '\0'; + + share_dir = std::string(buf); + share_dir = share_dir.substr(0, share_dir.size() - 11); + share_dir = share_dir + "share/ocarina/"; +} + Gtk::Window *ocarina_init(int *argc, char ***argv) { Gtk::Window *window; - lib :: init(argc, argv); + setup_share((*argv)[0]); gui :: __O_BUILDER = Gtk::Builder::create(); - if (!gui :: __O_BUILDER->add_from_file(lib :: share_file("ocarina6.glade"))) + if (!gui::__O_BUILDER->add_from_file(gui::share_file("ocarina6.glade"))) exit(1); gst :: init(argc, argv); diff --git a/gui/window.cpp b/gui/window.cpp index 0cf6566d..6614eb4b 100644 --- a/gui/window.cpp +++ b/gui/window.cpp @@ -62,7 +62,7 @@ Gtk::Window *window_init() window->set_can_focus(); window->set_title(appname + get_version()); - window->set_icon_from_file(lib :: share_file("ocarina.png")); + window->set_icon_from_file(gui :: share_file("ocarina.png")); window->signal_key_press_event().connect(sigc::ptr_fun(on_window_key_pressed)); window->signal_key_release_event().connect(sigc::ptr_fun(on_window_key_released)); diff --git a/include/gui/ocarina.h b/include/gui/ocarina.h index 885d186f..b7b0b36f 100644 --- a/include/gui/ocarina.h +++ b/include/gui/ocarina.h @@ -5,7 +5,7 @@ #define OCARINA_H #include -#include +#include /* main.cpp */ @@ -13,6 +13,8 @@ namespace gui { extern Glib::RefPtr __O_BUILDER; + const std::string share_file(const std::string &); + template static inline T *get_widget(const std::string &name) { diff --git a/include/gui/tabs.h b/include/gui/tabs.h index a0db1069..5b08bfb4 100644 --- a/include/gui/tabs.h +++ b/include/gui/tabs.h @@ -4,7 +4,6 @@ #ifndef OCARINA_TABS_H #define OCARINA_TABS_H -#include #include #include #include diff --git a/include/lib/lib.h b/include/lib/lib.h deleted file mode 100644 index c1f813ad..00000000 --- a/include/lib/lib.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2014 (c) Anna Schumaker. - */ -#ifndef OCARINA_LIB_LIB_H -#define OCARINA_LIB_LIB_H - -#include -#include - -namespace lib -{ - - void init(int *, char ***); - const std::string share_file(const std::string &); - -} - -#endif /* OCARINA_LIB_LIB_H */ diff --git a/lib/Sconscript b/lib/Sconscript deleted file mode 100644 index d7d8a604..00000000 --- a/lib/Sconscript +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/python -Import("env") -env.UsePackage("gtkmm-3.0") -res = Glob("*.cpp") -Return("res") diff --git a/lib/lib.cpp b/lib/lib.cpp deleted file mode 100644 index 54d2110b..00000000 --- a/lib/lib.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2014 (c) Anna Schumaker. - */ -#include -#include -#include - -static std::string share_dir = ""; - -static void setup_share(const std::string &path) -{ - char buf[1024]; - ssize_t len = readlink("/proc/self/exe", buf, sizeof(buf) - 1); - - if (len == -1) - return; - buf[len] = '\0'; - - share_dir = std::string(buf); - share_dir = share_dir.substr(0, share_dir.size() - 11); - share_dir = share_dir + "share/ocarina/"; -} - -void lib :: init(int *argc, char ***argv) -{ - setup_share((*argv)[0]); -} - -const std::string lib :: share_file(const std::string &f) -{ - return share_dir + f; -} diff --git a/tests/Sconscript b/tests/Sconscript index dd8f78f8..75587452 100644 --- a/tests/Sconscript +++ b/tests/Sconscript @@ -56,6 +56,5 @@ add_test(test, "") SConscript("core/Sconscript") -#SConscript("lib/Sconscript") Return("res") diff --git a/tests/lib/.gitignore b/tests/lib/.gitignore deleted file mode 100644 index bd99e9a8..00000000 --- a/tests/lib/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -lib -colmgr -model -tags/ diff --git a/tests/lib/Sconscript b/tests/lib/Sconscript deleted file mode 100644 index bd48e220..00000000 --- a/tests/lib/Sconscript +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/python -import os -Import("test_env", "generic_test") - -objs = [] -core = [] - -for f in Glob("../../core/*.cpp"): - f = str(f) - core += [ test_env.Object("%s-core" % os.path.basename(f), f) ] -for f in Glob("../../core/tags/*.cpp"): - f = str(f) - core += [ test_env.Object("tags/%s-core" % os.path.basename(f), f) ] - -def test(name): - global core, objs - objs = generic_test(name, "lib", objs, core) - - -test( "lib" ) - -test_env.UsePackage("gtkmm-3.0") -test( "model" ) diff --git a/tests/lib/lib.cpp b/tests/lib/lib.cpp deleted file mode 100644 index f22bf8b2..00000000 --- a/tests/lib/lib.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2014 (c) Anna Schumaker. - */ -#include -#include -#include -#include - -static void test_init(int *argc, char ***argv) -{ - Gtk::Window *window; - - test_equal(deck :: get_queues().size(), (size_t)0); - - test :: cp_data_dir(); - lib :: init(argc, argv, "ocarina6.glade"); - - test_equal(deck :: get_queues().size(), (size_t)2); - test_equal(lib :: share_file("saria"), (std::string)"./share/ocarina/saria"); - - window = lib :: get_widget("o_window"); - test_not_equal(window, (Gtk::Window *)NULL); -} - -int main(int argc, char **argv) -{ - Gtk::Main ocarina(&argc, &argv); - run_test("Lib Test", test_init, &argc, &argv); - return 0; -} diff --git a/tests/lib/model.cpp b/tests/lib/model.cpp deleted file mode 100644 index b7c697a3..00000000 --- a/tests/lib/model.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2014 (c) Anna Schumaker. - */ -#include -#include -#include -#include - -static void test_qmodel() -{ - QueueModel model(library :: get_queue()); - Gtk::TreePath path; - Gtk::TreeIter iter; - Gtk::TreeRow row; - bool valid; - - test_equal(model.get_flags(), Gtk::TREE_MODEL_LIST_ONLY); - test_equal(model.get_n_columns(), 10); - - for (unsigned int i = 0; i < 10; i++) { - if ((i == 0) || (i == 5) || (i == 7)) - test_equal(model.get_column_type(i), G_TYPE_UINT); - else - test_equal(model.get_column_type(i), G_TYPE_STRING); - } - - path = Gtk::TreePath("42"); - iter = model.get_iter(path); - valid = (iter ? true : false); - test_equal(valid, false); - - path = Gtk::TreePath("19"); - iter = model.get_iter(path); - valid = (iter ? true : false); - test_equal(valid, true); - - test_equal(model.get_path(iter), path); - test_equal(model.get_iter(path), iter); - - test_equal(model.iter_to_id(iter), (unsigned)19); - test_equal(model.path_to_id(path), (unsigned)15); - - valid = (++iter ? true : false); - test_equal(valid, false); -} - -int main(int argc, char **argv) -{ - Gtk::Main ocarina(&argc, &argv); - test :: cp_data_dir(); - lib :: init(&argc, &argv, "ocarina6.glade"); - - run_test("QueueModel Test", test_qmodel); - return 0; -}