gtkhtml r9096 - trunk/components/editor



Author: mbarnes
Date: Mon Jan 12 04:37:09 2009
New Revision: 9096
URL: http://svn.gnome.org/viewvc/gtkhtml?rev=9096&view=rev

Log:
2009-01-12  Matthew Barnes  <mbarnes redhat com>

	** Fixes bug #565493

	* gtkhtml-editor-actions.c (action_bold_cb), (action_italic_cb),
	(action_monospaced_cb), (action_style_cb), (action_size_cb),
	(action_strikethrough_cb), (action_underline_cb):
	Ignore the action activation if 'ignore_style_change' is set.
	Means we're moving the cursor around and updating the toolbar.

	* gtkhtml-editor.c (editor_font_style_changed_cb),
	(editor_paragraph_style_changed_cb):
	Set 'ignore_style_change' for the duration of the function.

	* gtkhtml-editor-private.h:
	Add 'ignore_style_change' counter to the private struct.



Modified:
   trunk/components/editor/ChangeLog
   trunk/components/editor/gtkhtml-editor-actions.c
   trunk/components/editor/gtkhtml-editor-private.h
   trunk/components/editor/gtkhtml-editor.c

Modified: trunk/components/editor/gtkhtml-editor-actions.c
==============================================================================
--- trunk/components/editor/gtkhtml-editor-actions.c	(original)
+++ trunk/components/editor/gtkhtml-editor-actions.c	Mon Jan 12 04:37:09 2009
@@ -284,6 +284,9 @@
 {
 	const gchar *command;
 
+	if (editor->priv->ignore_style_change)
+		return;
+
 	if (gtk_toggle_action_get_active (action))
 		command = "bold-on";
 	else
@@ -692,6 +695,9 @@
 {
 	const gchar *command;
 
+	if (editor->priv->ignore_style_change)
+		return;
+
 	if (gtk_toggle_action_get_active (action))
 		command = "italic-on";
 	else
@@ -859,6 +865,9 @@
 	GtkHTMLFontStyle and_mask;
 	GtkHTMLFontStyle or_mask;
 
+	if (editor->priv->ignore_style_change)
+		return;
+
 	if (gtk_toggle_action_get_active (action)) {
 		and_mask = GTK_HTML_FONT_STYLE_MAX;
 		or_mask = GTK_HTML_FONT_STYLE_FIXED;
@@ -955,6 +964,9 @@
 {
 	const gchar *command = NULL;
 
+	if (editor->priv->ignore_style_change)
+		return;
+
 	switch (gtk_radio_action_get_current_value (current)) {
 		case GTK_HTML_PARAGRAPH_STYLE_NORMAL:
 			command = "style-normal";
@@ -1041,6 +1053,9 @@
 {
 	const gchar *command = NULL;
 
+	if (editor->priv->ignore_style_change)
+		return;
+
 	switch (gtk_radio_action_get_current_value (current)) {
 		case GTK_HTML_FONT_STYLE_SIZE_1:
 			command = "size-minus-2";
@@ -1081,6 +1096,9 @@
 {
 	const gchar *command;
 
+	if (editor->priv->ignore_style_change)
+		return;
+
 	if (gtk_toggle_action_get_active (action))
 		command = "strikeout-on";
 	else
@@ -1112,6 +1130,9 @@
 {
 	const gchar *command;
 
+	if (editor->priv->ignore_style_change)
+		return;
+
 	if (gtk_toggle_action_get_active (action))
 		command = "underline-on";
 	else

Modified: trunk/components/editor/gtkhtml-editor-private.h
==============================================================================
--- trunk/components/editor/gtkhtml-editor-private.h	(original)
+++ trunk/components/editor/gtkhtml-editor-private.h	Mon Jan 12 04:37:09 2009
@@ -172,6 +172,7 @@
 	gchar *current_folder;
 	GtkhtmlColorPalette *palette;
 	GtkhtmlColorState *text_color;
+	guint ignore_style_change;
 	gboolean changed;
 };
 

Modified: trunk/components/editor/gtkhtml-editor.c
==============================================================================
--- trunk/components/editor/gtkhtml-editor.c	(original)
+++ trunk/components/editor/gtkhtml-editor.c	Mon Jan 12 04:37:09 2009
@@ -102,6 +102,8 @@
 {
 	GtkHTMLFontStyle size;
 
+	editor->priv->ignore_style_change++;
+
 	gtk_toggle_action_set_active (
 		GTK_TOGGLE_ACTION (ACTION (BOLD)),
 		style & GTK_HTML_FONT_STYLE_BOLD);
@@ -128,6 +130,8 @@
 
 	gtk_radio_action_set_current_value (
 		GTK_RADIO_ACTION (ACTION (SIZE_PLUS_ZERO)), size);
+
+	editor->priv->ignore_style_change--;
 }
 
 static void
@@ -141,8 +145,12 @@
 editor_paragraph_style_changed_cb (GtkhtmlEditor *editor,
                                    GtkHTMLParagraphStyle style)
 {
+	editor->priv->ignore_style_change++;
+
 	gtk_radio_action_set_current_value (
 		GTK_RADIO_ACTION (ACTION (STYLE_NORMAL)), style);
+
+	editor->priv->ignore_style_change--;
 }
 
 static void



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