@@ -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}
@@ -398,6 +407,10 @@ void window_keypress_handler(GtkWidget *widget, GdkEventKey *event,
398407 switch_mode_to_arrow (state );
399408 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state -> ui -> arrow ), true);
400409 break ;
410+ case GDK_KEY_l :
411+ switch_mode_to_line (state );
412+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state -> ui -> line ), true);
413+ break ;
401414 case GDK_KEY_d :
402415 switch_mode_to_blur (state );
403416 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state -> ui -> blur ), true);
@@ -524,6 +537,7 @@ void draw_area_button_press_handler(GtkWidget *widget, GdkEventButton *event,
524537 case SWAPPY_PAINT_MODE_RECTANGLE :
525538 case SWAPPY_PAINT_MODE_ELLIPSE :
526539 case SWAPPY_PAINT_MODE_ARROW :
540+ case SWAPPY_PAINT_MODE_LINE :
527541 case SWAPPY_PAINT_MODE_TEXT :
528542 paint_add_temporary (state , x , y , state -> mode );
529543 render_state (state );
@@ -554,6 +568,7 @@ void draw_area_motion_notify_handler(GtkWidget *widget, GdkEventMotion *event,
554568 case SWAPPY_PAINT_MODE_RECTANGLE :
555569 case SWAPPY_PAINT_MODE_ELLIPSE :
556570 case SWAPPY_PAINT_MODE_ARROW :
571+ case SWAPPY_PAINT_MODE_LINE :
557572 if (is_button1_pressed ) {
558573 paint_update_temporary_shape (state , x , y , is_control_pressed );
559574 render_state (state );
@@ -582,6 +597,7 @@ void draw_area_button_release_handler(GtkWidget *widget, GdkEventButton *event,
582597 case SWAPPY_PAINT_MODE_RECTANGLE :
583598 case SWAPPY_PAINT_MODE_ELLIPSE :
584599 case SWAPPY_PAINT_MODE_ARROW :
600+ case SWAPPY_PAINT_MODE_LINE :
585601 commit_state (state );
586602 break ;
587603 case SWAPPY_PAINT_MODE_TEXT :
@@ -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