diff --git a/sample/GtkDemo/DemoMain.cs b/sample/GtkDemo/DemoMain.cs index 8875d2cec..cc621b29e 100644 --- a/sample/GtkDemo/DemoMain.cs +++ b/sample/GtkDemo/DemoMain.cs @@ -8,6 +8,7 @@ using System; using System.IO; using System.Collections; +using System.Reflection; using Gdk; using Gtk; @@ -57,25 +58,34 @@ namespace GtkDemo private void LoadFile (string filename) { - if (File.Exists (filename)) + Stream file = Assembly.GetExecutingAssembly ().GetManifestResourceStream (filename); + if (file != null) { - Stream file = File.OpenRead (filename); - StreamReader sr = new StreamReader (file); - string s = sr.ReadToEnd (); - sr.Close (); - file.Close (); - - infoBuffer.Text = filename; - sourceBuffer.Text = s; - - Fontify (); + LoadStream (file, filename); + } + else if (File.Exists (filename)) + { + file = File.OpenRead (filename); + LoadStream (file, filename); } else { infoBuffer.Text = String.Format ("{0} was not found.", filename); sourceBuffer.Text = String.Empty; - Fontify (); } + + Fontify (); + } + + private void LoadStream (Stream file, string filename) + { + StreamReader sr = new StreamReader (file); + string s = sr.ReadToEnd (); + sr.Close (); + file.Close (); + + infoBuffer.Text = filename; + sourceBuffer.Text = s; } private void Fontify () diff --git a/sample/GtkDemo/DemoTextView.cs b/sample/GtkDemo/DemoTextView.cs index e3ce8932c..8f7e2fd65 100644 --- a/sample/GtkDemo/DemoTextView.cs +++ b/sample/GtkDemo/DemoTextView.cs @@ -97,13 +97,13 @@ namespace GtkDemo textView.AddChildAtAnchor (scale, scaleAnchor); scale.ShowAll (); - Gtk.Image image = new Gtk.Image ("images/floppybuddy.gif"); + Gtk.Image image = new Gtk.Image (Gdk.Pixbuf.LoadFromResource ("floppybuddy.gif")); textView.AddChildAtAnchor (image, animationAnchor); image.ShowAll (); Entry entry = new Entry (); textView.AddChildAtAnchor (entry, entryAnchor); - image.ShowAll (); + entry.ShowAll (); } private void CreateTags (TextBuffer buffer) diff --git a/sample/GtkDemo/Makefile.am b/sample/GtkDemo/Makefile.am index 0589d6c4b..3b5fd110f 100644 --- a/sample/GtkDemo/Makefile.am +++ b/sample/GtkDemo/Makefile.am @@ -41,7 +41,8 @@ images = \ /resource:$(srcdir)/images/floppybuddy.gif,floppybuddy.gif build_sources = $(addprefix $(srcdir)/, $(sources)) +resources = $(addprefix /resource:, $(sources)) GtkDemo.exe: $(build_sources) $(assemblies) - $(CSC) /debug /out:GtkDemo.exe $(build_sources) $(references) $(images) + $(CSC) /debug /out:GtkDemo.exe $(build_sources) $(references) $(images) $(resources)