Merge lp:~mconley/globalmenu-extension/bug710149-escape-underscores into lp:globalmenu-extension

Proposed by Mike Conley
Status: Merged
Merged at revision: 81
Proposed branch: lp:~mconley/globalmenu-extension/bug710149-escape-underscores
Merge into: lp:globalmenu-extension
Diff against target: 53 lines (+18/-7)
1 file modified
extensions/globalmenu/components/src/uGlobalMenuObject.cpp (+18/-7)
To merge this branch: bzr merge lp:~mconley/globalmenu-extension/bug710149-escape-underscores
Reviewer Review Type Date Requested Status
Chris Coulson Approve
Review via email: mp+48652@code.launchpad.net

Description of the change

Here's a patch for bug 710149 (underscores are not being escaped properly). Any/all feedback welcome.

To post a comment you must log in.
Revision history for this message
Chris Coulson (chrisccoulson) wrote :

Thanks!

Feel free to push this to lp:globalmenu-extension, with 1 minor adjustment though - could you please use PRBool rather than bool for foundAccessKey?

Thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'extensions/globalmenu/components/src/uGlobalMenuObject.cpp'
--- extensions/globalmenu/components/src/uGlobalMenuObject.cpp 2011-02-03 00:44:41 +0000
+++ extensions/globalmenu/components/src/uGlobalMenuObject.cpp 2011-02-04 19:26:11 +0000
@@ -478,6 +478,7 @@
478 // Gecko stores the label and access key in separate attributes478 // Gecko stores the label and access key in separate attributes
479 // so we need to convert label="Foo"/accesskey="F" in to479 // so we need to convert label="Foo"/accesskey="F" in to
480 // label="_Foo" for dbusmenu480 // label="_Foo" for dbusmenu
481
481 nsAutoString label;482 nsAutoString label;
482 mContent->GetAttr(kNameSpaceID_None, uWidgetAtoms::label, label);483 mContent->GetAttr(kNameSpaceID_None, uWidgetAtoms::label, label);
483484
@@ -489,24 +490,34 @@
489 PRUnichar *end = label.EndWriting();490 PRUnichar *end = label.EndWriting();
490 int length = label.Length();491 int length = label.Length();
491 int pos = 0;492 int pos = 0;
493 bool foundAccessKey = false;
492494
493 while(cur < end) {495 while(cur < end) {
494 if(*cur != *key) {496 if((*cur == *key && !foundAccessKey) || *cur == PRUnichar('_')) {
495 cur++;497
496 pos++;
497 } else {
498 length += 1;498 length += 1;
499 label.SetLength(length);499 label.SetLength(length);
500 int newLength = label.Length();500 int newLength = label.Length();
501 if(length != newLength)501 if(length != newLength)
502 break;502 break;
503
503 cur = label.BeginWriting() + pos;504 cur = label.BeginWriting() + pos;
505 end = label.EndWriting();
504 memmove(cur + 1, cur, (length - 1 - pos) * sizeof(PRUnichar));506 memmove(cur + 1, cur, (length - 1 - pos) * sizeof(PRUnichar));
505// \^/507// \^/
506 *cur = PRUnichar('_'); // Yeah!508 *cur = PRUnichar('_'); // Yeah!
507// v509// v
508 break;510
509 }511 if(*cur == *key)
512 foundAccessKey = true;
513
514 cur += 2;
515 pos += 2;
516
517 } else {
518 cur++;
519 pos++;
520 }
510 }521 }
511522
512 // Ellipsize long labels. I've picked an arbitrary length here523 // Ellipsize long labels. I've picked an arbitrary length here

Subscribers

People subscribed via source and target branches