Re: DMD Deimos || GDC Deimos?

2014-04-26 Thread Mike Wey via Digitalmars-d-learn

On 04/26/2014 08:18 PM, Entry wrote:

I'd like to use GLFW from Deimos, but I couldn't get it to work (DMD
said it cannot use libglfw.a) and I've read somewhere that only GDC can
use these DLLs directly (with a D header, but that's still better than
hooking the methods). So do I need GDC for that or not? And would you
actually recommend it?

On a side note, getting GDC to work is a bitch. I had to copy around
several DLLs (like libiconv-2.dll) and it's now working only with the
libgcc_s_sjlj-1.dll copied right next to my application's exe. What am I
doing wrong?

This is really frustrating :/


With MinGW you would use the:

-static-libgcc

flag when linking the application.
I'm not sure if gdc also supports this, but you can give it a try.

--
Mike Wey


Re: Working on a library: request for code review

2014-06-13 Thread Mike Wey via Digitalmars-d-learn

On 06/12/2014 09:30 PM, Rene Zwanenburg wrote:

I remember a function which does something like only only + canFind on
one go. It would look something like

header.colorMapDepth.among(16, 32);

but I can't find it right now.. Maybe it was only proposed but never added.


http://dlang.org/library/std/algorithm/among.html

--
Mike Wey


Re: DMD Fails with fPIC error

2014-06-14 Thread Mike Wey via Digitalmars-d-learn

On 06/14/2014 03:58 AM, Reuben wrote:

Hi,
I'm new to D and am trying to compile a simple hello world program.
I get the following error when compiling it:


dmd test.d

/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../x86_64-pc-linux-gnu/bin/ld:
/opt/dmd-2.065/lib64/libphobos2.a(lifetime_488_4cd.o): relocation
R_X86_64_32 against `_D15TypeInfo_Shared7__ClassZ' can not be used when
making a shared object; recompile with -fPIC
/opt/dmd-2.065/lib64/libphobos2.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
--- errorlevel 1

This error occurs regardless of whether I use the -fPIC option or not.
Compiling DMD from source does not change anything.

I am using DMD 2.065.0 on Sabayon amd64, compiled from the dlang overlay
with gcc (Gentoo Hardened 4.7.3-r1 p1.4, pie-0.5.5) 4.7.3.

Thanks in advance.


From the error it looks like you are compiling test.d as shared while 
linking against the static version of the standard library.


If dmd test.d is the command being run there probably is an error in 
with the configuration in dmd.conf, the conf file is probably in /etc.


Depending on the desired behavior you'll need to remove the -shared flag 
from the configuration or add -defaultlib=:libphobos2.so


--
Mike Wey


Re: DMD Fails with fPIC error

2014-06-14 Thread Mike Wey via Digitalmars-d-learn

On 06/14/2014 02:01 PM, Reuben wrote:

On Saturday, 14 June 2014 at 10:45:25 UTC, Mike Wey wrote:

On 06/14/2014 03:58 AM, Reuben wrote:

Depending on the desired behavior you'll need to remove the -shared
flag from the configuration or add -defaultlib=:libphobos2.so


dmd.conf contains the default settings. I haven't specified -shared
anywhere. The only thing I can think of is that if -fPIC is required,
DMD might be implying it somehow.


Try running dmd test.d -v the last line in the outpus from dmd should 
show hows it's invoking gcc for the linking step.

Posting that here might give us some clue of what dmd is doing.


Compiling with -defaultlib seems to have fixed it. I'm getting a
warning, but the program compiles and seems to run OK.


dmd -defaultlib=:libphobos2.so -fPIC test.d
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../x86_64-pc-linux-gnu/bin/ld:
test.o: warning: relocation in readonly section `.rodata'.
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../x86_64-pc-linux-gnu/bin/ld:
warning: creating a DT_TEXTREL in object.


Is the warning something I should be worried about?


I don't know about this one.

--
Mike Wey


Re: DMD Fails with fPIC error

2014-06-15 Thread Mike Wey via Digitalmars-d-learn

On 06/14/2014 06:37 PM, Reuben wrote:

It looks like the only difference is which version of Phobos we link. I
think the reason for this might be that since my version of gcc is
hardened, it uses -fPIE by default for linking.
(http://wiki.gentoo.org/wiki/Hardened/Toolchain#Automatic_generation_of_Position_Independent_Executables_.28PIEs.29)


In that case the static Phobos needs to be build with -fPIC, which 
currently isn't the case looking at the Ebuild.


--
Mike Wey


Re: DMD Fails with fPIC error

2014-06-19 Thread Mike Wey via Digitalmars-d-learn

On 06/18/2014 08:51 AM, Reuben wrote:

On Sunday, 15 June 2014 at 09:08:10 UTC, Mike Wey wrote:

In that case the static Phobos needs to be build with -fPIC, which
currently isn't the case looking at the Ebuild.


Compiling DMD with PIC=1 doesn't seem to do the trick. -fPIC is used for
the C files, but when linking Phobos the following appears:

/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../x86_64-pc-linux-gnu/bin/ld:
generated/linux/release/64/libphobos2.so.0..o: warning: relocation in
readonly section `.deh_eh'.
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../x86_64-pc-linux-gnu/bin/ld:
warning: creating a DT_TEXTREL in object.


Compiling dmd with -fPIC shoudn't matter, building the static version of 
Phobos works for me (make -f posix.mak DFLAGS=-fPIC), but i don't have 
an hardened gcc, so that may be why.


Google tells me the DT_TEXTREL error is because of non -fPIC objects in 
a shared library.



Compiling with it then gives the following:

$ ./dmd test.d
... error ...


readelf doesn't show any TEXTRELs in libc, so I assume it is also hardened.


test.d still needs to be build with -fPIC.

--
Mike Wey


Re: Bizarre compile error in GtkD

2014-06-30 Thread Mike Wey via Digitalmars-d-learn

On 06/30/2014 01:32 PM, Chris wrote:

Dunno if it's the ResponseType vs GtkResponseType


ResponseType is an alias for GtkReponseType, so that isn't the problem.

getParentWindow() returns an gdk.Window.Window while the 
FileChooserDialog constructor expects an gtk.Window.Window.


you probably want to use:
cast(gtk.Window.Window)(editor.drawingArea.getToplevel())
if you don't have access to the variable holding your main window.

--
Mike Wey


Re: Thread-safety and lazy-initialization of libraries

2014-06-30 Thread Mike Wey via Digitalmars-d-learn

On 06/30/2014 11:05 PM, bearophile wrote:

Sergey Protko:


libmpg123 has mpg123_init and mpg123_exit functions, which are not
thread-safe, so we should to call them only once per process. Most of
useful libraries also has such stuff. But manual initialization is
killing all beauty of high-level bindings.


I think module static this is thread-local, so in theory you can use
that. But I don't know if it's a good idea to perform heavy computations
inside those module static this.

Bye,
bearophile


You'll need to use a `shared static this` if those functions can be 
called only once per process.

A regular static this is executed once per Thread.

--
Mike Wey


Re: Problem Linking Phobos git master

2014-07-05 Thread Mike Wey via Digitalmars-d-learn

On 07/05/2014 12:13 AM, Nordlöw wrote:

On Ubuntu 14.04 my git master build script for phobos now fails as below.

Why? Help please.

/usr/bin/ld points to /usr/bin/ld.bfd on my system

Terminal echo and error message follows:

../dmd/src/dmd -I/home/per/opt/x86_64-unknown-linux-gnu/dmd/include/d2
-shared -debuglib= -defaultlib= ...


Do you have an DFLAGS environment variable set on your system?

It looks like the environment variable is used instead of the make file 
variable while compiling.


--
Mike Wey


Re: What hashing algorithm is used for the D implementation of associative arrays?

2014-08-09 Thread Mike Wey via Digitalmars-d-learn

On 08/09/2014 11:33 AM, Gary Willoughby wrote:

What hashing algorithm is used for the D implementation of associative
arrays? Where in the D source does the AA code live?


Paul Hsieh's SuperFastHash:
http://www.azillionmonkeys.com/qed/hash.html

The source is here: 
https://github.com/D-Programming-Language/druntime/blob/master/src/rt/aaA.d


--
Mike Wey


Re: What hashing algorithm is used for the D implementation of associative arrays?

2014-08-09 Thread Mike Wey via Digitalmars-d-learn

On 08/09/2014 01:43 PM, Gary Willoughby wrote:

On Saturday, 9 August 2014 at 10:28:02 UTC, Mike Wey wrote:

Paul Hsieh's SuperFastHash:
http://www.azillionmonkeys.com/qed/hash.html


Where is this implemented?


https://github.com/D-Programming-Language/druntime/blob/master/src/rt/util/hash.d

--
Mike Wey


Re: [dub] Size of executable

2014-11-27 Thread Mike Wey via Digitalmars-d-learn

On 11/27/2014 03:14 PM, Chris wrote:

 dub says:

Compiling using dmd...
Linking...

I have the exact same setting, I think. I don't build for release with
either method.

dmd file1.d file2.d file3.d ...

(dub compiles the same files, no release build)


dub builds with --debug by default.

--
Mike Wey


Re: Hello World Example with Glade?

2015-09-11 Thread Mike Wey via Digitalmars-d-learn

On 09/11/2015 04:00 PM, Mike McKee wrote:

On Friday, 11 September 2015 at 09:07:37 UTC, Jordi Sayol wrote:

On  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


Re: GTKD Cairo get pixel color

2016-01-04 Thread Mike Wey via Digitalmars-d-learn

I think you are looking for something like this.

Context.getTarget will get you the surface the Context is drawing to, 
this most likely isn't a ImageSurface.
So you will need to create an pixbuf from the returned surface, with the 
Pixbuf you can then get the raw pixel data using getPixelsWithLength().


```
import gdk.Pixbuf;

bool drawCallback(Scoped!Context cr, Widget widget)
{
GtkAllocation size;
Pixbuf surafce;

getAllocation(size);

//Draw something;

surface = getFromSurface(cr.getTarget(), 0, 0, size.width, 
size.height);


ubyte[] data = cast(ubyte[])surface.getPixelsWithLength();

//Do somthing with data.

return true;
}
```

getPixelsWithLength has the wrong return type, which will probably be 
fixed some time.


--
Mike Wey


Re: GTKD Cairo get pixel color

2016-01-04 Thread Mike Wey via Digitalmars-d-learn

On 01/04/2016 09:13 PM, TheDGuy wrote:

On Monday, 4 January 2016 at 19:27:48 UTC, Mike Wey wrote:

I think you are looking for something like this.

Context.getTarget will get you the surface the Context is drawing to,
this most likely isn't a ImageSurface.
So you will need to create an pixbuf from the returned surface, with
the Pixbuf you can then get the raw pixel data using
getPixelsWithLength().

```
import gdk.Pixbuf;

bool drawCallback(Scoped!Context cr, Widget widget)
{
GtkAllocation size;
Pixbuf surafce;

getAllocation(size);

//Draw something;

surface = getFromSurface(cr.getTarget(), 0, 0, size.width,
size.height);

ubyte[] data = cast(ubyte[])surface.getPixelsWithLength();

//Do somthing with data.

return true;
}
```

getPixelsWithLength has the wrong return type, which will probably be
fixed some time.


Thank you very much! But surface.getPixelsWithLength() only gives me an
array with 16 fields (with a 256x256 DrawingArea)?

I also tried to save the Pixbuf with:

string[] options = ["quality"];
string[] opval = ["100"];
surface.savev("C:\\Users\\Standardbenutzer\\Desktop\test.jpeg", "jpeg",
options, opval);

but i found absolutely NOTHING about the options or the option values i
have to set, therefore i get an invalid argument exception :(


I don't have any issues with either getPixelsWithLength and savev.
for the savev call there is an missing \ just before test.jpg, but that 
might be a copy and paste error?


For the options that are available for savev the documentation of 
GDK-PixBuff lists the few available options.

https://developer.gnome.org/gdk-pixbuf/unstable/gdk-pixbuf-File-saving.html#gdk-pixbuf-save

Although i'm on Linux so that might make an difference.

--
Mike Wey


Re: GTKD Cairo get pixel color

2016-01-02 Thread Mike Wey via Digitalmars-d-learn

On 01/02/2016 12:32 AM, TheDGuy wrote:

On Friday, 1 January 2016 at 22:00:04 UTC, TheDGuy wrote:

On Friday, 1 January 2016 at 19:32:40 UTC, Basile B. wrote:

On Wednesday, 30 December 2015 at 23:20:23 UTC, Basile B. wrote:

On Wednesday, 30 December 2015 at 20:44:44 UTC, TheDGuy wrote:

Hello,

is there any way to get the pixel color of a single pixel by x and
y coordinates of a context?


render to a png back buffer.

see cairo_image_surface_create_for_data

then you'll be able to access the data and, at the same time, to
blit your buffer to screen.



Actually I was thinking to a user defined buffer type:

struct SurfaceBuffer
{
void* data; // used as param to create the surface
Rgba[] opIndex(size_t index);
Rgba[][] scanline();
}

that you would pass as data in cairo_image_surface_create_for_data().

But gtk certainly has pitcure classes with the typical scanline
method and that you could use in cairo_image_surface_create_for_data.


Ahm, i am not quite sure if you and [Mike Wey] talk about the same
thing. And i posted the error message in my last post when i try to
call "cairo_image_surface_create_for_data". I still don't know where i
am able to call the function?


I took a look into the source code of cairo and in the
"ImageSurface.d"-file there is a function called "createForData" but if
i try to use it like this:

cairo.ImageSurface.createForData(c,cairo.FORMAT_ARGB32,256,256,256*4);

i get: "undefined identifier 'createForData' in module 'cairo.ImageSurface'


```
import cairo.ImageSurface;
ImageSurface.createForData(c,cairo.FORMAT_ARGB32,256,256,256*4);
```

You need to import the ImageSurface module, and the createForData 
function is in the ImageSurface class which is in the cairo.ImageSurface 
module.




That is just one example of my experience using D:

some things are easy to understand but in other cases: even if you think
it should work and you can proof it, it just doesn't or you have to do
it in a really inconvenient way. I am getting frustrated


--
Mike Wey


Re: GTKD Cairo get pixel color

2016-01-01 Thread Mike Wey via Digitalmars-d-learn

On 01/01/2016 01:37 PM, TheDGuy wrote:

On Wednesday, 30 December 2015 at 23:20:23 UTC, Basile B. wrote:

On Wednesday, 30 December 2015 at 20:44:44 UTC, TheDGuy wrote:

Hello,

is there any way to get the pixel color of a single pixel by x and y
coordinates of a context?


render to a png back buffer.

see cairo_image_surface_create_for_data

then you'll be able to access the data and, at the same time, to blit
your buffer to screen.


Thanks for your answer. But how do i access the function via the context?

It does not work like this:

class DW:DrawingArea{
 this(){
 addOnDraw();
 }
 bool drawCallback(Scoped!Context cr, Widget widget){
 char[] c = new char[](256*256);
 auto val =
cr.cairo_image_surface_create_for_data(c,cairo_format_t.CAIRO_FORMAT_ARGB32,
256,256,
cairo.format_stride_for_width(cairo_format_t.CAIRO_FORMAT_ARGB32,256));
 return true;
 }
}
"no property 'cairo_image_surface_create_for_data' for type 'Scoped'"


you would either cr.getTarget(); or cairo.ImageSurface.ImageSurface.create.

I'm not sure how those would get you access to the pixel data.

--
Mike Wey


Re: GTKD Cairo get pixel color

2016-01-05 Thread Mike Wey via Digitalmars-d-learn

On 01/04/2016 11:08 PM, TheDGuy wrote:

On Monday, 4 January 2016 at 21:42:16 UTC, Mike Wey wrote:

On 01/04/2016 09:13 PM, TheDGuy wrote:

[...]


I don't have any issues with either getPixelsWithLength and savev.
for the savev call there is an missing \ just before test.jpg, but
that might be a copy and paste error?

For the options that are available for savev the documentation of
GDK-PixBuff lists the few available options.
https://developer.gnome.org/gdk-pixbuf/unstable/gdk-pixbuf-File-saving.html#gdk-pixbuf-save


Although i'm on Linux so that might make an difference.


Ups, that was my fault, sry :(

But how do i get now the color for each pixel out of the ubyte[]?


It looks like the array has the R, G and B values like this:

[R, G, B, R, G, B, R, G, B, R, G, B, ...]

for every pixel from left to right top to bottom,
So data[0] gives you the Red value for the pixel at 0,0.
data[1] the Blue value and data[2] the green value.
data[3] would then be Red for pixel 1,0.

--
Mike Wey


Re: GTKD - Get the size of the context

2015-12-26 Thread Mike Wey via Digitalmars-d-learn

On 12/25/2015 11:55 AM, TheDGuy wrote:

Hello,

i want to draw something to a GTKD context and i need the size of the
context in pixel but i don't know how i can get the pixel height and
width? Any ideas?

With best regards


You could try getting the size of the widget the context is referring to 
with getAllocation.


GtkAllocation size;
widget.getAllocation(size);

and then use size.width and size.height.

--
Mike Wey


Re: GTKD drawing area remains white even SourceRgb is changed

2015-12-28 Thread Mike Wey via Digitalmars-d-learn

On 12/28/2015 12:29 AM, TheDGuy wrote:

My code:

http://dpaste.com/1X3E1HW

i store colors in the accumulator-array and draw them via
"cr.rectangle()". Because i have some problems with the code i set the
SourceRgb-color to a constant value but if i execute the program, the
window remains white.


The values passed to setSourceRgb should be between 0 and 1.

--
Mike Wey


Re: GTKD - Attach Button to Grid in specific column and row

2016-06-11 Thread Mike Wey via Digitalmars-d-learn

On 06/11/2016 04:57 PM, TheDGuy wrote:

Hi,
i am wondering why this code doesn't work, even though i set the column
and row position of the button it is always placed at the top left (so
basically first row and first column):

   ... Code ...


The way GTK manages width and height, usually widgets are given the 
minimum size they need. So when the button is the only widget in the 
grid the other rows and columns have a height/width of 0.


You can force the button / gird cell to the bottom left by setting the 
expand and alignment properties of the button.


this(int width, int height, string title){
super(title);
setDefaultSize(width,height);

Button btn = new Button();
btn.setSizeRequest(25,25);
btn.setLabel("Exit");
btn.setVexpand(true);
btn.setHexpand(true);
btn.setHalign(Align.END);
btn.setValign(Align.END);
auto call = 
btn.addOnEnterNotify(call);
btn.addOnLeaveNotify(call);

Grid grid = new Grid();
grid.setColumnSpacing(6);
grid.setRowSpacing(6);
grid.attach(btn,3,3,1,1);
add(grid);

showAll();
}

--
Mike Wey


Re: GTKD - Attach Button to Grid in specific column and row

2016-06-14 Thread Mike Wey via Digitalmars-d-learn

On 06/14/2016 04:54 PM, TheDGuy wrote:

On Saturday, 11 June 2016 at 21:14:43 UTC, Mike Wey wrote:

The way GTK manages width and height, usually widgets are given the
minimum size they need. So when the button is the only widget in the
grid the other rows and columns have a height/width of 0.

You can force the button / gird cell to the bottom left by setting the
expand and alignment properties of the button.




Thanks for your reply, but now the button is always on the bottom right :(




What are you trying to accomplish?

--
Mike Wey


Re: GTKD - get CSS class for button

2016-06-22 Thread Mike Wey via Digitalmars-d-learn

On 06/22/2016 05:16 PM, TheDGuy wrote:

On Wednesday, 22 June 2016 at 13:47:01 UTC, Gerald wrote:

On Wednesday, 22 June 2016 at 12:57:51 UTC, TheDGuy wrote:

widget.getStyleContext().listClasses() to get a list of all classes
assigned to the widget. If you just want to see if a specific class
is assigned to the widget you can use
widget.getStyleContext().hasClass()


Thanks a lot for your answer. Do you know how i can get the first
classname as string from the widget? I don't understand how the
return type 'GList' is organized.


ListG has a D specific method called toArray that allows you to
convert it to a typed array, so you could use it in this case to get a
string[] out of it.

http://api.gtkd.org/src/glib/ListG.html


"Type T wraps should match the type of the data"

Does string match the type of the data? What is the type of the data?
How do i tell the function that i want the Array as a string array? I am
not familiar with Types and what 'TC' or 'T' is, i am afraid.


toArray currently only works for GtkD classes, so it doesn't work for 
lists of stings.


ListG is a linked list, the data is stored in the data property. to 
iterate over the list do something like this:


```
ListG list = widget.getStyleContext().listClasses();

while(list !is null)
{
string str = to!string(cast(char*)list.data);

//do something with str.

list = list.next;
}
```

--
Mike Wey


Re: GTKD - addOnButtonPress faulty?

2016-06-23 Thread Mike Wey via Digitalmars-d-learn

On 06/23/2016 10:30 AM, TheDGuy wrote:

Hi,

sorry for my next thread but i did encounter a strange behaviour of the
"Button.addOnButtnPress" - Event. Sometimes if i click very fast on the
GTKD button, it reacts twice! I am working on a small game and i noticed
that if i click slowly everything works as expected but sometimes i have
to click a button more than once and if i do it very fast it is often
recognized as 3 clicks. I did it like this:


I'm not sure about this one, but when you click the button more than 
once the event is also called more than once.



Button btn_1 = new Button();
auto call1 = 
btn_1.addOnButtonPress(call1);

bool btn1ClickedEvent(Event e, Widget widget){
userInput ~= 1;
checkForWin();
return true;
}

So is it my bad code or was it recognized by others as well? I know that
GTKD claims that this method is deprecated but i didn't find anything
else that works.


addOnPressed is deprecated addOnButtonPress is not.

--
Mike Wey


Re: GTKD - CSS class color "flash" delay

2016-06-25 Thread Mike Wey via Digitalmars-d-learn

On 06/25/2016 05:26 PM, TheDGuy wrote:

On Saturday, 25 June 2016 at 13:01:09 UTC, TheDGuy wrote:

Thanks for your answer.
I have to pass the Button object to my timeout function to change the
CSS class. But how do i do that within the Timeout constructor?


I mean:

I have to pass my function and delay time to the constructor, but i
can't pass any data to the function here, also only functions are
allowed (at least it looks like that to me) who don't have parameters.

If i want to add a new function i have to use the function .add(), with
this function i can pass 'userData' (so my button for example). But why
am i unable to do that in the constructor? Do i have 2 different
functions for the same thing, one with the other one without parameter?

My current approach:

private void letButtonsFlash(){
foreach(Button btn;bArr){
btn.setSensitive(false);
}
for(int i = 0; i < level; i++){
Button currentButton = bArr[rndButtonBlink[i]];
ListG list = currentButton.getStyleContext().listClasses();
string CSSClassName = to!string(cast(char*)list.next().data);
currentButton.getStyleContext().addClass(CSSClassName ~
"-flash");
//writeln(CSSClassName);
Timeout t = new Timeout(_delay,5,false); //error
appears here
t.add(5,_delay,currentButton);
}
foreach(Button btn;bArr){
btn.setSensitive(true);
}
}
bool timeout_delay(Button currentButton){
ListG list = currentButton.getStyleContext().listClasses();
string CSSClassName = to!string(cast(char*)list.next().data);
currentButton.getStyleContext().removeClass(CSSClassName ~
"-flash");
return false;
}

But i get the error:
Error: none of the overloads of '__ctor' are callable using argument
types (bool delegate(void* userData), int, bool), candidates are:
glib.Timeout.Timeout.this(uint interval, bool delegate() dlg, bool
fireNow = false)
glib.Timeout.Timeout.this(uint interval, bool delegate() dlg, GPriority
priority, bool fireNow = false)
glib.Timeout.Timeout.this(bool delegate() dlg, uint seconds, bool
fireNow = false)
glib.Timeout.Timeout.this(bool delegate() dlg, uint seconds, GPriority
priority, bool fireNow = false)

If i take a look at GTK for C it looks like there is a function for that:

http://www.gtk.org/tutorial1.2/gtk_tut-17.html

Why is this so confusing?


The constructor accepts an delegate, witch can access it's context so it 
has access to some of the data.


The functions from GTK are also available like Timeout.add from the 
linked tutorial: http://api.gtkd.org/src/glib/Timeout.html#Timeout.add



You may want to do something like this:

```
private void letButtonsFlash()
{
foreach(Button btn;bArr){
btn.setSensitive(false);
}

Timeout t = new Timeout(_delay,5,false);
}

private bool timeout_delay()
{
for(int i = 0; i < level; i++){
Button currentButton = bArr[rndButtonBlink[i]];
ListG list = currentButton.getStyleContext().listClasses();
string CSSClassName = to!string(cast(char*)list.next().data);
currentButton.getStyleContext().addClass(CSSClassName ~ "-flash");
}

return false;
}

```

--
Mike Wey


Re: GTKD - CSS class color "flash" delay

2016-06-26 Thread Mike Wey via Digitalmars-d-learn

On 06/26/2016 12:10 AM, TheDGuy wrote:

On Saturday, 25 June 2016 at 21:57:35 UTC, TheDGuy wrote:

But i want to flash (e.g. change the CSS class) the buttons one by one
and not all at the sime time? How am i going to do that?


Okay, i tried it with a new private int-variable which contains the
current index of the for-loop, like this:

private void letButtonsFlash(){
foreach(Button btn;bArr){
btn.setSensitive(false);
}
for(int i = 0; i < level; i++){
index = i; //index is public
Button currentButton = bArr[rndButtonBlink[i]];
ListG list = currentButton.getStyleContext().listClasses();
string CSSClassName = to!string(cast(char*)list.next().data);
currentButton.getStyleContext().addClass(CSSClassName ~
"-flash");
Timeout t = new Timeout(_delay,1,false);
}

foreach(Button btn;bArr){
btn.setSensitive(true);
}
}
bool timeout_delay(){
Button currentButton = bArr[rndButtonBlink[index]];
ListG list = currentButton.getStyleContext().listClasses();
string CSSClassName = to!string(cast(char*)list.next().data);
currentButton.getStyleContext().removeClass(CSSClassName ~
"-flash");
return false;
}

But now the strange thing happens, that the first button lights up as
expected but the second button remains at its "flash color" and doesn't
go back to normal color, i don't understand why this happens? Any ideas?


You should probably increment the index in the timeout_delay function.

--
Mike Wey


Re: GTKD - CSS class color "flash" delay

2016-06-26 Thread Mike Wey via Digitalmars-d-learn

On 06/26/2016 05:03 PM, TheDGuy wrote:

On Sunday, 26 June 2016 at 12:30:22 UTC, Mike Wey wrote:


You should probably increment the index in the timeout_delay function.


This leads to a Range violation exception...


How about this:

private void letButtonsFlash(){
foreach(Button btn;bArr){
btn.setSensitive(false);
}
for(int i = 0; i < level; i++){
Button currentButton = bArr[rndButtonBlink[i]];
ListG list = currentButton.getStyleContext().listClasses();
string CSSClassName = to!string(cast(char*)list.next().data);
currentButton.getStyleContext().addClass(CSSClassName ~ "-flash");
}
Timeout t = new Timeout(_delay,1,false);
}

bool timeout_delay(){
for(int i = 0; i < level; i++){
Button currentButton = bArr[rndButtonBlink[i]];
ListG list = currentButton.getStyleContext().listClasses();
string CSSClassName = to!string(cast(char*)list.next().data);
currentButton.getStyleContext().removeClass(CSSClassName ~ 
"-flash");

}
foreach(Button btn;bArr){
btn.setSensitive(true);
}
return false;
}

Sets all the buttons to the flash color and after an timeout removes the 
flash color from all the buttons.


--
Mike Wey


Re: GTKD - CSS class color "flash" delay

2016-06-25 Thread Mike Wey via Digitalmars-d-learn

On 06/24/2016 10:03 PM, TheDGuy wrote:

On Friday, 24 June 2016 at 16:44:59 UTC, Gerald wrote:

Other then the obvious multi-threaded, using glib.Timeout to trigger
the reversion of the color change could be an option.

http://api.gtkd.org/src/glib/Timeout.html


Thanks! I tried this so far:
private void letButtonsFlash(){
foreach(Button btn;bArr){
btn.setSensitive(false);
}
for(int i = 0; i < level; i++){
Button currentButton = bArr[rndButtonBlink[i]];
ListG list = currentButton.getStyleContext().listClasses();
string CSSClassName = to!string(cast(char*)list.next().data);
currentButton.getStyleContext().addClass(CSSClassName ~
"-flash");
writeln(CSSClassName);
Timeout t = new Timeout(_delay,1,true);
currentButton.getStyleContext().removeClass(CSSClassName ~
"-flash");

}
foreach(Button btn;bArr){
btn.setSensitive(true);
}
}
bool timeout_delay(){
Thread.sleep(dur!("seconds")(5));
return false;
}

and it is "working" to the extend that at least the CSSClassName gets
written in the console but the UI again just pops up after 5 sec. Could
you give me a tip?



You should change the css class in the timeout_delay function.

It's called by the GTK main loop every time the amount of seconds passed 
to the constructor has passed. And return true if you want to continue 
to flash the button, and false to stop.


Also don't sleep in the timeout function, the main loop should take care 
of that, currently you are blocking the main thread for 5 seconds.


--
Mike Wey


Re: Status icon on Linux

2016-02-20 Thread Mike Wey via Digitalmars-d-learn

On 02/20/2016 06:13 AM, Chris Wright wrote:

I want a status icon for a Linux application. gtk.StatusIcon notes that
it's deprecated (and doesn't work on MATE 1.8.2).

What should I be using?



The GTK developers have decided that we don't need no status icon, it 
would presumably mess up there beautiful gnome shell design.


The documentation states we should use notifications, that means i'll 
probably need to add libnotify bindings to GtkD. Though sending 
notifications using DBus is also possible. 
(https://developer.gnome.org/notification-spec/)


Depending on the use case using notifications might or might not be useful.

--
Mike Wey


Re: Status icon on Linux

2016-02-21 Thread Mike Wey via Digitalmars-d-learn

On 02/20/2016 06:32 PM, Gerald wrote:

On Saturday, 20 February 2016 at 11:36:11 UTC, Mike Wey wrote:

The documentation states we should use notifications, that means i'll
probably need to add libnotify bindings to GtkD. Though sending
notifications using DBus is also possible.
(https://developer.gnome.org/notification-spec/)

Depending on the use case using notifications might or might not be
useful.


Would the support for libnotify be for those applications not using
gtk.Application since it already supports sending notifications via
sendNotification. I'm using it in Terminix and it works quite well.



A search of the GTK documentation only gave me results form libnotify so 
i missed the GApplication / GNotification functionality.


--
Mike Wey


Re: Where do I learn to use GtkD

2016-04-04 Thread Mike Wey via Digitalmars-d-learn

On 04/04/2016 09:33 PM, Karabuta wrote:

On Monday, 14 March 2016 at 03:46:02 UTC, Gerald wrote:

On Sunday, 13 March 2016 at 19:53:35 UTC, karabuta wrote:

On Sunday, 13 March 2016 at 19:34:36 UTC, WebFreak001 wrote:

and in the (not quite complete) documentation you can find widgets
you might want to use. Its a great place for getting ideas on which
widgets to use imo. http://api.gtkd.org/src/gtk/AboutDialog.html


That thing really need some work to make it consumable :)


I contributed a script (makeddocs.sh) to generate the documentation in
ddox instead of candydocs, ddox is miles better then candydocs and
using it is way more efficient IMHO.


Where can I find and use?


https://github.com/gtkd-developers/GtkD/blob/master/makeddox.sh

running ./makedocs.sh should generate the ddox documentation.

--
Mike Wey


Re: GTKD - CSS class color "flash" delay

2016-06-30 Thread Mike Wey via Digitalmars-d-learn

On 06/30/2016 08:53 AM, TheDGuy wrote:

On Wednesday, 29 June 2016 at 10:41:21 UTC, TheDGuy wrote:

I tried to debug a little and what i don't understand is, that i get
two times 'blue' on the console, even though yellow and blue lit up
but yellow stayed at the flash color:

private void letButtonsFlash(){
foreach(Button btn;bArr){
btn.setSensitive(false);
}
for(int i = 0; i < level; i++){
index = i;
Button currentButton = bArr[rndButtonBlink[i]]; //Array
holds randomized Buttons
ListG list = currentButton.getStyleContext().listClasses();
string CSSClassName = to!string(cast(char*)list.next().data);
currentButton.getStyleContext().addClass(CSSClassName ~
"-flash");
Timeout t = new Timeout(() =>
this.timeout_delay(currentButton),1,false);
}

foreach(Button btn;bArr){
btn.setSensitive(true);
}
}
bool timeout_delay(Button currentButton){
ListG list = currentButton.getStyleContext().listClasses();
string CSSClassName = to!string(cast(char*)list.next().data);
writeln(CSSClassName); //try to debug
currentButton.getStyleContext().removeClass(CSSClassName ~
"-flash");
return false;
}

The reason for the problem that buttons are flashing simultaneously
might be, that the Timeout is running in an extra thread and therefore
another Timeout is created by the mainthread in the for-loop even
though the last one hasn't finished yet.

But what i don't understand is why the last button doesn't go back to
the normal CSSClass and that the first button has two timeouts
(according to my console debug text)?

It would be very much appreciated if someone who has GTKD installed
can try my code:

http://pastebin.com/h0Nx1mL6


Okay, i am quite sure now that this is some kind of bug:

https://picload.org/image/rrrgwpgi/gtkd_timeout.png

private void letButtonsFlash(){
foreach(Button btn;bArr){
btn.setSensitive(false);
}
for(int i = 0; i < level; i++){
index = i;
Button currentButton = bArr[rndButtonBlink[i]]; //Array
holds randomized Buttons
ListG list = currentButton.getStyleContext().listClasses();
string CSSClassName = to!string(cast(char*)list.next().data);
currentButton.getStyleContext().addClass(CSSClassName ~
"-flash");
writeln("Creating Timeout for : " ~ CSSClassName);
Timeout t = new Timeout(() =>
this.timeout_delay(currentButton),1,false);
}

foreach(Button btn;bArr){
btn.setSensitive(true);
}
}
bool timeout_delay(Button currentButton){
ListG list = currentButton.getStyleContext().listClasses();
string CSSClassName = to!string(cast(char*)list.next().data);
currentButton.getStyleContext().removeClass(CSSClassName ~
"-flash");
writeln("Removing flash CSS color for: " ~ CSSClassName);
return false;
}


Is the complete source available some ware?

--
Mike Wey


Re: Getting GtkD working with OpenGL

2016-10-04 Thread Mike Wey via Digitalmars-d-learn

On 10/03/2016 11:46 PM, Chalix wrote:

On Monday, 3 October 2016 at 18:00:53 UTC, Mike Wey wrote:

The signal functions can be found in the gobject.Signals module.

But you should use the GLArea.addOnCreateContext / addOnRender /
addOnResize functions to attach a D delegate to the signal.
You will still need to link with the OpenGL libraries or use someting
like Derelict.


Hi Mike, thanks for your fast answer again!

I just read about this delegates and I liked the concept. I experimented
with it for a while and read a bit on the Internet, but I still don't
get it working...

My minimal example looks like this:

import gtk.Main;
import gtk.MainWindow;
import gtk.GLArea;
import glgdk.GLContext;

void main(string[] args)
{
bool render(GLContext context, GLArea area)
{
return true;
}

Main.init(args);
MainWindow win = new MainWindow("Hello World");
GLArea area = new GLArea();

area.addOnRender(,cast(GConnectFlags)0);

win.add(area);
win.showAll();
Main.run();
}

If I compile it, I get this error:

$ dmd main.d -I/usr/local/include/d/gtkd-3 -L-lgtkd-3
main.d(27):
Error: function gtk.GLArea.GLArea.addOnRender
(bool delegate(GLContext, GLArea) dlg, GConnectFlags connectFlags =
cast(GConnectFlags)0)
is not callable using argument types
(bool delegate(GLContext context, GLArea area), GConnectFlags)

I cant see, what I am doing wrong... Someone else sees the error?
Tomorrow I try to subclass the GLArea, if this works I am happy :) But
I'd like to use the handler stuff.

Ah, and I know now, that I have to link against the GL and GLU library,
but which module do I have to import, to make the functions visible for
the compiler? Or do I need another binding therefore?


Replace "import glgdk.GLContext;" with "import gdk.GLContext;"

The error is a bit confusing without the fully qualified names of the 
types, but GLArea depends on the OpenGL functionality build in to GDK, 
and doesn't depend on gtkglext.


--
Mike Wey


Re: Getting GtkD working with OpenGL

2016-10-06 Thread Mike Wey via Digitalmars-d-learn

On 10/06/2016 05:18 PM, Chalix wrote:

On Thursday, 6 October 2016 at 13:35:01 UTC, Mike Parker wrote:

So, change DerelictGL3.load to DerelictGL.load, then add a call to
DerelictGL.reload after creating and activating the context.


Thank you! That fixed the segmentation fault problem and the crash :)

But I still struggle with the right Context...

if I do something like this

DerelictGL.load();
area.makeCurrent();
DerelictGL.reload();

I get an (runtime) error (on the terminal where I run my application):

(LibraryTest:2984): Gtk-CRITICAL **: gtk_gl_area_make_current: assertion
'gtk_widget_get_realized (widget)' failed
derelict.util.exception.DerelictException@gl3.d(85): DerelictGL3.reload
failure: An OpenGL context is not currently active.
[...]


After all, I really don't know, what a GLContext is, what I need it for
and how to use it. If somebody can explain it to me, I would be happy! I
didn't find anything about it on the Internet, but I like to know, whats
going on behind my code...

I will keep on playing around with all the context functions, maybe I
find something by accident that works xD



When you don't register an callback for the createContext signal 
(addOnCreateContext), gtk does the following internally:


```
context = area.getWindow().createGlContext();
```
to get an context that renders to the GLArea.

gdk.GLContext is an platform independent abstraction for the context you 
would normally use with openGL. like the one's returned by 
wglCreateContext or glxCreateContext.


makeCurrent() sets that context as the one that is rendered to.
realize() i think makes sure the context is initialized, but 
makeCurrent() also calls realize, so makeCurrent is probably the one you 
want to use.


--
Mike Wey


Re: Getting GtkD working with OpenGL

2016-09-18 Thread Mike Wey via Digitalmars-d-learn

On 09/18/2016 09:36 PM, Chalix wrote:

Hi All!

This weekend I explored Dlang and I think it's very promising. So I
wanted to create some projects I've created with C++ already - for the
sake of comparison.

I wanted to create a new class which inherits from DrawingArea (from the
Gtk library). This will be my OpenGL-Widget with functions like
"drawGL", which I have to override.

So I downloaded the "GtkD-3.3.0.zip" from here:
http://gtkd.org/download.html and compiled it successfully (with "make
all").

Now I've got the libraries gstreamerd-3, gtkd-3, gtkdgl-3, gtkdsv-3 and
vted-3. I also got the module files for the import at
"/usr/local/include/d/gtkd-3/", after I did a "make install".

Now I tested a little example I found somewhere in the web, which looks
like:

import gtk.MainWindow;
import gtk.Label;
import gtk.Main;
import gtk.GLArea;
void main(string[] args)
{
Main.init(args);
MainWindow win = new MainWindow("Hello World");
GLArea area = new GLArea();
win.add(area);
win.setDefaultSize(200, 100);
win.showAll();
Main.run();
}

This compiles fine and I get an empty black window. (I compiled with the
options: "dmd main.d -I/usr/local/include/d/gtkd-3
-L/pathToLib/libgtkd-3.a")



Now I scanned through the demos at the GtkD Library and I found one,
that fits my needs perfectly. It is located at
".../GtkD-3.3.0/demos/gl/simple/SimpleGL.d" (I post the source code in
an extra answer, since it is a bit lengthy...)

This demo compiles fine (with "dmd main.d -c -I/...", -c tells the
compiler not to link).
But the linker gives an error here (command was: "dmd main.o
-L/libgtkd-3.a -L/libgtkdgl-3.a ...", I linked to all the libs mentioned
above).
I get a very lengthy error message, and I cant figure out, why the
reference to all the gl stuff is missing. Would be really great, if some
one could give me a hint!

Ah, yeah, just do avoid the answer "make it with dub!": Actually I did
it also with dub and I get the same error messages... If you are
interested, I can provide you also my .json file. But I like to know
whats going on behind, so I prefer the way to install my libs manually.
Would be great, if I get this working.



The demo still uses the old GtkGLExt binding, which usually isn't 
available in de distributions repositories.


The newer GLArea is easier to use since it's part of GTK.

As for the linker errors, you'll need to link with the OpenGL libraries:
"-L-lGL -L-lGLU"

--
Mike Wey


Re: Getting GtkD working with OpenGL

2016-10-03 Thread Mike Wey via Digitalmars-d-learn

On 10/03/2016 01:50 PM, Chalix wrote:

On Sunday, 18 September 2016 at 21:41:45 UTC, Mike Wey wrote:

The demo still uses the old GtkGLExt binding, which usually isn't
available in de distributions repositories.

The newer GLArea is easier to use since it's part of GTK.

As for the linker errors, you'll need to link with the OpenGL libraries:
"-L-lGL -L-lGLU"


Hey, thanks for your fast answer! I had a lot of other work to do, so I
could only continue working on this project now.

Yeah, that solved my problem :) Now it links. Although if I execute the
program, it complains about the missing GtkGLExt library, like expected...
Library load failed: libgdkglext-3.0.so.0

So I wanted to install this library from here:
https://projects.gnome.org/gtkglext/download.html
but the ./configure script tells me,
No package 'pangox' found (pangox >= 1.0.0)

I looked at the folder /usr/lib/x86_64-linux-gnu/ and there is a file
called "libpangox-1.0.so.0.0.0". So I don't know, why this is not
working...


You will need the Gtk3 port of gtkglext: https://github.com/tdz/gtkglext
Last time i tried compiling it i needed to remove the documentation 
generation from the make files.



Anyway, I want to follow Mikes advice and use GLArea instead, so if
there is not a quick fix available, lets skip the problems with the
GtkGLExt library...



But, sadly enough, I did not get GLArea working, too. The documentation
https://developer.gnome.org/gtk3/stable/GtkGLArea.html
says, I have to connect my render function to the widget like this:
g_signal_connect (gl_area, "render", G_CALLBACK (render), NULL);
But, my compiler can't find the g_signal_connect method (and the GL
Methods...):
main.d(22): Error: undefined identifier 'g_signal_connect'
main.d(39): Error: undefined identifier 'glClearColor'
main.d(40): Error: undefined identifier 'glClear'

There might some include files (or import files, as you say in D)
missing, but I could not figure out, where to find them for D...

Could you tell me, where this g_signal_connect method can be found? And
what I have to include for the GL functionality? Simply "import
gtk.GLArea;" does not do the trick...


The signal functions can be found in the gobject.Signals module.

But you should use the GLArea.addOnCreateContext / addOnRender / 
addOnResize functions to attach a D delegate to the signal.
You will still need to link with the OpenGL libraries or use someting 
like Derelict.



Btw, is g_signal_connect a GTK method? I intend to use my program
platform independent, so if this is dependent on gnome, it would not be
good.


It's a GLib/GObject method, it's available on any platform GTK runs on.


Or is there any other way to get the GLArea working? I am used to the Qt
Libraries, where you create a QGLWidget and simply override the init and
render functions.


Thanks for reading this far, would be great if we could solve this
problem :D



--
Mike Wey


Re: Why using wrappers for D?

2016-10-03 Thread Mike Wey via Digitalmars-d-learn

On 10/03/2016 07:19 PM, Chalix wrote:

On Monday, 3 October 2016 at 13:51:28 UTC, Mike Parker wrote:

// wrapfoo.d
import foo;  // import the foo module from above

void myFunc(string s)
{
import std.string : toStringz;
my_func(s.toStringz());
}


Thank you for the example, Mike!

And thanks to all others who support me with their answers! I didn't
expect so much answers, the D community seems to be very helpful :)

But there still is one thing, which I don't get:

If I "import foo;" in my project, it will be compiled alongside. So
there is no need for an extra library. Same should be for wrapfoo.d. If
I "import wrapfoo;", I should just need the C-library "foo", and no
D-library "food" right?


To have a more practical example, I looked up the "header" of the GtkD
gtk/Main.d file. There are functions exactly like you described:


public static void init(ref string[] argv)
{
int argc = cast(int)argv.length;
char** outargv = Str.toStringzArray(argv);

gtk_init(, );

argv = Str.toStringArray(outargv, argc);
}


This function wraps the C-like gtk_init function to a D init function.
The gtk_init function is the function from the GTK+ library, which is
loaded in the gtkc/gtk.d file:

Linker.link(gtk_init, "gtk_init", LIBRARY.GTK);

Linker and link are defined in the gtkc/Loader.d

So, why is it not enough just to "import gtk.Main"? What kind of code is
inside the gtkd-3 library?


The gtkd-3 library contains for example the code you quoted above.

--
Mike Wey


Re: Parsing a UTF-16LE file line by line, BUG?

2017-01-06 Thread Mike Wey via Digitalmars-d-learn

On 01/06/2017 11:33 AM, pineapple wrote:

On Friday, 6 January 2017 at 06:24:12 UTC, rumbu wrote:


I'm not sure if this works quite as intended, but I was at least able
to produce a UTF-16 decode error rather than a UTF-8 decode error by
setting the file orientation before reading it.

import std.stdio;
import core.stdc.wchar_ : fwide;
void main(){
auto file = File("UTF-16LE encoded file.txt");
fwide(file.getFP(), 1);
foreach(line; file.byLine){
writeln(file.readln);
}
}


fwide is not implemented in Windows:
https://msdn.microsoft.com/en-us/library/aa985619.aspx


That's odd. It was on Windows 7 64-bit that I put together and tested
that example, and calling fwide definitely had an effect on program
behavior.


Are you compiling a 32bit binary? Because in that case you would be 
using the digital mars c runtime which might have an implementation for 
fwide.


--
Mike Wey


Re: Gui programing in D

2016-12-27 Thread Mike Wey via Digitalmars-d-learn

On 12/27/2016 01:47 PM, Samson Akomire wrote:

I am working with GTKD for GUI Application in D programing language. D
programing Language is truly wholesome in all definitions.I have a great
difficulty in setting widgets width and height. I will also appreciate
any direction to resources to learn GTKD.


These might be use full:

https://sites.google.com/site/gtkdtutorial/
http://gexperts.com/wp/category/gtk/
http://www.britseyeview.com/software/articles/gsgtkd101.html

--
Mike Wey


Re: Get name of current function

2017-04-23 Thread Mike Wey via Digitalmars-d-learn

On 04/23/2017 10:34 PM, Mike B Johnson wrote:

I'd like to get the symbolic name of the current function I'm in

void foo()
{
 writeln(thisFunc.stringof()); // prints foo
}

I need something short, elegant and doesn't require modifying 
preexisting code... I'm sure D has something along those lines?


The __FUNCTION__ keyword would give you the fully qualified name of the 
function.


http://dlang.org/spec/traits.html#specialkeywords

--
Mike Wey


Re: foreach for string[string]AA

2017-03-02 Thread Mike Wey via Digitalmars-d-learn

On 03/02/2017 09:09 AM, Anton Pastukhov wrote:

On Wednesday, 1 March 2017 at 19:26:23 UTC, Mike Wey wrote:

On 02/28/2017 07:16 PM, Anton Pastukhov wrote:

On Tuesday, 28 February 2017 at 17:16:43 UTC, Daniel Kozák wrote:

[...]


Thank you for the link, it was informative reading. It's a pity that
still there is no ordered AA at least as a library type.


I had the same use case in the generator for GtkD, i needed fast
lookup while iteration needed to preserve the insertion order. I opted
for storing nodes of a linked list in the build in AA.

The implementation[1] is currently LGPL to match the rest of the
library, but if anyone would find it useful it can be changed to
something else.

[1]
https://github.com/gtkd-developers/GtkD/blob/master/wrap/utils/LinkedHasMap.d



Interesting.
How this approach is compared to array of tuples performance-wise?


The biggest difference would be that you don't have to iterate the array 
to find a specific key. If you don't need to index by key i suspect a 
array of tuples is slightly faster to iterate.


--
Mike Wey


Re: foreach for string[string]AA

2017-03-01 Thread Mike Wey via Digitalmars-d-learn

On 02/28/2017 07:16 PM, Anton Pastukhov wrote:

On Tuesday, 28 February 2017 at 17:16:43 UTC, Daniel Kozák wrote:

V Tue, 28 Feb 2017 15:15:00 +
Anton Pastukhov via Digitalmars-d-learn
 napsáno:


I can't see the logic in AA foreach order. Consider this code:
...
Output:
three
two
one
four

I was sure output should be
one
two
three
four


https://forum.dlang.org/post/xbanhtkvrizyqjcib...@forum.dlang.org


Thank you for the link, it was informative reading. It's a pity that
still there is no ordered AA at least as a library type.


I had the same use case in the generator for GtkD, i needed fast lookup 
while iteration needed to preserve the insertion order. I opted for 
storing nodes of a linked list in the build in AA.


The implementation[1] is currently LGPL to match the rest of the 
library, but if anyone would find it useful it can be changed to 
something else.


[1] 
https://github.com/gtkd-developers/GtkD/blob/master/wrap/utils/LinkedHasMap.d


--
Mike Wey


Re: dmd can't build gtk x64

2017-07-29 Thread Mike Wey via Digitalmars-d-learn

On 29-07-17 01:57, FoxyBrown wrote:

On Friday, 28 July 2017 at 22:45:58 UTC, FoxyBrown wrote:
Error: can't run 'C:\VS\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64', 
check PATH


It is trying to run some x64.exe/com/bat file... why? What is this file?

simply doing dmd -m64 build.d

Works fine for x86.



I was able to get this to work by copying all the required lib's to the 
lib dir from the windows sdk(liburct.lib, shell32.lib) and copying 
link.exe to x64.


The program compiles, but when ran, I get the error

object.Exception@generated\gtkd\gtkd\Loader.d(125): Library load failed 
(libgdk-3-0.dll):  is not a valid Win32 application.


which I assume is due to the fact that I have x86 gtk installed(I think, 
as I thought I installed the dual package... can't seem to find x64 
gtk3+ standalone).


Yes, that error is probably because you only have the 32bit version of 
the GTK runtime installed.


On gtkd.org installers for both 32bit and 64bit are available, they can 
be installed side by side without any issues.


--
Mike Wey


Re: gtk arch issues

2017-07-31 Thread Mike Wey via Digitalmars-d-learn

On 31-07-17 19:16, Johnson Jones wrote:

how does one allow both gtk x86 and x64 to work side by side seamlessly?

I installed x64 first and it seems, because whatever is using the path 
to find the gtk runtime, it looks for that first even in x86 build.


Seems like gtkd's dll resolution is not very intelligent. While I could 
manually modify the path each time I switch archs, that seems pointless.


One of the problems in gtkd is that it has multiple places where it 
defines libgdk-3-0.dll.



I've tried modifying gdkD so that it uses versioning properly by 
searching for libgdk-3-0.dll and changing all to use an x86 or x64 when 
appropriate but that doesn't seem to help. Probably have to rebuild gtkD.


Anyways, doesn't seem to be a great solution ;/ Any ideas and maybe 
someone can add an issue to the github page to get this fixed? (I can't 
do it for a while because of other issues).




At startup GtkD searches the Path for "libgtk-3-0.dll", when it finds 
one it checks the architecture of the library. If it's the correct 
architecture it calls `SetDllDirectory` so that the directory with the 
correct architecture will be searched first by `LoadLibrary`.


If it's not the correct architecture it continues searching, if no 
library with the correct architecture is found, we rely on `LoadLibrary` 
to error out if the libraries are also not in the other locations 
searched by `LoadLibrary`.


--
Mike Wey


Re: gtk arch issues

2017-07-31 Thread Mike Wey via Digitalmars-d-learn

On 31-07-17 19:53, Johnson Jones wrote:

Also, why is gtkD even using gtksharp? That's for mono and .net!


We don't. only the (C) Gtk runtime is needed.

Where did you see gtksharp?

--
Mike Wey


Re: Bug in gtkd?

2017-08-03 Thread Mike Wey via Digitalmars-d-learn

On 03-08-17 05:00, Johnson Jones wrote:

On Wednesday, 2 August 2017 at 14:51:45 UTC, Mike Wey wrote:

On 02-08-17 08:04, Johnson Jones wrote:
Ok, Using msys I was able to get glade 3.20 running. Maybe that will 
fix everything.


Great, unfortunately "Use msys2" seems to be the official way to 
install anything GTK related on windows.


... Also, I cannot seem to load a jpg using an imageview

(test.exe:1628): Gtk-WARNING **: Could not load image 
'a.jpg': Couldn't recognize the image file format for file 'a.jpg'


Just a normal jpg. Tried a bmp, same thing. It shows fine in glade itself.



It looks like the pixbuf loaders are missing from the installer.

--
Mike Wey


Re: gtk arch issues

2017-08-01 Thread Mike Wey via Digitalmars-d-learn

On 01-08-17 22:16, Johnson Jones wrote:

nvm, the file exists.  Why it is not being found is unknown.

I did some stuff and it says it is not a valid win32, this is using that 
gtk3 runtime I linked to... says it's x64 version but probably x86.


Would be nice if the error message printed the full path of what was 
being loaded so it's quicker to diagnose.


Seems there is a


> ... code ...


which is used, could I just hijack this to set the correct path based on 
what version it is compiled under? Would be the easiest thing, at least 
as a temporary workaround.




You renamed the gtk DLL's, i assume you simply renamed them, but to get 
things working with different names you would need to build GTK from 
source, and apply the appropriate patches to GTK and its make files.


If you would use a dependency walker on libgtk-3-0.dll you can see that 
it depends on basically all the other dll's in the directory, and by 
renaming them they can no longer be found. For libraries that are in 
both GTK 3 and GTK 2 it might find the libraries distributed with 
gtksharp but that would also fail because of the version difference.


Printing the full path of the library in the error would only only be 
possible if we call LoadLibrary with the full path. It's been a while 
since i implemented the architecture check but if i remember correctly 
there were some issues with that. Otherwise it might be loaded from one 
of the other directories LoadLibrary searches, and then the printed path 
would be wrong, making things even worse.


And yes you could hard code the path that is passed to SetDllDirectory 
as a work around, but the dll's will need to have there proper names.


--
Mike Wey


Re: Bug in gtkd?

2017-08-01 Thread Mike Wey via Digitalmars-d-learn

On 01-08-17 21:44, Johnson Jones wrote:

On Tuesday, 1 August 2017 at 15:20:08 UTC, Mike Wey wrote:

On 01-08-17 05:53, Johnson Jones wrote:




GtkD is currently based on GTK 3 the properties it complains about 
were removed in GTK 3.0.


Which version of glade are you using?


The latest: Glade 3.8.5


Could you check File -> Properties and see what is set as the runtime 
version? It should be at least 3.0 so it doesn't use things that were 
removed.


--
Mike Wey


Re: Bug in gtkd?

2017-08-03 Thread Mike Wey via Digitalmars-d-learn

On 03-08-17 22:40, Johnson Jones wrote:
Ok, so, I linked the gtk to the msys gtk that I installed before when 
trying to get glade to work and it worked!


seems that msys is much more up to date than anything else as it just 
works(I need to remember than in the future).


The problem I see is this:

When I get ready to release my app to the public, I can't expect them to 
all have to install msys and build.


msys seems to clump everything together and I don't know what files I 
need to extract to be able to bundle everything together.


Any ideas how to solve that problem? At least now I can move ahead and 
actually make some progress on my app.


Would still be nice to get the x86 vs x64 issue resolved so I don't have 
to keep switching between the two for testing purposes. Since Visual D 
was just patched to handle x64 BP's I guess I can stay with that for now.




I'll try to build and test some new installers tomorrow that will 
include the loaders.


--
Mike Wey


Re: gtkD window centering message up and no app on taskbar

2017-08-10 Thread Mike Wey via Digitalmars-d-learn

On 09-08-17 23:54, Johnson Jones wrote:

Ok, I added

 import core.sys.windows.winuser;
 __gshared extern(C) core.sys.windows.winuser.HANDLE 
function(GdkWindow*) gdk_win32_window_get_handle;
 Linker.link(gdk_win32_window_get_handle, 
"gdk_win32_window_get_handle", LIBRARY_GDK);


to GtkD\generated\gtkd\gdk\c\functions.d

and rebuilt and it seems to work. Hopefully that is the right place so 
in the future when I replace GtkD with it won't show up as a bug in my 
code somewhere. I assume master will be updated with this at some point?


That would be the correct place. If it is added to GtkD it won't be in 
functions.d, which is generated. It would be something like: gdk.c.win32.


--
Mike Wey


Re: Fix gtkD api display

2017-08-10 Thread Mike Wey via Digitalmars-d-learn

On 10-08-17 15:57, Adam D. Ruppe wrote:

On Saturday, 5 August 2017 at 14:02:09 UTC, Mike Wey wrote:
One issue is the shear size of the generated documentation, though the 
current version of ddox no longer generates a ton of unused files 
bringing the size down from 15-20GB to a mere 2GB.


what?! I'm not actually sure how much gtk alone takes, but my entire doc 
folder is 4 GB, including a good chunk of the dub repo, phobos, 
druntime, my stuff, search indexes, archives, etc.


I guess it is possible the gtkd is 2 GB of that, but at least it isn't 20.


The problem was that there are a few large classes at the start of the 
hierarchy, and with the old version of ddox the function pages would not 
only be generated for the base class, but also for all the derived classes.


So when you have a base class with 264 functions, and you have 385 
classes that are directly or indirectly derived from it.
Things start to add up, That is 101_640 html pages just for this one 
case, and there are more.


Luckily this is fixed, especially because ddox never actually linked to 
these pages.


The need to go trough the empty module page when browsing the 
documentation. For a lot / most? functions the complete documentation 
is in the overview defeating the purpose of the one page per artifact.


If you guys are interested, I can do a custom adrdox for gtk that:

* reads more of the gtk syntax 
https://developer.gnome.org/gtk-doc-manual/stable/documenting_syntax.html.en 



* recognizes the one-item-per-module pattern and skips the empty pages

* has a style more like https://gtkd.org/index.html

* Maybe a few other little things?


That would be great.


And im not a big fan of the one page per artifact style of documentation.


Oh, it is so much better in a lot of ways.


I don't use the documentation myself so this isn't really a problem.

--
Mike Wey


Re: GtkD on android?

2017-07-26 Thread Mike Wey via Digitalmars-d-learn

On 25-07-17 20:06, Joakim wrote:

On Saturday, 22 July 2017 at 18:59:44 UTC, FoxyBrown wrote:
With LDC's new ability to do android/arm, we are missing the ability 
to do GUI's? Can any of the current D solutions work such as GtkD or 
QtD? I'm looking for something somewhat lightweight, easy to use(I 
find GtkD a bit funky but it does seem to work and is relatively easy 
once one gets through the basics). I think having a GUI builder is 
crucial though as it makes it so much easier in the long run. Glade is 
a bit funky but functional and works.


Ideally I'd like to be able to make portable apps that just work 
across the board(mac, linux, windows, android) without much hassle.


Mike said maybe later, when I asked him in January:

http://forum.dlang.org/post/o4rq0i$dur$1...@digitalmars.com

In the meantime, you can try DlangUI, as Seb pointed out, but I get the 
impression it's not touch-optimized, just like Gtk.


And if you want something lightweight, the complete GTK stack is 
probably not what you are looking for.


--
Mike Wey


Re: gtkD load images

2017-08-05 Thread Mike Wey via Digitalmars-d-learn

On 05-08-17 15:23, Johnson Jones wrote:

On Saturday, 5 August 2017 at 12:51:13 UTC, Mike Wey wrote:

On 03-08-17 21:56, Johnson Jones wrote:

If I do something like

import gdkpixbuf.Pixbuf;
Pixbuf.newFromResource("C:\\a.jpg");


There are two issues here, you need to properly escape the slash: 
"C:a.jpg".


And a.jpg is not a resource file, so you would use the Pixbuf 
constuctor to load an image file.


```
Pixbuf p = new Pixbuf(r"C:\\a.jpg");
```


Thanks. Why do I need 4 slashes? Is that standard with gtk because 
strings are interpreted twice or something? Seemed to work though.





Nothing specific to GTK but in D and other programing languages the \ is 
used as an escape character, so you can use special characters in your 
sting like `\n` for a newline. But this means you will need to use \\ to 
get an literal back slash.


https://dlang.org/spec/lex.html#double_quoted_strings

You can also use an wysiwyg string by using `r"` at the start so what 
you type is what you get.


https://dlang.org/spec/lex.html#wysiwyg

--
Mike Wey


Re: gtkD window centering message up and no app on taskbar

2017-08-05 Thread Mike Wey via Digitalmars-d-learn

On 05-08-17 20:14, Johnson Jones wrote:
When trying to center the window. If one uses ALWAYS_CENTERED any 
resizing of the window is totally busted. CENTER also does not work. 
move(0,0) seems to not be relative to the main display. I'd basically 
like to center the window on the main display or at least be able to set 
coordinates properly. Windows sets (0,0) to be the lower left corner of 
the main display I believe. What happens is that the gtk window, when 
using 0,0 actually is like -1000,0 or something in windows coordinates 
and ends up on my secondary monitor.


When the app starts there's no taskbar icon. Luckily I still have the 
console shown but Eventually I'll need the taskbar. I'm not setting 
skipTaskBarHint, but I have tried both true and false without any 
difference.




gtk.Widget.translateCoordinates or gtk.Fixed could be useful for 
positioning the widgets.


Windows will only show the taskbar icon if you are not running the 
application from the console.


--
Mike Wey


Re: gtkD load images

2017-08-06 Thread Mike Wey via Digitalmars-d-learn

On 05-08-17 22:59, ag0aep6g wrote:

On 08/05/2017 10:30 PM, Mike Wey wrote:

On 05-08-17 15:23, Johnson Jones wrote:

On Saturday, 5 August 2017 at 12:51:13 UTC, Mike Wey wrote:

[...]
There are two issues here, you need to properly escape the slash: 
"C:a.jpg".

[...]

```
Pixbuf p = new Pixbuf(r"C:\\a.jpg");
```


Thanks. Why do I need 4 slashes? Is that standard with gtk because 
strings are interpreted twice or something? Seemed to work though.





Nothing specific to GTK but in D and other programing languages the \ 
is used as an escape character, so you can use special characters in 
your sting like `\n` for a newline. But this means you will need to 
use \\ to get an literal back slash.


I think you missed the point of the question.

In the end, the path should contain only one backslash. But with 
`"C:a.jpg"` and `r"C:\\a.jpg"` you get two. Why do you need two? 
Does the library do another round of escape sequence handling?


That's me not being a Windows user shining trough, i somehow got it in 
my head that you needed two backslashes after the C:.


But indeed just "C:\\a.jpg" or r"C:\a.jpg" will work as expected.

--
Mike Wey


Re: gtkD: events being triggered twice

2017-08-06 Thread Mike Wey via Digitalmars-d-learn

On 06-08-17 03:25, Johnson Jones wrote:

GtkEventBox - Enter
GtkEventBox - Enter
Down
GtkEventBox - Leave
Up
GtkEventBox - Leave
GtkEventBox - Leave

That is when I move the mouse over the event box then click then move 
out out then release.


I would expect

Enter Down Leave Up

The fact that enter and leave are not paired equally is a problem. Can 
be worked around but seems like it would be a bug.


the code is simply


ebox.addOnEnterNotify(delegate(Event e, Widget w)
{
writeln(w.getName(), " - ", "Enter");
return true;});

ebox.addOnLeaveNotify((Event e, Widget w)
{writeln(w.getName(), " - ", "Leave");
return true;
});


Do you have an more complete example that i could test.

--
Mike Wey


Re: gtkD window centering message up and no app on taskbar

2017-08-08 Thread Mike Wey via Digitalmars-d-learn

On 07-08-17 23:52, Johnson Jones wrote:

On Monday, 7 August 2017 at 20:57:08 UTC, Mike Wey wrote:

On 07-08-17 22:46, Johnson Jones wrote:

[...]


This appears to be a GTK issue, a work around might be to get the 
Window handle from gtk and use the Windows API to set the taskbar 
visibility.




Yeah, I was thinking about that but haven't yet figured out how to find 
the window handle ;/


To get the Window handle you could use this for 32bit Windows:

```
import gtk.c.functions;

// Danger, Will Robinson!

HANDLE handle = 
*(cast(HANDLE*)((cast(void*)gtk_widget_get_window(w.getWidgetStruct()))+4));



```
Where w is your application window, i used this in the map event signal 
so the handle is actually set. To complicate things there is a race 
condition in gdk some ware so at random the handle isn't valid.



I haven't been able to set the taskbar icon with is tough.

The two attempts:

-Setting the parent window to null as windows with no parent should have 
an taskbar icon:


```
ShowWindow(handle, SW_HIDE);
SetParent(handle, null);
ShowWindow(handle, SW_SHOW);
```

Or set the extended window style to WS_EX_APPWINDOW as that should fore 
an taskbar icon according to msdn.


```
ShowWindow(handle, SW_HIDE);
SetWindowLong(handle, GWL_EXSTYLE, WS_EX_APPWINDOW);
ShowWindow(handle, SW_SHOW);
```

--
Mike Wey


Re: gtk arch issues

2017-08-01 Thread Mike Wey via Digitalmars-d-learn

On 01-08-17 01:37, Johnson Jones wrote:


So, the question is, is this a gtkd problem or a gtk problem? In either 
case, what's the way to get them both to work. Do you guys actually test 
out both versions installed on the same system?




Gtk also loads some of it's own libraries at start up with GModule / 
LoadLibrary. So with the library names changed GTK might be loading the 
Gtk 2 libraries installed with gtksharp instead of the correct ones.


--
Mike Wey


Re: Bug in gtkd?

2017-08-01 Thread Mike Wey via Digitalmars-d-learn

On 01-08-17 05:53, Johnson Jones wrote:




GtkD is currently based on GTK 3 the properties it complains about were 
removed in GTK 3.0.


Which version of glade are you using?

--
Mike Wey


Re: gtk arch issues(fixed)

2017-08-02 Thread Mike Wey via Digitalmars-d-learn

On 01-08-17 22:50, Johnson Jones wrote:


So, the problem is simple(but unfortunately a lot of wasted time). gtkD 
needs to be updated to work well with x64 and x86. I think all one has 
to do is be able to specify which path of gtk to use rather than have it 
search the windows path.


While I could manually rename the dirs or create a script that does so, 
that seems harsh.  It would be nice if we could simply set a path in D 
that gtkD attempts to use as a base path to load the dlls.


That way, we can completely avoid windows path if necessary and simply 
use d's version to set the correct path to the correct dlls.


(or modified gtkD to work properly with both versions installed instead 
of crapping out on the first instance of the dll it comes across if it 
is not correct... I'd actually prefer both ways implemented though so 
gtkD works better on the end user's end but I have more control when 
developing).


I currently have 3.22 32bit 3.22 64bit and 2.14 installed side by side 
without any issues. I guess i'll have to try this on a fresh install of 
Windows in case i forgot about some changes i may have made to the system.


--
Mike Wey


Re: custom drawing with gktd?

2017-08-02 Thread Mike Wey via Digitalmars-d-learn

On 02-08-17 08:35, Johnson Jones wrote:
I have a need to draw custom objects with gtkD, is this possible? I see 
that with drawing area one can use cario, and it seems that gtkD 
supports this. I'd rather use openGL if possible. I see there is a 
gtkDGL but no reference to how to use it.


I need pretty simple drawing stuff... lines, icons, maybe images(which, 
I guess, I'll have to use an external lib to load the images).


Thanks.


For openGL it would be better to use gtk.GLArea, which is included in 
gtk since 3.16. You can use the GLCore demo as an example:


https://github.com/gtkd-developers/GtkD/blob/master/demos/gl/core/CoreGL.d

GtkDGL wraps gtkglext3 which is currently not maintained, and no longer 
has any binaries available.


--
Mike Wey


Re: Bug in gtkd?

2017-08-02 Thread Mike Wey via Digitalmars-d-learn

On 02-08-17 08:04, Johnson Jones wrote:
Ok, Using msys I was able to get glade 3.20 running. Maybe that will fix 
everything.


Great, unfortunately "Use msys2" seems to be the official way to install 
anything GTK related on windows.


--
Mike Wey


Re: gtkD: events being triggered twice

2017-08-07 Thread Mike Wey via Digitalmars-d-learn

On 06-08-17 21:27, FoxyBrown wrote:

On Sunday, 6 August 2017 at 18:26:20 UTC, Mike Wey wrote:

On 06-08-17 16:58, FoxyBrown wrote:
I don't really(my code is a bit more complex) but basically all it 
boils down to is a UI with some nested widgets (an overlay, an box, 
and a box and one contains the eventbox which I added those callbacks 
on.


I think that something like

https://github.com/gtkd-developers/GtkD/blob/master/demos/gtkD/TestWindow/TestWindow.d 




should probably work by just adding an eventbox somewhere and adding 
that code above.


If it doesn't exhibit the same behavior then it has something to do 
with my project and I could try to reduce it to a minimal example.


To test i put the label that is on the label page in an event box but 
that doesn't reproduce the issue. I get just a single event on enter 
and a single event on leave.


Ok, I will try to work on figuring out what is going and and potentially 
reduce to a test case. It might be on my end. I'm pretty sure I'm not 
adding


You might try a separator though in the event box and might try to add 
it handling various events(maybe even other events for the event box)... 
things related to the mouse.


Here's the glade code for the event box I'm using

   
 5
 True
 False
 True
 
   
 5
 True
 False
 False
 
 vertical
   
 
   


Try that when you get some time and see if that changes anything. If it 
doesn't then it's surely in my code or in the gtk version I'm 
using(still using msys, I'll update to what you released to see if that 
fixes it). At least we can narrow it down a little...




Also seems to be working properly with a Separator.

--
Mike Wey


Re: gtkD window centering message up and no app on taskbar

2017-08-07 Thread Mike Wey via Digitalmars-d-learn

On 07-08-17 22:46, Johnson Jones wrote:

On Saturday, 5 August 2017 at 20:56:10 UTC, Mike Wey wrote:


Windows will only show the taskbar icon if you are not running the 
application from the console.


Now in x64 it is showing, not in x86. So, not sure what's going on but 
at least it is showing. I was in a windows console and added a main.def 
but dmd says that it's not compatible with x64 or something:


main.def(1) : warning LNK4017: EXETYPE statement not supported for the 
target platform; ignored
main.def(4) : warning LNK4017: SUBSYSTEM statement not supported for the 
target platform; ignored


but adding that file seemed to allow the icon like you said. I'm not 
doing anything different for x86 except switching gtk versions... but 
maybe there is a flag or setting somewhere that is causing the problem.


and, in the x64 version I get both the console and gtk app task bar 
icons... which is what I originally wanted and expected.




This appears to be a GTK issue, a work around might be to get the Window 
handle from gtk and use the Windows API to set the taskbar visibility.


Interestingly the icon shows up after restarting explorer.exe.

For 64bit apps dmd uses the microsoft linker, so you probably have to 
use different flags to set the subsystem.


--
Mike Wey


Re: gtkD window centering message up and no app on taskbar

2017-08-09 Thread Mike Wey via Digitalmars-d-learn

On 09-08-17 01:00, Johnson Jones wrote:

But, finally, this does seem to work:


// Fixup missing taskbar icon
void SetTaskBarIcon(gtk.ApplicationWindow window)
{

 version(Windows)
 version(X86)
 {
 import core.sys.windows.winuser, gdk.Window;
 auto handle = 
cast(core.sys.windows.winuser.HANDLE)gdk_win32_window_get_handle(gtk.gtk_widget_get_window(window.getWidgetStruct())); 


 ShowWindow(handle, SW_HIDE);
//SetParent(handle, null);
 SetWindowLong(handle, GWL_EXSTYLE, GetWindowLong(handle, 
GWL_EXSTYLE) | WS_EX_APPWINDOW);

 ShowWindow(handle, SW_SHOW);
 }
 return;
}

Of course, along with this:


MainWindow.addOnShow((Widget widget) { MainWindow.SetTaskBarIcon(); });


`gdk_win32_window_get_handle` I spend way to much time looking for a 
function like this, before giving up and doing the pointer arithmetic.


This should do it for getting the function:
```
import gtkd.Loader;
import gdk.c.functions; //Still at gtkc.gdk for 3.6.

__gshared extern(C) HANDLE function(GdkWindow*) gdk_win32_window_get_handle;
Linker.link(gdk_win32_window_get_handle, "gdk_win32_window_get_handle", 
LIBRARY_GDK);

```

I did find out that gdk set the Desktop window as the parent window and 
doesn't set `WS_EX_APPWINDOW` i should try if setting it for top level 
windows would fix this from within gdk.


--
Mike Wey


Re: gtkD load images

2017-08-05 Thread Mike Wey via Digitalmars-d-learn

On 03-08-17 21:56, Johnson Jones wrote:

If I do something like

import gdkpixbuf.Pixbuf;
Pixbuf.newFromResource("C:\\a.jpg");


There are two issues here, you need to properly escape the slash: 
"C:a.jpg".


And a.jpg is not a resource file, so you would use the Pixbuf constuctor 
to load an image file.


```
Pixbuf p = new Pixbuf(r"C:\\a.jpg");
```

--
Mike Wey


Re: GtkD custom theme on Windows

2017-08-05 Thread Mike Wey via Digitalmars-d-learn

On 04-08-17 05:06, Andres Clari wrote:
I've made a linux program with GtkD, and so far, it's been pretty 
awesome, however I'm thinking about porting it to Windows also, but the 
Adwaita theme is too fugly, and cringy, so I'd want to use a compatible 
theme, which is supposed to be doable.


What would be the way to go to make a GtkD app use a custom GTK theme in 
Windows?
I tried this in the past, but never succeeded following documentation 
found online.



I didn't try it myself but it should be something like this:

-Download a theme from gnome-look.org
-Extract the theme to: C:\\Program Files\Gtk-Runtime\share\themes
-Edit C:\\Program Files\Gtk-Runtime\etc\gtk-3.0\settings.ini and add:

```
gtk-theme-name = Name_of_Theme
```

--
Mike Wey


Re: Fix gtkD api display

2017-08-05 Thread Mike Wey via Digitalmars-d-learn

On 04-08-17 17:24, Gerald wrote:

On Friday, 4 August 2017 at 15:08:27 UTC, Mike Wey wrote:
Improving the documentation is something i want to do but there are 
always some more important things to do. Like the Questions/Issues you 
posted earlier.


So unless somebody volunteers it won't happen anytime soon.


Mike I had contributed the makeddox.sh script awhile ago, it generates 
much nicer documentation then candydocs in my IHMO and includes a nice 
search box. If there is something lacking in it that needs to be 
improved before it can be used let me know and I'll do the work.


The only issue with it that I am aware of is you need to manually copy 
the public ddox css into the generated folder. I didn't see an easy way 
to determine it's location automatically.


One issue is the shear size of the generated documentation, though the 
current version of ddox no longer generates a ton of unused files 
bringing the size down from 15-20GB to a mere 2GB.


So it has at leased become manageable to host it on the VPS that hosts 
gtkd.org.


Now remains figuring out setting up the proper redirects on the server, 
and a few personal preferences about ddox:


The need to go trough the empty module page when browsing the 
documentation. For a lot / most? functions the complete documentation is 
in the overview defeating the purpose of the one page per artifact.

And im not a big fan of the one page per artifact style of documentation.

--
Mike Wey


Re: Bug in gtkd?

2017-08-05 Thread Mike Wey via Digitalmars-d-learn

On 03-08-17 23:11, Johnson Jones wrote:

On Thursday, 3 August 2017 at 21:00:17 UTC, Mike Wey wrote:

On 03-08-17 22:40, Johnson Jones wrote:
Ok, so, I linked the gtk to the msys gtk that I installed before when 
trying to get glade to work and it worked!


seems that msys is much more up to date than anything else as it just 
works(I need to remember than in the future).


The problem I see is this:

When I get ready to release my app to the public, I can't expect them 
to all have to install msys and build.


msys seems to clump everything together and I don't know what files I 
need to extract to be able to bundle everything together.


Any ideas how to solve that problem? At least now I can move ahead 
and actually make some progress on my app.


Would still be nice to get the x86 vs x64 issue resolved so I don't 
have to keep switching between the two for testing purposes. Since 
Visual D was just patched to handle x64 BP's I guess I can stay with 
that for now.




I'll try to build and test some new installers tomorrow that will 
include the loaders.


Thanks. Could you take a look at the loading image thread I started when 
you get time? I can't seem to get an image to load even though it seems 
straight forward.


These are the pixbufs I'm using

mingw32/mingw-w64-i686-gdk-pixbuf2 2.36.6-2 [installed]
 An image loading library (mingw-w64)
mingw64/mingw-w64-x86_64-gdk-pixbuf2 2.36.6-2 [installed]
 An image loading library (mingw-w64)

in x64 it crashes completely without an exception though... which is why 
I want an easy way to switch between the two architectures... since x64 
seems to be more unstable than x86 but sometimes it's the reverse, and 
ultimately I'll want to release in x64.


Also, do I ever need to rebuild gdk when changing gtk installations? 
Does it ever grab anything from them at compile time or is it all at 
runtime?


The new installers are available: https://gtkd.org/Downloads/runtime/

You don't need to rebuild GtkD when changing GTK installations, it does 
it all at runtime.


--
Mike Wey


Re: Fix gtkD api display

2017-08-04 Thread Mike Wey via Digitalmars-d-learn

On 04-08-17 03:51, Johnson Jones wrote:

https://api.gtkd.org

It is difficult to navigate.

1. clicking the documentation on the main site takes it to the 
gtk.AboutDialog api. That is all it shows, I was confused at first, as 
I'm sure most people would be.


2. The packages list lists all the packages, but all the sub elements 
are expanded, making it time consuming to hunt down anything specific. 
Initially collapsing them and adding a search box would be nice.


3. When clicking on any packages it reloads the page and shows only the 
package in the first tab. This requires one to then go back to packages 
and hunt for something else again. Because the position of the scroll is 
not saved, one has to scroll down through the entire list.


It would be better, I think, if it was one single tab all in a single 
hierarchy that never reloaded the page so that it is easier to navigate 
quickly.


e.g.,

instead of

Package
atk
   atk.ActionIF
   atk.Action
   ...

we have

atk
   atk.ActionIF
  GetActionStruct
  GetStruct
  ...
   atk.Action
  ...
...


and so effectually combining both tabs. It should solve the issues that 
the current way has without really causing any problems. Everything 
should be collapsed by default and since no reloading of the page should 
occur(which might require having the api descriptions in a separate 
frame that is loaded separately on package changes to avoid reloading 
the tree view which will recollapse everything).


It will make navigating the gtkD api much more fun ;)


Improving the documentation is something i want to do but there are 
always some more important things to do. Like the Questions/Issues you 
posted earlier.


So unless somebody volunteers it won't happen anytime soon.

--
Mike Wey


Re: gtkD: events being triggered twice

2017-08-06 Thread Mike Wey via Digitalmars-d-learn

On 06-08-17 16:58, FoxyBrown wrote:
I don't really(my code is a bit more complex) but basically all it boils 
down to is a UI with some nested widgets (an overlay, an box, and a box 
and one contains the eventbox which I added those callbacks on.


I think that something like

https://github.com/gtkd-developers/GtkD/blob/master/demos/gtkD/TestWindow/TestWindow.d 



should probably work by just adding an eventbox somewhere and adding 
that code above.


If it doesn't exhibit the same behavior then it has something to do with 
my project and I could try to reduce it to a minimal example.


To test i put the label that is on the label page in an event box but 
that doesn't reproduce the issue. I get just a single event on enter and 
a single event on leave.


--
Mike Wey


Re: GtkD: How to respond to cell edit's?

2017-08-18 Thread Mike Wey via Digitalmars-d-learn

On 18-08-17 02:30, Johnson Jones wrote:

On Friday, 18 August 2017 at 00:27:05 UTC, Johnson Jones wrote:
I should also mention that when I use an ID to do what I want(again, 
something I don't want to do), I also need to get the column that was 
edited. This is because I'm using one delegate for all the edits.



auto cb = delegate(string index, string text, CellRendererText r)
{
// How to get the column of that we are editing? An index would be 
fine.

writeln(index, " - ", text);
};

RT1.addOnEdited(cb);
RT2.addOnEdited(cb);
RT2.addOnEdited(cb);

Looks like I might have to use separate edit handlers ;/

I wonder if I can somehow template it so I can do something like


RT1.addOnEdited(cb!1);
RT2.addOnEdited(cb!2);
RT2.addOnEdited(cb!3);

without having to write a bunch of code to make it happen. Maybe there 
is a library function that can help?


Obvious it is easy when you have ID's, but this is meant for the 
original case where I'm not using ID's.


A far as i can tell using id's is the only option.

You can use a templated function as a delegate:

```
void cb(int column)(string index, string text, CellRendererText r)
{
writeln(column, " - ", index, " - ", text);
}

RT1.addOnEdited(!1);
RT2.addOnEdited(!2);
RT2.addOnEdited(!3);
```

--
Mike Wey


Re: Module Info error

2017-08-19 Thread Mike Wey via Digitalmars-d-learn

On 19-08-17 04:07, Johnson Jones wrote:

Still getting this!

What I don't understand is why I can import certain libraries and they 
compile fine while others don't!


So, moduleInfo is a "function" per module that is created at 
compilation, right?


If one doesn't compile the module then the error results, just like 
standard extern functions. When I don't include the file in the project, 
it doesn't get compiled, even though it gets "imported"? Why? Why can't 
D just know, hey, module X imports module Y, module Y needs to be 
compiled to add moduleInfo?




For example, I am trying to get ffmpeg to work. I downloaded from

https://github.com/complistic-gaff/ffmpeg-d

extracted, put that path in my includes(sc.ini). created a module to 
import the standard modules, tried to compile my project and I get a 
bunch of ModuleInfo errors relating to the imports I added.


I use GtkD exactly the same, yet no errors.

Now, the only difference is that I import the gtkD.lib. I'm assuming 
that all the moduleInfo's of the 1000+ gtk files are in that lib and so 
That is the reason I don't have the compile them all, is that correct?


If so, how can I generate such a lib of moduleInfo's recursively for a 
directory so I can pick up all the files and just import it once?


ffmpeg doesn't require compiling but I don't wanna have to include ever 
file in to my project just to be able to get it to work because of the 
moduleInfo's are missing.


Looking at the build.d for gtkD, it looks like it builds a list of all 
the files to compile and does it recursively.


I imagine it can be modified for ffmpeg too to create a utility to solve 
this problem. Dmd should have a mode to do this automatically, it's 
quite an annoying problem ;/


You need to either compile ffmpeg-d in to a library and include it when 
you are building your application, or pass all the ffmpeg-d source files 
to the compiler.


It looks like ffmpeg-d only has a dub.json file for building so you will 
need to use dub to build it eg: `dub build` from the root of the project.


--
Mike Wey


Re: GtkD on android

2017-08-19 Thread Mike Wey via Digitalmars-d-learn

On 19-08-17 01:55, Johnson wrote:
Hey Mike, have you put in thought or effort in to getting GtkD working 
on android?



e.g.,

https://github.com/eugals/GTKAndroid/wiki/Building

If I get around to it and no one has beating me before, I will try to 
compile something like the above and get the gtk libs required then use 
the new ldc to create an app for android.




No, but it would be interesting to see if you can get things working.

--
Mike Wey


Re: GtkD: New widget

2017-08-22 Thread Mike Wey via Digitalmars-d-learn

On 22-08-17 01:38, Johnson wrote:

On Monday, 21 August 2017 at 20:54:04 UTC, Mike Wey wrote:

On 21-08-17 03:45, Johnson Jones wrote:

[...]


If you want gtk to know about the functions you override you could use 
gtkd.Implement.ImplementCLass.


[...]


Thanks, I'll test it out when I get a chance. I was able to work around 
the issue for now but I imagine I'll need the ability to implement my 
own container in the future.


BTW, when I try to create a value I get an error about opCall

Value handleSize = new Value(0);

vs

Value handleSize = Value(0);

I'd rather not create a value on the heap when I only need it locally.

Could you add a way to create the value with the right type to Value?

Even static constructors would work(probably could templatize it).

Although, I'm not sure how much it matters since value itself seems to 
allocate on the heap ;/


 public this()
 {
 this(new GValue);
 }

But it might help reduce some memory waste.



`Value` is a class so you will need to use `new`.

--
Mike Wey


Re: GStreamer issues.

2017-08-22 Thread Mike Wey via Digitalmars-d-learn

On 22-08-17 02:13, Johnson wrote:

I can't get the example to work(although slightly modified).

The installed version of GStreamer is 1.12.2
The file is: D:\temp\test.ogg
Loading
Setting to PLAYING.
Running.
XError: Could not demultiplex stream. dbug: gstoggdemux.c(4418): 
gst_ogg_demux_find_chains (): 
/GstPipeline:audio-player/GstOggDemux:ogg-parser:

can't get first chain

Actually I was getting a much worse error before ;/ I can't remember it 
now.



The installed version of GStreamer is 1.12.2
The file is: D:\temp\test2.wav
Loading
Setting to PLAYING.
Running.
XError: Internal data stream error. dbug: gstwavparse.c(2249): 
gst_wavparse_loop (): /GstPipeline:audio-player/GstWavParse:wav-parser:

streaming stopped, reason not-linked (-1)

Basically all I did was change the sink:

 sink = ElementFactory.make("autoaudiosink", "auto-output");

So it I could get past the error about alsa. I think the last name 
doesn't matter?


I downloaded the gstreamer binaries from their site, had some issues 
with a few of the dll's complaining about gxx errors, I removed 
them(h264, soundtouch, tag).



For the wav I changed
 //parser = ElementFactory.make("oggdemux", "ogg-parser");
 //decoder = ElementFactory.make("vorbisdec", "vorbis-decoder");
 parser = ElementFactory.make("wavparse", "wav-parser");
 decoder = ElementFactory.make("audioconvert", "wav-decoder");


which, is all i could find on line, I don't know if it's right at all.


Ultimately I want to be able to read somewhat arbitrary audio 
formats(most common at least), get the raw channel data(samples for each 
channel), play/pause/stop with good accuracy(no latency or low 
latency(<20ms), possibly do some pitch shifting and basic mixing(EQ, 
limiting, panning, etc), and eventually play some videos.


Is GstreamerD going to be useful for this or so I look in to using 
ffmpeg directly and do some of the stuff(e.g., eq) myself?


Thanks.


The Gstreamer demo should use an `playbin` instead of explicitly setting 
the pipeline, Like this: 
https://github.com/gtkd-developers/GtkD/blob/master/demos/gstreamer/helloworld/gstreamer_helloworld.d


This way gstreamer will detect the file type, i don't know if it helps 
with the errors.


--
Mike Wey


Re: GtkD: Build script

2017-08-20 Thread Mike Wey via Digitalmars-d-learn

On 20-08-17 20:41, Johnson Jones wrote:

I guess I see why now you did what you did! ;)

.LIB pagesize exceeds 512

https://issues.dlang.org/show_bug.cgi?id=15418

Wanna take bets on how many *years* this takes to get fixed?!?


That one happens when GtkD is build with debug symbols.

The main library is build by package because optlink or omf doesn't 
support more that 32767 symbols in one object file, and i hit that limit.


--
Mike Wey


Re: gtkd build fail on windows with dmd 2.074.0

2017-05-28 Thread Mike Wey via Digitalmars-d-learn

On 05/28/2017 03:20 PM, Mike Wey wrote:

On 05/27/2017 11:42 PM, greatsam4sure wrote:

rdmd Build.d fail on windows with dmd 2.074.0,dmd 2.073.0.
it says std.file.FileException@std\file.d(814)gtkd2.obj:The system 
cannot find the file specifield.


I have to use dmd 2.071.0 to build it

I will appreciate your help

sorry for the mistake


Fixed in commit: 
https://github.com/gtkd-developers/GtkD/commit/f396481d8d5fe52a2e58b0818494844d672b1c77 



The next commit also updates the build script to actually show the error 
from dmd, rather then blindly continuing with the next step.




The release branch seems to give the same error, because dmd tries to 
generate an object file with to many symbols. I should probably break 
the build up into even smaller chunks, i don't know why master is not 
affected.


--
Mike Wey


Re: gtkd build fail on windows with dmd 2.074.0

2017-05-28 Thread Mike Wey via Digitalmars-d-learn

On 05/27/2017 11:42 PM, greatsam4sure wrote:

rdmd Build.d fail on windows with dmd 2.074.0,dmd 2.073.0.
it says std.file.FileException@std\file.d(814)gtkd2.obj:The system 
cannot find the file specifield.


I have to use dmd 2.071.0 to build it

I will appreciate your help

sorry for the mistake


Fixed in commit: 
https://github.com/gtkd-developers/GtkD/commit/f396481d8d5fe52a2e58b0818494844d672b1c77


The next commit also updates the build script to actually show the error 
from dmd, rather then blindly continuing with the next step.


--
Mike Wey


Re: gtkd build fail on windows with dmd 2.074.0

2017-05-28 Thread Mike Wey via Digitalmars-d-learn

On 05/28/2017 03:30 PM, Mike Wey wrote:

On 05/28/2017 03:20 PM, Mike Wey wrote:

On 05/27/2017 11:42 PM, greatsam4sure wrote:

rdmd Build.d fail on windows with dmd 2.074.0,dmd 2.073.0.
it says std.file.FileException@std\file.d(814)gtkd2.obj:The system 
cannot find the file specifield.


I have to use dmd 2.071.0 to build it

I will appreciate your help

sorry for the mistake


Fixed in commit: 
https://github.com/gtkd-developers/GtkD/commit/f396481d8d5fe52a2e58b0818494844d672b1c77 



The next commit also updates the build script to actually show the 
error from dmd, rather then blindly continuing with the next step.




The release branch seems to give the same error, because dmd tries to 
generate an object file with to many symbols. I should probably break 
the build up into even smaller chunks, i don't know why master is not 
affected.




Also fixed: 
https://github.com/gtkd-developers/GtkD/commit/596a184d9a06754b56dec198bf557be712efe907


--
Mike Wey


Re: D and GDB

2017-06-05 Thread Mike Wey via Digitalmars-d-learn

On 06/05/2017 03:07 AM, H. S. Teoh via Digitalmars-d-learn wrote:

It can't be any more trivial than just running ddemangle, which is found
in the dlang/tools repo on github. (Arguably this should be shipped by
default with dmd... or is it already?)



Recent? versions of gdb also support demangling D symbols, it should 
detect it's D when you compile with -g.


--
Mike Wey


Re: The reason for SIGSEGV function pointer problem

2017-06-07 Thread Mike Wey via Digitalmars-d-learn

On 06/07/2017 06:50 PM, Russel Winder via Digitalmars-d-learn wrote:

So why isn't  a thing of type check_frontend_t*


AFAIK, you would usually translate:


typedef int (check_frontend_t*)(void *args, struct dvb_v5_fe_parms *parms);

into:

alias check_frontend_t = extern(C) int function (void* args, 
dvb_v5_fe_parms* parms);


The problem there is that libdvdv5 defines it as (check_frontend_t) and 
not (check_frontend_t*).
To get around that you can ommit the * in the declaration of 
dvb_scan_transponder, and then you should be able to pass  
to it.


--
Mike Wey


Re: GStreamer and D

2017-06-17 Thread Mike Wey via Digitalmars-d-learn

On 06/17/2017 01:34 AM, Jay Norwood wrote:

gst_plugin_feature_get_name


This is a macro, the alternative:

```
import gobject.Value;

Value name;
feature.getProperty("name", name);
name.getString();
```

or if you don't want to use GValue.

```
to!string((cast(GstObject)feature.getPluginFeatureStruct()).name);
```


g_list_next


https://github.com/gtkd-developers/GtkD/blob/master/generated/gtkd/glib/ListG.d#L75


g_return_if_fail


Also a macro, witch basically does this:

```
if ( !expression )
return;
```


g_value_get_boolean


https://github.com/gtkd-developers/GtkD/blob/master/generated/gtkd/gobject/Value.d#L245

--
Mike Wey


Re: Dub or Dmd trying to use some funny path to find linker.exe

2017-06-10 Thread Mike Wey via Digitalmars-d-learn

On 06/10/2017 07:04 PM, WhatMeWorry wrote:


Dub or Dmd dies when it can't find the linker.  Like so:

C:\Users\kheaser\Git\Delivery\projects\00_01_print_ogl_ver>dub run 
--arch=x86_64 --force

Performing "debug" build using dmd for x86_64.
derelict-util 2.0.6: building configuration "library"...
derelict-al 1.0.3: building configuration "library"...
derelict-assimp3 1.3.0: building configuration "library"...
derelict-fi 2.0.3: building configuration "library"...
derelict-fmod 2.0.4: building configuration "library"...
derelict-ft 1.1.3: building configuration "library"...
derelict-gl3 1.0.23: building configuration "library"...
derelict-glfw3 3.1.3: building configuration "derelict-glfw3-dynamic"...
00_01_print_ogl_ver ~master: building configuration "application"...
Linking...
Error: can't run 
'C:\Users\Administrator\Desktop\VC\\bin\x86_amd64\link.exe', check PATH

dmd failed with exit code -1.

C:\Users\kheaser\OneDrive for 
Business\GitHub\Delivery\projects\00_01_print_ogl_ver>where link.exe

C:\D\dmd2\windows\bin\link.exe

First off, I have no idea why dub (or dmd) is trying to use the path 
C:\Users\Administrator\Desktop\VC\\bin\x86_amd64\ to find link.exe?


I did the where command link.exe to show that the linker is in my PATH 
at C:\D\dmd2\windows\bin\.


So can I specify the linker path explicitly and if so, how is that done?

Sorry if this is a stupid question, but I've looked at the documentation 
all morning and not finding anything.  Thanks.


You are building a 64bit executable, and in that case the linker shiped 
with dmd isn't used, as it only handles 32bit (OMF). dmd instead relies 
on the microsoft linker. Judging from the error the path to the Windows 
SDK / linker is not set correctly in dmd's sc.ini.


--
Mike Wey


Re: gdc and shared objects

2017-06-06 Thread Mike Wey via Digitalmars-d-learn

On 06/06/2017 05:07 PM, Russel Winder via Digitalmars-d-learn wrote:

I hope I am just missing an option as everything seems to be there fore
this to work.


You are missing the `-shared-libphobos` option.

--
Mike Wey


Re: How to get DnD to work in GTKD?

2017-09-16 Thread Mike Wey via Digitalmars-d-learn

On 16-09-17 06:33, Joseph wrote:


I've used null in place of [te]. I'm not sure what target entry is for 
and if that is the problem or what. I am trying to drag files from 
windows explorer to a grid or label(I duplicated the code above for the 
label) and none the callbacks are ever called. I only need the filename 
of the file being dragged.


I will eventually also need to drag one list element to 
another(virtually so, I just need to know the index that was dragged).


Thanks.


You will also need to set an TargetList to tell gtk that you want to 
receive text:


```
TargetList lst = new TargetList([]);
lst.addTextTargets(0);

w..dragDestSetTargetList(lst);
```

for simple cases only `addOnDragDataReceived` will be needed, 
`addOnDragDataGet` is only used for the source and `addOnDragDrop` can 
be used to filter the things that can be droped.


List and Treeviews there are funtions like `getDragDestRow` available 
with the TreeView widget.


--
Mike Wey


Re: Gtk toArray List funkiness

2017-09-16 Thread Mike Wey via Digitalmars-d-learn

On 16-09-17 20:58, Joseph wrote:


https://github.com/gtkd-developers/GtkD/blob/master/demos/gtkD/TestWindow/TestWindow.d 



has the code

foreach ( int i, string selection ; fs.getSelections())
{
   writeln("File(s) selected [%d] %s",i,selection);
}

which is invalid for the demo, but

foreach ( int i, string selection ; fd.getFilenames().toArray!(string,?))
{
   writeln("File(s) selected [%d] %s",i,selection);
}

results in some funky code. Gives errors in ObjectG about uint when 
setting ? to string, string* or void* or even uint:


GtkD\generated\gtkd\gobject\ObjectG.d(172): Error: incompatible types 
for ((obj) is (null)): 'uint' and 'typeof(null)'
GtkD\generated\gtkd\glib\ListSG.d(98): Error: template instance 
gobject.ObjectG.ObjectG.getDObject!(string, string, uint) error 
instantiating

test.d(91):    instantiated from here: toArray!(string, uint)
test.d(93): Error: invalid foreach aggregate `fd.getFilenames()`, define 
opApply(), range primitives, or use .tupleof


without specifying ? it assumes it's a tuple, which seems wrong?



 public T[] toArray(T, TC = typeof(T.tupleof[0]))()
 {
     T[] arr = new T[length()];
     ListSG list = this;
     size_t count;

     while(list !is null && count < arr.length)
     {
     arr[count] = ObjectG.getDObject!(T)(cast(TC)list.data);
     list = list.next();
     count++;
     }

     return arr;
 }


     foreach ( int i, Value 
selection ; fd.getFilenames().toArray!(Value)())

{
   writeln("File(s) selected [%d] %s",i,selection.getString);
}

crashes ;/

I'm not sure what types are what and it changes depending on the input. 
I think Value is the wrong type to use but string doesn't work so...


ListG and ListSG are missing an toArray overload for string. And 
getFilenames returns a list of strings.


I've added a string overload for toArray: 
https://github.com/gtkd-developers/GtkD/commit/ba20490b38e502a4d281226572c83c662a700858


--
Mike Wey


Re: how to build project with locally compiled phobos

2017-09-23 Thread Mike Wey via Digitalmars-d-learn

On 23-09-17 13:58, Mengu wrote:

hi all

i've successfully compiled phobos master with gmake on freebsd. (make 
fails, i've no clue at all as to why)


how do i compile my project now against my local phobos with dub? with 
plain dmd?


i tried (in dub.sdl):
- full path to new libphobos.so with -defaultlib to dflags
- full path to new libphobos.so to lflags

i checked with ldd and saw the original libphobos.so was used. my 
current workaround is copying mine to /usr/lib.


thanks in advanced.


While you are linking with the phobos you compiled yourself with 
-defaultlib, ldd (and your binary) will pickup the one available in one 
of the paths configured for the run-time shared library loader.


To actually make use of the phobos you compiled you also need to set the 
rpath.


```
-L-rpath=/path/to/phobos
```

Or use phobos as a static library.

--
Mike Wey


Re: Gtk toArray List funkiness

2017-09-17 Thread Mike Wey via Digitalmars-d-learn

On 16-09-17 23:08, Joseph wrote:

On Saturday, 16 September 2017 at 20:54:21 UTC, Mike Wey wrote:

On 16-09-17 20:58, Joseph wrote:


https://github.com/gtkd-developers/GtkD/blob/master/demos/gtkD/TestWindow/TestWindow.d 




has the code

foreach ( int i, string selection ; fs.getSelections())
{
   writeln("File(s) selected [%d] %s",i,selection);
}

which is invalid for the demo, but

foreach ( int i, string selection ; 
fd.getFilenames().toArray!(string,?))

{
   writeln("File(s) selected [%d] %s",i,selection);
}

results in some funky code. Gives errors in ObjectG about uint when 
setting ? to string, string* or void* or even uint:


GtkD\generated\gtkd\gobject\ObjectG.d(172): Error: incompatible types 
for ((obj) is (null)): 'uint' and 'typeof(null)'
GtkD\generated\gtkd\glib\ListSG.d(98): Error: template instance 
gobject.ObjectG.ObjectG.getDObject!(string, string, uint) error 
instantiating

test.d(91):    instantiated from here: toArray!(string, uint)
test.d(93): Error: invalid foreach aggregate `fd.getFilenames()`, 
define opApply(), range primitives, or use .tupleof


without specifying ? it assumes it's a tuple, which seems wrong?



 public T[] toArray(T, TC = typeof(T.tupleof[0]))()
 {
 T[] arr = new T[length()];
 ListSG list = this;
 size_t count;

 while(list !is null && count < arr.length)
 {
 arr[count] = ObjectG.getDObject!(T)(cast(TC)list.data);
 list = list.next();
 count++;
 }

 return arr;
 }


 foreach ( int i, Value 
selection ; fd.getFilenames().toArray!(Value)())

{
   writeln("File(s) selected [%d] %s",i,selection.getString);
}

crashes ;/

I'm not sure what types are what and it changes depending on the 
input. I think Value is the wrong type to use but string doesn't work 
so...


ListG and ListSG are missing an toArray overload for string. And 
getFilenames returns a list of strings.


I've added a string overload for toArray: 
https://github.com/gtkd-developers/GtkD/commit/ba20490b38e502a4d281226572c83c662a700858 




 public ListSG getFilenames()
 {
     auto p = gtk_file_chooser_get_filenames(getFileChooserStruct());

     if(p is null)
     {
     return null;
     }

     return new ListSG(cast(GSList*) p, true);
 }

Doesn't return a list of strings? That was the first thing I tried and 
the foreach loop wouldn't work over it because it was a ListSG.


Thanks.



getFilenames returns a singly linked list of C strings, ie the data 
member is a char*.


With the changes in master you can use toArray!string() to get an array 
of strings out of it.


Or you can loop over the list:

```
auto list = fd.getFilenames();
string[] files;

while ( list.next !is null )
{
files ~= to!string(cast(char*)list.data);
list = list.next;
}
```

--
Mike Wey


Re: GtkD mouse latency issues

2017-09-11 Thread Mike Wey via Digitalmars-d-learn

On 11-09-17 06:29, Joseph wrote:
I have a GTK paned element and when I click to drag the handler, it does 
not respond immediately. I have to hold the left mouse button down for 
about 1 second and not move it before it "catches" and lets me drag, 
else I does not move.


I'm using Glade and the most simple example of a paned widget. Any ideas 
what could be causing this? Is GtkD introducing any type of UI response 
latency for the paned handle? In my app I have an icon/image that 
responds immediately.


Is polling being used by any chance for handling some of these events? 
I'm trying to determine if this is a Gtk or GtkD issue. The delay makes 
it pretty frustrating to use because it is an unnaturally long wait. 
Users will just want to click and immediately drag rather than wait a 
second to drag.


As far as I can tell, this only seems to be a problem with the paned 
handle, but I'm not 100% sure. It doesn't seem to be a UI update issue 
or it would eventually "catch up" with the movement of the mouse, which 
it doesn't.




I can't seem to reproduce the issue, at least not on linux.

If you haven't connected any signals everything should be handled by 
GTK. If you have some signals connected to the pane or other widgets, 
that might cause the issue.


--
Mike Wey


Re: Creating a dynamic library

2017-09-30 Thread Mike Wey via Digitalmars-d-learn

On 30-09-17 03:27, Tony wrote:
One thing I picked up from SCons is creating dynamic object files with a 
.os extension and static object files with the standard .o extension. 
That way they can be compiled in the same directory in the same build 
step. But dmd rejects the files that are named *.os. Is there an 
extension besides .o that dmd would accept for the dynamic object files?


I've been using .pic.o so it still ends with .o for dmd.

--
Mike Wey


Re: Best way to display images with GTKD

2017-10-01 Thread Mike Wey via Digitalmars-d-learn

On 01-10-17 01:56, Psychological Cleanup wrote:
I have to display images with a few controls: alpha channel, rotation, 
scaling, cropping. Generally it should be png but I want to be able to 
handle many images. The images will be memory based(I'll load the file 
in to memory then) and will be displayed in a drawing area.


Any ideas how to go about this correctly?


For displaying an image you can use gtk.Image. Rotating, scaling and 
cropping should be doable by loading the image into a cairo surface and 
then applying the transformations.

But that doesn't support things like changing the alpha channel.

--
Mike Wey


Re: GtkD: New widget

2017-08-21 Thread Mike Wey via Digitalmars-d-learn

On 21-08-17 03:45, Johnson Jones wrote:

Hey Mike, I bet you can answer this!

I'd like to extend a widget to add some functionality.

class MyBox : Box
{
 protected GtkBox* gtkBox;

 import std.typecons;
 _gtk.Box Wrapped;
 mixin Proxy!Wrapped;

 public this(Box b)
 {
 this.gtkBox = b.getBoxStruct();
 super(gtkBox, false);
 }

}

Trying something like the above does extend the box, as far as allowing 
one to replace it, I think(using the code);


auto b = new MyBox(W1);
auto p = W1.getParent();
auto c = cast(Box)W4;
c.remove(W1);
c.add(b);

So, W4 is the main boxx, W1 is the box inside the main box I replaced 
with the new box b.


When running that code, nothing changes, which, assuming we are actually 
using the new box, then that is fine.


But I'm pretty sure that gtk never has a clue about `MyBox`? I say this 
because I'd like to simply modify the reported sizes of the box.


A gtkBox is not the same as a gtk.Box.

It seems like the best I can do is use a gtk.Container and inherit from 
that.



e.g.,

class FixableSizedBox : Container
{
 protected GtkContainer* gtkContainer;

 import std.typecons;
 _gtk.Container Wrapped;
 mixin Proxy!Wrapped;

 public this(Container b)
 {
 this.gtkContainer = b.getContainerStruct();
 super(gtkContainer, false);
 }

}

But even the GtkD container doesn't seem to contain any code to deal 
with handling the sizes.



All I'm really looking to do is set the size of a container to whatever 
I want.




If you want gtk to know about the functions you override you could use 
gtkd.Implement.ImplementCLass.


It's only in master and not completely finished yet, but you could use 
it to for example overrride the getPreferredHeight and getPreferredWidth 
functions.


I'm not completely clear on what you want to do with the size so they 
might not be the correct functions to override.



```
class MyBox : Box
{
  import gtkd.Implement;
  import gobject.c.functions : g_object_newv;

  mixin ImplementClass!GtkBox;

  this()
  {
//TODO: sort out the constructor.
super(cast(GtkApplication*)g_object_newv(getType(), 0, null), true);

  }

  override public void getPreferredHeight(out int minimumHeight, out 
int naturalHeight)

  {
//Set minimumHeight and naturalHeight.
  }

  override public void getPreferredWidth(out int minimumWidth, out int 
naturalWidth)

  {
//Set minimumWidth and naturalWidth.
  }
}
```

--
Mike Wey


Re: Building (and including libraries) without dub

2017-08-26 Thread Mike Wey via Digitalmars-d-learn

On 26-08-17 12:02, drug wrote:

26.08.2017 12:03, Hasen Judy пишет:
Building simple programs without dub is easy, just pass a list of .d 
source files to `dmd` or `ldc2`.


What if I want to include a 3rd party library? Surely before dub 
existed, people were incorporating other libraries in their projects.


I want to learn how this works from first principles. I've been 
working with dynamic/interpreted languages for too long, I forgot what 
it's like to build native programs without a dependency manager.


Any help would be appreciated!


It's like C++. If you use Linux then:
```
dmd  -L/path/to/lib 
-llibrarynamewithoutlibprefix

```
or example
```
dmd myapp.d -L../otherproject/lib -lcool
```
line above compiles `myapp.d` file and links it with library `libcool` 
that is place in directory `../otherproject/lib`


You will need an extra `-L` to pass things to the linker with dmd.

```
dmd myapp.d -L-L../otherproject/lib -L-lcool
```

--
Mike Wey


Re: vibed services stop response after several days of work

2017-09-01 Thread Mike Wey via Digitalmars-d-learn

On 01-09-17 10:01, Suliman wrote:

I got same problem on Windows Server 2016 and on Linux Debian 8.5.
I have few very simple backend based on vibed 0.8.1, compiler dmd 2.075.1.

nginx servise is do port forwarding. Nothing more is used.

After several days of working I am begining to get "502 Bad Gateway" 
error. The service is not down, it's continue to working, but on Windows 
task manager I seen very low memory usage (0.4MB) and on Linux I see 
next: https://snag.gy/ban3jX.jpg (i am not familiar with Linux and do 
not sure if process is alive or not because htop do not show it)


The code is *very* simple https://github.com/bubnenkoff/dlang.ru

Is there any ideas how to diagnostic the problem?


For the linux screenshot ps also includes the grep process you are 
pipping the ps output to. So your vibe.d instance isn't running.


Are you running an release build? If so you might get a better idea of 
whats going on when using a plain or debug build.



--
Mike Wey


Re: Unable to compile GtkD on windows

2017-11-15 Thread Mike Wey via Digitalmars-d-learn

On 15-11-17 20:25, user wrote:

I tried compiling GtkD, I get the error message:


rdmd Build.d

Error: more than 32767 symbols in object file


1. How to work around this?

2. Is D still unfriendly to newbies? I am disappoint :-(

Using:
DMD 2.077
GtkD 3.7.1
gtk3-runtime_3.22.24-1, 32bit


It looks like dmd 2.077 generates more symbols than 2.076.

I've updated the build script to work around this by splitting the 
largest package even more than before: 
https://github.com/gtkd-developers/GtkD/commit/9ac582dc0a7fa1ce958a15048b6bcc3ddbcad858


A work around would be to use dmd 2.076.1 or build with dub.

Tough with dub you will need to pass `--build=plain` because of dmd 
issue: https://issues.dlang.org/show_bug.cgi?id=15418


--
Mike Wey


Re: Email validation

2017-11-28 Thread Mike Wey via Digitalmars-d-learn

On 28-11-17 20:32, Vino wrote:

On Tuesday, 28 November 2017 at 18:51:50 UTC, Rene Zwanenburg wrote:

On Tuesday, 28 November 2017 at 18:47:06 UTC, Vino wrote:

Hi All,


You can do this easily using the std.net.isemail module:

https://dlang.org/phobos/std_net_isemail.html


Hi Rene,

  Can you provide me a example, as the link does not have any examples.

From,
Vino.B


isEmail returns a struct with the status of the check.
You can use the valid and domainPart to check if it's a valid email 
address for the hotmail domain.


isMail only checks the formatting of the email address and optionally if 
the domain has a MX record.



```
auto e = isEmail("vino.bhee...@hotmail.com");

if ( e.valid && e.domainPart == "hotmail.com" )
...
```

--
Mike Wey


Re: What's the proper way to use std.getopt?

2017-12-12 Thread Mike Wey via Digitalmars-d-learn

On 12-12-17 00:35, Seb wrote:

D style would be to use sth. like this (instead of try/catch):

```
scope(failure) {
   e.msg.writeln;
   1.exit;
}
```


I might have missed something, but where is `e` defined in this case?

--
Mike Wey


Re: GtkD help

2017-11-19 Thread Mike Wey via Digitalmars-d-learn

On 18-11-17 22:57, Ivan Trombley wrote:
I have this small application for viewing select log data from a certain 
game that I originally wrote in C++/Qt. For various reasons, I decided 
to rewrite this app in D using gtk-d. First, I have to say that the 
documentation for gtk-d is atrocious! However, I managed to cobble 
together enough information to get 80% of it done.


I would like to be able to controll how the cells in a TreeView are 
rendered (ie the text color used) but I'm not able to find any 
information about how to do this. Does any one have experience here? If 
so, can you please give me a clue?


To change how a cell is rendered you will need to add a CellRenderer to 
the column, a CellRendererText would be used for rendering text and it 
has a foreground property to change the text color.


A small example on using CellRenderers can be found here: 
https://github.com/gtkd-developers/GtkD/blob/master/demos/gtkD/DemoMultiCellRenderer/DemoMultiCellRenderer.d


If the color needs to differ between the different rows you can use 
TreeViewColumn.addAttribute to map a property of an renderer to a value 
on the TreeModel.


If the color depends on the value of the cell 
TreeViewColumn.setCellDataFunc() is also an option.


--
Mike Wey


Re: What's the proper way to use std.getopt?

2017-12-11 Thread Mike Wey via Digitalmars-d-learn

On 11-12-17 21:58, Jordi Gutiérrez Hermoso wrote:
but instead, the docstring from getopt is only generated if all 
arguments are valid, i.e. when it's the least needed because the user 
already knew what to input.


What's the proper style, then? Can someone show me a good example of how 
to use getopt and the docstring it automatically generates?



I would use something like this, print the help information for --help, 
print an error for invalid arguments:



```
try
{
auto helpInformation = getopt(
args,
"input|i", "The input", ,
"output|o", "The output", 
);

if (helpInformation.helpWanted)
{
defaultGetoptPrinter("Description", helpInformation.options);
exit(0);
}
}
catch (GetOptException e)
{
writeln(e.msg);
exit(1);
}
```

--
Mike Wey


  1   2   >