2
// UnsupportedDatabaseView.cs
5
// Aaron Bockover <abockover@novell.com>
7
// Copyright (C) 2006-2008 Novell, Inc.
9
// Permission is hereby granted, free of charge, to any person obtaining
10
// a copy of this software and associated documentation files (the
11
// "Software"), to deal in the Software without restriction, including
12
// without limitation the rights to use, copy, modify, merge, publish,
13
// distribute, sublicense, and/or sell copies of the Software, and to
14
// permit persons to whom the Software is furnished to do so, subject to
15
// the following conditions:
17
// The above copyright notice and this permission notice shall be
18
// included in all copies or substantial portions of the Software.
20
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39
using Banshee.Widgets;
41
using Banshee.Dap.Gui;
43
namespace Banshee.Dap.Ipod
45
public class UnsupportedDatabaseView : DapPropertiesDisplay
47
private MessagePane pane;
48
private bool info_link_clicked = false;
49
private IpodSource source;
51
public event EventHandler Refresh;
53
public UnsupportedDatabaseView (IpodSource source) : base (source)
57
pane = new MessagePane();
58
pane.HeaderIcon = IconThemeUtils.LoadIcon(48, "face-surprise", Stock.DialogError);
59
pane.ArrowIcon = IconThemeUtils.LoadIcon(24, "go-next", Stock.GoForward);
60
pane.HeaderMarkup = String.Format("<big><b>{0}</b></big>",
61
GLib.Markup.EscapeText(Catalog.GetString("Unable to read your iPod")));
69
private void AddPaneItems()
71
if(info_link_clicked) {
72
bool file_exists = System.IO.File.Exists (Paths.Combine (
73
source.IpodDevice.ControlPath, "iTunes", "iTunesDB"));
76
pane.Append(Catalog.GetString(
77
"You have used this iPod with a version of iTunes that saves a " +
78
"version of the song database for your iPod that is too new " +
79
"for Banshee to recognize.\n\n" +
81
"Banshee can rebuild your database, but you might lose your settings and all the content in the device (be sure to backup your data first). " +
82
"Using Banshee and iTunes with the same iPod is not recommended."
85
LinkLabel link = new LinkLabel();
87
link.Markup = String.Format("<u>{0}</u>", GLib.Markup.EscapeText(Catalog.GetString(
88
"Learn more about Banshee's iPod support")));
90
link.Clicked += delegate { Banshee.Web.Browser.Open ("http://banshee.fm/IpodAndItunes"); };
93
pane.Append(link, Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill, 0, true);
95
pane.Append(Catalog.GetString(
96
"An iPod database could not be found on this device.\n\n" +
97
"Banshee can build a new database for you."
101
LinkLabel link = new LinkLabel();
103
link.Markup = String.Format("<u>{0}</u>", GLib.Markup.EscapeText(Catalog.GetString(
104
"What is the reason for this?")));
106
link.Clicked += delegate {
107
info_link_clicked = true;
113
pane.Append(link, Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill, 0, true);
116
if(source.IpodDevice.VolumeInfo.IsMountedReadOnly) {
117
pane.Append(Catalog.GetString("Your iPod is mounted read only. Banshee can not restore your iPod."),
118
true, IconThemeUtils.LoadIcon(48, "dialog-error"));
122
LinkLabel rebuild_link = new LinkLabel();
123
rebuild_link.Xalign = 0.0f;
124
rebuild_link.Markup = String.Format("<u>{0}</u>", GLib.Markup.EscapeText(Catalog.GetString(
125
"Rebuild iPod Database...")));
126
rebuild_link.Clicked += OnRebuildDatabase;
128
pane.Append(rebuild_link, Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill, 0, true);
131
private void OnRebuildDatabase(object o, EventArgs args)
133
string title = Catalog.GetString("Confirm Rebuild iPod Database");
134
HigMessageDialog md = new HigMessageDialog(null,
135
DialogFlags.DestroyWithParent, MessageType.Question,
139
"Rebuilding your iPod database may take some time. Also note that " +
140
"any playlists you have on your iPod will be lost.\n\n" +
141
"Are you sure you want to rebuild your iPod database?"));
143
md.AddButton(Catalog.GetString("Rebuild Database"), Gtk.ResponseType.Yes, true);
145
if(md.Run() != (int)ResponseType.Yes) {
152
pane.HeaderIcon = null;
153
pane.HeaderMarkup = null;
156
pane.Append(String.Format("<big><b>{0}</b></big>",
157
GLib.Markup.EscapeText(Catalog.GetString("Rebuilding iPod Database..."))),
160
DatabaseRebuilder rebuilder = new DatabaseRebuilder(source);
161
rebuilder.Finished += delegate {
166
protected virtual void OnRefresh()
168
EventHandler handler = Refresh;
169
if (handler != null) {
170
handler (this, new EventArgs ());