June 16, 2016
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.
June 16, 2016
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.
June 16, 2016
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!


June 16, 2016
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.

June 16, 2016
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();
}
June 16, 2016
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.
June 16, 2016
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();
}
June 17, 2016
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.
June 17, 2016
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!
1 2
Next ›   Last »