diff --git a/data/gwr-window.ui b/data/gwr-window.ui
index c6c10e6..7685fa6 100644
--- a/data/gwr-window.ui
+++ b/data/gwr-window.ui
@@ -7,19 +7,19 @@
600
300
-
+
+
+ True
+ False
+ Remaining
+
+
+ 0
+ 0
+
+
+
+
+ True
+ False
+ Hydration level
+
+
+ 1
+ 0
+
+
+
+
+ True
+ False
+
+
+ 0
+ 2
+
+
+
+
+ True
+ False
+
+
+ 1
+ 2
diff --git a/src/gwr-window.c b/src/gwr-window.c
index da6a0b0..a68987d 100644
--- a/src/gwr-window.c
+++ b/src/gwr-window.c
@@ -17,6 +17,8 @@
*/
#include "gwr-config.h"
+
+#include
#include "gwr-window.h"
#include "gwr-water-level.h"
@@ -28,6 +30,9 @@ struct _GwrWindow
GtkHeaderBar *header_bar;
GwrWaterLevel *level;
GwrWaterLevel *remaining;
+
+ GtkLabel *remaining_value;
+ GtkLabel *current_value;
};
G_DEFINE_TYPE (GwrWindow, gwr_window, GTK_TYPE_APPLICATION_WINDOW)
@@ -49,6 +54,23 @@ gwr_window_class_init (GwrWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, GwrWindow, header_bar);
gtk_widget_class_bind_template_child (widget_class, GwrWindow, level);
gtk_widget_class_bind_template_child (widget_class, GwrWindow, remaining);
+ gtk_widget_class_bind_template_child (widget_class, GwrWindow, current_value);
+ gtk_widget_class_bind_template_child (widget_class, GwrWindow, remaining_value);
+}
+
+static void
+level_changed(GwrWaterLevel *level,
+ GParamSpec *pspec,
+ GwrWindow *self)
+{
+ gchar *text;
+ GtkLabel *label = (level == self->level) ? self->current_value : self->remaining_value;
+
+ g_debug("level changed");
+
+ text = g_strdup_printf(_("Value: %.0f%%"), gwr_water_level_get_level (level) * 100);
+ gtk_label_set_text(label, text);
+ g_free(text);
}
static void
@@ -59,6 +81,12 @@ gwr_window_init (GwrWindow *self)
gtk_widget_init_template (GTK_WIDGET (self));
g_action_map_add_action_entries(G_ACTION_MAP(self), win_entries, G_N_ELEMENTS(win_entries), self);
+
+ g_signal_connect(self->level, "notify::level", G_CALLBACK(level_changed), self);
+ g_signal_connect(self->remaining, "notify::level", G_CALLBACK(level_changed), self);
+
+ level_changed(self->level, NULL, self);
+ level_changed(self->remaining, NULL, self);
}
static void