/* * AlbumArt Banshee Plugin, Copyright (c) 2006 Nick Bargnesi * nick at den-4.com * * THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW: * * 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. * * Author's note: * AlbumArt borrows heavily from the code found in the sample plugin * for Banshee, the TrackInfoPopup class contained in the Banshee.Widgets package, * the NotificationAreaIconPlugin, and bits of the Wikimedia plugin. * * My thanks to all authors for allowing an ex-KDE/amaroK user to "scratch an itch". */ using System; using Gtk; using Gdk; using GConf; using Mono.Unix; using Banshee.Base; using Banshee.Sources; using Banshee.MediaEngine; using Banshee.Widgets; namespace Banshee.Plugins.AlbumArt { public class AlbumArtConfigPage : VBox { /// Reference the plugin's properties private AlbumArtPlugin plugin; /// SpinButton widget representing x coordinate position in pixels private SpinButton spinXPosition; /// SpinButton widget representing y coordinate position in pixels private SpinButton spinYPosition; /// SpinButton widget representing size of popup in pixels private SpinButton spinSize; /// ComboBox widget containing CD cases private ComboBox cds; /// CheckButton widget representing whether the popups are sticky private CheckButton stick; /// A cheap way of skipping spinXPosition's changeXPosition event on creation private bool firstXChange; /// A cheap way of skipping spinYPosition's changeYPosition event on creation private bool firstYChange; /// A cheap way of skipping spinSize's changeSize event on creation private bool firstSizeChange; /// Creates a VBox widget for Banshee's configuration public AlbumArtConfigPage(AlbumArtPlugin plugin) : base() { this.plugin = plugin; BuildWidget(); } /// Builds all the widgets and creates the layout private void BuildWidget() { Spacing = 10; VBox box = new VBox(); box.Spacing = 5; HBox firstRow = new HBox(), secondRow = new HBox(), thirdRow = new HBox(), fourthRow = new HBox(); HBox fifthRow = new HBox(); firstRow.Spacing = 5; secondRow.Spacing = 5; thirdRow.Spacing = 5; fourthRow.Spacing = 5; fifthRow.Spacing = 5; /* These widgets should realy be aligned, staggered = bad */ cds = ComboBox.NewText(); cds.AppendText("Black"); cds.AppendText("Blue"); cds.AppendText("Brown"); cds.AppendText("Red"); cds.AppendText("White"); cds.AppendText("Purple"); cds.AppendText("Green"); cds.Active = plugin.CD; cds.Changed += new EventHandler(onComboBoxChanged); spinXPosition = new SpinButton(0, Screen.Width, 1); spinYPosition = new SpinButton(0, Screen.Height, 1); spinSize = new SpinButton((double) 50, (double) 500, (double) 1); stick = new CheckButton("Stick popups to all desktops"); if (plugin.Stick) stick.Active = true; spinXPosition.Value = plugin.X; spinYPosition.Value = plugin.Y; spinSize.Value = plugin.Size; firstRow.PackStart(new Label("CD case: "), false, false, 0); firstRow.PackStart(cds, false, false, 0); secondRow.PackStart(new Label("Horizontal position (pixels): "), false, false, 0); secondRow.PackStart(spinXPosition, false, false, 0); thirdRow.PackStart(new Label("Vertical position (pixels): "), false, false, 0); thirdRow.PackStart(spinYPosition, false, false, 0); fourthRow.PackStart(new Label("Size of the popup (pixels): "), false, false, 0); fourthRow.PackStart(spinSize, false, false, 0); fifthRow.PackStart(stick, false, false, 0); spinXPosition.ValueChanged += changeXPosition; spinXPosition.FocusInEvent += focusIn; spinXPosition.FocusOutEvent += focusOut; spinYPosition.ValueChanged += changeYPosition; spinYPosition.FocusInEvent += focusIn; spinYPosition.FocusOutEvent += focusOut; spinSize.ValueChanged += changeSize; spinSize.FocusInEvent += focusIn; spinSize.FocusOutEvent += focusOut; stick.Toggled += toggled; stick.FocusInEvent += focusIn; stick.FocusOutEvent += focusOut; box.PackStart(firstRow, false, false, 0); box.PackStart(secondRow, false, false, 0); box.PackStart(thirdRow, false, false, 0); box.PackStart(fourthRow, false, false, 0); box.PackStart(fifthRow, false, false, 0); PackStart(box, false, false, 0); ShowAll(); } /// Event triggered when the spinXPosition value changes private void changeXPosition(object o, EventArgs args) { if (!firstXChange) { firstXChange = true; return; } plugin.X = spinXPosition.ValueAsInt; } /// Event triggered when the spinYPosition value changes private void changeYPosition(object o, EventArgs args) { if (!firstYChange) { firstYChange = true; return; } plugin.Y = spinYPosition.ValueAsInt; } /// Event triggered when the spinSize value changes private void changeSize(object o, EventArgs args) { if (!firstSizeChange) { firstSizeChange = true; return; } plugin.Size = spinSize.ValueAsInt; } /// Event triggered when the cds combo value changes private void onComboBoxChanged(object o, EventArgs args) { plugin.CD = cds.Active; } /// Event triggered when spinXPosition or spinYPosition receives focus private void focusIn(object o, FocusInEventArgs args) { plugin.X = spinXPosition.ValueAsInt; plugin.Y = spinYPosition.ValueAsInt; } /// Event triggered when spinXPosition or spinYPosition loses focus private void focusOut(object o, FocusOutEventArgs args) { plugin.X = spinXPosition.ValueAsInt; plugin.Y = spinYPosition.ValueAsInt; } /// Event triggered when the check button is toggled private void toggled(object o, EventArgs args) { plugin.Stick = stick.Active; } } } // vim:ts=4:sw=4