X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=player%2Fpreferences.c;h=ef8b67f262b037809bc0a52da19a165001adb86e;hb=fd477d5430c84dd4bd9b099bb90acfa554a54635;hp=b7cc3adf678e6600f5d344bdd756b183f0031f0f;hpb=b397495e945570aaacee0eb8fa25704d03761401;p=projects%2Fchimara%2Fchimara.git diff --git a/player/preferences.c b/player/preferences.c index b7cc3ad..ef8b67f 100644 --- a/player/preferences.c +++ b/player/preferences.c @@ -86,6 +86,30 @@ preferences_create(ChimaraGlk *glk) gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); g_signal_connect(selection, "changed", G_CALLBACK(style_tree_select_callback), glk); + + /* Bind the preferences to the entries in the preferences file */ + extern GSettings *prefs_settings; + 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") ); + char *filename; + g_settings_get(prefs_settings, "resource-path", "ms", &filename); + if(filename) { + gtk_file_chooser_set_filename(blorb_chooser, filename); + g_free(filename); + } + + /* Initialize the list of preferred interpreters */ + GtkListStore *interp_list = GTK_LIST_STORE( load_object("interpreters") ); + GVariantIter *iter; + char *format, *plugin; + g_settings_get(prefs_settings, "preferred-interpreters", "a{ss}", &iter); + while(g_variant_iter_loop(iter, "{ss}", &format, &plugin)) { + GtkTreeIter tree_iter; + gtk_list_store_append(interp_list, &tree_iter); + gtk_list_store_set(interp_list, &tree_iter, 0, format, 1, plugin, -1); + } + g_variant_iter_free(iter); } static void @@ -111,9 +135,9 @@ style_tree_select_callback(GtkTreeSelection *selection, ChimaraGlk *glk) } void -on_toggle_left(GtkToggleAction *action, ChimaraGlk *glk) { +on_toggle_left(GtkToggleToolButton *button, ChimaraGlk *glk) { /* No nothing if the button is deactivated */ - if( !gtk_toggle_action_get_active(action) ) + if( !gtk_toggle_tool_button_get_active(button) ) return; /* Untoggle other alignment options */ @@ -129,8 +153,8 @@ on_toggle_left(GtkToggleAction *action, ChimaraGlk *glk) { } void -on_toggle_center(GtkToggleAction *action, ChimaraGlk *glk) { - if( !gtk_toggle_action_get_active(action) ) +on_toggle_center(GtkToggleToolButton *button, ChimaraGlk *glk) { + if( !gtk_toggle_tool_button_get_active(button) ) return; /* Untoggle other alignment options */ @@ -146,8 +170,8 @@ on_toggle_center(GtkToggleAction *action, ChimaraGlk *glk) { } void -on_toggle_right(GtkToggleAction *action, ChimaraGlk *glk) { - if( !gtk_toggle_action_get_active(action) ) +on_toggle_right(GtkToggleToolButton *button, ChimaraGlk *glk) { + if( !gtk_toggle_tool_button_get_active(button) ) return; /* Untoggle other alignment options */ @@ -163,8 +187,8 @@ on_toggle_right(GtkToggleAction *action, ChimaraGlk *glk) { } void -on_toggle_justify(GtkToggleAction *action, ChimaraGlk *glk) { - if( !gtk_toggle_action_get_active(action) ) +on_toggle_justify(GtkToggleToolButton *button, ChimaraGlk *glk) { + if( !gtk_toggle_tool_button_get_active(button) ) return; /* Untoggle other alignment options */ @@ -180,8 +204,8 @@ on_toggle_justify(GtkToggleAction *action, ChimaraGlk *glk) { } void -on_toggle_bold(GtkToggleAction *action, ChimaraGlk *glk) { - if( gtk_toggle_action_get_active(action) ) +on_toggle_bold(GtkToggleToolButton *button, ChimaraGlk *glk) { + if( gtk_toggle_tool_button_get_active(button) ) g_object_set(current_tag, "weight", PANGO_WEIGHT_BOLD, "weight-set", TRUE, NULL); else g_object_set(current_tag, "weight", PANGO_WEIGHT_NORMAL, "weight-set", TRUE, NULL); @@ -190,8 +214,8 @@ on_toggle_bold(GtkToggleAction *action, ChimaraGlk *glk) { } void -on_toggle_italic(GtkToggleAction *action, ChimaraGlk *glk) { - if( gtk_toggle_action_get_active(action) ) +on_toggle_italic(GtkToggleToolButton *button, ChimaraGlk *glk) { + if( gtk_toggle_tool_button_get_active(button) ) g_object_set(current_tag, "style", PANGO_STYLE_ITALIC, "style-set", TRUE, NULL); else g_object_set(current_tag, "style", PANGO_STYLE_NORMAL, "style-set", TRUE, NULL); @@ -200,8 +224,8 @@ on_toggle_italic(GtkToggleAction *action, ChimaraGlk *glk) { } void -on_toggle_underline(GtkToggleAction *action, ChimaraGlk *glk) { - if( gtk_toggle_action_get_active(action) ) +on_toggle_underline(GtkToggleToolButton *button, ChimaraGlk *glk) { + if( gtk_toggle_tool_button_get_active(button) ) g_object_set(current_tag, "underline", PANGO_UNDERLINE_SINGLE, "underline-set", TRUE, NULL); else g_object_set(current_tag, "underline", PANGO_UNDERLINE_NONE, "underline-set", TRUE, NULL); @@ -235,3 +259,12 @@ on_font_set(GtkFontButton *button, ChimaraGlk *glk) g_object_set(current_tag, "font-desc", font_description, NULL); chimara_glk_update_style(glk); } + +void +on_resource_file_set(GtkFileChooserButton *button, ChimaraGlk *glk) +{ + extern GSettings *prefs_settings; + char *filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(button) ); + g_settings_set(prefs_settings, "resource-path", "ms", filename); + g_free(filename); +}