# HG changeset patch # User zas_ # Date 1211450947 0 # Node ID 57f759d012c7ac2512778e8e0a725bb30f5b2cdd # Parent 8256c74730e2409bdfaa2147b134335774a226ec 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. diff -r 8256c74730e2 -r 57f759d012c7 src/image-overlay.c --- 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) diff -r 8256c74730e2 -r 57f759d012c7 src/image-overlay.h --- 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); diff -r 8256c74730e2 -r 57f759d012c7 src/main.c --- 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()); diff -r 8256c74730e2 -r 57f759d012c7 src/preferences.c --- 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));