Check data dirs for ui file.
git-svn-id: file:///home/vcs/svn/jsweeper/trunk@36 6611ac79-6612-48ef-a1e9-b906f853523emaster
parent
4e609827b4
commit
14608d8065
31
src/gui.cpp
31
src/gui.cpp
|
@ -1,3 +1,5 @@
|
|||
#include <sys/stat.h>
|
||||
#include <iostream>
|
||||
#include "config.h"
|
||||
#include "jack.h"
|
||||
#include "portmanager.h"
|
||||
|
@ -5,6 +7,8 @@
|
|||
#include "session_gui.h"
|
||||
#include "preferences_gui.h"
|
||||
|
||||
#define PACKAGE_NAME "jsweeper"
|
||||
|
||||
Glib::RefPtr<Gtk::Builder> g_builder;
|
||||
|
||||
Gui::Gui(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &builder)
|
||||
|
@ -107,10 +111,35 @@ void Gui::SetPortTypeSeparation()
|
|||
}
|
||||
}
|
||||
|
||||
static void TryLoad(const char *filename)
|
||||
{
|
||||
struct stat out;
|
||||
if (stat(filename, &out) == 0) {
|
||||
g_builder = Gtk::Builder::create_from_file(filename);
|
||||
}
|
||||
}
|
||||
|
||||
Gui *Gui::Open()
|
||||
{
|
||||
if (g_builder == NULL) {
|
||||
g_builder = Gtk::Builder::create_from_file("jsweeper.ui");
|
||||
const char * const *dirs = g_get_system_data_dirs();
|
||||
|
||||
while (*dirs != NULL && g_builder == NULL) {
|
||||
std::string path = *dirs;
|
||||
path = Glib::build_filename(path, PACKAGE_NAME);
|
||||
path = Glib::build_filename(path, "jsweeper.ui");
|
||||
|
||||
TryLoad(path.c_str());
|
||||
|
||||
dirs++;
|
||||
}
|
||||
|
||||
if (g_builder == NULL) TryLoad("jsweeper.ui");
|
||||
|
||||
if (g_builder == NULL) {
|
||||
std::cerr << "Failed to load jsweeper.ui!" << std::endl;
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
Gui *window = NULL;
|
||||
|
|
Loading…
Reference in New Issue