added a utility function to reduce code duplication.

2004-11-17  Sven Neumann  <sven@gimp.org>

	* plug-ins/script-fu/script-fu-interface.c: added a utility
	function to reduce code duplication.
This commit is contained in:
Sven Neumann
2004-11-17 17:06:22 +00:00
committed by Sven Neumann
parent 6580cc4c4a
commit 235bb4082a
2 changed files with 19 additions and 16 deletions

View File

@ -1,3 +1,8 @@
2004-11-17 Sven Neumann <sven@gimp.org>
* plug-ins/script-fu/script-fu-interface.c: added a utility
function to reduce code duplication.
2004-11-17 Michael Natterer <mitch@gimp.org> 2004-11-17 Michael Natterer <mitch@gimp.org>
* plug-ins/script-fu/script-fu-scripts.[ch] * plug-ins/script-fu/script-fu-scripts.[ch]

View File

@ -629,6 +629,16 @@ script_fu_combo_callback (GtkWidget *widget,
option->history = gtk_combo_box_get_active (GTK_COMBO_BOX (widget)); option->history = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
} }
static void
script_fu_string_update (gchar **dest,
const gchar *src)
{
if (*dest)
g_free (*dest);
*dest = g_strdup (src);
}
static void static void
script_fu_pattern_callback (const gchar *name, script_fu_pattern_callback (const gchar *name,
gint width, gint width,
@ -638,10 +648,7 @@ script_fu_pattern_callback (const gchar *name,
gboolean closing, gboolean closing,
gpointer data) gpointer data)
{ {
gchar **pname = data; script_fu_string_update (data, name);
g_free (*pname);
*pname = g_strdup (name);
} }
static void static void
@ -651,10 +658,7 @@ script_fu_gradient_callback (const gchar *name,
gboolean closing, gboolean closing,
gpointer data) gpointer data)
{ {
gchar **gname = data; script_fu_string_update (data, name);
g_free (*gname);
*gname = g_strdup (name);
} }
static void static void
@ -662,10 +666,7 @@ script_fu_font_callback (const gchar *name,
gboolean closing, gboolean closing,
gpointer data) gpointer data)
{ {
gchar **fname = data; script_fu_string_update (data, name);
g_free (*fname);
*fname = g_strdup (name);
} }
static void static void
@ -673,10 +674,7 @@ script_fu_palette_callback (const gchar *name,
gboolean closing, gboolean closing,
gpointer data) gpointer data)
{ {
gchar **fname = data; script_fu_string_update (data, name);
g_free (*fname);
*fname = g_strdup (name);
} }
static void static void