Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/EventEdition/EventDialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,8 @@ public class EventDialog : Granite.Dialog {

delete_dialog.response.connect ((response) => {
if (response == Gtk.ResponseType.YES) {
destroy ();
close ();
}

delete_dialog.destroy ();
});

delete_dialog.present ();
Expand Down
63 changes: 29 additions & 34 deletions src/Widgets/DeleteDialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,62 @@ class Calendar.DeleteEventDialog : Granite.MessageDialog {
public E.Source? source { get; construct; }
public ECal.Component ecal_event { get; construct; }
public ECal.ObjModType mod_type_prop { get; construct; }
public string delete_button_text {get; construct; }

public DeleteEventDialog (E.Source? source, ECal.Component ecal_event, ECal.ObjModType mod_type_prop) {
string title, description, delete_text;
Object (
source: source,
ecal_event: ecal_event,
mod_type_prop: mod_type_prop,
image_icon: new ThemedIcon ("dialog-warning"),
buttons: Gtk.ButtonsType.CANCEL
);
}

construct {
string delete_text;
var summary = ecal_event.get_summary ();
if (ecal_event.has_recurrences ()) {
if (mod_type_prop == ECal.ObjModType.THIS) {
if (summary == null) {
title = _("Delete this occurrence of event?");
primary_text = _("Delete this occurrence of event?");
} else {
title = _("Delete this occurrence of event “%s”?").printf (((!)summary).get_value ()); // Should question mark be in or out of quotes?
primary_text = _("Delete this occurrence of event “%s”?").printf (((!)summary).get_value ());
}
description = _("This occurrence will be permanently deleted, but all other occurrences will remain unchanged.");
secondary_text = _("This occurrence will be permanently deleted, but all other occurrences will remain unchanged.");
delete_text = _("Delete Occurrence");
} else {
if (mod_type_prop != ECal.ObjModType.ALL) {
warning (@"Creating delete dialog for unknown ObjModType: $mod_type_prop; defaulting to modify all");
}

if (summary == null) {
title = _("Delete event?");
primary_text = _("Delete event?");
} else {
title = _("Delete event “%s”?").printf (((!)summary).get_value ()); // Should question mark be in or out of quotes?
primary_text = _("Delete event “%s”?").printf (((!)summary).get_value ()); // Should question mark be in or out of quotes?
}
description = _("This event and all its occurrences will be permanently deleted.");
secondary_text = _("This event and all its occurrences will be permanently deleted.");
delete_text = _("Delete Event");
}
} else {
if (summary == null) {
title = _("Delete event?");
primary_text = _("Delete event?");
} else {
title = _("Delete event “%s”?").printf (((!)summary).get_value ()); // Should question mark be in or out of quotes?
primary_text = _("Delete event “%s”?").printf (((!)summary).get_value ()); // Should question mark be in or out of quotes?
}
description = _("This event will be permanently deleted.");
secondary_text = _("This event will be permanently deleted.");
delete_text = _("Delete Event");
}

Object (
source: source,
ecal_event: ecal_event,
mod_type_prop: mod_type_prop,
primary_text: title,
secondary_text: description,
image_icon: new ThemedIcon ("dialog-warning"),
buttons: Gtk.ButtonsType.CANCEL,
delete_button_text: delete_text
);
}

construct {
unowned var trash_button = add_button (delete_button_text, Gtk.ResponseType.YES);
unowned var trash_button = add_button (delete_text, Gtk.ResponseType.YES);
trash_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
}

public Gtk.ResponseType run_dialog () {
var response = (Gtk.ResponseType) this.run ();
if (response == Gtk.ResponseType.YES) {
var calmodel = Calendar.EventStore.get_default ();
calmodel.remove_event (source, ecal_event, mod_type_prop);
}
this.destroy ();
return response;
response.connect ((response) => {
if (response == Gtk.ResponseType.YES) {
var calmodel = Calendar.EventStore.get_default ();
calmodel.remove_event (source, ecal_event, mod_type_prop);
}

close ();
});
}
}
4 changes: 2 additions & 2 deletions src/Widgets/EventMenu.vala
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace Maya.EventMenu {
var delete_dialog = new Calendar.DeleteEventDialog (source, comp, ECal.ObjModType.ALL) {
transient_for = application.active_window
};
delete_dialog.run_dialog ();
delete_dialog.present ();
}

private static void add_exception (ECal.Component comp) {
Expand All @@ -72,6 +72,6 @@ namespace Maya.EventMenu {
var delete_dialog = new Calendar.DeleteEventDialog (source, comp, ECal.ObjModType.THIS) {
transient_for = application.active_window
};
delete_dialog.run_dialog ();
delete_dialog.present ();
}
}