internal static void Initialize(Gtk.Widget iconRenderer) { if ((Stetic.Gui.initialized == false)) { Stetic.Gui.initialized = true; Gtk.IconFactory w1 = new Gtk.IconFactory(); Gtk.IconSet w2 = new Gtk.IconSet(new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "./icons/rss.png"))); w1.Add("rss", w2); Gtk.IconSet w3 = new Gtk.IconSet(new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "./icons/donotdownload.png"))); w1.Add("donotdownload", w3); Gtk.IconSet w4 = new Gtk.IconSet(new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "./icons/high.png"))); w1.Add("high", w4); Gtk.IconSet w5 = new Gtk.IconSet(new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "./icons/highest.png"))); w1.Add("highest", w5); Gtk.IconSet w6 = new Gtk.IconSet(new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "./icons/immediate.png"))); w1.Add("immediate", w6); Gtk.IconSet w7 = new Gtk.IconSet(new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "./icons/low.png"))); w1.Add("low", w7); Gtk.IconSet w8 = new Gtk.IconSet(new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "./icons/lowest.png"))); w1.Add("lowest", w8); Gtk.IconSet w9 = new Gtk.IconSet(new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "./icons/normal.png"))); w1.Add("normal", w9); Gtk.IconSet w10 = new Gtk.IconSet(Stetic.IconLoader.LoadIcon(iconRenderer, "stock_weather-showers", Gtk.IconSize.Dialog, 48)); w1.Add("weather", w10); w1.AddDefault(); } }
internal static void Initialize(Gtk.Widget iconRenderer) { if ((Stetic.Gui.initialized == false)) { Stetic.Gui.initialized = true; Gtk.IconFactory w1 = new Gtk.IconFactory(); Gtk.IconSet w2 = new Gtk.IconSet(Gdk.Pixbuf.LoadFromResource("simple_icon.png")); w1.Add("magnatune", w2); w1.AddDefault(); } }
internal static void Initialize() { if ((Stetic.Gui.initialized == false)) { Stetic.Gui.initialized = true; Gtk.IconFactory w1 = new Gtk.IconFactory(); Gtk.IconSet w2 = new Gtk.IconSet(new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "./system-software-update_22.png"))); w1.Add("AddinManager", w2); w1.AddDefault(); } }
static void AddToIconFactory(string stockId, Gdk.Pixbuf pixbuf, Gdk.Pixbuf pixbuf2x, Gtk.IconSize iconSize) { Gtk.IconSet iconSet = iconFactory.Lookup(stockId); if (iconSet == null) { iconSet = new Gtk.IconSet(); iconFactory.Add(stockId, iconSet); } Gtk.IconSource source = new Gtk.IconSource(); Gtk.IconSource source2x = null; if (Platform.IsWindows) { var pixel_scale = Mono.TextEditor.GtkWorkarounds.GetPixelScale(); source.Pixbuf = pixbuf.ScaleSimple((int)(pixbuf.Width * pixel_scale), (int)(pixbuf.Height * pixel_scale), Gdk.InterpType.Bilinear); } else { source.Pixbuf = pixbuf; } source.Size = iconSize; source.SizeWildcarded = iconSize == Gtk.IconSize.Invalid; if (pixbuf2x != null) { if (Mono.TextEditor.GtkWorkarounds.SetSourceScale(source, 1)) { Mono.TextEditor.GtkWorkarounds.SetSourceScaleWildcarded(source, false); source2x = new Gtk.IconSource(); source2x.Pixbuf = pixbuf2x; source2x.Size = iconSize; source2x.SizeWildcarded = iconSize == Gtk.IconSize.Invalid; Mono.TextEditor.GtkWorkarounds.SetSourceScale(source2x, 2); Mono.TextEditor.GtkWorkarounds.SetSourceScaleWildcarded(source2x, false); } } else { Mono.TextEditor.GtkWorkarounds.SetSourceScaleWildcarded(source, true); } iconSet.AddSource(source); if (source2x != null) { iconSet.AddSource(source2x); } }
public Image(Gtk.IconSet icon_set, Gtk.IconSize size) : base(IntPtr.Zero) { if (GetType() != typeof(Image)) { var vals = new List <GLib.Value> (); var names = new List <string> (); names.Add("icon_set"); vals.Add(new GLib.Value(icon_set)); names.Add("icon_size"); vals.Add(new GLib.Value((int)size)); CreateNativeObject(names.ToArray(), vals.ToArray()); return; } Raw = gtk_image_new_from_icon_set(icon_set.Handle, (int)size); }
public Image(Gtk.IconSet icon_set, Gtk.IconSize size) : base(IntPtr.Zero) { if (GetType() != typeof(Image)) { ArrayList vals = new ArrayList(); ArrayList names = new ArrayList(); names.Add("icon_set"); vals.Add(new GLib.Value(icon_set)); names.Add("icon_size"); vals.Add(new GLib.Value((int)size)); CreateNativeObject((string[])names.ToArray(typeof(string)), (GLib.Value[])vals.ToArray(typeof(GLib.Value))); return; } Raw = gtk_image_new_from_icon_set(icon_set.Handle, (int)size); }
/// <summary> /// Create Pixbuf from stockId. /// </summary> /// <param name="iconName">Image stock id.</param> /// <param name="size">Icon Size.</param> /// <returns>Return Pixbuf</returns> public Gdk.Pixbuf GetIconFromStock(string iconName, Gtk.IconSize size) { string stockid = iconName; if (stockid != null) { Gtk.IconSet iconset = Gtk.IconFactory.LookupDefault(stockid); if (iconset != null) { return(iconset.RenderIcon(Gtk.Widget.DefaultStyle, Gtk.TextDirection.None, Gtk.StateType.Normal, size, null, null)); } } return(null); }
static void AddToIconFactory(string stockId, Gdk.Pixbuf pixbuf, Gtk.IconSize iconSize) { Gtk.IconSet iconSet = iconFactory.Lookup(stockId); if (iconSet == null) { iconSet = new Gtk.IconSet(); iconFactory.Add(stockId, iconSet); } Gtk.IconSource source = new Gtk.IconSource(); source.Pixbuf = pixbuf; source.Size = iconSize; source.SizeWildcarded = iconSize == Gtk.IconSize.Invalid; iconSet.AddSource(source); }
public static Gdk.Pixbuf GetPixbuf(string name, Gtk.IconSize size, bool generateDefaultIcon) { if (string.IsNullOrEmpty(name)) { LoggingService.LogWarning("Empty icon requested. Stack Trace: " + Environment.NewLine + Environment.StackTrace); return(CreateColorBlock("#FF0000", size)); } // If this name refers to an icon defined in an extension point, the images for the icon will now be laoded EnsureStockIconIsLoaded(name, size); //if an icon name begins with '#', we assume it's a hex colour if (name[0] == '#') { return(CreateColorBlock(name, size)); } // Converts an image spec into a real stock icon id string stockid = GetStockIdForImageSpec(name, size); if (string.IsNullOrEmpty(stockid)) { LoggingService.LogWarning("Can't get stock id for " + name + " : " + Environment.NewLine + Environment.StackTrace); return(CreateColorBlock("#FF0000", size)); } Gtk.IconSet iconset = Gtk.IconFactory.LookupDefault(stockid); if (iconset != null) { return(iconset.RenderIcon(Gtk.Widget.DefaultStyle, Gtk.TextDirection.Ltr, Gtk.StateType.Normal, size, null, null)); } if (Gtk.IconTheme.Default.HasIcon(stockid)) { int w, h; Gtk.Icon.SizeLookup(size, out w, out h); Gdk.Pixbuf result = Gtk.IconTheme.Default.LoadIcon(stockid, h, (Gtk.IconLookupFlags) 0); return(result); } if (generateDefaultIcon) { LoggingService.LogWarning("Can't lookup icon: " + name); return(CreateColorBlock("#FF0000FF", size)); } return(null); }
internal static Gdk.Pixbuf CreateBitmap(string stockId, double width, double height, double scaleFactor) { Gdk.Pixbuf result = null; Gtk.IconSet iconset = Gtk.IconFactory.LookupDefault(stockId); if (iconset != null) { // Find the size that better fits the requested size Gtk.IconSize gsize = Util.GetBestSizeFit(width); result = iconset.RenderIcon(Gtk.Widget.DefaultStyle, Gtk.TextDirection.Ltr, Gtk.StateType.Normal, gsize, null, null, scaleFactor); if (result == null || result.Width < width * scaleFactor) { var gsize2x = Util.GetBestSizeFit(width * scaleFactor, iconset.Sizes); if (gsize2x != Gtk.IconSize.Invalid && gsize2x != gsize) { // Don't dispose the previous result since the icon is owned by the IconSet result = iconset.RenderIcon(Gtk.Widget.DefaultStyle, Gtk.TextDirection.Ltr, Gtk.StateType.Normal, gsize2x, null, null); } } } if (result == null && Gtk.IconTheme.Default.HasIcon(stockId)) { result = Gtk.IconTheme.Default.LoadIcon(stockId, (int)width, (Gtk.IconLookupFlags) 0); } if (result == null) { // return CreateBitmap (Gtk.Stock.MissingImage, width, height, scaleFactor); int w = (int)width; int h = (int)height; Gdk.Pixmap pmap = new Gdk.Pixmap(Gdk.Screen.Default.RootWindow, w, h); Gdk.GC gc = new Gdk.GC(pmap); gc.RgbFgColor = new Gdk.Color(255, 255, 255); pmap.DrawRectangle(gc, true, 0, 0, w, h); gc.RgbFgColor = new Gdk.Color(0, 0, 0); pmap.DrawRectangle(gc, false, 0, 0, (w - 1), (h - 1)); gc.SetLineAttributes(3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round); gc.RgbFgColor = new Gdk.Color(255, 0, 0); pmap.DrawLine(gc, (w / 4), (h / 4), ((w - 1) - (w / 4)), ((h - 1) - (h / 4))); pmap.DrawLine(gc, ((w - 1) - (w / 4)), (h / 4), (w / 4), ((h - 1) - (h / 4))); return(Gdk.Pixbuf.FromDrawable(pmap, pmap.Colormap, 0, 0, 0, 0, w, h)); } return(result); }
internal static void Initialize(Gtk.Widget iconRenderer) { if ((Stetic.Gui.initialized == false)) { Stetic.Gui.initialized = true; Gtk.IconFactory w1 = new Gtk.IconFactory(); Gtk.IconSet w2 = new Gtk.IconSet(Stetic.IconLoader.LoadIcon(iconRenderer, "gtk-convert", Gtk.IconSize.Menu, 16)); w1.Add("relation.png", w2); Gtk.IconSet w3 = new Gtk.IconSet(Stetic.IconLoader.LoadIcon(iconRenderer, "gtk-missing-image", Gtk.IconSize.Menu, 16)); w1.Add("entity.png", w3); Gtk.IconSet w4 = new Gtk.IconSet(Stetic.IconLoader.LoadIcon(iconRenderer, "gtk-missing-image", Gtk.IconSize.Menu, 16)); w1.Add("relation_handle.png", w4); Gtk.IconSet w5 = new Gtk.IconSet(Stetic.IconLoader.LoadIcon(iconRenderer, "gtk-missing-image", Gtk.IconSize.Menu, 16)); w1.Add("attribute_handle.png", w5); Gtk.IconSet w6 = new Gtk.IconSet(Stetic.IconLoader.LoadIcon(iconRenderer, "gtk-missing-image", Gtk.IconSize.Menu, 16)); w1.Add("entity_handle.png", w6); w1.AddDefault(); } }
internal static void Initialize(Gtk.Widget iconRenderer) { if ((Stetic.Gui.initialized == false)) { Stetic.Gui.initialized = true; Gtk.IconFactory w1 = new Gtk.IconFactory(); Gtk.IconSet w2 = new Gtk.IconSet(); Gtk.IconSource w3 = new Gtk.IconSource(); w3.Pixbuf = new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "./res/swap.png")); w2.AddSource(w3); Gtk.IconSource w4 = new Gtk.IconSource(); w4.Pixbuf = new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "./res/flags/ar.png")); w2.AddSource(w4); Gtk.IconSource w5 = new Gtk.IconSource(); w5.Pixbuf = new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "./res/flags/bg.png")); w2.AddSource(w5); w1.Add("swap", w2); w1.AddDefault(); } }
internal static Gdk.Pixbuf CreateBitmap(string stockId, double width, double height) { Gdk.Pixbuf result = null; Gtk.IconSet iconset = Gtk.IconFactory.LookupDefault(stockId); if (iconset != null) { // Find the size that better fits the requested size Gtk.IconSize gsize = Util.GetBestSizeFit(width); result = iconset.RenderIcon(Gtk.Widget.DefaultStyle, Gtk.TextDirection.Ltr, Gtk.StateType.Normal, gsize, null, null); } if (result == null && Gtk.IconTheme.Default.HasIcon(stockId)) { result = Gtk.IconTheme.Default.LoadIcon(stockId, (int)width, (Gtk.IconLookupFlags) 0); } return(result); }
internal static void Initialize(Gtk.Widget iconRenderer) { if ((Stetic.Gui.initialized == false)) { Stetic.Gui.initialized = true; Gtk.IconFactory w1 = new Gtk.IconFactory(); Gtk.IconSet w2 = new Gtk.IconSet(Stetic.IconLoader.LoadIcon(iconRenderer, "gtk-harddisk", Gtk.IconSize.Menu, 16)); w1.Add("Device", w2); Gtk.IconSet w3 = new Gtk.IconSet(Stetic.IconLoader.LoadIcon(iconRenderer, "gtk-execute", Gtk.IconSize.Menu, 16)); w1.Add("Service", w3); Gtk.IconSet w4 = new Gtk.IconSet(Stetic.IconLoader.LoadIcon(iconRenderer, "gtk-go-forward", Gtk.IconSize.Menu, 16)); w1.Add("Input", w4); Gtk.IconSet w5 = new Gtk.IconSet(Stetic.IconLoader.LoadIcon(iconRenderer, "gtk-go-back", Gtk.IconSize.Menu, 16)); w1.Add("Output", w5); Gtk.IconSet w6 = new Gtk.IconSet(Stetic.IconLoader.LoadIcon(iconRenderer, "gtk-go-up", Gtk.IconSize.Menu, 16)); w1.Add("Return", w6); w1.AddDefault(); } }
public override object LoadFromIcon(string id, IconSize size) { string stockId = Util.ToGtkStock(id); var gsize = Util.ToGtkSize(size); Gtk.IconSet iconset = Gtk.IconFactory.LookupDefault(stockId); if (iconset != null) { return(iconset.RenderIcon(Gtk.Widget.DefaultStyle, Gtk.TextDirection.Ltr, Gtk.StateType.Normal, gsize, null, null)); } if (Gtk.IconTheme.Default.HasIcon(stockId)) { int w, h; Gtk.Icon.SizeLookup(gsize, out w, out h); Gdk.Pixbuf result = Gtk.IconTheme.Default.LoadIcon(stockId, h, (Gtk.IconLookupFlags) 0); return(result); } return(null); }
public override void SetImage(Gtk.Image imageView, Gtk.IconSize?iconSize) { using (var drawable = new Gdk.Pixmap(null, Size.Width, Size.Height, 24)) using (var gc = new Gdk.GC(drawable)) { drawable.Colormap = new Gdk.Colormap(Gdk.Visual.System, true); drawable.DrawIndexedImage(gc, 0, 0, Size.Width, Size.Height, Gdk.RgbDither.None, Control, rowStride, GetPmap()); if (iconSize != null) { var iconSet = new Gtk.IconSet(Gdk.Pixbuf.FromDrawable(drawable, Gdk.Colormap.System, 0, 0, 0, 0, size.Width, size.Height)); imageView.SetFromIconSet(iconSet, iconSize.Value); } else { imageView.Pixmap = drawable; } } }
public static Xwt.Drawing.Image GetIcon(string name, bool generateDefaultIcon) { name = name ?? ""; Xwt.Drawing.Image img; if (icons.TryGetValue(name, out img)) { return(img); } if (string.IsNullOrEmpty(name)) { LoggingService.LogWarning("Empty icon requested. Stack Trace: " + Environment.NewLine + Environment.StackTrace); icons [name] = img = CreateColorIcon("#FF0000"); return(img); } //if an icon name begins with '#', we assume it's a hex colour if (name[0] == '#') { icons [name] = img = CreateColorBlock(name, Gtk.IconSize.Dialog).ToXwtImage(); return(img); } EnsureStockIconIsLoaded(name); // Try again since it may have already been registered if (icons.TryGetValue(name, out img)) { return(img); } 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)); }
static void AddToIconFactory(string stockId, Gdk.Pixbuf pixbuf, Gdk.Pixbuf pixbuf2x, Gtk.IconSize iconSize) { Gtk.IconSet iconSet = iconFactory.Lookup(stockId); if (iconSet == null) { iconSet = new Gtk.IconSet(); iconFactory.Add(stockId, iconSet); } Gtk.IconSource source = new Gtk.IconSource(); Gtk.IconSource source2x = null; source.Pixbuf = pixbuf; source.Size = iconSize; source.SizeWildcarded = iconSize == Gtk.IconSize.Invalid; if (pixbuf2x != null) { if (Mono.TextEditor.GtkWorkarounds.SetSourceScale(source, 1)) { Mono.TextEditor.GtkWorkarounds.SetSourceScaleWildcarded(source, false); source2x = new Gtk.IconSource(); source2x.Pixbuf = pixbuf2x; source2x.Size = iconSize; source2x.SizeWildcarded = iconSize == Gtk.IconSize.Invalid; Mono.TextEditor.GtkWorkarounds.SetSourceScale(source2x, 2); Mono.TextEditor.GtkWorkarounds.SetSourceScaleWildcarded(source2x, false); } } else { Mono.TextEditor.GtkWorkarounds.SetSourceScaleWildcarded(source, true); } iconSet.AddSource(source); if (source2x != null) { iconSet.AddSource(source2x); } }
public Gdk.Pixbuf RenderIcon(Gtk.IconSize size) { if (GtkAction.StockId == null) { return(null); } Gdk.Pixbuf px = Project.IconFactory.RenderIcon(Project, GtkAction.StockId, size); if (px != null) { return(px); } Gtk.IconSet iset = Gtk.IconFactory.LookupDefault(GtkAction.StockId); if (iset == null) { return(WidgetUtils.MissingIcon); } else { return(iset.RenderIcon(new Gtk.Style(), Gtk.TextDirection.Ltr, Gtk.StateType.Normal, size, null, "")); } }
internal static void Initialize() { if ((Stetic.Gui.initialized == false)) { Stetic.Gui.initialized = true; Gtk.IconFactory w1 = new Gtk.IconFactory(); Gtk.IconSet w2 = new Gtk.IconSet(new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "./icons/rss.png"))); w1.Add("rss", w2); Gtk.IconSet w3 = new Gtk.IconSet(new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "./icons/donotdownload.png"))); w1.Add("donotdownload", w3); Gtk.IconSet w4 = new Gtk.IconSet(new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "./icons/high.png"))); w1.Add("high", w4); Gtk.IconSet w5 = new Gtk.IconSet(new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "./icons/highest.png"))); w1.Add("highest", w5); Gtk.IconSet w6 = new Gtk.IconSet(new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "./icons/immediate.png"))); w1.Add("immediate", w6); Gtk.IconSet w7 = new Gtk.IconSet(new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "./icons/low.png"))); w1.Add("low", w7); Gtk.IconSet w8 = new Gtk.IconSet(new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "./icons/lowest.png"))); w1.Add("lowest", w8); Gtk.IconSet w9 = new Gtk.IconSet(new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "./icons/normal.png"))); w1.Add("normal", w9); w1.AddDefault(); } }
void IExtensionService.Initialize() { Marshaller.Init(); has_karaoke = Marshaller.CheckGstPlugin("audiokaraoke"); Hyena.Log.Debug("[Karaoke] GstPlugin audiokaraoke" + (has_karaoke ? "" : " not") + " found"); if (!has_karaoke) { Hyena.Log.Warning("[Karaoke] audiokaraoke is not available, please install gstreamer-good-plugins"); return; } action_service = ServiceManager.Get <InterfaceActionService> (); actions = new Gtk.ActionGroup("Karaoke"); actions.Add(new Gtk.ActionEntry[] { new Gtk.ActionEntry("KaraokeAction", null, AddinManager.CurrentLocalizer.GetString("_Karaoke"), null, null, null), new Gtk.ActionEntry("KaraokeConfigureAction", Gtk.Stock.Properties, AddinManager.CurrentLocalizer.GetString("_Configure"), null, AddinManager.CurrentLocalizer.GetString("Configure the Karaoke extension"), OnConfigure) }); Gdk.Pixbuf icon = new Gdk.Pixbuf(System.Reflection.Assembly.GetExecutingAssembly() .GetManifestResourceStream("microphone.png")); Gtk.IconSet iconset = new Gtk.IconSet(icon); Gtk.IconFactory iconfactory = new Gtk.IconFactory(); iconfactory.Add("microphone", iconset); iconfactory.AddDefault(); actions.Add(new Gtk.ToggleActionEntry[] { new Gtk.ToggleActionEntry("KaraokeEnableAction", "microphone", AddinManager.CurrentLocalizer.GetString("_Activate Karaoke mode"), null, AddinManager.CurrentLocalizer.GetString("Activate Karaoke mode"), OnActivateKaraoke, karaoke_enabled) }); action_service.UIManager.InsertActionGroup(actions, 0); ui_menu_id = action_service.UIManager.AddUiFromResource("KaraokeMenu.xml"); ui_button_id = action_service.UIManager.AddUiFromResource("KaraokeButton.xml"); }
protected override void Initialize() { base.Initialize(); string name = (string)Value; if (name != null) { Stetic.ObjectWrapper w = Stetic.ObjectWrapper.Lookup(Instance); Stetic.IProject project = w.Project; Gdk.Pixbuf px = project.IconFactory.RenderIcon(project, name, ImageSize); if (px != null) { Image = px; label = name; return; } Gtk.StockItem item = Gtk.Stock.Lookup(name); label = item.Label != null && item.Label.Length > 0 ? item.Label : name; label = label.Replace("_", ""); Gtk.IconSet iset = Gtk.IconFactory.LookupDefault(name); if (iset == null) { Image = WidgetUtils.MissingIcon; } else { Image = iset.RenderIcon(new Gtk.Style(), Gtk.TextDirection.Ltr, Gtk.StateType.Normal, Gtk.IconSize.Menu, null, ""); } } else { Image = null; label = ""; } }
void IExtensionService.Initialize() { Marshaller.Init (); has_karaoke = Marshaller.CheckGstPlugin ("audiokaraoke"); Hyena.Log.Debug ("[Karaoke] GstPlugin audiokaraoke" + (has_karaoke ? "" : " not") + " found"); if (!has_karaoke) { Hyena.Log.Warning ("[Karaoke] audiokaraoke is not available, please install gstreamer-good-plugins"); return; } action_service = ServiceManager.Get<InterfaceActionService> (); actions = new Gtk.ActionGroup ("Karaoke"); actions.Add (new Gtk.ActionEntry[] { new Gtk.ActionEntry ("KaraokeAction", null, AddinManager.CurrentLocalizer.GetString ("_Karaoke"), null, null, null), new Gtk.ActionEntry ("KaraokeConfigureAction", Gtk.Stock.Properties, AddinManager.CurrentLocalizer.GetString ("_Configure"), null, AddinManager.CurrentLocalizer.GetString ("Configure the Karaoke extension"), OnConfigure) }); Gdk.Pixbuf icon = new Gdk.Pixbuf (System.Reflection.Assembly.GetExecutingAssembly () .GetManifestResourceStream ("microphone.png")); Gtk.IconSet iconset = new Gtk.IconSet (icon); Gtk.IconFactory iconfactory = new Gtk.IconFactory (); iconfactory.Add ("microphone", iconset); iconfactory.AddDefault (); actions.Add (new Gtk.ToggleActionEntry[] { new Gtk.ToggleActionEntry ("KaraokeEnableAction", "microphone", AddinManager.CurrentLocalizer.GetString ("_Activate Karaoke mode"), null, AddinManager.CurrentLocalizer.GetString ("Activate Karaoke mode"), OnActivateKaraoke, karaoke_enabled) }); action_service.UIManager.InsertActionGroup (actions, 0); ui_menu_id = action_service.UIManager.AddUiFromResource ("KaraokeMenu.xml"); ui_button_id = action_service.UIManager.AddUiFromResource ("KaraokeButton.xml"); }
static void AddToIconFactory (string stockId, Gdk.Pixbuf pixbuf, Gdk.Pixbuf pixbuf2x, Gtk.IconSize iconSize) { Gtk.IconSet iconSet = iconFactory.Lookup (stockId); if (iconSet == null) { iconSet = new Gtk.IconSet (); iconFactory.Add (stockId, iconSet); } Gtk.IconSource source = new Gtk.IconSource (); Gtk.IconSource source2x = null; source.Pixbuf = pixbuf; source.Size = iconSize; source.SizeWildcarded = iconSize == Gtk.IconSize.Invalid; if (pixbuf2x != null) { if (Mono.TextEditor.GtkWorkarounds.SetSourceScale (source, 1)) { Mono.TextEditor.GtkWorkarounds.SetSourceScaleWildcarded (source, false); source2x = new Gtk.IconSource (); source2x.Pixbuf = pixbuf2x; source2x.Size = iconSize; source2x.SizeWildcarded = iconSize == Gtk.IconSize.Invalid; Mono.TextEditor.GtkWorkarounds.SetSourceScale (source2x, 2); Mono.TextEditor.GtkWorkarounds.SetSourceScaleWildcarded (source2x, false); } } else { Mono.TextEditor.GtkWorkarounds.SetSourceScaleWildcarded (source, true); } iconSet.AddSource (source); if (source2x != null) iconSet.AddSource (source2x); }
static void AddToIconFactory (string stockId, Gdk.Pixbuf pixbuf, Gdk.Pixbuf pixbuf2x, Gtk.IconSize iconSize) { Gtk.IconSet iconSet = iconFactory.Lookup (stockId); if (iconSet == null) { iconSet = new Gtk.IconSet (); iconFactory.Add (stockId, iconSet); } Gtk.IconSource source = new Gtk.IconSource (); Gtk.IconSource source2x = null; if (Platform.IsWindows) { var pixel_scale = Mono.TextEditor.GtkWorkarounds.GetPixelScale (); source.Pixbuf = pixbuf.ScaleSimple ((int)(pixbuf.Width * pixel_scale), (int)(pixbuf.Height * pixel_scale), Gdk.InterpType.Bilinear); } else { source.Pixbuf = pixbuf; } source.Size = iconSize; source.SizeWildcarded = iconSize == Gtk.IconSize.Invalid; if (pixbuf2x != null) { if (Mono.TextEditor.GtkWorkarounds.SetSourceScale (source, 1)) { Mono.TextEditor.GtkWorkarounds.SetSourceScaleWildcarded (source, false); source2x = new Gtk.IconSource (); source2x.Pixbuf = pixbuf2x; source2x.Size = iconSize; source2x.SizeWildcarded = iconSize == Gtk.IconSize.Invalid; Mono.TextEditor.GtkWorkarounds.SetSourceScale (source2x, 2); Mono.TextEditor.GtkWorkarounds.SetSourceScaleWildcarded (source2x, false); } } else { Mono.TextEditor.GtkWorkarounds.SetSourceScaleWildcarded (source, true); } iconSet.AddSource (source); if (source2x != null) iconSet.AddSource (source2x); }
internal static void Initialize(Gtk.Widget iconRenderer) { if ((Stetic.Gui.initialized == false)) { Stetic.Gui.initialized = true; Gtk.IconFactory w1 = new Gtk.IconFactory(); Gtk.IconSet w2 = new Gtk.IconSet(omvviewerlight.MainClass.GetResource("icn_voice-groupfocus.png")); w1.Add("Groups", w2); w1.AddDefault(); } }
internal static void Initialize(Gtk.Widget iconRenderer) { if ((Stetic.Gui.initialized == false)) { Stetic.Gui.initialized = true; Gtk.IconFactory w1 = new Gtk.IconFactory(); Gtk.IconSet w2 = new Gtk.IconSet(Gdk.Pixbuf.LoadFromResource("Resources.inbox-16.png")); w1.Add("adroit-inbox", w2); Gtk.IconSet w3 = new Gtk.IconSet(Gdk.Pixbuf.LoadFromResource("Resources.reference-16.png")); w1.Add("adroit-reference", w3); Gtk.IconSet w4 = new Gtk.IconSet(Gdk.Pixbuf.LoadFromResource("Resources.incubator-16.png")); w1.Add("adroit-incubator", w4); w1.AddDefault(); } }
public void SetFromIconSet(Gtk.IconSet icon_set, Gtk.IconSize size) { gtk_image_set_from_icon_set(Handle, icon_set == null ? IntPtr.Zero : icon_set.Handle, (int)size); }
internal static void AddToIconFactory(string stockId, Gdk.Pixbuf pixbuf, Gtk.IconSize iconSize) { Gtk.IconSet iconSet = iconFactory.Lookup (stockId); if (iconSet == null) { iconSet = new Gtk.IconSet (); iconFactory.Add (stockId, iconSet); } Gtk.IconSource source = new Gtk.IconSource (); source.Pixbuf = pixbuf; source.Size = iconSize; iconSet.AddSource (source); }
internal static void AddToIconFactory(string stockId, string filename, Gtk.IconSize iconSize) { try { Gtk.IconSet iconSet = iconFactory.Lookup (stockId); if (iconSet == null) { iconSet = new Gtk.IconSet (); iconFactory.Add (stockId, iconSet); } Gtk.IconSource source = new Gtk.IconSource (); source.Filename = Path.GetFullPath (Path.Combine ("../data/resources/icons", filename)); source.Size = iconSize; iconSet.AddSource (source); // FIXME: temporary hack to retrieve the correct icon // from the filename stockMappings.Add (filename, stockId); } catch (GLib.GException ex) { // just discard the exception, the icon simply can't be // loaded Runtime.LoggingService.Info(typeof(ResourceService).ToString(), "Warning: can't load " + filename + " icon file"); } }
internal static Gdk.Pixbuf CreateBitmap(string stockId, double width, double height, double scaleFactor) { Gdk.Pixbuf result = null; Gtk.IconSet iconset = Gtk.IconFactory.LookupDefault(stockId); if (iconset != null) { // Find the size that better fits the requested size Gtk.IconSize gsize = Util.GetBestSizeFit(width); result = iconset.RenderIcon(Gtk.Widget.DefaultStyle, Gtk.TextDirection.Ltr, Gtk.StateType.Normal, gsize, null, null, scaleFactor); if (result == null || result.Width < width * scaleFactor) { var gsize2x = Util.GetBestSizeFit(width * scaleFactor, iconset.Sizes); if (gsize2x != Gtk.IconSize.Invalid && gsize2x != gsize) { // Don't dispose the previous result since the icon is owned by the IconSet result = iconset.RenderIcon(Gtk.Widget.DefaultStyle, Gtk.TextDirection.Ltr, Gtk.StateType.Normal, gsize2x, null, null); } } } if (result == null && Gtk.IconTheme.Default.HasIcon(stockId)) { result = Gtk.IconTheme.Default.LoadIcon(stockId, (int)width, (Gtk.IconLookupFlags) 0); } if (result == null) { // render a custom gtk-missing-image icon // if Gtk.Stock.MissingImage is not found int w = (int)width; int h = (int)height; #if XWT_GTK3 Cairo.ImageSurface s = new Cairo.ImageSurface(Cairo.Format.ARGB32, w, h); Cairo.Context cr = new Cairo.Context(s); cr.SetSourceRGB(255, 255, 255); cr.Rectangle(0, 0, w, h); cr.Fill(); cr.SetSourceRGB(0, 0, 0); cr.LineWidth = 1; cr.Rectangle(0.5, 0.5, w - 1, h - 1); cr.Stroke(); cr.SetSourceRGB(255, 0, 0); cr.LineWidth = 3; cr.LineCap = Cairo.LineCap.Round; cr.LineJoin = Cairo.LineJoin.Round; cr.MoveTo(w / 4, h / 4); cr.LineTo((w - 1) - w / 4, (h - 1) - h / 4); cr.MoveTo(w / 4, (h - 1) - h / 4); cr.LineTo((w - 1) - w / 4, h / 4); cr.Stroke(); result = Gtk3Extensions.GetFromSurface(s, 0, 0, w, h); #else using (Gdk.Pixmap pmap = new Gdk.Pixmap(Gdk.Screen.Default.RootWindow, w, h)) using (Gdk.GC gc = new Gdk.GC(pmap)) { gc.RgbFgColor = new Gdk.Color(255, 255, 255); pmap.DrawRectangle(gc, true, 0, 0, w, h); gc.RgbFgColor = new Gdk.Color(0, 0, 0); pmap.DrawRectangle(gc, false, 0, 0, (w - 1), (h - 1)); gc.SetLineAttributes(3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round); gc.RgbFgColor = new Gdk.Color(255, 0, 0); pmap.DrawLine(gc, (w / 4), (h / 4), ((w - 1) - (w / 4)), ((h - 1) - (h / 4))); pmap.DrawLine(gc, ((w - 1) - (w / 4)), (h / 4), (w / 4), ((h - 1) - (h / 4))); result = Gdk.Pixbuf.FromDrawable(pmap, pmap.Colormap, 0, 0, 0, 0, w, h); } #endif } return(result); }
internal static void Initialize(Gtk.Widget iconRenderer) { if ((Stetic.Gui.initialized == false)) { Stetic.Gui.initialized = true; Gtk.IconFactory w1 = new Gtk.IconFactory(); Gtk.IconSet w2 = new Gtk.IconSet(Gdk.Pixbuf.LoadFromResource("selection-tool.png")); w1.Add("selection-tool", w2); Gtk.IconSet w3 = new Gtk.IconSet(Gdk.Pixbuf.LoadFromResource("circle-tool.png")); w1.Add("circle-tool", w3); Gtk.IconSet w4 = new Gtk.IconSet(Gdk.Pixbuf.LoadFromResource("ellipse-tool.png")); w1.Add("ellipse-tool", w4); Gtk.IconSet w5 = new Gtk.IconSet(Gdk.Pixbuf.LoadFromResource("path-tool.png")); w1.Add("path-tool", w5); Gtk.IconSet w6 = new Gtk.IconSet(Gdk.Pixbuf.LoadFromResource("rectangle-tool.png")); w1.Add("rectangle-tool", w6); Gtk.IconSet w7 = new Gtk.IconSet(Gdk.Pixbuf.LoadFromResource("square-tool.png")); w1.Add("square-tool", w7); Gtk.IconSet w8 = new Gtk.IconSet(Gdk.Pixbuf.LoadFromResource("line-tool.png")); w1.Add("line-tool", w8); Gtk.IconSet w9 = new Gtk.IconSet(Gdk.Pixbuf.LoadFromResource("image-tool.png")); w1.Add("image-tool", w9); Gtk.IconSet w10 = new Gtk.IconSet(Gdk.Pixbuf.LoadFromResource("polyline-tool.png")); w1.Add("polyline-tool", w10); Gtk.IconSet w11 = new Gtk.IconSet(Gdk.Pixbuf.LoadFromResource("text-tool.png")); w1.Add("text-tool", w11); Gtk.IconSet w12 = new Gtk.IconSet(Gdk.Pixbuf.LoadFromResource("pen-tool.png")); w1.Add("pen-tool", w12); w1.AddDefault(); } }