Re: Writing Css inside Javascript
- From: "Alan Knowles" <alan roojs com>
- To: "Mohan R" <javascript-list-bounces gnome org>
- Cc: javascript-list gnome org
- Subject: Re: Writing Css inside Javascript
- Date: Wed, 14 Nov 2012 16:27:31 +0800
There is a bug with the gir - feel free to add a bug in bugzilla
in /usr/share/gir/Gtk-3.0.gir
<method name="load_from_data"
c:identifier="gtk_css_provider_load_from_data"
throws="1">
...
REMOVE THIS
<array length="1" zero-terminated="0" c:type="gchar*">
<type name="guint8"/>
</array>
ADD THIS.
<type name="utf8" c:type="gchar*"/>
Then
g-ir-compiler /tmp/Gtk-3.0.gir -o /usr/lib/girepository-1.0/Gtk-3.0.typelib
This works with seed, I get a nice red background...
const Gtk = imports.gi.Gtk;
Gtk.init(Seed.argv);
var css = "GtkWindow { background-color: red }";
var window = new Gtk.Window({title: "test"});
var styleContext = window.get_style_context();
var cssProvider = new Gtk.CssProvider();
print(cssProvider);
window.set_default_size(400, 400);
window.signal.connect("destroy", Gtk.main_quit);
styleContext.add_provider(cssProvider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
cssProvider.load_from_data(css, css.length);
window.show_all();
Gtk.main();
--- On 14/Nov/2012, Mohan R wrote:
> Hi,
>
> Did anyone have a working code which loads css using
> Gtk.CssProvider.load_from_data()? Following code is not working,
>
> const Gtk = imports.gi.Gtk;
> var css = "GtkWindow { background-color: red }";
> var window = new Gtk.Window({title: "test"});
> var styleContext = window.get_style_context();
> var cssProvider = new Gtk.CssProvider();
>
> window.set_default_size(400, 400);
> window.connect("destroy", Gtk.main_quit);
> styleContext.add_provider(cssProvider,
> Gtk.GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
> cssProvider.load_from_data(css, -1, null);
>
> window.show_all();
> Gtk.main();
>
>
> What kind of name I should use instead of 'GtkWindow' in javascript?
> Even Gtk.Window is not working. These same steps works perfectly If I
> write it in C instead of JavaScript.
>
> Thanks,
> Mohan R
>
> _______________________________________________
> javascript-list mailing list
> javascript-list gnome org
> https://mail.gnome.org/mailman/listinfo/javascript-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]