~mozillateam/thunderbird/thunderbird.lucid

« back to all changes in this revision

Viewing changes to debian/globalmenu/src/uGlobalMenuItem.cpp

  • Committer: Chris Coulson
  • Date: 2012-11-17 23:53:00 UTC
  • mfrom: (208.1.162 thunderbird-beta.lucid)
  • Revision ID: chris.coulson@canonical.com-20121117235300-wq4wxzwfevijfk71
* New upstream stable release (THUNDERBIRD_17_0_BUILD2)
  - see LP: #1080212 for USN information
* Build with --disable-webrtc on all architectures except for i386 and amd64
  - update debian/config/mozconfig.in
* Fix quoting issues when parsing preferences
  - update debian/apport/source_thunderbird.py.in
* Refresh patches
  - update debian/patches/add-syspref-dir.patch
  - update debian/patches/fix-for-bmo795395.patch
* Don't ship empty ".mkdir.done" files in our packages. This should probably
  be fixed in the upstream build system, but we'll do a temporary band-aid
  fix in the packaging for now just so we can get some builds
  - update debian/build/mozbuild.mk

Show diffs side-by-side

added added

removed removed

Lines of Context:
458
458
}
459
459
 
460
460
void
 
461
uGlobalMenuItem::SyncStateFromCommand()
 
462
{
 
463
  TRACETM()
 
464
 
 
465
  if (mCommandContent) {
 
466
    nsAutoString checked;
 
467
    if (mCommandContent->GetAttr(kNameSpaceID_None, uWidgetAtoms::checked,
 
468
                                 checked)) {
 
469
      LOGTM("Copying checked state from command node");
 
470
      mContent->SetAttr(kNameSpaceID_None, uWidgetAtoms::checked, checked, true);
 
471
    }
 
472
  }
 
473
}
 
474
 
 
475
void
461
476
uGlobalMenuItem::SyncTypeAndStateFromContent()
462
477
{
463
 
  MENUOBJECT_REENTRANCY_GUARD(UNITY_MENUITEM_SYNC_TYPE_GUARD);
464
 
  TRACETM();
 
478
  TRACETM()
465
479
 
466
480
  static nsIContent::AttrValuesArray attrs[] =
467
481
    { &uWidgetAtoms::checkbox, &uWidgetAtoms::radio, nullptr };
482
496
      SetMenuItemType(eRadio);
483
497
    }
484
498
 
485
 
    if (mCommandContent) {
486
 
      nsAutoString commandChecked;
487
 
      mCommandContent->GetAttr(kNameSpaceID_None, uWidgetAtoms::checked,
488
 
                               commandChecked);
489
 
      if (!commandChecked.IsEmpty() && !mContent->AttrValueIs(kNameSpaceID_None,
490
 
                                                              uWidgetAtoms::checked,
491
 
                                                              commandChecked,
492
 
                                                              eCaseMatters)) {
493
 
        mContent->SetAttr(kNameSpaceID_None, uWidgetAtoms::checked,
494
 
                          commandChecked, true);
495
 
      }
496
 
    }
497
 
 
498
499
    SetCheckState(mContent->AttrValueIs(kNameSpaceID_None, uWidgetAtoms::checked,
499
500
                                       uWidgetAtoms::_true, eCaseMatters));
500
501
    dbusmenu_menuitem_property_set_int(mDbusMenuItem,
512
513
  }
513
514
}
514
515
 
 
516
const char *types[] = {
 
517
  "Normal",
 
518
  "Checkbox",
 
519
  "Radio",
 
520
  NULL
 
521
};
 
522
 
 
523
void
 
524
uGlobalMenuItem::SetMenuItemType(uMenuItemType aType)
 
525
{
 
526
  ClearFlags(UNITY_MENUITEM_TYPE_MASK);
 
527
  SetFlags(aType << 8);
 
528
 
 
529
  LOGTM("Setting menuitem to type %s", types[aType]);
 
530
}
 
531
 
515
532
void
516
533
uGlobalMenuItem::Refresh(uMenuObjectRefreshMode aMode)
517
534
{
518
 
  TRACETM();
 
535
  TRACETM()
519
536
 
520
537
  if (aMode == eRefreshFull) {
521
538
    if (mCommandContent) {
554
571
 
555
572
  SyncVisibilityFromContent();
556
573
  SyncIconFromContent();
 
574
  SyncStateFromCommand();
557
575
}
558
576
 
559
577
/*static*/ void
561
579
                                       PRUint32 timeStamp,
562
580
                                       void *data)
563
581
{
 
582
  uMenuAutoSuspendMutationEvents as;
 
583
 
564
584
  uGlobalMenuItem *self = static_cast<uGlobalMenuItem *>(data);
565
585
  self->Activate(timeStamp);
566
586
}
568
588
void
569
589
uGlobalMenuItem::Activate(PRUint32 timeStamp)
570
590
{
 
591
  TRACETM()
 
592
 
571
593
  gdk_x11_window_set_user_time(gtk_widget_get_window(GetMenuBar()->TopLevelWindow()),
572
594
                               timeStamp);
573
595
  // This first bit seems backwards, but it's not really. If autocheck is
581
603
  //      the event, as the handler might check the new state
582
604
  if (!mContent->AttrValueIs(kNameSpaceID_None, uWidgetAtoms::autocheck,
583
605
                             uWidgetAtoms::_false, eCaseMatters) &&
584
 
      IsCheckboxOrRadioItem()) {
 
606
      (GetMenuItemType() == eCheckBox ||
 
607
       (GetMenuItemType() == eRadio && !IsChecked()))) {
585
608
    mContent->SetAttr(kNameSpaceID_None, uWidgetAtoms::checked,
586
609
                      IsChecked() ?
587
610
                      NS_LITERAL_STRING("false") :  NS_LITERAL_STRING("true"),
665
688
void
666
689
uGlobalMenuItem::UncheckSiblings()
667
690
{
668
 
  if (!(mFlags & UNITY_MENUITEM_IS_RADIO)) {
 
691
  TRACETM()
 
692
 
 
693
  if (GetMenuItemType() != eRadio) {
669
694
    // If we're not a radio button, we don't care
670
695
    return;
671
696
  }
672
697
 
673
698
  nsAutoString name;
674
699
  mContent->GetAttr(kNameSpaceID_None, uWidgetAtoms::name, name);
675
 
  if (name.IsEmpty()) {
676
 
    // If we don't have a name, then we can't find our siblings
677
 
    return;
678
 
  }
679
700
 
680
701
  nsIContent *parent = mContent->GetParent();
681
702
  if (!parent) {
685
706
  PRUint32 count = parent->GetChildCount();
686
707
  for (PRUint32 i = 0; i < count; i++) {
687
708
    nsIContent *sibling = parent->GetChildAt(i);
688
 
    if (sibling->AttrValueIs(kNameSpaceID_None, uWidgetAtoms::name,
689
 
        name, eCaseMatters) && sibling != mContent &&
 
709
 
 
710
    nsAutoString otherName;
 
711
    sibling->GetAttr(kNameSpaceID_None, uWidgetAtoms::name, otherName);
 
712
 
 
713
    if (sibling != mContent && otherName == name && 
690
714
        sibling->AttrValueIs(kNameSpaceID_None, uWidgetAtoms::type,
691
715
                             uWidgetAtoms::radio, eCaseMatters)) {
692
716
      sibling->UnsetAttr(kNameSpaceID_None, uWidgetAtoms::checked, true);
704
728
{
705
729
  TRACETM();
706
730
 
707
 
  if (mListener) {
708
 
    if (mCommandContent) {
709
 
      mListener->UnregisterForContentChanges(mCommandContent, this);
710
 
    }
711
 
    if (mKeyContent) {
712
 
      mListener->UnregisterForContentChanges(mKeyContent, this);
713
 
    }
714
 
  }
715
 
 
716
 
  if (mDbusMenuItem) {
717
 
    guint found = g_signal_handlers_disconnect_by_func(mDbusMenuItem,
718
 
                                                       FuncToVoidPtr(ItemActivatedCallback),
719
 
                                                       this);
720
 
    NS_ASSERTION(found == 1, "Failed to disconnect \"activated\" handler");
 
731
  if (!IsDestroyed()) {
 
732
    Destroy();
721
733
  }
722
734
 
723
735
  MOZ_COUNT_DTOR(uGlobalMenuItem);
744
756
}
745
757
 
746
758
void
747
 
uGlobalMenuItem::ObserveAttributeChanged(nsIDocument *aDocument,
748
 
                                         nsIContent *aContent,
 
759
uGlobalMenuItem::Destroy()
 
760
{
 
761
  NS_ASSERTION(!IsDestroyed(), "Menuitem is already destroyed");
 
762
  if (IsDestroyed()) {
 
763
    return;
 
764
  }
 
765
 
 
766
  if (mListener) {
 
767
    if (mCommandContent) {
 
768
      mListener->UnregisterForContentChanges(mCommandContent, this);
 
769
    }
 
770
    if (mKeyContent) {
 
771
      mListener->UnregisterForContentChanges(mKeyContent, this);
 
772
    }
 
773
  }
 
774
 
 
775
  if (mDbusMenuItem) {
 
776
    guint found = g_signal_handlers_disconnect_by_func(mDbusMenuItem,
 
777
                                                       FuncToVoidPtr(ItemActivatedCallback),
 
778
                                                       this);
 
779
    NS_ASSERTION(found == 1, "Failed to disconnect \"activated\" handler");
 
780
  }
 
781
 
 
782
  uGlobalMenuObject::Destroy();
 
783
}
 
784
 
 
785
void
 
786
uGlobalMenuItem::ObserveAttributeChanged(nsIContent *aContent,
749
787
                                         nsIAtom *aAttribute)
750
788
{
751
789
  TRACETM();
763
801
    if (aAttribute == uWidgetAtoms::command ||
764
802
        aAttribute == uWidgetAtoms::key) {
765
803
      Refresh(eRefreshFull);
766
 
    } else if (aAttribute == uWidgetAtoms::label ||
767
 
               aAttribute == uWidgetAtoms::accesskey) {
 
804
    } else if (aAttribute == uWidgetAtoms::label) {
 
805
      if (!mCommandContent) {
 
806
        SyncLabelFromContent();
 
807
      }
 
808
    } else if (aAttribute == uWidgetAtoms::accesskey) {
768
809
      SyncLabelFromContent(mCommandContent);
769
810
    } else if (aAttribute == uWidgetAtoms::disabled) {
770
 
      SyncSensitivityFromContent(mCommandContent);
 
811
      if (!mCommandContent) {
 
812
        SyncSensitivityFromContent();
 
813
      }
771
814
    } else if (aAttribute == uWidgetAtoms::checked ||
772
815
               aAttribute == uWidgetAtoms::type) {
773
816
      SyncTypeAndStateFromContent();
782
825
      SyncLabelFromContent(mCommandContent);
783
826
    } else if (aAttribute == uWidgetAtoms::disabled) {
784
827
      SyncSensitivityFromContent(mCommandContent);
785
 
    } else if (aAttribute == uWidgetAtoms::checked) {
786
 
      SyncTypeAndStateFromContent();
787
828
    }
788
829
  } else if (aContent == mKeyContent) {
789
830
    SyncAccelFromContent();