Ejemplo n.º 1
0
        private void OnUnmapSource(object o, EventArgs args)
        {
            IUnmapableSource source = ActionSource as IUnmapableSource;

            if (source != null && source.CanUnmap && (!source.ConfirmBeforeUnmap || ConfirmUnmap(source)))
            {
                source.Unmap();
            }
        }
Ejemplo n.º 2
0
        private void UpdateActions(bool force)
        {
            Source source = ActionSource;

            if ((force || source != last_source) && source != null)
            {
                IUnmapableSource    unmapable      = (source as IUnmapableSource);
                IImportSource       import_source  = (source as IImportSource);
                SmartPlaylistSource smart_playlist = (source as SmartPlaylistSource);
                PrimarySource       primary_source = (source as PrimarySource) ?? (source.Parent as PrimarySource);

                UpdateAction("UnmapSourceAction", unmapable != null, unmapable != null && unmapable.CanUnmap, source);
                UpdateAction("RenameSourceAction", source.CanRename, true, null);
                UpdateAction("ImportSourceAction", import_source != null, import_source != null && import_source.CanImport, source);
                UpdateAction("ExportPlaylistAction", source is AbstractPlaylistSource, true, source);
                UpdateAction("SourcePropertiesAction", source.HasProperties, true, source);
                UpdateAction("SourcePreferencesAction", source.PreferencesPageId != null, true, source);
                UpdateAction("RefreshSmartPlaylistAction", smart_playlist != null && smart_playlist.CanRefresh, true, source);
                this["OpenSourceSwitcher"].Visible = false;

                bool playlists_writable = primary_source != null && primary_source.SupportsPlaylists && !primary_source.PlaylistsReadOnly;
                UpdateAction("NewPlaylistAction", playlists_writable, true, source);
                UpdateAction("NewSmartPlaylistAction", playlists_writable, true, source);

                /*UpdateAction ("NewSmartPlaylistFromSearchAction", (source is LibrarySource || source.Parent is LibrarySource),
                 *      !String.IsNullOrEmpty (source.FilterQuery), source);*/

                ActionGroup browser_actions = Actions.FindActionGroup("BrowserView");
                if (browser_actions != null)
                {
                    IFilterableSource filterable_source = source as IFilterableSource;
                    bool has_browser = filterable_source != null && filterable_source.AvailableFilters.Count > 0;
                    UpdateAction(browser_actions["BrowserTopAction"], has_browser);
                    UpdateAction(browser_actions["BrowserLeftAction"], has_browser);
                    UpdateAction(browser_actions["BrowserVisibleAction"], has_browser);
                }

                last_source = source;
            }

            if (source != null)
            {
                UpdateAction("SortChildrenAction", source.ChildSortTypes.Length > 0 && source.Children.Count > 1, true, source);
            }

            Action <Source> handler = Updated;

            if (handler != null)
            {
                handler(source);
            }
        }
Ejemplo n.º 3
0
        private static bool ConfirmUnmap(IUnmapableSource source)
        {
            string key        = "no_confirm_unmap_" + source.GetType().Name.ToLower();
            bool   do_not_ask = ConfigurationClient.Get <bool> ("sources", key, false);

            if (do_not_ask)
            {
                return(true);
            }

            Hyena.Widgets.HigMessageDialog dialog = new Hyena.Widgets.HigMessageDialog(
                ServiceManager.Get <GtkElementsService> ().PrimaryWindow,
                Gtk.DialogFlags.Modal,
                Gtk.MessageType.Question,
                Gtk.ButtonsType.Cancel,
                String.Format(Catalog.GetString("Are you sure you want to delete this {0}?"),
                              source.GenericName.ToLower()),
                source.Name);

            dialog.AddButton(Gtk.Stock.Delete, Gtk.ResponseType.Ok, false);

            Gtk.Alignment alignment = new Gtk.Alignment(0.0f, 0.0f, 0.0f, 0.0f);
            alignment.TopPadding = 10;
            Gtk.CheckButton confirm_button = new Gtk.CheckButton(String.Format(Catalog.GetString(
                                                                                   "Do not ask me this again"), source.GenericName.ToLower()));
            confirm_button.Toggled += delegate {
                do_not_ask = confirm_button.Active;
            };
            alignment.Add(confirm_button);
            alignment.ShowAll();
            dialog.LabelVBox.PackStart(alignment, false, false, 0);

            try {
                if (dialog.Run() == (int)Gtk.ResponseType.Ok)
                {
                    ConfigurationClient.Set <bool> ("sources", key, do_not_ask);
                    return(true);
                }

                return(false);
            } finally {
                dialog.Destroy();
            }
        }
Ejemplo n.º 4
0
        private static bool ConfirmUnmap (IUnmapableSource source)
        {
            string key = "no_confirm_unmap_" + source.GetType ().Name.ToLower ();
            bool do_not_ask = ConfigurationClient.Get<bool> ("sources", key, false);

            if (do_not_ask) {
                return true;
            }

            Hyena.Widgets.HigMessageDialog dialog = new Hyena.Widgets.HigMessageDialog (
                ServiceManager.Get<GtkElementsService> ().PrimaryWindow,
                Gtk.DialogFlags.Modal,
                Gtk.MessageType.Question,
                Gtk.ButtonsType.Cancel,
                String.Format (Catalog.GetString ("Are you sure you want to delete this {0}?"),
                    source.GenericName.ToLower ()),
                source.Name);

            dialog.AddButton (Gtk.Stock.Delete, Gtk.ResponseType.Ok, false);

            Gtk.Alignment alignment = new Gtk.Alignment (0.0f, 0.0f, 0.0f, 0.0f);
            alignment.TopPadding = 10;
            Gtk.CheckButton confirm_button = new Gtk.CheckButton (String.Format (Catalog.GetString (
                "Do not ask me this again"), source.GenericName.ToLower ()));
            confirm_button.Toggled += delegate {
                do_not_ask = confirm_button.Active;
            };
            alignment.Add (confirm_button);
            alignment.ShowAll ();
            dialog.LabelVBox.PackStart (alignment, false, false, 0);

            try {
                if (dialog.Run () == (int)Gtk.ResponseType.Ok) {
                    ConfigurationClient.Set<bool> ("sources", key, do_not_ask);
                    return true;
                }

                return false;
            } finally {
                dialog.Destroy ();
            }
        }