Re: How to find the right function in the Phobos library?

2024-08-16 Thread Ron Tarrant via Digitalmars-d-learn

On Saturday, 17 August 2024 at 05:28:37 UTC, Bruce wrote:

Example.
I want to find the index of an item in an array.

```
import std.stdio;
import std.string;

void main()
{
   string text = "Hello, World!";
   string searchSubstring = "World";

   ptrdiff_t index = text.indexOf(searchSubstring);

   if (index != -1)
   {
  writeln("The substring '", searchSubstring, "' found at 
index ", index);

   }
   else
   {
  writeln("The substring '", searchSubstring, "' not found in 
the string.");

   }
}
```


Re: How to find the right function in the Phobos library?

2024-08-18 Thread Ron Tarrant via Digitalmars-d-learn
On Saturday, 17 August 2024 at 17:31:53 UTC, Steven Schveighoffer 
wrote:

Go to dlang.org, select dicumentation, then library reference.

Pick any module, click on it

In the upper right, switch the docs from stable to ddox

Now you can use the search bar and it is interactive. Typing in 
indexOf found it right away.


Good trick, Steve. I've been working/playing with D for almost 
six years and I didn't know that. Thank you.




DlangUI Layout Justification

2023-03-09 Thread Ron Tarrant via Digitalmars-d-learn

Hi all,
It's been a while since I've been on this forum. Hope everyone is 
doing well and have survived the pandemic.


Anyway, a question...

Is there a way to right-justify widgets in a DlangUI Layout?

I'm asking because I've spent the last six months learning to 
build Android apps with the Godot Game Engine, but frankly, it's 
cumbersome and I really miss D. So, I'm looking into D-language 
GUI toolkits that will allow me to make the transition.


And that leads to another question...

Has anyone else been using D to develop for Android? If so, have 
you documented your process/GUI toolkit choices and would you be 
willing to share with me?


With all that said, y'all take care and have a nice day. :)


Re: DlangUI Layout Justification

2023-03-09 Thread Ron Tarrant via Digitalmars-d-learn

On Thursday, 9 March 2023 at 10:11:04 UTC, Ron Tarrant wrote:


Is there a way to right-justify widgets in a DlangUI Layout?


Found it! (In Example 1 [duh]).

Still hoping to hear back from someone about the other question.


Re: DlangUI Layout Justification

2023-03-09 Thread Ron Tarrant via Digitalmars-d-learn

Another question...

I found LinkButton in the API, but I don't see how/where to give 
it a URL to go to. Anyone know?


Re: DlangUI Layout Justification

2023-03-09 Thread Ron Tarrant via Digitalmars-d-learn

On Thursday, 9 March 2023 at 10:51:31 UTC, Ron Tarrant wrote:

Another question...

I found LinkButton in the API, but I don't see how/where to 
give it a URL to go to. Anyone know?


Okay, so far I've got Platform.openURL(), but no idea how to use 
it. Pass it a string, yes, I got that part, but how do I attach 
it as an action to a LinkButton? Or is attaching actions not the 
way it's done?


I'm off to find out what's written about actions in dlangUI.


Re: DlangUI Layout Justification

2023-03-09 Thread Ron Tarrant via Digitalmars-d-learn

On Thursday, 9 March 2023 at 14:39:06 UTC, ryuukk_ wrote:

On Thursday, 9 March 2023 at 10:11:04 UTC, Ron Tarrant wrote:

Has anyone else been using D to develop for Android? If so, 
have you documented your process/GUI toolkit choices and would 
you be willing to share with me?


Adam has something for Android: 
https://github.com/adamdruppe/d_android


Many thanks, ryuukk. I'll check it out.


Blog Post #0054: MVC VII - TreeView Basics

2019-07-19 Thread Ron Tarrant via Digitalmars-d-learn
If you've been anticipating the TreeView examples, today's post 
is where the rubber hits the road with a look at the differences 
and similarities between populating a ComboBox and a TreeView. 
You can find it here: 
https://gtkdcoding.com/2019/07/19/0054-mvc-vii-treeview-basics.html




Blog Post #0055: MVC VIII - Dynamically Loading a TreeView

2019-07-23 Thread Ron Tarrant via Digitalmars-d-learn

Hi y'all,

This week's first post is entry #8 in the MVC series and covers 
loading up a TreeView with a decorated list of system fonts. 
Decorations include varying the size, weight, and style as well 
as the font face. You can view it here: 
https://gtkdcoding.com/2019/07/23/0055-mvc-viii-dynamically-loading-a-treeview.html




Blog Post #0056: MVC IX - A ComboBox with Flair

2019-07-26 Thread Ron Tarrant via Digitalmars-d-learn
Today we get to do something unusual. Drawing on and combining a 
bunch of things we've done in past instalments, we'll build a 
two-column ComboBox with different images, custom fonts, and 
background colors for each item in the list. Here's the post: 
http://gtkdcoding.com/2019/07/26/0056-mvc-ix-a-combobox-with-flair.html




Meaning of Scoped! ??

2019-07-30 Thread Ron Tarrant via Digitalmars-d-learn
Some things are almost impossible to research. For instance, in 
the GtkD wrapper code—specifically the Widget.d file—the 
following function definition appears:



	gulong addOnDraw(bool delegate(Scoped!Context, Widget) dlg, 
ConnectFlags connectFlags=cast(ConnectFlags)0)

{
		return Signals.connect(this, "draw", dlg, connectFlags ^ 
ConnectFlags.SWAPPED);

}


With contemporary search engines, it's impossible to search for 
'!' and get meaningful results. And searching for 'Scoped!' 
results in every variation of the word 'scope' and ignores the 
'!' altogether, even with Google's Verbatim tool turned on. 
Worse, Google ignores case as well.


I also searched all three D-language books and found nothing.

Here are my questions:

1) What exactly does the '!' mean? For instance, '=' means "is 
equal to," but I don't know what words to 'think' while looking 
at a '!'


2) What does 'Scoped' mean?

3) In the specific instance above, what does 'Scoped!Context' 
mean as opposed to just 'Context'? In other words, what are the 
differences between 'Scoped!Context' and 'Context'?


The last question needs more explanation...

In Widget.d, there are two overloads of addOnDraw(), the one 
cited above and this one:



	deprecated gulong addOnDraw(bool delegate(Context, Widget) dlg, 
ConnectFlags connectFlags=cast(ConnectFlags)0)

{
		return Signals.connect(this, "draw", dlg, connectFlags ^ 
ConnectFlags.SWAPPED);

}


The former works, but the latter spits out a 'deprecated' error 
(naturally).




Blog Post #0057: The Basics of Drawing with Cairo

2019-07-30 Thread Ron Tarrant via Digitalmars-d-learn
Several months ago, someone asked if I'd be covering drawing 
routines and after much preparation, today's post is the first in 
a series on drawing with Cairo.


You can find it here: 
http://gtkdcoding.com/2019/07/30/0057-cairo-i-the-basics.html


Re: Meaning of Scoped! ??

2019-07-30 Thread Ron Tarrant via Digitalmars-d-learn

On Tuesday, 30 July 2019 at 09:46:07 UTC, Andrea Fontana wrote:

Looking at its source code, it seems it's a way to force the 
call of "destroy" method of wrapped object (Context in your 
case) when the struct goes out of its scope (and d-tor is 
called)


Andrea


Thanks, Andrea (and rikki). I actually learned this a while back 
(even wrote about it in a blog post) but I've noticed my memory 
is playing tricks on me lately.


In fact, don't be surprised if I ask this same question (or a 
close variation of it) next month. (sigh)


Blog Post #0058: Cairo Rectangles

2019-08-02 Thread Ron Tarrant via Digitalmars-d-learn
Continuing on with Cairo, this is a look at the variations and 
permutations of drawing rectangles and you'll find it here: 
https://gtkdcoding.com/2019/08/02/0058-cairo-ii-rectangles.html




Blog Post #0059: Cairo Circles and Arcs

2019-08-06 Thread Ron Tarrant via Digitalmars-d-learn
Today's post covers the basics of drawing circles and arcs in a 
DrawingArea using Cairo functions. You can find it here: 
https://gtkdcoding.com/2019/08/06/0059-cairo-iii-circles-and-arcs.html


Also, in case it got missed, there's a second index of blog posts 
where everything is sorted by subject and that's right here: 
https://gtkdcoding.com/topics/


Blog Post #0060: Cairo Filled Arcs, Precision Arcs, and Curves

2019-08-09 Thread Ron Tarrant via Digitalmars-d-learn
Today's post covers a lot of ground and answers a few of those 
burning questions you may have about taming Cairo arcs and 
curves. Still, it's a quick read because... well, tons of 
diagrams and screenshots. So, come on over and take a look: 
https://gtkdcoding.com/2019/08/09/0060-cairo-iv-fill-arc-cartoon-mouth.html


Blog Post #0061: Cairo Toy Text

2019-08-13 Thread Ron Tarrant via Digitalmars-d-learn
When all you want is quick-n-dirty text in a GTK DrawingArea and 
Pango seems like more than you wanna deal with, Cairo's Toy Text 
will do the job nicely. Here's how: 
https://gtkdcoding.com/2019/08/13/0061-cairo-v-toy-text-image-formats.html


Blog Post #0062: Cairo Load & Display Images

2019-08-16 Thread Ron Tarrant via Digitalmars-d-learn
Continuing on with Cairo, this post covers loading and displaying 
three types of image (including a structured drawing) using two 
different load-n-display methods.


As an extra bonus, you'll see a photo of my cat, Bob, and three 
of the seven guitars I've found in my building's recycle room 
over the last year.


https://gtkdcoding.com/2019/08/16/0062-cairo-vi-load-display-images.html



Re: Blog Post #0062: Cairo Load & Display Images

2019-08-17 Thread Ron Tarrant via Digitalmars-d-learn

On Friday, 16 August 2019 at 12:44:15 UTC, bauss wrote:

Amazing! You might be able to answer me something, whether you 
could use gtkd solely for image manipulation using ex. Pixbuf? 
or would it only work with the internals of gtkd? Like can you 
manipulate the image and save it to disk etc.


Those are very good questions, bauss. I haven't dug in that deep 
yet, but I see no reason why Cairo couldn't be used to build a 
full-featured paint, manipulation, or structured drawing 
application. But it won't only be about Pixbufs. The Cairo 
Context seems to be where all the action is as far as drawing 
routines go.


Over the next few months, off and on, I'll be exploring stuff 
like that. I'm still working on getting through all the unsexy 
stuff first (the basic widgets) but every once in a while, I just 
have to let my hair down and do something that's a bit more 
complex.


After the basic image and drawing stuff is covered, I'll be 
digging into simple animation and how to tame the Timeout. Then, 
after a short side-trip to finish off MVC and do some more 
base-level widgets such as the Toolbar, Statusbar, and Expander, 
there's another Cairo miniseries coming up that covers nodes and 
noodles, something I've wanted to dig into for several years.


Thanks for reading and thanks for the kind words.



Re: Blog Post #0062: Cairo Load & Display Images

2019-08-17 Thread Ron Tarrant via Digitalmars-d-learn

On Friday, 16 August 2019 at 12:58:23 UTC, Andre Pany wrote:


Thanks a lot Ron, your page is really helpful.


You're welcome, Andre. And thanks for saying so.

Is there a reason why the source code starts after a lot of 
whitespaces on every line?
This causes some distruction on mobile phone as you have scroll 
horizontally although it would fit the screen if the source 
code would start at column 0.


Thanks for bringing this to my attention. I've recently switched 
from basic MD for displaying source and the way I was doing it 
demanded that everything be indented one tab. I've since switched 
to Jekyll/Liquid's {% highlight d %} system which doesn't have 
this limitation.


Now that I know this is an issue, give me a some time and I'll 
get all those extra indents removed.





Re: Blog Post #0062: Cairo Load & Display Images

2019-08-17 Thread Ron Tarrant via Digitalmars-d-learn

On Friday, 16 August 2019 at 12:58:23 UTC, Andre Pany wrote:

This causes some distruction on mobile phone as you have scroll 
horizontally although it would fit the screen if the source 
code would start at column 0.


That didn't take as long as I thought it would. I removed all 
excess indentation, so let me know if it's any better now.




Re: Blog Post #0062: Cairo Load & Display Images

2019-08-18 Thread Ron Tarrant via Digitalmars-d-learn

On Sunday, 18 August 2019 at 09:28:30 UTC, Andre Pany wrote:

II noticed you use an indentation level of 8 spaces. Is this by 
purpose? As far as I know, 4 spaces is recommended.


I only use three in PS Pad, so the extra spaces are being 
inserted by either Perl, Jekyll, Liquid, or some part of the 
GitHub Pages site.


Is it possible it's an interpretation layered on by the web 
browser on your phone?
I don't know enough about how browsers work to determine whether 
or not this is a valid question.


Re: Blog Post #0062: Cairo Load & Display Images

2019-08-18 Thread Ron Tarrant via Digitalmars-d-learn

On Sunday, 18 August 2019 at 14:44:29 UTC, Andre Pany wrote:

Hm I am not sure, i just tried lynx (on raspberry pi) and here 
also the indentation level are 8 spaces.


Perhaps if I switched from using tabs to spaces... I'll try it 
with one of the posts and get back to you so you can test it... 
if that's okay with you.


Re: Blog Post #0062: Cairo Load & Display Images

2019-08-18 Thread Ron Tarrant via Digitalmars-d-learn

On Sunday, 18 August 2019 at 14:44:29 UTC, Andre Pany wrote:

Hm I am not sure, i just tried lynx (on raspberry pi) and here 
also the indentation level are 8 spaces.


Turns out, it's GitHub inserting 8 spaces per tab. No idea why 
anyone would think this appropriate, but there it is.


A workaround you can try for now is to click through to an 
example code (this won't work on the blog pages, just the code 
pages) and, at the end of the URL, type: ?ts=3 to get tabs that 
are three spaces. Any number between 1 and 12 will work, 
apparently.


Hope this helps for now. I'm still looking into this to find a 
more permanent solution. This 8 spaces per tab bugs me, too.




Re: Blog Post #0062: Cairo Load & Display Images

2019-08-18 Thread Ron Tarrant via Digitalmars-d-learn

On Sunday, 18 August 2019 at 14:44:29 UTC, Andre Pany wrote:
Hm I am not sure, i just tried lynx (on raspberry pi) and here 
also the indentation level are 8 spaces.


For testing purposes, I replaced each tab with three spaces in 
this post: 
http://gtkdcoding.com/2019/05/31/0040-messagedialog.html


If this works better for you, let me know and I can do a quick 
s-n-r on all blog posts and add this as the final prep step as 
the posts go up.


Re: Blog Post #0062: Cairo Load & Display Images

2019-08-18 Thread Ron Tarrant via Digitalmars-d-learn

On Sunday, 18 August 2019 at 14:44:29 UTC, Andre Pany wrote:

the indentation level are 8 spaces.


Turns out it's settable in CSS. Tab size for quoted code blocks 
in the blog posts is now set to three. If you could check a few 
out and let me know if it's any better. If not, I'll take it down 
to two... now that I know how easy it is.





Re: Blog Post #0062: Cairo Load & Display Images

2019-08-18 Thread Ron Tarrant via Digitalmars-d-learn

On Sunday, 18 August 2019 at 17:10:38 UTC, Andre Pany wrote:


It looks now very nice, thanks a lot.


Excellent. Glad to do it.

Wheter you chose 2, 3 or 4 is up to you. 4 is mentioned in 
Phobos style guide, but it is up to you, what you prefer.


I've always been partial to three, but I'm also more of a tab 
person. Less work, if you see what I'm saying.




Blog Post #63 - Saving Images with Cairo

2019-08-20 Thread Ron Tarrant via Digitalmars-d-learn
Today we look at how to save images using Cairo with examples for 
JPeg, PNG, BMP, and TIFF.


https://gtkdcoding.com/2019/08/20/0063-cairo-vii-draw-save-images.html


Blog Post #64 - Animating with Cairo

2019-08-23 Thread Ron Tarrant via Digitalmars-d-learn
Today, and for the next few posts, we'll be looking at Cairo 
animation. This time, we'll do a simple frame counter at 24fps. 
The post is here: 
https://gtkdcoding.com/2019/08/23/0064-cairo-vii-drawingarea-animation.html


Re: Blog Post #64 - Animating with Cairo

2019-08-23 Thread Ron Tarrant via Digitalmars-d-learn

On Friday, 23 August 2019 at 09:37:56 UTC, Ron Tarrant wrote:
Today, and for the next few posts, we'll be looking at Cairo 
animation. This time, we'll do a simple frame counter at 24fps. 
The post is here: 
https://gtkdcoding.com/2019/08/23/0064-cairo-vii-drawingarea-animation.html


CORRECTION:

Today's post covers three different examples of animation:
- a text counter,
- drawing a circle, and
- a flipbook animating a series of images.


Blog Post #65 - TreeStore Basics

2019-08-27 Thread Ron Tarrant via Digitalmars-d-learn
Today we go back to finish off an earlier series on MVC and 
stores, this time looking at the TreeStore and how to populate a 
hierarchy of rows. You can find it here: 
https://gtkdcoding.com/2019/08/27/0065-mvc-x-treestore-basics.html


Re: Pro programmer

2019-08-27 Thread Ron Tarrant via Digitalmars-d-learn

On Sunday, 25 August 2019 at 21:30:10 UTC, GreatSam4sure wrote:
If I want to be a pro programmer what language must I start 
with?


If it's deep understanding you want, start with assembly 
language. Knowing how things are done down at that level—before 
all the layers of abstraction are added—will give you an edge 
over 99% of current coders.


It's the same with basic computer use. Wanna be a true expert 
user? Get any version of Linux or one of the BSDs and restrict 
yourself to using just the terminal for about a month. You'll be 
amazed at how much you'll learn. It'll also give you a great 
foundation for understanding coding.


And your typing skills will go through the roof.


Blog Post #66 - Toolbar Basics

2019-08-30 Thread Ron Tarrant via Digitalmars-d-learn
Today we cover one of the basic widgets, namely, the Toolbar 
which isn't as straightforward to use since the deprecation of so 
many of GTK's StockIDs. You can find out what's changed and how 
to get around it right here: 
https://gtkdcoding.com/2019/08/30/0066-toolbar-basics.html




Blog Post #67 - Expander

2019-09-03 Thread Ron Tarrant via Digitalmars-d-learn
Today's post covers the Expander, a widget that... well... 
expands to reveal things hidden within. It's not quite a 
TreeView, but it's also a lot easier to use. You can read all 
about it here: 
https://gtkdcoding.com/2019/09/03/0067-mvc-xii-expander.html


Blog Post #68: MVC - Multi-level TreeView

2019-09-06 Thread Ron Tarrant via Digitalmars-d-learn
Today we dig back into the MVC series to look at the multi-level 
TreeStore and maybe learn a little geography. You can read all 
about it right here: 
https://gtkdcoding.com/2019/09/06/0068-multi-level-treestore.html


Blog Post #69: TextView and TextBuffer Basics

2019-09-10 Thread Ron Tarrant via Digitalmars-d-learn
This morning's discussion covers the basic workings and 
relationship between the TextView and TextBuffer widgets. Here's 
the link: 
https://gtkdcoding.com/2019/09/10/0069-textview-and-textbuffer.html




Re: Blog Post #69: TextView and TextBuffer Basics

2019-09-10 Thread Ron Tarrant via Digitalmars-d-learn

On Tuesday, 10 September 2019 at 09:14:13 UTC, Mike Parker wrote:

Seriously impressed that you're able to keep this up so 
consistently. Keep on trucking!


Thanks, Mike.



Re: Blog Post #69: TextView and TextBuffer Basics

2019-09-11 Thread Ron Tarrant via Digitalmars-d-learn

On Wednesday, 11 September 2019 at 03:45:23 UTC, Zekereth wrote:

Yes, thank you very much. Your tutorials are a great help! Keep 
it up! Thanks again.


Oakey dokey.


Using CSS Data from Within My Code

2019-09-12 Thread Ron Tarrant via Digitalmars-d-learn

I found this presented as a solution in a 2016 post:

On Wednesday, 15 June 2016 at 22:05:37 UTC, captaindet wrote:


enum myCSS = q{
GtkNotebook {
background-color: #e9e9e9;
}
GtkNotebook tab {
background-color: #d6d6d6;
}
};


But when I try to use it, I get the following errors:

Warning: C preprocessor directive #e9e9e9 is not supported
Warning: C preprocessor directive #d6d6d6 is not supported

I thought it was odd having 'q' in front of the opening curly 
brace... is this a typo? Shorthand for "string quote"? Something 
like that?


Or do I need to escape these somehow?




Re: Using CSS Data from Within My Code

2019-09-12 Thread Ron Tarrant via Digitalmars-d-learn
On Thursday, 12 September 2019 at 10:09:06 UTC, Andrea Fontana 
wrote:
On Thursday, 12 September 2019 at 09:54:35 UTC, Ron Tarrant 
wrote:

I found this presented as a solution in a 2016 post:

On Wednesday, 15 June 2016 at 22:05:37 UTC, captaindet wrote:


enum myCSS = q{
GtkNotebook {
background-color: #e9e9e9;
}
GtkNotebook tab {
background-color: #d6d6d6;
}
};


But when I try to use it, I get the following errors:

Warning: C preprocessor directive #e9e9e9 is not supported
Warning: C preprocessor directive #d6d6d6 is not supported

I thought it was odd having 'q' in front of the opening curly 
brace... is this a typo? Shorthand for "string quote"? 
Something like that?


Or do I need to escape these somehow?


They are named "token string" and contained code must be a 
valid d code. See https://dlang.org/spec/lex.html#token_strings


Thanks, Andrea and Max.

Turns out there's a simpler way to inject CSS into D code. In 
case anyone else comes looking, I found that instead of an enum, 
a string will do. Here's the solution I came up with to make 
visible tabs in a Notebook:


class CSS // GTK4 compliant
{
CssProvider provider;
string cssPath = "./css/visible_tabs.css";

string myCSS = "tab { background-color: #f2f2f2; }";

this(StyleContext styleContext)
{
provider = new CssProvider();
provider.loadFromData(myCSS);
		styleContext.addProvider(provider, 
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);


} // this() 

} // class CSS

And in the class that will use it, this line does it:

css = new CSS(getStyleContext());




Re: Using CSS Data from Within My Code

2019-09-12 Thread Ron Tarrant via Digitalmars-d-learn

On Thursday, 12 September 2019 at 11:35:04 UTC, Ron Tarrant wrote:
On Thursday, 12 September 2019 at 10:09:06 UTC, Andrea Fontana 
wrote:
On Thursday, 12 September 2019 at 09:54:35 UTC, Ron Tarrant 
wrote:

I found this presented as a solution in a 2016 post:

On Wednesday, 15 June 2016 at 22:05:37 UTC, captaindet wrote:


enum myCSS = q{
GtkNotebook {
background-color: #e9e9e9;
}
GtkNotebook tab {
background-color: #d6d6d6;
}
};


But when I try to use it, I get the following errors:

Warning: C preprocessor directive #e9e9e9 is not supported
Warning: C preprocessor directive #d6d6d6 is not supported

I thought it was odd having 'q' in front of the opening curly 
brace... is this a typo? Shorthand for "string quote"? 
Something like that?


Or do I need to escape these somehow?


They are named "token string" and contained code must be a 
valid d code. See https://dlang.org/spec/lex.html#token_strings


Thanks, Andrea and Max.

Turns out there's a simpler way to inject CSS into D code. In 
case anyone else comes looking, I found that instead of an 
enum, a string will do. Here's the solution I came up with to 
make visible tabs in a Notebook:




That should have been:

class CSS // GTK4 compliant
{
CssProvider provider;
string myCSS = "tab { background-color: #f2f2f2; }";

this(StyleContext styleContext)
{
provider = new CssProvider();
provider.loadFromData(myCSS);
		styleContext.addProvider(provider, 
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);


} // this() 

} // class CSS

The CSS path/file name isn't needed.



Re: Using CSS Data from Within My Code

2019-09-12 Thread Ron Tarrant via Digitalmars-d-learn

On Thursday, 12 September 2019 at 13:09:16 UTC, Mike Parker wrote:
On Thursday, 12 September 2019 at 11:40:33 UTC, Ron Tarrant 
wrote:



string myCSS = "tab { background-color: #f2f2f2; }";




enum will work just as well here and without the need for the 
variable:


enum myCSS = "tab { background-color: #f2f2f2; }";

The original error was because q strings have to be valid D, 
not because of the enum.


Ah! Thanks for clearing that up, Mike. My D knowledge is still 
rather sparse, so this fills in another blank for me.


Blog Post #70: Statusbar Basics

2019-09-13 Thread Ron Tarrant via Digitalmars-d-learn
Time to get down to basics with the Statusbar. Although most 
contemporary applications don't bother with proper status bars, 
these widgets can still be useful. Here's how to get started with 
them: https://gtkdcoding.com/2019/09/13/0070-statusbar.html




Re: Using CSS Data from Within My Code

2019-09-13 Thread Ron Tarrant via Digitalmars-d-learn

On Thursday, 12 September 2019 at 19:14:26 UTC, Ali Çehreli wrote:

On 09/12/2019 02:54 AM, Ron Tarrant wrote:

> I thought it was odd having 'q' in front of the opening curly
brace...

I think my index can be useful in such searches. Both q"" and 
q{} are there:


  http://ddili.org/ders/d.en/ix.html

Ali


Thanks, Ali. I suppose I should be looking in your book first 
when I have a question... as I so often do.


Blog Post #71: Expanding on the Statusbar

2019-09-17 Thread Ron Tarrant via Digitalmars-d-learn
Here's the second instalment on the lowly Statusbar wherein we 
look at multiple status reports as well as the Statusbar's 
signal: 
https://gtkdcoding.com/2019/09/17/0071-expanding-on-the-statusbar.html




Blog Post #72: The Frame, Part I

2019-09-20 Thread Ron Tarrant via Digitalmars-d-learn
Today starts a two-part series in which we explore the gotchas 
and workarounds of the GTK Frame. You can find it here: 
https://gtkdcoding.com/2019/09/20/0072-frame-part-i.html


Looking for a Simple Doubly Linked List Implementation

2019-09-20 Thread Ron Tarrant via Digitalmars-d-learn

Hi guys,

I've been banging my head on the screen with this one for the 
last week or so. For whatever reason, I'm having major problems 
understanding how to implement a doubly-linked list in D. I don't 
know if it's because I'm losing my ability to sort these things 
or if it's just that different from C.


If someone could please post a minimal example (if there's extra 
stuff in there, I'll get confused; I'm getting that old, dammit) 
I'd be ever so grateful.




Re: Looking for a Simple Doubly Linked List Implementation

2019-09-21 Thread Ron Tarrant via Digitalmars-d-learn

On Friday, 20 September 2019 at 20:35:41 UTC, H. S. Teoh wrote:

Not a minimal example by any means, but Phobos *does* come with 
a doubly-linked list implementation: std.container.dlist.


Thanks, H.S. I did come across that in my search. Trouble is, 
with all the extra stuff in there, I'm having trouble separating 
what I need from what I don't.


On Friday, 20 September 2019 at 21:34:08 UTC, Dennis wrote:
Below is a simple doubly linked list with Garbage Collected 
memory.
It's not performant or complete by any means, just a minimal 
example in D like you wanted.


Thanks, Dennis. Not performant... It doesn't work? I was hoping 
for a complete, working example, but maybe this'll help.


You probably also want methods for removing nodes or inserting 
in the middle (else why don't you use an array?)


Yup. That's where I'm running into trouble.

I think you can think of an implementation for those yourself 
(or look them up, there should be plenty examples online).


I thought I could, too. And I thought there'd be lots of examples 
online, too. (Otherwise, I wouldn't have embarrassed myself in 
public like this.) But if there are, I can't find them... not in 
D. And it seems that D is just different enough from the other 
examples I'm finding so that I can't use them as a guide.


Here's a question for the room:

Does a doubly-linked list always have to be done with structs? 
Can it be classes instead? (Maybe that's why I can't get it to 
work, because I've been trying to make an OOP version?)


When I run the following code, it gets through creating the list 
head and the first node, then seems to get stuck in an infinite 
loop. Here's the code:


import std.stdio;
import std.conv;

class TabList
{
Tab _head;
int lastUniqueID = 0;
string labelText;

this()
{
append();
}


void append()
{
string labelText = "Tab " ~ lastUniqueID.to!string();
Tab* current;

if(_head is null)
{
_head = new Tab(lastUniqueID, labelText);
}
else
{
current = &_head;

while(current.getNext())
{
current = current.getNext();
}

Tab tab = new Tab(lastUniqueID, labelText);
current.setNext(&tab);
current.setPrev(current);
}

lastUniqueID++;

} // append()


Tab* getHead()
{
return(&_head);

} // getHead()

} // class TabList


class Tab
{
private:
int _tabID;
string _label;
Tab* _prev = null, _next = null;

public:
this(int uniqueID, string labelText)
{
_tabID = uniqueID;
_label = labelText;

} // this()


void destroy(int id)
{
if(_tabID is id)
{
_prev.setNext(_next);
_next.setPrev(_prev);
}

} // destroy()


Tab* getNext()
{
return(_next);

} // getNext()


Tab* getPrev()
{
return(_prev);

} // getPrev()


int getTabID()
{
return(_tabID);

} // getTabID()


void setNext(Tab* tab)
{
_next = tab;

} // setNext()


void setPrev(Tab* tab)
{
_prev = tab;

} // setPrev()  

} // class Tab


void main(string[] args)
{
TabList tabList;

tabList = new TabList();

for(int i = 0; i < 7; i++)
{
tabList.append();
}

writeln();
writeln();

Tab* tab = tabList.getHead();

} // main()



Re: Looking for a Simple Doubly Linked List Implementation

2019-09-21 Thread Ron Tarrant via Digitalmars-d-learn

On Saturday, 21 September 2019 at 08:49:48 UTC, ag0aep6g wrote:

On 21.09.19 10:34, Ron Tarrant wrote:

Here's a question for the room:

Does a doubly-linked list always have to be done with structs? 
Can it be classes instead? (Maybe that's why I can't get it to 
work, because I've been trying to make an OOP version?)


It can be done with classes.

When I run the following code, it gets through creating the 
list head and the first node, then seems to get stuck in an 
infinite loop. Here's the code:

[...]

class Tab
{

[...]

 Tab* _prev = null, _next = null;

[...]

 Tab* getNext()

[...]

 Tab* getPrev()

[...]

 void setNext(Tab* tab)

[...]

 void setPrev(Tab* tab)

[...]

} // class Tab


Your mistake is that you're using pointers. `Tab` is a class. 
That means values of the type are already references. There is 
no need for `Tab*`. Just use `Tab` wherever you have `Tab*` 
now, and get rid of any addr-ofs (`&foo`) and dereferendces 
(`*bar`) you have.


Ah! Thanks, ag0aep6g. I was wondering about that when I was 
writing the code. (If I already knew this, I'd forgotten.) I did 
as you suggested, took out all '*' and '&' and it works perfectly.


Re: Looking for a Simple Doubly Linked List Implementation

2019-09-21 Thread Ron Tarrant via Digitalmars-d-learn

Thanks for all the responses, y'all.

I got it figured out thanks to ag0aep6g pointing out something I 
forgot about the nature of class objects in D (Damn my failing 
memory). The results will show up on the gtkDcoding blog sometime 
in (I'm guessing) November as part of the the Notebook discussion 
series.




Re: Looking for a Simple Doubly Linked List Implementation

2019-09-21 Thread Ron Tarrant via Digitalmars-d-learn

On Saturday, 21 September 2019 at 18:52:23 UTC, Dennis wrote:
On Saturday, 21 September 2019 at 08:34:09 UTC, Ron Tarrant 
wrote:
Thanks, Dennis. Not performant... It doesn't work? I was 
hoping for a complete, working example, but maybe this'll help.


Bad word choice (it appears it's debatable whether 'performant' 
even is a word), I meant it was a simple implementation not 
optimized for speed / memory efficiency.
Making it 'complete' is a bit hard since I can think of tens of 
methods and operator overloads you could use, but if I include 
them all it's no longer minimal and it just becomes 
std.container.dlist.


Does a doubly-linked list always have to be done with structs? 
Can it be classes instead?


My example originally included classes actually. It was mostly 
the same, except that Node!T* was just Node!T. The only problem 
was with const:


```
size_t length() const {
size_t result = 0;
for(auto a = head; a !is null; a = a.next) result++;
return result;
}

```

Since I marked the method as const, `auto a = head` got the 
type const(Node!T) and `a = a.next` no longer compiled. With 
structs you can declare a const(Node!T)* (mutable pointer to 
const node), but I don't know if I can declare a mutable 
reference to a const class, so I switched to structs.


I have no idea, either.

But I did come up with something that works, so for anyone else 
looking for a full, working version (nothing fancy, mind you) 
here's my code with lots of 'proofs' dumped to the command line:


```
import std.stdio;
import std.conv;

class TabList
{
private:
Tab _head;
int _lastUniqueID = 0;
string labelText;

this()
{
append();
}


void append()
{
string labelText = "Tab " ~ _lastUniqueID.to!string();
Tab current;

if(_head is null)
{
_head = new Tab(_lastUniqueID, labelText);
_head.setPrev(null);
_head.setNext(null);
}
else
{
current = _head;
writeln("before the while loop");
current.showThings();

while(current.getNext() !is null)
{
writeln("in the while loop...");
current.showThings();

if(current.getPrev() !is null)
{
writeln("prev = ", 
current.getPrev().getTabID());
}
else
{
writeln("prev = null");
}
current = current.getNext();
}
writeln("out of the while loop\n");
Tab tab = new Tab(_lastUniqueID, labelText);
current.setNext(tab);
tab.setPrev(current);
}

_lastUniqueID++;

} // append()


Tab getHead()
{
return(_head);

} // getHead()


void removeTab(int uniqueID)
{
// get the head
Tab current = _head, prev, next;

// walk the list to find the Tab with the uniqueID
while(current.getNext() !is null)
{
// if the uniqueID matches the head's ID
if(current.getTabID() is uniqueID)
{
// destroy the Tab object
current.destroy(uniqueID);
}
// else
else
{
// go to the next Tab
current = current.getNext();
}
}

} // removeTab()

} // class TabList


class Tab
{
private:
int _tabID;
string _label;
Tab _prev = null, _next = null;

public:
this(int uniqueID, string labelText)
{
_tabID = uniqueID;
_label = labelText;

} // this()


void showThings()
{
writeln("Tab = ", getTabID());

if(getPrev() !is null)
{
writeln("Tab.prev = ", getPrev().getTabID());
}
else
{
writeln("Tab.prev is null");
}

  

Re: Looking for a Simple Doubly Linked List Implementation

2019-09-21 Thread Ron Tarrant via Digitalmars-d-learn

Sorry. I posted the wrong file. This is the one that works:

```
import std.stdio;
import std.conv;

class TabList
{
private:
Tab _head;
int _lastUniqueID = 0;
string labelText;

this()
{
append();
}


void append()
{
string labelText = "Tab " ~ _lastUniqueID.to!string();
Tab current;

if(_head is null)
{
_head = new Tab(_lastUniqueID, labelText);
_head.setPrev(null);
_head.setNext(null);
}
else
{
current = _head;
//writeln("before the while loop");
//current.showThings();

while(current.getNext() !is null)
{
//  writeln("in the while loop...");
//  current.showThings();

//  if(current.getPrev() !is null)
//  {
//  writeln("prev = ", 
current.getPrev().getTabID());
//  }
//  else
//  {
//  writeln("prev = null");
//  }
current = current.getNext();
}
//writeln("out of the while loop\n");
Tab tab = new Tab(_lastUniqueID, labelText);
current.setNext(tab);
tab.setPrev(current);
}

_lastUniqueID++;

} // append()


Tab getHead()
{
return(_head);

} // getHead()


void removeTab(int uniqueID)
{
// get the head
Tab current = _head;

// walk the list to find the Tab with the uniqueID
while(current.getNext() !is null)
{
// if the uniqueID matches the head's ID
if(current.getTabID() is uniqueID)
{
// destroy the Tab object
current.destroy(uniqueID);
break;
}

// go to the next Tab
current = current.getNext();
}


} // removeTab()

} // class TabList


class Tab
{
private:
int _tabID;
string _label;
Tab _prev = null, _next = null;

public:
this(int uniqueID, string labelText)
{
_tabID = uniqueID;
_label = labelText;

} // this()


void showThings()
{
writeln("Tab = ", getTabID());

if(getPrev() !is null)
{
writeln("Tab.prev = ", getPrev().getTabID());
}
else
{
writeln("Tab.prev is null");
}

if(getNext() !is null)
{
writeln("Tab.next = ", getNext().getTabID());
}
else
{
writeln("Tab.next = null");
}

} // showThings()


void destroy(int id)
{
if(_tabID is id)
{
// destroy the TextView
// destroy the Label
_prev.setNext(_next);
_next.setPrev(_prev);
}

} // destroy()


Tab getNext()
{
return(_next);

} // getNext()


Tab getPrev()
{
return(_prev);

} // getPrev()


int getTabID()
{
return(_tabID);

} // getTabID()


void setNext(Tab tab)
{
_next = tab;

} // setNext()


void setPrev(Tab tab)
{
_prev = tab;

} // setPrev()  

} // class Tab


void main(string[] args)
{
TabList tabList;

tabList = new TabList();

for(int i = 0; i < 7; i++)
{
//  writeln("building Tab #", i);
tabList.append();
//  writeln("--");
}

write

Re: Looking for a Simple Doubly Linked List Implementation

2019-09-23 Thread Ron Tarrant via Digitalmars-d-learn
Well, it turns out, I didn't need a linked list, doubly or 
otherwise. That's what happens when a person quits coffee for a 
week: complete brain chaos.


For a full week, I banged on this, trying to work out a scheme 
whereby I could track GTK Notebook tabs with a doubly-linked 
list, an array, and any other mechanism that came to mind. That 
was my caffeine-free week of getting absolutely nothing done. 
(Twice, I actually forgot my name.)


This morning, I had a coffee, realized I was not just on the 
wrong track, but in the wrong train station and within 45 
minutes, I had eight Notebook demos working perfectly.


Let this serve as a warning, no matter how much you may think you 
need to go off the caffeine, it's just not worth it.


Blog Post #73: The Frame, Part II

2019-09-24 Thread Ron Tarrant via Digitalmars-d-learn
Today we cover how to decorate the Frame... or UN-decorate it. 
Frames can be turned off or dressed up with CSS. To find out 
more, follow this link: 
https://gtkdcoding.com/2019/09/24/0073-frame-part-ii.html


Packaging and Distributing Dlang Applications with GtkD Dependency?

2019-09-25 Thread Ron Tarrant via Digitalmars-d-learn

Hi y'all,

I've been Googling how to do this, but coming up with nothing 
definitive. Are there any articles for how to do this for:


Windows?
Linux?
other UNIX-alike OSs?



Re: Packaging and Distributing Dlang Applications with GtkD Dependency?

2019-09-25 Thread Ron Tarrant via Digitalmars-d-learn

On Wednesday, 25 September 2019 at 11:50:58 UTC, a11e99z wrote:
On Wednesday, 25 September 2019 at 11:46:04 UTC, Ron Tarrant 
wrote:

Hi y'all,

I've been Googling how to do this, but coming up with nothing 
definitive. Are there any articles for how to do this for:


Windows?
Linux?
other UNIX-alike OSs?


UPX?
https://en.wikipedia.org/wiki/UPX
https://linux.die.net/man/1/upx


Thanks for the reply, alle99z. Sorry for my badly-phrased 
question, I think I need to clarify...


What I'm looking for is a system for bundling dlang apps and 
their dependencies for distribution to end users. Hopefully, this 
bundler will:


- install the app in an appropriate place (like C:\Program 
Files\,
- install libraries/dependencies (such as GtkD) also in an 
appropriate place,
- make any modifications to the system PATH that may be necessary 
for the app to run, and
- handle any other roadblocks that will keep the user from using 
the app.


Whether this is an actual pre-existing application bundler or 
just a list of instructions I can follow so I can end up with a 
distributable one-click-does-it-all (on Windows, at least) 
package.


Similarly, on Linux or other UNIX-alikes, a breakdown of how to 
use apt or something similar to do the same so the user can (for 
instance) just do:


apt-get  

to install.


Re: Packaging and Distributing Dlang Applications with GtkD Dependency?

2019-09-25 Thread Ron Tarrant via Digitalmars-d-learn

On Wednesday, 25 September 2019 at 12:32:58 UTC, a11e99z wrote:


so u need installers/installation program
https://en.wikipedia.org/wiki/List_of_installation_software

well, a long-long time ago I used InstallShield & Wix Toolset 
for Windows only.


I'll check those out. Thanks.


Re: Packaging and Distributing Dlang Applications with GtkD Dependency?

2019-09-25 Thread Ron Tarrant via Digitalmars-d-learn
On Wednesday, 25 September 2019 at 13:52:48 UTC, bioinfornatics 
wrote:


I think I misunderstood your need but are lo looking for dub 
tool with its repository https://code.dlang.org/


I don't think so, but I could be wrong. I tried reading up on 
dub, but got lost in the docs, so I really don't understand what 
all it can do.




Re: Looking for a Simple Doubly Linked List Implementation

2019-09-25 Thread Ron Tarrant via Digitalmars-d-learn

On Monday, 23 September 2019 at 22:40:41 UTC, Ali Çehreli wrote:

So, what was it then? Append to an array, sort it, and be 
happy? :)


Ali


Hi, Ali,

It turns out that the GTK Notebook has its own built-in mechanism 
for tracking tabs. Two things got me going down the wrong road on 
this:


1) the fact that Notebook.appendPage() returns an ever-increasing 
index each time a page is added, and

2) trying to quit caffeine.

I chased my tail for a full week (seriously: a full week!) trying 
to come up with a way to track tabs. Then I got tired of doing 
face-plants on my desk, took up coffee again, and solved it in 
three hours.


The moral of the story is: don't quit coffee until you have 
nothing left to contribute to this world. :)


Re: Packaging and Distributing Dlang Applications with GtkD Dependency?

2019-09-26 Thread Ron Tarrant via Digitalmars-d-learn

On Thursday, 26 September 2019 at 16:30:39 UTC, Andre Pany wrote:

Dub is a tool for developers, I understand your requirements 
that you want target end customers of your applications. 
Therefore dub is the wrong tool for this job.


To be more precise, gtkd is a wrapper for GTK. Gtkd is not 
interesting in this context, but the dependency on gtk. On 
windows you have the possibility to either publish your 
application with GTK dlls or to run gtk setup routine as part 
of your application setup routine or just say in your readme 
that the customer needs to run GTK setup on there own.


On posix (linus, macos) of course you can also say in your 
readme that the customer should run apt-get ... to install gtk 
(here I do not have much knowledge on packaging).


Kind regards
Andre


Excellent. That's exactly what I needed to know, Andre. Thanks 
very much.


Re: Packaging and Distributing Dlang Applications with GtkD Dependency?

2019-09-26 Thread Ron Tarrant via Digitalmars-d-learn
On Thursday, 26 September 2019 at 10:10:20 UTC, bioinfornatics 
wrote:


I prefer to use meson a builder tool (same category tool as 
Make, CMake ...)

doc: https://mesonbuild.com/Dlang-module.html

Is better as it ease the packaging for fedora, debian, ubuntu 
and so on ...


This is good to know. Thank you, bioinfornatics.


Blog Post #74: Cairo IX - Doodle a Noodle

2019-09-27 Thread Ron Tarrant via Digitalmars-d-learn
Because at this point we've covered almost every widget GtkD has 
to offer, today we're taking a departure from that to do 
something non-standard.


Nodes-n-noodles are becoming more popular as UI elements, so this 
is the beginnings of how we can get this paradigm working in GtkD.


You can find part one here: 
https://gtkdcoding.com/2019/09/27/0074-cairo-doodle-a-noodle.html




Re: Packaging and Distributing Dlang Applications with GtkD Dependency?

2019-09-28 Thread Ron Tarrant via Digitalmars-d-learn
On Friday, 27 September 2019 at 12:42:56 UTC, Jacob Carlborg 
wrote:


For macOS you should distribute a GUI application for end users 
as an application bundle [1]. That's basically a directory 
containing a specific structure. Any dependencies and resources 
like libraries (GTK), images and so on should be bundled inside 
the application bundle. Then package the application bundle 
inside an archive, ideally a Disk Image (DMG) [2]. The 
application would be completely self contained and the user can 
install it by dragging it to the Application directory.


There might be some specific documentation how to bundle a GTK 
application on macOS. I found this [3], don't know if it's good 
or not.


Ideally the application should be distributed on the Mac App 
Store. But that requires a developer account that costs money. 
It also has some restrictions that distribution outside of the 
Mac App Store doesn't have. If you cannot distribute using the 
Mac App Store the next best thing is to notarize the 
application (also requires a paid developer account, as far as 
I can see) before distributing it. Otherwise the user will get 
a dialog complaining that the application is from an unknown 
developer and the user need to explicitly go into System 
Preferences to allow it.


[1] 
https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/1123i-CH101-SW1


[2] https://en.wikipedia.org/wiki/Apple_Disk_Image
[3] https://gitlab.gnome.org/GNOME/gtk-mac-bundler

--
/Jacob Carlborg


Excellent, Jacob. Thanks for all that.


Re: Packaging and Distributing Dlang Applications with GtkD Dependency?

2019-09-28 Thread Ron Tarrant via Digitalmars-d-learn
On Saturday, 28 September 2019 at 02:15:42 UTC, Hossain Adnan 
wrote:



For Linux there are 3 new options:

(things omitted)
There are tutorials for using all of those three online, but 
not specific to Dlang. But if you use the Meson build system 
there are plenty of tutorials available.


Thanks Hossian. This helps a lot.


Re: Packaging and Distributing Dlang Applications with GtkD Dependency?

2019-09-28 Thread Ron Tarrant via Digitalmars-d-learn

On Saturday, 28 September 2019 at 08:52:36 UTC, Jordi Sayol wrote:

On Bebian/Ubuntu/Linux Mint, You have "d-apt" 



This sounds so appropriate for a D application. :)

If you static links your d program, you don't need any package 
from it at runtime.
But if you dynamic links it, you've runtime libraries for GtkD 
"libgtkd3-nn" and TkD "libtkd-nn" on "d-apt".
"nn" on library name should be replaced with the DMD major 
version (without initial zero).

i.e. For the last DMD version, "libgtkd3-88" or "libtkd-88".


Thank you for filling in some blanks for me.


Blog Post #75: Cairo X - Noodling with the Mouse

2019-10-01 Thread Ron Tarrant via Digitalmars-d-learn
Here's the second installment of the Nodes-n-noodles coverage in 
which we get the mouse involved: 
https://gtkdcoding.com/2019/10/01/0075-cairo-x-mouse-noodle.html


Re: Blog Post #76: Nodes and Noodles, Part II

2019-10-04 Thread Ron Tarrant via Digitalmars-d-learn

On Friday, 4 October 2019 at 11:36:52 UTC, Ron Tarrant wrote:
Here's the second instalment of the Nodes-n-noodles series 
wherein noodle drawing on a DrawingArea is now complete. You 
can find it here: 
http://localhost:4000/2019/10/04/0076-cairo-xi-noodles-and-mouse-clicks.html


Beg pardon. That should be "the third instalment," not "the 
second."


Blog Post #76: Nodes and Noodles, Part II

2019-10-04 Thread Ron Tarrant via Digitalmars-d-learn
Here's the second instalment of the Nodes-n-noodles series 
wherein noodle drawing on a DrawingArea is now complete. You can 
find it here: 
http://localhost:4000/2019/10/04/0076-cairo-xi-noodles-and-mouse-clicks.html


Re: Blog Post #75: Cairo X - Noodling with the Mouse

2019-10-05 Thread Ron Tarrant via Digitalmars-d-learn

On Friday, 4 October 2019 at 20:56:31 UTC, Greatsam4sure wrote:

Pls sir can you make a pdf of the tutorials. that can be easily 
downloaded once and for all. So that I need to be online. Not 
everybody have cheap internet.


That's an interesting idea, but it would mean a lot of extra time 
and effort, so it would be nice to be compensated. Do you think 
it's better to ask for a set fee or donations?




Re: Blog Post #76: Nodes and Noodles, Part II

2019-10-06 Thread Ron Tarrant via Digitalmars-d-learn

On Sunday, 6 October 2019 at 23:00:51 UTC, Zekereth wrote:

Here's the correct URL 
https://gtkdcoding.com/2019/10/04/0076-app-01-iii-noodles-and-mouse-clicks.html


Great tutorial(s)! Thanks!


LOL! Thanks, Zekereth.


Blog Post #77: Notebook, Part I

2019-10-08 Thread Ron Tarrant via Digitalmars-d-learn
Today starts a new series on the Notebook widget. Over the next 
few weeks, we'll dig in deep, looking at single-tab and 
multiple-tab demos, customizing the look of the actual tabs, 
adding and removing tabs... a whole ton of stuff. Sounds like 
fun, right?


Come on over and check it out: 
https://gtkdcoding.com/2019/10/08/0077-notebook-i-basics.html


Re: Blog Post #77: Notebook, Part I

2019-10-09 Thread Ron Tarrant via Digitalmars-d-learn

On Wednesday, 9 October 2019 at 03:13:48 UTC, GreatSam4sure wrote:


Good works


Thanks, GreatSam4sure.

Is there any way to detect the size of my screen using gtkd? So 
that incan calculate the size of my screen and center my window 
on the screen using move(x, y).


I had a quick look into this and there is no straightforward 
solution, so I can't give you an immediate answer. It would be 
easier to explain with a demo, so I'll need some time to work one 
up. I've put it on my to-do list.


Besides can you convert all your posts to a pdf that is easily 
downloadable for those with little internet access?


I've been thinking about an ebook based on the blog, something 
that would start with installing a development environment, go 
into how to organize and write each part of an application, and 
end with how to distribute the finished product. It's in very 
early stages ATM, but I'm open to any suggestions you (or anyone 
else) may have for how to make it as useful as possible.




Blog Post #78: Notebook, Part II

2019-10-11 Thread Ron Tarrant via Digitalmars-d-learn
Continuing the series on the GTK Notebook, we look at multiple 
tabs, reordering tabs, and stuffing images into tabs. Exciting 
stuff, no?


Here it is: 
https://gtkdcoding.com/2019/10/11/0078-notebook-ii-multiple-tabs.html




GtkD ListG Howto?

2019-10-11 Thread Ron Tarrant via Digitalmars-d-learn

Hi all,

I'm trying to add an icon list to a GTK Window using 
setIconList(), but what the function expects is a ListG of 
Pixbufs.


The way I understand it, I have to instantiate the Pixbufs, build 
a ListG of void pointers to the Pixbufs, and pass that to 
setIconList().


Here is how I assume this process would play out:

```

Pixbuf airportImage1, airportImage2, airportImage3, airportImage4;
void * image1, image2, image3, image4;

airportImage1 = new Pixbuf("images/airport_25.png");
airportImage2 = new Pixbuf("images/airport_35.png");
airportImage3 = new Pixbuf("images/airport_60.png");
airportImage4 = new Pixbuf("images/airport_100.png");
image1 = &airportImage1;
image2 = &airportImage2;
image3 = &airportImage3;
image4 = &airportImage4;

ListG listG = null;

listG = listG.append(image1);
listG = listG.append(image2);
listG = listG.append(image3);
listG = listG.append(image4);

setIconList(listG);

```

But this, although it compiles, just dies when it hits all those 
append() statements.


Would someone please tell me where I'm going off track?




Re: GtkD ListG Howto?

2019-10-11 Thread Ron Tarrant via Digitalmars-d-learn

On Friday, 11 October 2019 at 20:40:25 UTC, mipri wrote:


I get the segfault to go away with

  ListG list = new ListG(null);

which is usage you can find in APILookupGLib.txt


Ah! Thanks, mipri. I didn't think to read through the unit tests.


Re: Blog Post #77: Notebook, Part I

2019-10-12 Thread Ron Tarrant via Digitalmars-d-learn
On Saturday, 12 October 2019 at 16:34:01 UTC, Carsten Schlote 
wrote:



Nice work, Ron!


Thanks, Carsten.

I'm just converted some of you examples into dub based 
projects, and compiled and run them a normal intel PC and a 
Raspberry. As a prerequisite I had to install the following on 
a Raspian Lite installation (from a NOOP sdcard, no GUI)


Well, that's pretty cool.

Ever considered to provide such dub based examples on 
GitHub/GitLab/... for easy access?


Yup! It's coming. Also, module-based stuff.

Such source examples could be very helpful for GTK newbies. And 
dub projects should work on Windows as well.


Yup, absolutely.




Re: Blog Post #0043 - File Dialog IX - Custom Dialogs (2 of 3)

2019-10-13 Thread Ron Tarrant via Digitalmars-d-learn

On Monday, 17 June 2019 at 07:09:33 UTC, BoQsc wrote:


Aw man, your content have. "© Copyright 2019 Ron Tarrant"


I just noticed this response, otherwise I would have responded 
sooner.


The copyright only covers the text, not the code. I'll see about 
getting a lack-of-copyright notice together to put at the top of 
each code file.


I hope that puts your mind at ease.



Permission to Use Comments?

2019-10-14 Thread Ron Tarrant via Digitalmars-d-learn

Hi all,

I've been thinking about how to take GtkDcoding to the next level 
and one idea is to use (favourable) comments made here on the 
forum to help promote the blog.


So, since I'm not clear on copyright law and how it affects forum 
posts, I decided to ask...


1) Does anyone know how copyright laws stand regarding reuse of 
comments on a forum?


2) Does anyone object to me quoting them for promotional purposes?



Blog Post #79: Notebook, Part III - Customized Tabs, Part I

2019-10-15 Thread Ron Tarrant via Digitalmars-d-learn

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




Re: Blog Post #77: Notebook, Part I

2019-10-15 Thread Ron Tarrant via Digitalmars-d-learn

On Wednesday, 9 October 2019 at 03:13:48 UTC, GreatSam4sure wrote:

Is there any way to detect the size of my screen using gtkd? So 
that incan calculate the size of my screen and center my window 
on the screen using move(x, y).


I was distracted last time I replied to this thread and so 
overlooked the obvious.


This is actually very simple to do. Add this to your Window or 
MainWindow constructor:


Window.setPosition(WindowPosition.CENTER);

That's it.

Here's a full example, so you can see it in its natural habitat: 
https://github.com/rontarrant/gtkDcoding/blob/master/001_window/window_001_11_centered.d


Re: Permission to Use Comments?

2019-10-15 Thread Ron Tarrant via Digitalmars-d-learn

On Tuesday, 15 October 2019 at 14:33:27 UTC, Russel Winder wrote:

Not I. I am happy for comments I make regarding GtkDCoding on 
this email list to be used above my name on the GtkDCoding 
website.


Thanks, Russel.



Re: Permission to Use Comments?

2019-10-15 Thread Ron Tarrant via Digitalmars-d-learn

On Monday, 14 October 2019 at 15:36:44 UTC, Jesse Phillips wrote:

Pretty sure since this is a public forum, legally you just need 
to reference your sources (if even that). Asking permission is 
just polite.


Well, yes and no. According to the FTC (U.S.) and the Federal 
Competition Bureau (Canada) it's best to get permission in 
written form, even if it's email or on a public forum, no matter 
what the source of the comments. It's polite, yes, but it also 
removes ambiguity.



I don't say anything good, but you're free to use mine.


:)  Why, thanks, Jesse.



Re: Blog Post #79: Notebook, Part III - Customized Tabs, Part I

2019-10-15 Thread Ron Tarrant via Digitalmars-d-learn

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?


Re: Blog Post #79: Notebook, Part III - Customized Tabs, Part I

2019-10-16 Thread Ron Tarrant via Digitalmars-d-learn
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.


Re: several types in one Array ?

2019-10-17 Thread Ron Tarrant via Digitalmars-d-learn

On Thursday, 17 October 2019 at 14:45:24 UTC, Mil58 wrote:

Hi all...
Does exist (or not?) a way to create array with several types 
(as in Python)


You actually have at least three options for handling mixed data:

```
// Three ways to handle mixed data

import std.stdio;
import std.typecons;
import std.variant;

struct Result
{
string itemName;
int quantity;
bool needIt;

} // struct Result


class GroceryItem
{
private:
bool _needIt;
int _quantity;
string _itemName;

public:
this(string itemName, int quantity, bool needIt)
{
_itemName = itemName;
_quantity = quantity;
_needIt = needIt;

} // this()


Variant getVariant()
{
		return(cast(Variant)tuple(_itemName, _quantity, _needIt)); // 
use with a Variant return type


} // getVariant()


Tuple!(string, int, bool)getTuple()
{
		return(tuple(_itemName, _quantity, _needIt)); // use with a 
Tuple!(string, int, bool) return type


} // getTuple()


Result getStruct()
{
Result result = {_itemName, _quantity, _needIt};

return(result);

} // getStruct()


void set(bool needIt)
{
_needIt = needIt;

} // set()

} // class GroceryItem


void main(string[] args)
{
GroceryItem[] groceryList;

GroceryItem item1 = new GroceryItem("Paper Towels", 1, true);
groceryList ~= item1;
GroceryItem item2 = new GroceryItem("Bread", 2, true);
groceryList ~= item2;
GroceryItem item3 = new GroceryItem("Butter", 1, false);
groceryList ~= item3;
GroceryItem item4 = new GroceryItem("Milk", 1, true);
groceryList ~= item4;
GroceryItem item5 = new GroceryItem("Potato Chips", 3, false);
groceryList ~= item5;
GroceryItem item6 = new GroceryItem("Pickles", 4, true);
groceryList ~= item6;

writeln("Returning variants...");

foreach(groceryItem; groceryList)
{
writeln(groceryItem.getVariant());
}

writeln();
writeln("Returning tuples...");

foreach(groceryItem; groceryList)
{
writeln(groceryItem.getTuple());
}

writeln();
writeln("Returning structs...");

foreach(groceryItem; groceryList)
{
writeln(groceryItem.getStruct());
}

} // main()

```


Blog Post #80: Notebook, Part IV - Customized Tabs, Part II

2019-10-18 Thread Ron Tarrant via Digitalmars-d-learn
Here's the second instalment of the customized tabs discussion. 
May it bring you peace and joy. 
https://gtkdcoding.com/2019/10/18/0080-notebook-iv-custom-tabs-ii.html




Re: Meta question - what about moving the D - Learn Forum to a seperate StackExchange platform?

2019-10-18 Thread Ron Tarrant via Digitalmars-d-learn
On Friday, 18 October 2019 at 07:35:21 UTC, Martin Tschierschke 
wrote:
I very often end with a solution found on one of the 
StackExchange forums like > StackOverflow or AskUbuntu etc.


I have found that StackExchange does often have answers, but I 
can't say I like asking questions on there, especially if the 
question is almost-the-same-but-not-the-same as a question asked 
earlier. In cases like this, I've been told that the previous 
answer applies to my question, even when it doesn't.


In one instance, a moderator closed my question without reading 
the details in order to find out that, no, it's not the same 
question at all... and then refuse to reopen the question when I 
point this out.


So, although I'll continue to use StackExchange as an historical 
resource, I would rather not depend on it for getting answers to 
new questions.




Blog Post #81: Notebook, Part V - Customized Tabs, Part III

2019-10-22 Thread Ron Tarrant via Digitalmars-d-learn
Today we wrap up the customized tabs discussion as we look at the 
drawing routines. It's here: 
https://gtkdcoding.com/2019/10/22/0081-notebook-v-custom-tabs-iii.html


Blog Post #82: Notebook, Part VI - Add and Remove Tabs

2019-10-25 Thread Ron Tarrant via Digitalmars-d-learn
More fun with Notebooks, adding and removing tabs willy-nilly: 
https://gtkdcoding.com/2019/10/25/0082-notebook-vi-add-remove-tabs.html


Blog Post #83: Notebook, Part VII - All Signals

2019-10-29 Thread Ron Tarrant via Digitalmars-d-learn
This post looks at a handful of Notebook signals, how they're 
triggered, and what they can be used for. We also go over the 
keyboard shortcuts used by the GTK Notebook. You'll find it all 
here: 
https://gtkdcoding.com/2019/10/29/0083-notebook-vii-notebook-all-signals.html


Re: Gtkd and libgtksourceview

2019-10-30 Thread Ron Tarrant via Digitalmars-d-learn
On Wednesday, 30 October 2019 at 14:48:23 UTC, bioinfornatics 
wrote:


I tried the latest gtkd release and it try to open dynamically 
libgtksourceview-4.so.0 however  I have only 
libgtksourceview-3.so.1


On Windows, I had to change a line in 
C:\D\dmd2\src\sourceview\gsv\c\functions.d from:


static immutable LIBRARY_GSV = ["libgtksourceview-4.0.dll"];

to:

static immutable LIBRARY_GSV = ["libgtksourceview-3.0-1.dll"];


Assuming the sourceview/gsv/c/functions.d exists on Linux as 
well, a similar change should help.


However, you will also, very likely, have to look for a folder in 
generated/ called:


"sourceview"

and copy it and its contents to:

dmd2/src/

And I have no idea where you'll find the dmd2/src/ folder on 
Linux. But, assuming you can find it, this may get you up and 
running.


Let me know how it goes.


Re: Gtkd and libgtksourceview

2019-10-30 Thread Ron Tarrant via Digitalmars-d-learn
On Wednesday, 30 October 2019 at 14:48:23 UTC, bioinfornatics 
wrote:


so which version should I used to be compatible with 
libgtksourceview-3 (I use centos 7)


When Mike Wey gets back in town (any day now) he should be able 
to provide a solution that's less of a kludge.


Re: Gtkd and libgtksourceview

2019-10-30 Thread Ron Tarrant via Digitalmars-d-learn

On Wednesday, 30 October 2019 at 18:00:24 UTC, Mike Wey wrote:

GtkSourceview was updated to 4.x in GtkD version 3.9.0, so any 
older version should work with GtkSourceview 3.


Welcome back, Mike...

The latest Windows runtime available on the GtkD downloads page 
installs libgtksourceview-3.0-1.dll, not the 4.0 version, so I 
suspect the Linux libraries may be out of step, too.


If you need Sourceview 3 in the newer version of GtkD you could 
replace `file: GtkSource-4.gir` with `file: GtkSource-3.0.gir` 
in `src/APILookupSourceView.txt` and then run `make generate` 
(requires girtod) and you should have a up to date binding for 
Sourceview 3.


Just for the record, this doesn't work on Windows. I made the 
change in APILookupSourceView.txt and re-ran Build.d, but 
sourceview/gsv/c/functions.d still shows:


version (Windows)
static immutable LIBRARY_GSV = ["libgtksourceview-4-0.dll"];
else version (OSX)
static immutable LIBRARY_GSV = ["libgtksourceview-4.0.dylib"];
else
static immutable LIBRARY_GSV = ["libgtksourceview-4.so.0"];



Re: Gtkd and libgtksourceview

2019-10-31 Thread Ron Tarrant via Digitalmars-d-learn

On Wednesday, 30 October 2019 at 22:26:41 UTC, Mike Wey wrote:


---
girtod -i src --use-runtime-linker --use-bind-dir
---


Hmmm... I'll need more information, I'm afraid. I Googled, but 
I'm not finding any instructions for building these DLLs.


Re: Gtkd and libgtksourceview

2019-10-31 Thread Ron Tarrant via Digitalmars-d-learn

On Thursday, 31 October 2019 at 11:47:41 UTC, Mike Wey wrote:

girtod can be found here: 
https://github.com/gtkd-developers/gir-to-d


It's a tool that generates a D Binding from GObject 
Introspection files, if you use the GTK installer from the gtkd 
website or msys2 the needed introspection (.gir) files should 
be installed on your system.


Running the command above in the root of the GtkD project, will 
regenerate the source based on the gir files found on your 
system.


The last two options passed to girtod are for backwards 
compatibility with older version of GtkD, and aren't needed for 
new bindings.


And technically you could also run: "girtod -i GSource-3.0.gir" 
and it will create a "out" directory with a GtkSourceview 
binding that should be fairly complete.


Okay, thanks, Mike. I'll try to set aside some time next week to 
dig into this.


Blog Post #84: Notebook, Part VIII - Child Widgets

2019-11-01 Thread Ron Tarrant via Digitalmars-d-learn
For the final instalment in the Notebook series, we take a look 
at accessing the contents of child widgets: 
https://gtkdcoding.com/2019/11/01/0084-notebook-viii-child-widgets.html


GtkDcoding Blog Interruption

2019-11-05 Thread Ron Tarrant via Digitalmars-d-learn
My apologies. I'm experiencing a technical problem with the GtkD 
Coding Blog site. Today's post has been uploaded, but the site 
isn't being updated properly, so the new page isn't available. 
Everything works fine locally, so for the moment, I'm stumped.


Until I can resolve this, please bear with me. I'll keep you all 
updated of any progress.




Re: GtkDcoding Blog Interruption

2019-11-05 Thread Ron Tarrant via Digitalmars-d-learn

On Tuesday, 5 November 2019 at 12:31:04 UTC, Ron Tarrant wrote:

Until I can resolve this, please bear with me. I'll keep you 
all updated of any progress.


I've been in touch with GitHub support and they're in a yellow 
alert situation, meaning (I assume) that service for all sites 
hosted on GitHub Pages will be degraded until that's cleared up.




Blog Post #85: Nodes-n-noodles, Part IV - A Node from a DrawingArea

2019-11-06 Thread Ron Tarrant via Digitalmars-d-learn

A day late, but here we are...

Diving back into the Nodes-n-noodles series, we look at how to 
build a moveable node from a DrawingArea. You can find it here: 
https://gtkdcoding.com/2019/11/05/0085-nodes-iv-node-drawing.html


Re: Blog Post #76: Nodes and Noodles, Part II

2019-11-06 Thread Ron Tarrant via Digitalmars-d-learn

On Sunday, 6 October 2019 at 23:15:43 UTC, Ron Tarrant wrote:

On Sunday, 6 October 2019 at 23:00:51 UTC, Zekereth wrote:

Here's the correct URL 
https://gtkdcoding.com/2019/10/04/0076-app-01-iii-noodles-and-mouse-clicks.html


Great tutorial(s)! Thanks!


LOL! Thanks, Zekereth.


Because of code reorganization, the above link should now be:

https://gtkdcoding.com/2019/10/04/0076-nodes-iii-noodles-and-mouse-clicks.html


  1   2   3   4   >