gtkhtml r8812 - in trunk: components/editor gtkhtml



Author: mbarnes
Date: Sat Apr  5 16:24:55 2008
New Revision: 8812
URL: http://svn.gnome.org/viewvc/gtkhtml?rev=8812&view=rev

Log:
2008-04-05  Matthew Barnes  <mbarnes redhat com>

	** Fixes part of bug #526152

	* gtkhtml/gtkhtml-properties.c (gtk_html_class_properties_load):
	* gtkhtml/gtkhtml-private.h:
	* gtkhtml/gtkhtml.c (destroy), (client_notify_spell_widget),
	(setup_class_properties), (init_properties_widget):
	Defer management of spell check languages and color to the editor
	component.  The last remnants of GnomeSpell have been swept away.

	* components/editor/gtkhtml-spell-language.c (spell_language_compare):
	Remove this function; use gtkhtml_spell_language_compare().

	* components/editor/gtkhtml-editor.c
	(gtkhtml_editor_get_spell_language),
	(gtkhtml_editor_set_spell_language):
	New functions provide a way to programmatically get and set the
	active spell checking languages.



Modified:
   trunk/components/editor/ChangeLog
   trunk/components/editor/gtkhtml-editor.c
   trunk/components/editor/gtkhtml-editor.h
   trunk/components/editor/gtkhtml-spell-language.c
   trunk/gtkhtml/ChangeLog
   trunk/gtkhtml/gtkhtml-private.h
   trunk/gtkhtml/gtkhtml-properties.c
   trunk/gtkhtml/gtkhtml-properties.h
   trunk/gtkhtml/gtkhtml.c

Modified: trunk/components/editor/gtkhtml-editor.c
==============================================================================
--- trunk/components/editor/gtkhtml-editor.c	(original)
+++ trunk/components/editor/gtkhtml-editor.c	Sat Apr  5 16:24:55 2008
@@ -1154,6 +1154,64 @@
 	g_object_notify (G_OBJECT (editor), "magic-smileys");
 }
 
+GList *
+gtkhtml_editor_get_spell_languages (GtkhtmlEditor *editor)
+{
+	GList *spell_languages = NULL;
+	GtkActionGroup *action_group;
+	GList *list;
+
+	g_return_val_if_fail (GTKHTML_IS_EDITOR (editor), NULL);
+
+	action_group = editor->priv->language_actions;
+	list = gtk_action_group_list_actions (action_group);
+
+	while (list != NULL) {
+		GtkToggleAction *action = list->data;
+		const GtkhtmlSpellLanguage *language;
+		const gchar *language_code;
+
+		list = g_list_delete_link (list, list);
+		if (!gtk_toggle_action_get_active (action))
+			continue;
+
+		language_code = gtk_action_get_name (GTK_ACTION (action));
+		language = gtkhtml_spell_language_lookup (language_code);
+
+		spell_languages = g_list_prepend (
+			spell_languages, (gpointer) language);
+	}
+
+	return g_list_reverse (spell_languages);
+}
+
+void
+gtkhtml_editor_set_spell_languages (GtkhtmlEditor *editor,
+                                    GList *spell_languages)
+{
+	GtkActionGroup *action_group;
+	GList *list;
+
+	g_return_if_fail (GTKHTML_IS_EDITOR (editor));
+
+	action_group = editor->priv->language_actions;
+	list = gtk_action_group_list_actions (action_group);
+
+	while (list != NULL) {
+		GtkToggleAction *action = list->data;
+		const GtkhtmlSpellLanguage *language;
+		const gchar *language_code;
+		gboolean active;
+
+		list = g_list_delete_link (list, list);
+		language_code = gtk_action_get_name (GTK_ACTION (action));
+		language = gtkhtml_spell_language_lookup (language_code);
+		active = (g_list_find (spell_languages, language) != NULL);
+
+		gtk_toggle_action_set_active (action, active);
+	}
+}
+
 gint
 gtkhtml_editor_file_chooser_dialog_run (GtkhtmlEditor *editor,
                                         GtkWidget *dialog)

Modified: trunk/components/editor/gtkhtml-editor.h
==============================================================================
--- trunk/components/editor/gtkhtml-editor.h	(original)
+++ trunk/components/editor/gtkhtml-editor.h	Sat Apr  5 16:24:55 2008
@@ -122,6 +122,11 @@
 gboolean	gtkhtml_editor_get_magic_smileys(GtkhtmlEditor *editor);
 void		gtkhtml_editor_set_magic_smileys(GtkhtmlEditor *editor,
 						 gboolean magic_smileys);
+GList *		gtkhtml_editor_get_spell_languages
+						(GtkhtmlEditor *editor);
+void		gtkhtml_editor_set_spell_languages
+						(GtkhtmlEditor *editor,
+						 GList *spell_languages);
 gint		gtkhtml_editor_file_chooser_dialog_run
 						(GtkhtmlEditor *editor,
 						 GtkWidget *dialog);

Modified: trunk/components/editor/gtkhtml-spell-language.c
==============================================================================
--- trunk/components/editor/gtkhtml-spell-language.c	(original)
+++ trunk/components/editor/gtkhtml-spell-language.c	Sat Apr  5 16:24:55 2008
@@ -213,13 +213,6 @@
 	g_tree_replace (tree, g_strdup (language_code), language_name);
 }
 
-static gint
-spell_language_compare (const GtkhtmlSpellLanguage *a,
-                        const GtkhtmlSpellLanguage *b)
-{
-	return g_utf8_collate (a->name, b->name);
-}
-
 static const GtkhtmlSpellLanguage *
 spell_language_copy (const GtkhtmlSpellLanguage *language)
 {
@@ -246,7 +239,7 @@
 
 	*available_languages = g_list_insert_sorted (
 		*available_languages, language,
-		(GCompareFunc) spell_language_compare);
+		(GCompareFunc) gtkhtml_spell_language_compare);
 
 	return FALSE;
 }

Modified: trunk/gtkhtml/gtkhtml-private.h
==============================================================================
--- trunk/gtkhtml/gtkhtml-private.h	(original)
+++ trunk/gtkhtml/gtkhtml-private.h	Sat Apr  5 16:24:55 2008
@@ -45,7 +45,6 @@
 
 	GtkWidget *search_input_line;
 
-	guint notify_spell_id;
 	guint notify_monospace_font_id;
 
 	GtkIMContext *im_context;

Modified: trunk/gtkhtml/gtkhtml-properties.c
==============================================================================
--- trunk/gtkhtml/gtkhtml-properties.c	(original)
+++ trunk/gtkhtml/gtkhtml-properties.c	Sat Apr  5 16:24:55 2008
@@ -102,25 +102,9 @@
 	g_free (p);
 }
 
-#define GNOME_SPELL_GCONF_DIR "/GNOME/Spell"
-#define GETSP(t,x,prop,f,c) \
-        key = g_strconcat (GNOME_SPELL_GCONF_DIR, x, NULL); \
-        val = gconf_client_get_without_default (client, key, NULL); \
-        if (val) { f; p->prop = c (gconf_value_get_ ## t (val)); \
-        gconf_value_free (val); } \
-        g_free (key);
-
 void
 gtk_html_class_properties_load (GtkHTMLClassProperties *p, GConfClient *client)
 {
-	GConfValue *val;
-	gchar *key;
-
-	g_assert (client);
-
-	GETSP (string, "/language", language,
-	       g_free (p->language), g_strdup);
-
 }
 
 #define SET(t,x,prop) \

Modified: trunk/gtkhtml/gtkhtml-properties.h
==============================================================================
--- trunk/gtkhtml/gtkhtml-properties.h	(original)
+++ trunk/gtkhtml/gtkhtml-properties.h	Sat Apr  5 16:24:55 2008
@@ -47,7 +47,7 @@
 	gboolean  font_fix_print_points;
 
 	/* editor */
-	gchar    *language;
+	gchar    *language;  /* unused */
 };
 
 GtkHTMLClassProperties * gtk_html_class_properties_new       (GtkWidget *widget);

Modified: trunk/gtkhtml/gtkhtml.c
==============================================================================
--- trunk/gtkhtml/gtkhtml.c	(original)
+++ trunk/gtkhtml/gtkhtml.c	Sat Apr  5 16:24:55 2008
@@ -130,8 +130,6 @@
 	gchar *plain_text;
 };
 
-#define GNOME_SPELL_GCONF_DIR "/GNOME/Spell"
-
 #define d_s(x)
 #define D_IM(x)
 
@@ -759,11 +757,6 @@
 			html->priv->scroll_timeout_id = 0;
 		}
 
-		if (html->priv->notify_spell_id) {
-			gconf_client_notify_remove (gconf_client, html->priv->notify_spell_id);
-			html->priv->notify_spell_id = 0;
-		}
-
 		if (html->priv->notify_monospace_font_id) {
 			gconf_client_notify_remove (gconf_client, html->priv->notify_monospace_font_id);
 			html->priv->notify_monospace_font_id = 0;
@@ -2220,27 +2213,6 @@
 
 /* Initialization.  */
 static void
-client_notify_spell_widget (GConfClient* client, guint cnxn_id, GConfEntry* entry, gpointer user_data)
-{
-	GtkHTML *html = (GtkHTML *) user_data;
-	GtkHTMLClass *klass = GTK_HTML_CLASS (GTK_WIDGET_GET_CLASS (html));
-	GtkHTMLClassProperties *prop = klass->properties;
-	gchar *tkey;
-
-	g_assert (client == gconf_client);
-	g_assert (entry->key);
-	tkey = strrchr (entry->key, '/');
-	g_assert (tkey);
-
-	if (!strcmp (tkey, "/language")) {
-		g_free (prop->language);
-		prop->language = gconf_client_get_string (client, entry->key, NULL);
-		if (!html->engine->language)
-			gtk_html_api_set_language (html);
-	}
-}
-
-static void
 setup_class_properties (GtkHTML *html)
 {
 	GtkHTMLClass *klass;
@@ -2265,13 +2237,6 @@
 		gconf_client_add_dir (gconf_client, GTK_HTML_GCONF_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, &gconf_error);
 		if (gconf_error)
 			g_error ("gconf error: %s\n", gconf_error->message);
-		gconf_client_add_dir (gconf_client, GNOME_SPELL_GCONF_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, &gconf_error);
-		if (gconf_error)
-			g_error ("gconf error: %s\n", gconf_error->message);
-		gtk_html_class_properties_load (klass->properties, gconf_client);
-
-		if (gconf_error)
-			g_warning ("gconf error: %s\n", gconf_error->message);
 	}
 }
 
@@ -3039,12 +3004,6 @@
 	if (!gconf_client)
 		gconf_client = gconf_client_get_default ();
 
-	html->priv->notify_spell_id = gconf_client_notify_add (gconf_client, GNOME_SPELL_GCONF_DIR,
-							       client_notify_spell_widget, html, NULL, &gconf_error);
-	if (gconf_error) {
-		g_warning ("gconf error: %s\n", gconf_error->message);
-		html->priv->notify_spell_id = 0;
-	}
 }
 
 void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]