From a11c662b4f2e1a36dd30bafda72e24977bbe7d46 Mon Sep 17 00:00:00 2001
From: Puck Meerburg <puck@puckipedia.nl>
Date: Mon, 30 Dec 2013 23:16:37 +0000
Subject: [PATCH] Pulse: Fix #6901
---
src/apps/pulse/Common.h | 2 ++
src/apps/pulse/DeskbarPulseView.cpp | 8 ++++++++
src/apps/pulse/Prefs.cpp | 16 +++++++++++++++-
src/apps/pulse/Prefs.h | 5 +++--
src/apps/pulse/PrefsWindow.cpp | 3 +++
src/apps/pulse/PulseWindow.cpp | 9 +++++++++
6 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/src/apps/pulse/Common.h b/src/apps/pulse/Common.h
index b21284c..df08285 100644
a
|
b
|
enum {
|
63 | 63 | #define DEFAULT_DESKBAR_ACTIVE_COLOR 0x20c02000 |
64 | 64 | #define DEFAULT_DESKBAR_IDLE_COLOR 0x20402000 |
65 | 65 | #define DEFAULT_DESKBAR_FRAME_COLOR 0x20202000 |
| 66 | #define DEFAULT_PREFS_FOCUSED_TAB 0 |
66 | 67 | #define DEFAULT_NORMAL_FADE_COLORS true |
| 68 | #define DEFAULT_OPEN_PREFWINDOW false |
67 | 69 | #define DEFAULT_DESKBAR_ICON_WIDTH 9 |
68 | 70 | |
69 | 71 | #endif |
diff --git a/src/apps/pulse/DeskbarPulseView.cpp b/src/apps/pulse/DeskbarPulseView.cpp
index 959c49d..2fb1ac0 100644
a
|
b
|
void DeskbarPulseView::AttachedToWindow() {
|
85 | 85 | // the current pulse rate and affecting other replicants |
86 | 86 | messagerunner = new BMessageRunner(messenger, new BMessage(PV_REPLICANT_PULSE), |
87 | 87 | 200000, -1); |
| 88 | if (prefs->open_prefwindow) { |
| 89 | BMessenger(this).SendMessage(PV_PREFERENCES); |
| 90 | } |
88 | 91 | } |
89 | 92 | |
90 | 93 | void DeskbarPulseView::MouseDown(BPoint point) { |
… |
… |
void DeskbarPulseView::Remove() {
|
191 | 194 | void DeskbarPulseView::SetMode(bool normal) { |
192 | 195 | if (normal) prefs->window_mode = NORMAL_WINDOW_MODE; |
193 | 196 | else prefs->window_mode = MINI_WINDOW_MODE; |
| 197 | if (prefswindow == NULL || prefswindow->IsHidden() |
| 198 | || prefswindow->IsMinimized()) |
| 199 | prefs->open_prefwindow = false; |
| 200 | else |
| 201 | prefs->open_prefwindow = true; |
194 | 202 | prefs->Save(); |
195 | 203 | be_roster->Launch(APP_SIGNATURE); |
196 | 204 | } |
diff --git a/src/apps/pulse/Prefs.cpp b/src/apps/pulse/Prefs.cpp
index 0e00d89..f283acd 100644
a
|
b
|
Prefs::Prefs()
|
109 | 109 | return; |
110 | 110 | } |
111 | 111 | |
| 112 | i = DEFAULT_PREFS_FOCUSED_TAB; |
| 113 | if (!GetInt("prefs_focused_tab", &prefs_focused_tab, &i)) { |
| 114 | fFatalError = true; |
| 115 | return; |
| 116 | } |
| 117 | |
112 | 118 | bool b = DEFAULT_NORMAL_FADE_COLORS; |
113 | 119 | if (!GetBool("normal_fade_colors", &normal_fade_colors, &b)) { |
114 | 120 | fFatalError = true; |
115 | 121 | return; |
116 | 122 | } |
117 | 123 | |
| 124 | b = DEFAULT_OPEN_PREFWINDOW; |
| 125 | if (!GetBool("open_prefwindow", &open_prefwindow, &b)) { |
| 126 | fFatalError = true; |
| 127 | return; |
| 128 | } |
| 129 | |
118 | 130 | // Use the default size unless it would prevent having at least |
119 | 131 | // a one pixel wide display per CPU... this will only happen with > quad |
120 | 132 | i = DEFAULT_DESKBAR_ICON_WIDTH; |
… |
… |
Prefs::Save()
|
293 | 305 | || !PutInt("deskbar_idle_color", &deskbar_idle_color) |
294 | 306 | || !PutInt("deskbar_frame_color", &deskbar_frame_color) |
295 | 307 | || !PutBool("normal_fade_colors", &normal_fade_colors) |
296 | | || !PutInt("deskbar_icon_width", &deskbar_icon_width)) |
| 308 | || !PutInt("prefs_focused_tab", &prefs_focused_tab) |
| 309 | || !PutInt("deskbar_icon_width", &deskbar_icon_width) |
| 310 | || !PutBool("open_prefwindow", &open_prefwindow)) |
297 | 311 | return false; |
298 | 312 | |
299 | 313 | return true; |
diff --git a/src/apps/pulse/Prefs.h b/src/apps/pulse/Prefs.h
index 98296af..fbb399e 100644
a
|
b
|
class Prefs {
|
23 | 23 | int window_mode, deskbar_icon_width; |
24 | 24 | BRect normal_window_rect, mini_window_rect, prefs_window_rect; |
25 | 25 | int normal_bar_color, mini_active_color, mini_idle_color, mini_frame_color, |
26 | | deskbar_active_color, deskbar_idle_color, deskbar_frame_color; |
27 | | bool normal_fade_colors; |
| 26 | deskbar_active_color, deskbar_idle_color, deskbar_frame_color, |
| 27 | prefs_focused_tab; |
| 28 | bool normal_fade_colors, open_prefwindow; |
28 | 29 | |
29 | 30 | private: |
30 | 31 | BFile *fFile; |
diff --git a/src/apps/pulse/PrefsWindow.cpp b/src/apps/pulse/PrefsWindow.cpp
index 85d7424..7b28514 100644
a
|
b
|
PrefsWindow::PrefsWindow(BRect frame, const char *name,
|
90 | 90 | fTabView->SetResizingMode(B_FOLLOW_NONE); |
91 | 91 | ResizeTo(fTabView->Frame().Width(), fTabView->Frame().bottom + 16.0f |
92 | 92 | + okButton->Bounds().Height()); |
| 93 | |
| 94 | fTabView->Select(fPrefs->prefs_focused_tab); |
93 | 95 | } |
94 | 96 | |
95 | 97 | |
96 | 98 | PrefsWindow::~PrefsWindow() |
97 | 99 | { |
98 | 100 | fPrefs->prefs_window_rect = Frame(); |
| 101 | fPrefs->prefs_focused_tab = fTabView->Selection(); |
99 | 102 | fPrefs->Save(); |
100 | 103 | } |
101 | 104 | |
diff --git a/src/apps/pulse/PulseWindow.cpp b/src/apps/pulse/PulseWindow.cpp
index 10e71b6..025291c 100644
a
|
b
|
PulseWindow::PulseWindow(BRect rect)
|
55 | 55 | fMiniPulseView->Hide(); |
56 | 56 | |
57 | 57 | fPrefsWindow = NULL; |
| 58 | if (pulseapp->prefs->open_prefwindow) { |
| 59 | BMessenger(this).SendMessage(PV_PREFERENCES); |
| 60 | } |
58 | 61 | } |
59 | 62 | |
60 | 63 | |
… |
… |
PulseWindow::SetMode(int newmode)
|
200 | 203 | bool |
201 | 204 | PulseWindow::QuitRequested() |
202 | 205 | { |
| 206 | PulseApp* app = (PulseApp*)be_app; |
| 207 | if (fPrefsWindow == NULL || fPrefsWindow->IsHidden() |
| 208 | || fPrefsWindow->IsMinimized()) |
| 209 | app->prefs->open_prefwindow = false; |
| 210 | else |
| 211 | app->prefs->open_prefwindow = true; |
203 | 212 | be_app->PostMessage(B_QUIT_REQUESTED); |
204 | 213 | return true; |
205 | 214 | } |