Skip to content

Commit

Permalink
GIF animation settings
Browse files Browse the repository at this point in the history
Preserve GIF animation setting between sessions
Include GIF animation on View menu. Shortcut key is "A"
  • Loading branch information
Colin Clark committed Jan 18, 2017
1 parent 2bb1e27 commit 7819394
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion src/layout_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions src/layout_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
13 changes: 13 additions & 0 deletions src/layout_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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[] = {
Expand Down Expand Up @@ -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'/>"
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 7819394

Please sign in to comment.