[gnome-boxes/take-manual-input-for-memory-widget: 2/2] memory-row: Handle user manual input of memory values
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/take-manual-input-for-memory-widget: 2/2] memory-row: Handle user manual input of memory values
- Date: Tue, 1 Mar 2022 12:16:50 +0000 (UTC)
commit c5be977075506dba7aca5def2c29ea188fa2a0ff
Author: Felipe Borges <felipeborges gnome org>
Date: Tue Mar 1 13:15:35 2022 +0100
memory-row: Handle user manual input of memory values
Fixes #766
src/preferences/memory-row.vala | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/src/preferences/memory-row.vala b/src/preferences/memory-row.vala
index 9e568df5..92f5d4b2 100644
--- a/src/preferences/memory-row.vala
+++ b/src/preferences/memory-row.vala
@@ -12,16 +12,18 @@
[GtkCallback]
private int on_spin_button_input (Gtk.SpinButton spin_button, out double new_value) {
uint64 current_value = (uint64)spin_button.get_value ();
-
- /* FIXME: we should be getting the value with spin_button.get_text () so we can
- * accept user manual input. This will require to parse the text properly and
- * convert strings such as 2.0 GiB into 2.0 * Osinfo.MEBIBYTE * 1024.
- *
- * As it is now, we don't support manual input, and the value can only be changed
- * by using the + and - buttons of the GtkSpinButton.
- */
new_value = current_value;
+ string? text = spin_button.get_text ();
+ if (text == null)
+ return 1;
+
+ double user_input_value = double.parse (text);
+ if (user_input_value == 0)
+ return 1;
+
+ new_value = user_input_value * Osinfo.GIBIBYTES;
+
return 1;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]