Re: GTKD - Application crashes - or not? [Coedit]

2016-06-17 Thread TheDGuy via Digitalmars-d-learn

On Friday, 17 June 2016 at 06:18:59 UTC, Basile B. wrote:

On Thursday, 16 June 2016 at 09:18:54 UTC, TheDGuy wrote:

On Thursday, 16 June 2016 at 08:20:00 UTC, Basile B. wrote:
Yes it's "WorkingDirectory" (and not current...). But 
otherwise you can use args[0]. Actually using the cwd in a 
program is often an error because there is no guarantee that 
the cwd is the path to the application ;)


People often forget that (Generally speaking).


If i use args[0] as workingDirectory i still get the same 
error. I created a custom Tool like this:


https://picload.org/image/rgwapdac/coedit_run_options.png

if i execute it via "Custom Tools" -> "Run this project" 
nothing happens.


There was a bug I've fixed yesterday. There's a workaround: 
this would have worked when the tool option "clearMessages" is 
checked.


Thanks a lot!


Re: GTKD - Application crashes - or not? [Coedit]

2016-06-17 Thread Basile B. via Digitalmars-d-learn

On Thursday, 16 June 2016 at 09:18:54 UTC, TheDGuy wrote:

On Thursday, 16 June 2016 at 08:20:00 UTC, Basile B. wrote:
Yes it's "WorkingDirectory" (and not current...). But 
otherwise you can use args[0]. Actually using the cwd in a 
program is often an error because there is no guarantee that 
the cwd is the path to the application ;)


People often forget that (Generally speaking).


If i use args[0] as workingDirectory i still get the same 
error. I created a custom Tool like this:


https://picload.org/image/rgwapdac/coedit_run_options.png

if i execute it via "Custom Tools" -> "Run this project" 
nothing happens.


There was a bug I've fixed yesterday. There's a workaround: this 
would have worked when the tool option "clearMessages" is checked.


Re: GTKD - Application crashes - or not? [Coedit]

2016-06-16 Thread TheDGuy via Digitalmars-d-learn

On Thursday, 16 June 2016 at 17:44:08 UTC, Basile B. wrote:

Please Stop your comedy.


Thanks a lot for your help!
This is my solution:

import gtk.Main;
import gtk.MainWindow;
import gtk.CssProvider;
import gtk.Button;
import gdk.Display;
import gdk.Screen;
import gtk.StyleContext;
import glib.GException;
import std.stdio;
import std.file;
import std.path;

class Window : MainWindow{
this(int width, int height, string title, string wd){
super(title);
setDefaultSize(width, height);
Button btn = new Button("Test");
btn.setName("CssName");

string cssPath = dirName(wd) ~ "\\" ~ "test.css";

CssProvider provider = new CssProvider();
provider.loadFromPath(cssPath);

Display display = Display.getDefault();
Screen screen = display.getDefaultScreen();
StyleContext.addProviderForScreen(screen, provider, 
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);


add(btn);
showAll();
}
}

void main(string[] args){
Main.init(args);
auto win = new Window(250,250,"Tutorial", args[0]);
Main.run();
}


Re: GTKD - Application crashes - or not? [Coedit]

2016-06-16 Thread Basile B. via Digitalmars-d-learn

On Thursday, 16 June 2016 at 15:57:36 UTC, TheDGuy wrote:

On Thursday, 16 June 2016 at 10:14:47 UTC, Basile B. wrote:


from args[0] you can get the base bath and since your css is 
relative to the base path:


string cssPath = "test.css";
CssProvider provider = new CssProvider();
provider.loadFromPath(cssPath);


add something like

import std.path;
basePath = args[0].dirName;

string cssPath = basePath ~ "\" ~ "test.css";

and you can remove all the stuff in the Run options.


But i don't call my CSS file in the main-function but instead i 
call it in the MainWindow:


import gtk.Main;
import gtk.MainWindow;
import gtk.CssProvider;
import gtk.Button;
import gdk.Display;
import gdk.Screen;
import gtk.StyleContext;
import glib.GException;

class Window : MainWindow{
this(int width, int height, string title){
super(title);
setDefaultSize(width, height);
Button btn = new Button("Test");
btn.setName("CssName");

string cssPath = "test.css";

CssProvider provider = new CssProvider();
provider.loadFromPath(cssPath);

Display display = Display.getDefault();
Screen screen = display.getDefaultScreen();
StyleContext.addProviderForScreen(screen, provider, 
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);


add(btn);
showAll();
}
}

void main(string[] args){
Main.init(args);
auto win = new Window(250,250,"Tutorial");
Main.run();
}


Please Stop your comedy.


Re: GTKD - Application crashes - or not? [Coedit]

2016-06-16 Thread TheDGuy via Digitalmars-d-learn

On Thursday, 16 June 2016 at 10:14:47 UTC, Basile B. wrote:


from args[0] you can get the base bath and since your css is 
relative to the base path:


string cssPath = "test.css";
CssProvider provider = new CssProvider();
provider.loadFromPath(cssPath);


add something like

import std.path;
basePath = args[0].dirName;

string cssPath = basePath ~ "\" ~ "test.css";

and you can remove all the stuff in the Run options.


But i don't call my CSS file in the main-function but instead i 
call it in the MainWindow:


import gtk.Main;
import gtk.MainWindow;
import gtk.CssProvider;
import gtk.Button;
import gdk.Display;
import gdk.Screen;
import gtk.StyleContext;
import glib.GException;

class Window : MainWindow{
this(int width, int height, string title){
super(title);
setDefaultSize(width, height);
Button btn = new Button("Test");
btn.setName("CssName");

string cssPath = "test.css";

CssProvider provider = new CssProvider();
provider.loadFromPath(cssPath);

Display display = Display.getDefault();
Screen screen = display.getDefaultScreen();
StyleContext.addProviderForScreen(screen, provider, 
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);


add(btn);
showAll();
}
}

void main(string[] args){
Main.init(args);
auto win = new Window(250,250,"Tutorial");
Main.run();
}


Re: GTKD - Application crashes - or not? [Coedit]

2016-06-16 Thread Basile B. via Digitalmars-d-learn

On Thursday, 16 June 2016 at 10:02:01 UTC, TheDGuy wrote:

On Thursday, 16 June 2016 at 09:27:38 UTC, Basile B. wrote:
FOrget any previous comment and in your program use the first 
argument of the command line to detect your resources, this 
will solve your problem. For the execution click compile and 
run or just run.


Okay:

void main(string[] args){
writeln(args[0]);
Main.init(args);
auto win = new Window(250,250,"Tutorial");
Main.run();
}

This gives me the location of the .exe. What should i do with 
it now?


On Win and Nux, the first argument of the command line is 
always the program filename so you just have to get the 
directory for this string and you'll get what you expected 
with cwd.


I don't care about cwd i want to get rid of the error!


from args[0] you can get the base bath and since your css is 
relative to the base path:


string cssPath = "test.css";
CssProvider provider = new CssProvider();
provider.loadFromPath(cssPath);


add something like

import std.path;
basePath = args[0].dirName;

string cssPath = basePath ~ "\" ~ "test.css";

and you can remove all the stuff in the Run options.



Re: GTKD - Application crashes - or not? [Coedit]

2016-06-16 Thread TheDGuy via Digitalmars-d-learn

On Thursday, 16 June 2016 at 09:27:38 UTC, Basile B. wrote:
FOrget any previous comment and in your program use the first 
argument of the command line to detect your resources, this 
will solve your problem. For the execution click compile and 
run or just run.


Okay:

void main(string[] args){
writeln(args[0]);
Main.init(args);
auto win = new Window(250,250,"Tutorial");
Main.run();
}

This gives me the location of the .exe. What should i do with it 
now?


On Win and Nux, the first argument of the command line is 
always the program filename so you just have to get the 
directory for this string and you'll get what you expected with 
cwd.


I don't care about cwd i want to get rid of the error!




Re: GTKD - Application crashes - or not? [Coedit]

2016-06-16 Thread Basile B. via Digitalmars-d-learn

On Thursday, 16 June 2016 at 09:18:54 UTC, TheDGuy wrote:

On Thursday, 16 June 2016 at 08:20:00 UTC, Basile B. wrote:
Yes it's "WorkingDirectory" (and not current...). But 
otherwise you can use args[0]. Actually using the cwd in a 
program is often an error because there is no guarantee that 
the cwd is the path to the application ;)


People often forget that (Generally speaking).


If i use args[0] as workingDirectory i still get the same 
error. I created a custom Tool like this:


https://picload.org/image/rgwapdac/coedit_run_options.png

if i execute it via "Custom Tools" -> "Run this project" 
nothing happens.


FOrget any previous comment and in your program use the first 
argument of the command line to detect your resources, this will 
solve your problem. For the execution click compile and run or 
just run.


On Win and Nux, the first argument of the command line is always 
the program filename so you just have to get the directory for 
this string and you'll get what you expected with cwd.


Re: GTKD - Application crashes - or not? [Coedit]

2016-06-16 Thread TheDGuy via Digitalmars-d-learn

On Thursday, 16 June 2016 at 08:20:00 UTC, Basile B. wrote:
Yes it's "WorkingDirectory" (and not current...). But otherwise 
you can use args[0]. Actually using the cwd in a program is 
often an error because there is no guarantee that the cwd is 
the path to the application ;)


People often forget that (Generally speaking).


If i use args[0] as workingDirectory i still get the same error. 
I created a custom Tool like this:


https://picload.org/image/rgwapdac/coedit_run_options.png

if i execute it via "Custom Tools" -> "Run this project" nothing 
happens.


Re: GTKD - Application crashes - or not? [Coedit]

2016-06-16 Thread Basile B. via Digitalmars-d-learn

On Thursday, 16 June 2016 at 07:51:14 UTC, TheDGuy wrote:

On Thursday, 16 June 2016 at 07:50:13 UTC, TheDGuy wrote:
I get 'Failed to execute: 267'. Probably because a symbolic 
string is used in the run options?

https://picload.org/upload,8e3f683557a8cd3401f002304f387932.html


That is the correct image link: 
https://img1.picload.org/image/rgwaopli/coedit_run_options.png


Yes it's "WorkingDirectory" (and not current...). But otherwise 
you can use args[0]. Actually using the cwd in a program is often 
an error because there is no guarantee that the cwd is the path 
to the application ;)


People often forget that (Generally speaking).


Re: GTKD - Application crashes - or not? [Coedit]

2016-06-16 Thread TheDGuy via Digitalmars-d-learn

On Thursday, 16 June 2016 at 00:46:44 UTC, Basile B. wrote:

On Wednesday, 15 June 2016 at 23:41:51 UTC, Basile B. wrote:


- You can create a launcher in the custom tools, excluding the 
double quote:

- as executable type ""
- as CurrentDirectory type ""
- as alias put something like "Run this project"
This will work if the binary is compiled in the same directory 
as the binary that's produced. Otherwise you can adjust by 
adding directories after the symbol. (e.g  "bin\release").



You just need to change "CurrentDirectory" in the "Run options".


Hm, i don't see "CurrentDirectory" in the run options tab:
https://picload.org/image/rgwaopad/coedit_run_options.png

- I had to verify but the cwd should really be set to the path 
where the application is output. I mean that it's written so. I 
don't know what's happening on your system right now. My 
windows is still win 7 and my dev directory is not in 
ProgramFiles.


Everything worked fine for the last projects but as soon as i 
tried to customize buttons with CSS something is wrong. I just 
store the Coedit-Program in "ProgramFiles" (because every program 
i have installed is located there). For my projects i usually use 
the "document" folder of my user where the ".exe" and ".d" - 
files are stored.


And I've tested using this simple project: 
https://gist.github.com/BBasile/2e110ed48989b53e2a53b57977a81736. You can DL it as a >zip, open the .ce file as a project and click "compile project and run" you should see >the right CWD written in the messages.


I get 'Failed to execute: 267'. Probably because a symbolic 
string is used in the run options?

https://picload.org/upload,8e3f683557a8cd3401f002304f387932.html





Re: GTKD - Application crashes - or not? [Coedit]

2016-06-16 Thread TheDGuy via Digitalmars-d-learn

On Thursday, 16 June 2016 at 07:50:13 UTC, TheDGuy wrote:
I get 'Failed to execute: 267'. Probably because a symbolic 
string is used in the run options?

https://picload.org/upload,8e3f683557a8cd3401f002304f387932.html


That is the correct image link: 
https://img1.picload.org/image/rgwaopli/coedit_run_options.png


Re: GTKD - Application crashes - or not? [Coedit]

2016-06-15 Thread Basile B. via Digitalmars-d-learn

On Wednesday, 15 June 2016 at 23:41:51 UTC, Basile B. wrote:

On Wednesday, 15 June 2016 at 17:35:32 UTC, TheDGuy wrote:
I'm gonna check on Windows today but in the meantime you can try



I've checked on windows and here is what I can say about the 
problem.


- Symbolic strings won't work on the "CurrentDirectoy" parameter. 
This is not handled at all. (you would get an error 267). I'll 
add the translation code for this parameter but this is for 
version 3 so not soon.


- I had to verify but the cwd should really be set to the path 
where the application is output. I mean that it's written so. I 
don't know what's happening on your system right now. My windows 
is still win 7 and my dev directory is not in ProgramFiles. And 
I've tested using this simple project: 
https://gist.github.com/BBasile/2e110ed48989b53e2a53b57977a81736. 
You can DL it as a zip, open the .ce file as a project and click 
"compile project and run" you should see the right CWD written in 
the messages.


- You can create a launcher in the custom tools, excluding the 
double quote:

- as executable type ""
- as CurrentDirectory type ""
- as alias put something like "Run this project"
This will work if the binary is compiled in the same directory as 
the binary that's produced. Otherwise you can adjust by adding 
directories after the symbol. (e.g  "bin\release").


Re: GTKD - Application crashes - or not? [Coedit]

2016-06-15 Thread Basile B. via Digitalmars-d-learn

On Wednesday, 15 June 2016 at 17:35:32 UTC, TheDGuy wrote:
On Wednesday, 15 June 2016 at 13:15:56 UTC, Rene Zwanenburg 
wrote:
I'm not familiar with Coedit, but the run options seem to 
contain a field for setting it:

https://github.com/BBasile/Coedit/wiki#run-options

You may be able to use the symbolic strings there:
https://github.com/BBasile/Coedit/wiki#symbolic-strings


I changed the working directory in the native project 
configuration in "Pre-build process", "Post-build process" and 
in "Run options" in "default", "debug" and "release" to:


You just need to change "CurrentDirectory" in the "Run options". 
The two others are for the process that's executed before and 
after compiling.


I'm gonna check on Windows today but in the meantime you can try

- sets the output path to to a value that's different from the 
project file location, e.g bin/name.exe and remove completly the 
value you've set in "Run Options"\"CurrentDirectory"
- add a trailing back slash to the value in the "Run 
Options"\"CurrentDirectory"




Re: GTKD - Application crashes - or not? [Coedit]

2016-06-15 Thread TheDGuy via Digitalmars-d-learn

On Wednesday, 15 June 2016 at 13:15:56 UTC, Rene Zwanenburg wrote:
I'm not familiar with Coedit, but the run options seem to 
contain a field for setting it:

https://github.com/BBasile/Coedit/wiki#run-options

You may be able to use the symbolic strings there:
https://github.com/BBasile/Coedit/wiki#symbolic-strings


I changed the working directory in the native project 
configuration in "Pre-build process", "Post-build process" and in 
"Run options" in "default", "debug" and "release" to:


C:\Users\Standardbenutzer\Documents\Dlang_Projects

but i still get:

glib.GException.GException@..\..\..\AppData\Roaming\dub\packages\gtk-d-3.3.1\gtk-d\src\glib\GException.d(40):
 Failed to import: No such file or directory

0x0045C39D
0x00402094
0x00402120
0x00403FC7
0x00403EC8
0x00402557
0x740F38F4 in BaseThreadInitThunk
0x76F85DE3 in RtlUnicodeStringToInteger
0x76F85DAE in RtlUnicodeStringToInteger
error: the process 
(C:\Users\Standardbenutzer\Documents\Dlang_Projects\GTKD_Test.exe) has returned the signal 1






Re: GTKD - Application crashes - or not? [Coedit]

2016-06-15 Thread Rene Zwanenburg via Digitalmars-d-learn

On Wednesday, 15 June 2016 at 10:31:18 UTC, TheDGuy wrote:
Thanks a lot for your answer, getcwd() returns the path where 
coedit is located on my harddrive:

C:\Program Files (x86)\Coedit_32\coedit.2update6.win32

How can i change that?


I'm not familiar with Coedit, but the run options seem to contain 
a field for setting it:

https://github.com/BBasile/Coedit/wiki#run-options

You may be able to use the symbolic strings there:
https://github.com/BBasile/Coedit/wiki#symbolic-strings


Re: GTKD - Application crashes - or not? [Coedit]

2016-06-15 Thread TheDGuy via Digitalmars-d-learn

On Wednesday, 15 June 2016 at 10:21:20 UTC, Rene Zwanenburg wrote:

On Wednesday, 15 June 2016 at 09:48:19 UTC, TheDGuy wrote:
But if i execute the app my hand (in the windows command 
window or my double click) it works as expected (so no error)? 
Why is that?


My first guess would be that Coedit does not use the directory 
where the executable is located as working directory. You can 
check what getcwd returns:

https://dlang.org/phobos/std_file.html#.getcwd


Thanks a lot for your answer, getcwd() returns the path where 
coedit is located on my harddrive:

C:\Program Files (x86)\Coedit_32\coedit.2update6.win32

How can i change that?


Re: GTKD - Application crashes - or not? [Coedit]

2016-06-15 Thread Rene Zwanenburg via Digitalmars-d-learn

On Wednesday, 15 June 2016 at 09:48:19 UTC, TheDGuy wrote:
But if i execute the app my hand (in the windows command window 
or my double click) it works as expected (so no error)? Why is 
that?


My first guess would be that Coedit does not use the directory 
where the executable is located as working directory. You can 
check what getcwd returns:

https://dlang.org/phobos/std_file.html#.getcwd


GTKD - Application crashes - or not? [Coedit]

2016-06-15 Thread TheDGuy via Digitalmars-d-learn

Hi,
this is my app:

import gtk.Main;
import gtk.MainWindow;
import gtk.CssProvider;
import gdk.Display;
import gdk.Screen;
import gtk.StyleContext;
import glib.GException;

class Window : MainWindow{
this(int width, int height, string title){
super(title);
setDefaultSize(width, height);

string cssPath = "test.css";

CssProvider provider = new CssProvider();
provider.loadFromPath(cssPath);

Display display = Display.getDefault();
Screen screen = display.getDefaultScreen();
StyleContext.addProviderForScreen(screen, provider, 
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);


showAll();
}
}

void main(string[] args){
Main.init(args);
auto win = new Window(250,250,"Tutorial");
Main.run();
}

I use Coedit to write and execute D apps. If i execute this app i 
get the error message (it compiles fine):


glib.GException.GException@..\..\..\AppData\Roaming\dub\packages\gtk-d-3.3.1\gtk-d\src\glib\GException.d(40):
 Failed to import: No such file or directory

0x00430569
0x00402065
0x004020D8
0x0040275F
0x00402660
0x004020F7
0x740F38F4 in BaseThreadInitThunk
0x76F85DE3 in RtlUnicodeStringToInteger
0x76F85DAE in RtlUnicodeStringToInteger
error: the process 
(C:\Users\Standardbenutzer\Documents\Dlang_Projects\GTKD_Test.exe) has returned the signal 1


But if i execute the app my hand (in the windows command window 
or my double click) it works as expected (so no error)? Why is 
that?