diff options
author | Lluis Sanchez <lluis@xamarin.com> | 2013-07-10 17:35:34 +0400 |
---|---|---|
committer | Lluis Sanchez <lluis@xamarin.com> | 2013-07-25 01:41:06 +0400 |
commit | 3be8515b85420696cc8a730d96dcfbb820b3a9ef (patch) | |
tree | ba7bcb1f37d63a9599e7e6d27c6117487c672a6f /main/src/core | |
parent | a0cd46940f504b31ab648ba33a7af60fb15dd32f (diff) |
More Image/Pixbuf changes
Diffstat (limited to 'main/src/core')
23 files changed, 155 insertions, 123 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/ISearchDataSource.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/ISearchDataSource.cs index 0790c80b1e..c8b1f6a594 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/ISearchDataSource.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/ISearchDataSource.cs @@ -36,7 +36,7 @@ namespace MonoDevelop.Components.MainToolbar { int ItemCount { get; } - Gdk.Pixbuf GetIcon (int item); + Xwt.Drawing.Image GetIcon (int item); string GetMarkup (int item, bool isSelected); string GetDescriptionMarkup (int item, bool isSelected); TooltipInformation GetTooltip (int item); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/ResultsDataSource.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/ResultsDataSource.cs index 8b6e309b66..5de97bdd00 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/ResultsDataSource.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/ResultsDataSource.cs @@ -115,7 +115,7 @@ namespace MonoDevelop.Components.MainToolbar #region ISearchDataSource implementation - Gdk.Pixbuf ISearchDataSource.GetIcon (int item) + Xwt.Drawing.Image ISearchDataSource.GetIcon (int item) { return this [item].Icon; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchPopupWindow.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchPopupWindow.cs index 4bc2e9be3a..4142fb547e 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchPopupWindow.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchPopupWindow.cs @@ -62,7 +62,7 @@ namespace MonoDevelop.Components.MainToolbar class NullDataSource : ISearchDataSource { #region ISearchDataSource implementation - Gdk.Pixbuf ISearchDataSource.GetIcon (int item) + Xwt.Drawing.Image ISearchDataSource.GetIcon (int item) { throw new NotImplementedException (); } @@ -859,8 +859,7 @@ namespace MonoDevelop.Components.MainToolbar var px = dataSrc.GetIcon (i); if (px != null) { - Gdk.CairoHelper.SetSourcePixbuf (context, px, (int)x + marginIconSpacing, (int)y + (h - px.Height) / 2); - context.Paint (); + context.DrawImage (this, px, (int)x + marginIconSpacing, (int)y + (h - px.Height) / 2); x += px.Width + iconTextSpacing + marginIconSpacing; } @@ -903,8 +902,7 @@ namespace MonoDevelop.Components.MainToolbar var px = dataSrc.GetIcon (i); if (px != null) { - Gdk.CairoHelper.SetSourcePixbuf (context, px, (int)x + marginIconSpacing, (int)y + (h - px.Height) / 2); - context.Paint (); + context.DrawImage (this, px, (int)x + marginIconSpacing, (int)y + (h - px.Height) / 2); x += px.Width + iconTextSpacing + marginIconSpacing; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchResult.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchResult.cs index 58ee7b303e..b09591a971 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchResult.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchResult.cs @@ -71,7 +71,7 @@ namespace MonoDevelop.Components.MainToolbar public virtual int Column { get { return -1; } } public abstract string File { get; } - public abstract Gdk.Pixbuf Icon { get; } + public abstract Xwt.Drawing.Image Icon { get; } public abstract string Description { get; } public string MatchedString { get; private set;} @@ -127,9 +127,9 @@ namespace MonoDevelop.Components.MainToolbar get { return type.Region.FileName; } } - public override Gdk.Pixbuf Icon { + public override Xwt.Drawing.Image Icon { get { - return ImageService.GetPixbuf (type.GetStockIcon (false), IconSize.Menu); + return ImageService.GetIcon (type.GetStockIcon (false), IconSize.Menu); } } @@ -224,9 +224,9 @@ namespace MonoDevelop.Components.MainToolbar } } - public override Gdk.Pixbuf Icon { + public override Xwt.Drawing.Image Icon { get { - return DesktopService.GetPixbufForFile (file.FilePath, IconSize.Menu); + return DesktopService.GetIconForFile (file.FilePath, IconSize.Menu); } } @@ -293,9 +293,9 @@ namespace MonoDevelop.Components.MainToolbar get { return member.DeclaringTypeDefinition.Region.FileName; } } - public override Gdk.Pixbuf Icon { + public override Xwt.Drawing.Image Icon { get { - return ImageService.GetPixbuf (member.GetStockIcon (false), IconSize.Menu); + return ImageService.GetIcon (member.GetStockIcon (false), IconSize.Menu); } } @@ -385,9 +385,9 @@ namespace MonoDevelop.Components.MainToolbar } } - public override Pixbuf Icon { + public override Xwt.Drawing.Image Icon { get { - return ImageService.GetPixbuf ("md-command", IconSize.Menu); + return ImageService.GetIcon ("md-command", IconSize.Menu); } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/FileCommands.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/FileCommands.cs index 78bdb5f2e2..3dd61d9caa 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/FileCommands.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/FileCommands.cs @@ -276,11 +276,11 @@ namespace MonoDevelop.Ide.Commands var cmd = new CommandInfo (acceleratorKeyPrefix + ri.DisplayName.Replace ("_", "__")) { Description = GettextCatalog.GetString ("Open {0}", ri.FileName) }; - Gdk.Pixbuf icon = DesktopService.GetPixbufForFile (ri.FileName, IconSize.Menu); +/* Gdk.Pixbuf icon = DesktopService.GetIconForFile (ri.FileName, IconSize.Menu); #pragma warning disable 618 if (icon != null) cmd.Icon = ImageService.GetStockId (icon, IconSize.Menu); - #pragma warning restore 618 + #pragma warning restore 618*/ info.Add (cmd, ri.FileName); i++; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs index 684c5c20c3..fd2c04b378 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs @@ -39,6 +39,7 @@ using MonoDevelop.Core; using Mono.Unix; using MonoDevelop.Ide.Extensions; using MonoDevelop.Core.Execution; +using MonoDevelop.Components; using MonoDevelop.Components.MainToolbar; @@ -141,88 +142,88 @@ namespace MonoDevelop.Ide.Desktop } } - public Gdk.Pixbuf GetPixbufForFile (string filename, Gtk.IconSize size) + public Xwt.Drawing.Image GetIconForFile (string filename) { - Gdk.Pixbuf pic = null; + Xwt.Drawing.Image pic = null; - string icon = GetIconForFile (filename); + string icon = GetIconIdForFile (filename); if (icon != null) - pic = ImageService.GetPixbuf (icon, size, false); + pic = ImageService.GetIcon (icon, false); if (pic == null) - pic = OnGetPixbufForFile (filename, size); + pic = OnGetIconForFile (filename); if (pic == null) { string mtype = GetMimeTypeForUri (filename); if (mtype != null) { foreach (string mt in GetMimeTypeInheritanceChain (mtype)) { - pic = GetPixbufForType (mt, size); + pic = GetIconForType (mt); if (pic != null) return pic; } } } - return pic ?? GetDefaultIcon (size); + return pic ?? GetDefaultIcon (); } - public Gdk.Pixbuf GetPixbufForType (string mimeType, Gtk.IconSize size) + public Xwt.Drawing.Image GetIconForType (string mimeType) { - Gdk.Pixbuf bf = (Gdk.Pixbuf) iconHash [mimeType+size]; + Xwt.Drawing.Image bf = (Xwt.Drawing.Image) iconHash [mimeType]; if (bf != null) return bf; foreach (string type in GetMimeTypeInheritanceChain (mimeType)) { // Try getting an icon name for the type - string icon = GetIconForType (type); + string icon = GetIconIdForType (type); if (icon != null) { - bf = ImageService.GetPixbuf (icon, size, false); + bf = ImageService.GetIcon (icon, false); if (bf != null) break; } // Try getting a pixbuff - bf = OnGetPixbufForType (type, size); + bf = OnGetIconForType (type); if (bf != null) break; } if (bf == null) { - bf = ImageService.GetPixbuf (mimeType, size, false); + bf = ImageService.GetIcon (mimeType, false); if (bf == null) - bf = GetDefaultIcon (size); + bf = GetDefaultIcon (); } - iconHash [mimeType+size] = bf; + iconHash [mimeType] = bf; return bf; } - - Gdk.Pixbuf GetDefaultIcon (Gtk.IconSize size) + + Xwt.Drawing.Image GetDefaultIcon () { - string id = "__default" + size; - Gdk.Pixbuf bf = (Gdk.Pixbuf) iconHash [id]; + string id = "__default"; + Xwt.Drawing.Image bf = (Xwt.Drawing.Image) iconHash [id]; if (bf != null) return bf; - string icon = DefaultFileIcon; + string icon = DefaultFileIconId; if (icon != null) - bf = ImageService.GetPixbuf (icon, size, false); + bf = ImageService.GetIcon (icon, false); if (bf == null) - bf = OnGetDefaultFileIcon (size); + bf = DefaultFileIcon; if (bf == null) - bf = ImageService.GetPixbuf ("md-regular-file", size, true); + bf = ImageService.GetIcon ("md-regular-file", true); iconHash [id] = bf; return bf; } - string GetIconForFile (string fileName) + string GetIconIdForFile (string fileName) { MimeTypeNode mt = FindMimeTypeForFile (fileName); if (mt != null) return mt.Icon; else - return OnGetIconForFile (fileName); + return OnGetIconIdForFile (fileName); } - string GetIconForType (string type) + string GetIconIdForType (string type) { if (type == "text/plain") return "md-text-file-icon"; @@ -230,7 +231,7 @@ namespace MonoDevelop.Ide.Desktop if (mt != null) return mt.Icon; else - return OnGetIconForType (type); + return OnGetIconIdForType (type); } static List<MimeTypeNode> mimeTypeNodes = new List<MimeTypeNode> (); @@ -288,33 +289,32 @@ namespace MonoDevelop.Ide.Desktop return false; } - protected virtual string OnGetIconForFile (string filename) + protected virtual string OnGetIconIdForFile (string filename) { return null; } - protected virtual string OnGetIconForType (string type) + protected virtual string OnGetIconIdForType (string type) { return null; } - protected virtual Gdk.Pixbuf OnGetPixbufForFile (string filename, Gtk.IconSize size) + protected virtual Xwt.Drawing.Image OnGetIconForFile (string filename) { return null; } - protected virtual Gdk.Pixbuf OnGetPixbufForType (string type, Gtk.IconSize size) + protected virtual Xwt.Drawing.Image OnGetIconForType (string type) { return null; } - protected virtual string DefaultFileIcon { + protected virtual string DefaultFileIconId { get { return null; } } - protected virtual Gdk.Pixbuf OnGetDefaultFileIcon (Gtk.IconSize size) - { - return null; + protected virtual Xwt.Drawing.Image DefaultFileIcon { + get { return null; } } public virtual bool SetGlobalMenu (MonoDevelop.Components.Commands.CommandManager commandManager, diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResult.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResult.cs index 353f708209..9fdf7f0372 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResult.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResult.cs @@ -62,7 +62,7 @@ namespace MonoDevelop.Ide.FindInFiles set; } - public Gdk.Pixbuf Pixbuf { + public Xwt.Drawing.Image Icon { get; set; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultWidget.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultWidget.cs index 3ee5310001..9296642b06 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultWidget.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultWidget.cs @@ -129,7 +129,7 @@ namespace MonoDevelop.Ide.FindInFiles fileNameColumn.FixedWidth = 200; - var fileNamePixbufRenderer = new CellRendererPixbuf (); + var fileNamePixbufRenderer = new CellRendererImage (); fileNameColumn.PackStart (fileNamePixbufRenderer, false); fileNameColumn.SetCellDataFunc (fileNamePixbufRenderer, FileIconDataFunc); @@ -354,13 +354,13 @@ namespace MonoDevelop.Ide.FindInFiles { if (TreeIter.Zero.Equals (iter)) return; - var fileNamePixbufRenderer = (CellRendererPixbuf) cell; + var fileNamePixbufRenderer = (CellRendererImage) cell; var searchResult = (SearchResult)store.GetValue (iter, SearchResultColumn); if (searchResult == null) return; - if (searchResult.Pixbuf == null) - searchResult.Pixbuf = DesktopService.GetPixbufForFile (searchResult.FileName, IconSize.Menu); - fileNamePixbufRenderer.Pixbuf = searchResult.Pixbuf; + if (searchResult.Icon == null) + searchResult.Icon = DesktopService.GetIconForFile (searchResult.FileName, IconSize.Menu); + fileNamePixbufRenderer.Image = searchResult.Icon; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/OptionsDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/OptionsDialog.cs index 9a3090d04b..c523ae7a66 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/OptionsDialog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/OptionsDialog.cs @@ -41,7 +41,7 @@ namespace MonoDevelop.Ide.Gui.Dialogs { Gtk.HBox mainHBox; Gtk.TreeView tree; - Gtk.Image image; + Xwt.ImageView image; Gtk.Label labelTitle; Gtk.HBox pageFrame; Gtk.Button buttonCancel; @@ -114,7 +114,7 @@ namespace MonoDevelop.Ide.Gui.Dialogs var vbox = new VBox (); mainHBox.PackStart (vbox, true, true, 0); var headerBox = new HBox (false, 6); - image = new Image (); + image = new Xwt.ImageView (); // headerBox.PackStart (image, false, false, 0); labelTitle = new Label (); @@ -206,7 +206,7 @@ namespace MonoDevelop.Ide.Gui.Dialogs // Instead, give this some awareness of the mime system. var mimeSection = section as MonoDevelop.Ide.Projects.OptionPanels.MimetypeOptionsDialogSection; if (mimeSection != null && !string.IsNullOrEmpty (mimeSection.MimeType)) { - var pix = DesktopService.GetPixbufForType (mimeSection.MimeType, treeIconSize); + var pix = DesktopService.GetIconForType (mimeSection.MimeType, treeIconSize).ToPixbuf (); if (pix != null) { crp.Pixbuf = pix; } else { @@ -481,15 +481,15 @@ namespace MonoDevelop.Ide.Gui.Dialogs //HACK: mimetype panels can't provide stock ID for mimetype images. Give this some awareness of mimetypes. var mimeSection = section as MonoDevelop.Ide.Projects.OptionPanels.MimetypeOptionsDialogSection; if (mimeSection != null && !string.IsNullOrEmpty (mimeSection.MimeType)) { - var pix = DesktopService.GetPixbufForType (mimeSection.MimeType, headerIconSize); + var pix = DesktopService.GetIconForType (mimeSection.MimeType, headerIconSize); if (pix != null) { - image.Pixbuf = pix; + image.Image = pix; } else { - image.Pixbuf = ImageService.GetPixbuf (emptyCategoryIcon, headerIconSize); + image.Image = ImageService.GetIcon (emptyCategoryIcon, headerIconSize); } } else { string icon = section.Icon.IsNull? emptyCategoryIcon : section.Icon.ToString (); - image.Pixbuf = ImageService.GetPixbuf (icon, headerIconSize); + image.Image = ImageService.GetIcon (icon, headerIconSize); } /* var algn = new HeaderBox (); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectFileNodeBuilder.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectFileNodeBuilder.cs index b13ff50ee9..b4282fcea3 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectFileNodeBuilder.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectFileNodeBuilder.cs @@ -77,7 +77,7 @@ namespace MonoDevelop.Ide.Gui.Pads.ProjectPad label = "<span foreground='red'>" + label + "</span>"; } - icon = DesktopService.GetPixbufForFile (file.FilePath, Gtk.IconSize.Menu).ToXwtImage (); + icon = DesktopService.GetIconForFile (file.FilePath, Gtk.IconSize.Menu); if (file.IsLink && icon != null) { var overlay = ImageService.GetIcon ("md-link-overlay"); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SolutionFolderFileNodeBuilder.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SolutionFolderFileNodeBuilder.cs index 49f008a524..72e6316076 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SolutionFolderFileNodeBuilder.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SolutionFolderFileNodeBuilder.cs @@ -57,7 +57,7 @@ namespace MonoDevelop.Ide.Gui.Pads.ProjectPad label = file.FileName.FileName; if (!System.IO.File.Exists (file.FileName)) label = "<span foreground='red'>" + label + "</span>"; - icon = DesktopService.GetPixbufForFile (file.FileName, Gtk.IconSize.Menu).ToXwtImage (); + icon = DesktopService.GetIconForFile (file.FileName, Gtk.IconSize.Menu); } public override object GetParentObject (object dataObject) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SystemFileNodeBuilder.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SystemFileNodeBuilder.cs index 9d7b8312ee..a210c6f727 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SystemFileNodeBuilder.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SystemFileNodeBuilder.cs @@ -68,7 +68,7 @@ namespace MonoDevelop.Ide.Gui.Pads.ProjectPad SystemFile file = (SystemFile) dataObject; label = GLib.Markup.EscapeText (file.Name); - icon = DesktopService.GetPixbufForFile (file.Path, Gtk.IconSize.Menu).ToXwtImage (); + icon = DesktopService.GetIconForFile (file.Path, Gtk.IconSize.Menu); if (file.ShowTransparent) { var gicon = Context.GetComposedIcon (icon, "fade"); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs index c58abd764b..10786f6363 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs @@ -381,15 +381,15 @@ namespace MonoDevelop.Ide.Gui } } - Gdk.Pixbuf mimeimage = null; + Xwt.Drawing.Image mimeimage = null; if (content.StockIconId != null ) { - mimeimage = ImageService.GetPixbuf (content.StockIconId, IconSize.Menu); + mimeimage = ImageService.GetIcon (content.StockIconId, IconSize.Menu); } else if (content.IsUntitled && content.UntitledName == null) { - mimeimage = DesktopService.GetPixbufForType ("gnome-fs-regular", Gtk.IconSize.Menu); + mimeimage = DesktopService.GetIconForType ("gnome-fs-regular", Gtk.IconSize.Menu); } else { - mimeimage = DesktopService.GetPixbufForFile (content.ContentName ?? content.UntitledName, Gtk.IconSize.Menu); + mimeimage = DesktopService.GetIconForFile (content.ContentName ?? content.UntitledName, Gtk.IconSize.Menu); } var tab = tabControl.InsertTab (-1); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DockNotebook.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DockNotebook.cs index 5168077141..dbbd8e8099 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DockNotebook.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DockNotebook.cs @@ -283,7 +283,7 @@ namespace MonoDevelop.Ide.Gui int Index { get; }
string Text { get; set; }
string Markup { get; set; }
- Pixbuf Icon { get; set; }
+ Xwt.Drawing.Image Icon { get; set; }
Widget Content { get; set; }
string Tooltip { get; set; }
bool Notify { get; set; }
@@ -298,7 +298,7 @@ namespace MonoDevelop.Ide.Gui string text;
string markup;
- Gdk.Pixbuf icon;
+ Xwt.Drawing.Image icon;
Gtk.Widget content;
internal Gdk.Rectangle Allocation;
@@ -355,7 +355,7 @@ namespace MonoDevelop.Ide.Gui }
}
- public Pixbuf Icon {
+ public Xwt.Drawing.Image Icon {
get {
return this.icon;
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DocumentSwitcher.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DocumentSwitcher.cs index be9c659a1a..823563f7b9 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DocumentSwitcher.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DocumentSwitcher.cs @@ -37,6 +37,7 @@ using MonoDevelop.Components.Commands; using MonoDevelop.Ide.Commands; using MonoDevelop.Core; using Mono.TextEditor; +using MonoDevelop.Components; namespace MonoDevelop.Ide @@ -109,7 +110,7 @@ namespace MonoDevelop.Ide } for (int i = cat.FirstVisibleItem; i < cat.Items.Count; i++) { var item = cat.Items[i]; - int itemWidth = w + item.Icon.Width + 2 + itemPadding * 2; + int itemWidth = w + (int)item.Icon.Width + 2 + itemPadding * 2; if (xPos <= x && yPos <= y && x < xPos + itemWidth && y < yPos + iconHeight) return item; yPos += iconHeight; @@ -177,7 +178,7 @@ namespace MonoDevelop.Ide yPos = padding; cr.MoveTo (xPos, yPos); layout.SetMarkup ("<b>" + cat.Title + "</b>"); - cr.Color = (HslColor)Style.Text (StateType.Normal); + cr.Color = (Mono.TextEditor.HslColor)Style.Text (StateType.Normal); cr.ShowLayout (layout); if (cat.Items.Count == 0) @@ -225,25 +226,24 @@ namespace MonoDevelop.Ide } if (item == ActiveItem) { - int itemWidth = w + item.Icon.Width + 2 + itemPadding * 2; + int itemWidth = w + (int)item.Icon.Width + 2 + itemPadding * 2; cr.Rectangle (xPos, yPos, itemWidth, iconHeight); cr.LineWidth = 1; - cr.Color = (HslColor)Style.Base (StateType.Selected); + cr.Color = (Mono.TextEditor.HslColor)Style.Base (StateType.Selected); cr.Fill (); } else if (item == hoverItem) { - int itemWidth = w + item.Icon.Width + 2 + itemPadding * 2; + int itemWidth = w + (int)item.Icon.Width + 2 + itemPadding * 2; cr.Rectangle (xPos + 0.5, yPos + 0.5, itemWidth - 1, iconHeight); cr.LineWidth = 1; - cr.Color = (HslColor)Style.Base (StateType.Selected); + cr.Color = (Mono.TextEditor.HslColor)Style.Base (StateType.Selected); cr.Stroke (); } - cr.Color = (HslColor)Style.Text (item == ActiveItem? StateType.Selected : StateType.Normal); + cr.Color = (Mono.TextEditor.HslColor)Style.Text (item == ActiveItem? StateType.Selected : StateType.Normal); cr.MoveTo (xPos + item.Icon.Width + 2 + itemPadding, yPos + (iconHeight - h) / 2); layout.SetText (Ellipsize (item.ListTitle ?? item.Title, maxLength)); cr.ShowLayout (layout); - Gdk.CairoHelper.SetSourcePixbuf (cr, item.Icon, (int)xPos + itemPadding, + cr.DrawImage (this, item.Icon, (int)xPos + itemPadding, (int)(yPos + (iconHeight - item.Icon.Height) / 2)); - cr.Paint (); yPos += iconHeight; if (++curItem >= maxItems) { curItem = 0; @@ -466,8 +466,8 @@ namespace MonoDevelop.Ide return; var icon = firstNonEmptyCat.Items[0].Icon; - var iconHeight = Math.Max (h, icon.Height + 2) + itemPadding * 2; - var iconWidth = icon.Width + 2 + w + itemPadding * 2; + var iconHeight = Math.Max (h, (int)icon.Height + 2) + itemPadding * 2; + var iconWidth = (int) icon.Width + 2 + w + itemPadding * 2; foreach (var cat in categories) { var headerHeight = h + headerDistance; @@ -490,7 +490,7 @@ namespace MonoDevelop.Ide set; } - public Pixbuf Icon { + public Xwt.Drawing.Image Icon { get; set; } @@ -556,7 +556,7 @@ namespace MonoDevelop.Ide internal class DocumentSwitcher : Gtk.Window { List<MonoDevelop.Ide.Gui.Document> documents; - Gtk.Image imageTitle = new Gtk.Image (); + Xwt.ImageView imageTitle = new Xwt.ImageView (); Label labelFileName = new Label (); Label labelType = new Label (); Label labelTitle = new Label (); @@ -585,7 +585,7 @@ namespace MonoDevelop.Ide var hBox2 = new HBox (); hBox2.PackStart (hBox, false, false, 8); - hBox.PackStart (imageTitle, true, false, 2); + hBox.PackStart (imageTitle.ToGtkWidget (), true, false, 2); labelTitle.Xalign = 0; labelTitle.HeightRequest = 24; hBox.PackStart (labelTitle, true, true, 2); @@ -616,7 +616,7 @@ namespace MonoDevelop.Ide if (!pad.Visible) continue; var item = new DocumentList.Item () { - Icon = ImageService.GetPixbuf (pad.Icon.Name ?? MonoDevelop.Ide.Gui.Stock.MiscFiles, IconSize.Menu), + Icon = ImageService.GetIcon (pad.Icon.Name ?? MonoDevelop.Ide.Gui.Stock.MiscFiles, IconSize.Menu), Title = pad.Title, Tag = pad }; @@ -647,7 +647,7 @@ namespace MonoDevelop.Ide labelFileName.Text = labelType.Text = labelTitle.Text = ""; return; } - imageTitle.Pixbuf = documentList.ActiveItem.Icon; + imageTitle.Image = documentList.ActiveItem.Icon; labelFileName.Text = documentList.ActiveItem.Path; labelType.Markup = "<span size=\"small\">" + documentList.ActiveItem.Description + "</span>"; labelTitle.Markup = "<span size=\"xx-large\" weight=\"bold\">" + documentList.ActiveItem.Title + "</span>"; @@ -685,14 +685,14 @@ namespace MonoDevelop.Ide this.GrabDefault (); } - Pixbuf GetIconForDocument (MonoDevelop.Ide.Gui.Document document, Gtk.IconSize iconSize) + Xwt.Drawing.Image GetIconForDocument (MonoDevelop.Ide.Gui.Document document, Gtk.IconSize iconSize) { if (!string.IsNullOrEmpty (document.Window.ViewContent.StockIconId)) - return ImageService.GetPixbuf (document.Window.ViewContent.StockIconId, iconSize); + return ImageService.GetIcon (document.Window.ViewContent.StockIconId, iconSize); if (string.IsNullOrEmpty (document.FileName)) - return ImageService.GetPixbuf (MonoDevelop.Ide.Gui.Stock.MiscFiles, iconSize); + return ImageService.GetIcon (MonoDevelop.Ide.Gui.Stock.MiscFiles, iconSize); - return DesktopService.GetPixbufForFile (document.FileName, iconSize); + return DesktopService.GetIconForFile (document.FileName, iconSize); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs index e05179d783..b386f8bc61 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs @@ -676,14 +676,14 @@ namespace MonoDevelop.Ide.Gui try { if (content.StockIconId != null ) { - tab.Icon = ImageService.GetPixbuf (content.StockIconId, IconSize.Menu); + tab.Icon = ImageService.GetIcon (content.StockIconId, IconSize.Menu); } else if (content.ContentName != null && content.ContentName.IndexOfAny (new char[] { '*', '+'}) == -1) { - tab.Icon = DesktopService.GetPixbufForFile (content.ContentName, Gtk.IconSize.Menu); + tab.Icon = DesktopService.GetIconForFile (content.ContentName, Gtk.IconSize.Menu); } } catch (Exception ex) { LoggingService.LogError (ex.ToString ()); - tab.Icon = DesktopService.GetPixbufForType ("gnome-fs-regular", Gtk.IconSize.Menu); + tab.Icon = DesktopService.GetIconForType ("gnome-fs-regular", Gtk.IconSize.Menu); } if (TitleChanged != null) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/CodeFormattingPanel.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/CodeFormattingPanel.cs index 4b47bbfb31..f091b7044e 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/CodeFormattingPanel.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/CodeFormattingPanel.cs @@ -367,7 +367,7 @@ namespace MonoDevelop.Ide.Projects.OptionPanels void Fill () { foreach (MimeTypePanelData mt in panel.GetMimeTypeData ()) { - store.AppendValues (mt, DesktopService.GetPixbufForType (mt.MimeType, Gtk.IconSize.Menu), mt.TypeDescription); + store.AppendValues (mt, DesktopService.GetIconForType (mt.MimeType, Gtk.IconSize.Menu), mt.TypeDescription); } } @@ -391,7 +391,7 @@ namespace MonoDevelop.Ide.Projects.OptionPanels try { if (MessageService.RunCustomDialog (dlg, this.Toplevel as Gtk.Window) == (int) Gtk.ResponseType.Ok) { MimeTypePanelData mt = panel.AddGlobalMimeType (dlg.MimeType); - store.AppendValues (mt, DesktopService.GetPixbufForType (mt.MimeType, Gtk.IconSize.Menu), mt.TypeDescription); + store.AppendValues (mt, DesktopService.GetIconForType (mt.MimeType, Gtk.IconSize.Menu), mt.TypeDescription); } } finally { dlg.Destroy (); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/AddMimeTypeDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/AddMimeTypeDialog.cs index a551e06cf3..5ea7153076 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/AddMimeTypeDialog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/AddMimeTypeDialog.cs @@ -28,6 +28,7 @@ using System; using System.Linq; using System.Collections.Generic; using MonoDevelop.Core; +using MonoDevelop.Components; using System.IO; namespace MonoDevelop.Ide.Projects @@ -56,26 +57,26 @@ namespace MonoDevelop.Ide.Projects image.Visible = true; - Gdk.Pixbuf img; + Xwt.Drawing.Image img; string desc; string mt = TryGetFileType (name); if (mt != null && mt != "text/plain") { desc = DesktopService.GetMimeTypeDescription (mt); - img = DesktopService.GetPixbufForType (mt, Gtk.IconSize.Menu); + img = DesktopService.GetIconForType (mt, Gtk.IconSize.Menu); mimeType = mt; } else if (name.IndexOf ('/') != -1) { desc = DesktopService.GetMimeTypeDescription (name); - img = DesktopService.GetPixbufForType (name, Gtk.IconSize.Menu); + img = DesktopService.GetIconForType (name, Gtk.IconSize.Menu); mimeType = name; } else { - img = ImageService.GetPixbuf (Gtk.Stock.DialogError, Gtk.IconSize.Menu); + img = ImageService.GetIcon (Gtk.Stock.DialogError, Gtk.IconSize.Menu); desc = GettextCatalog.GetString ("Unknown type"); mimeType = null; } if (mimeType != null && currentTypes.Contains (mimeType)) { - img = ImageService.GetPixbuf (Gtk.Stock.DialogError, Gtk.IconSize.Menu); + img = ImageService.GetIcon (Gtk.Stock.DialogError, Gtk.IconSize.Menu); desc = GettextCatalog.GetString ("Type '{0}' already registered", desc); mimeType = null; } @@ -83,7 +84,7 @@ namespace MonoDevelop.Ide.Projects desc = mt; buttonOk.Sensitive = mimeType != null; labelDesc.Text = desc ?? string.Empty; - image.Pixbuf = img; + image.Pixbuf = img.ToPixbuf (Gtk.IconSize.Menu); } string TryGetFileType (string name) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/ConfirmProjectDeleteDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/ConfirmProjectDeleteDialog.cs index 7b487a3efe..6c4590a7e1 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/ConfirmProjectDeleteDialog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/ConfirmProjectDeleteDialog.cs @@ -31,6 +31,7 @@ using System.Collections.Generic; using MonoDevelop.Core; using MonoDevelop.Projects; using Gtk; +using MonoDevelop.Components; namespace MonoDevelop.Ide.Projects @@ -70,9 +71,9 @@ namespace MonoDevelop.Ide.Projects col.PackStart (crt, false); col.AddAttribute (crt, "active", 0); - CellRendererPixbuf crp = new CellRendererPixbuf (); + CellRendererImage crp = new CellRendererImage (); col.PackStart (crp, false); - col.AddAttribute (crp, "pixbuf", 1); + col.AddAttribute (crp, "image", 1); CellRendererText cre = new CellRendererText (); col.PackStart (cre, true); @@ -102,7 +103,7 @@ namespace MonoDevelop.Ide.Projects // from the item directory are shown in the list foreach (FilePath f in item.GetItemFiles (false)) { if (!f.IsChildPathOf (item.BaseDirectory)) { - Gdk.Pixbuf pix = DesktopService.GetPixbufForFile (f, IconSize.Menu); + var pix = DesktopService.GetIconForFile (f, IconSize.Menu); paths [f] = store.AppendValues (true, pix, f.FileName, f.ToString ()); } } @@ -178,21 +179,21 @@ namespace MonoDevelop.Ide.Projects TreeIter dit; if (!iter.Equals (TreeIter.Zero)) { - dit = store.AppendValues (iter, false, DesktopService.GetPixbufForFile (dir, IconSize.Menu), dir.FileName.ToString (), dir.ToString ()); + dit = store.AppendValues (iter, false, DesktopService.GetIconForFile (dir, IconSize.Menu), dir.FileName.ToString (), dir.ToString ()); fileList.ExpandRow (store.GetPath (iter), false); } else - dit = store.AppendValues (false, DesktopService.GetPixbufForFile (dir, IconSize.Menu), dir.FileName.ToString (), dir.ToString ()); + dit = store.AppendValues (false, DesktopService.GetIconForFile (dir, IconSize.Menu), dir.FileName.ToString (), dir.ToString ()); paths [dir] = dit; foreach (string file in Directory.GetFiles (dir)) { string path = System.IO.Path.GetFileName (file); - Gdk.Pixbuf pix = DesktopService.GetPixbufForFile (file, IconSize.Menu); + var pix = DesktopService.GetIconForFile (file, IconSize.Menu); bool active = itemFiles.Contains (file); string color = null; if (!active) { - pix = ImageService.MakeTransparent (pix, 0.5); + pix = pix.WithAlpha (0.5); color = "dimgrey"; } else cinfo |= ChildInfo.HasProjectFiles; @@ -219,8 +220,7 @@ namespace MonoDevelop.Ide.Projects if ((cinfo & ChildInfo.AllSelected) != 0 && hasChildren) store.SetValue (dit, 0, true); if ((cinfo & ChildInfo.HasProjectFiles) == 0) { - Gdk.Pixbuf pix = DesktopService.GetPixbufForFile (dir, IconSize.Menu); - pix = ImageService.MakeTransparent (pix, 0.5); + var pix = DesktopService.GetIconForFile (dir, IconSize.Menu).WithAlpha (0.5); store.SetValue (dit, 1, pix); store.SetValue (dit, 4, "dimgrey"); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/IncludeNewFilesDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/IncludeNewFilesDialog.cs index 2ef28f6a38..09399cd809 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/IncludeNewFilesDialog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/IncludeNewFilesDialog.cs @@ -204,7 +204,7 @@ namespace MonoDevelop.Ide.Projects TreeIter iter = GetPath (relativePath.ParentDirectory); object[] values = new object[] { //FIXME: look these pixbufs up lazily in the renderer - DesktopService.GetPixbufForFile (filePath, IconSize.Menu), + DesktopService.GetIconForFile (filePath, IconSize.Menu), null, filePath.FileName, filePath.ToString (), diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/ProjectFileSelectorDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/ProjectFileSelectorDialog.cs index 8f0f3aec9a..596f5e4336 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/ProjectFileSelectorDialog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/ProjectFileSelectorDialog.cs @@ -276,7 +276,7 @@ namespace MonoDevelop.Ide.Projects continue; if (regex.IsMatch (pf.FilePath.FileName)) - fileStore.AppendValues (pf, DesktopService.GetPixbufForFile (pf.FilePath, Gtk.IconSize.Menu)); + fileStore.AppendValues (pf, DesktopService.GetIconForFile (pf.FilePath, Gtk.IconSize.Menu)); } TreeIter root; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs index 99fea3e064..a99f59b37b 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs @@ -30,6 +30,7 @@ using Mono.Addins; using MonoDevelop.Ide.Desktop; using MonoDevelop.Core; using System.IO; +using MonoDevelop.Components; using MonoDevelop.Components.MainToolbar; namespace MonoDevelop.Ide @@ -169,14 +170,24 @@ namespace MonoDevelop.Ide return PlatformService.GetMimeTypeInheritanceChain (mimeType); } - public static Gdk.Pixbuf GetPixbufForFile (string filename, Gtk.IconSize size) + public static Xwt.Drawing.Image GetIconForFile (string filename) { - return PlatformService.GetPixbufForFile (filename, size); + return PlatformService.GetIconForFile (filename); + } + + public static Xwt.Drawing.Image GetIconForFile (string filename, Gtk.IconSize size) + { + return PlatformService.GetIconForFile (filename).WithSize (size); } - public static Gdk.Pixbuf GetPixbufForType (string mimeType, Gtk.IconSize size) + public static Xwt.Drawing.Image GetIconForType (string mimeType) + { + return PlatformService.GetIconForType (mimeType); + } + + public static Xwt.Drawing.Image GetIconForType (string mimeType, Gtk.IconSize size) { - return PlatformService.GetPixbufForType (mimeType, size); + return PlatformService.GetIconForType (mimeType).WithSize (size); } public static bool SetGlobalMenu (MonoDevelop.Components.Commands.CommandManager commandManager, diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ImageService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ImageService.cs index cdeeb66ad8..510503c9c9 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ImageService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ImageService.cs @@ -281,6 +281,11 @@ namespace MonoDevelop.Ide public static Xwt.Drawing.Image GetIcon (string name) { + return GetIcon (name, true); + } + + public static Xwt.Drawing.Image GetIcon (string name, bool generateDefaultIcon) + { name = name ?? ""; Xwt.Drawing.Image img; @@ -289,7 +294,7 @@ namespace MonoDevelop.Ide if (string.IsNullOrEmpty (name)) { LoggingService.LogWarning ("Empty icon requested. Stack Trace: " + Environment.NewLine + Environment.StackTrace); - icons [name] = img = CreateColorBlock ("#FF0000", Gtk.IconSize.Dialog).ToXwtImage (); + icons [name] = img = CreateColorIcon ("#FF0000"); return img; } @@ -301,6 +306,12 @@ namespace MonoDevelop.Ide EnsureStockIconIsLoaded (name); + Gtk.IconSet iconset = Gtk.IconFactory.LookupDefault (name); + if (iconset == null && !Gtk.IconTheme.Default.HasIcon (name) && generateDefaultIcon) { + LoggingService.LogWarning ("Unknown icon: " + name); + return CreateColorIcon ("#FF0000FF"); + } + return icons [name] = img = Xwt.Toolkit.CurrentEngine.WrapImage (name); } @@ -417,6 +428,17 @@ namespace MonoDevelop.Ide } } + static Xwt.Drawing.Image CreateColorIcon (string name) + { + var color = Xwt.Drawing.Color.FromName (name); + using (var ib = new Xwt.Drawing.ImageBuilder (16, 16)) { + ib.Context.Rectangle (0, 0, 16, 16); + ib.Context.SetColor (color); + ib.Context.Fill (); + return ib.ToVectorImage (); + } + } + static Gdk.Pixbuf CreateColorBlock (string name, Gtk.IconSize size) { int w, h; |