From 3b0d12d51f2b0ac3393002f4fa53361055701847 Mon Sep 17 00:00:00 2001 From: bgk Date: Tue, 28 Oct 2008 09:44:04 +0000 Subject: [PATCH] GTK: made gvbam installable again --- src/gtk/main.cpp | 8 +------- src/gtk/ui/display.ui | 2 +- src/gtk/{vba.glade => ui/vbam.glade} | 0 src/gtk/window.cpp | 13 +++++++++++++ src/gtk/window.h | 1 + src/gtk/windowcallbacks.cpp | 5 +++-- 6 files changed, 19 insertions(+), 10 deletions(-) rename src/gtk/{vba.glade => ui/vbam.glade} (100%) diff --git a/src/gtk/main.cpp b/src/gtk/main.cpp index 901686f9..d1f469db 100644 --- a/src/gtk/main.cpp +++ b/src/gtk/main.cpp @@ -88,13 +88,7 @@ int main(int argc, char * argv[]) Gtk::Window::set_default_icon_name("vbam"); - // Use the glade file from the source folder if it exists - // to make gvbam runnable without installation - std::string sGladeFile = "src/gtk/vba.glade"; - if (!Glib::file_test(sGladeFile, Glib::FILE_TEST_EXISTS)) - { - sGladeFile = PKGDATADIR "/vba.glade"; - } + std::string sGladeFile = VBA::Window::sGetUiFilePath("vbam.glade"); Glib::RefPtr poXml; try diff --git a/src/gtk/ui/display.ui b/src/gtk/ui/display.ui index 76caecf0..24c67fd3 100644 --- a/src/gtk/ui/display.ui +++ b/src/gtk/ui/display.ui @@ -43,7 +43,7 @@ - + 5 GTK_WIN_POS_CENTER_ON_PARENT GDK_WINDOW_TYPE_HINT_DIALOG diff --git a/src/gtk/vba.glade b/src/gtk/ui/vbam.glade similarity index 100% rename from src/gtk/vba.glade rename to src/gtk/ui/vbam.glade diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index ee7ecf3c..efc6f06e 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1503,4 +1503,17 @@ void Window::vSDLPollEvents() } } +std::string Window::sGetUiFilePath(const std::string &_sFileName) +{ + // Use the ui file from the source folder if it exists + // to make gvbam runnable without installation + std::string sUiFile = "src/gtk/ui/" + _sFileName; + if (!Glib::file_test(sUiFile, Glib::FILE_TEST_EXISTS)) + { + sUiFile = PKGDATADIR "/ui/" + _sFileName; + } + + return sUiFile; +} + } // VBA namespace diff --git a/src/gtk/window.h b/src/gtk/window.h index 411b56d9..32bfa3e0 100644 --- a/src/gtk/window.h +++ b/src/gtk/window.h @@ -45,6 +45,7 @@ public: virtual ~Window(); inline static Window * poGetInstance() { return m_poInstance; } + static std::string sGetUiFilePath(const std::string &_sFileName); enum ECartridge { diff --git a/src/gtk/windowcallbacks.cpp b/src/gtk/windowcallbacks.cpp index 45fdeed3..5561c4b5 100644 --- a/src/gtk/windowcallbacks.cpp +++ b/src/gtk/windowcallbacks.cpp @@ -554,10 +554,11 @@ void Window::vOnJoypadConfigure() void Window::vOnDisplayConfigure() { - Glib::RefPtr poBuilder = Gtk::Builder::create_from_file("src/gtk/ui/display.ui"); + std::string sUiFile = sGetUiFilePath("display.ui"); + Glib::RefPtr poBuilder = Gtk::Builder::create_from_file(sUiFile); DisplayConfigDialog * poDialog = 0; - poBuilder->get_widget_derived("dialog1", poDialog); + poBuilder->get_widget_derived("DisplayConfigDialog", poDialog); poDialog->vSetConfig(m_poDisplayConfig, this); poDialog->set_transient_for(*this); poDialog->run();