Aylur / ags

A customizable and extensible shell
GNU General Public License v3.0
1.75k stars 94 forks source link

Stack seems to prioritize showing box widget over other widgets #359

Closed TheRiceCold closed 3 months ago

TheRiceCold commented 3 months ago

ags version: 1.8.0

I notice this issue when I was writing this script. The child2 forces itself to show up first when it's a box widget, so I use EventBox instead. The code below is just a short sample.

export default () => Widget.Stack({
  children: {
    'child1': Widget.Label('Test label'), // child1 supposed to show up first
    'child2': Widget.Box([ ]), // child2 shows up first just because it's a Box
    // 'child2': Widget.EventBox([ ]) // unlike Box, EventBox doesn't force itself to show up first 
  },
  // shown: 'child1', // This doesn't help
  // setup: self => self.shown = 'child1' // This also doesn't help
})
h-banii commented 3 months ago

hmmm I just managed to reproduce it with just lables, so it might not be specific to Boxes...

const stack = Widget.Stack({
  children: {
    'child1': Widget.Label('first child'),
    'child2': Widget.Label('second child'),
  },
  shown: 'child2', // it shows the first child...
})

Using a variable works as expected though

const shownVariable = Variable('child2');

const stack = Widget.Stack({
  children: {
    'child1': Widget.Label('first child'),
    'child2': Widget.Label('second child'),
  },
  shown: shownVariable.bind(), // it shows the second child
})
Aylur commented 3 months ago

the gobject constructor might run the shown setter before the children, in which case setting it statically doesn't work but I feel the shown property is usully bound to something, similar to visible, so this can be safely ignored, maybe its worth a mention on the wiki

kotontrion commented 3 months ago

If you want to set the shown property statically anyway, you might have luck setting it in the setup method, which should be the last thing executed. Didn't try this though.

const stack = Widget.Stack({
  children: {
    'child1': Widget.Label('first child'),
    'child2': Widget.Label('second child'),
  },
  setup: self => {
    self.shown = 'child2'
  }
})
TheRiceCold commented 3 months ago

I expect the child1(Label) to show up first without using shown statically or dynamically, but it always shows the child2(Box) first so I what I did is change child2 to EventBox and it worked.

Widget.Stack({
  children: {
    'child1': Widget.Label('first child'),
    'child2': Widget.EventBox({ }), // does not force itself to show up first unlike box widget
  }
})
TheRiceCold commented 3 months ago

If you want to set the shown property statically anyway, you might have luck setting it in the setup method, which should be the last thing executed. Didn't try this though.

const stack = Widget.Stack({
  children: {
    'child1': Widget.Label('first child'),
    'child2': Widget.Label('second child'),
  },
  setup: self => {
    self.shown = 'child2'
  }
})

I've tried that but the box(child2) still forces itself to show up first.

TheRiceCold commented 3 months ago

hmmm I just managed to reproduce it with just lables, so it might not be specific to Boxes...

const stack = Widget.Stack({
  children: {
    'child1': Widget.Label('first child'),
    'child2': Widget.Label('second child'),
  },
  shown: 'child2', // it shows the first child...
})

Using a variable works as expected though

const shownVariable = Variable('child2');

const stack = Widget.Stack({
  children: {
    'child1': Widget.Label('first child'),
    'child2': Widget.Label('second child'),
  },
  shown: shownVariable.bind(), // it shows the second child
})

I'm trying to show child1 first, but child2(Box) forces itself to show up first. It worked when I replaced Box(child2) with EventBox.