fixes circular progress widgets

This commit is contained in:
kotontrion
2024-08-23 10:52:40 +02:00
parent 8da6a21742
commit d248645888
6 changed files with 19 additions and 16 deletions
+2 -2
View File
@@ -35,7 +35,7 @@ const ctors = {
box: Widget.Box,
button: Widget.Button,
centerbox: Widget.CenterBox,
// TODO: circularprogress
circularprogress: Widget.CircularProgress,
drawingarea: Widget.DrawingArea,
entry: Widget.Entry,
eventbox: Widget.EventBox,
@@ -63,7 +63,7 @@ declare global {
box: Widget.BoxProps
button: Widget.ButtonProps
centerbox: Widget.CenterBoxProps
// TODO: circularprogress
circularprogress: Widget.CircularProgressProps,
drawingarea: Widget.DrawingAreaProps
entry: Widget.EntryProps
eventbox: Widget.EventBoxProps
+5 -1
View File
@@ -26,7 +26,11 @@ export type CenterBox = Widget<Astal.CenterBox>
export const CenterBox = astalify<typeof Astal.CenterBox, CenterBoxProps, "CenterBox">(Astal.CenterBox)
export type CenterBoxProps = ConstructProps<Astal.CenterBox, Astal.CenterBox.ConstructorProps>
// TODO: CircularProgress
// CircularProgress
export type CircularProgress = Widget<Astal.CircularProgress>
export const CircularProgress = astalify<typeof Astal.CircularProgress, CircularProgressProps, "CircularProgress">(Astal.CircularProgress)
export type CircularProgressProps = ConstructProps<Astal.CircularProgress, Astal.CircularProgress.ConstructorProps>
// DrawingArea
export type DrawingArea = Widget<Gtk.DrawingArea>
+1 -1
View File
@@ -209,7 +209,7 @@ local Widget = {
Box = astalify(Astal.Box),
Button = astalify(Astal.Button),
CenterBox = astalify(Astal.CenterBox),
-- TODO: CircularProgress
CircularProgress = astalify(Astal.CircularProgress),
DrawingArea = astalify(Gtk.DrawingArea),
Entry = astalify(Gtk.Entry),
EventBox = astalify(Astal.EventBox),
-2
View File
@@ -15,8 +15,6 @@ prefix = get_option('prefix')
libdir = get_option('prefix') / get_option('libdir')
pkgdatadir = prefix / get_option('datadir') / 'astal'
# math
add_project_arguments(['-X', '-lm'], language: 'vala')
assert(
get_option('lib') or get_option('cli'),
+5 -3
View File
@@ -14,7 +14,7 @@ config = configure_file(
},
)
deps = [
pkgconfig_deps = [
dependency('glib-2.0'),
dependency('gio-unix-2.0'),
dependency('gobject-2.0'),
@@ -24,12 +24,14 @@ deps = [
dependency('gtk-layer-shell-0'),
]
deps = pkgconfig_deps + meson.get_compiler('c').find_library('m')
sources = [
config,
'widget/box.vala',
'widget/button.vala',
'widget/centerbox.vala',
# 'widget/circularprogress.vala', # TODO: math lib -X -lm
'widget/circularprogress.vala',
'widget/eventbox.vala',
'widget/icon.vala',
'widget/label.vala',
@@ -65,7 +67,7 @@ if get_option('lib')
filebase: meson.project_name() + '-' + api_version,
version: meson.project_version(),
subdirs: meson.project_name(),
requires: deps,
requires: pkgconfig_deps,
install_dir: libdir / 'pkgconfig',
variables: {
'gjs': pkgdatadir / 'gjs',
+6 -7
View File
@@ -1,6 +1,5 @@
namespace Astal {
public class CircularProgress : Gtk.Bin {
public new Gtk.Widget child { get; set; }
public double start_at { get; set; }
public double end_at { get; set; }
public double value { get; set; }
@@ -20,7 +19,7 @@ public class CircularProgress : Gtk.Bin {
set_css_name("circular-progress");
}
public new void get_preferred_height(out int minh, out int nath) {
public override void get_preferred_height(out int minh, out int nath) {
var val = get_style_context().get_property("min-height", Gtk.StateFlags.NORMAL);
if (val.get_int() <= 0) {
minh = 40;
@@ -31,7 +30,7 @@ public class CircularProgress : Gtk.Bin {
nath = val.get_int();
}
public new void get_preferred_width(out int minw, out int natw) {
public override void get_preferred_width(out int minw, out int natw) {
var val = get_style_context().get_property("min-width", Gtk.StateFlags.NORMAL);
if (val.get_int() <= 0) {
minw = 40;
@@ -89,7 +88,7 @@ public class CircularProgress : Gtk.Bin {
return max;
}
public new bool draw(Cairo.Context cr) {
public override bool draw(Cairo.Context cr) {
Gtk.Allocation allocation;
get_allocation(out allocation);
@@ -162,9 +161,9 @@ public class CircularProgress : Gtk.Bin {
cr.fill();
}
if (this.child != null) {
this.child.size_allocate(allocation);
this.propagate_draw(this.child, cr);
if (this.get_child() != null) {
this.get_child().size_allocate(allocation);
this.propagate_draw(this.get_child(), cr);
}
return true;