Sign up

Embed glade file into a binary

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?

Re: Embed glade file into a binary

I've found the solution with some help. Here is part of the code:

public import gtk.Main;
import gtk.TreeIter, gtk.TreeModel, gtk.TreeModelIF;
enum fileContent = import("file_name.glade");

// More code here...

class Vista{
private:

Window window;
Modelo obj_model = new Modelo();

public:

Button btn_exit;
Button btn_format;
ComboBoxList cbo_list;
Switch swi_bnivel;
Label lbl_info;
Entry txt_et;
int test_val = 3;

//this(){ } // constructor

void init_ui(){
    Builder g = new Builder();
    g.addFromString(fileContent);

    window = cast(Window)g.getObject("Win_01");
}

// More code here ...

}

// Compile command: ldc -w -disable-linker-strip-dead -deps=txtdeps.txt main.d extra.d vista.d modelo.d X.d Xlib.d -J="/home/directorygladefilepath/" -L-lX11 `pkg-config --cflags --libs