Embed glade file into a binary
Lodovico Giaretta via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Sep 17 12:07:33 PDT 2016
On Saturday, 17 September 2016 at 19:01:10 UTC, Geert wrote:
> On Saturday, 17 September 2016 at 18:36:52 UTC, llmp wrote:
>> On Saturday, 17 September 2016 at 18:18:37 UTC, Geert wrote:
>>> I've compiled a small application, and it runs when i execute
>>> it at the same directory where is the glade file.
>>>
>>> Is there a way to embed a glade file into a binary?
>>
>> enum fileContent = import(file);
>>
>> fileContent is a static array of ubyte.
>> the compiler must know the path to "file" via -J"dir/subdir"
>
> Thanks!
> I've just tried that, but i get an error message with the xml
> file content, and this at the end:
>
> // More XML here...
>
> <property name="visible">True</property>
> <property name="can_focus">True</property>
> <property
> name="receives_default">True</property>
> </object>
> <packing>
> <property name="expand">True</property>
> <property name="fill">True</property>
> <property name="position">2</property>
> </packing>
> </child>
> </object>
> <packing>
> <property name="expand">True</property>
> <property name="fill">True</property>
> <property name="position">6</property>
> </packing>
> </child>
> </object>
> </child>
> </object>
> </interface>
> ': File name too long
>
> // End of message.
>
> This is part of the application code:
>
> [...]
>
> enum fileContent = import("vista.glade");
>
> [...]
>
> g.addFromFile(fileContent);
>
> window = cast(Window)g.getObject("Win_01");
> }
>
> // More code here ...
> }
>
> [...]
addFromFile expects the *name* of the file. Because you already
have the *contents* of the file, you should change method. Maybe
addFromString is the correct one, but I'm not sure.
More information about the Digitalmars-d-learn
mailing list