Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono-addins.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez Gual <lluis@novell.com>2011-02-04 05:38:33 +0300
committerLluis Sanchez Gual <lluis@novell.com>2011-02-04 05:38:33 +0300
commit54e0632ca4e8334b7824335d4b3493ffc6ddb0b3 (patch)
treeef5cc5eea95af3b5b9844ce8d125910090bd1df4 /Mono.Addins.Gui
parent1cae03732c53614872e29ec42e39fa7315d3538b (diff)
Added support for preview images.
Diffstat (limited to 'Mono.Addins.Gui')
-rw-r--r--Mono.Addins.Gui/Mono.Addins.Gui/AddinInfoView.cs81
-rw-r--r--Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinInfoView.cs16
-rw-r--r--Mono.Addins.Gui/gtk-gui/gui.stetic2
3 files changed, 90 insertions, 9 deletions
diff --git a/Mono.Addins.Gui/Mono.Addins.Gui/AddinInfoView.cs b/Mono.Addins.Gui/Mono.Addins.Gui/AddinInfoView.cs
index 455b7d8..957f296 100644
--- a/Mono.Addins.Gui/Mono.Addins.Gui/AddinInfoView.cs
+++ b/Mono.Addins.Gui/Mono.Addins.Gui/AddinInfoView.cs
@@ -24,6 +24,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
+using System.IO;
using System.Collections.Generic;
using Mono.Addins.Setup;
using System.Text;
@@ -39,6 +40,7 @@ namespace Mono.Addins.Gui
List<Addin> selectedAddin = new List<Addin> ();
SetupService service;
HeaderBox topHeaderBox;
+ List<Gtk.Widget> previewImages = new List<Gtk.Widget> ();
public event EventHandler InstallClicked;
public event EventHandler UninstallClicked;
@@ -94,6 +96,12 @@ namespace Mono.Addins.Gui
eboxButs.Visible = true;
topHeaderBox.Hide ();
+ foreach (var img in previewImages) {
+ ((Gtk.Container)img.Parent).Remove (img);
+ img.Destroy ();
+ }
+ previewImages.Clear ();
+
if (data.Length == 1) {
headerBox.Show ();
ShowAddin (data[0]);
@@ -174,6 +182,10 @@ namespace Mono.Addins.Gui
sinfo = SetupService.GetAddinHeader (installed);
updateInfo = GetUpdate (installed);
selectedEntry.Clear ();
+ foreach (var prop in sinfo.Properties) {
+ if (prop.Name.StartsWith ("PreviewImage"))
+ previewImages.Add (new ImageContainer (installed, prop.Value));
+ }
}
else if (data is AddinRepositoryEntry) {
AddinRepositoryEntry entry = (AddinRepositoryEntry) data;
@@ -184,6 +196,10 @@ namespace Mono.Addins.Gui
selectedEntry.Add (entry);
string rname = !string.IsNullOrEmpty (entry.RepositoryName) ? entry.RepositoryName : entry.RepositoryUrl;
repo = Catalog.GetString ("<small>Available in repository:") + "\n" + GLib.Markup.EscapeText (rname) + "\n\n</small>";
+ foreach (var prop in sinfo.Properties) {
+ if (prop.Name.StartsWith ("PreviewImage"))
+ previewImages.Add (new ImageContainer (entry, prop.Value));
+ }
} else
selectedEntry.Clear ();
@@ -243,6 +259,9 @@ namespace Mono.Addins.Gui
string desc = GLib.Markup.EscapeText (sinfo.Description);
labelDesc.Markup = repo + GLib.Markup.EscapeText (desc);
+
+ foreach (var img in previewImages)
+ vboxDesc.PackStart (img, false, false, 0);
}
}
@@ -294,5 +313,67 @@ namespace Mono.Addins.Gui
scrolledwindow.ModifyBg (Gtk.StateType.Normal, gcol);
}
}
+
+ class ImageContainer: Gtk.EventBox
+ {
+ AddinRepositoryEntry aentry;
+ IAsyncResult aresult;
+ Gtk.Image image;
+ bool destroyed;
+
+ ImageContainer ()
+ {
+ image = new Gtk.Image ();
+ Add (image);
+ Show ();
+ }
+
+ public ImageContainer (AddinRepositoryEntry aentry, string fileName): this ()
+ {
+ this.aentry = aentry;
+ aresult = aentry.BeginDownloadSupportFile (fileName, ImageDownloaded, null);
+ }
+
+ public ImageContainer (Addin addin, string fileName): this ()
+ {
+ string path = System.IO.Path.Combine (addin.Description.BasePath, fileName);
+ LoadImage (File.OpenRead (path));
+ }
+
+ void ImageDownloaded (object state)
+ {
+ Gtk.Application.Invoke (delegate {
+ if (destroyed)
+ return;
+ try {
+ LoadImage (aentry.EndDownloadSupportFile (aresult));
+ } catch {
+ // ignore
+ }
+ });
+ }
+
+ void LoadImage (Stream s)
+ {
+ using (s) {
+ Gdk.PixbufLoader loader = new Gdk.PixbufLoader (s);
+ Gdk.Pixbuf pix = image.Pixbuf = loader.Pixbuf;
+ loader.Dispose ();
+ if (pix.Width > 250) {
+ Gdk.Pixbuf spix = pix.ScaleSimple (250, (250 * pix.Height) / pix.Width, Gdk.InterpType.Hyper);
+ pix.Dispose ();
+ pix = spix;
+ }
+ image.Pixbuf = pix;
+ image.Show ();
+ }
+ }
+
+ protected override void OnDestroyed ()
+ {
+ destroyed = true;
+ base.OnDestroyed ();
+ }
+ }
}
diff --git a/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinInfoView.cs b/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinInfoView.cs
index 9522b0d..c646de5 100644
--- a/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinInfoView.cs
+++ b/Mono.Addins.Gui/gtk-gui/Mono.Addins.Gui.AddinInfoView.cs
@@ -15,7 +15,7 @@ namespace Mono.Addins.Gui
private global::Gtk.Label labelVersion;
private global::Gtk.ScrolledWindow scrolledwindow;
private global::Gtk.EventBox ebox2;
- private global::Gtk.VBox vbox7;
+ private global::Gtk.VBox vboxDesc;
private global::Gtk.Label labelDesc;
private global::Gtk.EventBox eboxButs;
private global::Gtk.HBox hbox1;
@@ -110,22 +110,22 @@ namespace Mono.Addins.Gui
this.ebox2 = new global::Gtk.EventBox ();
this.ebox2.Name = "ebox2";
// Container child ebox2.Gtk.Container+ContainerChild
- this.vbox7 = new global::Gtk.VBox ();
- this.vbox7.Name = "vbox7";
- this.vbox7.Spacing = 6;
- // Container child vbox7.Gtk.Box+BoxChild
+ this.vboxDesc = new global::Gtk.VBox ();
+ this.vboxDesc.Name = "vboxDesc";
+ this.vboxDesc.Spacing = 6;
+ // Container child vboxDesc.Gtk.Box+BoxChild
this.labelDesc = new global::Gtk.Label ();
this.labelDesc.WidthRequest = 250;
this.labelDesc.Name = "labelDesc";
this.labelDesc.Xalign = 0F;
this.labelDesc.LabelProp = global::Mono.Unix.Catalog.GetString ("Long description of the add-in. Long description of the add-in. Long description of the add-in. Long description of the add-in. Long description of the add-in. Long description of the add-in. ");
this.labelDesc.Wrap = true;
- this.vbox7.Add (this.labelDesc);
- global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.vbox7 [this.labelDesc]));
+ this.vboxDesc.Add (this.labelDesc);
+ global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.vboxDesc [this.labelDesc]));
w8.Position = 0;
w8.Expand = false;
w8.Fill = false;
- this.ebox2.Add (this.vbox7);
+ this.ebox2.Add (this.vboxDesc);
w7.Add (this.ebox2);
this.scrolledwindow.Add (w7);
this.vbox3.Add (this.scrolledwindow);
diff --git a/Mono.Addins.Gui/gtk-gui/gui.stetic b/Mono.Addins.Gui/gtk-gui/gui.stetic
index e048924..a39fcb5 100644
--- a/Mono.Addins.Gui/gtk-gui/gui.stetic
+++ b/Mono.Addins.Gui/gtk-gui/gui.stetic
@@ -1513,7 +1513,7 @@
<widget class="Gtk.EventBox" id="ebox2">
<property name="MemberName" />
<child>
- <widget class="Gtk.VBox" id="vbox7">
+ <widget class="Gtk.VBox" id="vboxDesc">
<property name="MemberName" />
<property name="Spacing">6</property>
<child>