GIF animation settings
authorColin Clark <cclark@mcb.net>
Wed, 18 Jan 2017 13:57:37 +0000 (13:57 +0000)
committerColin Clark <cclark@mcb.net>
Wed, 18 Jan 2017 13:57:37 +0000 (13:57 +0000)
Preserve GIF animation setting between sessions
Include GIF animation on View menu. Shortcut key is "A"

src/layout.c
src/layout_image.c
src/layout_image.h
src/layout_util.c

index 055a033..6b40bb2 100644 (file)
@@ -2294,6 +2294,8 @@ void layout_write_attributes(LayoutOptions *layout, GString *outstr, gint indent
        WRITE_NL(); WRITE_UINT(*layout, image_overlay.state);
        WRITE_NL(); WRITE_INT(*layout, image_overlay.histogram_channel);
        WRITE_NL(); WRITE_INT(*layout, image_overlay.histogram_mode);
+
+       WRITE_NL(); WRITE_BOOL(*layout, animate);
 }
 
 
@@ -2363,6 +2365,8 @@ void layout_load_attributes(LayoutOptions *layout, const gchar **attribute_names
                if (READ_INT(*layout, image_overlay.histogram_channel)) continue;
                if (READ_INT(*layout, image_overlay.histogram_mode)) continue;
 
+               if (READ_BOOL(*layout, animate)) continue;
+
                log_printf("unknown attribute %s = %s\n", option, value);
                }
        if (id && strcmp(id, LAYOUT_ID_CURRENT) != 0)
index e5e5659..12eb2cf 100644 (file)
@@ -406,11 +406,17 @@ static gboolean layout_image_animate_new_file(LayoutWindow *lw)
        return TRUE;
 }
 
-static void layout_image_animate_toggle(LayoutWindow *lw)
+void layout_image_animate_toggle(LayoutWindow *lw)
 {
+       GtkAction *action;
+
        if (!lw) return;
 
        lw->options.animate = !lw->options.animate;
+
+       action = gtk_action_group_get_action(lw->action_group, "Animate");
+       gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.animate);
+
        layout_image_animate_new_file(lw);
 }
 
index 383a214..9f926fd 100644 (file)
@@ -95,6 +95,7 @@ gboolean layout_image_slideshow_active(LayoutWindow *lw);
 gboolean layout_image_slideshow_pause_toggle(LayoutWindow *lw);
 gboolean layout_image_slideshow_paused(LayoutWindow *lw);
 
+void layout_image_animate_toggle(LayoutWindow *lw);
 
 void layout_image_overlay_toggle(LayoutWindow *lw);
 
index 659dba5..413294f 100644 (file)
@@ -705,6 +705,14 @@ static void layout_menu_histogram_cb(GtkToggleAction *action, gpointer data)
                }
 }
 
+static void layout_menu_animate_cb(GtkToggleAction *action, gpointer data)
+{
+       LayoutWindow *lw = data;
+
+       if (lw->options.animate == gtk_toggle_action_get_active(action)) return;
+       layout_image_animate_toggle(lw);
+}
+
 static void layout_menu_rectangular_selection_cb(GtkToggleAction *action, gpointer data)
 {
        LayoutWindow *lw = data;
@@ -1589,6 +1597,7 @@ static GtkToggleActionEntry menu_toggle_entries[] = {
   { "ImageOverlay",    NULL,                   N_("Image _Overlay"),                   NULL,                   N_("Image Overlay"),                    CB(layout_menu_overlay_cb),      FALSE },
   { "ImageHistogram",  NULL,                   N_("_Show Histogram"),                  NULL,                   N_("Show Histogram"),                   CB(layout_menu_histogram_cb),    FALSE },
   { "RectangularSelection",    NULL,                   N_("Rectangular Selection"),                    "<alt>R",                       N_("Rectangular Selection"),                    CB(layout_menu_rectangular_selection_cb),        FALSE },
+  { "Animate", NULL,   N_("GIF _animation"),           "A",                    N_("Toggle GIF animation"),                     CB(layout_menu_animate_cb),      FALSE  },
 };
 
 static GtkRadioActionEntry menu_radio_entries[] = {
@@ -1821,6 +1830,7 @@ static const gchar *menu_ui_description =
 "      <menuitem action='ShowInfoPixel'/>"
 "      <placeholder name='ToolsSection'/>"
 "      <separator/>"
+"      <menuitem action='Animate'/>"
 "      <menuitem action='SlideShow'/>"
 "      <menuitem action='SlideShowPause'/>"
 "      <menuitem action='Refresh'/>"
@@ -2459,6 +2469,9 @@ static void layout_util_sync_views(LayoutWindow *lw)
        action = gtk_action_group_get_action(lw->action_group, "SlideShow");
        gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), layout_image_slideshow_active(lw));
 
+       action = gtk_action_group_get_action(lw->action_group, "Animate");
+       gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.animate);
+
        action = gtk_action_group_get_action(lw->action_group, "ImageOverlay");
        gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), osd_flags != OSD_SHOW_NOTHING);