Closed Bug 342988 Opened 18 years ago Closed 18 years ago

Allow plugins to rebuild menu(s) after changing client.menuSpecs

Categories

(Other Applications :: ChatZilla, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: bugzilla-mozilla-20000923, Assigned: Gijs)

References

(Blocks 1 open bug)

Details

(Whiteboard: [cz-0.9.76][cz-0.9.78])

Attachments

(3 obsolete files)

To allow for plugins to modify the menus when they load/unload, we need to allow them to trigger a rebuild of all the menus (on all windows once bug 76175 is done). I'm thinking:

  client.menuManager.updateMenus();

which can be called after any change to client.menuSpecs to sync things (only one way). We should get plugins into the habit of calling this as soon as possible, so that when we get to the new ChatZilla service code and multiple windows stuff, it actually works for most existing plugins.
After some discussion in #chatzilla, it was decided that allowing an array of menuSpec keys as an optional parameter is wise. This would allow the plugin to only trigger the updating on menus it knew it had changed (including ones it has added and/or removed).
Assignee: rginda → silver
Attached patch Patch (obsolete) — Splinter Review
Taking this for a bit; I think this patch will do, it sufficed in my testing, but given that I wrote the 'fun' bits while in a conference (being mildly distracted at times) it might need some care.
Assignee: silver → gijskruitbosch+bugs
Status: NEW → ASSIGNED
Attachment #239501 - Flags: review?(silver)
Argh. I want a 'keep assignee CC-ed' field. Seriously.
Patch with a different API, in a different place.
Attachment #239501 - Attachment is obsolete: true
Attachment #243909 - Flags: review?(silver)
Attachment #239501 - Flags: review?(silver)
Comment on attachment 243909 [details] [diff] [review]
[checked in w/ nits] Better patch

>+    if (!menu.parentNode)
>+        parentNode.insertBefore(menu, beforeNode);
>+

I'm going to trust you that the code works, but can we at least have a comment for why this moved?

r=silver with that commented.
Attachment #243909 - Flags: review?(silver) → review+
Fixed with additional comment:

Checking in mozilla/extensions/irc/js/lib/menu-manager.js;
/cvsroot/mozilla/extensions/irc/js/lib/menu-manager.js,v  <--  menu-manager.js
new revision: 1.9; previous revision: 1.8
done
Checking in mozilla/extensions/irc/xul/content/static.js;
/cvsroot/mozilla/extensions/irc/xul/content/static.js,v  <--  static.js
new revision: 1.213; previous revision: 1.212
done
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Whiteboard: [cz-0.9.76]
So, there's a small problem which Toast and I stumbled upon when writing a new version of ChattyTunes:

1. Write a plugin that adds a new menuspec
2. run client.updateMenus("mainmenu:yourmenu") in your enable code.
3. Autoload your plugin
4. Your menu is duplicated.

This is, afaict, because right now createMenus doesn't really give a shit if your menu is there already, it'll just re-add all the items! Oops.

I'm curious whether it will live if one just replaces calls to createMenus with updateMenus, but I can try that later.

Status: RESOLVED → REOPENED
Resolution: FIXED → ---
The original plan was that calls to client.updateMenus would do nothing if they were called before initMenus() or whatever it is that creates the initial set. That's what needs to happen here.
Well, yeah. That was fairly straightforward. Prevented any problems from showing on ChattyTunes on Fx 2.0 w/ CZ trunk + this patch.
Attachment #247732 - Flags: review?(silver)
Attachment #243909 - Attachment description: Better patch → [checked in w/ nits] Better patch
Attachment #243909 - Attachment is obsolete: true
Attachment #247732 - Flags: review?(silver) → review+
Checking in mozilla/extensions/irc/xul/content/static.js;
/cvsroot/mozilla/extensions/irc/xul/content/static.js,v  <--  static.js
new revision: 1.220; previous revision: 1.219
done
Status: REOPENED → RESOLVED
Closed: 18 years ago18 years ago
Resolution: --- → FIXED
Attachment #247732 - Attachment description: Patch to fix it not to do anything on startup → [checked in] Patch to fix it not to do anything on startup
Attachment #247732 - Attachment is obsolete: true
Whiteboard: [cz-0.9.76] → [cz-0.9.76][cz-0.9.78]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: