Re: Creating composite PopupMenuItems



Ok, I've tried creating a St.BoxLayout to hold the St.Button, St.Icon
and PopupSwitchMenuItem in like so (snippet):

  this.box = new St.BoxLayout({vertical: false});

  this.button = new St.Button(...);
  this.box.add(this.button);

  this.icon = new St.Icon(...);
  this.box.add(this.icon);

  this.toggle = new PopupMenu.PopupSwitchMenuItem(...);
  this.box.add(this.toggle);

It all works up until I try to add the PopupSwitchMenuItem to the
St.BoxLayout, complaining about "Object 0x... proto 0x... doesn't have
a dynamically registered class, it has Object".

I guess this means that Popup*MenuItems *can't* be embedded into St.Box* ?

I also tried initialising an empty menu item via `PopupMenuItem("")`
and .addActor( this.toggle ) to that, which gives a similar error.

Is my only hope for adding St items to the *left* of a
PopupSwitchMenuItem to just copy all the PopupSwitchMenuItem code into
my own class, making sure I insert my items in the _init method?

On 29 May 2012 16:32, Amy C <mathematical coffee gmail com> wrote:
> But PopupSwitchMenuItem/PopupBaseMenuItem do not have this method,
> only addActor, and menuItem.actor.insert_child_at_index seems not to
> exist.
>
> If I use insert_child_at_index on some private member of the
> PopupSwitchMenuItem I'd have to make sure I did everything else that
> PopupSwitchMenuItem.addActor does (adding Params.parse(...) to
> this._children, etc).
>
> At the moment I'm subclassing PopupBaseMenuItem, making a
> St.BoxLayout, and putting a St.Button, St.Icon and
> PopupMenu.PopupSwitchMenuItem inside it (haven't actually tried the
> code yet).
>
> I have this vague feeling that the Popup*MenuItems should really be
> top-level things and not be embedded within a PopupBaseMenuItem.
>
> cheers.
>
> On Tue, May 29, 2012 at 3:45 PM, Tim <darkxst fastmail fm> wrote:
>> you can use `insert_child_at_index()` to put actor before existing ones
>>
>> On 29/05/12 14:15, Amy C wrote:
>>> Hi all,
>>>
>>> I'd like to create a PopupMenuItem that is basically a
>>> PopupSwitchMenuItem (the label + toggle) and to the *left* of that, a
>>> button and an icon.
>>>
>>> Now if the button/icon were to the right I'd just create a
>>> PopupSwitchMenuItem and call .addActor( theButton ) and .addActor(
>>> theIcon ).
>>>
>>> How can I insert these to the left instead? I could subclass
>>> PopupBaseMenuItem and basically replicate the code of
>>> PopupSwitchMenuItem but make sure that in _init I addActor my button
>>> and icon *before* the label and toggle, but this seems to be not the
>>> "right way" in that I have to copy the PopupSwitchMenuItem. i.e. I'd
>>> be recreating the wheel (ie have to always make sure the code I copied
>>> from PopuSwitchMenuItem remains consistent every time it changes)
>>> instead of just using it.
>>>
>>> Could I make a St.{something? Box? BoxLayout} and just add an
>>> St.Button, St.Icon and then a PopupSwitchMenuItem to it? But would a
>>> PopupMenu then be able to    addMenuItem this? I feel I'm missing
>>> something simple.
>>>
>>> cheers.
>>> _______________________________________________
>>> gnome-shell-list mailing list
>>> gnome-shell-list gnome org
>>> https://mail.gnome.org/mailman/listinfo/gnome-shell-list


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]