diff --git a/Makefile b/Makefile index 263e440..f32347d 100644 --- a/Makefile +++ b/Makefile @@ -91,14 +91,14 @@ OPTIMIZE := # will recreate only the "locales/en.catkeys" file. Use it as a template # for creating catkeys for other languages. All localization files must be # placed in the "locales" subdirectory. -LOCALES = ca de en_AU en_GB en eo es fr fur it nl pt ru sv tr uk +LOCALES = ca de en_AU en_GB en eo es fr fur it nb nl pt ru sv tr uk # Specify all the preprocessor symbols to be defined. The symbols will not # have their values set automatically; you must supply the value (if any) to # use. For example, setting DEFINES to "DEBUG=1" will cause the compiler # option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" would pass # "-DDEBUG" on the compiler's command line. -DEFINES := +DEFINES := # Specify the warning level. Either NONE (suppress all warnings), # ALL (enable all warnings), or leave blank (enable default warnings). @@ -110,7 +110,7 @@ SYMBOLS := # Includes debug information, which allows the binary to be debugged easily. # If set to "TRUE", debug info will be created. -DEBUGGER := +DEBUGGER := # Specify any additional compiler flags to be used. COMPILER_FLAGS = diff --git a/Source/ForecastDeskbarView.cpp b/Source/ForecastDeskbarView.cpp index 54f1fc6..dceb25f 100644 --- a/Source/ForecastDeskbarView.cpp +++ b/Source/ForecastDeskbarView.cpp @@ -3,22 +3,26 @@ * All rights reserved. Distributed under the terms of the MIT license. */ -#include #include +#include #include #include #include #include #include -#include "App.h" #include "ForecastDeskbarView.h" #include "ForecastView.h" #include "Util.h" +#undef B_TRANSLATION_CONTEXT +#define B_TRANSLATION_CONTEXT "ForecastDeskbarView" + const uint32 kUpdateForecastMessage = 'Updt'; const float kToolTipDelay = 1000000; /*1000000ms = 1s*/ +int fMaxHeight; +extern "C" _EXPORT BView* instantiate_deskbar_item(float maxWidth, float maxHeight); ForecastDeskbarView::ForecastDeskbarView(BRect viewSize, ForecastView* forecastView) : @@ -28,6 +32,13 @@ ForecastDeskbarView::ForecastDeskbarView(BRect viewSize, ForecastView* forecastV fMessageRunner = NULL; } +ForecastDeskbarView::ForecastDeskbarView(BMessage* archive) + : + BView(archive) +{ + fMessageRunner = NULL; +} + ForecastDeskbarView::~ForecastDeskbarView() { @@ -48,17 +59,16 @@ ForecastDeskbarView::AttachedToWindow() AdoptParentColors(); } -extern "C" _EXPORT BView* instantiate_deskbar_item(); - -BView* -instantiate_deskbar_item() +extern "C" _EXPORT BView* +instantiate_deskbar_item(float maxWidth, float maxHeight) { + fMaxHeight = maxHeight; BMessage settings; LoadSettings(settings); ForecastDeskbarView* view = new ForecastDeskbarView( - BRect(0, 0, 16, 16), - new ForecastView(BRect(0, 0, 0, 0), + BRect(0, 0, maxHeight, maxHeight), + new ForecastView(BRect(0, 0, 0, 0), &settings)); entry_ref appRef; settings.FindRef("appLocation", &appRef); @@ -73,11 +83,11 @@ ForecastDeskbarView::Draw(BRect drawRect) BView::Draw(drawRect); SetDrawingMode(B_OP_OVER); - // TO-DO: Try with + // TO-DO: Try with // SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); BBitmap* bitmap = fForecastView->GetWeatherIcon(static_cast(1)); if (bitmap) - DrawBitmapAsync(bitmap, BPoint(0, 0)); + DrawBitmapAsync(bitmap, drawRect); SetDrawingMode(B_OP_COPY); } @@ -88,7 +98,7 @@ ForecastDeskbarView::Instantiate(BMessage* archive) if (!validate_instantiation(archive, "ForecastDeskbarView")) return NULL; - return reinterpret_cast(instantiate_deskbar_item()); + return reinterpret_cast(instantiate_deskbar_item(fMaxHeight, fMaxHeight)); } @@ -96,16 +106,13 @@ void ForecastDeskbarView::MessageReceived(BMessage* message) { if (message->what == kUpdateForecastMessage) { - BString weatherDetailsText; - weatherDetailsText << "Temperature: " - << FormatString(fForecastView->Unit(), - fForecastView->Temperature()) - << "\n"; - weatherDetailsText << "Condition: " << fForecastView->GetCondition() - << "\n"; - weatherDetailsText << "Location: " << fForecastView->CityName(); - SetToolTip(weatherDetailsText.String()); - + BString tooltip; + BString temperature = FormatString(fForecastView->Unit(), fForecastView->Temperature()); + tooltip.SetToFormat(B_TRANSLATE("Temperature: %s\nCondition: %s\nLocation: %s"), + temperature.String(), + fForecastView->GetStatus().String(), + fForecastView->CityName().String()); + SetToolTip(tooltip); Invalidate(); } else BView::MessageReceived(message); diff --git a/Source/ForecastDeskbarView.h b/Source/ForecastDeskbarView.h index cfc7934..28b5395 100644 --- a/Source/ForecastDeskbarView.h +++ b/Source/ForecastDeskbarView.h @@ -7,9 +7,6 @@ #include #include -#include -#include -#include #include #include "ForecastView.h" @@ -17,16 +14,17 @@ class ForecastDeskbarView : public BView { - + public: ForecastDeskbarView(BRect viewSize, ForecastView* forecastView); + ForecastDeskbarView(BMessage* archive); ~ForecastDeskbarView(); virtual void AttachedToWindow(); virtual void MouseDown(BPoint point); virtual void MouseMoved( - BPoint point, - uint32 message, + BPoint point, + uint32 message, const BMessage* dragMessage); virtual void Draw(BRect drawRect); virtual void MessageReceived(BMessage* message); @@ -41,4 +39,4 @@ class ForecastDeskbarView : public BView }; -#endif // FORECASTDESKBARVIEW_H +#endif // FORECASTDESKBARVIEW_H \ No newline at end of file diff --git a/Source/ForecastView.cpp b/Source/ForecastView.cpp index abfb6ad..edc36ad 100644 --- a/Source/ForecastView.cpp +++ b/Source/ForecastView.cpp @@ -4,8 +4,8 @@ * Copyright 2015 Przemysław Buczkowski * Copyright 2014 George White * All rights reserved. Distributed under the terms of the MIT license. - */ - + */ + #include #include #include @@ -56,7 +56,7 @@ extern const char* kSignature; class TransparentButton : public BButton { public: - TransparentButton(const char* name, const char* label, + TransparentButton(const char* name, const char* label, BMessage* message); virtual void Draw(BRect updateRect); }; @@ -1246,4 +1246,4 @@ ForecastView::_NetworkConnected() } } return false; -} +} diff --git a/Source/MainWindow.cpp b/Source/MainWindow.cpp index 2a145cd..59a53bb 100644 --- a/Source/MainWindow.cpp +++ b/Source/MainWindow.cpp @@ -46,8 +46,8 @@ MainWindow::_PrepareMenuBar(void) B_TRANSLATE("Refresh"), new BMessage(kUpdateMessage), 'R')); menu->AddSeparatorItem(); // Remove menu item until Deskbar replicant is fixed - // menu->AddItem(fReplicantMenuItem = new BMenuItem(B_TRANSLATE("Deskbar - //Replicant"), new BMessage(kToggleDeskbarReplicantMessage), 'T')); + menu->AddItem(fReplicantMenuItem = new BMenuItem(B_TRANSLATE("Deskbar replicant"), + new BMessage(kToggleDeskbarReplicantMessage), 'T')); menu->AddItem(new BMenuItem(B_TRANSLATE("Change location" B_UTF8_ELLIPSIS), new BMessage(kCitySelectionMessage), 'L')); menu->AddItem(new BMenuItem(B_TRANSLATE("Preferences" B_UTF8_ELLIPSIS), @@ -90,7 +90,7 @@ MainWindow::MainWindow() fForecastView = new ForecastView(BRect(0, 0, 100, 100), &settings); AddChild(fForecastView); // Enable when works - // fShowForecastMenuItem->SetMarked(fForecastView->ShowForecast()); + //fShowForecastMenuItem->SetMarked(fForecastView->ShowForecast()); } @@ -253,8 +253,8 @@ void MainWindow::MenusBeginning() { // Menu item removed until Deskbar replicant is fixed - // BDeskbar deskbar; - // fReplicantMenuItem->SetMarked(deskbar.HasItem("ForecastDeskbarView")); + BDeskbar deskbar; + fReplicantMenuItem->SetMarked(deskbar.HasItem("ForecastDeskbarView")); } diff --git a/locales/en.catkeys b/locales/en.catkeys index 0e2ec2c..eee37c2 100644 --- a/locales/en.catkeys +++ b/locales/en.catkeys @@ -1,4 +1,4 @@ -1 English x-vnd.przemub.Weather 704655087 +1 English x-vnd.przemub.Weather 2992569182 No network ForecastView No network OK ForecastView OK Slight rain ForecastView Slight rain @@ -6,14 +6,15 @@ Slight snow showers ForecastView Slight snow showers Loading… ForecastView Loading… OK MainWindow OK Quit MainWindow Quit -Dense drizzle ForecastView Dense drizzle Heavy snow showers ForecastView Heavy snow showers +Dense drizzle ForecastView Dense drizzle City: CitiesListSelectionWindow City: Background ForecastView Background Preferences… MainWindow Preferences… Freezing dense drizzle ForecastView Freezing dense drizzle Use Celsius °C PreferencesWindow Use Celsius °C Heavy snow fall ForecastView Heavy snow fall +Deskbar replicant MainWindow Deskbar replicant Weather (The Replicant version) ForecastView Weather (The Replicant version) Weather System name Weather Loading… MainWindow Loading… @@ -33,6 +34,7 @@ Clear sky ForecastView Clear sky Moderate rain showers ForecastView Moderate rain showers Enter location: city, country, region CitiesListSelectionWindow Enter location: city, country, region Snow grains ForecastView Snow grains +Temperature: %s\nCondition: %s\nLocation: %s ForecastDeskbarView Temperature: %s\nCondition: %s\nLocation: %s Slight rain showers ForecastView Slight rain showers Heavy rain ForecastView Heavy rain Light drizzle ForecastView Light drizzle diff --git a/locales/nb.catkeys b/locales/nb.catkeys new file mode 100644 index 0000000..81f2bfb --- /dev/null +++ b/locales/nb.catkeys @@ -0,0 +1,60 @@ +1 Norwegian x-vnd.przemub.Weather 704655087 +About Weather ForecastView Om Weather +Background ForecastView Bakgrunn +Clear sky ForecastView Klar himmel +Connecting… ForecastView Kobler til... +Connection error ForecastView Tilkoblingsfeil +Default ForecastView Standard +Dense drizzle ForecastView Tett duskregn +Depositing rime fog ForecastView Rimtåke +Fog ForecastView Tåke +Freezing dense drizzle ForecastView Underkjølt tett duskregn +Freezing light drizzle ForecastView Underkjølt lett duskregn +Heavy freezing rain ForecastView Kraftig underkjølt regn +Heavy rain ForecastView Kraftig regn +Heavy rain showers ForecastView Kraftige regnbyger +Heavy snow fall ForecastView Kraftig snøfall +Heavy snow showers ForecastView Kraftige regnbyger +Light drizzle ForecastView Lett duskregn +Light freezing rain ForecastView Lett underkjølt regn +Loading… ForecastView Laster... +Mainly clear ForecastView Hovedsakelig klart +Moderate drizzle ForecastView Moderat duskregn +Moderate rain ForecastView Moderat regn +Moderate rain showers ForecastView Moderate regnbyger +Moderate snow fall ForecastView Moderat snøfall +No network ForecastView Ingen nettverk +Not available ForecastView Ikke tilgjengelig +OK ForecastView OK +Overcast ForecastView Overskyet +Partly cloudy ForecastView Delvis skyet +Slight rain ForecastView Lett regn +Slight rain showers ForecastView Lette regnbyger +Slight snow fall ForecastView Lett snøfall +Slight snow showers ForecastView Lette snøbyger +Snow grains ForecastView Snøkorn +Text ForecastView Tekst +Thunderstorm ForecastView Tordenvær +Thunderstorm with heavy hail ForecastView Tordenvær med kraftig hagl +Thunderstorm with slight hail ForecastView Tordenvær med lett hagl +Transparent ForecastView Gjennomsiktig +Weather (The Replicant version) ForecastView Weather (replikantversjonen) +About Weather MainWindow Om Weather +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. +Change location… MainWindow Bytt sted... +Loading… MainWindow Laster... +OK MainWindow OK +Preferences… MainWindow Innstillinger... +Quit MainWindow Avslutt +Refresh MainWindow Oppdater +Unable to create a deskbar replicant. The error is: \" MainWindow Kan ikke lage en skrivebordsreplikant. Feilen er: \" +Cancel CitiesListSelectionWindow Avbryt +Choose location CitiesListSelectionWindow Velg sted +City: CitiesListSelectionWindow By: +Enter location: city, country, region CitiesListSelectionWindow Velg sted: by, land, område +OK CitiesListSelectionWindow OK +OK PreferencesWindow OK +Preferences PreferencesWindow Innstillinger +Use Celsius °C PreferencesWindow Bruk Celsius °C +Use Fahrenheit °F PreferencesWindow Bruk Fahrenheit °F +Weather System name Weather