Re: [evolution-patches] properties changes



I forgot it would be a pain to keep the  removals separate in the diff,
here it is with both.

--Larry

On Tue, 2003-05-20 at 11:50, Larry Ewing wrote:
> 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
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/ChangeLog,v
retrieving revision 1.1806
diff -u -p -r1.1806 ChangeLog
--- ChangeLog	20 May 2003 15:28:34 -0000	1.1806
+++ ChangeLog	20 May 2003 17:16:28 -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: 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
--- gtkhtml-private.h	29 Apr 2003 16:02:48 -0000	1.38
+++ gtkhtml-private.h	20 May 2003 17:16:28 -0000
@@ -49,8 +49,6 @@ struct _GtkHTMLPrivate {
 
 	GnomePrintJob *print_master;
 
-	guint set_font_id;
-	guint notify_id;
 	guint notify_spell_id;
 
 	GtkIMContext *im_context;
@@ -63,6 +61,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: gtkhtml-properties.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml-properties.c,v
retrieving revision 1.92
diff -u -p -r1.92 gtkhtml-properties.c
--- gtkhtml-properties.c	16 Apr 2003 17:51:55 -0000	1.92
+++ gtkhtml-properties.c	20 May 2003 17:16:28 -0000
@@ -65,13 +65,7 @@ gtk_html_class_properties_new (GtkWidget
 		fixed_size = var_size;
 	}
 
-	/* default values */
-	/* display */
-	p->animations              = TRUE;
-
 	/* editing */
-	p->magic_links             = TRUE;
-	p->live_spell_check        = TRUE;
 	p->language                = g_strdup (e_iconv_locale_language ());
 
 	/* printf ("Variable Printing Font: \"%s\"\n", p->font_var_print); */
@@ -94,13 +88,6 @@ gtk_html_class_properties_destroy (GtkHT
 	g_free (p);
 }
 
-#define GET(t,x,prop,f,c) \
-        key = g_strconcat (GTK_HTML_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);
-
 #define GNOME_SPELL_GCONF_DIR "/GNOME/Spell"
 #define GETSP(t,x,prop,f,c) \
         key = g_strconcat (GNOME_SPELL_GCONF_DIR, x, NULL); \
@@ -117,9 +104,6 @@ gtk_html_class_properties_load (GtkHTMLC
 
 	g_assert (client);
 
-	GET (bool, "/magic_links", magic_links,,);
-	GET (bool, "/animations", animations,,);
-
 	GETSP (string, "/language", language,
 	       g_free (p->language), g_strdup);
 
@@ -136,14 +120,6 @@ gtk_html_class_properties_update (GtkHTM
 {
 	gchar *key;
 
-	if (p->animations != old->animations)
-		SET (bool, "/animations", animations);
-	if (p->magic_links != old->magic_links)
-		SET (bool, "/magic_links", magic_links);
-	if (p->live_spell_check != old->live_spell_check)
-		SET (bool, "/live_spell_check", live_spell_check);
-
-
 	if (strcmp (p->font_var_print, old->font_var_print))
 		SET (string, "/font_variable_print", font_var_print);
 	if (strcmp (p->font_fix_print, old->font_fix_print))
@@ -156,7 +132,6 @@ gtk_html_class_properties_update (GtkHTM
 		SET (int, "/font_variable_size_print", font_var_size_print);
 	if (p->font_fix_size_print != old->font_fix_size_print || p->font_fix_print_points != old->font_fix_print_points)
 		SET (int, "/font_fixed_size_print", font_fix_size_print);
-	
 	
 	gconf_client_suggest_sync (client, NULL);
 }
Index: gtkhtml-properties.h
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml-properties.h,v
retrieving revision 1.24
diff -u -p -r1.24 gtkhtml-properties.h
--- gtkhtml-properties.h	9 Apr 2003 18:57:14 -0000	1.24
+++ gtkhtml-properties.h	20 May 2003 17:16:28 -0000
@@ -39,7 +39,6 @@
 
 struct _GtkHTMLClassProperties {
 	/* viewer */
-	gboolean  animations;
 	gchar    *font_var_print;
 	guint     font_var_size_print;
 	gboolean  font_var_print_points;
@@ -48,8 +47,6 @@ struct _GtkHTMLClassProperties {
 	gboolean  font_fix_print_points;
 
 	/* editor */
-	gboolean  magic_links;
-	gboolean  live_spell_check;
 	gchar    *language;
 };
 
Index: gtkhtml.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml.c,v
retrieving revision 1.513
diff -u -p -r1.513 gtkhtml.c
--- gtkhtml.c	20 May 2003 15:28:34 -0000	1.513
+++ gtkhtml.c	20 May 2003 17:16:28 -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;
@@ -1995,26 +1958,6 @@ client_notify_spell_widget (GConfClient*
 	}
 }
 
-static void
-client_notify_class (GConfClient* client,
-		     guint cnxn_id,
-		     GConfEntry* entry,
-		     gpointer user_data)
-{
-	GtkHTMLClass *klass = (GtkHTMLClass *) user_data;
-	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, "/magic_links")) {
-		prop->magic_links = gconf_client_get_bool (client, entry->key, NULL);
-	}
-}
-
 static GtkHTMLClassProperties *
 get_class_properties (GtkHTML *html)
 {
@@ -2045,7 +1988,6 @@ get_class_properties (GtkHTML *html)
 			g_error ("gconf error: %s\n", gconf_error->message);
 		gtk_html_class_properties_load (klass->properties, gconf_client);
 
-		gconf_client_notify_add (gconf_client, GTK_HTML_GCONF_DIR, client_notify_class, klass, NULL, &gconf_error);
 		if (gconf_error)
 			g_warning ("gconf error: %s\n", gconf_error->message);
 	}
@@ -2655,7 +2597,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 +2642,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) {
@@ -2840,9 +2774,6 @@ gtk_html_init (GtkHTML* html)
 	html->priv->content_type = g_strdup ("html/text; charset=utf-8");
 	html->priv->search_input_line = NULL;
 
-	html->priv->set_font_id = 0;
-	html->priv->notify_id = 0;
-
 	gtk_selection_add_targets (GTK_WIDGET (html),
 				   GDK_SELECTION_PRIMARY,
 				   targets, n_targets);
@@ -3383,6 +3314,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: gtkhtml.h
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml.h,v
retrieving revision 1.145
diff -u -p -r1.145 gtkhtml.h
--- gtkhtml.h	20 May 2003 15:17:13 -0000	1.145
+++ gtkhtml.h	20 May 2003 17:16:28 -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: htmlclueflow.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlclueflow.c,v
retrieving revision 1.287
diff -u -p -r1.287 htmlclueflow.c
--- htmlclueflow.c	6 May 2003 11:04:58 -0000	1.287
+++ htmlclueflow.c	20 May 2003 17:16:29 -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: 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
--- htmlengine-edit-cut-and-paste.c	7 Apr 2003 06:38:05 -0000	1.92
+++ htmlengine-edit-cut-and-paste.c	20 May 2003 17:16:29 -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: 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
--- htmlengine-edit.c	4 Nov 2002 14:33:58 -0000	1.97
+++ htmlengine-edit.c	20 May 2003 17:16:29 -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]