1
/* DoAddinInstallerDialog.cs
3
* GNOME Do is the legal property of its developers. Please refer to the
4
* COPYRIGHT file distributed with this
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
22
using System.Threading;
23
using System.Collections;
24
using Mono.Addins.Setup;
25
using Mono.Addins.Description;
28
using Mono.Addins.Gui;
34
public partial class DoAddinInstallerDialog : Gtk.Dialog, IProgressStatus
36
PackageCollection entries = new PackageCollection ();
37
PluginUpdateNodeView plugins_view;
41
bool addins_not_found;
44
public DoAddinInstallerDialog (AddinRegistry reg, string message, string[] addinIds)
50
plugins_view = new PluginUpdateNodeView (reg, addin_ids);
51
plugin_scroll.Add (plugins_view);
52
plugin_scroll.ShowAll ();
54
setup = new SetupService (reg);
56
if (!CheckAddins (true))
60
bool CheckAddins (bool updating)
63
bool addinsNotFound = false;
64
foreach (string id in addin_ids) {
65
string name = Addin.GetIdName (id);
66
string version = Addin.GetIdVersion (id);
67
AddinRepositoryEntry[] ares = setup.Repositories.GetAvailableAddin (name, version);
68
if (ares.Length == 0) {
69
addinsNotFound = true;
71
entries.Add (Package.FromRepository (ares[0]));
75
DependencyCollection unresolved;
76
PackageCollection toUninstall;
78
if (!setup.ResolveDependencies (this, entries, out toUninstall, out unresolved)) {
79
/* Change this to some way of notifying that there are missing deps
80
foreach (Dependency dep in unresolved) {
81
txt += "<span foreground='red'><b>" + dep.Name + "</b> (not found)</span>\n";
84
addinsNotFound = true;
86
return !addinsNotFound;
92
setup.Repositories.UpdateAllRepositories (this);
94
addins_not_found = CheckAddins (false);
95
if (err_message != null) {
100
public int LogLevel {
106
public bool IsCanceled {
112
public bool AddinsNotFound {
114
return addins_not_found;
118
public string ErrMessage {
124
public void SetMessage (string msg)
126
progress_bar.Text = msg;
127
while (Gtk.Application.EventsPending ())
128
Gtk.Application.RunIteration ();
131
public void SetProgress (double progress)
133
progress_bar.Fraction = progress;
134
while (Gtk.Application.EventsPending ())
135
Gtk.Application.RunIteration ();
138
public void ReportError (string message, System.Exception exception)
140
err_message = message;
143
public void Log (string msg)
147
public void ReportWarning (string message)
151
public void Cancel ()
153
Respond (Gtk.ResponseType.Cancel);
156
protected virtual void OnButtonOKClick (object sender, System.EventArgs e)
158
if (addins_not_found) {
159
err_message = Catalog.GetString ("Some of the required add-ins were not found");
160
Respond (Gtk.ResponseType.Ok);
163
progress_bar.Visible = true;
165
progress_bar.Show ();
166
progress_bar.Fraction = 0;
167
progress_bar.Text = "";
168
bool res = setup.Install (this, entries);
170
button_cancel.Sensitive = button_ok.Sensitive = false;
171
if (err_message == null)
172
Catalog.GetString ("Installation failed");
175
Respond (Gtk.ResponseType.Ok);