Skip to content

Commit

Permalink
Added confirmation dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
leolost2605 committed Dec 14, 2022
1 parent 8b56449 commit cf97ecb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,9 @@ public class MyApp : Adw.Application {
var bottom_end_box = new Gtk.Box (HORIZONTAL, 0) {halign = END};
bottom_box.append (bottom_end_box);

var edit_subject_button = new EditSubjectButton (i) {margin_end = 20};
var edit_subject_button = new EditSubjectButton (i) {
icon_name = "document-edit-symbolic"
};
bottom_end_box.append (edit_subject_button);


Expand Down
1 change: 0 additions & 1 deletion src/edit-subject-button.vala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ public class EditSubjectButton : Gtk.Button {
public int index;

public EditSubjectButton (int i) {
label = "Edit this subject";
index = i;
halign = END;
}
Expand Down
23 changes: 22 additions & 1 deletion src/edit-subject-dialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ public class EditSubjectDialog : Gtk.Dialog {
};
bottom_box.append (new_cat_button);


main_box.append(new Gtk.Separator(HORIZONTAL));


var bottom_delete_box = new Gtk.Box (HORIZONTAL, 0) {
margin_top = 20,
margin_start = 20,
margin_end = 20,
margin_bottom = 20,
Expand All @@ -63,7 +68,23 @@ public class EditSubjectDialog : Gtk.Dialog {
bottom_delete_box.append(subject_delete_button);

subject_delete_button.clicked.connect (() => {
subject = null;
string n = s.name;
var message_dialog = new Adw.MessageDialog(this, @"Are you sure you want to delete $n?", null);
message_dialog.add_response("0", "Cancel");
message_dialog.add_response("1", "Yes");
message_dialog.set_response_appearance("1", DESTRUCTIVE);
message_dialog.present();
message_dialog.response.connect ((id) => {
switch (id) {
case "0":
break;
case "1":
subject = null;

this.response(Gtk.ResponseType.ACCEPT);
break;
}
});
});

new_cat_button.clicked.connect (() => {
Expand Down

0 comments on commit cf97ecb

Please sign in to comment.