diff --git a/src/Views/ProcessView/ProcessInfoView/Preventor.vala b/src/Views/ProcessView/ProcessInfoView/Preventor.vala index 19d58cde..5b6f50b5 100644 --- a/src/Views/ProcessView/ProcessInfoView/Preventor.vala +++ b/src/Views/ProcessView/ProcessInfoView/Preventor.vala @@ -4,25 +4,28 @@ public class Monitor.Preventor : Gtk.Box { private Gtk.Button confirm_button; private Gtk.Button deny_button; - private Gtk.Widget child_widget; + private Gtk.Stack stack; public signal void confirmed (bool is_confirmed); construct { valign = Gtk.Align.END; + halign = Gtk.Align.END; - preventive_action_bar = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); - preventive_action_bar.valign = Gtk.Align.START; - preventive_action_bar.halign = Gtk.Align.END; - preventive_action_bar.margin_top = 10; + preventive_action_bar = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0){ + valign = Gtk.Align.START, + halign = Gtk.Align.END, + margin_top = 10 + }; + confirmation_label = new Gtk.Label (_("Are you sure you want to do this?")){ + margin_end = 10 + }; - confirmation_label = new Gtk.Label (_("Are you sure you want to do this?")); - confirmation_label.margin_end = 10; - - confirm_button = new Gtk.Button.with_label (_("Yes")); - confirm_button.margin_end = 10; - // confirm_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION); + confirm_button = new Gtk.Button.with_label (_("Yes")) { + margin_end = 10 + }; + confirm_button.add_css_class (Granite.STYLE_CLASS_DESTRUCTIVE_ACTION); deny_button = new Gtk.Button.with_label (_("No")); @@ -31,28 +34,29 @@ public class Monitor.Preventor : Gtk.Box { preventive_action_bar.append (deny_button); } - public Preventor (Gtk.Widget _child, string name) { - child_widget = _child; - append (child_widget); - append (preventive_action_bar); + public Preventor (Gtk.Widget child_widget, string name) { + stack = new Gtk.Stack (); + append (stack); + stack.add_named (child_widget, name); + stack.add_named (preventive_action_bar, "preventive_action_bar"); deny_button.clicked.connect (() => { - // set_transition_type (Gtk.StackTransitionType.SLIDE_UP); - // set_visible_child (child_widget); + stack.set_transition_type (Gtk.StackTransitionType.SLIDE_UP); + stack.set_visible_child (child_widget); confirmed (false); }); confirm_button.clicked.connect (() => { - // set_transition_type (Gtk.StackTransitionType.SLIDE_UP); - // set_visible_child (child_widget); + stack.set_transition_type (Gtk.StackTransitionType.SLIDE_UP); + stack.set_visible_child (child_widget); confirmed (true); }); } public void set_prevention (string confirmation_text) { - // set_transition_type (Gtk.StackTransitionType.SLIDE_DOWN); + stack.set_transition_type (Gtk.StackTransitionType.SLIDE_DOWN); confirmation_label.set_text (_(confirmation_text)); - // set_visible_child (preventive_action_bar); + stack.set_visible_child (preventive_action_bar); preventive_action_bar.visible = true; } diff --git a/src/Views/ProcessView/ProcessInfoView/ProcessInfoView.vala b/src/Views/ProcessView/ProcessInfoView/ProcessInfoView.vala index 58c68700..54917bc9 100644 --- a/src/Views/ProcessView/ProcessInfoView/ProcessInfoView.vala +++ b/src/Views/ProcessView/ProcessInfoView/ProcessInfoView.vala @@ -1,4 +1,5 @@ public class Monitor.ProcessInfoView : Gtk.Box { + private Preventor preventor; private ProcessInfoIOStats process_info_io_stats = new ProcessInfoIOStats (); private Process _process; @@ -21,6 +22,7 @@ public class Monitor.ProcessInfoView : Gtk.Box { process_info_io_stats.hide (); end_process_button.hide (); kill_process_button.hide (); + preventor.hide (); } else { _process.fd_permission_error.connect (show_permission_error_infobar); @@ -37,6 +39,7 @@ public class Monitor.ProcessInfoView : Gtk.Box { process_info_io_stats.set_visible (true); end_process_button.show (); kill_process_button.show (); + preventor.show(); } } } @@ -114,15 +117,24 @@ public class Monitor.ProcessInfoView : Gtk.Box { process_action_bar.append (kill_process_button); append (grid); - append (process_action_bar); + + preventor = new Preventor (process_action_bar, "process_action_bar"); + grid.attach (preventor, 0, 5, 1, 1); + preventor.hide (); kill_process_button.clicked.connect (() => { - process.kill (); // maybe add a toast that process killed + preventor.set_prevention (_("Confirm kill of the process?")); + preventor.confirmed.connect ((is_confirmed) => { + if (is_confirmed) process.kill (); // maybe add a toast that process killed + }); }); end_process_button.clicked.connect (() => { - process.end (); // maybe add a toast that process ended + preventor.set_prevention (_("Confirm end of the process?")); + preventor.confirmed.connect ((is_confirmed) => { + if (is_confirmed) process.end (); // maybe add a toast that process ended + }); }); }