Re: gtkd , addondraw is deprecated

2021-05-21 Thread Mike Wey via Digitalmars-d-learn

On 21-05-2021 12:35, Alain De Vos wrote:
What is the advised function to use instead of 
gtk.Widget.Widget.addOnDraw ?

```
this()
     { addOnDraw();}
```


Change the `Context` passed to the drawCallback to a `Scoped!Context` 
only the non scoped overload is deprecated.


```
bool drawCallback(Scoped!Context cr, Widget widget)
```

--
Mike Wey


Re: GtkD - how to list 0..100K strings

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

On 26-04-2020 10:06, mark wrote:

I'm trying to develop an application in GtkD.

I need a widget to display a list of strings: there could be anything 
from 0 to 100K strings, but typically a few hundred or thousand.


Using the DemoCustomList as a model I have created this code:

...

When populateNames() is called the treeview expands horizontally but 
shows nothing, so I'm stuck.


Can anyone help?

Note that I don't have to use a tree widget if there's a better one for 
this use case. I did see ListBox but that seemed to be a list of widgets 
which would be a bit heavy for 100K strings?


The code looks correct, do you have something that compiles so that we 
can test where things go wrong?


--
Mike Wey


Re: How to compile with GtkD

2020-02-09 Thread Mike Wey via Digitalmars-d-learn

On 09-02-2020 12:52, mark wrote:


I am trying to build a simple "hello world" app (from the gtkDcoding 
blog) in $HOME/app/d/gtktest (which is a dub init created directory) and 
have this dub.sdl:


name "gtktest"
description "Gtk Test"
authors "Mark"
targetType "executable"
dependency "gtk-d:gtkd" version=">=3.9.0"
importPaths "$HOME/opt/GtkD3"
libs "libgtkd-3"


Libraries should be passed to dub / ld without the lib prefix, so that 
last line would become: libs "gtkd-3"


Since dub will build a copy of the libraries listed as dependencies, you 
can either remove the dependency line, or the importPaths and libs 
lines. Since now you are linking against both the library build by dub 
and the one on your system.


--
Mike Wey


Re: Running GtkD programs on macOS

2019-11-29 Thread Mike Wey via Digitalmars-d-learn

On 29-11-2019 04:40, Joel wrote:
Oh, I used 'brew install gtk+3', and the test program worked, but (see 
below) I don't know about all that installing - is that alright?


They all look like GTK+ dependencies so that would be alright/

--
Mike Wey


Re: Gtkd and libgtksourceview

2019-10-31 Thread Mike Wey via Digitalmars-d-learn

On 31-10-2019 12:16, Ron Tarrant wrote:

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


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


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


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

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


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


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


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


--
Mike Wey


Re: Gtkd and libgtksourceview

2019-10-30 Thread Mike Wey via Digitalmars-d-learn

On 30-10-2019 20:17, Ron Tarrant wrote:

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

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


Welcome back, Mike...


Thanks.

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


The installer could use an update, Sourceview 4 is available for windows.

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


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


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



For windows there isn't an easy command to regenerate the source, but 
running this command should work (Its been a while since i tried it on 
windows):


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


--
Mike Wey


Re: Gtkd and libgtksourceview

2019-10-30 Thread Mike Wey via Digitalmars-d-learn

On 30-10-2019 15:48, bioinfornatics wrote:

Dear,

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


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




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


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


--
Mike Wey


Re: Options for unit testing in D?

2019-06-21 Thread Mike Wey via Digitalmars-d-learn

On 21-06-2019 06:08, Mike Brockus wrote:

If you never herd about Meson before:
樂. https://mesonbuild.com/

I am wondering as to what options are available for a Meson build user 
when unit testing?


What I am trying todo is simply rewrite my C17 project reference 
templates to D versions so I may show other developers the basic 
structure of my project if I have a question about something or to 
influence the idea of Meson with D projects.  Excuse the Conan file.


As reference:
C17
https://github.com/squidfarts/c-example.git
https://github.com/squidfarts/c-project.git

Dlang
https://github.com/squidfarts/d-example.git




If you are using the D unittests in your source you can recompile the 
same source with `d_unittest: true`, the appstream-generator project 
does this: 
https://github.com/ximion/appstream-generator/blob/master/src/asgen/meson.build#L108


Or you can keep the tests separate and compile these test separately 
like you are doing in your C project. I use this option in the GlibD 
project: 
https://github.com/gtkd-developers/GlibD/blob/master/tests/gobject/meson.build


--
Mike Wey


Re: GtkD slows down visual D keyboard

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

On 26-04-2019 10:31, Amex wrote:
When debugging under visual D, the keyboard response is slowed down to 
the extreme. This is a Gtk issue I believe. It only has to do with the 
keyboard.


For example, if I hit F10 to step, it takes the ide about 10 seconds to 
"respond" and move to the next line... yet the mouse can access stuff 
instantaneous.



I believe Gtk or GtkD is slowing down the keyboard input somehow and for 
some reason making debugging apps a nightmare since it literally takes 
about 100 times longer to debug than it should.


searching google reveals:

https://github.com/Microsoft/vcpkg/issues/4529

https://developercommunity.visualstudio.com/content/problem/42018/debugging-with-keyboard-very-slow.html 



"You somehow break keyboard shortcuts during debugging in VS if the 
application you're debugging is registering a callback with 
"SetWindowsHookEx" from user32.dll with hook ID "WH_KEYBOARD_LL".


Don't call it in debug builds or add "if (!Debugger.IsAttached)" in 
front of the call to "SetWindowsHookEx" if the debugger is attached 
before the function is called.


This brings debugging with keyboard back to the same speed as with the 
UI buttons for our application."




This seems to be an issue with Gtk. I'm not sure if GtkD can do anything 
about it. Maybe somehow reroute the keyboard handler(first remove it 
from the hook then call it manually or reduce the number of calls to it).


I can confirm that gtk call  "SetWindowsHookEx" with the 
"WH_KEYBOARD_LL" ID upon initialization.


As far as i can tell it doesn't provide a way to skip this.

--
Mike Wey


Re: GTK Scale/Volume Buttons Show Muted Icon on Startup

2019-04-25 Thread Mike Wey via Digitalmars-d-learn

On 25-04-2019 15:19, Ron Tarrant wrote:

On Thursday, 25 April 2019 at 12:40:00 UTC, number wrote:

On Thursday, 25 April 2019 at 11:36:26 UTC, Ron Tarrant wrote:

When running this example of a VolumeButton, ...


When using `setValue(initialValue)` after `setAdjustment()` the scale 
seems have the correct value. If in addition the Adjustment is created 
with an initial value different from the `initialValue` used with 
`setValue()` then the icons are also correct on startup. Though I 
don't know why that is. The loading issue doesn't happen here (on linux).


Must be a Windows thing, then.

And even explicitly setting it with setValue() doesn't help. The icon is 
still wrong on startup.




This looks like an issue with GTK, the icon is not updated when changing 
the Adjustment, only when the value changes.


Using setValue after setting the ajustment should work, only you have to 
use a different value than the initial value of the adjustment or GTK 
doesn't see it as a change.


--
Mike Wey


Re: Retrieving Column Data from a ListStore?

2019-04-24 Thread Mike Wey via Digitalmars-d-learn

On 24-04-2019 16:38, Ron Tarrant wrote:
Another thing I've been struggling with is fetching data from a 
TreeIter. Getting the iter itself is no problem, but when it comes to 
getting the contents of a specific column within the iter, none of the 
methods I've tried have worked. In fact, it almost seems like none of 
them are implemented.


I've written a callback function named onChanged() in the MyComboBox 
class that gets the TreeIter, but that's all I can get working. If 
anyone knows how to grab data from column 2 of the iter (see the 
MyListStore class at the bottom for the structure of the store) I'd be 
ever so grateful if you could fill in whatever else would be needed in 
that callback.


Here's the code:

```
...

```


The ListStore/TreeModel provides functions to retrieve the data, 
`gtk.TreeModelIF.TreeModelIF.getValue`.


A TreeIter indicates the row these kind of function apply to.
--
Mike Wey


Re: D threading and shared variables

2019-04-07 Thread Mike Wey via Digitalmars-d-learn

On 07-04-2019 16:49, Archie Allison wrote:

The codebase is a reasonable size so too big (and proprietary) to share.

It's always run with a GUI (GTKD), it's just the difference in linking 
so launching (a)GUI + attached console for stdout.writeln vs. (b)just 
the GUI window. There's nothing I'd expect to cause races or deadlocks.




How are you using the GUI, GTK is not thread safe, all gui function 
calls should be made from the GUI thread.


Last time i checked threadsEnter and threadsLeave didn't work properly 
on windows.


--
Mike Wey


Re: gtkDcoding Blog Post for 2019-03-29 - Grid

2019-04-02 Thread Mike Wey via Digitalmars-d-learn

On 02-04-2019 17:48, Ron Tarrant wrote:

On Tuesday, 2 April 2019 at 14:13:09 UTC, number wrote:

Can somebody explain why getRgba() (apparently inherited from 
ColorChooser) does take an out parameter instead of returning an 
Gdk.RGBA?


My understanding is this:

Returning an object (as opposed to a single value) means returning a 
pointer rather than the entire object. And the object will cease to 
exist once the function returns because the scope no longer exists. So, 
it follows that an out variable passed in will preserve the object 
itself once program control returns to the caller.




While that would be true for things that live on the stack, this is not 
the case for RGBA. The C version of getRgba uses the "out" parameter so 
you can pass in a existing GdkRgba, even tough that would make it more 
like ref.
This doesn't make sense for the d binding since you will always get a 
new RGBA passed through the out parameter.


--
Mike Wey


Re: Request some GtkD Assistance

2019-03-27 Thread Mike Wey via Digitalmars-d-learn

On 27-03-2019 11:01, Andrew Edwards wrote:
This would is already included in dlang.conf no? Yes furnishing an 
explicit path works.

dmd -de -w -L/Users/edwarac/dlang/dmd-2.085.0/osx/lib/libgtkd-3.a nufsaid

But why do I need to do that if it's sitting right next to phobos and 
DMD is already searching that directory for libraries?



That because of the way the dmd and the linker interpret the arguments.

-L tell dmd to pass the command that follows to the linker.
To tell the linker to link with a library in a known location you would 
use the -l flag.


For the value passed to -l the linker will prefix `lib` and postfix 
`.so` `.a`.


So the following should work properly:
`dmd -de -w -L-lgtkd-3 nufsaid'

--
Mike Wey


Re: gtkD: How to paint to screen for animation

2019-03-19 Thread Mike Wey via Digitalmars-d-learn

On 19-03-2019 01:54, Michelle Long wrote:
I've added a function to addOnDraw for a DrawingArea and it paints using 
the code I have when I resize.


I added a queueDraw in threadsAddIdle and it seems to draws the screen 
immediately but it does not seem to be called again.


If I put queueDraw inside the addOnDraw routine then the animation works 
but it is quite slow, about 1 fps and cpu usage is 100% without it, it 
is 0%.


You will probably want to use glib.Timeout to make the time between 
redraws consistent.
The callBack for treadsAddIdle or glib.Idle is only called when the 
mainloop has nothing else to do.


The cairo clock demo is a good example: 
https://github.com/gtkd-developers/GtkD/blob/master/demos/cairo/cairo_clock/clock.d


If performance is an issue one option would be to save your context in a 
cairo surface and only redraw the parts that have changed.


--
Mike Wey


Re: problem extracting data from GtkSourceView using Gtkd

2019-01-17 Thread Mike Wey via Digitalmars-d-learn

On 17-01-2019 00:31, Chris Bare wrote:


Are the widgets destroyed before onShutdown?


The onShutdown callback is run after the GTK main loop terminates, so 
most objects would be finalized.


--
Mike Wey


Re: problem extracting data from GtkSourceView using Gtkd

2019-01-15 Thread Mike Wey via Digitalmars-d-learn

On 14-01-2019 23:52, Chris Bare wrote:
I would have posted this in the Gtkd forum, but it has been down for a 
while.


I'm porting a GTK2/C program to Gtkd. I'm trying to read the data from a 
GtkSourceView, but when I try to get the bounds, it's always zero.


Here's the c version that works:
 GtkSourceBuffer *bf;
 GtkTextIter start, end;
 int len;

 bf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (w.mainTxt));
 gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER(bf), , );
 data = gtk_text_buffer_get_text (GTK_TEXT_BUFFER(bf), , , 
FALSE);


Here's what I tried in D:
 SourceBuffer bf;
 auto start = new TextIter();
 auto end = new TextIter();

 bf = this.mainTxt.getBuffer ();
 bf.getBounds (start, end);
 string str = bf.getText (start, end, false);

getBounds is defined as: getBounds(out TextIter start, out TextIter end)

Is there something I'm doing wrong?
Any suggestions on what else to try?


Your code looks correct, and when copying it into the GtkD sourceview 
demo str does indeed hold the text displayed in the GtkSourceview.


Do you have a more complete example we could look at?

--
Mike Wey


Re: DMD32 compiling gtkd out of memory on 32bit Windows 7 machine

2018-09-14 Thread Mike Wey via Digitalmars-d-learn

On 9/14/18 4:02 AM, dangbinghoo wrote:

thanks timoses ,

singleFile mode works for building, but when linking, I got this:

--
OPTLINK (R) for Win32  Release 8.00.17
Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
OPTLINK : Warning 9: Unknown Option : LLIB
OPTLINK : Warning 9: Unknown Option : WIN32
C:\Users\Administrator.USER-20180912OL\AppData\Local\dub\packages\gtk-d-3.8.3\gtk-d\.dub\build\library-debug-windows-x86-dmd_2082-9C5C1D99F672708E9D6D6FE9E60296B4\gtkd-3.lib 


  Warning 178: .LIB pagesize exceeds 512
C:\Users\Administrator.USER-20180912OL\AppData\Local\dub\packages\gtk-d-3.8.3\gtk-d\.dub\build\library-debug-windows-x86-dmd_2082-9C5C1D99F672708E9D6D6FE9E60296B4\gtkd-3.lib 


  Error 7: Out of Memory
Error: linker exited with status 1
dmd failed with exit code 1.
---

I think that DMD should give up it's DMC linkers, using MinGW ld 
instead. DMC linker is not even a working linker.




You will also have to pass `--build=plain` to dub because of a optlink bug.

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

--
Mike Wey


Re: Load D shared library on windows x64

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

On 18-08-18 02:31, Tofu Ninja wrote:

On Friday, 17 August 2018 at 20:27:05 UTC, Tofu Ninja wrote:

Its this part that fails... always returns null

HMODULE h = cast(HMODULE) Runtime.loadLibrary(dllName);
if (h is null) {
writeln("error loading");
return;
}



I there any way to see why Runtime.loadLibrary is failing? It just 
returns null on error which is not very helpful.


You can probably use: core.sys.windows.winbase.GetLastError

--
Mike Wey


Re: Elegant way to use dynamic bindings

2018-02-09 Thread Mike Wey via Digitalmars-d-learn

On 09-02-18 15:04, Dennis wrote:
I read the Derelict documentation a while ago, I didn't grasp all of it. 
Reading it again, I can now make sense of it though. :)


On Friday, 9 February 2018 at 12:53:44 UTC, Mike Parker wrote:
Did you link with the library you created with implib? That linker 
error suggests you didn't.


I added `pragma(lib, "mupen64plus.lib");` above the extern(C) block.
Adding `libs "mupen64plus"` to dub.sdl doesn't make a difference.

The thing that confuses me is that the import lib has symbols without 
underscore prefix (I see them when running `libunres -p 
mupen64plus.lib`), but when I change the function pointer declaration 
into a function declaration it tries to link "_CoreGetAPIVersions" and 
can't find it.


I put the .dll's in the root of the project directory by the way. Does 
that count as a "system library search path"?


You may need to pass `/s` to implib so it will add the underscore to the 
symbol in the import library. If it's actually needed depends on what 
the dll uses.


--
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: 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


Re: .LIB pagesize exceeds 512

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

On 10-12-17 16:57, user wrote:

Could someone please list some workarounds?

I am trying to compile a demo app from gtkd. I tried compiling gtkd 
using dub with --build=plain option and still got that error when 
compiling the demo app. Using the latest dmd.


Thanks in advance.


As far as i know the error is caused by the debug information, and using 
`--build=plain` for dub used to fix that, but that might have changed.


You could try building gtkD with the windows build script: `rdmd Build.d`

Or if possible build the 64bit version witch doesn't use optlink.

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: 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: 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: opCast fails when this is null.

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

On 28-10-17 16:22, Nicholas Wilson wrote:

On Saturday, 28 October 2017 at 14:19:01 UTC, Nicholas Wilson wrote:
As Basile mentioned, this is compiler sticking checks in behind your 
back.
The reason it works on new LDC is because #6982 was cherry picked to 
LDC (1.3?) before it was merged into dmd (not sure what version, I 
though it was 2.076, but it might have been one of the betas of 2.077) 
because I needed it for DCompute to build without -release.


The only course is to use recent compilers.


Erm, 2.077 is not a thing yet. Does it work with 2.076.1?

No, it does work with the 2.077 beta tough.

--
Mike Wey


opCast fails when this is null.

2017-10-28 Thread Mike Wey via Digitalmars-d-learn
The following code runs correctly when compiled with ldc (1.4.0) but 
fails with an assert error when compiled with dmd (2.076 and ldc 1.2.0)



```
class A
{

}

class B
{
T opCast(T)()
{
return this;
}
}

void main()
{
A a = null;
B b = null;

auto c = cast(Object)a;
	auto d = cast(Object)b; // Fails with: 
core.exception.AssertError@test.d(8): null this

}
```

How would you write an opCast that would handle this case correctly?

Testing if this is null at the start of the opCast doesn't help since 
the assert is thrown before that happens.
Making the opCast static leaves us without access to this, which would 
be needed in my use case.
We can't relay on ufcs since the rewrite to opCast doesn't happen when 
it's not a member function.


--
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: 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: 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: 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 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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: 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 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: 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: 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: 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 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 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-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: 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: 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: 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: 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: 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: 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(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: 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: 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: 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-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

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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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-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: 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: 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: 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: 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: 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-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-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-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: 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 - 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 - 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 - 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


  1   2   >