Commit 4f705fec authored by Michael Terry's avatar Michael Terry

Make some window management fixes

- Default buttons in dialogs are now appropriately styled.
- When launching deja-dup with an existing hidden operation dialog
  (like happens when an autolaunched backup starts), we'll show the
  dialog instead of the preference window.
- When lauching an operation dialog while the preferences window
  is open, we mark the dialog as a modal child window, so the window
  manager can pair them correctly.
- When deja-dup is terminated unexpectedly, try harder to kill child
  duplicity processes.
parent 569ec2b5
Pipeline #49533 passed with stage
in 6 minutes and 11 seconds
......@@ -289,6 +289,12 @@ public abstract class Assistant : Gtk.Window
return btn;
}
void make_button_default(Gtk.Widget button)
{
button.grab_default();
button.get_style_context().add_class(Gtk.STYLE_CLASS_SUGGESTED_ACTION);
}
void set_buttons()
{
return_if_fail(current != null);
......@@ -349,13 +355,13 @@ public abstract class Assistant : Gtk.Window
if (show_forward) {
forward_button = add_button(info.forward_text, FORWARD);
if (!has_default)
forward_button.grab_default();
make_button_default(forward_button);
has_default = true;
}
if (show_resume) {
resume_button = add_button(_("_Resume Later"), RESUME);
if (!has_default)
resume_button.grab_default();
make_button_default(resume_button);
has_default = true;
}
if (show_back)
......@@ -363,7 +369,7 @@ public abstract class Assistant : Gtk.Window
if (show_close) {
close_button = add_button(_("_Close"), CLOSE);
if (!has_default)
close_button.grab_default();
make_button_default(close_button);
has_default = true;
}
if (show_cancel)
......
......@@ -714,6 +714,13 @@ public abstract class AssistantOperation : Assistant
}
}
public void stop()
{
hide_everything();
if (op != null)
op.stop();
}
protected virtual void do_cancel()
{
hide_everything();
......
......@@ -152,7 +152,9 @@ public class DejaDupApp : Gtk.Application
{
base.activate();
if (main_window != null)
if (op != null)
op.present_with_time(Gtk.get_current_event_time());
else if (main_window != null)
main_window.present_with_time(Gtk.get_current_event_time());
else {
// We're first instance. Yay!
......@@ -188,6 +190,12 @@ public class DejaDupApp : Gtk.Application
}
}
bool exit_cleanly()
{
quit();
return Source.REMOVE;
}
public override void startup()
{
base.startup();
......@@ -202,6 +210,17 @@ public class DejaDupApp : Gtk.Application
set_accels_for_action("app.help", {"F1"});
set_accels_for_action("app.quit", {"<Primary>q"});
quit_action = lookup_action("quit") as SimpleAction;
// Cleanly exit (shutting down duplicity as we go)
Unix.signal_add(ProcessSignal.HUP, exit_cleanly);
Unix.signal_add(ProcessSignal.INT, exit_cleanly);
Unix.signal_add(ProcessSignal.TERM, exit_cleanly);
}
public override void shutdown()
{
if (op != null)
op.stop();
}
void clear_op()
......@@ -221,6 +240,15 @@ public class DejaDupApp : Gtk.Application
this.op.destroy.connect(clear_op);
quit_action.set_enabled(false);
register_window(op);
if (main_window != null) {
op.transient_for = main_window;
op.modal = true;
op.destroy_with_parent = true;
op.type_hint = Gdk.WindowTypeHint.DIALOG;
main_window.present_with_time(Gtk.get_current_event_time());
}
op.show_all();
Gdk.notify_startup_complete();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment