diff --git a/src/util.ts b/src/util.ts index f1284e3..c407e35 100644 --- a/src/util.ts +++ b/src/util.ts @@ -223,14 +223,14 @@ export class Note extends GObject.Object { GObject.BindingFlags.SYNC_CREATE, (_, content) => { if (!content) return [false, ""]; - return [true, content.substring(0, 24)] + + const title = content.split("\n")[0]; + return [true, title.length > 20 ? title.slice(0, 20) + "..." : title]; }, null ); - this.connect("notify::title", () => { - this.emit('title-changed'); - }); + } static generate() { @@ -307,9 +307,6 @@ export class Note extends GObject.Object { // deno-fmt-ignore open: GObject.ParamSpec.boolean("open", "Open", "Whether the note was open when the application was closed", GObject.ParamFlags.READWRITE, false), }, - Signals: { - 'title-changed': {}, - }, }, this); } } diff --git a/src/window.ts b/src/window.ts index ff09c77..ce1d938 100644 --- a/src/window.ts +++ b/src/window.ts @@ -100,7 +100,7 @@ export class Window extends Adw.ApplicationWindow { this.update_title(); - this.note.connect("title-changed", () => { + this.note.connect("notify::title", () => { this.update_title(); }); @@ -158,8 +158,8 @@ export class Window extends Adw.ApplicationWindow { } update_title() { - if (this.note.title === "") { - this.set_title(_("Untitled Note")); + if (!this.note.title) { + this.set_title("Untitled Note"); return; } this.set_title(this.note.title);