Replace fullscreen.info and fullscreen.show_info options by:
authorLaurent Monin <geeqie@norz.org>
Mon, 21 Apr 2008 20:01:22 +0000 (20:01 +0000)
committerLaurent Monin <geeqie@norz.org>
Mon, 21 Apr 2008 20:01:22 +0000 (20:01 +0000)
image_overlay.common.enabled => to save last state to rc file
image_overlay.common.show_at_startup => overrides .common.enabled at startup
image_overlay.common.template_string => replace fullscreen.info

common is used since for now there is only one image overlay setup,
later specific setups may be added.

src/fullscreen.c
src/globals.c
src/image-overlay.c
src/main.c
src/preferences.c
src/rcfile.c
src/typedefs.h

index b3b38da..d78a00f 100644 (file)
@@ -34,8 +34,8 @@ enum {
 
 void set_default_fullscreen_info(ConfOptions *options)
 {
-       if (options->fullscreen.info) g_free(options->fullscreen.info);
-       options->fullscreen.info = g_strdup(DEFAULT_OVERLAY_INFO);
+       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);
 }
 
 static void clear_mouse_cursor(GtkWidget *widget, gint state)
index db59b78..6dab944 100644 (file)
@@ -51,9 +51,9 @@ ConfOptions *init_options(ConfOptions *options)
        options->fullscreen.above = FALSE;
        options->fullscreen.clean_flip = FALSE;
        options->fullscreen.disable_saver = TRUE;
-       options->fullscreen.info = NULL;
+       options->image_overlay.common.template_string = NULL;
        options->fullscreen.screen = -1;
-       options->fullscreen.show_info = TRUE;
+       options->image_overlay.common.show_at_startup = TRUE;
 
        memset(&options->image.border_color, 0, sizeof(options->image.border_color));
        options->image.dither_quality = (gint)GDK_RGB_DITHER_NORMAL;
index c926e0f..4ec8c9d 100644 (file)
@@ -335,7 +335,7 @@ static GdkPixbuf *image_osd_info_render(ImageWindow *imd)
                }
        else
                {
-               text = image_osd_mkinfo(options->fullscreen.info, imd, vars);
+               text = image_osd_mkinfo(options->image_overlay.common.template_string, imd, vars);
                }
 
        g_free(size);
index 3b22023..1f5e152 100644 (file)
@@ -1261,7 +1261,7 @@ static void exit_program_final(void)
                        layout_geometry_get(NULL, &options->layout.main_window.x, &options->layout.main_window.y,
                                            &options->layout.main_window.w, &options->layout.main_window.h);
                        }
-               options->fullscreen.show_info = image_osd_get(lw->image, NULL, NULL);
+               options->image_overlay.common.enabled = image_osd_get(lw->image, NULL, NULL);
                }
 
        layout_geometry_get_dividers(NULL, &options->layout.main_window.hdivider_pos, &options->layout.main_window.vdivider_pos);
@@ -1532,7 +1532,7 @@ int main (int argc, char *argv[])
                                                    collection_get_first(first_collection));
                        }
                }
-       image_osd_set(lw->image, FALSE, options->fullscreen.show_info);
+       image_osd_set(lw->image, FALSE, (options->image_overlay.common.show_at_startup || options->image_overlay.common.enabled));
 
        g_free(geometry);
        g_free(cmd_path);
index b06a55f..c23ad2d 100644 (file)
@@ -252,11 +252,11 @@ static void config_window_apply(void)
        options->fullscreen.clean_flip = c_options->fullscreen.clean_flip;
        options->fullscreen.disable_saver = c_options->fullscreen.disable_saver;
        options->fullscreen.above = c_options->fullscreen.above;
-       options->fullscreen.show_info = c_options->fullscreen.show_info;
-       if (c_options->fullscreen.info)
+       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->fullscreen.info);
-               options->fullscreen.info = g_strdup(c_options->fullscreen.info);
+               g_free(options->image_overlay.common.template_string);
+               options->image_overlay.common.template_string = g_strdup(c_options->image_overlay.common.template_string);
                }
 
        options->update_on_time_change = c_options->update_on_time_change;
@@ -775,7 +775,7 @@ static void safe_delete_clear_cb(GtkWidget* widget, gpointer data)
        gtk_widget_show(gd->dialog);
 }
 
-static void fullscreen_info_view_changed_cb(GtkWidget* widget, gpointer data)
+static void image_overlay_template_view_changed_cb(GtkWidget* widget, gpointer data)
 {
        GtkWidget *pTextView;
        GtkTextBuffer* pTextBuffer;
@@ -788,8 +788,8 @@ static void fullscreen_info_view_changed_cb(GtkWidget* widget, gpointer data)
        gtk_text_buffer_get_start_iter(pTextBuffer, &iStart);
        gtk_text_buffer_get_end_iter(pTextBuffer, &iEnd);
 
-       if (c_options->fullscreen.info) g_free(c_options->fullscreen.info);
-       c_options->fullscreen.info = gtk_text_buffer_get_text(pTextBuffer, &iStart, &iEnd, TRUE);
+       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);
 }
 
 static void fullscreen_info_default_ok_cb(GenericDialog *gd, gpointer data)
@@ -801,7 +801,7 @@ static void fullscreen_info_default_ok_cb(GenericDialog *gd, gpointer data)
        if (!configwindow) return;
 
        buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view));
-       gtk_text_buffer_set_text(buffer, options->fullscreen.info, -1);
+       gtk_text_buffer_set_text(buffer, options->image_overlay.common.template_string, -1);
 }
 
 static void fullscreen_info_default_cb(GtkWidget *widget, gpointer data)
@@ -1278,7 +1278,7 @@ static void config_tab_advanced(GtkWidget *notebook)
        GtkWidget *spin;
        GtkWidget *scrolled;
        GtkWidget *viewport;
-       GtkWidget *fullscreen_info_view;
+       GtkWidget *image_overlay_template_view;
        GtkTextBuffer *buffer;
        gint i;
 
@@ -1311,9 +1311,9 @@ static void config_tab_advanced(GtkWidget *notebook)
                              options->fullscreen.clean_flip, &c_options->fullscreen.clean_flip);
        pref_checkbox_new_int(group, _("Disable screen saver"),
                              options->fullscreen.disable_saver, &c_options->fullscreen.disable_saver);
-       pref_checkbox_new_int(group, _("Always show fullscreen info"),
-                             options->fullscreen.show_info, &c_options->fullscreen.show_info);
-       pref_label_new(group, _("Fullscreen info string"));
+       pref_checkbox_new_int(group, _("Always show image overlay at startup"),
+                             options->image_overlay.common.show_at_startup, &c_options->image_overlay.common.show_at_startup);
+       pref_label_new(group, _("Image overlay template"));
 
        scrolled = gtk_scrolled_window_new(NULL, NULL);
        gtk_widget_set_size_request(scrolled, 200, 150);
@@ -1323,10 +1323,10 @@ static void config_tab_advanced(GtkWidget *notebook)
        gtk_box_pack_start(GTK_BOX(group), scrolled, TRUE, TRUE, 5);
        gtk_widget_show(scrolled);
 
-       fullscreen_info_view = gtk_text_view_new();
+       image_overlay_template_view = gtk_text_view_new();
 
 #if GTK_CHECK_VERSION(2,12,0)
-       gtk_widget_set_tooltip_markup(fullscreen_info_view,
+       gtk_widget_set_tooltip_markup(image_overlay_template_view,
        _("<i>%name%</i> results in the filename of the picture.\n"
          "Also available: <i>%collection%</i>, <i>%number%</i>, <i>%total%</i>, <i>%date%</i>,\n"
          "<i>%size%</i> (filesize), <i>%width%</i>, <i>%height%</i>, <i>%res%</i> (resolution)\n"
@@ -1339,20 +1339,20 @@ static void config_tab_advanced(GtkWidget *notebook)
          "If a line is empty, it is removed. This allows to add lines that totally disappear when no data is available.\n"
 ));
 #endif
-       gtk_container_add(GTK_CONTAINER(scrolled), fullscreen_info_view);
-       gtk_widget_show(fullscreen_info_view);
+       gtk_container_add(GTK_CONTAINER(scrolled), image_overlay_template_view);
+       gtk_widget_show(image_overlay_template_view);
 
        hbox = pref_box_new(group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_BUTTON_GAP);
 
        button = pref_button_new(NULL, NULL, _("Defaults"), FALSE,
-                                G_CALLBACK(fullscreen_info_default_cb), fullscreen_info_view);
+                                G_CALLBACK(fullscreen_info_default_cb), image_overlay_template_view);
        gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
        gtk_widget_show(button);
 
-       buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(fullscreen_info_view));
-       if (options->fullscreen.info) gtk_text_buffer_set_text(buffer, options->fullscreen.info, -1);
+       buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(image_overlay_template_view));
+       if (options->image_overlay.common.template_string) gtk_text_buffer_set_text(buffer, options->image_overlay.common.template_string, -1);
        g_signal_connect(G_OBJECT(buffer), "changed",
-                        G_CALLBACK(fullscreen_info_view_changed_cb), fullscreen_info_view);
+                        G_CALLBACK(image_overlay_template_view_changed_cb), image_overlay_template_view);
 
        group = pref_group_new(vbox, FALSE, _("Delete"), GTK_ORIENTATION_VERTICAL);
 
index b699e06..722ad0e 100644 (file)
@@ -427,8 +427,11 @@ void save_options(void)
        WRITE_BOOL(fullscreen.clean_flip);
        WRITE_BOOL(fullscreen.disable_saver);
        WRITE_BOOL(fullscreen.above);
-       WRITE_BOOL(fullscreen.show_info);
-       WRITE_CHAR(fullscreen.info);
+
+       WRITE_SUBTITLE("Image Overlay Options");
+       WRITE_BOOL(image_overlay.common.enabled);
+       WRITE_BOOL(image_overlay.common.show_at_startup);
+       WRITE_CHAR(image_overlay.common.template_string);
 
        WRITE_SUBTITLE("Slideshow Options");
 
@@ -703,11 +706,13 @@ void load_options(void)
                READ_BOOL(fullscreen.clean_flip);
                READ_BOOL(fullscreen.disable_saver);
                READ_BOOL(fullscreen.above);
-               READ_BOOL(fullscreen.show_info);
-               READ_CHAR(fullscreen.info);
 
-               /* slideshow options */
+               /* image overlay */
+               READ_BOOL(image_overlay.common.enabled);
+               READ_BOOL(image_overlay.common.show_at_startup);
+               READ_CHAR(image_overlay.common.template_string);
 
+               /* slideshow options */
                READ_INT_UNIT(slideshow.delay, SLIDESHOW_SUBSECOND_PRECISION);
                READ_BOOL(slideshow.random);
                READ_BOOL(slideshow.repeat);
index 16a7490..64a93c6 100644 (file)
@@ -843,15 +843,22 @@ struct _ConfOptions
        } slideshow;
 
        /* fullscreen */
-       struct  {
+       struct {
                gint screen;
                gint clean_flip;
                gint disable_saver;
                gint above;
-               gint show_info;
-               gchar *info;
        } fullscreen;
 
+       /* image overlay */
+       struct {
+               struct {
+                       gint enabled;
+                       gint show_at_startup;
+                       gchar *template_string;
+               } common;
+       } image_overlay;
+
        /* layout */
        struct {
                gchar *order;