AddButton() 개인적인 메소드

private AddButton ( Gtk button, Gtk response, bool isDefault ) : void
button Gtk
response Gtk
isDefault bool
리턴 void
예제 #1
0
        private void RateLimitedSync ()
        {
            syncing = true;

            bool sync_playlists = false;
            if (dap.SupportsPlaylists) {
                foreach (DapLibrarySync library_sync in library_syncs) {
                    if (library_sync.Library.SupportsPlaylists) {
                        sync_playlists = true;
                        break;
                    }
                }
            }

            if (sync_playlists) {
                dap.RemovePlaylists ();
            }

            foreach (DapLibrarySync library_sync in library_syncs) {
                try {
                    library_sync.Sync ();
                } catch (DapLibrarySync.PossibleUserErrorException e) {

                    string header = String.Format (
                        Catalog.GetPluralString (
                           // singular form unused b/c we know it's > 1, but we still need GetPlural
                           "The sync operation will remove one track from your device.",
                           "The sync operation will remove {0} tracks from your device.",
                           e.TracksToRemove),
                        e.TracksToRemove);
                    string message = Catalog.GetString ("Are you sure you want to continue?");

                    HigMessageDialog md = new HigMessageDialog (
                        ServiceManager.Get<GtkElementsService> ().PrimaryWindow,
                        DialogFlags.DestroyWithParent, MessageType.Warning,
                        ButtonsType.None, header, message
                    );
                    md.AddButton ("gtk-cancel", ResponseType.No, true);
                    md.AddButton (Catalog.GetString ("Remove tracks"), ResponseType.Yes, false);

                    bool remove_tracks = false;
                    ThreadAssist.BlockingProxyToMain (() => {
                        try {
                            if (md.Run () == (int) ResponseType.Yes) {
                                remove_tracks = true;
                            }
                        } finally {
                            md.Destroy ();
                        }
                    });

                    if (remove_tracks) {
                        library_sync.Sync (true);
                    }
                }
            }

            if (sync_playlists) {
                dap.SyncPlaylists ();
            }

            syncing = false;
        }
예제 #2
0
        internal static bool ConfirmUserAction (int tracks_to_remove)
        {
            string header = String.Format (
                Catalog.GetPluralString (
                    // singular form unused b/c we know it's > 1, but we still need GetPlural
                    "The sync operation will remove one track from your device.",
                    "The sync operation will remove {0} tracks from your device.",
                    tracks_to_remove),
                tracks_to_remove);
            string message = Catalog.GetString ("Are you sure you want to continue?");

            var md = new HigMessageDialog (
                ServiceManager.Get<GtkElementsService> ().PrimaryWindow,
                DialogFlags.DestroyWithParent, MessageType.Warning,
                ButtonsType.None, header, message
            );
            md.AddButton ("gtk-cancel", ResponseType.No, true);
            md.AddButton (Catalog.GetString ("Remove tracks"), ResponseType.Yes, false);

            bool remove_tracks = false;
            ThreadAssist.BlockingProxyToMain (() => {
                try {
                    if (md.Run () == (int) ResponseType.Yes) {
                        remove_tracks = true;
                    }
                } finally {
                    md.Destroy ();
                }
            });
            return remove_tracks;
        }
예제 #3
0
        private static bool ConfirmRemove (bool delete)
        {
            bool ret = false;
            string header = null;
            string message = null;
            string button_label = null;

            if (delete) {
                header = AddinManager.CurrentLocalizer.GetString (
                    "Are you sure you want to permanently delete the selected items?");
                message = AddinManager.CurrentLocalizer.GetString (
                    "If you delete the selection, it will be permanently lost.");
                button_label = "gtk-delete";
            } else {
                header = AddinManager.CurrentLocalizer.GetString (
                    "Remove selection from Library?");
                message = AddinManager.CurrentLocalizer.GetString (
                    "Are you sure you want to remove the selected items from your Library?");
                button_label = "gtk-remove";
            }

            HigMessageDialog md = new HigMessageDialog (ServiceManager.Get<GtkElementsService> ().PrimaryWindow,
                DialogFlags.DestroyWithParent, delete ? MessageType.Warning : MessageType.Question,
                ButtonsType.None, header, message);
            // Delete from Disk defaults to Cancel and the others to OK/Confirm.
            md.AddButton ("gtk-cancel", ResponseType.No, delete);
            md.AddButton (button_label, ResponseType.Yes, !delete);
            
            try {
                if (md.Run () == (int)ResponseType.Yes) {
                    ret = true;
                }
            } finally {
                md.Destroy ();
            }
            return ret;
        }