Skip to content

Instantly share code, notes, and snippets.

@multani
Last active June 5, 2018 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save multani/5747431 to your computer and use it in GitHub Desktop.
Save multani/5747431 to your computer and use it in GitHub Desktop.
Test Gtk CSS
test-c
test-vala
all: test-c test-vala
test-vala: test.vala
valac --pkg gtk+-3.0 $< -o $@
test-c: test.c
gcc `pkg-config --cflags gtk+-3.0` -std=c99 -o test-c test.c `pkg-config --libs gtk+-3.0`
#include <stdio.h>
#include <gtk/gtk.h>
int main (int argc, char *argv[])
{
GtkCssProvider* provider;
GError* error;
const char* files[4];// = {"test1.css", "test2.css", "test3.css", "test4.css"};
files[0] = "test1.css";
files[1] = "test2.css";
files[2] = "test3.css";
files[3] = "test4.css";
for (int i = 0; i < 4; i++) {
const char* file = files[i];
printf("Loading %s\n", file);
provider = gtk_css_provider_new();
gtk_css_provider_load_from_path(provider, (gchar*)file, &error);
}
return 0;
}
from gi.repository import Gtk
def test(path):
print("Testing %s..." % path)
provider = Gtk.CssProvider()
try:
provider.load_from_path(path)
except Exception as e:
print("%s -> Failure: %s" % (path, str(e)))
else:
print("%s -> OK" % (path, ))
test('test1.css')
test('test2.css')
test('test3.css')
test('test4.css')
// valac --pkg gtk+-3.0 test.vala
using Gtk;
int main (string[] args) {
string[] files = {"test1.css", "test2.css", "test3.css", "test4.css"};
foreach (var file in files)
{
var provider = new Gtk.CssProvider();
stdout.printf("Testing %s...\n", file);
try {
provider.load_from_path(file);
} catch (GLib.Error e) {
stdout.printf("%s -> Failure: %s\n", file, e.message);
continue;
}
stdout.printf("%s -> OK\n", file);
}
return 0;
}
GtkLabel.test {
font-size: 19;
}
GtkLabel.test {
font-size: 19px;
}
GtkLabel.test {
font-size: 19.5;
}
GtkLabel.test {
font-size: 19.5px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment