Hard code freeze break request [gcalctool]



Hi,

A bug [1] has been reported against gcalctool 5.27.92 (and earlier)
showing that the power key '^' is unable to be entered in some
keyboard layouts (e.g. German, Spanish etc).  This is a feature that
has been broken since at least 2.22 and causes difficulty for
non-English layout users.

The attached patch fixes this problem by catching the keycode that is
being used in these layouts and also converting two consecutive '*' to
a '^'.  I am the maintainer of gcalctool and I approve this patch.

[1] https://bugzilla.gnome.org/show_bug.cgi?id=546819

Thanks,
--Robert Ancell
GCalctool Maintainer
diff --git a/src/gtk.c b/src/gtk.c
index f91fec4..ce90439 100644
--- a/src/gtk.c
+++ b/src/gtk.c
@@ -396,8 +396,8 @@ static struct button_widget button_widgets[] = {
     { GDK_H, 0 }},
 
     {FN_X_POW_Y,            "x_pow_y",
-    { 0,     0,         0,               0 },
-    { GDK_o, GDK_caret, GDK_asciicircum, 0 }},
+    { 0,     0,         0,               0,                   0 },
+    { GDK_o, GDK_caret, GDK_asciicircum, GDK_dead_circumflex, 0 }},
 
     {FN_X_POW_Y_INV,        "x_pow_y",
     { 0,     0 },
@@ -529,7 +529,9 @@ typedef struct {
 
     GdkAtom clipboard_atom;
     GdkAtom primary_atom;  
-    char *shelf;                       /* PUT selection shelf contents. */   
+    char *shelf;                       /* PUT selection shelf contents. */
+    
+    int last_function;
 } GtkUI;
 static GtkUI X;
 
@@ -998,8 +1000,17 @@ static void do_button(int function, int arg)
             cursor_start = -1;
         cursor_end = cursor_start;
     }
-
-    do_expression(function, arg, cursor_start, cursor_end);
+    
+    /* Some keyboards don't have a '^' button so convert two multiplies to one '^' */
+    if (cursor_start == cursor_end &&
+        function == FN_MULTIPLY && X.last_function == FN_MULTIPLY) {
+        do_button(FN_BACKSPACE, 0);
+        do_button(FN_X_POW_Y, 0);
+    }
+    else {
+        do_expression(function, arg, cursor_start, cursor_end);
+        X.last_function = function;
+    }
 }
 
 static void


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