Skip to content

Instantly share code, notes, and snippets.

@rmacqueen
Created March 29, 2016 20:16
Show Gist options
  • Save rmacqueen/2adf7dca40e436bd7b3765319f43f159 to your computer and use it in GitHub Desktop.
Save rmacqueen/2adf7dca40e436bd7b3765319f43f159 to your computer and use it in GitHub Desktop.
const Gtk = imports.gi.Gtk;
const Gdk = imports.gi.Gdk;
Gtk.init(null);
let overlay = new Gtk.Overlay()
let button = new Gtk.Button({
expand: true,
});
button.connect('clicked', function (widget) {
print("hello")
})
button.set_size_request(200, 100)
button.get_style_context().add_class('shadow')
let css = ".shadow {background-color:red; border: 2px solid blue; box-shadow: 0px 1px 20px 0px alpha(black, 0.5); padding: 10px;}"
let provider = new Gtk.CssProvider();
provider.load_from_data(css);
let context = button.get_style_context();
context.add_provider(provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
let mwindow = new Gtk.Window({
default_width: 800,
default_height: 600
});
overlay.add(button)
let stack = new Gtk.Stack({
halign: Gtk.Align.START,
hexpand: true,
})
stack.set_size_request(50, 50)
stack.get_style_context().add_class('shadow')
overlay.add_overlay(stack)
overlay.set_overlay_pass_through(stack, true)
mwindow.add(overlay);
mwindow.show_all();
mwindow.connect('destroy', function() { Gtk.main_quit() });
Gtk.main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment