[Gtk-sharp-list] Glade using resources

underdog10 at netcourrier.com underdog10 at netcourrier.com
Wed Jul 6 06:04:41 EDT 2005


Well  i think of 2 work around:

1- Modify Galde.XML.LoadFromresources to make it loading external files from resources.
2- Add all application imge to the Gtk.StockItem and Gtk.IconFactory, and make glade load image from stock.

As anyone try the second method ?

The idea is to put image data in your program compile it in as a resource and load it from glade XML file. This way you will not need to depend on loading external files, your application binary can be self-contained.

underdog

>
>I think that you have to load the icons manually -- via the
>LoadFromResource and then set them manually within the GUI.
> At least, you needed to when we coded up our GUI...
>
>Mike.
>
>On 7/5/05, underdog10 at netcourrier.com <underdog10 at netcourrier.com> wrote:
>> 
>> 
>> Thanks for reply, the problem about glade file but image specify into the glade file.
>> 
>> the app load glade xml file from resource, but it don't try to get the image form resource
>> 
>> For example:
>> using Glade, create a simple window and add a image.
>> If you set the image file directly in glade, it will try get the image from the disk.
>> What i would like, it is to load the image from resrouces compiled in the binary, like it does for the glade file.
>> 
>> Getting resource when GTK# is handle by hand it is working.
>> 
>> But getting resource when the GUI is made with glade, it is not possible.
>> 
>> You can find the Makefile here.
>> http://cvs.sourceforge.net/viewcvs.py/xbgm/xbgmsharp/src/Makefile?rev=1.2&view=markup
>> 
>> 
>> Thanks
>> KaYa
>> 
>> 
>> >
>> >I use the commented out version in your code successfully:
>> >
>> >        Glade.XML glade_xml = new Glade.XML (null, "main_window.glade",
>> >                               "mainWindow", null);
>> >        glade_xml.Autoconnect (this);
>> >
>> >Are you sure you are compiling the glade file into the binary? I don't
>> >know much about resources, but I use:
>> >
>> >-resource:$(srcdir)/../glade/main_window.glade,main_window.glade
>> >
>> >in my makefile.
>> >
>> >Mike.
>> >
>> >On 7/4/05, underdog10 at netcourrier.com <underdog10 at netcourrier.com> wrote:
>> >> Hello,
>> >>
>> >> I would like to load image from resources using a glade interface.
>> >> I try this 2 method without success:
>> >>
>> >> //Glade.XML gxml = new Glade.XML(null, "testgui.glade", "window1", null);
>> >>
>> >> Glade.XML gxml = Glade.XML.FromAssembly ("testgui.glade", "window1", null);
>> >>
>> >> When i say without success, i mean it fail because galde is looking for the file on disk not in built in resources.
>> >>
>> >> I can set the gui icon using:
>> >> window1.Icon = Gdk.Pixbuf.LoadFromResource ("testicon.png");
>> >>
>> >> So is there anyway to load image from resources using a glade interface?
>> >>
>> >> Thanks
>> >>
>> >>
>> >> --Error here---
>> >> (<unknown>:2000): GLib-CRITICAL **: g_path_get_dirname: assertion `file_name != NULL' failed
>> >>
>> >> (<unknown>:2000): GdkPixbuf-CRITICAL **: gdk_pixbuf_new_from_file_utf8: assertion `filename != NULL' failed
>> >>
>> >> (<unknown>:2000): libglade-WARNING **: Couldn't find image file: "test.png"
>> >>
>> >> (<unknown>:2000): GLib-CRITICAL **: g_path_get_dirname: assertion `file_name != NULL' failed
>> >>
>> >> (<unknown>:2000): GdkPixbuf-CRITICAL **: gdk_pixbuf_new_from_file_utf8: assertion `filename != NULL' failed
>> >> Glade GUI error: Object reference not set to an instance of an object
>> >>
>> >> Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object
>> >> in <0x000f4> Test.Gui.MyGui:.ctor ()
>> >> in <0x0006a> Test.MainClass:Main (System.String[] args)
>> >>
>> >> -------------------------------------------------------------
>> >> NetCourrier, votre bureau virtuel sur Internet : Mail, Agenda, Clubs, Toolbar...
>> >> Web/Wap : www.netcourrier.com
>> >> Téléphone/Fax : 08 92 69 00 21 (0,34 € TTC/min)
>> >> Minitel: 3615 NETCOURRIER (0,16 € TTC/min)
>> >>
>> >> _______________________________________________
>> >> Gtk-sharp-list maillist  -  Gtk-sharp-list at lists.ximian.com
>> >> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>> >>
>> >
>> >
>> >--
>> >"He who fights with monsters might take care
>> >lest he thereby become a monster. And if you
>> >gaze for long into an abyss, the abyss gazes
>> >also into you." - Nietzsc
>> 
>> -------------------------------------------------------------
>> NetCourrier, votre bureau virtuel sur Internet : Mail, Agenda, Clubs, Toolbar...
>> Web/Wap : www.netcourrier.com
>> Téléphone/Fax : 08 92 69 00 21 (0,34 € TTC/min)
>> Minitel: 3615 NETCOURRIER (0,16 € TTC/min)
>> 
>> 
>
>
>-- 
>"He who fights with monsters might take care 
>lest he thereby become a monster. And if you 
>gaze for long into an abyss, the abyss gazes 
>also into you." - Nietzsche_______________________________________________
>Gtk-sharp-list maillist  -  Gtk-sharp-list at lists.ximian.com
>http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>
>

-------------------------------------------------------------
NetCourrier, votre bureau virtuel sur Internet : Mail, Agenda, Clubs, Toolbar...
Web/Wap : www.netcourrier.com
Téléphone/Fax : 08 92 69 00 21 (0,34 € TTC/min)
Minitel: 3615 NETCOURRIER (0,16 € TTC/min)



More information about the Gtk-sharp-list mailing list