changeset 11269:1cbe76d30e81

[gaim-migrate @ 13451] Refactoring the duplicate format clearing code. Also: (23:29:52) Etan Reisner (deryni): Since you are removing send_formatting, do we still want to be renaming use_custom_font to it? (23:30:04) rlaager: probably not committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Mon, 15 Aug 2005 04:51:53 +0000
parents e17f09e77785
children da0dc44368ba
files plugins/ChangeLog.API src/gtkconv.c src/gtkimhtml.c src/gtkimhtml.h src/gtkprefs.c
diffstat 5 files changed, 36 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/ChangeLog.API	Mon Aug 15 04:35:40 2005 +0000
+++ b/plugins/ChangeLog.API	Mon Aug 15 04:51:53 2005 +0000
@@ -71,6 +71,7 @@
 	* Changed: gtk_imhtml_toggle_bold, gtk_imhtml_toggle_italic,
 	           gtk_imhtml_toggle_underline, gtk_imhtml_toggle_strike:
 	           no longer return a value
+	* Added:   gtk_imhtml_clear_formatting()
 
 	Signals:
 	* Changed: "received-im-msg" and "received-chat-msg" to match, both
--- a/src/gtkconv.c	Mon Aug 15 04:35:40 2005 +0000
+++ b/src/gtkconv.c	Mon Aug 15 04:51:53 2005 +0000
@@ -300,30 +300,6 @@
 }
 
 static void
-clear_format(GaimGtkConversation *c)
-{
-	gboolean bold, italic, uline;
-	bold = italic = uline = FALSE;
-
-	gtk_imhtml_get_current_format(GTK_IMHTML(c->entry), &bold, &italic, &uline);
-	if (bold)
-		gtk_imhtml_toggle_bold(GTK_IMHTML(c->entry));
-	if (italic)
-		gtk_imhtml_toggle_italic(GTK_IMHTML(c->entry));
-	if (uline)
-		gtk_imhtml_toggle_underline(GTK_IMHTML(c->entry));
-
-	gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), 3);
-	gtk_imhtml_toggle_fontface(GTK_IMHTML(c->entry), NULL);
-
-	gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), NULL);
-	gtk_imhtml_toggle_backcolor(GTK_IMHTML(c->entry), NULL);
-	gtk_imhtml_toggle_background(GTK_IMHTML(c->entry), NULL);
-
-	gtk_widget_grab_focus(c->entry);
-}
-
-static void
 default_formatize(GaimGtkConversation *c)
 {
 	GaimConversation *conv = c->active_conv;
@@ -1790,7 +1766,7 @@
 
 					conv->send_history = conv->send_history->next;
 					gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry));
-					clear_format(gtkconv);
+					gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry));
 					gtk_imhtml_append_text_with_images(
 						GTK_IMHTML(gtkconv->entry), conv->send_history->data,
 						0, NULL);
@@ -1814,7 +1790,7 @@
 
 					conv->send_history = conv->send_history->prev;
 					gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry));
-					clear_format(gtkconv);
+					gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry));
 					gtk_imhtml_append_text_with_images(
 						GTK_IMHTML(gtkconv->entry), conv->send_history->data,
 						0, NULL);
--- a/src/gtkimhtml.c	Mon Aug 15 04:35:40 2005 +0000
+++ b/src/gtkimhtml.c	Mon Aug 15 04:51:53 2005 +0000
@@ -3828,6 +3828,30 @@
 	return imhtml->editable;
 }
 
+void
+gtk_imhtml_clear_formatting(GtkIMHtml *imhtml)
+{
+	gboolean bold, italic, uline;
+	bold = italic = uline = FALSE;
+
+	gtk_imhtml_get_current_format(imhtml, &bold, &italic, &uline);
+	if (bold)
+		gtk_imhtml_toggle_bold(imhtml);
+	if (italic)
+		gtk_imhtml_toggle_italic(imhtml);
+	if (uline)
+		gtk_imhtml_toggle_underline(imhtml);
+
+	gtk_imhtml_font_set_size(imhtml, 3);
+	gtk_imhtml_toggle_fontface(imhtml, NULL);
+
+	gtk_imhtml_toggle_forecolor(imhtml, NULL);
+	gtk_imhtml_toggle_backcolor(imhtml, NULL);
+	gtk_imhtml_toggle_background(imhtml, NULL);
+
+	gtk_widget_grab_focus(GTK_WIDGET(imhtml));
+}
+
 /*
  * I had this crazy idea about changing the text cursor color to reflex the foreground color
  * of the text about to be entered. This is the place you'd do it, along with the place where
--- a/src/gtkimhtml.h	Mon Aug 15 04:35:40 2005 +0000
+++ b/src/gtkimhtml.h	Mon Aug 15 04:51:53 2005 +0000
@@ -576,6 +576,13 @@
 gboolean gtk_imhtml_get_editable(GtkIMHtml *imhtml);
 
 /**
+ * Clear all the formatting on a GTK+ IM/HTML.
+ *
+ * @param imhtml The GTK+ IM/HTML.
+ */
+void gtk_imhtml_clear_formatting(GtkIMHtml *imhtml);
+
+/**
  * Toggles bold at the cursor location or selection in a GTK+ IM/HTML.
  *
  * @param imhtml The GTK+ IM/HTML.
--- a/src/gtkprefs.c	Mon Aug 15 04:35:40 2005 +0000
+++ b/src/gtkprefs.c	Mon Aug 15 04:51:53 2005 +0000
@@ -820,25 +820,7 @@
 
 static void
 formatting_reset_cb(GtkWidget *w, GtkWidget *imhtml) {
-	gboolean bold, italic, uline;
-	bold = italic = uline = FALSE;
-
-	gtk_imhtml_get_current_format(GTK_IMHTML(imhtml), &bold, &italic, &uline);
-	if (bold)
-		gtk_imhtml_toggle_bold(GTK_IMHTML(imhtml));
-	if (italic)
-		gtk_imhtml_toggle_italic(GTK_IMHTML(imhtml));
-	if (uline)
-		gtk_imhtml_toggle_underline(GTK_IMHTML(imhtml));
-
-	gtk_imhtml_font_set_size(GTK_IMHTML(imhtml), 3);
-	gtk_imhtml_toggle_fontface(GTK_IMHTML(imhtml), NULL);
-
-	gtk_imhtml_toggle_forecolor(GTK_IMHTML(imhtml), NULL);
-	gtk_imhtml_toggle_backcolor(GTK_IMHTML(imhtml), NULL);
-	gtk_imhtml_toggle_background(GTK_IMHTML(imhtml), NULL);
-
-	gtk_widget_grab_focus(imhtml);
+	gtk_imhtml_clear_formatting(GTK_IMHTML(imhtml));
 }
 
 static GtkWidget *
@@ -2296,9 +2278,6 @@
 	gaim_prefs_rename("/core/conversations/placement",
 					  "/gaim/gtk/conversations/placement");
 
-	gaim_prefs_rename("/gaim/gtk/conversations/use_custom_font",
-					  "/gaim/gtk/conversations/send_formatting");
-
 	gaim_prefs_rename("/gaim/gtk/debug/timestamps", "/core/debug/timestamps");
 	gaim_prefs_rename("/gaim/gtk/conversations/im/raise_on_events", "/plugins/gtk/X11/notify/method_raise");
 
@@ -2329,6 +2308,7 @@
 	gaim_prefs_remove("/gaim/gtk/conversations/smiley_shortcuts");
 	gaim_prefs_remove("/gaim/gtk/conversations/use_custom_bgcolor");
 	gaim_prefs_remove("/gaim/gtk/conversations/use_custom_fgcolor");
+	gaim_prefs_remove("/gaim/gtk/conversations/use_custom_font");
 	gaim_prefs_remove("/gaim/gtk/conversations/use_custom_size");
 	gaim_prefs_remove("/gaim/gtk/conversations/chat/old_tab_complete");
 	gaim_prefs_remove("/gaim/gtk/conversations/chat/tab_completion");