From 2bdab684e1eace53ad7b78414ad467d312dc10ad Mon Sep 17 00:00:00 2001 From: Jeremy Attali Date: Thu, 26 Dec 2019 12:19:47 -0500 Subject: [PATCH] feat(ui): add binding for clear action --- src/application.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/application.c b/src/application.c index 212fc53..e3d9a31 100644 --- a/src/application.c +++ b/src/application.c @@ -45,6 +45,12 @@ static void action_redo(struct swappy_state *state) { } } +static void action_clear(struct swappy_state *state) { + paint_free_all(state); + render_state(state); + update_ui(state); +} + static void action_toggle_painting_pane(struct swappy_state *state) { GtkWidget *painting_box = GTK_WIDGET(state->ui->painting_box); gboolean is_visible = gtk_widget_get_visible(painting_box); @@ -147,9 +153,7 @@ void save_clicked_handler(GtkWidget *widget, struct swappy_state *state) { } void clear_clicked_handler(GtkWidget *widget, struct swappy_state *state) { - paint_free_all(state); - render_state(state); - update_ui(state); + action_clear(state); } void copy_clicked_handler(GtkWidget *widget, struct swappy_state *state) { @@ -189,6 +193,9 @@ void window_keypress_handler(GtkWidget *widget, GdkEventKey *event, switch_mode_to_arrow(state); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(state->ui->arrow), true); break; + case GDK_KEY_k: + action_clear(state); + break; default: break; }