[evolution-patches] properties changes



this moves the useful gtkhtml properties out of class properties and
into get/set methods.  It also adds bonobo properties mirroring these
changes to the editor control property bag.  I'll follow up with another
patch removing the old cruft from gtkhtml-properties.

--Larry
? autom4te.cache
? stamp-h1
? components/html-editor/test_editor
Index: components/html-editor/ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/components/html-editor/ChangeLog,v
retrieving revision 1.402
diff -u -p -r1.402 ChangeLog
--- components/html-editor/ChangeLog	19 May 2003 13:28:09 -0000	1.402
+++ components/html-editor/ChangeLog	20 May 2003 16:46:23 -0000
@@ -1,3 +1,8 @@
+2003-05-20  Larry Ewing  <lewing ximian com>
+
+	* editor-control-factory.c: add inline smiley and link bonobo
+	properties.
+
 2003-05-17  Larry Ewing  <lewing ximian com>
 
 	* menubar.c (file_dialog_ok): rewrite file insertion to try utf-8
Index: components/html-editor/editor-control-factory.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/components/html-editor/editor-control-factory.c,v
retrieving revision 1.128
diff -u -p -r1.128 editor-control-factory.c
--- components/html-editor/editor-control-factory.c	12 May 2003 20:46:48 -0000	1.128
+++ components/html-editor/editor-control-factory.c	20 May 2003 16:46:23 -0000
@@ -444,7 +444,10 @@ editor_set_format (GtkHTMLControlData *c
 
 static enum {
 	PROP_EDIT_HTML,
-	PROP_HTML_TITLE
+	PROP_HTML_TITLE,
+	PROP_INLINE_SPELLING,
+	PROP_MAGIC_LINKS,
+	PROP_MAGIC_SMILEYS
 } EditorControlProps;
 
 static void
@@ -463,6 +466,15 @@ editor_get_prop (BonoboPropertyBag *bag,
 	case PROP_HTML_TITLE:
 		BONOBO_ARG_SET_STRING (arg, gtk_html_get_title (cd->html));
 		break;
+	case PROP_INLINE_SPELLING:
+		BONOBO_ARG_SET_BOOLEAN (arg, gtk_html_get_inline_spelling (cd->html));
+		break;
+	case PROP_MAGIC_LINKS:
+		BONOBO_ARG_SET_BOOLEAN (arg, gtk_html_get_magic_links (cd->html));
+		break;
+	case PROP_MAGIC_SMILEYS:
+		BONOBO_ARG_SET_BOOLEAN (arg, gtk_html_get_magic_smileys (cd->html));
+		break;
        	default:
 		bonobo_exception_set (ev, ex_Bonobo_PropertyBag_NotFound);
 		break;
@@ -486,6 +498,15 @@ editor_set_prop (BonoboPropertyBag *bag,
 	case PROP_HTML_TITLE:
 		gtk_html_set_title (cd->html, BONOBO_ARG_GET_STRING (arg));
 		break;
+	case PROP_INLINE_SPELLING:
+		gtk_html_set_inline_spelling (cd->html, BONOBO_ARG_GET_BOOLEAN (arg));
+		break;
+	case PROP_MAGIC_LINKS:
+		gtk_html_set_magic_links (cd->html, BONOBO_ARG_GET_BOOLEAN (arg));
+		break;
+	case PROP_MAGIC_SMILEYS:
+		gtk_html_set_magic_smileys (cd->html, BONOBO_ARG_GET_BOOLEAN (arg));
+		break;
 	default:
 		bonobo_exception_set (ev, ex_Bonobo_PropertyBag_NotFound);
 		break;
@@ -536,6 +557,36 @@ editor_control_construct (BonoboControl 
 	bonobo_property_bag_add (pb, "FormatHTML", PROP_EDIT_HTML,
 				 BONOBO_ARG_BOOLEAN, def,
 				 "Whether or not to edit in HTML mode", 
+				 0);
+
+	CORBA_free (def);
+
+	def = bonobo_arg_new (BONOBO_ARG_BOOLEAN);
+	BONOBO_ARG_SET_BOOLEAN (def, gtk_html_get_inline_spelling (GTK_HTML (html_widget)));
+
+	bonobo_property_bag_add (pb, "InlineSpelling", PROP_INLINE_SPELLING,
+				 BONOBO_ARG_BOOLEAN, def,
+				 "Include spelling errors inline", 
+				 0);
+
+	CORBA_free (def);
+
+	def = bonobo_arg_new (BONOBO_ARG_BOOLEAN);
+	BONOBO_ARG_SET_BOOLEAN (def, gtk_html_get_magic_links (GTK_HTML (html_widget)));
+
+	bonobo_property_bag_add (pb, "MagicLinks", PROP_MAGIC_LINKS,
+				 BONOBO_ARG_BOOLEAN, def,
+				 "Recognize links in text and replace them", 
+				 0);
+
+	CORBA_free (def);
+
+	def = bonobo_arg_new (BONOBO_ARG_BOOLEAN);
+	BONOBO_ARG_SET_BOOLEAN (def, gtk_html_get_magic_smileys (GTK_HTML (html_widget)));
+
+	bonobo_property_bag_add (pb, "MagicSmileys", PROP_MAGIC_SMILEYS,
+				 BONOBO_ARG_BOOLEAN, def,
+				 "Recognize smileys in text and replace them", 
 				 0);
 
 	CORBA_free (def);
Index: src/ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/ChangeLog,v
retrieving revision 1.1806
diff -u -p -r1.1806 ChangeLog
--- src/ChangeLog	20 May 2003 15:28:34 -0000	1.1806
+++ src/ChangeLog	20 May 2003 16:46:27 -0000
@@ -1,5 +1,14 @@
 2003-05-20  Larry Ewing  <lewing ximian com>
 
+	* gtkhtml.h: add prototypes.
+
+	* htmlengine-edit-cut-and-paste.c (use_pictograms): use get_magic_smileys.
+	(check_magic_link): use get_magic_links.
+
+	* htmlengine-edit.c: use get_inline_spelling.
+
+	* htmlclueflow.c: use get_inline_spelling.
+
 	* gtkhtml.c (gtk_html_set_iframe_parent): use parents
 	animate_setting.
 
Index: src/gtkhtml-private.h
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml-private.h,v
retrieving revision 1.38
diff -u -p -r1.38 gtkhtml-private.h
--- src/gtkhtml-private.h	29 Apr 2003 16:02:48 -0000	1.38
+++ src/gtkhtml-private.h	20 May 2003 16:46:27 -0000
@@ -63,6 +63,10 @@ struct _GtkHTMLPrivate {
 
 	guint32     event_time;
 	gboolean    selection_as_cite;
+
+	gboolean    magic_links;
+	gboolean    magic_smileys;
+	gboolean    inline_spelling;
 };
 
 void  gtk_html_private_calc_scrollbars  (GtkHTML                 *html,
Index: src/gtkhtml.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml.c,v
retrieving revision 1.513
diff -u -p -r1.513 gtkhtml.c
--- src/gtkhtml.c	20 May 2003 15:28:34 -0000	1.513
+++ src/gtkhtml.c	20 May 2003 16:46:27 -0000
@@ -700,16 +700,6 @@ destroy (GtkObject *object)
 			html->priv->scroll_timeout_id = 0;
 		}
 
-		if (html->priv->set_font_id) {
-			g_source_remove (html->priv->set_font_id);
-			html->priv->set_font_id = 0;
-		}
-
-		if (html->priv->notify_id) {
-			gconf_client_notify_remove (gconf_client, html->priv->notify_id);
-			html->priv->notify_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;
@@ -1948,33 +1938,6 @@ set_adjustments (GtkLayout     *layout,
 
 /* Initialization.  */
 static void
-client_notify_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, "/live_spell_check")) {
-		prop->live_spell_check = gconf_client_get_bool (client, entry->key, NULL);
-		if (html_engine_get_editable (html->engine)) {
-			if (prop->live_spell_check)
-				html_engine_spell_check (html->engine);
-			else
-				html_engine_clear_spell_check (html->engine);
-		}
-	}
-}
-
-static void
 client_notify_spell_widget (GConfClient* client, guint cnxn_id, GConfEntry* entry, gpointer user_data)
 {
 	GtkHTML *html = (GtkHTML *) user_data;
@@ -2655,7 +2618,6 @@ gtk_html_class_init (GtkHTMLClass *klass
 	widget_class->realize = realize;
 	widget_class->unrealize = unrealize;
 	widget_class->style_set = style_set;
-	/* RM2 widget_class->draw = draw; */
 	widget_class->key_press_event = key_press_event;
 	widget_class->key_release_event = key_release_event;
 	widget_class->expose_event  = expose;
@@ -2701,13 +2663,6 @@ init_properties_widget (GtkHTML *html)
 
 	prop = get_class_properties (html);
 
-	html->priv->notify_id = gconf_client_notify_add (gconf_client, GTK_HTML_GCONF_DIR,
-							 client_notify_widget, html, NULL, &gconf_error);
-	if (gconf_error) {
-		g_warning ("gconf error: %s\n", gconf_error->message);
-		html->priv->notify_id = 0;
-	}
-
 	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) {
@@ -3383,6 +3338,68 @@ gtk_html_get_editable  (const GtkHTML *h
 	g_return_val_if_fail (GTK_IS_HTML (html), FALSE);
 
 	return html_engine_get_editable (html->engine);
+}
+
+void
+gtk_html_set_inline_spelling (GtkHTML *html,
+			      gboolean inline_spell)
+{
+	g_return_if_fail (html != NULL);
+	g_return_if_fail (GTK_IS_HTML (html));
+
+	html->priv->inline_spelling = inline_spell;
+
+	if (gtk_html_get_editable (html) && html->priv->inline_spelling)
+		html_engine_spell_check (html->engine);
+	else
+		html_engine_clear_spell_check (html->engine);
+}	
+
+gboolean
+gtk_html_get_inline_spelling (const GtkHTML *html)
+{
+	g_return_val_if_fail (html != NULL, FALSE);
+	g_return_val_if_fail (GTK_IS_HTML (html), FALSE);
+
+	return html->priv->inline_spelling;
+}
+
+void
+gtk_html_set_magic_links (GtkHTML *html,
+			  gboolean links)
+{
+	g_return_if_fail (html != NULL);
+	g_return_if_fail (GTK_IS_HTML (html));
+
+	html->priv->magic_links = links;
+}
+
+gboolean
+gtk_html_get_magic_links (const GtkHTML *html)
+{
+	g_return_val_if_fail (html != NULL, FALSE);
+	g_return_val_if_fail (GTK_IS_HTML (html), FALSE);
+
+	return 	html->priv->magic_links;
+}
+
+void
+gtk_html_set_magic_smileys (GtkHTML *html,
+			    gboolean smile)
+{
+	g_return_if_fail (html != NULL);
+	g_return_if_fail (GTK_IS_HTML (html));
+
+	html->priv->magic_smileys = smile;
+}
+
+gboolean
+gtk_html_get_magic_smileys (const GtkHTML *html)
+{
+	g_return_val_if_fail (html != NULL, FALSE);
+	g_return_val_if_fail (GTK_IS_HTML (html), FALSE);
+
+	return 	html->priv->magic_smileys;
 }
 
 static void
Index: src/gtkhtml.h
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml.h,v
retrieving revision 1.145
diff -u -p -r1.145 gtkhtml.h
--- src/gtkhtml.h	20 May 2003 15:17:13 -0000	1.145
+++ src/gtkhtml.h	20 May 2003 16:46:27 -0000
@@ -186,6 +186,20 @@ gboolean                   gtk_html_expo
 void                       gtk_html_set_editable                  (GtkHTML                   *html,
 								   gboolean                   editable);
 gboolean                   gtk_html_get_editable                  (const GtkHTML             *html);
+void                       gtk_html_set_inline_spelling           (GtkHTML                   *html,
+								   gboolean                   inline_spell);
+gboolean                   gtk_html_get_inline_spelling           (const GtkHTML             *html);
+void                       gtk_html_set_magic_links               (GtkHTML                   *html,
+								   gboolean                   magic_links);
+gboolean                   gtk_html_get_magic_links               (const GtkHTML             *html);
+void                       gtk_html_set_magic_smileys             (GtkHTML                   *html,
+								   gboolean                   magic_smileys);
+gboolean                   gtk_html_get_magic_smileys             (const GtkHTML             *html);
+
+/* Animated Images */
+void                       gtk_html_set_animate                   (GtkHTML                   *html,
+								   gboolean                   animate);
+gboolean                   gtk_html_get_animate                   (const GtkHTML             *html);
 
 /* Animated Images */
 void                       gtk_html_set_animate                   (GtkHTML                   *html,
Index: src/htmlclueflow.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlclueflow.c,v
retrieving revision 1.287
diff -u -p -r1.287 htmlclueflow.c
--- src/htmlclueflow.c	6 May 2003 11:04:58 -0000	1.287
+++ src/htmlclueflow.c	20 May 2003 16:46:28 -0000
@@ -2788,9 +2788,7 @@ html_clueflow_spell_check (HTMLClueFlow 
 	   printf ("html_clueflow_spell_check %p %p %d %d\n", i->from, i->to, i->from_offset, i->to_offset); */
 
 	clue = HTML_CLUE (flow);
-	if (!e->widget->editor_api
-	    || !GTK_HTML_CLASS (GTK_WIDGET_GET_CLASS (e->widget))->properties->live_spell_check
-	    || !clue || !clue->tail)
+	if (!e->widget->editor_api || !gtk_html_get_inline_spelling (e->widget) || !clue || !clue->tail)
 		return;
 
 	off  = 0;
Index: src/htmlengine-edit-cut-and-paste.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine-edit-cut-and-paste.c,v
retrieving revision 1.92
diff -u -p -r1.92 htmlengine-edit-cut-and-paste.c
--- src/htmlengine-edit-cut-and-paste.c	7 Apr 2003 06:38:05 -0000	1.92
+++ src/htmlengine-edit-cut-and-paste.c	20 May 2003 16:46:28 -0000
@@ -1119,7 +1119,8 @@ static void
 check_magic_link (HTMLEngine *e, const gchar *text, guint len)
 {
 	if (HTML_IS_TEXT (e->cursor->object)
-	    && GTK_HTML_PROPERTY (e->widget, magic_links) && len == 1
+	    && gtk_html_get_magic_links (e->widget) 
+	    && len == 1
 	    && (*text == ' ' || text [0] == '\n' || text [0] == '>' || text [0] == ')'))
 		html_text_magic_link (HTML_TEXT (e->cursor->object), e, html_object_get_length (e->cursor->object));
 }
@@ -1223,7 +1224,7 @@ use_pictograms (HTMLEngine *e)
 	gint relative;
 	gunichar uc;
 
-	if (!html_object_is_text (e->cursor->object))
+	if (!html_object_is_text (e->cursor->object) || !gtk_html_get_magic_smileys (e->widget))
 		return;
 
 	pos = e->cursor->offset - 1;
Index: src/htmlengine-edit.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine-edit.c,v
retrieving revision 1.97
diff -u -p -r1.97 htmlengine-edit.c
--- src/htmlengine-edit.c	4 Nov 2002 14:33:58 -0000	1.97
+++ src/htmlengine-edit.c	20 May 2003 16:46:28 -0000
@@ -178,8 +178,7 @@ html_engine_spell_check_range (HTMLEngin
 
 	e->need_spell_check = FALSE;
 
-	if (!e->widget->editor_api || !GTK_HTML_CLASS (GTK_WIDGET_GET_CLASS (e->widget))->properties->live_spell_check
-	    || !begin->object->parent)
+	if (!e->widget->editor_api || !gtk_html_get_inline_spelling (e->widget) || !begin->object->parent)
 		return;
 
 	begin = html_cursor_dup (begin);


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