Commit 7e774490 authored by Philip Chimento's avatar Philip Chimento 🚮

examples: Fix some best practices

As discussed in the code review of !207.
parent 8c58407d
......@@ -4,14 +4,15 @@ Clutter.init(null);
let stage = new Clutter.Stage();
let texture = new Clutter.Texture({filename: 'test.jpg',
reactive: true});
texture.connect('button-press-event',
function(o, event) {
log('Clicked!');
return true;
});
let texture = new Clutter.Texture({
filename: 'test.jpg',
reactive: true,
});
texture.connect('button-press-event', () => {
log('Clicked!');
return Clutter.EVENT_STOP;
});
let color = new Clutter.Color();
color.from_string('Black');
......
......@@ -11,7 +11,7 @@ function cat(filename) {
try {
contents = f.load_contents_finish(res)[1];
} catch (e) {
log(`*** ERROR: ${e.message}`);
logError(e);
loop.quit();
return;
}
......
......@@ -23,7 +23,7 @@ let window = new Gtk.Window ({
window.title = 'Hello World!';
// This is a callback function
function onDeleteEvent(widget, event) {
function onDeleteEvent() {
log('delete-event emitted');
// If you return false in the "delete_event" signal handler, Gtk will emit
// the "destroy" signal.
......
......@@ -8,7 +8,7 @@ function main() {
msg.response_headers.set_content_type('text/html', {});
msg.response_body.append(`<html><body>Greetings, visitor from ${client.get_host()}<br>What is your name?<form action="/hello"><input name="myname"></form></body></html>\n`);
};
let helloHandler = function(server, msg, path, query, client) {
let helloHandler = function(server, msg, path, query) {
if (!query) {
msg.set_redirect(302, '/');
return;
......@@ -16,7 +16,7 @@ function main() {
msg.status_code = 200;
msg.response_headers.set_content_type('text/html', {charset: 'UTF-8'});
msg.response_body.append(`<html><body>Hello, ${query.myname}! \u263A<br><a href="/">Go back</a></body></html>`);
msg.response_body.append(`<html><body>Hello, ${query.myname}! <br><a href="/">Go back</a></body></html>`);
};
let server = new Soup.Server({port: 1080});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment