Пример #1
0
void
spell_language_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer user_data)
{
#ifdef HAVE_GTKSPELL
	Ebook *ebook;
	GConfValue *value;
	GtkSpell *spell;
	const gchar *gconf_lang;
	gchar *lang;
	GtkWidget * window, * G_GNUC_UNUSED spell_check;
	GtkTextView * text_view;
	gboolean spellcheck_wanted;

	g_return_if_fail (user_data);

	ebook = (Ebook *) user_data;
	value = gconf_entry_get_value (entry);
	gconf_lang = gconf_value_get_string (value);
	window = GTK_WIDGET(gtk_builder_get_object (ebook->builder, "gpdfwindow"));
	spell_check = GTK_WIDGET(gtk_builder_get_object (ebook->builder, "spellcheckmenuitem"));
	text_view = GTK_TEXT_VIEW(gtk_builder_get_object (ebook->builder, "textview"));

	if (*gconf_lang == '\0' || gconf_lang == NULL)
		lang = NULL;
	else
		lang = g_strdup (gconf_lang);

	if (window)
	{
		spellcheck_wanted = gconf_client_get_bool (ebook->client, ebook->spell_check.key, NULL);
		spell = gtkspell_get_from_text_view (text_view);
		if (spellcheck_wanted)
		{
			if (spell && lang)
				/* Only if we have both spell and lang non-null we can use _set_language() */
				gtkspell_set_language (spell, lang, NULL);
			else
			{
				/* We need to create a new spell widget if we want to use lang == NULL (use default lang)
				 * or if the spell isn't initialized */
				if (spell)
					gtkspell_detach (spell);
				spell = gtkspell_new_attach (text_view, lang, NULL);
			}
			gtkspell_recheck_all (spell);
		}
	}
	spell_language_select_menuitem (ebook, lang);
	g_free (lang);
#endif /* HAVE_GTKSPELL */
}
Пример #2
0
void
jam_view_settings_changed(JamView *view) {
#ifdef HAVE_GTKSPELL
	GtkSpell *spell;
	GError *err = NULL;
	spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(view->entry));
	if (conf.options.usespellcheck) {
		GtkWindow *toplevel;
		toplevel = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(view)));
		if (spell) {
			if (!gtkspell_set_language(spell, conf.spell_language, &err)) {
				jam_warning(toplevel,
						_("GtkSpell error: %s"), err->message);
				g_error_free(err);
			}
		} else {
			GError *err = NULL;
			if (gtkspell_new_attach(GTK_TEXT_VIEW(view->entry), conf.spell_language , &err) == NULL) {
				jam_warning(toplevel,
						_("GtkSpell error: %s"), err->message);
				conf.options.usespellcheck = FALSE;
				g_error_free(err);
			}
		}
	} else {
		if (spell)
			gtkspell_detach(spell);
	}
#endif
	if (conf.uifont)
		jam_widget_set_font(view->entry, conf.uifont);

	if (view->musicbar) {
	    /* There are many cleaner ways to add/remove the Refresh button when
	     * the music preference has changed, but this works fine. */
		music_remove(view);
		music_add(view);
	}
}