Modify set_default_image_overlay_template_string() to accept the pointer to
authorLaurent Monin <geeqie@norz.org>
Thu, 22 May 2008 10:09:07 +0000 (10:09 +0000)
committerLaurent Monin <geeqie@norz.org>
Thu, 22 May 2008 10:09:07 +0000 (10:09 +0000)
the string to modify and add a generic function to set template_string value.

src/image-overlay.c
src/image-overlay.h
src/main.c
src/preferences.c

index 863ab95..f5d57a9 100644 (file)
@@ -83,11 +83,18 @@ static OSDIcon osd_icons[] = {
 
 static void image_osd_timer_schedule(OverlayStateData *osd);
 
+void set_image_overlay_template_string(gchar **template_string, const gchar *value)
+{
+       g_assert(template_string);
+
+       g_free(*template_string);
+       *template_string = g_strdup(value);
+}
+
 
-void set_default_image_overlay_template_string(ConfOptions *options)
+void set_default_image_overlay_template_string(gchar **template_string)
 {
-       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);
+       set_image_overlay_template_string(template_string, DEFAULT_OVERLAY_INFO);
 }
 
 static OverlayStateData *image_get_osd_data(ImageWindow *imd)
index 4f833d3..dfae1b6 100644 (file)
@@ -31,7 +31,8 @@ typedef enum {
        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);
index 381cdff..ab72153 100644 (file)
@@ -576,7 +576,7 @@ static void setup_default_options(void)
                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());
index fcaf13c..2a243d3 100644 (file)
@@ -283,11 +283,9 @@ static void config_window_apply(void)
        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 @@ static void image_overlay_template_view_changed_cb(GtkWidget* widget, gpointer d
        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 @@ static void image_overlay_default_template_ok_cb(GenericDialog *gd, gpointer dat
        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));