GTK: made gvbam installable again

This commit is contained in:
bgk 2008-10-28 09:44:04 +00:00
parent a24c229a28
commit 3b0d12d51f
6 changed files with 19 additions and 10 deletions

View File

@ -88,13 +88,7 @@ int main(int argc, char * argv[])
Gtk::Window::set_default_icon_name("vbam"); Gtk::Window::set_default_icon_name("vbam");
// Use the glade file from the source folder if it exists std::string sGladeFile = VBA::Window::sGetUiFilePath("vbam.glade");
// 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";
}
Glib::RefPtr<Xml> poXml; Glib::RefPtr<Xml> poXml;
try try

View File

@ -43,7 +43,7 @@
</row> </row>
</data> </data>
</object> </object>
<object class="GtkDialog" id="dialog1"> <object class="GtkDialog" id="DisplayConfigDialog">
<property name="border_width">5</property> <property name="border_width">5</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property> <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>

View File

@ -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 } // VBA namespace

View File

@ -45,6 +45,7 @@ public:
virtual ~Window(); virtual ~Window();
inline static Window * poGetInstance() { return m_poInstance; } inline static Window * poGetInstance() { return m_poInstance; }
static std::string sGetUiFilePath(const std::string &_sFileName);
enum ECartridge enum ECartridge
{ {

View File

@ -554,10 +554,11 @@ void Window::vOnJoypadConfigure()
void Window::vOnDisplayConfigure() void Window::vOnDisplayConfigure()
{ {
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file("src/gtk/ui/display.ui"); std::string sUiFile = sGetUiFilePath("display.ui");
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
DisplayConfigDialog * poDialog = 0; DisplayConfigDialog * poDialog = 0;
poBuilder->get_widget_derived("dialog1", poDialog); poBuilder->get_widget_derived("DisplayConfigDialog", poDialog);
poDialog->vSetConfig(m_poDisplayConfig, this); poDialog->vSetConfig(m_poDisplayConfig, this);
poDialog->set_transient_for(*this); poDialog->set_transient_for(*this);
poDialog->run(); poDialog->run();