diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 10e02af36..2c77c8764 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -1055,34 +1055,31 @@ namespace Scratch { // Persist last entries (not necessarily valid) Scratch.settings.set_string ("default-remote", clone_dialog.get_remote ()); Scratch.settings.set_string ("default-projects-folder", clone_dialog.get_projects_folder ()); - // Clone dialog show spinner during cloning so keep visible //TODO Show more information re progress using Ggit callbacks if (res == Gtk.ResponseType.APPLY && clone_dialog.can_clone) { - clone_dialog.cloning_in_progress = true; + sidebar.cloning_in_progress = true; + clone_dialog.hide (); var uri = clone_dialog.get_valid_source_repository_uri (); var target = clone_dialog.get_valid_target (); git_manager.clone_repository.begin ( uri, target, (obj, res) => { - clone_dialog.cloning_in_progress = false; + sidebar.cloning_in_progress = false; File? workdir = null; string? error = null; if (git_manager.clone_repository.end (res, out workdir, out error)) { open_folder (workdir); clone_dialog.destroy (); - var message_dialog = new Granite.MessageDialog.with_image_from_icon_name ( - _("Repository %s successfully cloned").printf (uri), - _("Local repository working directory is %s").printf (workdir.get_uri ()), - "dialog-information", - Gtk.ButtonsType.CLOSE - ) { - transient_for = this - }; - message_dialog.response.connect (message_dialog.destroy); - message_dialog.present (); + if (this.is_active) { + sidebar.notify_cloning_success (); + } else { + var notification = new Notification (_("Cloning completed")); + notification.set_body (_("Clone successfully created in %s").printf (target)); + notification.set_icon (new ThemedIcon ("process-completed-symbolic")); + app.send_notification ("cloning-finished-%s".printf (target), notification); + } } else { - clone_dialog.hide (); var message_dialog = new Granite.MessageDialog.with_image_from_icon_name ( _("Unable to clone %s").printf (uri), error, diff --git a/src/Widgets/ChooseProjectButton.vala b/src/Widgets/ChooseProjectButton.vala index 3b035c5b2..7c6c658bb 100644 --- a/src/Widgets/ChooseProjectButton.vala +++ b/src/Widgets/ChooseProjectButton.vala @@ -17,6 +17,8 @@ */ public class Code.ChooseProjectButton : Gtk.MenuButton { + public bool cloning_in_progress { get; set; } + private const string NO_PROJECT_SELECTED = N_("No Project Selected"); private const string PROJECT_TOOLTIP = N_("Active Git Project: %s"); private Gtk.Label label_widget; @@ -32,15 +34,23 @@ public class Code.ChooseProjectButton : Gtk.MenuButton { label_widget = new Gtk.Label (_(NO_PROJECT_SELECTED)) { ellipsize = Pango.EllipsizeMode.MIDDLE, - xalign = 0.0f + xalign = 0.0f, + hexpand = true + }; + + var cloning_spinner = new Gtk.Spinner () { + halign = END }; + bind_property ("cloning-in-progress", cloning_spinner, "active"); - var grid = new Gtk.Grid () { - halign = Gtk.Align.START + var box = new Gtk.Box (HORIZONTAL, 3) { + hexpand = true, + vexpand = false }; - grid.add (img); - grid.add (label_widget); - add (grid); + box.add (img); + box.add (label_widget); + box.add (cloning_spinner); + add (box); project_listbox = new Gtk.ListBox () { selection_mode = Gtk.SelectionMode.SINGLE diff --git a/src/Widgets/Sidebar.vala b/src/Widgets/Sidebar.vala index ff3060cf4..89c604cf4 100644 --- a/src/Widgets/Sidebar.vala +++ b/src/Widgets/Sidebar.vala @@ -26,8 +26,19 @@ public class Code.Sidebar : Gtk.Grid { public Code.ChooseProjectButton choose_project_button { get; private set; } public Hdy.HeaderBar headerbar { get; private set; } public GLib.MenuModel project_menu_model { get; construct; } + // May show progress in different way in future + public bool cloning_in_progress { + get { + return choose_project_button.cloning_in_progress; + } + + set { + choose_project_button.cloning_in_progress = value; + } + } private Gtk.StackSwitcher stack_switcher; + private Granite.Widgets.Toast cloning_success_toast; construct { orientation = Gtk.Orientation.VERTICAL; @@ -38,6 +49,10 @@ public class Code.Sidebar : Gtk.Grid { valign = Gtk.Align.CENTER }; + cloning_success_toast = new Granite.Widgets.Toast (_("Cloning complete")) { + halign = END + }; + headerbar = new Hdy.HeaderBar () { custom_title = choose_project_button, show_close_button = true @@ -80,6 +95,7 @@ public class Code.Sidebar : Gtk.Grid { actionbar.pack_start (project_menu_button); add (headerbar); + add (cloning_success_toast); add (stack_switcher); add (stack); add (actionbar); @@ -161,4 +177,8 @@ public class Code.Sidebar : Gtk.Grid { public void remove_tab (Code.PaneSwitcher tab) { stack.remove (tab); } + + public void notify_cloning_success () { + cloning_success_toast.send_notification (); + } }