From 1e8a56019621ec01c643dda285c498e87786f59b Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Sun, 11 Dec 2016 10:15:50 -0600 Subject: [PATCH] SoftwareUpdater: Handle message events, Exit on cancel press. --- .../softwareupdater/SoftwareUpdaterWindow.cpp | 23 +++++++++++++++---- .../softwareupdater/SoftwareUpdaterWindow.h | 2 ++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/apps/softwareupdater/SoftwareUpdaterWindow.cpp b/src/apps/softwareupdater/SoftwareUpdaterWindow.cpp index c0f211a6ac..43c38f28e7 100644 --- a/src/apps/softwareupdater/SoftwareUpdaterWindow.cpp +++ b/src/apps/softwareupdater/SoftwareUpdaterWindow.cpp @@ -28,8 +28,8 @@ #define B_TRANSLATION_CONTEXT "SoftwareUpdater" -const uint32 UPDATE_MESSAGE = 'iUPD'; -const uint32 EXIT_MESSAGE = 'iEXT'; +const uint32 kMsgUpdate = 'iUPD'; +const uint32 kMsgExit = 'iEXT'; SoftwareUpdaterWindow::SoftwareUpdaterWindow() @@ -50,10 +50,10 @@ SoftwareUpdaterWindow::SoftwareUpdaterWindow() fStripeView = new StripeView(icon); BButton* updateButton = new BButton("Update now", - new BMessage(UPDATE_MESSAGE)); + new BMessage(kMsgUpdate)); BButton* exitButton = new BButton("Cancel", - new BMessage(EXIT_MESSAGE)); + new BMessage(kMsgExit)); // Form text based on updates available BStringView* headerView; @@ -118,3 +118,18 @@ SoftwareUpdaterWindow::QuitRequested() be_app->PostMessage(B_QUIT_REQUESTED); return true; } + + +void +SoftwareUpdaterWindow::MessageReceived(BMessage* message) +{ + switch (message->what) { + case kMsgExit: + QuitRequested(); + break; + case kMsgUpdate: + break; + default: + BWindow::MessageReceived(message); + } +} diff --git a/src/apps/softwareupdater/SoftwareUpdaterWindow.h b/src/apps/softwareupdater/SoftwareUpdaterWindow.h index 41e39820d0..fb3d979b76 100644 --- a/src/apps/softwareupdater/SoftwareUpdaterWindow.h +++ b/src/apps/softwareupdater/SoftwareUpdaterWindow.h @@ -22,6 +22,8 @@ public: ~SoftwareUpdaterWindow(); bool QuitRequested(); + void MessageReceived(BMessage* message); + private: StripeView* fStripeView; app_info* fAppInfo;