www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Blog Post #79: Notebook, Part III - Customized Tabs, Part I

reply Ron Tarrant <rontarrant gmail.com> writes:
Well, if that title isn't confusing, I'm not doing my job right.

Today's post starts a three-part mini-series within the Notebook 
series on building customized tabs in a DrawingArea. There's a 
ton of stuff to go over; that's why it's in three parts.

Anyway, the fun begins right here: 
https://gtkdcoding.com/2019/10/15/0079-notebook-iii-custom-tabs-i.html
Oct 15 2019
parent reply WebFreak001 <d.forum webfreak.org> writes:
On Tuesday, 15 October 2019 at 12:07:22 UTC, Ron Tarrant wrote:
 Well, if that title isn't confusing, I'm not doing my job right.

 Today's post starts a three-part mini-series within the 
 Notebook series on building customized tabs in a DrawingArea. 
 There's a ton of stuff to go over; that's why it's in three 
 parts.

 Anyway, the fun begins right here: 
 https://gtkdcoding.com/2019/10/15/0079-notebook-iii-custom-tabs-i.html
thank you so much for these tutorials! I love how they are progressing. Small, simple and concise topics with good images, nice drawings, and most importantly, paragraphs explaining the logic along with the code. I am also fan of your consistent style of the website and the tutorial images. Keep up the great work on these tutorials! They are a great resource showing people how to easily do great GUIs in D and will surely attract a lot of people. Could you maybe do a tutorial how to use Glade with D in the future? Glade is a visual GTK forms editor and there are 2 dub packages to generate D code from the forms files. (one very new one with nice explanations and one that is a year old with a bit less documentation) I don't really have too much experience with Glade but I'm sure a little bit of entry level Glade tutorial alongside with how to directly use it in D will surely attract a lot of people!
Oct 15 2019
parent reply Ron Tarrant <rontarrant gmail.com> writes:
On Tuesday, 15 October 2019 at 14:00:32 UTC, WebFreak001 wrote:

 thank you so much for these tutorials! I love how they are 
 progressing.
Thanks, WebFreak001.
 Small, simple and concise topics with good images, nice 
 drawings, and most importantly, paragraphs explaining the logic 
 along with the code.

 I am also fan of your consistent style of the website and the 
 tutorial images. Keep up the great work on these tutorials! 
 They are a great resource showing people how to easily do great 
 GUIs in D and will surely attract a lot of people.
Those are some very kind words. Thank you very much.
 Could you maybe do a tutorial how to use Glade with D in the 
 future?
I'll put this on my todo list. How could I turn you down after the preamble you wrote? :)
 there are 2 dub packages to generate D code from the forms 
 files. (one very new one with nice explanations and one that is 
 a year old with a bit less documentation)
Do you have links for these?
Oct 15 2019
parent reply WebFreak001 <d.forum webfreak.org> writes:
On Tuesday, 15 October 2019 at 20:03:00 UTC, Ron Tarrant wrote:
 On Tuesday, 15 October 2019 at 14:00:32 UTC, WebFreak001 wrote:

 thank you so much for these tutorials! I love how they are 
 progressing.
Thanks, WebFreak001.
 Small, simple and concise topics with good images, nice 
 drawings, and most importantly, paragraphs explaining the 
 logic along with the code.

 I am also fan of your consistent style of the website and the 
 tutorial images. Keep up the great work on these tutorials! 
 They are a great resource showing people how to easily do 
 great GUIs in D and will surely attract a lot of people.
Those are some very kind words. Thank you very much.
 Could you maybe do a tutorial how to use Glade with D in the 
 future?
I'll put this on my todo list. How could I turn you down after the preamble you wrote? :)
 there are 2 dub packages to generate D code from the forms 
 files. (one very new one with nice explanations and one that 
 is a year old with a bit less documentation)
Do you have links for these?
thanks! :p both the packages can simply be found on dub: https://code.dlang.org/search?q=glade Not sure if there are other ways like directly loading an XML in GTK, haven't looked into it too much yet because I am not so often building GTK GUI applications, but with the new Linux Phones on the market (Librem 5, PinePhone) running GTK Apps natively and really needing some Apps those will be great platforms to start app development on.
Oct 15 2019
parent reply Antonio Corbi <acrb ggmail.com> writes:
On Tuesday, 15 October 2019 at 22:02:35 UTC, WebFreak001 wrote:
 On Tuesday, 15 October 2019 at 20:03:00 UTC, Ron Tarrant wrote:
...
 Do you have links for these?
thanks! :p both the packages can simply be found on dub: https://code.dlang.org/search?q=glade Not sure if there are other ways like directly loading an XML in GTK, haven't looked into it too much yet because I am not so often building GTK GUI applications, but with the new Linux Phones on the market (Librem 5, PinePhone) running GTK Apps natively and really needing some Apps those will be great platforms to start app development on.
Hi WebFreak001, Ron: There's no need to generate code from glade files. You can load at runtime the XML file that glade generates. You have to create an instance of the Gtk.Builder class[1], and supply it the XML file, i.e. from the file that you saved from glade[2] and after that you 'load' your UI controls into your program variables using getObject[3], a small snippet of this pattern: --------------------------------------------------- .... auto builder = new Builder(); if(!builder.addFromFile(buildPath(pkgdatadir,"ui/MainWindow.ui"))) { writeln("Window ui-file cannot be found"); return; } HeaderBar headerBar = cast(HeaderBar) builder.getObject("headerBar"); Box windowContent = cast(Box) builder.getObject("windowContent"); ... --------------------------------------------------- Once I wrote this extremely simple class to simplify Builder usage: --------------------------------------------------- module gtagui.uibuilder; private import gobject.ObjectG; import gtk.Builder; class UiBuilder : Builder { this (string uif) { if (!addFromFile (uif)) throw new Exception ("File not found: " ~ uif); } public T getObject(T) (string name) { return (cast(T) super.getObject (name)); } } --------------------------------------------------- So you can now write things like this: --------------------------------------------------- public void loadUiFrom (string uifile) { uib = new UiBuilder (uifile); topbox = uib.getObject!Box ("box1"); theCanvas = uib.getObject!DrawingArea("imgwindow"); assert (theCanvas !is null); --------------------------------------------------- Hope this helps. Antonio [1] https://api.gtkd.org/gtk.Builder.Builder.html [2] https://api.gtkd.org/gtk.Builder.Builder.addFromFile.html [3] https://api.gtkd.org/gtk.Builder.Builder.getObject.html
Oct 16 2019
parent Ron Tarrant <rontarrant gmail.com> writes:
On Wednesday, 16 October 2019 at 07:46:42 UTC, Antonio Corbi 
wrote:

 Hope this helps.
Thanks, Antonio. I'll check this out. I'll work up a demo based on this stuff and put it in the gtkdcoding queue.
Oct 16 2019