From cf2260d5a8d4163f451029b53327cbe3b6ee73ab Mon Sep 17 00:00:00 2001 From: Aylur Date: Sat, 27 Jul 2024 13:52:29 +0200 Subject: add: Label widget --- gjs/src/widgets.ts | 6 +++--- src/meson.build | 1 + src/widget/label.vala | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 src/widget/label.vala diff --git a/gjs/src/widgets.ts b/gjs/src/widgets.ts index a0f333b..82d4708 100644 --- a/gjs/src/widgets.ts +++ b/gjs/src/widgets.ts @@ -63,9 +63,9 @@ export const Icon = astalify(Astal.Icon) export type IconProps = ConstructProps // Label -export type Label = Widget -export const Label = astalify(Gtk.Label) -export type LabelProps = ConstructProps +export type Label = Widget +export const Label = astalify(Astal.Label) +export type LabelProps = ConstructProps // LevelBar export type LevelBar = Widget diff --git a/src/meson.build b/src/meson.build index 0bc73a1..0dac152 100644 --- a/src/meson.build +++ b/src/meson.build @@ -33,6 +33,7 @@ sources = [ # 'widget/circularprogress.vala', # TODO: math lib -X -lm 'widget/eventbox.vala', 'widget/icon.vala', + 'widget/label.vala', 'widget/levelbar.vala', 'widget/overlay.vala', 'widget/scrollable.vala', diff --git a/src/widget/label.vala b/src/widget/label.vala new file mode 100644 index 0000000..4063b6f --- /dev/null +++ b/src/widget/label.vala @@ -0,0 +1,18 @@ +using Pango; + +public class Astal.Label : Gtk.Label { + public bool truncate { + set { ellipsize = value ? EllipsizeMode.END : EllipsizeMode.NONE; } + get { return ellipsize == EllipsizeMode.END; } + } + + public new bool justify_fill { + set { justify = value ? Gtk.Justification.FILL : Gtk.Justification.LEFT; } + get { return justify == Gtk.Justification.FILL; } + } + + construct { + notify["ellipsize"].connect(() => notify_property("truncate")); + notify["justify"].connect(() => notify_property("justify_fill")); + } +} -- cgit v1.2.3