How to…¶
Short recipes for the changes people make most. Each lists every file that is easy to forget.
Add a weather value to a card¶
Example: show the dew point on its own card.
- Ask for it. Add the field to
CURRENT_FIELDS,HOURLY_FIELDSorDAILY_FIELDSinservices/open_meteo.py. (Tests that check the URL may need updating:tests/test_api.py.) - Model it. Add the annotation to the model in
core/models.py. The attribute itself is set automatically. - Derive it, if needed. A value the current API doesn't give is filled in from the hourly forecast in
add_hourly_fieldsinstate/weather_store.py, in the store's worker. A level goes incore/levels.pyas aclassify_*function, with a test intests/test_levels.py. - Convert units in the API layer,
core/units.pyor the store, never in a widget. - Show it. A metric card is a function in
ui/cards/metric.pythat returnsCardSquare(title, value, unit, desc, …, visual=…).card; followuv_cardorhumidity_card. Add it to the small-widget grid in_render_weather_gridinui/window.py. - Strings. Wrap them in
_(), then run./update-pot. - Check both units, light and dark, and with dynamic backgrounds on and off.
Add a setting¶
- A
<key>indata/io.github.amit9838.mousam.gschema.xml, thenglib-compile-schemas --strict --dry-run data/. Never rename or retype an existing key. - A property on
Settingsinservices/settings.py. - A row in
ui/dialogs/preferences.py, if the user can change it. - Whoever shows the value reacts with
settings.connect("changed::<key>", …)(throughweak_connecton rebuilt widgets). - A test, if a decision depends on it: pass the value in as an argument and test the function.
Add an overview rule¶
- Describe it in
docs/overview-rules.mdin the app repo first (its sections 9 to 11 cover the rules, writing messages and adding a rule). - Add its message key and 2 to 5 wordings to
core/overview/messages.py, all with the same placeholders. - Add a priority to
OVERVIEW_PRIORITIESand any numbers toconfig.py(metric). - Build the rule. "The first hour that…" is a
FirstHourRulewith anHourTestand aPhrasing; otherwise subclassRule. Register it inRuleBook.default(). - Add a case to
tests/test_overview_rules.py. ./update-pot.
Add a weather code¶
A WMO code must be added to all four tables in ui/icons.py together: icons_default, icons_material, bg_css and condition. Add the night variant ("61n") where the others have one. Add the icon files under data/icons/, and the background class in src/css/style.css.
Add a card to the grid¶
The main window builds its grid in _render_weather_grid (ui/window.py): current conditions on top, hourly graphs and the 7-day forecast, a grid of small cards, and air quality and the sun card. A card gets its data through its constructor and is ready when the constructor returns. Add it with add_card(widget, column, row, width). If it draws with Cairo, use a piece from ui/drawing/ or a new one that follows the same pattern (own drawing area, safe_set_draw_func, everything computed in __init__).
The compact window (ui/compact_window.py) has its own, smaller layout.
Add a file¶
See Architecture: the folder's meson.build, po/POTFILES and mousam.gresource.xml.
Add a language¶
Add the language code to po/LINGUAS with its .po file (run ./update-pot then ./update-po). Don't machine-translate; translators maintain the files, also through Weblate.
Debug a problem¶
- Turn on debug mode (Preferences → Advanced → Debug Mode, or
gsettings set io.github.amit9838.mousam debug-mode true). - Read the console or
mousam.log; each module logs under its own area name (data_managerfor the store,overviewfor the engine,API_Weather,main, …). - For the overview (section 12 of
docs/overview-rules.mdexplains the log), the log lists every insight with its level and what the memory knows, then what was shown and where it went (Overview channel: … -> window). - For leaks or a busy CPU after a refresh, see the checks in Data flow and threads.