Linux & DMD & GtkD

Antonio Corbi antonio at
Sat Feb 16 19:11:03 UTC 2019

On Saturday, 16 February 2019 at 16:28:09 UTC, Ron Tarrant wrote:
> On Saturday, 16 February 2019 at 14:29:56 UTC, Russel Winder 
> wrote:
>> Pass, sorry.
> Thanks for the replies, guys...
> I quoted the above line because it's just about the only thing 
> I understood. Let me explain...
> It's been almost 20 years since I used Linux and my notes are 
> long gone. A ton of things have changed. Like, for instance, it 
> found all my hardware this time, without me getting involved. 
> But also the software installation managers and lots of other 
> things are completely unrecognizable. On top of that, my brain 
> has (unfortunately) been molded into the Windows/Microsoft way 
> of thinking.
> I guess what I'm hoping for is a step-by-step, 
> full-on-hand-holding, large-print with pictures tutorial for 
> how to get GtkD and (I guess) dub working. I know the stuff you 
> wrote is probably helpful, but I'm not well-enough versed in 
> Linux or any flavour of UNIX ATM to understand it, pick which 
> option I should use, and to put these commands in proper order.
> So far, as I said, dmd is working. Up until now, I've avoided 
> dub because, with so many code examples (more than 70 at 
> present) dub would bring in a lot of file/directory clutter.
> But you're saying that dub will make it easier to keep up with 
> future changes/updates in all the various bits and bobs, so if 
> that means I finally have to do dub, perhaps someone could 
> point me at a good tutorial for that?
> Sorry if I sound ungrateful or cranky, but I have a lot on my 
> plate ATM and I'm getting frustrated.

Hi Ron,

For one-file programs, dub usage is very easy.

Placing a minimal comment-header between /+ +/ symbol comments, 
gets your job done like in this example ( I think the gtkd code 
is from one of your examples in the blog):

  name       "gtkhello"
  dflags     "-dip25" "-dip1000"
  dependency "gtk-d:gtkd" version="~>3.8.0"

   dub run --single gtkhello.d
   dub build --single gtkhello.d.
   dub gtkhello.d <arguments to hello>.

module gtkhello;

import std.stdio;
import gtk.MainWindow;
import gtk.Main;
import gtk.Widget;
import gtk.Layout;
import gtk.Button;
import gdk.Event;

void main(string[] args)
   TestRigWindow myTestRig = new TestRigWindow("Test Rig");

} // main()

class TestRigWindow : MainWindow
   this(string title)
     // window
     addOnDestroy(delegate void(Widget w) { quitApp(); } );

     auto myButton = new MyButt("Button Name");
     auto myOtherButton = new MyOtherButt("Other Button Name");

     // layout
     auto myLayout = new MyLayout(myButton, myOtherButton);

   } // this() CONSTRUCTOR

   void quitApp()

   } // quitApp()

} // class myAppWindow

class MyLayout : Layout
   this(MyButt myButton, MyOtherButt otherButton)
     super(null, null);
     put(myButton, 10, 20);
     put(otherButton, 10, 60);

   } // this()

} // class MyLayout

class MyButt : Button
   this(string labelText)

   } // this()

   bool doSomething(Event e, Widget w)
     writeln("Something was done.");


   } // doSomething()

} // class MyButt

class MyOtherButt : Button
   this(string labelText)
     string message = "Something other than that was done.";
     addOnClicked(delegate void(_) { doSomething(message); } );

   } // this()

   void doSomething(string messageText)

   } // doSomething()



More information about the Digitalmars-d-learn mailing list