| 417 | } |
| 418 | |
| 419 | const Glib::ustring UPower::getText(const upDevice_output& upDevice_, const std::string& format) { |
| 420 | Glib::ustring ret{""}; |
| 421 | if (upDevice_.upDevice != NULL) { |
| 422 | std::string timeStr{""}; |
| 423 | switch (upDevice_.state) { |
| 424 | case UP_DEVICE_STATE_CHARGING: |
| 425 | case UP_DEVICE_STATE_PENDING_CHARGE: |
| 426 | timeStr = secondsToString(std::chrono::seconds(upDevice_.time_full)); |
| 427 | break; |
| 428 | case UP_DEVICE_STATE_DISCHARGING: |
| 429 | case UP_DEVICE_STATE_PENDING_DISCHARGE: |
| 430 | timeStr = secondsToString(std::chrono::seconds(upDevice_.time_empty)); |
| 431 | break; |
| 432 | default: |
| 433 | break; |
| 434 | } |
| 435 | |
| 436 | ret = fmt::format( |
| 437 | fmt::runtime(format), |
| 438 | fmt::arg("percentage", std::to_string((int)std::round(upDevice_.percentage)) + '%'), |
| 439 | fmt::arg("time", timeStr), |
| 440 | fmt::arg("temperature", fmt::format("{:-.2g}C", upDevice_.temperature)), |
| 441 | fmt::arg("model", upDevice_.model), fmt::arg("native-path", upDevice_.nativePath)); |
| 442 | } |
| 443 | |
| 444 | return ret; |
| 445 | } |
| 446 | |
| 447 | bool UPower::queryTooltipCb(int x, int y, bool keyboard_tooltip, |
| 448 | const Glib::RefPtr<Gtk::Tooltip>& tooltip) { |
nothing calls this directly
no test coverage detected