@@ -156,6 +156,11 @@ static void switch_mode_to_arrow(struct swappy_state *state) {
156156 gtk_widget_set_sensitive (GTK_WIDGET (state -> ui -> fill_shape ), false);
157157}
158158
159+ static void switch_mode_to_line (struct swappy_state * state ) {
160+ state -> mode = SWAPPY_PAINT_MODE_LINE ;
161+ gtk_widget_set_sensitive (GTK_WIDGET (state -> ui -> fill_shape ), false);
162+ }
163+
159164static void switch_mode_to_blur (struct swappy_state * state ) {
160165 state -> mode = SWAPPY_PAINT_MODE_BLUR ;
161166 gtk_widget_set_sensitive (GTK_WIDGET (state -> ui -> fill_shape ), false);
@@ -302,6 +307,10 @@ void arrow_clicked_handler(GtkWidget *widget, struct swappy_state *state) {
302307 switch_mode_to_arrow (state );
303308}
304309
310+ void line_clicked_handler (GtkWidget * widget , struct swappy_state * state ) {
311+ switch_mode_to_line (state );
312+ }
313+
305314void blur_clicked_handler (GtkWidget * widget , struct swappy_state * state ) {
306315 switch_mode_to_blur (state );
307316}
@@ -374,6 +383,7 @@ void window_keypress_handler(GtkWidget *widget, GdkEventKey *event,
374383 case GDK_KEY_Escape :
375384 case GDK_KEY_q :
376385 maybe_save_output_file (state );
386+ state -> exit_code = 1 ;
377387 gtk_main_quit ();
378388 break ;
379389 case GDK_KEY_b :
@@ -398,6 +408,10 @@ void window_keypress_handler(GtkWidget *widget, GdkEventKey *event,
398408 switch_mode_to_arrow (state );
399409 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state -> ui -> arrow ), true);
400410 break ;
411+ case GDK_KEY_l :
412+ switch_mode_to_line (state );
413+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state -> ui -> line ), true);
414+ break ;
401415 case GDK_KEY_d :
402416 switch_mode_to_blur (state );
403417 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state -> ui -> blur ), true);
@@ -524,6 +538,7 @@ void draw_area_button_press_handler(GtkWidget *widget, GdkEventButton *event,
524538 case SWAPPY_PAINT_MODE_RECTANGLE :
525539 case SWAPPY_PAINT_MODE_ELLIPSE :
526540 case SWAPPY_PAINT_MODE_ARROW :
541+ case SWAPPY_PAINT_MODE_LINE :
527542 case SWAPPY_PAINT_MODE_TEXT :
528543 paint_add_temporary (state , x , y , state -> mode );
529544 render_state (state );
@@ -554,6 +569,7 @@ void draw_area_motion_notify_handler(GtkWidget *widget, GdkEventMotion *event,
554569 case SWAPPY_PAINT_MODE_RECTANGLE :
555570 case SWAPPY_PAINT_MODE_ELLIPSE :
556571 case SWAPPY_PAINT_MODE_ARROW :
572+ case SWAPPY_PAINT_MODE_LINE :
557573 if (is_button1_pressed ) {
558574 paint_update_temporary_shape (state , x , y , is_control_pressed );
559575 render_state (state );
@@ -765,6 +781,8 @@ static bool load_layout(struct swappy_state *state) {
765781 GTK_RADIO_BUTTON (gtk_builder_get_object (builder , "ellipse" ));
766782 GtkRadioButton * arrow =
767783 GTK_RADIO_BUTTON (gtk_builder_get_object (builder , "arrow" ));
784+ GtkRadioButton * line =
785+ GTK_RADIO_BUTTON (gtk_builder_get_object (builder , "line" ));
768786 GtkRadioButton * blur =
769787 GTK_RADIO_BUTTON (gtk_builder_get_object (builder , "blur" ));
770788
@@ -795,6 +813,7 @@ static bool load_layout(struct swappy_state *state) {
795813 state -> ui -> rectangle = rectangle ;
796814 state -> ui -> ellipse = ellipse ;
797815 state -> ui -> arrow = arrow ;
816+ state -> ui -> line = line ;
798817 state -> ui -> blur = blur ;
799818 state -> ui -> area = area ;
800819 state -> ui -> window = window ;
@@ -832,6 +851,10 @@ static void set_paint_mode(struct swappy_state *state) {
832851 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state -> ui -> arrow ), true);
833852 gtk_widget_set_sensitive (GTK_WIDGET (state -> ui -> fill_shape ), false);
834853 break ;
854+ case SWAPPY_PAINT_MODE_LINE :
855+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state -> ui -> line ), true);
856+ gtk_widget_set_sensitive (GTK_WIDGET (state -> ui -> fill_shape ), false);
857+ break ;
835858 case SWAPPY_PAINT_MODE_BLUR :
836859 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state -> ui -> blur ), true);
837860 gtk_widget_set_sensitive (GTK_WIDGET (state -> ui -> fill_shape ), false);
0 commit comments