[gnome-calculator] programming mode: Dim inapplicable bits on word size change
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator] programming mode: Dim inapplicable bits on word size change
- Date: Thu, 22 Oct 2020 05:04:34 +0000 (UTC)
commit 279360ec940f95f15ca1d9804bd228bd29a923da
Author: A.M. Rowsell <amrowsell frozenelectronics ca>
Date: Thu Oct 22 05:04:33 2020 +0000
programming mode: Dim inapplicable bits on word size change
When using a word size less than 64 bit, it is misleading to have
the bit buttons larger than that bit size active. This patch
dims (de-sensitizes) the applicable bits so they cannot be toggled.
It also sets all bits larger than the word size to zero.
src/math-buttons.vala | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/src/math-buttons.vala b/src/math-buttons.vala
index fc8b6269..cbda5672 100644
--- a/src/math-buttons.vala
+++ b/src/math-buttons.vala
@@ -504,10 +504,31 @@ public class MathButtons : Gtk.Box
private void word_size_changed_cb ()
{
var size = equation.word_size;
- string format = ngettext("%d-bit", "%d-bit", size);
- word_size_label.set_label(format.printf(size));
+ string format = ngettext ("%d-bit", "%d-bit", size);
+ word_size_label.set_label (format.printf(size));
+ update_bit_button_sensitivities ();
}
+ private void update_bit_button_sensitivities ()
+ {
+ var i = 0;
+ foreach (var button in toggle_bit_buttons)
+ {
+ if (i < equation.word_size)
+ {
+ button.set_sensitive (true);
+ }
+ else
+ {
+ if (button.label == "1")
+ {
+ equation.toggle_bit (63-i);
+ }
+ button.set_sensitive (false);
+ }
+ i++;
+ }
+ }
private void on_launch_finc_dialog (SimpleAction action, Variant? param)
{
var name = param.get_string ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]