changeset 733:57f759d012c7

Modify set_default_image_overlay_template_string() to accept the pointer to the string to modify and add a generic function to set template_string value.
author zas_
date Thu, 22 May 2008 10:09:07 +0000
parents 8256c74730e2
children e6ebae313d46
files src/image-overlay.c src/image-overlay.h src/main.c src/preferences.c
diffstat 4 files changed, 20 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/image-overlay.c	Thu May 22 09:22:29 2008 +0000
+++ b/src/image-overlay.c	Thu May 22 10:09:07 2008 +0000
@@ -83,11 +83,18 @@
 
 static void image_osd_timer_schedule(OverlayStateData *osd);
 
-
-void set_default_image_overlay_template_string(ConfOptions *options)
+void set_image_overlay_template_string(gchar **template_string, const gchar *value)
 {
-	if (options->image_overlay.common.template_string) g_free(options->image_overlay.common.template_string);
-	options->image_overlay.common.template_string = g_strdup(DEFAULT_OVERLAY_INFO);
+	g_assert(template_string);
+
+	g_free(*template_string);
+	*template_string = g_strdup(value);
+}
+
+
+void set_default_image_overlay_template_string(gchar **template_string)
+{
+	set_image_overlay_template_string(template_string, DEFAULT_OVERLAY_INFO);
 }
 
 static OverlayStateData *image_get_osd_data(ImageWindow *imd)
--- a/src/image-overlay.h	Thu May 22 09:22:29 2008 +0000
+++ b/src/image-overlay.h	Thu May 22 10:09:07 2008 +0000
@@ -31,7 +31,8 @@
 	OSD_SHOW_HISTOGRAM	= 1 << 2
 } OsdShowFlags;
 
-void set_default_image_overlay_template_string(ConfOptions *options);
+void set_image_overlay_template_string(gchar **template_string, const gchar *value);
+void set_default_image_overlay_template_string(gchar **template_string);
 
 void image_osd_set(ImageWindow *imd, OsdShowFlags show);
 OsdShowFlags image_osd_get(ImageWindow *imd);
--- a/src/main.c	Thu May 22 09:22:29 2008 +0000
+++ b/src/main.c	Thu May 22 10:09:07 2008 +0000
@@ -576,7 +576,7 @@
 		options->color_profile.input_name[i] = NULL;
 		}
 
-	set_default_image_overlay_template_string(options);
+	set_default_image_overlay_template_string(&options->image_overlay.common.template_string);
 	sidecar_ext_add_defaults();
 	options->layout.order = g_strdup("123");
 	options->properties.tabs_order = g_strdup(info_tab_default_order());
--- a/src/preferences.c	Thu May 22 09:22:29 2008 +0000
+++ b/src/preferences.c	Thu May 22 10:09:07 2008 +0000
@@ -283,11 +283,9 @@
 	options->fullscreen.above = c_options->fullscreen.above;
 	options->image_overlay.common.show_at_startup = c_options->image_overlay.common.show_at_startup;
 	if (c_options->image_overlay.common.template_string)
-		{
-		g_free(options->image_overlay.common.template_string);
-		options->image_overlay.common.template_string = g_strdup(c_options->image_overlay.common.template_string);
-		}
-
+		set_image_overlay_template_string(&options->image_overlay.common.template_string,
+						  c_options->image_overlay.common.template_string);
+		
 	options->update_on_time_change = c_options->update_on_time_change;
 	options->image.exif_rotate_enable = c_options->image.exif_rotate_enable;
 
@@ -825,8 +823,8 @@
 	gtk_text_buffer_get_start_iter(pTextBuffer, &iStart);
 	gtk_text_buffer_get_end_iter(pTextBuffer, &iEnd);
 
-	if (c_options->image_overlay.common.template_string) g_free(c_options->image_overlay.common.template_string);
-	c_options->image_overlay.common.template_string = gtk_text_buffer_get_text(pTextBuffer, &iStart, &iEnd, TRUE);
+	set_image_overlay_template_string(&c_options->image_overlay.common.template_string,
+					  gtk_text_buffer_get_text(pTextBuffer, &iStart, &iEnd, TRUE));
 }
 
 static void image_overlay_default_template_ok_cb(GenericDialog *gd, gpointer data)
@@ -834,7 +832,7 @@
 	GtkTextView *text_view = data;
 	GtkTextBuffer *buffer;
 
-	set_default_image_overlay_template_string(options);
+	set_default_image_overlay_template_string(&options->image_overlay.common.template_string);
 	if (!configwindow) return;
 
 	buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view));