summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-07-27 13:52:29 +0200
committerAylur <[email protected]>2024-07-27 13:52:29 +0200
commitcf2260d5a8d4163f451029b53327cbe3b6ee73ab (patch)
treed677248316abc8e482ff1faae496ca66ff7fec17
parent22132efcdeb08569cc27ca5414a0bb47511872d6 (diff)
add: Label widget
-rw-r--r--gjs/src/widgets.ts6
-rw-r--r--src/meson.build1
-rw-r--r--src/widget/label.vala18
3 files changed, 22 insertions, 3 deletions
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<typeof Astal.Icon, IconProps, "Icon">(Astal.Icon)
export type IconProps = ConstructProps<Astal.Icon, Astal.Icon.ConstructorProps>
// Label
-export type Label = Widget<Gtk.Label>
-export const Label = astalify<typeof Gtk.Label, LabelProps, "Label">(Gtk.Label)
-export type LabelProps = ConstructProps<Gtk.Label, Gtk.Label.ConstructorProps>
+export type Label = Widget<Astal.Label>
+export const Label = astalify<typeof Astal.Label, LabelProps, "Label">(Astal.Label)
+export type LabelProps = ConstructProps<Astal.Label, Astal.Label.ConstructorProps>
// LevelBar
export type LevelBar = Widget<Astal.LevelBar>
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"));
+ }
+}