Created
February 5, 2014 05:10
-
-
Save mattdangerw/8817721 to your computer and use it in GitHub Desktop.
em in gtk, and em with sdk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Gtk = imports.gi.Gtk; | |
const Gdk = imports.gi.Gdk; | |
const System = imports.system; | |
let css = "\n\ | |
GtkLabel {\n\ | |
font-size: 5em;\n\ | |
}\n"; | |
Gtk.init(null, 0); | |
let provider = new Gtk.CssProvider(); | |
provider.load_from_data(css); | |
Gtk.StyleContext.add_provider_for_screen( | |
Gdk.Screen.get_default(), provider, | |
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); | |
let label = new Gtk.Label({ label: "Should be 5em, or 60 pixels" }); | |
let test_window = new Gtk.Window(); | |
test_window.add(label); | |
test_window.connect("destroy", Gtk.main_quit); | |
test_window.show_all(); | |
Gtk.main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Lang = imports.lang; | |
const Endless = imports.gi.Endless; | |
const Gdk = imports.gi.Gdk; | |
const Gtk = imports.gi.Gtk; | |
const GObject = imports.gi.GObject; | |
const TEST_APPLICATION_ID = 'com.endlessm.example.test'; | |
const CSS = "\n\ | |
GtkLabel {\n\ | |
font-size: 5em;\n\ | |
}\n"; | |
const TestApplication = new Lang.Class ({ | |
Name: 'TestApplication', | |
Extends: Endless.Application, | |
vfunc_startup: function() { | |
this.parent(); | |
let provider = new Gtk.CssProvider(); | |
provider.load_from_data(CSS); | |
Gtk.StyleContext.add_provider_for_screen( | |
Gdk.Screen.get_default(), provider, | |
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); | |
this._label1 = new Gtk.Label({ label: "Should be 5em, or 60 pixels but scale with window" }); | |
this._test_window = new Endless.Window({ | |
application: this, | |
font_scaling_active: true, | |
font_scaling_min_font_size: 1 | |
}); | |
this._pm = this._test_window.get_page_manager(); | |
this._pm.add(this._label1); | |
this._test_window.show_all(); | |
} | |
}); | |
let app = new TestApplication({ application_id: TEST_APPLICATION_ID, | |
flags: 0 }); | |
app.run(ARGV); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment