Use embedded resources in CssProvider.LoadFromResource (#238)
This commit is contained in:
parent
c81830ad50
commit
aa1095a02d
2 changed files with 29 additions and 0 deletions
27
Source/Libs/GtkSharp/CssProvider.cs
Normal file
27
Source/Libs/GtkSharp/CssProvider.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
namespace Gtk
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
public partial class CssProvider
|
||||
{
|
||||
public bool LoadFromResource(string resource) => LoadFromResource(Assembly.GetCallingAssembly(), resource);
|
||||
|
||||
public bool LoadFromResource(Assembly assembly, string resource)
|
||||
{
|
||||
if (assembly == null)
|
||||
assembly = Assembly.GetCallingAssembly();
|
||||
|
||||
Stream stream = assembly.GetManifestResourceStream(resource);
|
||||
if (stream == null)
|
||||
throw new ArgumentException("'" + resource + "' is not a valid resource name of assembly '" + assembly + "'.", nameof(resource));
|
||||
|
||||
using (var reader = new StreamReader(stream))
|
||||
{
|
||||
string data = reader.ReadToEnd();
|
||||
return LoadFromData(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1017,6 +1017,8 @@
|
|||
<attr path="/api/namespace/object[@cname='GtkIconInfo']/method[@name='LoadSymbolicAsync']/*/*[@name='callback']" name="scope">async</attr>
|
||||
<attr path="/api/namespace/object[@cname='GtkIconInfo']/method[@name='LoadSymbolicForContextAsync']/*/*[@name='callback']" name="scope">async</attr>
|
||||
|
||||
<attr path="/api/namespace/object[@cname='GtkCssProvider']/method[@name='LoadFromResource']" name="hidden">1</attr>
|
||||
|
||||
<!-- Mark reserved fields as padding -->
|
||||
<attr path="//*[contains(@cname, 'gtk_reserved')]" name="padding">true</attr>
|
||||
<attr path="//*[contains(@vm, 'gtk_reserved')]" name="padding">true</attr>
|
||||
|
|
Loading…
Reference in a new issue