www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Hello World Example with Glade?

reply "Mike McKee" <volomike gmail.com> writes:
On Ubuntu Linux, I can draw a simple Hello World interface (and a 
button on it to close the window) with Glade and save the file. 
Now how do I use GtkD and D to load that interface? Anyone got a 
super simple tutorial for that?
Sep 10 2015
parent reply "Mike McKee" <volomike gmail.com> writes:
On Friday, 11 September 2015 at 06:00:39 UTC, Mike McKee wrote:
 On Ubuntu Linux, I can draw a simple Hello World interface (and 
 a button on it to close the window) with Glade and save the 
 file. Now how do I use GtkD and D to load that interface? 
 Anyone got a super simple tutorial for that?
I think the start of this probably looks like the following, but I'm not certain: import gtk; import gobject.Type; import std.stdio; import std.c.process; int main (string[] args) { Main.init(args); Builder b = new Builder(); b.addFromFile("test1.glade"); Window w = cast(Window)b.getObject("window1"); w.showAll(); Main.run(); return 0; } ...so, this assumed that I had a test1.glade file, and that I had this line inside it: <object class="GtkApplicationWindow" id="window1"> So now I need to figure out how to get GtkD installed on Ubuntu Linux 14.04.
Sep 10 2015
parent reply "Mike James" <foo bar.com> writes:
On Friday, 11 September 2015 at 06:45:07 UTC, Mike McKee wrote:
 On Friday, 11 September 2015 at 06:00:39 UTC, Mike McKee wrote:
 [...]
I think the start of this probably looks like the following, but I'm not certain: import gtk; import gobject.Type; import std.stdio; import std.c.process; int main (string[] args) { Main.init(args); Builder b = new Builder(); b.addFromFile("test1.glade"); Window w = cast(Window)b.getObject("window1"); w.showAll(); Main.run(); return 0; }
Hi Mike, There's a Glade example in the demos/builder directory... Regards, -<Mike>-
 ...so, this assumed that I had a test1.glade file, and that I 
 had this line inside it:

 <object class="GtkApplicationWindow" id="window1">

 So now I need to figure out how to get GtkD installed on Ubuntu 
 Linux 14.04.
Sep 10 2015
parent reply "Mike McKee" <volomike gmail.com> writes:
On Friday, 11 September 2015 at 06:53:07 UTC, Mike James wrote:
 There's a Glade example in the demos/builder directory...
I'm having trouble installing GtkD on Ubuntu Linux 14.04. I did the apt steps from here: http://d-apt.sourceforge.net/ $ sudo su # wget http://master.dl.sourceforge.net/project/d-apt/files/d-apt.list -O /etc/apt/sources.list.d/d-apt.list # apt-get update && apt-get -y --allow-unauthenticated install --reinstall d-apt-keyring && apt-get update # apt-get install libgtkd3-dev libgtkd3-doc I then run the following and it fails: # dmd test1.d test1.d(1): Error: module gtk is in file 'gtk.d' which cannot be read import path[0] = /usr/include/dmd/phobos import path[1] = /usr/include/dmd/druntime/import
Sep 11 2015
next sibling parent reply "Mike James" <foo bar.com> writes:
On Friday, 11 September 2015 at 07:13:22 UTC, Mike McKee wrote:
 On Friday, 11 September 2015 at 06:53:07 UTC, Mike James wrote:
 There's a Glade example in the demos/builder directory...
I'm having trouble installing GtkD on Ubuntu Linux 14.04. I did the apt steps from here: http://d-apt.sourceforge.net/ $ sudo su # wget http://master.dl.sourceforge.net/project/d-apt/files/d-apt.list -O /etc/apt/sources.list.d/d-apt.list # apt-get update && apt-get -y --allow-unauthenticated install --reinstall d-apt-keyring && apt-get update # apt-get install libgtkd3-dev libgtkd3-doc I then run the following and it fails: # dmd test1.d test1.d(1): Error: module gtk is in file 'gtk.d' which cannot be read import path[0] = /usr/include/dmd/phobos import path[1] = /usr/include/dmd/druntime/import
It looks last keep you're missing an import path (-Ipath_to_source). Check out http://dlang.org/dmd-linux.html#switches Regards, -<Mike>-
Sep 11 2015
parent reply "Mike McKee" <volomike gmail.com> writes:
On Friday, 11 September 2015 at 07:20:57 UTC, Mike James wrote:
 It looks last keep you're missing an import path 
 (-Ipath_to_source). Check out 
 http://dlang.org/dmd-linux.html#switches
I tried this just now: # dmd test1.d -I/usr/include/dmd/gtkd3/gtkc /usr/include/dmd/gtkd3/gtkc/gtk.d(28): Error: module gtktypes is in file 'gtkc/gtktypes.d' which cannot be read import path[0] = /usr/include/dmd/gtkd3/gtkc import path[1] = /usr/include/dmd/phobos import path[2] = /usr/include/dmd/druntime/import It's saying that it can't read gtkc/gtktypes.d, but there is a file in path /usr/include/dmd/gtkd3/gtkc/gtktypes.d
Sep 11 2015
parent reply "Mike James" <foo bar.com> writes:
On Friday, 11 September 2015 at 07:29:23 UTC, Mike McKee wrote:
 On Friday, 11 September 2015 at 07:20:57 UTC, Mike James wrote:
 It looks last keep you're missing an import path 
 (-Ipath_to_source). Check out 
 http://dlang.org/dmd-linux.html#switches
I tried this just now: # dmd test1.d -I/usr/include/dmd/gtkd3/gtkc /usr/include/dmd/gtkd3/gtkc/gtk.d(28): Error: module gtktypes is in file 'gtkc/gtktypes.d' which cannot be read import path[0] = /usr/include/dmd/gtkd3/gtkc import path[1] = /usr/include/dmd/phobos import path[2] = /usr/include/dmd/druntime/import It's saying that it can't read gtkc/gtktypes.d, but there is a file in path /usr/include/dmd/gtkd3/gtkc/gtktypes.d
try # dmd test1.d -I/usr/include/dmd/gtkd3 I'm using GtkD on Windows so there is a .../src directory with all the source files in. regards, -<mike>-
Sep 11 2015
parent reply "Mike McKee" <volomike gmail.com> writes:
On Friday, 11 September 2015 at 07:39:46 UTC, Mike James wrote:
 try # dmd test1.d -I/usr/include/dmd/gtkd3
# dmd test1.d -L-ldl -I/usr/include/dmd/gtkd3 test1.o:(.rodata+0x12c): undefined reference to `_D3gtk7Builder12__ModuleInfoZ' test1.o:(.rodata+0x130): undefined reference to `_D3gtk4Main12__ModuleInfoZ' test1.o:(.rodata+0x134): undefined reference to `_D3gtk6Window12__ModuleInfoZ' test1.o:(.rodata+0x138): undefined reference to `_D7gobject4Type12__ModuleInfoZ' test1.o: In function `_Dmain': test1.d:(.text._Dmain+0xc): undefined reference to `_D3gtk4Main4Main4initFKAAyaZv' test1.d:(.text._Dmain+0x11): undefined reference to `_D3gtk7Builder7Builder7__ClassZ' test1.d:(.text._Dmain+0x1c): undefined reference to `_D3gtk7Builder7Builder6__ctorMFZC3gtk7Builder7Builder' test1.d:(.text._Dmain+0x38): undefined reference to `_D3gtk6Window6Window7__ClassZ' test1.d:(.text._Dmain+0x63): undefined reference to `_D3gtk4Main4Main3runFZv' collect2: error: ld returned 1 exit status I also tried without the "-L-ldl" and got the same result. I then tried this: # rdmd -I/usr/include/dmd/gtkd3 -L-ldl test1.d ** (test1:3169): WARNING **: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-PJfKDfNeIv: Connection refused Segmentation fault (core dumped)
Sep 11 2015
parent "Mike James" <foo bar.com> writes:
On Friday, 11 September 2015 at 07:47:15 UTC, Mike McKee wrote:
 [...]
The undefined references mean you haven't provided a linker path to the GtkD libs. Have you built the GtkD libraries? Check out https://github.com/gtkd-developers/GtkD
Sep 11 2015
prev sibling next sibling parent reply Jordi Sayol via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
El 11/09/15 a les 09:13, Mike McKee via Digitalmars-d-learn ha escrit:
 On Friday, 11 September 2015 at 06:53:07 UTC, Mike James wrote:
 There's a Glade example in the demos/builder directory...
I'm having trouble installing GtkD on Ubuntu Linux 14.04. I did the apt steps from here: http://d-apt.sourceforge.net/ $ sudo su # wget http://master.dl.sourceforge.net/project/d-apt/files/d-apt.list -O /etc/apt/sources.list.d/d-apt.list # apt-get update && apt-get -y --allow-unauthenticated install --reinstall d-apt-keyring && apt-get update # apt-get install libgtkd3-dev libgtkd3-doc I then run the following and it fails: # dmd test1.d test1.d(1): Error: module gtk is in file 'gtk.d' which cannot be read import path[0] = /usr/include/dmd/phobos import path[1] = /usr/include/dmd/druntime/import
On <http://d-apt.sourceforge.net/> there is the "pkg-config" section: --- pkg-config: Every dev package contains "pkg-config" (shared and static) configuration files for the specific library. i.e. link GtkD2 applications against "libgtkd2.so" and "libphobos2.so" shared libraries: $ dmd `pkg-config --cflags --libs gtkd2` my_gtkd2_app.d or link GtkD2 applications against "libgtkd2.a" and "libphobos2.a" static libraries: $ dmd `pkg-config --cflags --libs gtkd2-static` my_gtkd2_app.d --- Best regards
Sep 11 2015
parent reply "Mike McKee" <volomike gmail.com> writes:
On Friday, 11 September 2015 at 09:07:37 UTC, Jordi Sayol wrote:
 On <http://d-apt.sourceforge.net/> there is the "pkg-config" 
 section:
I finally got it to compile with your help, guys! :) Here's what I had to type: # dmd test1.d -L-ldl -I/usr/include/dmd/gtkd3 `pkg-config --cflags --libs gtkd3`
Sep 11 2015
next sibling parent "Adam D. Ruppe" <destructionator gmail.com> writes:
On Friday, 11 September 2015 at 14:00:30 UTC, Mike McKee wrote:
 I finally got it to compile with your help, guys! :)

 Here's what I had to type:

 # dmd test1.d -L-ldl -I/usr/include/dmd/gtkd3 `pkg-config 
 --cflags --libs gtkd3`
Don't forget to answer yourself on SO too! http://stackoverflow.com/questions/32516092/how-to-show-hello-world-with-glade-gtkd-and-d-programming-language
Sep 11 2015
prev sibling parent reply Mike Wey <mike-wey example.com> writes:
On 09/11/2015 04:00 PM, Mike McKee wrote:
 On Friday, 11 September 2015 at 09:07:37 UTC, Jordi Sayol wrote:
 On <http://d-apt.sourceforge.net/> there is the "pkg-config" section:
I finally got it to compile with your help, guys! :) Here's what I had to type: # dmd test1.d -L-ldl -I/usr/include/dmd/gtkd3 `pkg-config --cflags --libs gtkd3`
You should be able to drop the -L-ldl and -I/usr/.... flags, as they are included in the pkg-config output. -- Mike Wey
Sep 11 2015
parent reply "Mike McKee" <volomike gmail.com> writes:
On Friday, 11 September 2015 at 20:29:05 UTC, Mike Wey wrote:
 You should be able to drop the -L-ldl and -I/usr/.... flags, as 
 they are included in the pkg-config output.
I just tested and you are correct. Now, is there a way that I can edit /etc/dmd.conf and make it so that I don't need to do this pkg-config stuff all the time?
Sep 11 2015
parent reply Russel Winder via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
On Sat, 2015-09-12 at 06:58 +0000, Mike McKee via Digitalmars-d-learn
wrote:
[=E2=80=A6]
 I just tested and you are correct. Now, is there a way that I can=20
 edit /etc/dmd.conf and make it so that I don't need to do this=20
 pkg-config stuff all the time?
I think editing /etc/dmd.conf would be the wrong way forward on this. I would suggest using one of SCons, CMake, Make as a build tool and encode this in the build rules. Once you get to a GtkD application bigger than "Hello World" create a project and use Dub.=20 --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Sep 12 2015
parent "Mike McKee" <volomike gmail.com> writes:
On Saturday, 12 September 2015 at 09:03:53 UTC, Russel Winder 
wrote:
 Once you get to a GtkD application bigger than "Hello World" 
 create a project and use Dub.
Oh yes, Dub. That's the ticket. Thanks, mate.
Sep 12 2015
prev sibling next sibling parent Jordi Sayol via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
El 11/09/15 a les 11:05, Jordi Sayol via Digitalmars-d-learn ha escrit:
 El 11/09/15 a les 09:13, Mike McKee via Digitalmars-d-learn ha escrit:
 On Friday, 11 September 2015 at 06:53:07 UTC, Mike James wrote:
 There's a Glade example in the demos/builder directory...
I'm having trouble installing GtkD on Ubuntu Linux 14.04. I did the apt steps from here: http://d-apt.sourceforge.net/ $ sudo su # wget http://master.dl.sourceforge.net/project/d-apt/files/d-apt.list -O /etc/apt/sources.list.d/d-apt.list # apt-get update && apt-get -y --allow-unauthenticated install --reinstall d-apt-keyring && apt-get update # apt-get install libgtkd3-dev libgtkd3-doc I then run the following and it fails: # dmd test1.d test1.d(1): Error: module gtk is in file 'gtk.d' which cannot be read import path[0] = /usr/include/dmd/phobos import path[1] = /usr/include/dmd/druntime/import
On <http://d-apt.sourceforge.net/> there is the "pkg-config" section: --- pkg-config: Every dev package contains "pkg-config" (shared and static) configuration files for the specific library. i.e. link GtkD2 applications against "libgtkd2.so" and "libphobos2.so" shared libraries: $ dmd `pkg-config --cflags --libs gtkd2` my_gtkd2_app.d or link GtkD2 applications against "libgtkd2.a" and "libphobos2.a" static libraries: $ dmd `pkg-config --cflags --libs gtkd2-static` my_gtkd2_app.d ---
Just replace "gtkd2" by "gtkd3" $ dmd `pkg-config --cflags --libs gtkd3` my_glade_app.d $ dmd `pkg-config --cflags --libs gtkd3-static` my_glade_app.d This works out of the box with the "builderTest.d" example on GtkD demos folder. Regards
Sep 11 2015
prev sibling parent "Gary Willoughby" <dev nomad.so> writes:
On Friday, 11 September 2015 at 07:13:22 UTC, Mike McKee wrote:
 I'm having trouble installing GtkD on Ubuntu Linux 14.04.
Here's an old guide I wrote years ago. It might be a little out of date but may help you put things together: http://nomad.so/2013/07/cross-platform-gui-programming-using-d-and-gtk/
Sep 11 2015