int main(int argc, char *argv[]) { GError *error = NULL; gtk_init(&argc, &argv); create_window(); gtk_widget_show_all(window); if(argc < 2) g_error("Must provide a plugin\n"); GFile *plugin_file; if( g_str_has_suffix(argv[1], ".la") ) plugin_file = libname_from_la_file(argv[1]); else plugin_file = g_file_new_for_commandline_arg(argv[1]); chimara_glk_set_resource_load_callback(CHIMARA_GLK(glk), (ChimaraResourceLoadFunc)resource_load, NULL, NULL); if( !chimara_glk_run_file(CHIMARA_GLK(glk), plugin_file, argc - 1, argv + 1, &error) ) g_error("Error starting Glk library: %s\n", error->message); g_object_unref(plugin_file); gtk_main(); chimara_glk_stop(CHIMARA_GLK(glk)); chimara_glk_wait(CHIMARA_GLK(glk)); g_object_unref(glk); return 0; }
int main(int argc, char **argv) { gtk_init(&argc, &argv); GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_set_size_request(window, 800, 500); g_signal_connect(window, "delete_event", G_CALLBACK(on_delete_event), NULL); GtkWidget *hpaned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL); gtk_paned_set_position(GTK_PANED(hpaned), 400); GtkWidget *frotz = chimara_glk_new(); chimara_glk_set_css_from_string(CHIMARA_GLK(frotz), "buffer.normal { font-family: 'Lucida Sans'; font-size: 12; }" "grid.normal { font-family: 'Lucida Console'; font-size: 12; }"); g_signal_connect(frotz, "started", G_CALLBACK(on_started), "Frotz"); g_signal_connect(frotz, "stopped", G_CALLBACK(on_stopped), "Frotz"); GtkWidget *nitfol = chimara_glk_new(); chimara_glk_set_css_from_string(CHIMARA_GLK(frotz), "buffer.normal { font-family: 'Bitstream Charter'; font-size: 12; }" "grid.normal { font-family: 'Luxi Mono'; font-size: 12; }"); g_signal_connect(nitfol, "started", G_CALLBACK(on_started), "Nitfol"); g_signal_connect(nitfol, "stopped", G_CALLBACK(on_stopped), "Nitfol"); gtk_paned_pack1(GTK_PANED(hpaned), frotz, TRUE, TRUE); gtk_paned_pack2(GTK_PANED(hpaned), nitfol, TRUE, TRUE); gtk_container_add(GTK_CONTAINER(window), hpaned); gtk_widget_show_all(window); if(!chimara_glk_run(CHIMARA_GLK(frotz), "../interpreters/frotz/.libs/frotz.so", argc, argv, NULL)) return 1; if(!chimara_glk_run(CHIMARA_GLK(nitfol), "../interpreters/nitfol/.libs/nitfol.so", argc, argv, NULL)) return 1; gtk_main(); chimara_glk_stop(CHIMARA_GLK(frotz)); chimara_glk_stop(CHIMARA_GLK(nitfol)); return 0; }
int main(int argc, char *argv[]) { #ifdef ENABLE_NLS bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); #endif gtk_init(&argc, &argv); /* Create configuration dir ~/.chimara */ gchar *configdir = g_build_filename(g_get_home_dir(), ".chimara", NULL); if(!g_file_test(configdir, G_FILE_TEST_IS_DIR) && g_mkdir(configdir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) g_error("Cannot create configuration directory ~/.chimara"); g_free(configdir); /* Initialize settings file; it can be overridden by a "chimara-config" file in the current directory */ gchar *keyfile; if(g_file_test("chimara-config", G_FILE_TEST_IS_REGULAR)) keyfile = g_strdup("chimara-config"); else keyfile = g_build_filename(g_get_home_dir(), ".chimara", "config", NULL); GSettingsBackend *backend = g_keyfile_settings_backend_new(keyfile, "/org/chimara-if/player/", NULL); prefs_settings = g_settings_new_with_backend("org.chimara-if.player.preferences", backend); state_settings = g_settings_new_with_backend("org.chimara-if.player.state", backend); g_free(keyfile); app = gtk_application_new("org.chimara-if.player", G_APPLICATION_HANDLES_OPEN); g_signal_connect(app, "activate", G_CALLBACK(on_activate), NULL); g_signal_connect(app, "open", G_CALLBACK(on_open), NULL); if( !create_window() ) { error_dialog(NULL, NULL, "Error while building interface."); return 1; } int status = g_application_run(G_APPLICATION(app), argc, argv); g_object_unref(app); chimara_glk_stop(CHIMARA_GLK(glk)); chimara_glk_wait(CHIMARA_GLK(glk)); g_object_unref( G_OBJECT(builder) ); return status; }
int main(int argc, char *argv[]) { GError *error = NULL; #ifdef ENABLE_NLS bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); #endif gdk_threads_init(); gtk_init(&argc, &argv); /* Create configuration dir ~/.chimara */ gchar *configdir = g_build_filename(g_get_home_dir(), ".chimara", NULL); if(!g_file_test(configdir, G_FILE_TEST_IS_DIR) && g_mkdir(configdir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) g_error(_("Cannot create configuration directory ~/.chimara")); g_free(configdir); /* Initialize settings file; it can be overridden by a "chimara-config" file in the current directory */ gchar *keyfile; if(g_file_test("chimara-config", G_FILE_TEST_IS_REGULAR)) keyfile = g_strdup("chimara-config"); else keyfile = g_build_filename(g_get_home_dir(), ".chimara", "config", NULL); GSettingsBackend *backend = g_keyfile_settings_backend_new(keyfile, "/org/chimara-if/player/", NULL); prefs_settings = g_settings_new_with_backend("org.chimara-if.player.preferences", backend); state_settings = g_settings_new_with_backend("org.chimara-if.player.state", backend); g_free(keyfile); if( !create_window() ) { error_dialog(NULL, NULL, "Error while building interface."); return 1; } gtk_widget_show_all(window); g_object_unref( G_OBJECT(uimanager) ); if(argc == 3) { g_object_set(glk, "graphics-file", argv[2], NULL); } if(argc >= 2) { if( !chimara_if_run_game(CHIMARA_IF(glk), argv[1], &error) ) { error_dialog(GTK_WINDOW(window), error, "Error starting Glk library: "); return 1; } } gdk_threads_enter(); gtk_main(); gdk_threads_leave(); chimara_glk_stop(CHIMARA_GLK(glk)); chimara_glk_wait(CHIMARA_GLK(glk)); g_object_unref( G_OBJECT(builder) ); return 0; }