Sign up

GtkD Version vs. GTK Version?

Hi Mike,
Since the subject of wrapper versions has come up again...

Which version of GTK does the latest GtkD version correspond with?

I ask because I'm wondering if we have access to the 3.96 updates that reflect 4.0 changes.

If not, are there plans to sync up GtkD to either 3.96 or 4.x?

Re: GtkD Version vs. GTK Version?

On 18-05-2019 11:45, Ron Tarrant wrote:

Hi Mike,
Since the subject of wrapper versions has come up again...

Which version of GTK does the latest GtkD version correspond with?

I ask because I'm wondering if we have access to the 3.96 updates that reflect 4.0 changes.

If not, are there plans to sync up GtkD to either 3.96 or 4.x?

The current release of GtkD is based on GTK 3.22, and git master is at 3.24.

The plan is to break up GtkD into smaller libraries, like what has
already been done for GLib an ATK, and than support both GTK 3.X and 4.X
as separate libraries.

Re: GtkD Version vs. GTK Version?

On Sat, 18 May 2019 13:04:16 +0200, Mike Wey wrote:

The plan is to break up GtkD into smaller libraries, like what has
already been done for GLib an ATK, and than support both GTK 3.X and 4.X
as separate libraries.

Okay, thanks.

Re: GtkD Version vs. GTK Version?

On Sat, 18 May 2019 13:04:16 +0200, Mike Wey wrote:

The current release of GtkD is based on GTK 3.22, and git master is at 3.24.

On a related topic...

How can I find out which features are implemented and which aren't? Is it a matter of digging through the source, or is there another way?

As to 'the source' I'm assuming there's something other than the generated wrapper code? (I really don't know how these wrapper things work.)

Re: GtkD Version vs. GTK Version?

On Sun, 19 May 2019 10:29:54 GMT, Ron Tarrant wrote:

How can I find out which features are implemented and which aren't? Is it a matter of digging through the source, or is there another way?

Forgot to say...

The reason I ask: I'm digging into using CSS and I've had some success with setting colors and fonts for Labels, but for Buttons, I can only affect the font, not the colors, and I'm wondering if it's because not all the CSS properties/attributes are available for the Button widget.

I also can't seem to set the background-color for a window, either.

And that got me wondering about what else hasn't been implemented... if that is that case.

Here's the D code:

// Test Rig Foundation for Learning GtkD Coding

import std.stdio;

import gtk.MainWindow;
import gtk.Main;
import gtk.Box;
import gtk.Widget;
import gtk.Button;
import gtk.Label;
import gtk.CssProvider;
import gtk.StyleContext;
import gdk.Screen;

void main(string[] args)
{
	Main.init(args);

	TestRigWindow myTestRig = new TestRigWindow("Test Rig");
	
	Main.run();
	
} // main()


class TestRigWindow : MainWindow
{
	AppBox appBox;
	string cssName = "mywindow";
	Screen screen;
	CssProvider cssProvider;
	string cssFile = "./theme.css";
	StyleContext styleContext;
	
	this(string title)
	{
		super(title);
		setName(cssName);
		writeln("window name: ", getName());

		screen = getScreen();
		
		cssProvider = new CssProvider();
		cssProvider.loadFromPath(cssFile);
		
		styleContext = new StyleContext();
		styleContext.addProviderForScreen(screen, cssProvider, STYLE_PROVIDER_PRIORITY_FALLBACK);

		addOnDestroy(&quitApp);
		
		appBox = new AppBox();
		add(appBox);
		
		showAll();

	} // this() CONSTRUCTOR
	
		
	void quitApp(Widget widget)
	{
		writeln("Bye.");
		Main.quit();
		
	} // quitApp()

} // class myAppWindow


class AppBox : Box
{
	CSSButton cssButton1, cssButton2;
	CSSLabel cssLabel1, cssLabel2, cssLabel3;
	string button1Text = "CSS Button 1", button2Text = "CSS Button 2";
	string button1CSSName = "button1", button2CSSName = "button2";
	string label1Text = "Hello 1", label2Text = "Hello 2 U", label3Text = "Hello 3";
	string label1CSSName = "label1", label2CSSName = "label2",label3CSSName = "label3";
	
	this()
	{
		super(Orientation.VERTICAL, 25);
		
		cssButton1 = new CSSButton(button1Text, button1CSSName);
		cssLabel1 = new CSSLabel(label1Text, label1CSSName);
		cssLabel2 = new CSSLabel(label2Text, label2CSSName);
		cssLabel3 = new CSSLabel(label3Text, label3CSSName);
		cssButton2 = new CSSButton(button2Text, button2CSSName);
		
		setHomogeneous(true);

		// packStart(<child object>, false, false, 0); // LEFT justify
		add(cssButton1);
		add(cssLabel1);
		add(cssLabel2);
		add(cssLabel3);
		add(cssButton2);
				
		// packEnd(<child object>, false, false, 0); // RIGHT justify
		
	} // this()

} // class AppBox


class CSSButton : Button
{
	this(string textLabel, string cssName)
	{
		super(textLabel);
		setName(cssName);
		
	} // this()
	
} // class CSSButton


class CSSLabel : Label
{
	this(string textLabel, string cssName)
	{
		super(textLabel);
		setName(cssName);
		
	} // this()
	
} // class CSSLabel

And here's my CSS file (saved as theme.css in the same folder):

#mywindow
{
	font-family: "Times New Roman";
	font-size: 12px;
	background-color: rgba(233,23,34,1);
}

button.text-button#button2
{
	color: green;
	background-color: blue;
	font-family: "Bodoni MT";
	font-size: 20px;
	text-decoration: underline;
}

button.text-button#button1
{
	font-family: "Comic Sans MS";
	font-size: 16px;
	color: red;
	background-color: yellow;
}

label#label1
{
	font-family: "Times New Roman";
	color: red;
	background-color: yellow;
}

label#label2
{
	color: green;
	background-color: yellow;
}

label#label3
{
	color: blue;
	background-color: yellow;
}

Of those attributes I've tested, here's what works:

  • for Labels:
    -- font-family,
    -- color,
    -- background-color,
    -- font-size,
  • for Buttons:
    -- font-family,
    -- font-size,

And from what I've tested so far, here's what does NOT work:

  • Window:
    -- font-family,
    -- font-size,
    -- background-color.

Although I'm really not sure where I would see CSS font changes in a Window... the titlebar?

According to the examples I've been able to find for other languages, the background-color should be the background of the Window. I tried one example with just a Window and nothing else and the background-color setting still does nothing. Oh. And I tried both named colors (ie. blue, green) as well as the rgba() form. Same results.

And neither do these:

  • Button:
    -- color,
    -- background-color,
    -- text-decoration.

Re: GtkD Version vs. GTK Version?

On Sun, 19 May 2019 11:04:26 GMT, Ron Tarrant wrote:

On Sun, 19 May 2019 10:29:54 GMT, Ron Tarrant wrote:

I found a solution in an example on the D forum.

I won't outline the details of the changes I made, but here's the updated code for future reference. I will make this one cautionary note:

This is only a test. This code makes for one ugly demo. Use at your own risk. May cause disturbing nightmares or afterimages.

// Test Rig Foundation for Learning GtkD Coding

import std.stdio;

import gtk.MainWindow;
import gtk.Main;
import gtk.Box;
import gtk.Widget;
import gtk.Button;
import gtk.Label;
import gtk.CssProvider;
import gtk.StyleContext;
import gdk.Screen;
import gdk.Display;

void main(string[] args)
{
	Main.init(args);

	TestRigWindow myTestRig = new TestRigWindow("Test Rig");
	
	Main.run();
	
} // main()


class TestRigWindow : MainWindow
{
	AppBox appBox;
	string cssName = "mywindow";
	Screen screen;
	CssProvider cssProvider;
	string cssFile = "./theme.css";
	StyleContext styleContext;
	
	this(string title)
	{
		super(title);
		setName(cssName);
		writeln("window name: ", getName());

		Display display = Display.getDefault();
		Screen screen = display.getDefaultScreen();
		
		cssProvider = new CssProvider();
		cssProvider.loadFromPath(cssFile);
		
		styleContext = new StyleContext();
		styleContext.addProviderForScreen(screen, cssProvider, STYLE_PROVIDER_PRIORITY_APPLICATION);

		addOnDestroy(&quitApp);
		
		appBox = new AppBox();
		add(appBox);
		
		showAll();

	} // this() CONSTRUCTOR
	
		
	void quitApp(Widget widget)
	{
		writeln("Bye.");
		Main.quit();
		
	} // quitApp()

} // class myAppWindow


class AppBox : Box
{
	CSSButton cssButton1, cssButton2;
	CSSLabel cssLabel1, cssLabel2, cssLabel3;
	string button1Text = "CSS Button 1", button2Text = "CSS Button 2";
	string button1CSSName = "button1", button2CSSName = "button2";
	string label1Text = "Hello 1", label2Text = "Hello 2 U", label3Text = "Hello 3";
	string label1CSSName = "label1", label2CSSName = "label2",label3CSSName = "label3";
	
	this()
	{
		super(Orientation.VERTICAL, 25);
		
		cssButton1 = new CSSButton(button1Text, button1CSSName);
		cssLabel1 = new CSSLabel(label1Text, label1CSSName);
		cssLabel2 = new CSSLabel(label2Text, label2CSSName);
		cssLabel3 = new CSSLabel(label3Text, label3CSSName);
		cssButton2 = new CSSButton(button2Text, button2CSSName);
		
		setHomogeneous(true);

		// packStart(<child object>, false, false, 0); // LEFT justify
		add(cssButton1);
		add(cssLabel1);
		add(cssLabel2);
		add(cssLabel3);
		add(cssButton2);
				
		// packEnd(<child object>, false, false, 0); // RIGHT justify
		
	} // this()

} // class AppBox


class CSSButton : Button
{
	this(string textLabel, string cssName)
	{
		super(textLabel);
		setName(cssName);
		
	} // this()
	
} // class CSSButton


class CSSLabel : Label
{
	this(string textLabel, string cssName)
	{
		super(textLabel);
		setName(cssName);
		
	} // this()
	
} // class CSSLabel

And the new theme.css file:

#mywindow
{
	font-family: "Times New Roman";
	font-size: 12px;
	background-image: none;
	background-color: blue;
}

button.text-button#button2
{
	color: green;
	background-image: none;
	background-color: blue;
	font-family: "Bodoni MT";
	font-size: 20px;
	text-decoration: underline;
}

button.text-button#button1
{
	font-family: "Comic Sans MS";
	font-size: 16px;
	color: red;
	background-image: none;
	background-color: yellow;
}

label#label1
{
	font-family: "Times New Roman";
	color: red;
	font-size: 26px;
	background-color: yellow;
}

label#label2
{
	color: green;
	background-color: yellow;
}

label#label3
{
	color: blue;
	background-color: yellow;
}

Re: GtkD Version vs. GTK Version?

On 19-05-2019 17:38, Ron Tarrant wrote:

On Sun, 19 May 2019 11:04:26 GMT, Ron Tarrant wrote:

On Sun, 19 May 2019 10:29:54 GMT, Ron Tarrant wrote:
I found a solution in an example on the D forum.

I won't outline the details of the changes I made, but here's the updated code for future reference. I will make this one cautionary note:

This is only a test. This code makes for one ugly demo. Use at your own risk. May cause disturbing nightmares or afterimages.

Great, as for the version information / feature availability. For
functions the documentation includes a Since: X.XX annotation for
functions that weren't available in X.0.

For the CSS options the documentation is a bit more lacing, but you can
use the GtkInspector to view the available css options and there current
values.

Re: GtkD Version vs. GTK Version?

On Sun, 19 May 2019 22:35:53 +0200, Mike Wey wrote:

Great, as for the version information / feature availability. For
functions the documentation includes a Since: X.XX annotation for
functions that weren't available in X.0.

Thanks. It gives me something to send Agent Ransack after. :)

For the CSS options the documentation is a bit more lacing, but you can
use the GtkInspector to view the available css options and there current
values.

I'll give that a try. Again, thanks.