diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2021-12-19 05:33:57 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2021-12-19 05:37:11 +0100 |
commit | 6e903f6f5cf69e3e8a7edb6cb93e07429ad6c372 (patch) | |
tree | 93468c0d65dd70d4e8aaf2244e6e4eda78928f14 /fiv-view.c | |
parent | e23ed245db960b12e0974f5f091c300a2fb8b9ac (diff) | |
download | fiv-6e903f6f5cf69e3e8a7edb6cb93e07429ad6c372.tar.gz fiv-6e903f6f5cf69e3e8a7edb6cb93e07429ad6c372.tar.xz fiv-6e903f6f5cf69e3e8a7edb6cb93e07429ad6c372.zip |
Add a playback toggle button
Diffstat (limited to 'fiv-view.c')
-rw-r--r-- | fiv-view.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -88,6 +88,7 @@ enum { PROP_SCALE = 1, PROP_SCALE_TO_FIT, PROP_FILTER, + PROP_PLAYING, N_PROPERTIES }; @@ -117,6 +118,9 @@ fiv_view_get_property( case PROP_FILTER: g_value_set_boolean(value, self->filter); break; + case PROP_PLAYING: + g_value_set_boolean(value, !!self->frame_update_connection); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); } @@ -472,6 +476,7 @@ stop_animating(FivView *self) self->frame_time = 0; self->frame_update_connection = 0; self->remaining_loops = 0; + g_object_notify_by_pspec(G_OBJECT(self), view_properties[PROP_PLAYING]); } static gboolean @@ -546,6 +551,7 @@ start_animating(FivView *self) (uintptr_t) cairo_surface_get_user_data(self->page, &fiv_io_key_loops); gdk_frame_clock_begin_updating(clock); + g_object_notify_by_pspec(G_OBJECT(self), view_properties[PROP_PLAYING]); } static void @@ -790,6 +796,8 @@ fiv_view_key_press_event(GtkWidget *widget, GdkEventKey *event) return command(self, FIV_VIEW_COMMAND_FRAME_PREVIOUS); case GDK_KEY_braceright: return command(self, FIV_VIEW_COMMAND_FRAME_NEXT); + case GDK_KEY_space: + return command(self, FIV_VIEW_COMMAND_TOGGLE_PLAYBACK); } return FALSE; } @@ -811,6 +819,9 @@ fiv_view_class_init(FivViewClass *klass) view_properties[PROP_FILTER] = g_param_spec_boolean( "filter", "Use filtering", "Scale images smoothly", TRUE, G_PARAM_READWRITE); + view_properties[PROP_PLAYING] = g_param_spec_boolean( + "playing", "Playing animation", "An animation is running", + TRUE, G_PARAM_READWRITE); g_object_class_install_properties( object_class, N_PROPERTIES, view_properties); @@ -918,6 +929,10 @@ fiv_view_command(FivView *self, FivViewCommand command) frame_step(self, -1); break; case FIV_VIEW_COMMAND_FRAME_NEXT: frame_step(self, +1); + break; case FIV_VIEW_COMMAND_TOGGLE_PLAYBACK: + self->frame_update_connection + ? stop_animating(self) + : start_animating(self); break; case FIV_VIEW_COMMAND_TOGGLE_FILTER: self->filter = !self->filter; |