|
18 | 18 |
|
19 | 19 | public class Scratch.Dialogs.CloseProjectsConfirmationDialog : Granite.MessageDialog { |
20 | 20 |
|
21 | | - public CloseProjectsConfirmationDialog (MainWindow parent) { |
| 21 | + public uint n_parents { get; construct; } |
| 22 | + public uint n_children { get; construct; } |
| 23 | + |
| 24 | + public CloseProjectsConfirmationDialog (MainWindow parent, uint n_parents, uint n_children) { |
22 | 25 | Object ( |
23 | 26 | buttons: Gtk.ButtonsType.NONE, |
24 | | - transient_for: parent |
| 27 | + transient_for: parent, |
| 28 | + n_parents: n_parents, |
| 29 | + n_children: n_children |
25 | 30 | ); |
26 | 31 | } |
27 | 32 |
|
28 | 33 | construct { |
29 | 34 | image_icon = new ThemedIcon ("dialog-warning"); |
| 35 | + var button_label = ""; |
| 36 | + // We can assume that either n_parents or n_children is zero (but not both). |
| 37 | + // We can assume n_parents is either zero or one |
| 38 | + if (n_children > 0) { |
| 39 | + primary_text = ngettext ( |
| 40 | + _("This folder is the parent of an open project"), |
| 41 | + _("This folder is the parent of %u open projects").printf (n_children), |
| 42 | + (ulong) n_children |
| 43 | + ); |
| 44 | + ; |
| 45 | + secondary_text = ngettext ( |
| 46 | + _("Opening this folder will close the child project"), |
| 47 | + _("Opening this folder will close all child projects"), |
| 48 | + (ulong) n_children |
| 49 | + ); |
30 | 50 |
|
31 | | - primary_text = _("This folder is a parent or child of an existing open project"); |
32 | | - secondary_text = _("Opening this folder will close all parent or child projects"); |
| 51 | + button_label = ngettext ( |
| 52 | + _("Close Child Project"), |
| 53 | + _("Close Child Projects"), |
| 54 | + (ulong) n_children |
| 55 | + ); |
| 56 | + } else { |
| 57 | + primary_text = _("This folder is a child of an open project"); |
| 58 | + secondary_text = _("Opening this folder will close the parent project"); |
| 59 | + button_label = _("Close Parent Project"); |
| 60 | + } |
33 | 61 |
|
34 | 62 | add_button (_("Don't Open"), Gtk.ResponseType.REJECT); |
35 | 63 |
|
36 | | - var ignore_button = (Gtk.Button) add_button (_("Close Other Projects"), Gtk.ResponseType.ACCEPT); |
| 64 | + var ignore_button = (Gtk.Button) add_button (button_label, Gtk.ResponseType.ACCEPT); |
37 | 65 | ignore_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION); |
38 | 66 | } |
39 | 67 | } |
0 commit comments