changeset 2433:40e75fe44eac

GIF animation settings Preserve GIF animation setting between sessions Include GIF animation on View menu. Shortcut key is "A"
author Colin Clark <cclark@mcb.net>
date Wed, 18 Jan 2017 13:57:37 +0000
parents 1f5389d824df
children ddba21e66364
files src/layout.c src/layout_image.c src/layout_image.h src/layout_util.c
diffstat 4 files changed, 25 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/layout.c	Wed Jan 11 13:21:10 2017 +0000
+++ b/src/layout.c	Wed Jan 18 13:57:37 2017 +0000
@@ -2294,6 +2294,8 @@
 	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 @@
 		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)
--- a/src/layout_image.c	Wed Jan 11 13:21:10 2017 +0000
+++ b/src/layout_image.c	Wed Jan 18 13:57:37 2017 +0000
@@ -406,11 +406,17 @@
 	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);
 }
 
--- a/src/layout_image.h	Wed Jan 11 13:21:10 2017 +0000
+++ b/src/layout_image.h	Wed Jan 18 13:57:37 2017 +0000
@@ -95,6 +95,7 @@
 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);
 
--- a/src/layout_util.c	Wed Jan 11 13:21:10 2017 +0000
+++ b/src/layout_util.c	Wed Jan 18 13:57:37 2017 +0000
@@ -705,6 +705,14 @@
 		}
 }
 
+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 @@
   { "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 @@
 "      <menuitem action='ShowInfoPixel'/>"
 "      <placeholder name='ToolsSection'/>"
 "      <separator/>"
+"      <menuitem action='Animate'/>"
 "      <menuitem action='SlideShow'/>"
 "      <menuitem action='SlideShowPause'/>"
 "      <menuitem action='Refresh'/>"
@@ -2459,6 +2469,9 @@
 	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);