Skip to content

Commit cf97ecb

Browse files
committed
Added confirmation dialog
1 parent 8b56449 commit cf97ecb

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

src/application.vala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,9 @@ public class MyApp : Adw.Application {
364364
var bottom_end_box = new Gtk.Box (HORIZONTAL, 0) {halign = END};
365365
bottom_box.append (bottom_end_box);
366366

367-
var edit_subject_button = new EditSubjectButton (i) {margin_end = 20};
367+
var edit_subject_button = new EditSubjectButton (i) {
368+
icon_name = "document-edit-symbolic"
369+
};
368370
bottom_end_box.append (edit_subject_button);
369371

370372

src/edit-subject-button.vala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ public class EditSubjectButton : Gtk.Button {
22
public int index;
33

44
public EditSubjectButton (int i) {
5-
label = "Edit this subject";
65
index = i;
76
halign = END;
87
}

src/edit-subject-dialog.vala

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ public class EditSubjectDialog : Gtk.Dialog {
4848
};
4949
bottom_box.append (new_cat_button);
5050

51+
52+
main_box.append(new Gtk.Separator(HORIZONTAL));
53+
54+
5155
var bottom_delete_box = new Gtk.Box (HORIZONTAL, 0) {
56+
margin_top = 20,
5257
margin_start = 20,
5358
margin_end = 20,
5459
margin_bottom = 20,
@@ -63,7 +68,23 @@ public class EditSubjectDialog : Gtk.Dialog {
6368
bottom_delete_box.append(subject_delete_button);
6469

6570
subject_delete_button.clicked.connect (() => {
66-
subject = null;
71+
string n = s.name;
72+
var message_dialog = new Adw.MessageDialog(this, @"Are you sure you want to delete $n?", null);
73+
message_dialog.add_response("0", "Cancel");
74+
message_dialog.add_response("1", "Yes");
75+
message_dialog.set_response_appearance("1", DESTRUCTIVE);
76+
message_dialog.present();
77+
message_dialog.response.connect ((id) => {
78+
switch (id) {
79+
case "0":
80+
break;
81+
case "1":
82+
subject = null;
83+
84+
this.response(Gtk.ResponseType.ACCEPT);
85+
break;
86+
}
87+
});
6788
});
6889

6990
new_cat_button.clicked.connect (() => {

0 commit comments

Comments
 (0)