custom drawing with gktd?
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.
Re: Bug in gtkd?
Ok, Using msys I was able to get glade 3.20 running. Maybe that will fix everything.
Re: Bug in gtkd?
On Tuesday, 1 August 2017 at 20:18:19 UTC, Mike Wey wrote: 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. There is no File/Properties. If I go to help/about it says 3.8.5. If I go to edit/preferences it says target gtk+ version and the highest is 2.24. This is where I downloaded it from: http://ftp.gnome.org/pub/GNOME/binaries/win32/glade/3.8/ It seems I do, in fact have an older version ;/ https://glade.gnome.org/sources.html I upgraded to 3.14(for some reason I was thinking 8 > 14 ;/). It does have the properties and did warn me about my glade file being old(strange though, the ver 14 looks crappier as the fonts are thinner). Not a big deal though. Seems ver 3.14 is the newest binaries for windows for some reason ;/ No one has compiled a windows version for 3.20 in over a year. Not sure of the differences between 3.14 and 3.20 but 3.14 does target gtk+3 while 3.8 targeted gtk+2. How to build glade 3.20 for windows, or better, request the originators to build it(since they obviously have done it for the previous versions)?
Re: Adding deprecated to an enum member
On Tuesday, 1 August 2017 at 01:12:28 UTC, Jeremy DeHaan wrote: I got an error today because I added deprecated to an enum member. Is there a way to achieve this, or am I out of luck? If it isn't doable, should it be? Here's what I want: [...] It's a bug [1]. [1] https://issues.dlang.org/show_bug.cgi?id=9395
Re: this r-value optimizations
On Tuesday, 1 August 2017 at 22:47:24 UTC, Nordlöw wrote: Given the `struct S` with lots of data fields, I've written the following functional way of initializing only a subset of the members in an instance of `S`: struct S { [...] } Now the question becomes: will the S-copying inside `withF` be optimized out in the case when `this` is an r-value such as in the call auto y = S(32).withF(42.0); ? You're going to have to be specific about optimized out by whom. By the frontend? Doesn't seem that way to me by looking at the `-O0` assembly generated by ldc [1]. If not, one solution of doing this manually is to write `withF` as a free function [...] Is this the preferred way of solving this until we (ever) get named parameters in D? Preferred by whom? The people who want named parameters in D seem to be a minority in the community from my personal observation, so you would most likely get personal preferred way as an answer (instead of "the" unanimous preferred way). In any case, this looks like a case of evil early optimization to me, because it's statistically unlikely that this is going to be the bottleneck of your program (though profiling would be in order to confirm / disprove that assumption for your specific use case). [1] https://godbolt.org/g/Htdtht
Re: why won't byPair work with a const AA?
On Tue, Aug 01, 2017 at 07:31:41PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: > On 8/1/17 7:15 PM, H. S. Teoh via Digitalmars-d-learn wrote: > > On Tue, Aug 01, 2017 at 07:09:45PM -0400, Steven Schveighoffer via > > Digitalmars-d-learn wrote: > > > If this were a true implementation without the opaqueness, it > > > would not work properly. > > [...] > > > > Actually, a proper implementation would still work, provided you > > declare your pointer types carefully. Sketch of idea: > > > > auto byKeyValue(AA)(AA aa) { > > struct Result { > > const(Slot)* current; // N.B.: proper type > > bool empty() { ... } > > auto front() { return Pair(*current); } > > void popFront() { > > current = current.next; > > ... > > } > > } > > return Result(aa); > > } > > > > Basically, the type of `current` must be const(Slot)* rather than > > const(Slot*), which would be the default inferred type. But since > > it's legal to assign a const pointer to a pointer to const (you > > can't modify the original pointer, nor what it points to, but it's > > valid to copy the pointer to a mutable pointer variable, as long as > > what is pointed to is still const), this actually will work without > > breaking / bypassing the type system. > > No, you can't const the Slot, because if the value type is a pointer, > you can't then cast away the const-ness of it legally. > > There are ways to get it right, it involves templating for mutability. [...] Counter-proof: struct Slot { Slot* next; const(string) key; const(int) value; } struct AA { Slot*[] slots; } unittest { const(AA) aa; static assert(is(typeof(aa.slots[0]) == const(Slot*))); const(Slot)* p = aa.slots[0]; // N.B.: legal p = p.next; // N.B.: legal } Note especially the type checked for in the static assert: you cannot modify any of the Slot pointers in the AA, but you *can* assign them to mutable (but tail-const) pointers. Therefore you totally can iterate a const AA without any casts or any breaking of the type system. And there's no need to template for mutability either. T -- One Word to write them all, One Access to find them, One Excel to count them all, And thus to Windows bind them. -- Mike Champion
Re: why won't byPair work with a const AA?
On 8/1/17 7:15 PM, H. S. Teoh via Digitalmars-d-learn wrote: On Tue, Aug 01, 2017 at 07:09:45PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: If this were a true implementation without the opaqueness, it would not work properly. [...] Actually, a proper implementation would still work, provided you declare your pointer types carefully. Sketch of idea: auto byKeyValue(AA)(AA aa) { struct Result { const(Slot)* current; // N.B.: proper type bool empty() { ... } auto front() { return Pair(*current); } void popFront() { current = current.next; ... } } return Result(aa); } Basically, the type of `current` must be const(Slot)* rather than const(Slot*), which would be the default inferred type. But since it's legal to assign a const pointer to a pointer to const (you can't modify the original pointer, nor what it points to, but it's valid to copy the pointer to a mutable pointer variable, as long as what is pointed to is still const), this actually will work without breaking / bypassing the type system. No, you can't const the Slot, because if the value type is a pointer, you can't then cast away the const-ness of it legally. There are ways to get it right, it involves templating for mutability. The current code is pretty horrific though, any way you slice it. -Steve
Re: Adding deprecated to an enum member
On Tuesday, 1 August 2017 at 02:06:27 UTC, dark777 wrote: I did as follows using deprecated may help you to elucidate in relation to this https://pastebin.com/NEHtWiGx Deprecating an entire module isn't really a solution though. I only want parts of an existing enum to be deprecated when they are used.
Re: why won't byPair work with a const AA?
On Tue, Aug 01, 2017 at 07:09:45PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: > On 8/1/17 6:50 PM, H. S. Teoh via Digitalmars-d-learn wrote: [...] > > Actually, there's nothing about the implementation of both > > byKeyValue (the underlying implementation in druntime) and byPair in > > std.array that would preclude them from being used with const AA's. > > The only flaw is that the declaration of byPair doesn't match const > > AA's: > > > > https://issues.dlang.org/show_bug.cgi?id=17711 > > > > Here's the fix: > > > > https://github.com/dlang/phobos/pull/5668 > > It works, because the byKeyValue implementation is so... ugly. > > For instance this: > > return Result(_aaRange(cast(void*)aa)); > > Just throws away all const/mutability. However, the Pair struct inside > restores the correct modifiers. I hope... > > If this were a true implementation without the opaqueness, it would > not work properly. [...] Actually, a proper implementation would still work, provided you declare your pointer types carefully. Sketch of idea: auto byKeyValue(AA)(AA aa) { struct Result { const(Slot)* current; // N.B.: proper type bool empty() { ... } auto front() { return Pair(*current); } void popFront() { current = current.next; ... } } return Result(aa); } Basically, the type of `current` must be const(Slot)* rather than const(Slot*), which would be the default inferred type. But since it's legal to assign a const pointer to a pointer to const (you can't modify the original pointer, nor what it points to, but it's valid to copy the pointer to a mutable pointer variable, as long as what is pointed to is still const), this actually will work without breaking / bypassing the type system. T -- People tell me that I'm skeptical, but I don't believe them.
Re: why won't byPair work with a const AA?
On 8/1/17 6:50 PM, H. S. Teoh via Digitalmars-d-learn wrote: On Tue, Aug 01, 2017 at 10:04:18AM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: On 7/30/17 12:19 AM, Matthew Gamble wrote: [...] import std.array; import std.algorithm; class A { this() { aa = ["a":1, "b" : 2, "c" : 3]; } auto pairs() @property const { return aa.byPair.array.sort().release; } private: int[string] aa; } If I remove const from the pairs function it compiles fine. I'm just not sure this is a behavior I want. Any help/recommendation would be appreciated. byPair must store a pointer to the data in the AA. If you mark the AA const, then it must store a const pointer to AA data. [...] Actually, there's nothing about the implementation of both byKeyValue (the underlying implementation in druntime) and byPair in std.array that would preclude them from being used with const AA's. The only flaw is that the declaration of byPair doesn't match const AA's: https://issues.dlang.org/show_bug.cgi?id=17711 Here's the fix: https://github.com/dlang/phobos/pull/5668 It works, because the byKeyValue implementation is so... ugly. For instance this: return Result(_aaRange(cast(void*)aa)); Just throws away all const/mutability. However, the Pair struct inside restores the correct modifiers. I hope... If this were a true implementation without the opaqueness, it would not work properly. -Steve
Re: why won't byPair work with a const AA?
On Tue, Aug 01, 2017 at 10:04:18AM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: > On 7/30/17 12:19 AM, Matthew Gamble wrote: [...] > > import std.array; > > import std.algorithm; > > > > class A > > { > > this() { aa = ["a":1, "b" : 2, "c" : 3]; } > > auto pairs() @property const { return > > aa.byPair.array.sort().release; } > > private: > > int[string] aa; > > } > > > > If I remove const from the pairs function it compiles fine. I'm just > > not sure this is a behavior I want. Any help/recommendation would be > > appreciated. > > byPair must store a pointer to the data in the AA. If you mark the AA > const, then it must store a const pointer to AA data. [...] Actually, there's nothing about the implementation of both byKeyValue (the underlying implementation in druntime) and byPair in std.array that would preclude them from being used with const AA's. The only flaw is that the declaration of byPair doesn't match const AA's: https://issues.dlang.org/show_bug.cgi?id=17711 Here's the fix: https://github.com/dlang/phobos/pull/5668 T -- Sometimes the best solution to morale problems is just to fire all of the unhappy people. -- despair.com
Re: gtk arch issues
On Tuesday, 1 August 2017 at 21:03:44 UTC, Mike Wey wrote: 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. I rebuilt gtkD but obviously not gtk, which I guess was using searching the dll's the same way that gtkD did. 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. I didn't actually rename, I copied then renamed the copies so that the originals were still there. The point was to get gtkD to use different versions, which it did, but I guess gtk had the same problem with it's versioning where it would simply try to use whatever it found in the path. 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. As I stated the last post, everything is working. I reverted back to the original gtkD so it uses the original names. I only have one GTK dir in the path at a time now rather than both x86 and x64. That solved the problem. The only problem that exists now is that I have to manually swap the installations of gtkx86 and gtkx64. When I switch from from x86 to x64 and vice versa... not difficult but I'm sure I'll forget months down the road and waste time trying to remember what I needed to do. So, I have dirs like C:\Gtkx86 C:\Gtkx64 C:\Gtk where C:\Gtk is a junction that points to either C:\Gtkx86 or C:\Gtkx64 depend on which arch I'm compiling for. The path only as C:\Gtk in it so there is no possibility for the dlls to get mixed up, which is what happens when both architecture versions are in the path. I'd like to avoid having to change the junction each time I decide to test my app in a different architecture. Instead, having a simple version(X86) SetGTKDir("C:\\Gtkx86"); version(Win64) SetGTKDir("C:\\Gtkx64"); is what I'm after.
this r-value optimizations
Given the `struct S` with lots of data fields, I've written the following functional way of initializing only a subset of the members in an instance of `S`: struct S { int i; float f; ... this(int i) { this.i = i; } S withF(float f) { // will this be optimized out if `this` is an r-value? S copy = this; copy.f = f; return copy; } } Now the question becomes: will the S-copying inside `withF` be optimized out in the case when `this` is an r-value such as in the call auto y = S(32).withF(42.0); ? If not, one solution of doing this manually is to write `withF` as a free function S withF()(auto ref S this_, float f) { static if (__traits(isRef, this_)) { // this_ is an l-value (and was passed by ref) // so a copy has to be made before modifying it } else { // this_ is an r-value (and was passed by move) // so it can be modified in-place } } Is this the preferred way of solving this until we (ever) get named parameters in D?
Re: gtk arch issues
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: gtk arch issues(fixed)
So, The error I currently get is object.Exception@generated\gtkd\gtkd\Loader.d(125): Library load failed (libgdk-3-0x64.dll): is not a valid Win32 application. and libgdk-3-0x64.dll was libgdk-3-0.dll from the 64-bit gtk package. (I simply added the extension)... the package downloaded from the gdk website. The size of the file is 1.15 MB (1,211,571 bytes) What's strange is that the file says the original name was libgdk-win32-3.0-0.dll.. This is from the supposedly 64-bit package on the gdk website: gtk3-runtime_3.22.4_64-bit I extracted the files directly from that to compare and that is what it says... so, if the dll is truly 32-bit then it would explain it and the 64-bit runtime is not correct. Trying the files from http://www.tarnyko.net/dl/gtk.htm still has the same name(maybe the name is not correct... but still doesn't work). I've uninstalled all the gtk stuff and reinstalled using that website(seems to be a later version?). Eventually after setting the paths and all that I run the program and get a different error: (note the the spelling error) object.Error@(0): The function you are calling is not pressent in your version of GTK+. 0x7FF7DBE8A033 in extern (C) void gtkd.Loader.Linker.unsupportedSymbol() 0x7FF7DBAC28BB in gtk.Builder.Builder gtk.Builder.Builder.__ctor(immutable(char)[]) 0x7FF7DBAC145A in D main at main.d(17) 0x7FF7DBEF0172 in D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv 0x7FF7DBEF007F in void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) 0x7FF7DBEF010C in void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll() 0x7FF7DBEF007F in void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) 0x7FF7DBEEFF9F in d_run_main 0x7FF7DBAC1502 in __entrypoint.main 0x7FF7DBF6B654 in invoke_main at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl(65) 0x7FF7DBF6B567 in __scrt_common_main_seh at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl(259) 0x7FF7DBF6B42E in __scrt_common_main at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl(302) 0x7FF7DBF6B669 in mainCRTStartup at f:\dd\vctools\crt\vcstartup\src\startup\exe_main.cpp(17) 0x7FFB8EBD2774 in BaseThreadInitThunk 0x7FFB90050D51 in RtlUserThreadStart now trying the the gtkd's gtk64. woot! which works! 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).
Re: Bug in gtkd?
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: gtk arch issues
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 public static void loadLibrary(string library) { void* handle = pLoadLibrary(library); //TODO: A more general way to try more than one version. if ( handle is null && library == importLibs[LIBRARY.GSV] ) handle = pLoadLibrary(importLibs[LIBRARY.GSV1]); if ( handle is null ) throw new Exception("Library load failed ("~ library ~"): "~ getErrorMessage()); loadedLibraries[library] = handle; } private void* pLoadLibrary(string libraryName, int flag = RTLD_NOW) { void* handle = dlopen(cast(char*)toStringz(basePath.buildPath(libraryName)), flag | RTLD_GLOBAL); if(!handle){ lastError = dlerror().fromStringz.idup; } // clear the error buffer dlerror(); return handle; } private void setDllPath() { static bool isSet; if ( isSet ) return; string gtkPath = getGtkPath(); if ( gtkPath.length > 0 ) SetDllDirectoryA((gtkPath~'\0').ptr); isSet = true; } 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.
Re: gtk arch issues
On Tuesday, 1 August 2017 at 15:14:50 UTC, Mike Wey wrote: 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. Ok, I renamed Program Files (x86)\GtkSharp so that it effectively deleted it, Same issue though: C:\Program Files (x86)\Gtk-Runtime\bin\libgdk_pixbuf-2.0-0.dll unloaded. C:\Program Files (x86)\Gtk-Runtime\bin\libepoxy-0.dll unloaded. C:\Windows\System32\dwmapi.dll unloaded. C:\Windows\System32\setupapi.dll unloaded. C:\Program Files\Gtk-Runtime\bin\libcairo-gobject-2.dll unloaded. C:\Program Files\Gtk-Runtime\bin\libcairo-2.dll unloaded. C:\Program Files\Gtk-Runtime\bin\libgio-2.0-0.dll unloaded. C:\Windows\System32\ole32.dll unloaded. C:\Windows\System32\winmmbase.dll unloaded. C:\Windows\System32\winmm.dll unloaded. C:\Windows\System32\ws2_32.dll unloaded. C:\Program Files\Gtk-Runtime\bin\libglib-2.0-0.dll unloaded. C:\Program Files\Gtk-Runtime\bin\libgdk-3-0x64.dll unloaded. The thread 0x1590 has exited with code 1 (0x1). The thread 0x1598 has exited with code 1 (0x1). The thread 0x1594 has exited with code 1 (0x1). The program '[5472] test.exe' has exited with code 1 (0x1). Renaming Program Files (x86)\Gtk-Runtime Gives C:\Windows\System32\dwmapi.dll unloaded. C:\Windows\System32\setupapi.dll unloaded. C:\Program Files\Gtk-Runtime\bin\libcairo-gobject-2.dll unloaded. C:\Program Files\Gtk-Runtime\bin\libcairo-2.dll unloaded. C:\Program Files\Gtk-Runtime\bin\libgio-2.0-0.dll unloaded. C:\Windows\System32\ole32.dll unloaded. C:\Windows\System32\winmmbase.dll unloaded. C:\Windows\System32\winmm.dll unloaded. C:\Windows\System32\ws2_32.dll unloaded. C:\Program Files\Gtk-Runtime\bin\libglib-2.0-0.dll unloaded. C:\Program Files\Gtk-Runtime\bin\libgobject-2.0-0.dll unloaded. C:\Program Files\Gtk-Runtime\bin\libgdk-3-0x64.dll unloaded. The thread 0x1480 has exited with code 1 (0x1). The thread 0x1560 has exited with code 1 (0x1). The thread 0x4f0 has exited with code 1 (0x1). The program '[3936] test.exe' has exited with code 1 (0x1). And x86 test.exe gives the error: "The image File C:\Program Files\Gtk-Runtime\bin\libatk-1.0-0.dll" is valid but is for a machine type other than the current machine. Select Ok to Continue or Cancel to fail the DLL load". which was the original error I got. At this point x64 gives the error: object.Exception@generated\gtkd\gtkd\Loader.d(125): Library load failed (libgdk-3-0x64.dll): The specified module could not be found. which has the code: //TODO: A more general way to try more than one version. if ( handle is null && library == importLibs[LIBRARY.GSV] ) handle = pLoadLibrary(importLibs[LIBRARY.GSV1]); Which, if I'm not mistaken, suggests that maybe it is time to add this "more general way" ;) Now, why it is trying to load libgdk-3-0x64.dll, which is clearly one of the modified files, but a dll of gdk, is unclear. I have no file with gdk in it in any of the proper directories. tried installing https://sourceforge.net/projects/gtk3win/files/latest/download but no luck. Says it's for x86 and x64 but I have my doubts. So what is going on here?
Re: Bug in gtkd?
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
Re: Can you parse the d source file during compile time with std.regex?
On Tuesday, 1 August 2017 at 16:20:07 UTC, Stefan Koch wrote: On Tuesday, 1 August 2017 at 16:16:46 UTC, 12345swordy wrote: I don't see this anywhere in the documentation. I am asking this as I want to know that it's possible to create a attribute to prevent certain functions being called in the body of a function. To enforce a certain code standard upon myself. UDA's are your friend here. There is no need to use parser, and in any case std.regex cannot match the regex at ct. I know that UDA exist, what I want to know if it is possible to create one that prevent certain things like calling certain functions in a function body Ie @custom main() { //function body example()//throw error by @custom } There is no getRawFunctionBody for traits either, so I was thinking about using std.regex to get the string of the function body and and then parse that string during compile time. Alex
Re: Can you parse the d source file during compile time with std.regex?
On Tuesday, 1 August 2017 at 16:16:46 UTC, 12345swordy wrote: I don't see this anywhere in the documentation. I am asking this as I want to know that it's possible to create a attribute to prevent certain functions being called in the body of a function. To enforce a certain code standard upon myself. UDA's are your friend here. There is no need to use parser, and in any case std.regex cannot match the regex at ct.
Can you parse the d source file during compile time with std.regex?
I don't see this anywhere in the documentation. I am asking this as I want to know that it's possible to create a attribute to prevent certain functions being called in the body of a function. To enforce a certain code standard upon myself.
Re: How to build GUI-based applications in D ?
On Tuesday, 1 August 2017 at 15:18:12 UTC, ashit wrote: i couldn't set control's width and height (Button widget) shows error. maybe it works a different way. 1. Try layoutHeight/width. Remember to set it for the main widget too, not just the children of it. 2. DlangUI is not intended to define sizes in pixels as a standard practice. Instead, use layouts and layout sizes. This is intended to courage you to make your program resolution-agnostic. But I'm a beginner at this topic too. Take these with a grain of salt
Re: How to build GUI-based applications in D ?
On Tuesday, 1 August 2017 at 14:57:50 UTC, JamesD wrote: On Tuesday, 1 August 2017 at 09:31:32 UTC, ashit wrote: what is the simplest library to create gui applications in D? i want to create gui applications but couldnt configure the tools so far. [snip] I recommend you check out the D widget toolkit (DWT). DWT is a library for creating cross-platform GUI applications. It's a port of the SWT Java library from Eclipse. The key advantages of DWT are; 1. Extensive API and examples from SWT that can be searched with your Browser 2. Statically linked (don't need an external DLL) 3. Easy to learn and use Here is the dub package for DWT: https://code.dlang.org/packages/dwtlib See more features in the DWT forum: https://forum.dlang.org/group/dwt Here are the various GUIs for the D language: https://wiki.dlang.org/GUI_Libraries thank you James i should try that. i was always enjoy the pure and efficiency of C. that made me stubborn to learn java. but now, as i look behind i know i was wrong. (that caused i miss android). i need to rethink my strategy. but instead of that C brought me to the MCU's world.
Re: It makes me sick!
On Tuesday, 1 August 2017 at 15:16:44 UTC, Vladimir Panteleev wrote: Sorry, isn't that how things work now? For modules, yes. For packages, no. That inconsistency is what I want to change. So since we have a package here and the compiler doesn't allow you to define a package in the existing datetime.d, we have to move the file. And unzipping doesn't pick up that the file was moved and leaves old stuff behind. b.d(1): Error: package name 'aa' conflicts with usage as a module name in file That error shouldn't exist. The problem here is that the compiler picks up the OLD datetime.d If we could just use datetime.d as the package file, there would be no old datetime.d anymore.
Re: How to build GUI-based applications in D ?
On Tuesday, 1 August 2017 at 10:09:56 UTC, Russel Winder wrote: I use GtkD (with GStreamerD) for my GUI applications written in D. https://gtkd.org/ thank you Russel. i have tried to config that several months ago, but no luck. i should try that once again.
Re: Bug in gtkd?
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: How to build GUI-based applications in D ?
On Tuesday, 1 August 2017 at 09:44:48 UTC, ketmar wrote: ashit wrote: [...] Adam Ruppe has minigui in his arsd[0] repo. and minigui_xml to make interface creation easier. it is not really well-documented yet, tho, so you will prolly have to figure some things on your own. [0] https://github.com/adamdruppe/arsd On Tuesday, 1 August 2017 at 09:44:48 UTC, ketmar wrote: thank you
Re: It makes me sick!
On Tuesday, 1 August 2017 at 14:29:28 UTC, Adam D. Ruppe wrote: So we can keep the search path: `datetime.di`, then `datetime.d`, then `datetime/package.d`, and any one of them, as long as it has `module std.datetime;` at the top, can count equally as the package.d. Sorry, isn't that how things work now? The problem here is that the compiler picks up the OLD datetime.d, and then things fail at the linking stage because symbols in the old datetime.d are not present in the new phobos.lib.
Re: How to build GUI-based applications in D ?
On Tuesday, 1 August 2017 at 09:39:36 UTC, Daniel Kozak wrote: https://www.youtube.com/watch?v=5eUL8Z9AFW0 https://github.com/buggins/dlangui thank you Daniel. i have tried Dlangui previously and had no luck. but this time i could successfully compile my first app. now, i can say level zero created. i couldn't set control's width and height (Button widget) shows error. maybe it works a different way. i used the following code instead, but no effect. // create some widget to show in window auto button1 = new Button("btn1", "OK"d).margins(50); button1.minWidth = 200; button1.minHeight = 50; button1.maxWidth = 201; button1.maxHeight = 51; also i couldn't compile dlangide. it shows error like every time before: D:\ashit\software\D Compiler\DlangUI\dlangide-master>dub run Performing "debug" build using dmd for x86. emsi_containers 0.5.3: target for configuration "library" is up to date. libdparse 0.7.1-beta.7: building configuration "library"... C:\Users\axar\AppData\Roaming\dub\packages\libdparse-0.7.1beta.7\libdparse\src\ dparse\lexer.d(1789,12): Error: module std.math import 'nextPow2' not found dmd failed with exit code 1.
Re: gtk arch issues
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: It makes me sick!
On 8/1/17 10:29 AM, Adam D. Ruppe wrote: On Tuesday, 1 August 2017 at 14:20:00 UTC, Steven Schveighoffer wrote: But the fix here is to fix the bizarre package.d design. Don't break the zip for cases like mine where adding files is a key feature of it. How should it be fixed? Well, my preference would be to treat it just like any other module: the compiler has a search path, but if it opens a file, the module name is definitive. So we can keep the search path: `datetime.di`, then `datetime.d`, then `datetime/package.d`, and any one of them, as long as it has `module std.datetime;` at the top, can count equally as the package.d. I don't remember the reason why we can't just have foo/... and foo.d and needed to use foo/package.d to do this. It does fail to compile though if I use foo.d instead of package.d: foo/bar.d(1): Error: package name 'foo' conflicts with usage as a module name in file foo.d BTW I kinda want to put `datetime/package.d` first on the search path, but I fear that'd hurt the speed of the normal case (every import would mean 2 file not found queries until it actually finds the common `file.d`)... but it might be worth investigating if we do want to prefer it. Either way, you now have a file that is completely ignored, which is going to confuse someone. I actually think the only "fix" at the moment is to error when both are present, since the compiler can't be sure which one is correct. So we are stuck with at least trying to find a package file. I don't see the speed of opening two files being a huge issue for compilation. Anyway, if package.d is just like any other module, if we want to break up a module, then you can keep the existing file, with the existing module declaration, and just start moving stuff out. You wouldn't have to literally create a package.d file, you can just keep using your existing module.d file. I'm sure there's a reason why it's this way, but I don't know what it is. Anyone remember? -Steve
Re: How to build GUI-based applications in D ?
On Tuesday, 1 August 2017 at 09:31:32 UTC, ashit wrote: what is the simplest library to create gui applications in D? i want to create gui applications but couldnt configure the tools so far. [snip] I recommend you check out the D widget toolkit (DWT). DWT is a library for creating cross-platform GUI applications. It's a port of the SWT Java library from Eclipse. The key advantages of DWT are; 1. Extensive API and examples from SWT that can be searched with your Browser 2. Statically linked (don't need an external DLL) 3. Easy to learn and use Here is the dub package for DWT: https://code.dlang.org/packages/dwtlib See more features in the DWT forum: https://forum.dlang.org/group/dwt Here are the various GUIs for the D language: https://wiki.dlang.org/GUI_Libraries
Re: It makes me sick!
On Tuesday, 1 August 2017 at 14:20:00 UTC, Steven Schveighoffer wrote: But the fix here is to fix the bizarre package.d design. Don't break the zip for cases like mine where adding files is a key feature of it. How should it be fixed? Well, my preference would be to treat it just like any other module: the compiler has a search path, but if it opens a file, the module name is definitive. So we can keep the search path: `datetime.di`, then `datetime.d`, then `datetime/package.d`, and any one of them, as long as it has `module std.datetime;` at the top, can count equally as the package.d. BTW I kinda want to put `datetime/package.d` first on the search path, but I fear that'd hurt the speed of the normal case (every import would mean 2 file not found queries until it actually finds the common `file.d`)... but it might be worth investigating if we do want to prefer it. Anyway, if package.d is just like any other module, if we want to break up a module, then you can keep the existing file, with the existing module declaration, and just start moving stuff out. You wouldn't have to literally create a package.d file, you can just keep using your existing module.d file.
Re: Convert ResultSet to List of Associted Array
On Tuesday, 1 August 2017 at 14:14:57 UTC, Steven Schveighoffer wrote: On 8/1/17 10:14 AM, Steven Schveighoffer wrote: On 7/30/17 1:02 PM, Jshah wrote: On Sunday, 30 July 2017 at 16:39:05 UTC, Jshah wrote: Hi I am new to D writing a web service with vibe. My webservice connect to mysql and return the result as JSON. How do I convert resultset to Array of Associated Array [["col1" : value, "col2" : value], ] I am using mysql-native Variant[string][] realresult; realresult.reserve(resultset.length); while(!resultset.empty) { realresult ~= resultset.asAA; resultset.popFront(); // forgot this. } -Steve Thanks It is working
Re: It makes me sick!
On 7/29/17 3:51 PM, Adam D. Ruppe wrote: But the fix here is to fix the bizarre package.d design. Don't break the zip for cases like mine where adding files is a key feature of it. How should it be fixed? -Steve
Re: Convert ResultSet to List of Associted Array
On 8/1/17 10:14 AM, Steven Schveighoffer wrote: On 7/30/17 1:02 PM, Jshah wrote: On Sunday, 30 July 2017 at 16:39:05 UTC, Jshah wrote: Hi I am new to D writing a web service with vibe. My webservice connect to mysql and return the result as JSON. How do I convert resultset to Array of Associated Array [["col1" : value, "col2" : value], ] I am using mysql-native Variant[string][] realresult; realresult.reserve(resultset.length); while(!resultset.empty) { realresult ~= resultset.asAA; resultset.popFront(); // forgot this. } -Steve
Re: Convert ResultSet to List of Associted Array
On 7/30/17 1:02 PM, Jshah wrote: On Sunday, 30 July 2017 at 16:39:05 UTC, Jshah wrote: Hi I am new to D writing a web service with vibe. My webservice connect to mysql and return the result as JSON. How do I convert resultset to Array of Associated Array [["col1" : value, "col2" : value], ] I am using mysql-native Variant[string][] realresult; realresult.reserve(resultset.length); while(!resultset.empty) { realresult ~= resultset.asAA; } -Steve
Re: why won't byPair work with a const AA?
On 7/30/17 12:19 AM, Matthew Gamble wrote: I have a class member function from which I'm trying to return a sorted array of key, value tuples stored in an associative array as a private member. The member function should be able to be marked const to prevent the AA from being modified. I have reduced the problem to the simple case below which won't compile with DMD v2.072.2. import std.array; import std.algorithm; class A { this() { aa = ["a":1, "b" : 2, "c" : 3]; } auto pairs() @property const { return aa.byPair.array.sort().release; } private: int[string] aa; } If I remove const from the pairs function it compiles fine. I'm just not sure this is a behavior I want. Any help/recommendation would be appreciated. byPair must store a pointer to the data in the AA. If you mark the AA const, then it must store a const pointer to AA data. However, because we don't have tail modifiers, you can't construct just one range that would make this work. We would need many different ranges, one for each flavor of mutability. So you are stuck doing what Ali recommended -- cast away the const. In this case, no harm comes if you don't cast back to const (since the value of the AA is `int`), but in general this solution isn't valid if the value type contains references. -Steve
Re: sharedLog between dll
On 01/08/2017 11:27 AM, Domain wrote: On Tuesday, 1 August 2017 at 09:06:39 UTC, rikki cattermole wrote: On 01/08/2017 9:28 AM, Domain wrote: I want to redirect the sharedLog to my logger in one dll, and all dlls will use the new one. What should I do? sharedLog = new MyLogger(); // this will not change the logger in other dll You said the magic phrase, DLL. Can't share e.g. classes between dll/host[0]. [0] https://issues.dlang.org/show_bug.cgi?id=4071 That issue is reported 7 years ago! I think DLL support should be a basic feature. And I think the core team spend too little time on those features which will block the usage of D in the real world. I have to reconsider using C++ instead. Please email Walter about this. It works everywhere else.
Re: sharedLog between dll
On Tuesday, 1 August 2017 at 09:06:39 UTC, rikki cattermole wrote: On 01/08/2017 9:28 AM, Domain wrote: I want to redirect the sharedLog to my logger in one dll, and all dlls will use the new one. What should I do? sharedLog = new MyLogger(); // this will not change the logger in other dll You said the magic phrase, DLL. Can't share e.g. classes between dll/host[0]. [0] https://issues.dlang.org/show_bug.cgi?id=4071 That issue is reported 7 years ago! I think DLL support should be a basic feature. And I think the core team spend too little time on those features which will block the usage of D in the real world. I have to reconsider using C++ instead.
Re: How to build GUI-based applications in D ?
I use GtkD (with GStreamerD) for my GUI applications written in D. https://gtkd.org/ On Tue, 2017-08-01 at 09:31 +, ashit via Digitalmars-d-learn wrote: > what is the simplest library to create gui applications in D? > i want to create gui applications but couldnt configure the tools > so far. > i tried to install DFL several times, but it shows some errors > while installing (that bold red lables showing : depreacated, > depreacated, ... ) > > i dont need to build something advanced or so, only that common > and simple elements like: buttons, labels, textboxs, ... > > i really like D's syntax (C, C++, C#), but i have nothing to do > with command line. > the good thing about C# (& WPF) is: double click on installer, > start design your app. > -- Russel. = Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.win...@ekiga.net 41 Buckmaster Roadm: +44 7770 465 077 xmpp: rus...@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder signature.asc Description: This is a digitally signed message part
Re: How to build GUI-based applications in D ?
ashit wrote: what is the simplest library to create gui applications in D? i want to create gui applications but couldnt configure the tools so far. i tried to install DFL several times, but it shows some errors while installing (that bold red lables showing : depreacated, depreacated, ... ) i dont need to build something advanced or so, only that common and simple elements like: buttons, labels, textboxs, ... i really like D's syntax (C, C++, C#), but i have nothing to do with command line. the good thing about C# (& WPF) is: double click on installer, start design your app. Adam Ruppe has minigui in his arsd[0] repo. and minigui_xml to make interface creation easier. it is not really well-documented yet, tho, so you will prolly have to figure some things on your own. [0] https://github.com/adamdruppe/arsd
Re: How to build GUI-based applications in D ?
https://www.youtube.com/watch?v=5eUL8Z9AFW0 https://github.com/buggins/dlangui On Tue, Aug 1, 2017 at 11:31 AM, ashit via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > what is the simplest library to create gui applications in D? > i want to create gui applications but couldnt configure the tools so far. > i tried to install DFL several times, but it shows some errors while > installing (that bold red lables showing : depreacated, depreacated, ... ) > > i dont need to build something advanced or so, only that common and simple > elements like: buttons, labels, textboxs, ... > > i really like D's syntax (C, C++, C#), but i have nothing to do with > command line. > the good thing about C# (& WPF) is: double click on installer, start > design your app. > >
How to build GUI-based applications in D ?
what is the simplest library to create gui applications in D? i want to create gui applications but couldnt configure the tools so far. i tried to install DFL several times, but it shows some errors while installing (that bold red lables showing : depreacated, depreacated, ... ) i dont need to build something advanced or so, only that common and simple elements like: buttons, labels, textboxs, ... i really like D's syntax (C, C++, C#), but i have nothing to do with command line. the good thing about C# (& WPF) is: double click on installer, start design your app.
Re: sharedLog between dll
On 01/08/2017 9:28 AM, Domain wrote: I want to redirect the sharedLog to my logger in one dll, and all dlls will use the new one. What should I do? sharedLog = new MyLogger(); // this will not change the logger in other dll You said the magic phrase, DLL. Can't share e.g. classes between dll/host[0]. [0] https://issues.dlang.org/show_bug.cgi?id=4071
sharedLog between dll
I want to redirect the sharedLog to my logger in one dll, and all dlls will use the new one. What should I do? sharedLog = new MyLogger(); // this will not change the logger in other dll