<commit_before>//
// TrackActions.cs
//
// Author:
//   <NAME> <<EMAIL>>
//
// Copyright (C) 2007-2008 Novell, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

using System;
using System.Collections.Generic;
using Mono.Unix;
using Gtk;

using Hyena;
using Hyena.Widgets;

using Banshee.Query;
using Banshee.Sources;
using Banshee.Library;
using Banshee.Playlist;
using Banshee.Collection;
using Banshee.Collection.Database;
using Banshee.ServiceStack;
using Banshee.Widgets;
using Banshee.Gui;
using Banshee.Gui.Dialogs;
using Banshee.Gui.Widgets;
using Hyena.Data;

namespace Banshee.Gui
{
    public class TrackActions : BansheeActionGroup
    {
        private RatingActionProxy rating_proxy;

        private static readonly string [] require_selection_actions = new string [] {
            "TrackPropertiesAction", "AddToPlaylistAction",
            "RemoveTracksAction", "RemoveTracksFromLibraryAction", "OpenContainingFolderAction",
            "DeleteTracksFromDriveAction", "RateTracksAction", "SelectNoneAction", "PlayTrack"
        };

        private static readonly string [] disable_for_filter_actions = new string [] {
            "SelectAllAction", "SelectNoneAction", "SearchMenuAction",
            // FIXME should be able to do this, just need to implement it
            "RateTracksAction"
        };

        private Hyena.Collections.Selection filter_selection = new Hyena.Collections.Selection ();

        private bool filter_focused;
        public bool FilterFocused {
            get { return filter_focused; }
            set {
                if (filter_focused == value)
                    return;

                filter_focused = value;
                if (value) {
                    Selection = filter_selection;
                    SuppressSelectActions ();
                } else {
                    Selection = current_source.TrackModel.Selection;
                    UnsuppressSelectActions ();
                }

                UpdateActions ();
                OnSelectionChanged ();
            }
        }

        public event EventHandler SelectionChanged;

        public Hyena.Collections.Selection Selection { get; private set; }

        public ModelSelection<TrackInfo> SelectedTracks {
            get {
                return FilterFocused
                    ? new ModelSelection<TrackInfo> (current_source.TrackModel, Selection)
                    : current_source.TrackModel.SelectedItems;
            }
        }

        public TrackActions () : base ("Track")
        {
            Add (new ActionEntry [] {
                new ActionEntry("TrackContextMenuAction", null,
                    String.Empty, null, null, OnTrackContextMenu),

                new ActionEntry("SelectAllAction", null,
                    Catalog.GetString("Select _All"), "<control>A",
                    Catalog.GetString("Select all tracks"), OnSelectAll),

                new ActionEntry("SelectNoneAction", null,
                    Catalog.GetString("Select _None"), "<control><shift>A",
                    Catalog.GetString("Unselect all tracks"), OnSelectNone),

                new ActionEntry ("TrackEditorAction", Stock.Edit,
                    Catalog.GetString ("_Edit Track Information"), "E",
                    Catalog.GetString ("Edit information on selected tracks"), OnTrackEditor),

                new ActionEntry ("TrackPropertiesAction", Stock.Properties,
                    Catalog.GetString ("Properties"), null,
                    Catalog.GetString ("View information on selected tracks"), OnTrackProperties),

                new ActionEntry ("PlayTrack", null,
                    Catalog.GetString ("_Play"), null,
                    Catalog.GetString ("Play the selected item"), OnPlayTrack),

                new ActionEntry ("AddToPlaylistAction", null,
                    Catalog.GetString ("Add _to Playlist"), null,
                    Catalog.GetString ("Append selected items to playlist or create new playlist from selection"),
                    OnAddToPlaylistMenu),

                new ActionEntry ("AddToNewPlaylistAction", Stock.New,
                    Catalog.GetString ("New Playlist"), null,
                    Catalog.GetString ("Create new playlist from selected tracks"),
                    OnAddToNewPlaylist),

                new ActionEntry ("RemoveTracksAction", Stock.Remove,
                    Catalog.GetString ("_Remove"), "Delete",
                    Catalog.GetString ("Remove selected track(s) from this source"), OnRemoveTracks),

                new ActionEntry ("RemoveTracksFromLibraryAction", null,
                    Catalog.GetString ("Remove From _Library"), "",
                    Catalog.GetString ("Remove selected track(s) from library"), OnRemoveTracksFromLibrary),

                new ActionEntry ("OpenContainingFolderAction", null,
                    Catalog.GetString ("_Open Containing Folder"), null,
                    Catalog.GetString ("Open the folder that contains the selected item"), OnOpenContainingFolder),

                new ActionEntry ("DeleteTracksFromDriveAction", null,
                    Catalog.GetString ("_Delete From Drive"), null,
                    Catalog.GetString ("Permanently delete selected item(s) from medium"), OnDeleteTracksFromDrive),

                new ActionEntry ("RateTracksAction", null,
                    String.Empty, null, null, OnRateTracks),

                new ActionEntry ("SearchMenuAction", Stock.Find,
                    Catalog.GetString ("_Search"), null,
                    Catalog.GetString ("Search for items matching certain criteria"), null),

                new ActionEntry ("SearchForSameAlbumAction", null,
                    Catalog.GetString ("By Matching _Album"), null,
                    Catalog.GetString ("Search all songs of this album"), OnSearchForSameAlbum),

                new ActionEntry ("SearchForSameArtistAction", null,
                    Catalog.GetString ("By Matching A_rtist"), null,
                    Catalog.GetString ("Search all songs of this artist"), OnSearchForSameArtist),
            });

            Actions.UIManager.ActionsChanged += HandleActionsChanged;

            Actions.GlobalActions["EditMenuAction"].Activated += HandleEditMenuActivated;
            ServiceManager.SourceManager.ActiveSourceChanged += HandleActiveSourceChanged;<commit_msg>TrackActions: Use "" instead of null for empty accels (bgo#657565)<commit_after>//
// TrackActions.cs
//
// Author:
//   <NAME> <<EMAIL>>
//
// Copyright (C) 2007-2008 Novell, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

using System;
using System.Collections.Generic;
using Mono.Unix;
using Gtk;

using Hyena;
using Hyena.Widgets;

using Banshee.Query;
using Banshee.Sources;
using Banshee.Library;
using Banshee.Playlist;
using Banshee.Collection;
using Banshee.Collection.Database;
using Banshee.ServiceStack;
using Banshee.Widgets;
using Banshee.Gui;
using Banshee.Gui.Dialogs;
using Banshee.Gui.Widgets;
using Hyena.Data;

namespace Banshee.Gui
{
    public class TrackActions : BansheeActionGroup
    {
        private RatingActionProxy rating_proxy;

        private static readonly string [] require_selection_actions = new string [] {
            "TrackPropertiesAction", "AddToPlaylistAction",
            "RemoveTracksAction", "RemoveTracksFromLibraryAction", "OpenContainingFolderAction",
            "DeleteTracksFromDriveAction", "RateTracksAction", "SelectNoneAction", "PlayTrack"
        };

        private static readonly string [] disable_for_filter_actions = new string [] {
            "SelectAllAction", "SelectNoneAction", "SearchMenuAction",
            // FIXME should be able to do this, just need to implement it
            "RateTracksAction"
        };

        private Hyena.Collections.Selection filter_selection = new Hyena.Collections.Selection ();

        private bool filter_focused;
        public bool FilterFocused {
            get { return filter_focused; }
            set {
                if (filter_focused == value)
                    return;

                filter_focused = value;
                if (value) {
                    Selection = filter_selection;
                    SuppressSelectActions ();
                } else {
                    Selection = current_source.TrackModel.Selection;
                    UnsuppressSelectActions ();
                }

                UpdateActions ();
                OnSelectionChanged ();
            }
        }

        public event EventHandler SelectionChanged;

        public Hyena.Collections.Selection Selection { get; private set; }

        public ModelSelection<TrackInfo> SelectedTracks {
            get {
                return FilterFocused
                    ? new ModelSelection<TrackInfo> (current_source.TrackModel, Selection)
                    : current_source.TrackModel.SelectedItems;
            }
        }

        public TrackActions () : base ("Track")
        {
            Add (new ActionEntry [] {
                new ActionEntry("TrackContextMenuAction", null,
                    String.Empty, null, null, OnTrackContextMenu),

                new ActionEntry("SelectAllAction", null,
                    Catalog.GetString("Select _All"), "<control>A",
                    Catalog.GetString("Select all tracks"), OnSelectAll),

                new ActionEntry("SelectNoneAction", null,
                    Catalog.GetString("Select _None"), "<control><shift>A",
                    Catalog.GetString("Unselect all tracks"), OnSelectNone),

                new ActionEntry ("TrackEditorAction", Stock.Edit,
                    Catalog.GetString ("_Edit Track Information"), "E",
                    Catalog.GetString ("Edit information on selected tracks"), OnTrackEditor),

                new ActionEntry ("TrackPropertiesAction", Stock.Properties,
                    Catalog.GetString ("Properties"), null,
                    Catalog.GetString ("View information on selected tracks"), OnTrackProperties),

                new ActionEntry ("PlayTrack", null,
                    Catalog.GetString ("_Play"), "",
                    Catalog.GetString ("Play the selected item"), OnPlayTrack),

                new ActionEntry ("AddToPlaylistAction", null,
                    Catalog.GetString ("Add _to Playlist"), "",
                    Catalog.GetString ("Append selected items to playlist or create new playlist from selection"),
                    OnAddToPlaylistMenu),

                new ActionEntry ("AddToNewPlaylistAction", Stock.New,
                    Catalog.GetString ("New Playlist"), null,
                    Catalog.GetString ("Create new playlist from selected tracks"),
                    OnAddToNewPlaylist),

                new ActionEntry ("RemoveTracksAction", Stock.Remove,
                    Catalog.GetString ("_Remove"), "Delete",
                    Catalog.GetString ("Remove selected track(s) from this source"), OnRemoveTracks),

                new ActionEntry ("RemoveTracksFromLibraryAction", null,
                    Catalog.GetString ("Remove From _Library"), "",
                    Catalog.GetString ("Remove selected track(s) from library"), OnRemoveTracksFromLibrary),

                new ActionEntry ("OpenContainingFolderAction", null,
                    Catalog.GetString ("_Open Containing Folder"), "",
                    Catalog.GetString ("Open the folder that contains the selected item"), OnOpenContainingFolder),

                new ActionEntry ("DeleteTracksFromDriveAction", null,
                    Catalog.GetString ("_Delete From Drive"), "",
                    Catalog.GetString ("Permanently delete selected item(s) from medium"), OnDeleteTracksFromDrive),

                new ActionEntry ("RateTracksAction", null,
                    String.Empty, null, null, OnRateTracks),

                new ActionEntry ("SearchMenuAction", Stock.Find,
                    Catalog.GetString ("_Search"), null,
                    Catalog.GetString ("Search for items matching certain criteria"), null),

                new ActionEntry ("SearchForSameAlbumAction", null,
                    Catalog.GetString ("By Matching _Album"), "",
                    Catalog.GetString ("Search all songs of this album"), OnSearchForSameAlbum),

                new ActionEntry ("SearchForSameArtistAction", null,
                    Catalog.GetString ("By Matching A_rtist"), "",
                    Catalog.GetString ("Search all songs of this artist"), OnSearchForSameArtist),
            });

            Actions.UIManager.ActionsChanged += HandleActionsChanged;

            Actions.GlobalActions["EditMenuAction"].Activated += HandleEditMenuActivated;
            ServiceManager.SourceManager.ActiveSourceChanged += HandleActiveSourceChanged;
{'fraction_non_alphanumeric': 0.08633286413298479, 'fraction_numerical': 0.0014746296668677525, 'mean_word_length': 2.2619151727153475, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6611033', 'n_tokens_mistral': 3609, 'n_tokens_neox': 3387, 'n_words': 1107}