Skip to content

Commit

Permalink
Merge pull request #233 from gjsify/revert-225-generic-layout-manager
Browse files Browse the repository at this point in the history
Revert "Fix Generics for LayoutManager"
  • Loading branch information
JumpLink authored Feb 11, 2025
2 parents b1cefa3 + 1450c1c commit f4892b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 4 additions & 1 deletion packages/lib/src/generics/clutter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ export const clutterTemplate = (version: string) => ({
Actor.props
.filter(p => p.name === "layout_manager" || p.name === "layoutManager")
.forEach(prop => {
prop.type = new GenericType("A", LayoutManager.getType());
// TODO Automatically infer such changes.
prop.type = new GenericType("A", Content.getType());
});

Actor.props
.filter(p => p.name === "content")
.forEach(prop => {
// TODO Automatically infer such changes.
prop.type = new GenericType("B", Content.getType());
});

Expand All @@ -45,6 +47,7 @@ export const clutterTemplate = (version: string) => ({
Clone.props
.filter(p => p.name === "source")
.forEach(prop => {
// TODO Automatically infer such changes.
prop.type = new GenericType("A", Content.getType());
});
}
Expand Down
10 changes: 4 additions & 6 deletions packages/lib/src/generics/st.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ const stTemplate = (version: string) => ({
const ScrollView = namespace.assertClass("ScrollView");
const ScrollBar = namespace.assertClass("ScrollBar");
const Widget = namespace.assertClass("Widget");
// TODO: Create a way to propagate this generic to child classes.
const Viewport = namespace.assertClass("Viewport");
const StBoxLayout = namespace.assertClass("BoxLayout");

const Clutter = namespace.assertInstalledImport("Clutter");

const Actor = Clutter.assertClass("Actor");
const Content = Clutter.assertClass("Content");
// Container was removed in Clutter-14
const Container = Number(version) < 14 ? Clutter.assertClass("Container") : null;
const LayoutManager = Clutter.assertClass("LayoutManager");
const ClutterBoxLayout = Clutter.assertClass("BoxLayout");
Expand All @@ -37,12 +39,6 @@ const stTemplate = (version: string) => ({
constraint: Content.getType()
});

Widget.props
.filter(p => p.name === "layout_manager")
.forEach(prop => {
prop.type = new GenericType("A", LayoutManager.getType());
});

Viewport.addGeneric({
deriveFrom: Widget.getType(),
default: LayoutManager.getType(),
Expand Down Expand Up @@ -92,6 +88,7 @@ const stTemplate = (version: string) => ({

if (get_hscroll_bar) {
const fixed_get_h = get_hscroll_bar?.copy({ returnType: ScrollBar.getType() });

const index = ScrollView.members.indexOf(get_hscroll_bar);
ScrollView.members.splice(index, 1, fixed_get_h);
}
Expand All @@ -111,6 +108,7 @@ const stTemplate = (version: string) => ({
Bin.props
.filter(p => p.name === "child")
.forEach(prop => {
// TODO Automatically infer such changes.
prop.type = new GenericType("A", Actor.getType());
});
}
Expand Down

0 comments on commit f4892b2

Please sign in to comment.