g_free(title);
}
+static void
+on_css_changed(GSettings *prefs_settings, char *key, ChimaraPlayer *self)
+{
+ char *user_css;
+ g_settings_get(prefs_settings, "css-file", "ms", &user_css);
+ if(user_css) {
+ if(!chimara_glk_set_css_from_file(CHIMARA_GLK(self->glk), user_css, 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);
+ }
+ g_free(user_css);
+ }
+}
+
static void
chimara_player_dispose(GObject *object)
{
"ignore-errors", TRUE,
/*"interpreter-number", CHIMARA_IF_ZMACHINE_TANDY_COLOR,*/
NULL);
+
+ /* Set the CSS styles for the interpreter */
char *default_css = get_data_file_path("style.css");
if( !chimara_glk_set_css_from_file(CHIMARA_GLK(self->glk), default_css, &error) ) {
error_dialog(GTK_WINDOW(self), error, "Couldn't open default CSS file: ");
}
+ g_free(default_css);
+ on_css_changed(theapp->prefs_settings, "css-file", self);
/* DON'T UNCOMMENT THIS your eyes will burn
but it is a good test of programmatically altering just one style
gtk_builder_connect_signals(builder, self);
g_signal_connect(self->glk, "notify::program-name", G_CALLBACK(change_window_title), self);
g_signal_connect(self->glk, "notify::story-name", G_CALLBACK(change_window_title), self);
+ g_signal_connect(theapp->prefs_settings, "changed::css-file", G_CALLBACK(on_css_changed), self);
g_object_unref(builder);
g_object_unref(uimanager);
NULL));
}
+void
+chimara_player_set_user_css_file(ChimaraPlayer *self, const char *filename)
+{
+ chimara_glk_set_css_to_default(CHIMARA_GLK(self->glk));
+ chimara_glk_set_css_from_file(CHIMARA_GLK(self->glk), filename, NULL);
+}
+
/* GLADE CALLBACKS */
#if 0
gtk_file_chooser_set_filename(blorb_chooser, filename);
g_free(filename);
}
+
g_settings_get(theapp->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(theapp->prefs_settings, "css-file", "ms", NULL);
- // } else {
- // gtk_file_chooser_set_filename(css_chooser, filename);
- // }
- // g_free(filename);
- //}
+ if(filename) {
+ 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(builder, "available_interpreters") );
void
on_css_filechooser_file_set(GtkFileChooserButton *button, ChimaraGlk *glk)
{
- //GError *error = NULL;
- //ChimaraApp *theapp = chimara_app_get();
- //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(theapp->prefs_settings, "css-file", "ms", NULL);
- //} else {
- // g_settings_set(theapp->prefs_settings, "css-file", "ms", filename);
- //}
- //g_free(filename);
+ ChimaraApp *theapp = chimara_app_get();
+ char *filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(button) );
+ g_settings_set(theapp->prefs_settings, "css-file", "ms", filename);
+ g_free(filename);
}
void