[gcalctool] Add shortcuts for programming base mode



commit b811251d4b27bed0ab49dbead704a93646c589ba
Author: Robert Ancell <robert ancell canonical com>
Date:   Mon May 30 20:36:29 2011 +1000

    Add shortcuts for programming base mode

 src/math-window.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/src/math-window.c b/src/math-window.c
index 59a427f..d32dec6 100644
--- a/src/math-window.c
+++ b/src/math-window.c
@@ -250,6 +250,29 @@ key_press_cb(MathWindow *window, GdkEventKey *event)
 {
     gboolean result;
     g_signal_emit_by_name(window->priv->display, "key-press-event", event, &result);
+
+    if (math_buttons_get_mode (window->priv->buttons) == PROGRAMMING && (event->state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK) {
+        switch(event->keyval)
+        {
+        /* Binary */
+        case GDK_KEY_b:
+            math_equation_set_base (window->priv->equation, 2);
+            return TRUE;
+        /* Octal */
+        case GDK_KEY_o:
+            math_equation_set_base (window->priv->equation, 8);
+            return TRUE;
+        /* Decimal */
+        case GDK_KEY_d:
+            math_equation_set_base (window->priv->equation, 10);
+            return TRUE;
+        /* Hexdecimal */
+        case GDK_KEY_h:
+            math_equation_set_base (window->priv->equation, 16);
+            return TRUE;
+        }
+    }
+
     return result;
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]