diff --git a/desmume/src/gtk-glade/main.c b/desmume/src/gtk-glade/main.c index 63fc18052..96be981ab 100755 --- a/desmume/src/gtk-glade/main.c +++ b/desmume/src/gtk-glade/main.c @@ -59,24 +59,29 @@ void notify_Tools() { } /* Return the glade directory. */ -gchar * get_ui_file (const char *filename) +gchar * get_ui_file (const char *filename, const char * prog) { - char *path; + char *path, *path2; + + /* EHhhhh ! building dir ?*/ + path = g_path_get_dirname(prog); + path2 = g_build_filename (path, "glade", filename, NULL); + g_free (path); + if (g_file_test (path2, G_FILE_TEST_IS_REGULAR)) return path2; + g_free (path2); - /* looking in uninstalled dir first */ - path = g_build_filename (GLADEUI_UNINSTALLED_DIR, filename, NULL); - if (g_file_test (path, G_FILE_TEST_IS_REGULAR)) - return path; - g_free (path); - - /* looking in installed dir */ - path = g_build_filename (DATADIR, filename, NULL); - if (g_file_test (path, G_FILE_TEST_IS_REGULAR)) - return path; - g_free (path); - - /* not found */ - return NULL; + /* looking in uninstalled dir first */ + path = g_build_filename (GLADEUI_UNINSTALLED_DIR, filename, NULL); + if (g_file_test (path, G_FILE_TEST_IS_REGULAR)) return path; + g_free (path); + + /* looking in installed dir */ + path = g_build_filename (DATADIR, filename, NULL); + if (g_file_test (path, G_FILE_TEST_IS_REGULAR)) return path; + g_free (path); + + /* not found */ + return NULL; } @@ -246,8 +251,8 @@ int main(int argc, char *argv[]) { Read_ConfigFile(); /* load the interface */ - xml = glade_xml_new(get_ui_file("DeSmuMe.glade"), NULL, NULL); - xml_tools = glade_xml_new(get_ui_file("DeSmuMe_Dtools.glade"), NULL, NULL); + xml = glade_xml_new(get_ui_file("DeSmuMe.glade",argv[0]), NULL, NULL); + xml_tools = glade_xml_new(get_ui_file("DeSmuMe_Dtools.glade",argv[0]), NULL, NULL); pWindow = glade_xml_get_widget(xml, "wMainW"); pDrawingArea = glade_xml_get_widget(xml, "wDraw_Main"); pDrawingArea2 = glade_xml_get_widget(xml, "wDraw_Sub");