changeset 12605:cd1d0131e07f

[gaim-migrate @ 14940] Part of SF Patch #1378464 from Sadrul This removes code duplication in the format toggling functions. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Wed, 21 Dec 2005 21:59:18 +0000
parents 71299d63801d
children 51b0ce9d45d9
files src/gtkimhtml.c
diffstat 1 files changed, 18 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkimhtml.c	Wed Dec 21 21:48:38 2005 +0000
+++ b/src/gtkimhtml.c	Wed Dec 21 21:59:18 2005 +0000
@@ -4034,6 +4034,17 @@
 	g_slist_free(tags);
 }
 
+static void imhtml_emit_signal_for_format(GtkIMHtml *imhtml, GtkIMHtmlButtons button)
+{
+	GObject *object;
+
+	g_return_if_fail(imhtml != NULL);
+
+	object = g_object_ref(G_OBJECT(imhtml));
+	g_signal_emit(object, signals[TOGGLE_FORMAT], 0, button);
+	g_object_unref(object);
+}
+
 static void imhtml_toggle_bold(GtkIMHtml *imhtml)
 {
 	GtkTextIter start, end;
@@ -4057,13 +4068,7 @@
 
 void gtk_imhtml_toggle_bold(GtkIMHtml *imhtml)
 {
-	GObject *object;
-
-	g_return_if_fail(imhtml != NULL);
-
-	object = g_object_ref(G_OBJECT(imhtml));
-	g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_BOLD);
-	g_object_unref(object);
+	imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_BOLD);
 }
 
 static void imhtml_toggle_italic(GtkIMHtml *imhtml)
@@ -4088,13 +4093,8 @@
 
 void gtk_imhtml_toggle_italic(GtkIMHtml *imhtml)
 {
-	GObject *object;
-
-	g_return_if_fail(imhtml != NULL);
-
-	object = g_object_ref(G_OBJECT(imhtml));
-	g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_ITALIC);
-	g_object_unref(object);}
+	imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_ITALIC);
+}
 
 static void imhtml_toggle_underline(GtkIMHtml *imhtml)
 {
@@ -4118,13 +4118,7 @@
 
 void gtk_imhtml_toggle_underline(GtkIMHtml *imhtml)
 {
-	GObject *object;
-
-	g_return_if_fail(imhtml != NULL);
-
-	object = g_object_ref(G_OBJECT(imhtml));
-	g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_UNDERLINE);
-	g_object_unref(object);
+	imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_UNDERLINE);
 }
 
 static void imhtml_toggle_strike(GtkIMHtml *imhtml)
@@ -4149,13 +4143,7 @@
 
 void gtk_imhtml_toggle_strike(GtkIMHtml *imhtml)
 {
-	GObject *object;
-
-	g_return_if_fail(imhtml != NULL);
-
-	object = g_object_ref(G_OBJECT(imhtml));
-	g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_STRIKE);
-	g_object_unref(object);
+	imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_STRIKE);
 }
 
 void gtk_imhtml_font_set_size(GtkIMHtml *imhtml, gint size)
@@ -4207,13 +4195,7 @@
 
 void gtk_imhtml_font_shrink(GtkIMHtml *imhtml)
 {
-	GObject *object;
-
-	g_return_if_fail(imhtml != NULL);
-
-	object = g_object_ref(G_OBJECT(imhtml));
-	g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_SHRINK);
-	g_object_unref(object);
+	imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_SHRINK);
 }
 
 static void imhtml_font_grow(GtkIMHtml *imhtml)
@@ -4242,13 +4224,7 @@
 
 void gtk_imhtml_font_grow(GtkIMHtml *imhtml)
 {
-	GObject *object;
-
-	g_return_if_fail(imhtml != NULL);
-
-	object = g_object_ref(G_OBJECT(imhtml));
-	g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_GROW);
-	g_object_unref(object);
+	imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_GROW);
 }
 
 #define gtk_imhtml_toggle_str_tag(imhtml, color, edit_field, remove_func, find_func, button) { \