59 lines
1.3 KiB
C++
59 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <array>
|
|
#include <glibmm/dispatcher.h>
|
|
#include <gtkmm/box.h>
|
|
#include <gtkmm/label.h>
|
|
#include <sigc++/sigc++.h>
|
|
|
|
#include "gtkmm/scrolledwindow.h"
|
|
|
|
class WeatherWidget : public Gtk::Box {
|
|
public:
|
|
struct CurrentWeather {
|
|
double temperature;
|
|
double apparent_temperature;
|
|
double precipitation;
|
|
int weather_code;
|
|
};
|
|
|
|
struct DailyWeather {
|
|
double temperature_2m_max;
|
|
double temperature_2m_min;
|
|
double apparent_temperature_min;
|
|
double apparent_temperature_max;
|
|
double precipitation_sum;
|
|
int weather_code;
|
|
std::string time;
|
|
};
|
|
|
|
struct HourlyWeather {
|
|
double temperature_2m;
|
|
double apparent_temperature;
|
|
double precipitation_probability;
|
|
double precipitation;
|
|
int weather_code;
|
|
std::string time;
|
|
};
|
|
|
|
WeatherWidget();
|
|
|
|
private:
|
|
std::array<DailyWeather, 7> daily_weather{};
|
|
std::array<HourlyWeather, 24> hourly_weather{};
|
|
CurrentWeather current_weather{};
|
|
|
|
Gtk::ScrolledWindow currentScroll;
|
|
Gtk::ScrolledWindow hourlyScroll;
|
|
Gtk::ScrolledWindow dailyScroll;
|
|
|
|
Glib::Dispatcher m_dispatcher;
|
|
|
|
bool onRefreshTick();
|
|
void fetchWeather();
|
|
|
|
void refreshCurrentWeather();
|
|
void refreshHourlyWeather();
|
|
void refreshDailyWeather();
|
|
};
|