From: P. F. Chimento Date: Sun, 13 Mar 2011 19:36:56 +0000 (+0100) Subject: Set CSS file from preferences dialog X-Git-Tag: v0.9~114 X-Git-Url: https://git.stderr.nl/gitweb?p=projects%2Fchimara%2Fchimara.git;a=commitdiff_plain;h=36d2b1cc41af8ef5d9e67785f9601f11242196ca Set CSS file from preferences dialog Now you can set a custom CSS file from the preferences dialog and it will be remembered across runs of the program. --- diff --git a/player/chimara.ui b/player/chimara.ui index d8c2ea8..0a80104 100644 --- a/player/chimara.ui +++ b/player/chimara.ui @@ -394,6 +394,7 @@ Philip Chimento True False Select A CSS File + 1 diff --git a/player/org.chimara-if.gschema.xml b/player/org.chimara-if.gschema.xml index 6c0e4d1..83c521e 100644 --- a/player/org.chimara-if.gschema.xml +++ b/player/org.chimara-if.gschema.xml @@ -18,6 +18,14 @@ + + nothing + CSS style file + + The CSS file containing the current theme for the text in the games. + + + nothing Resource path diff --git a/player/preferences.c b/player/preferences.c index ad77ee6..88e88ff 100644 --- a/player/preferences.c +++ b/player/preferences.c @@ -168,12 +168,24 @@ preferences_create(ChimaraGlk *glk) GObject *flep = G_OBJECT( load_object("flep") ); g_settings_bind(prefs_settings, "flep", flep, "active", G_SETTINGS_BIND_DEFAULT); GtkFileChooser *blorb_chooser = GTK_FILE_CHOOSER( load_object("blorb_file_chooser") ); + GtkFileChooser *css_chooser = GTK_FILE_CHOOSER( load_object("css-filechooser") ); char *filename; g_settings_get(prefs_settings, "resource-path", "ms", &filename); if(filename) { gtk_file_chooser_set_filename(blorb_chooser, filename); g_free(filename); } + g_settings_get(prefs_settings, "css-file", "ms", &filename); + if(filename) { + if(!chimara_glk_set_css_from_file(glk, filename, NULL)) { + /* If the setting didn't point to a CSS file, fail silently and + null the setting */ + g_settings_set(prefs_settings, "css-file", "ms", NULL); + } else { + gtk_file_chooser_set_filename(css_chooser, filename); + } + g_free(filename); + } /* Populate the list of available interpreters */ GtkListStore *interp_list = GTK_LIST_STORE( load_object("available_interpreters") ); @@ -324,6 +336,21 @@ on_font_set(GtkFontButton *button, ChimaraGlk *glk) chimara_glk_update_style(glk); } +void +on_css_filechooser_file_set(GtkFileChooserButton *button, ChimaraGlk *glk) +{ + GError *error = NULL; + extern GSettings *prefs_settings; + char *filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(button) ); + if(!chimara_glk_set_css_from_file(glk, filename, &error)) { + error_dialog(NULL, error, "There was a problem reading the CSS file: "); + g_settings_set(prefs_settings, "css-file", "ms", NULL); + } else { + g_settings_set(prefs_settings, "css-file", "ms", filename); + } + g_free(filename); +} + void on_resource_file_set(GtkFileChooserButton *button, ChimaraGlk *glk) {