Skip to content

Commit acd0672

Browse files
committed
Fix Deskbar icon and tooltip
1 parent cb695af commit acd0672

7 files changed

+109
-42
lines changed

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ OPTIMIZE :=
9191
# will recreate only the "locales/en.catkeys" file. Use it as a template
9292
# for creating catkeys for other languages. All localization files must be
9393
# placed in the "locales" subdirectory.
94-
LOCALES = ca de en_AU en_GB en eo es fr fur it nl pt ru sv tr uk
94+
LOCALES = ca de en_AU en_GB en eo es fr fur it nb nl pt ru sv tr uk
9595

9696
# Specify all the preprocessor symbols to be defined. The symbols will not
9797
# have their values set automatically; you must supply the value (if any) to
9898
# use. For example, setting DEFINES to "DEBUG=1" will cause the compiler
9999
# option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" would pass
100100
# "-DDEBUG" on the compiler's command line.
101-
DEFINES :=
101+
DEFINES :=
102102

103103
# Specify the warning level. Either NONE (suppress all warnings),
104104
# ALL (enable all warnings), or leave blank (enable default warnings).
@@ -110,7 +110,7 @@ SYMBOLS :=
110110

111111
# Includes debug information, which allows the binary to be debugged easily.
112112
# If set to "TRUE", debug info will be created.
113-
DEBUGGER :=
113+
DEBUGGER :=
114114

115115
# Specify any additional compiler flags to be used.
116116
COMPILER_FLAGS =

Source/ForecastDeskbarView.cpp

+28-21
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,26 @@
33
* All rights reserved. Distributed under the terms of the MIT license.
44
*/
55

6-
#include <Alert.h>
76
#include <Bitmap.h>
7+
#include <Catalog.h>
88
#include <Looper.h>
99
#include <MessageRunner.h>
1010
#include <Roster.h>
1111
#include <String.h>
1212
#include <StringView.h>
1313

14-
#include "App.h"
1514
#include "ForecastDeskbarView.h"
1615
#include "ForecastView.h"
1716
#include "Util.h"
1817

18+
#undef B_TRANSLATION_CONTEXT
19+
#define B_TRANSLATION_CONTEXT "ForecastDeskbarView"
20+
1921
const uint32 kUpdateForecastMessage = 'Updt';
2022
const float kToolTipDelay = 1000000; /*1000000ms = 1s*/
23+
int fMaxHeight;
2124

25+
extern "C" _EXPORT BView* instantiate_deskbar_item(float maxWidth, float maxHeight);
2226

2327
ForecastDeskbarView::ForecastDeskbarView(BRect viewSize, ForecastView* forecastView)
2428
:
@@ -28,6 +32,13 @@ ForecastDeskbarView::ForecastDeskbarView(BRect viewSize, ForecastView* forecastV
2832
fMessageRunner = NULL;
2933
}
3034

35+
ForecastDeskbarView::ForecastDeskbarView(BMessage* archive)
36+
:
37+
BView(archive)
38+
{
39+
fMessageRunner = NULL;
40+
}
41+
3142

3243
ForecastDeskbarView::~ForecastDeskbarView()
3344
{
@@ -48,17 +59,16 @@ ForecastDeskbarView::AttachedToWindow()
4859
AdoptParentColors();
4960
}
5061

51-
extern "C" _EXPORT BView* instantiate_deskbar_item();
5262

53-
54-
BView*
55-
instantiate_deskbar_item()
63+
extern "C" _EXPORT BView*
64+
instantiate_deskbar_item(float maxWidth, float maxHeight)
5665
{
66+
fMaxHeight = maxHeight;
5767
BMessage settings;
5868
LoadSettings(settings);
5969
ForecastDeskbarView* view = new ForecastDeskbarView(
60-
BRect(0, 0, 16, 16),
61-
new ForecastView(BRect(0, 0, 0, 0),
70+
BRect(0, 0, maxHeight, maxHeight),
71+
new ForecastView(BRect(0, 0, 0, 0),
6272
&settings));
6373
entry_ref appRef;
6474
settings.FindRef("appLocation", &appRef);
@@ -73,11 +83,11 @@ ForecastDeskbarView::Draw(BRect drawRect)
7383
BView::Draw(drawRect);
7484

7585
SetDrawingMode(B_OP_OVER);
76-
// TO-DO: Try with
86+
// TO-DO: Try with
7787
// SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
7888
BBitmap* bitmap = fForecastView->GetWeatherIcon(static_cast<weatherIconSize>(1));
7989
if (bitmap)
80-
DrawBitmapAsync(bitmap, BPoint(0, 0));
90+
DrawBitmapAsync(bitmap, drawRect);
8191
SetDrawingMode(B_OP_COPY);
8292
}
8393

@@ -88,24 +98,21 @@ ForecastDeskbarView::Instantiate(BMessage* archive)
8898
if (!validate_instantiation(archive, "ForecastDeskbarView"))
8999
return NULL;
90100

91-
return reinterpret_cast<BArchivable*>(instantiate_deskbar_item());
101+
return reinterpret_cast<BArchivable*>(instantiate_deskbar_item(fMaxHeight, fMaxHeight));
92102
}
93103

94104

95105
void
96106
ForecastDeskbarView::MessageReceived(BMessage* message)
97107
{
98108
if (message->what == kUpdateForecastMessage) {
99-
BString weatherDetailsText;
100-
weatherDetailsText << "Temperature: "
101-
<< FormatString(fForecastView->Unit(),
102-
fForecastView->Temperature())
103-
<< "\n";
104-
weatherDetailsText << "Condition: " << fForecastView->GetCondition()
105-
<< "\n";
106-
weatherDetailsText << "Location: " << fForecastView->CityName();
107-
SetToolTip(weatherDetailsText.String());
108-
109+
BString tooltip;
110+
BString temperature = FormatString(fForecastView->Unit(), fForecastView->Temperature()).String();
111+
tooltip.SetToFormat(B_TRANSLATE("Temperature: %s\nCondition: %s\nLocation: %s"),
112+
temperature.String(),
113+
fForecastView->CityName().String(),
114+
fForecastView->GetStatus().String());
115+
SetToolTip(tooltip);
109116
Invalidate();
110117
} else
111118
BView::MessageReceived(message);

Source/ForecastDeskbarView.h

+5-7
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,24 @@
77

88
#include <Bitmap.h>
99
#include <Entry.h>
10-
#include <Looper.h>
11-
#include <MessageRunner.h>
12-
#include <SupportDefs.h>
1310
#include <View.h>
1411

1512
#include "ForecastView.h"
1613

1714

1815
class ForecastDeskbarView : public BView
1916
{
20-
17+
2118
public:
2219
ForecastDeskbarView(BRect viewSize, ForecastView* forecastView);
20+
ForecastDeskbarView(BMessage* archive);
2321
~ForecastDeskbarView();
2422

2523
virtual void AttachedToWindow();
2624
virtual void MouseDown(BPoint point);
2725
virtual void MouseMoved(
28-
BPoint point,
29-
uint32 message,
26+
BPoint point,
27+
uint32 message,
3028
const BMessage* dragMessage);
3129
virtual void Draw(BRect drawRect);
3230
virtual void MessageReceived(BMessage* message);
@@ -41,4 +39,4 @@ class ForecastDeskbarView : public BView
4139
};
4240

4341

44-
#endif // FORECASTDESKBARVIEW_H
42+
#endif // FORECASTDESKBARVIEW_H

Source/ForecastView.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* Copyright 2015 Przemysław Buczkowski <[email protected]>
55
* Copyright 2014 George White
66
* All rights reserved. Distributed under the terms of the MIT license.
7-
*/
8-
7+
*/
8+
99
#include <Alert.h>
1010
#include <AppKit.h>
1111
#include <Bitmap.h>
@@ -56,7 +56,7 @@ extern const char* kSignature;
5656
class TransparentButton : public BButton
5757
{
5858
public:
59-
TransparentButton(const char* name, const char* label,
59+
TransparentButton(const char* name, const char* label,
6060
BMessage* message);
6161
virtual void Draw(BRect updateRect);
6262
};
@@ -1246,4 +1246,4 @@ ForecastView::_NetworkConnected()
12461246
}
12471247
}
12481248
return false;
1249-
}
1249+
}

Source/MainWindow.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ MainWindow::_PrepareMenuBar(void)
4646
B_TRANSLATE("Refresh"), new BMessage(kUpdateMessage), 'R'));
4747
menu->AddSeparatorItem();
4848
// Remove menu item until Deskbar replicant is fixed
49-
// menu->AddItem(fReplicantMenuItem = new BMenuItem(B_TRANSLATE("Deskbar
50-
//Replicant"), new BMessage(kToggleDeskbarReplicantMessage), 'T'));
49+
menu->AddItem(fReplicantMenuItem = new BMenuItem(B_TRANSLATE("Deskbar replicant"),
50+
new BMessage(kToggleDeskbarReplicantMessage), 'T'));
5151
menu->AddItem(new BMenuItem(B_TRANSLATE("Change location" B_UTF8_ELLIPSIS),
5252
new BMessage(kCitySelectionMessage), 'L'));
5353
menu->AddItem(new BMenuItem(B_TRANSLATE("Preferences" B_UTF8_ELLIPSIS),
@@ -90,7 +90,7 @@ MainWindow::MainWindow()
9090
fForecastView = new ForecastView(BRect(0, 0, 100, 100), &settings);
9191
AddChild(fForecastView);
9292
// Enable when works
93-
// fShowForecastMenuItem->SetMarked(fForecastView->ShowForecast());
93+
//fShowForecastMenuItem->SetMarked(fForecastView->ShowForecast());
9494
}
9595

9696

@@ -253,8 +253,8 @@ void
253253
MainWindow::MenusBeginning()
254254
{
255255
// Menu item removed until Deskbar replicant is fixed
256-
// BDeskbar deskbar;
257-
// fReplicantMenuItem->SetMarked(deskbar.HasItem("ForecastDeskbarView"));
256+
BDeskbar deskbar;
257+
fReplicantMenuItem->SetMarked(deskbar.HasItem("ForecastDeskbarView"));
258258
}
259259

260260

locales/en.catkeys

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
1 English x-vnd.przemub.Weather 704655087
1+
1 English x-vnd.przemub.Weather 2992569182
22
No network ForecastView No network
33
OK ForecastView OK
44
Slight rain ForecastView Slight rain
55
Slight snow showers ForecastView Slight snow showers
66
Loading… ForecastView Loading…
77
OK MainWindow OK
88
Quit MainWindow Quit
9-
Dense drizzle ForecastView Dense drizzle
109
Heavy snow showers ForecastView Heavy snow showers
10+
Dense drizzle ForecastView Dense drizzle
1111
City: CitiesListSelectionWindow City:
1212
Background ForecastView Background
1313
Preferences… MainWindow Preferences…
1414
Freezing dense drizzle ForecastView Freezing dense drizzle
1515
Use Celsius °C PreferencesWindow Use Celsius °C
1616
Heavy snow fall ForecastView Heavy snow fall
17+
Deskbar replicant MainWindow Deskbar replicant
1718
Weather (The Replicant version) ForecastView Weather (The Replicant version)
1819
Weather System name Weather
1920
Loading… MainWindow Loading…
@@ -33,6 +34,7 @@ Clear sky ForecastView Clear sky
3334
Moderate rain showers ForecastView Moderate rain showers
3435
Enter location: city, country, region CitiesListSelectionWindow Enter location: city, country, region
3536
Snow grains ForecastView Snow grains
37+
Temperature: %s\nCondition: %s\nLocation: %s ForecastDeskbarView Temperature: %s\nCondition: %s\nLocation: %s
3638
Slight rain showers ForecastView Slight rain showers
3739
Heavy rain ForecastView Heavy rain
3840
Light drizzle ForecastView Light drizzle

locales/nb.catkeys

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
1 Norwegian x-vnd.przemub.Weather 704655087
2+
About Weather ForecastView Om Weather
3+
Background ForecastView Bakgrunn
4+
Clear sky ForecastView Klar himmel
5+
Connecting… ForecastView Kobler til...
6+
Connection error ForecastView Tilkoblingsfeil
7+
Default ForecastView Standard
8+
Dense drizzle ForecastView Tett duskregn
9+
Depositing rime fog ForecastView Rimtåke
10+
Fog ForecastView Tåke
11+
Freezing dense drizzle ForecastView Underkjølt tett duskregn
12+
Freezing light drizzle ForecastView Underkjølt lett duskregn
13+
Heavy freezing rain ForecastView Kraftig underkjølt regn
14+
Heavy rain ForecastView Kraftig regn
15+
Heavy rain showers ForecastView Kraftige regnbyger
16+
Heavy snow fall ForecastView Kraftig snøfall
17+
Heavy snow showers ForecastView Kraftige regnbyger
18+
Light drizzle ForecastView Lett duskregn
19+
Light freezing rain ForecastView Lett underkjølt regn
20+
Loading… ForecastView Laster...
21+
Mainly clear ForecastView Hovedsakelig klart
22+
Moderate drizzle ForecastView Moderat duskregn
23+
Moderate rain ForecastView Moderat regn
24+
Moderate rain showers ForecastView Moderate regnbyger
25+
Moderate snow fall ForecastView Moderat snøfall
26+
No network ForecastView Ingen nettverk
27+
Not available ForecastView Ikke tilgjengelig
28+
OK ForecastView OK
29+
Overcast ForecastView Overskyet
30+
Partly cloudy ForecastView Delvis skyet
31+
Slight rain ForecastView Lett regn
32+
Slight rain showers ForecastView Lette regnbyger
33+
Slight snow fall ForecastView Lett snøfall
34+
Slight snow showers ForecastView Lette snøbyger
35+
Snow grains ForecastView Snøkorn
36+
Text ForecastView Tekst
37+
Thunderstorm ForecastView Tordenvær
38+
Thunderstorm with heavy hail ForecastView Tordenvær med kraftig hagl
39+
Thunderstorm with slight hail ForecastView Tordenvær med lett hagl
40+
Transparent ForecastView Gjennomsiktig
41+
Weather (The Replicant version) ForecastView Weather (replikantversjonen)
42+
About Weather MainWindow Om Weather
43+
An open source weather app showing a forecast for the next 5 days. MainWindow En åpen kildekode vær-app som viser et værvarsel for de neste 5 dagene.
44+
Change location… MainWindow Bytt sted...
45+
Loading… MainWindow Laster...
46+
OK MainWindow OK
47+
Preferences… MainWindow Innstillinger...
48+
Quit MainWindow Avslutt
49+
Refresh MainWindow Oppdater
50+
Unable to create a deskbar replicant. The error is: \" MainWindow Kan ikke lage en skrivebordsreplikant. Feilen er: \"
51+
Cancel CitiesListSelectionWindow Avbryt
52+
Choose location CitiesListSelectionWindow Velg sted
53+
City: CitiesListSelectionWindow By:
54+
Enter location: city, country, region CitiesListSelectionWindow Velg sted: by, land, område
55+
OK CitiesListSelectionWindow OK
56+
OK PreferencesWindow OK
57+
Preferences PreferencesWindow Innstillinger
58+
Use Celsius °C PreferencesWindow Bruk Celsius °C
59+
Use Fahrenheit °F PreferencesWindow Bruk Fahrenheit °F
60+
Weather System name Weather

0 commit comments

Comments
 (0)