X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=player%2Fmain.c;h=bd007b4ee128b0a7966822a37c547ca98c7b7c85;hb=02c13aec1755ce0397011d502a92a80d1f69ea43;hp=70bad3b3941ae4062058548fec4631e0a942cccc;hpb=39b9e14c0e3c11a4b6df8c22ac4a554e2aae9720;p=projects%2Fchimara%2Fchimara.git diff --git a/player/main.c b/player/main.c index 70bad3b..bd007b4 100644 --- a/player/main.c +++ b/player/main.c @@ -38,6 +38,7 @@ #include #include +#include #include /* Use a custom GSettings backend for our preferences file */ @@ -117,7 +118,13 @@ create_window(void) aboutwindow = GTK_WIDGET(load_object("aboutwindow")); prefswindow = GTK_WIDGET(load_object("prefswindow")); GtkActionGroup *actiongroup = GTK_ACTION_GROUP(load_object("actiongroup")); + + /* Set the default value of the "View/Toolbar" menu item upon creation of a + new window to the "show-toolbar-default" setting, but bind the setting + one-way only - we don't want toolbars to disappear suddenly */ GtkToggleAction *toolbar_action = GTK_TOGGLE_ACTION(load_object("toolbar")); + gtk_toggle_action_set_active(toolbar_action, g_settings_get_boolean(state_settings, "show-toolbar-default")); + g_settings_bind(state_settings, "show-toolbar-default", toolbar_action, "active", G_SETTINGS_BIND_SET); const gchar **ptr; GtkRecentFilter *filter = gtk_recent_filter_new(); @@ -163,24 +170,6 @@ create_window(void) } #endif /* DEBUG */ } - chimara_if_set_preferred_interpreter(CHIMARA_IF(glk), - CHIMARA_IF_FORMAT_Z5, - CHIMARA_IF_INTERPRETER_FROTZ); - chimara_if_set_preferred_interpreter(CHIMARA_IF(glk), - CHIMARA_IF_FORMAT_Z6, - CHIMARA_IF_INTERPRETER_NITFOL); - chimara_if_set_preferred_interpreter(CHIMARA_IF(glk), - CHIMARA_IF_FORMAT_Z8, - CHIMARA_IF_INTERPRETER_FROTZ); - chimara_if_set_preferred_interpreter(CHIMARA_IF(glk), - CHIMARA_IF_FORMAT_Z_BLORB, - CHIMARA_IF_INTERPRETER_FROTZ); - chimara_if_set_preferred_interpreter(CHIMARA_IF(glk), - CHIMARA_IF_FORMAT_GLULX, - CHIMARA_IF_INTERPRETER_GLULXE); - chimara_if_set_preferred_interpreter(CHIMARA_IF(glk), - CHIMARA_IF_FORMAT_GLULX_BLORB, - CHIMARA_IF_INTERPRETER_GLULXE); /* DON'T UNCOMMENT THIS your eyes will burn but it is a good test of programmatically altering just one style @@ -203,6 +192,10 @@ create_window(void) else gtk_widget_hide(toolbar); + /* Connect the accelerators */ + GtkAccelGroup *accels = gtk_ui_manager_get_accel_group(uimanager); + gtk_window_add_accel_group(GTK_WINDOW(window), accels); + gtk_box_pack_end(vbox, glk, TRUE, TRUE, 0); gtk_box_pack_start(vbox, menubar, FALSE, FALSE, 0); gtk_box_pack_start(vbox, toolbar, FALSE, FALSE, 0); @@ -231,11 +224,24 @@ main(int argc, char *argv[]) gdk_threads_init(); gtk_init(&argc, &argv); - /* Initialize settings file */ - gchar *keyfile = g_build_filename(g_get_home_dir(), ".chimara", NULL); + /* 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); create_window(); gtk_widget_show_all(window);