@@ -23,7 +23,7 @@ public class MyApp : Adw.Application {
2323 { " preferences" , this . on_preferences_action },
2424 { " help" , this . on_help_action },
2525 { " about" , this . on_about_action },
26- { " newsubject" , this . on_newsubject_action}
26+ { " newsubject" , this . on_newsubject_action},
2727 };
2828 this . add_action_entries (action_entries, this );
2929 }
@@ -252,11 +252,27 @@ public class MyApp : Adw.Application {
252252
253253
254254 public void edit_subject_dialog (int index ) {
255- var dialog = new EditSubjectDialog (main_window, subjects[index]);
255+ var dialog = new EditSubjectDialog (main_window, subjects[index], this );
256256
257257 dialog. response. connect ((response_id) = > {
258258 if (response_id == Gtk . ResponseType . ACCEPT ) {
259- subjects[index] = dialog. subject;
259+ if (dialog. subject != null ) {
260+ subjects[index] = dialog. subject;
261+ } else {
262+ subjects[index] = null ;
263+
264+ for (int i = index; i < subjects. length - 1 ; i++ ) {
265+ subjects[i] = subjects[i + 1 ];
266+ }
267+
268+ subjects[subjects. length - 1 ] = null ;
269+
270+ if (subjects[index] != null ) {
271+ window_stack_ui (index);
272+ } else {
273+ window_stack_ui (index - 1 );
274+ }
275+ }
260276 }
261277 dialog. destroy ();
262278 });
@@ -351,10 +367,6 @@ public class MyApp : Adw.Application {
351367 var edit_subject_button = new EditSubjectButton (i) {margin_end = 20 };
352368 bottom_end_box. append (edit_subject_button);
353369
354- var delete_subject_button = new DeleteSubjectButton (i);
355- delete_subject_button. add_css_class (" destructive-action" );
356- bottom_end_box. append (delete_subject_button);
357-
358370
359371 // CALL LISTBOX WITH GRADES
360372 window_grade_rows_ui (i);
@@ -369,10 +381,6 @@ public class MyApp : Adw.Application {
369381 new_grade_dialog (new_grade_button. index);
370382 });
371383
372- delete_subject_button. clicked. connect (() = > {
373- delete_subject (delete_subject_button. index);
374- });
375-
376384 edit_subject_button. clicked. connect (() = > {
377385 edit_subject_dialog (edit_subject_button. index);
378386 });
@@ -504,27 +512,6 @@ public class MyApp : Adw.Application {
504512 }
505513
506514
507-
508-
509- public void delete_subject (int index) {
510- subjects[index] = null ;
511-
512- for (int i = index; i < subjects. length - 1 ; i++ ) {
513- subjects[i] = subjects[i + 1 ];
514- }
515-
516- subjects[subjects. length - 1 ] = null ;
517-
518- if (subjects[index] != null ) {
519- window_stack_ui (index);
520- } else {
521- window_stack_ui (index - 1 );
522- }
523- }
524-
525-
526-
527-
528515 protected override void activate () {
529516 main_window = new Adw .ApplicationWindow (this ) {
530517 default_height = 600 ,
0 commit comments