Skip to content

Conversation

@dospuntos
Copy link
Contributor

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.


BView*
extern "C" _EXPORT BView*
instantiate_deskbar_item()
Copy link
Member

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

Copy link
Contributor Author

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()?

Copy link
Member

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*.

Copy link
Contributor Author

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.


BString weatherDetailsText;
weatherDetailsText << "Temperature: "
weatherDetailsText << B_TRANSLATE("Temperature: ")
Copy link
Member

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:

Suggested change
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.

Copy link
Contributor Author

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.

@dospuntos dospuntos force-pushed the fix-deskbar-replicant branch from 007d4d1 to acd0672 Compare November 9, 2023 05:11
@dospuntos dospuntos force-pushed the fix-deskbar-replicant branch from acd0672 to 61157f4 Compare November 9, 2023 05:34
@dospuntos dospuntos marked this pull request as draft November 10, 2023 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants