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..de93765 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 uint32 kOpenWeatherApp = 'Owea'; const float kToolTipDelay = 1000000; /*1000000ms = 1s*/ +extern "C" _EXPORT BView* instantiate_deskbar_item(); ForecastDeskbarView::ForecastDeskbarView(BRect viewSize, ForecastView* forecastView) : @@ -48,17 +52,15 @@ ForecastDeskbarView::AttachedToWindow() AdoptParentColors(); } -extern "C" _EXPORT BView* instantiate_deskbar_item(); - -BView* +extern "C" _EXPORT BView* instantiate_deskbar_item() { BMessage settings; LoadSettings(settings); ForecastDeskbarView* view = new ForecastDeskbarView( - BRect(0, 0, 16, 16), - new ForecastView(BRect(0, 0, 0, 0), + BRect(0, 0, 16, 16), + new ForecastView(BRect(0, 0, 0, 0), &settings)); entry_ref appRef; settings.FindRef("appLocation", &appRef); @@ -73,11 +75,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); } @@ -96,14 +98,19 @@ void ForecastDeskbarView::MessageReceived(BMessage* message) { if (message->what == kUpdateForecastMessage) { + + // Todo: Reload after X minutes + //if (fForecastView->IsConnected()) + //fForecastView->Reload(); + BString weatherDetailsText; - weatherDetailsText << "Temperature: " + weatherDetailsText << B_TRANSLATE("Temperature: ") << FormatString(fForecastView->Unit(), fForecastView->Temperature()) << "\n"; - weatherDetailsText << "Condition: " << fForecastView->GetCondition() + weatherDetailsText << B_TRANSLATE("Condition: ") << fForecastView->GetStatus() << "\n"; - weatherDetailsText << "Location: " << fForecastView->CityName(); + weatherDetailsText << B_TRANSLATE("Location: ") << fForecastView->CityName(); SetToolTip(weatherDetailsText.String()); Invalidate(); diff --git a/Source/ForecastDeskbarView.h b/Source/ForecastDeskbarView.h index cfc7934..bc71f34 100644 --- a/Source/ForecastDeskbarView.h +++ b/Source/ForecastDeskbarView.h @@ -7,9 +7,6 @@ #include #include -#include -#include -#include #include #include "ForecastView.h" @@ -17,7 +14,7 @@ class ForecastDeskbarView : public BView { - + public: ForecastDeskbarView(BRect viewSize, ForecastView* forecastView); ~ForecastDeskbarView(); @@ -25,8 +22,8 @@ class ForecastDeskbarView : public BView 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); 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..2a8ab2a 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..fd5dce9 100644 --- a/locales/en.catkeys +++ b/locales/en.catkeys @@ -1,4 +1,5 @@ -1 English x-vnd.przemub.Weather 704655087 +1 English x-vnd.przemub.Weather 878890540 +Location: ForecastDeskbarView Location: No network ForecastView No network OK ForecastView OK Slight rain ForecastView Slight rain @@ -6,8 +7,8 @@ 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… @@ -26,6 +27,7 @@ Connecting… ForecastView Connecting… Unable to create a deskbar replicant. The error is: \" MainWindow Unable to create a deskbar replicant. The error is: \" Overcast ForecastView Overcast Moderate rain ForecastView Moderate rain +Temperature: ForecastDeskbarView Temperature: Depositing rime fog ForecastView Depositing rime fog About Weather MainWindow About Weather Moderate drizzle ForecastView Moderate drizzle @@ -58,3 +60,5 @@ Slight snow fall ForecastView Slight snow fall Cancel CitiesListSelectionWindow Cancel About Weather ForecastView About Weather Moderate snow fall ForecastView Moderate snow fall +Condition: ForecastDeskbarView Condition: +Deskbar Replicant MainWindow Deskbar Replicant 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