Hello everyone,
I've working on implementing a panel applet for my application Desktop
Drapes. After using Gtk#/Gnome# for quite some time now I've felt that
the PanelApplet class does lack way of just loading, a Xml file (and a
resource from the assembly) just like the Glade# is able to use a
stream/file/asm. So I've decided to add the two methods to PanelApplet;
while this isn't technically _needed_ I feel that provides a great
convince and also feels more complete (again going back to the Glade#).
The code for loading it from the assembly is taken from tomboy the file
loading is mine.
Cheers.
Milosz
P.S: Patch is attached.
Index: gnome/PanelApplet.custom
===================================================================
--- gnome/PanelApplet.custom (revision 63628)
+++ gnome/PanelApplet.custom (working copy)
@@ -12,6 +12,31 @@
PersistentData ["setup_menu_verbs"] = items;
}
+public void SetupMenuFromFile(string FileName, BonoboUIVerb[] verbs)
+{
+ System.IO.StreamReader menufile = new System.IO.StreamReader(FileName);
+ string xml = menufile.ReadToEnd();
+ menufile.Close();
+
+ SetupMenu(xml, verbs);
+}
+
+new void SetupMenuFromResource (System.Reflection.Assembly asm, string resource, BonoboUIVerb [] verbs)
+{
+ if (asm == null)
+ asm = GetType ().Assembly;
+
+ System.IO.Stream stream = asm.GetManifestResourceStream (resource);
+ if (stream != null) {
+ System.IO.StreamReader reader = new System.IO.StreamReader (stream);
+ String xml = reader.ReadToEnd ();
+ reader.Close ();
+ stream.Close ();
+
+ SetupMenu (xml, verbs);
+ }
+}
+
public abstract void Creation ();
public abstract string IID {
_______________________________________________
Gtk-sharp-list maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list