summaryrefslogtreecommitdiff
path: root/lib/astal
diff options
context:
space:
mode:
Diffstat (limited to 'lib/astal')
-rw-r--r--lib/astal/gtk3/src/widget/circularprogress.vala63
l---------[-rw-r--r--]lib/astal/gtk4/gir.py59
l---------[-rw-r--r--]lib/astal/io/gir.py59
3 files changed, 47 insertions, 134 deletions
diff --git a/lib/astal/gtk3/src/widget/circularprogress.vala b/lib/astal/gtk3/src/widget/circularprogress.vala
index a3ecdf1..df1635d 100644
--- a/lib/astal/gtk3/src/widget/circularprogress.vala
+++ b/lib/astal/gtk3/src/widget/circularprogress.vala
@@ -44,26 +44,53 @@ public class Astal.CircularProgress : Gtk.Bin {
set_css_name("circular-progress");
}
+ public override Gtk.SizeRequestMode get_request_mode() {
+ if(get_child() != null) return get_child().get_request_mode();
+ return Gtk.SizeRequestMode.HEIGHT_FOR_WIDTH;
+ }
+
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;
- nath = 40;
+ if(get_child() != null) {
+ int minw, natw;
+ get_child().get_preferred_height(out minh, out nath);
+ get_child().get_preferred_width(out minw, out natw);
+
+ minh = int.max(minw, minh);
+ nath = int.max(natw, nath);
}
+ var w_val = get_style_context().get_property("min-width", Gtk.StateFlags.NORMAL);
+ var h_val = get_style_context().get_property("min-height", Gtk.StateFlags.NORMAL);
+ minh = int.max(w_val.get_int(), minh);
+ nath = int.max(w_val.get_int(), nath);
+ minh = int.max(h_val.get_int(), minh);
+ nath = int.max(h_val.get_int(), nath);
+ }
- minh = val.get_int();
- nath = val.get_int();
+ public override void get_preferred_height_for_width(int width, out int minh, out int nath) {
+ minh = width;
+ nath = width;
}
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;
- natw = 40;
+ if(get_child() != null) {
+ int minh, nath;
+ get_child().get_preferred_height(out minh, out nath);
+ get_child().get_preferred_width(out minw, out natw);
+
+ minw = int.max(minw, minh);
+ natw = int.max(natw, nath);
}
+ var w_val = get_style_context().get_property("min-width", Gtk.StateFlags.NORMAL);
+ var h_val = get_style_context().get_property("min-height", Gtk.StateFlags.NORMAL);
+ minw = int.max(w_val.get_int(), minw);
+ natw = int.max(w_val.get_int(), natw);
+ minw = int.max(h_val.get_int(), minw);
+ natw = int.max(h_val.get_int(), natw);
+ }
- minw = val.get_int();
- natw = val.get_int();
+ public override void get_preferred_width_for_height(int height, out int minw, out int natw) {
+ minw = height;
+ natw = height;
}
private double to_radian(double percentage) {
@@ -115,6 +142,12 @@ public class Astal.CircularProgress : Gtk.Bin {
Gtk.Allocation allocation;
get_allocation(out allocation);
+ if (get_child() != null) {
+ get_child().size_allocate(allocation);
+ propagate_draw(get_child(), cr);
+ }
+
+
var styles = get_style_context();
var width = allocation.width;
var height = allocation.height;
@@ -195,12 +228,6 @@ public class Astal.CircularProgress : Gtk.Bin {
cr.arc(end_x, end_y, fg_stroke / 2, 0, 0 - 0.01);
cr.fill();
}
-
- if (get_child() != null) {
- get_child().size_allocate(allocation);
- propagate_draw(get_child(), cr);
- }
-
return true;
}
}
diff --git a/lib/astal/gtk4/gir.py b/lib/astal/gtk4/gir.py
index 9ef680f..16a3a64 100644..120000
--- a/lib/astal/gtk4/gir.py
+++ b/lib/astal/gtk4/gir.py
@@ -1,58 +1 @@
-"""
-Vala's generated gir does not contain comments,
-so we use valadoc to generate them. However, they are formatted
-for valadoc and not gi-docgen so we need to fix it.
-"""
-
-import xml.etree.ElementTree as ET
-import html
-import sys
-import subprocess
-
-
-def fix_gir(name: str, gir: str, out: str):
- namespaces = {
- "": "http://www.gtk.org/introspection/core/1.0",
- "c": "http://www.gtk.org/introspection/c/1.0",
- "glib": "http://www.gtk.org/introspection/glib/1.0",
- }
- for prefix, uri in namespaces.items():
- ET.register_namespace(prefix, uri)
-
- tree = ET.parse(gir)
- root = tree.getroot()
-
- for doc in root.findall(".//doc", namespaces):
- if doc.text:
- doc.text = (
- html.unescape(doc.text).replace("<para>", "").replace("</para>", "")
- )
-
- if (inc := root.find("c:include", namespaces)) is not None:
- inc.set("name", f"{name}.h")
- else:
- print("no c:include tag found", file=sys.stderr)
- exit(1)
-
- tree.write(out, encoding="utf-8", xml_declaration=True)
-
-
-def valadoc(name: str, gir: str, args: list[str]):
- cmd = ["valadoc", "-o", "docs", "--package-name", name, "--gir", gir, *args]
- try:
- subprocess.run(cmd, check=True, text=True, capture_output=True)
- except subprocess.CalledProcessError as e:
- print(e.stderr, file=sys.stderr)
- exit(1)
-
-
-if __name__ == "__main__":
- name = sys.argv[1]
- in_out = sys.argv[2].split(":")
- args = sys.argv[3:]
-
- gir = in_out[0]
- out = in_out[1] if len(in_out) > 1 else gir
-
- valadoc(name, gir, args)
- fix_gir(name, gir, out)
+../../gir.py \ No newline at end of file
diff --git a/lib/astal/io/gir.py b/lib/astal/io/gir.py
index 9ef680f..16a3a64 100644..120000
--- a/lib/astal/io/gir.py
+++ b/lib/astal/io/gir.py
@@ -1,58 +1 @@
-"""
-Vala's generated gir does not contain comments,
-so we use valadoc to generate them. However, they are formatted
-for valadoc and not gi-docgen so we need to fix it.
-"""
-
-import xml.etree.ElementTree as ET
-import html
-import sys
-import subprocess
-
-
-def fix_gir(name: str, gir: str, out: str):
- namespaces = {
- "": "http://www.gtk.org/introspection/core/1.0",
- "c": "http://www.gtk.org/introspection/c/1.0",
- "glib": "http://www.gtk.org/introspection/glib/1.0",
- }
- for prefix, uri in namespaces.items():
- ET.register_namespace(prefix, uri)
-
- tree = ET.parse(gir)
- root = tree.getroot()
-
- for doc in root.findall(".//doc", namespaces):
- if doc.text:
- doc.text = (
- html.unescape(doc.text).replace("<para>", "").replace("</para>", "")
- )
-
- if (inc := root.find("c:include", namespaces)) is not None:
- inc.set("name", f"{name}.h")
- else:
- print("no c:include tag found", file=sys.stderr)
- exit(1)
-
- tree.write(out, encoding="utf-8", xml_declaration=True)
-
-
-def valadoc(name: str, gir: str, args: list[str]):
- cmd = ["valadoc", "-o", "docs", "--package-name", name, "--gir", gir, *args]
- try:
- subprocess.run(cmd, check=True, text=True, capture_output=True)
- except subprocess.CalledProcessError as e:
- print(e.stderr, file=sys.stderr)
- exit(1)
-
-
-if __name__ == "__main__":
- name = sys.argv[1]
- in_out = sys.argv[2].split(":")
- args = sys.argv[3:]
-
- gir = in_out[0]
- out = in_out[1] if len(in_out) > 1 else gir
-
- valadoc(name, gir, args)
- fix_gir(name, gir, out)
+../../gir.py \ No newline at end of file