Ticket #9426: 0001-Changed-notification-button-to-a-checkbox.patch

File 0001-Changed-notification-button-to-a-checkbox.patch, 4.3 KB (added by Secris, 10 years ago)

Patch with all changes included.

  • src/preferences/notifications/GeneralView.cpp

    From ab10faa2ad952cc4f728549efaf336917e27a67b Mon Sep 17 00:00:00 2001
    From: Sean Thames <secris1@gmail.com>
    Date: Wed, 5 Mar 2014 15:48:18 -0500
    Subject: [PATCH] Changed notification button to a checkbox. Changed to more
     appropriate variable names. Fixed a potential issue with fNotificationBox
     getting out of sync
    
    ---
     src/preferences/notifications/GeneralView.cpp | 47 +++++++--------------------
     src/preferences/notifications/GeneralView.h   |  4 +--
     2 files changed, 12 insertions(+), 39 deletions(-)
    
    diff --git a/src/preferences/notifications/GeneralView.cpp b/src/preferences/notifications/GeneralView.cpp
    index db6e9ce..e9fc6c0 100644
    a b  
    3939
    4040#undef B_TRANSLATION_CONTEXT
    4141#define B_TRANSLATION_CONTEXT "GeneralView"
    42 const int32 kServer = '_TSR';
    43 
    44 const char* kStartServer = B_TRANSLATE("Enable notifications");
    45 const char* kStopServer = B_TRANSLATE("Disable notifications");
    46 const char* kStarted = B_TRANSLATE("Events are notified");
    47 const char* kStopped = B_TRANSLATE("Events are not notified");
    48 
     42const int32 kToggleNotifications = '_TSR';
    4943
    5044GeneralView::GeneralView(SettingsHost* host)
    5145    :
    5246    SettingsPane("general", host)
    5347{
    54     BFont statusFont;
    55 
    56     // Set a smaller font for the status label
    57     statusFont.SetSize(be_plain_font->Size() * 0.8);
    58 
    59     // Status button and label
    60     fServerButton = new BButton("server", kStartServer, new BMessage(kServer));
    61     fStatusLabel = new BStringView("status", kStopped);
    62     fStatusLabel->SetFont(&statusFont);
    63 
    64     // Update status label and server button
    65     if (_IsServerRunning()) {
    66         fServerButton->SetLabel(kStopServer);
    67         fStatusLabel->SetText(kStarted);
    68     } else {
    69         fServerButton->SetLabel(kStartServer);
    70         fStatusLabel->SetText(kStopped);
    71     }
     48    // Notifications
     49    fNotificationBox = new BCheckBox("server",
     50        B_TRANSLATE("Enable notifications"),
     51        new BMessage(kToggleNotifications));
    7252
    7353    // Autostart
    7454    fAutoStart = new BCheckBox("autostart",
    GeneralView::GeneralView(SettingsHost* host)  
    9373    SetLayout(new BGroupLayout(B_VERTICAL));
    9474    AddChild(BGroupLayoutBuilder(B_VERTICAL, inset)
    9575        .AddGroup(B_HORIZONTAL, inset)
    96             .Add(fServerButton)
    97             .Add(fStatusLabel)
     76            .Add(fNotificationBox)
    9877            .AddGlue()
    9978        .End()
    10079
    GeneralView::GeneralView(SettingsHost* host)  
    11695void
    11796GeneralView::AttachedToWindow()
    11897{
    119     fServerButton->SetTarget(this);
     98    fNotificationBox->SetTarget(this);
    12099    fAutoStart->SetTarget(this);
    121100    fTimeout->SetTarget(this);
    122101}
    void  
    126105GeneralView::MessageReceived(BMessage* msg)
    127106{
    128107    switch (msg->what) {
    129         case kServer: {
     108        case kToggleNotifications: {
    130109                entry_ref ref;
    131110
    132111                // Check if server is available
    GeneralView::MessageReceived(BMessage* msg)  
    141120                    return;
    142121                }
    143122
    144                 if (_IsServerRunning()) {
     123                if (fNotificationBox->Value() == B_CONTROL_OFF) {
    145124                    // Server team
    146125                    team_id team = be_roster->TeamFor(kNotificationServerSignature);
    147126
    GeneralView::MessageReceived(BMessage* msg)  
    170149                        (void)alert->Go();
    171150                        return;
    172151                    }
    173 
    174                     fServerButton->SetLabel(kStartServer);
    175                     fStatusLabel->SetText(kStopped);
    176152                } else {
    177153                    // Start server
    178154                    status_t err = be_roster->Launch(kNotificationServerSignature);
    GeneralView::MessageReceived(BMessage* msg)  
    188164                        (void)alert->Go();
    189165                        return;
    190166                    }
    191 
    192                     fServerButton->SetLabel(kStopServer);
    193                     fStatusLabel->SetText(kStarted);
    194167                }
    195168            } break;
    196169        case kSettingChanged:
    GeneralView::Load()  
    231204
    232205    char buffer[255];
    233206
     207    fNotificationBox->SetValue(_IsServerRunning() ? B_CONTROL_ON : B_CONTROL_OFF);
     208
    234209    bool autoStart;
    235210    if (settings.FindBool(kAutoStartName, &autoStart) != B_OK)
    236211        autoStart = kDefaultAutoStart;
  • src/preferences/notifications/GeneralView.h

    diff --git a/src/preferences/notifications/GeneralView.h b/src/preferences/notifications/GeneralView.h
    index 12c5f40..0464d1c 100644
    a b  
    99#include "SettingsPane.h"
    1010
    1111class BCheckBox;
    12 class BButton;
    1312class BStringView;
    1413class BTextControl;
    1514
    public:  
    2625            status_t        Revert();
    2726
    2827private:
    29         BButton*            fServerButton;
    30         BStringView*        fStatusLabel;
     28        BCheckBox*          fNotificationBox;
    3129        BCheckBox*          fAutoStart;
    3230        BTextControl*       fTimeout;
    3331        BCheckBox*          fHideAll;