Skip to content

Commit

Permalink
chore: update listen & add ellipsis
Browse files Browse the repository at this point in the history
  • Loading branch information
anig1scur committed Oct 23, 2024
1 parent edaf53f commit c664f5b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down

0 comments on commit c664f5b

Please sign in to comment.