-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Deskbar icon and tooltip #101
base: master
Are you sure you want to change the base?
Conversation
Source/ForecastDeskbarView.cpp
Outdated
|
||
BView* | ||
extern "C" _EXPORT BView* | ||
instantiate_deskbar_item() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a instantiate_deskbar_item(float maxWidth, float maxHeight)
that avoids hard-coding the icon size. The Deskbar tray and its icons are resized with the set system font size. Compare with, e.g. https://cgit.haiku-os.org/haiku/tree/src/apps/powerstatus/PowerStatusView.cpp#n929
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, I'm trying to adapt the code but I'm struggling with this part:
BArchivable*
ForecastDeskbarView::Instantiate(BMessage* archive)
{
if (!validate_instantiation(archive, "ForecastDeskbarView"))
return NULL;
return reinterpret_cast<BArchivable*>(instantiate_deskbar_item());
}
How can I include maxWidth and maxHeight in instantiate_deskbar_item()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep in mind that I don't really know what I'm doing, esp. when it comes to replicants...
The Instantiate() should return a ForecastDeskbarView*, not a BArchivable*.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep in mind that I don't really know what I'm doing, esp. when it comes to replicants...
Hard to believe...
The Instantiate() should return a ForecastDeskbarView*, not a BArchivable*.
I noticed that from the examples, however with the current code this caused the app to crash. As it is now (with my latest update), the code works and the icon will resize according to the system font size.
Source/ForecastDeskbarView.cpp
Outdated
BString weatherDetailsText; | ||
weatherDetailsText << "Temperature: " | ||
weatherDetailsText << B_TRANSLATE("Temperature: ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, and for rhe strings below, I suggest to remove the space at the end of the string and append it separately. A space at the end can easily be overlooked by the translators, so:
weatherDetailsText << B_TRANSLATE("Temperature: ") | |
weatherDetailsText << B_TRANSLATE("Temperature:") << " " |
Or go with one long translatable string that contains variables ("%temperature%" etc.) that get replaced using BString's SetToFormat() etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a single, translatable string that inserts the variables with SetToFormat() as suggested.
007d4d1
to
acd0672
Compare
acd0672
to
61157f4
Compare
This pull request enables the Deskbar Replicant menu item. The replicant will show an icon with the curren weather, and a tooltip with details about the condition, temperature and location.
The tooltip is translatable, new
en.catkeys
generated but not added to Polyglot.I also removed a few header files that didn't seem necessary, please correct me if I'm wrong.