? aclocal.m4
? intltool-extract.in
? intltool-merge.in
? config.h.in
? intltool-update.in
? autom4te.cache
? Makefile.in
? configure
? config.log
? config.status
? gcalctool.desktop
? Makefile
? config.h
? stamp-h1
? intltool-extract
? intltool-merge
? intltool-update
? gcalctool/Makefile.in
? gcalctool/Makefile
? gcalctool/gcalctool
? help/Makefile.in
? help/Makefile
? help/C/Makefile.in
? help/C/Makefile
? help/C/omf_timestamp
Index: gcalctool.schemas
===================================================================
RCS file: /cvs/gnome/gcalctool/gcalctool.schemas,v
retrieving revision 1.2
diff -u -r1.2 gcalctool.schemas
--- gcalctool.schemas	18 Mar 2003 11:20:24 -0000	1.2
+++ gcalctool.schemas	18 Mar 2003 12:03:14 -0000
@@ -20,7 +20,7 @@
       <owner>gcalctool</owner>
       <type>string</type>
       <locale name="C">
-        <default>2</default>
+        <default>9</default>
         <short>Accuracy value</short>
         <long>
           The number of digits displayed after the numeric point.
@@ -75,6 +75,20 @@
             FINANCIAL
             LOGICAL 
             SCIENTIFIC
+        </long>
+      </locale>
+    </schema>
+    <schema>
+      <applyto>/apps/gcalctool/removezeroes</applyto>
+      <key>/schemas/apps/gcalctool/removezeroes</key>
+      <owner>gcalctool</owner>
+      <type>string</type>
+      <locale name="C">
+        <default>true</default>
+        <short>Remove Trailing Zeroes</short>
+        <long>
+          Indicates whether any trailing zeroes after the 
+          number point should be removed from the display value.
         </long>
       </locale>
     </schema>
Index: gcalctool/calctool.c
===================================================================
RCS file: /cvs/gnome/gcalctool/gcalctool/calctool.c,v
retrieving revision 1.34
diff -u -r1.34 calctool.c
--- gcalctool/calctool.c	4 Mar 2003 21:24:48 -0000	1.34
+++ gcalctool/calctool.c	18 Mar 2003 12:03:15 -0000
@@ -51,7 +51,8 @@
 };
 
 char *calc_res[] = {
-    "accuracy", "base", "display", "mode", "showregisters", "trigtype"
+    "accuracy", "base", "display", "mode", "showregisters", "trigtype",
+    "removezeroes"
 };
 
 char *dtype_str[] = {          /* Strings for each display mode value. */
@@ -223,13 +224,13 @@
     do_calc
 },
 {
-    N_("Acc"),
-    N_("Set accuracy from 0 to 9 numeric places"),
-    CALC_MOD_SHIFT_MASK,
-    CALC_KEY_ACC,
-    'A',
-    M_ACC,
-    do_pending
+    "    ",
+    "    ",
+    CALC_MOD_NONE,
+    CALC_KEY_NONE,
+    ' ',
+    M_NONE,
+    do_none
 },
 {
     N_("+/-"),
@@ -646,13 +647,13 @@
     do_paren
 },
 {
-    "    ",
-    "    ",
-    CALC_MOD_NONE,
-    CALC_KEY_NONE,
-    ' ',
-    M_NONE,
-    do_none
+    N_("Acc"),
+    N_("Set accuracy from 0 to 9 numeric places"),
+    CALC_MOD_SHIFT_MASK,
+    CALC_KEY_ACC,
+    'A',
+    M_ACC,
+    do_pending
 },
 
 /* Row 2. */
Index: gcalctool/calctool.h
===================================================================
RCS file: /cvs/gnome/gcalctool/gcalctool/calctool.h,v
retrieving revision 1.29
diff -u -r1.29 calctool.h
--- gcalctool/calctool.h	4 Mar 2003 21:24:49 -0000	1.29
+++ gcalctool/calctool.h	18 Mar 2003 12:03:15 -0000
@@ -68,7 +68,8 @@
 enum num_type { ENG, FIX, SCI };            /* Number display mode. */
 
 /* Resources. */
-enum res_type { R_ACCURACY, R_BASE, R_DISPLAY, R_MODE, R_REGS, R_TRIG
+enum res_type { R_ACCURACY, R_BASE, R_DISPLAY, R_MODE, R_REGS, R_TRIG,
+                R_ZEROES
 };
 
 enum trig_type { DEG, GRAD, RAD };          /* Trigonometric types. */
@@ -110,7 +111,7 @@
 #define KEY_BSP   b_buttons[5]              /* Control-h */
 
 #define KEY_MUL   b_buttons[11]             /* * */
-#define KEY_ACC   b_buttons[12]             /* A */
+
 #define KEY_CHS   b_buttons[13]             /* C */
 #define KEY_INT   b_buttons[14]             /* i */
 #define KEY_STO   b_buttons[15]             /* S */
@@ -144,6 +145,7 @@
 #define KEY_32    s_buttons[3]              /* ] */
 #define KEY_LPAR  s_buttons[5]              /* ( */
 #define KEY_RPAR  s_buttons[6]              /* ) */
+#define KEY_ACC   s_buttons[7]              /* A */
 
 #define KEY_CON   s_buttons[8]              /* # */
 #define KEY_FUN   s_buttons[9]              /* F */
@@ -314,6 +316,7 @@
     int pending_op;    /* Arithmetic operation for pending command. */
     int pointed;       /* Whether a decimal point has been given. */
     int rstate;        /* Indicates if memory register frame is displayed. */
+    int rm_zeroes;     /* Set if trailing zeroes should be removed. */
     int show_paren;    /* Set if we wish to show DISPLAYITEM during parens. */
     int started;       /* Set just before window is displayed. */
     int toclear;       /* Indicates if display should be cleared. */
@@ -406,6 +409,7 @@
 void read_str(char **, char *);
 void save_pending_values(struct button *);
 void save_resources();
+void set_accuracy_toggle(int);
 void set_display(char *str);
 void set_hyp_item(int);
 void set_ins_key();
@@ -413,6 +417,7 @@
 void set_inv_item(int);
 void set_mode(enum mode_type);
 void set_title(enum fcp_type, char *);
+void set_rm_zeroes_toggle(int);
 void show_ascii_frame();
 void show_display(int *);
 void srand48();
Index: gcalctool/display.c
===================================================================
RCS file: /cvs/gnome/gcalctool/gcalctool/display.c,v
retrieving revision 1.17
diff -u -r1.17 display.c
--- gcalctool/display.c	21 Feb 2003 17:57:01 -0000	1.17
+++ gcalctool/display.c	18 Mar 2003 12:03:15 -0000
@@ -158,6 +158,17 @@
     v->toclear = 1;
     v->pointed = 0;
 
+    if (v->rm_zeroes && v->accuracy != 0) {
+        optr = v->fnum + strlen(v->fnum) - 1;
+        while (*optr == '0') {
+            optr--;
+        }
+        if (*optr != '.') {
+            optr++;
+        }
+        *optr = '\0';
+    }
+
     return(v->fnum);
 }
 
Index: gcalctool/functions.c
===================================================================
RCS file: /cvs/gnome/gcalctool/gcalctool/functions.c,v
retrieving revision 1.18
diff -u -r1.18 functions.c
--- gcalctool/functions.c	21 Feb 2003 16:37:09 -0000	1.18
+++ gcalctool/functions.c	18 Mar 2003 12:03:15 -0000
@@ -51,13 +51,23 @@
     char intval[5];
     int i;
 
-    for (i = 0; i <= 9; i++) {
-        if (v->current->value == get_menu_entry(M_ACC, i)) {
-            v->accuracy = char_val(v->current->value);
-            SPRINTF(intval, "%d", v->accuracy);
-            put_resource(R_ACCURACY, intval);
-            make_registers();
-            return;
+    if (!v->started) {
+        return;
+    }
+
+    if (v->current->value == 'R') {     /* "Remove trailing zeroes" entry? */
+        v->rm_zeroes = !v->rm_zeroes;
+        put_resource(R_ZEROES, set_bool(v->rm_zeroes == TRUE));
+        make_registers();
+    } else {
+        for (i = 0; i <= 9; i++) {
+            if (v->current->value == get_menu_entry(M_ACC, i)) {
+                v->accuracy = char_val(v->current->value);
+                SPRINTF(intval, "%d", v->accuracy);
+                put_resource(R_ACCURACY, intval);
+                make_registers();
+                return;
+            }
         }
     }
 }
Index: gcalctool/gcalctool.1
===================================================================
RCS file: /cvs/gnome/gcalctool/gcalctool/gcalctool.1,v
retrieving revision 1.16
diff -u -r1.16 gcalctool.1
--- gcalctool/gcalctool.1	26 Feb 2003 16:41:44 -0000	1.16
+++ gcalctool/gcalctool.1	18 Mar 2003 12:03:15 -0000
@@ -1,5 +1,5 @@
 .\" Copyright (c) 1987-2003 - Sun Microsystems, Inc.
-.TH gcalctool 1 "26 February 2003"
+.TH gcalctool 1 "15 March 2003"
 .SH NAME
 gcalctool \- a desktop calculator
 .SH SYNOPSIS
@@ -136,6 +136,17 @@
 .B Description
 The initial calculator mode. Valid values are "BASIC", "FINANCIAL"
 and "SCIENTIFIC".
+.sp
+.TP
+.B Resource:
+/schemes/apps/gcalctool/removezeroes
+.TP
+.B Values:
+true, false (true)
+.TP
+.B Description
+Whether trailing zeroes, after the numeric point, are removed from the 
+display value.
 .sp
 .TP
 .B Resource:
Index: gcalctool/get.c
===================================================================
RCS file: /cvs/gnome/gcalctool/gcalctool/get.c,v
retrieving revision 1.18
diff -u -r1.18 get.c
--- gcalctool/get.c	18 Mar 2003 11:20:32 -0000	1.18
+++ gcalctool/get.c	18 Mar 2003 12:03:15 -0000
@@ -137,7 +137,7 @@
                         FPRINTF(stderr, 
                                 _("%s: accuracy should be in the range 0-9\n"),
                                 v->progname);
-                        v->accuracy = 2;
+                        v->accuracy = 9;
                     }
                     break;
 
@@ -194,7 +194,8 @@
 {
     int acc, i, n, size;
 
-    v->accuracy      = 2;      /* Initial accuracy. */
+    v->accuracy      = 9;      /* Initial accuracy. */
+    v->rm_zeroes     = TRUE;   /* Remove trailing zeroes. */
     v->base          = DEC;    /* Initial base. */
     v->dtype         = FIX;    /* Initial number display mode. */
     v->ttype         = DEG;    /* Initial trigonometric type. */
@@ -256,7 +257,7 @@
         if (v->accuracy < 0 || v->accuracy > 9) {
             FPRINTF(stderr, _("%s: accuracy should be in the range 0-9\n"), 
                     v->progname);
-            v->accuracy = 2;
+            v->accuracy = 9;
         }
     }
 
@@ -321,6 +322,10 @@
 
     if (get_bool_resource(R_REGS, &boolval)) {
         v->rstate = boolval;
+    }
+
+    if (get_bool_resource(R_ZEROES, &boolval)) {
+        v->rm_zeroes = boolval;
     }
 }
 
Index: gcalctool/gtk.c
===================================================================
RCS file: /cvs/gnome/gcalctool/gcalctool/gtk.c,v
retrieving revision 1.77
diff -u -r1.77 gtk.c
--- gcalctool/gtk.c	15 Mar 2003 03:20:37 -0000	1.77
+++ gcalctool/gtk.c	18 Mar 2003 12:03:15 -0000
@@ -46,12 +46,13 @@
 #define BUT_7     X->bas_buttons[0]        /* 7 */
 #define BUT_8     X->bas_buttons[1]        /* 8 */
 #define BUT_9     X->bas_buttons[2]        /* 9 */
-#define BUT_A     X->sci_buttons[24]       /* A */
-#define BUT_B     X->sci_buttons[25]       /* B */
-#define BUT_C     X->sci_buttons[26]       /* C */
-#define BUT_D     X->sci_buttons[16]       /* D */
-#define BUT_E     X->sci_buttons[17]       /* E */
-#define BUT_F     X->sci_buttons[18]       /* F */
+#define BUT_ACC   X->sci_buttons[7]        /* A */
+#define BUT_A     X->sci_buttons[24]       /* a */
+#define BUT_B     X->sci_buttons[25]       /* b */
+#define BUT_C     X->sci_buttons[26]       /* c */
+#define BUT_D     X->sci_buttons[16]       /* d */
+#define BUT_E     X->sci_buttons[17]       /* e */
+#define BUT_F     X->sci_buttons[18]       /* f */
 #define BUT_ADD   X->bas_buttons[27]       /* + */
 #define BUT_SUB   X->bas_buttons[19]       /* - */
 #define BUT_MUL   X->bas_buttons[11]       /* x */
@@ -177,9 +178,10 @@
 static void put_constant(int, char *, char *);
 static void put_function(int, char *, char *);
 static void quit_cb(GtkWidget *, gpointer);
+static void reset_mode_values(enum mode_type);
 static void set_button_state(GtkWidget *, int);
 static void set_gcalctool_icon(void);
-static void set_memory_toggle(int state);
+static void set_memory_toggle(int);
 static void trig_cb(GtkToggleButton *, gpointer);
 
 static XVars X;
@@ -209,16 +211,18 @@
 };
 
 static GtkItemFactoryEntry acc_menu[] = {
-    { N_("/0 radix places"), NULL, menu_proc, '0', NULL, },
-    { N_("/1 radix places"), NULL, menu_proc, '1', NULL, },
-    { N_("/2 radix places"), NULL, menu_proc, '2', NULL, },
-    { N_("/3 radix places"), NULL, menu_proc, '3', NULL, },
-    { N_("/4 radix places"), NULL, menu_proc, '4', NULL, },
-    { N_("/5 radix places"), NULL, menu_proc, '5', NULL, },
-    { N_("/6 radix places"), NULL, menu_proc, '6', NULL, },
-    { N_("/7 radix places"), NULL, menu_proc, '7', NULL, },
-    { N_("/8 radix places"), NULL, menu_proc, '8', NULL, },
-    { N_("/9 radix places"), NULL, menu_proc, '9', NULL, },
+    { N_("/0 radix places"), NULL, menu_proc, '0', "<RadioItem>" },
+    { N_("/1 radix places"), NULL, menu_proc, '1', "/0 radix places" },
+    { N_("/2 radix places"), NULL, menu_proc, '2', "/0 radix places" },
+    { N_("/3 radix places"), NULL, menu_proc, '3', "/0 radix places" },
+    { N_("/4 radix places"), NULL, menu_proc, '4', "/0 radix places" },
+    { N_("/5 radix places"), NULL, menu_proc, '5', "/0 radix places" },
+    { N_("/6 radix places"), NULL, menu_proc, '6', "/0 radix places" },
+    { N_("/7 radix places"), NULL, menu_proc, '7', "/0 radix places" },
+    { N_("/8 radix places"), NULL, menu_proc, '8', "/0 radix places" },
+    { N_("/9 radix places"), NULL, menu_proc, '9', "/0 radix places" },
+    { N_("/sep1"),           NULL, NULL,       0,  "<Separator>" },
+    { N_("/_Remove Trailing Zeroes"),"<control>R", menu_proc, 'R', "<ToggleItem>" },
 };
 
 static GtkItemFactoryEntry lshift_menu[] = {
@@ -930,6 +934,24 @@
     vbox = gtk_vbox_new(FALSE, 0);
     gtk_widget_ref(vbox);
 
+/* Make Trig. type radio button widgets. */
+ 
+    trig_hbox = gtk_hbox_new(FALSE, 0);
+    gtk_widget_show(trig_hbox);
+ 
+    for (i = 0; i < MAXTRIGMODES; i++) {
+        X->trig[i] = gtk_radio_button_new_with_mnemonic(NULL, _(ttype_str[i]));
+        g_object_set_data(G_OBJECT(X->trig[i]), "trig", (gpointer) i);
+        gtk_widget_show(X->trig[i]);
+        gtk_box_pack_start(GTK_BOX(trig_hbox), X->trig[i], FALSE, FALSE, 0);
+        gtk_radio_button_set_group(GTK_RADIO_BUTTON(X->trig[i]), trig_gr);
+        trig_gr = gtk_radio_button_get_group(GTK_RADIO_BUTTON(X->trig[i]));
+        g_signal_connect(G_OBJECT(X->trig[i]), "toggled",
+                         G_CALLBACK(trig_cb), NULL);
+    }
+ 
+    gtk_box_pack_start(GTK_BOX(row1_hbox), trig_hbox, FALSE, TRUE, 0);
+
 /* Make numeric base radio button widgets. */
 
     base_hbox = gtk_hbox_new(FALSE, 0);
@@ -946,25 +968,21 @@
                          G_CALLBACK(base_cb), NULL);
     }
 
-    gtk_box_pack_start(GTK_BOX(row1_hbox), base_hbox, FALSE, TRUE, 0);
+    gtk_box_pack_end(GTK_BOX(row1_hbox), base_hbox, FALSE, TRUE, 0);
 
-/* Make Trig. type radio button widgets. */
- 
-    trig_hbox = gtk_hbox_new(FALSE, 0);
-    gtk_widget_show(trig_hbox);
- 
-    for (i = 0; i < MAXTRIGMODES; i++) {
-        X->trig[i] = gtk_radio_button_new_with_mnemonic(NULL, _(ttype_str[i]));
-        g_object_set_data(G_OBJECT(X->trig[i]), "trig", (gpointer) i);
-        gtk_widget_show(X->trig[i]);
-        gtk_box_pack_start(GTK_BOX(trig_hbox), X->trig[i], FALSE, FALSE, 0);
-        gtk_radio_button_set_group(GTK_RADIO_BUTTON(X->trig[i]), trig_gr);
-        trig_gr = gtk_radio_button_get_group(GTK_RADIO_BUTTON(X->trig[i]));
-        g_signal_connect(G_OBJECT(X->trig[i]), "toggled",
-                         G_CALLBACK(trig_cb), NULL);
-    }
+/* Make Hyp and Inv trigonometric check boxes. */
+
+    X->inv = gtk_check_button_new_with_mnemonic(_("_Inv"));
+    gtk_widget_show(X->inv);
+    gtk_box_pack_start(GTK_BOX(row2_hbox), X->inv, FALSE, FALSE, 0);
+    g_signal_connect(G_OBJECT(X->inv), "toggled",
+                      G_CALLBACK(inv_cb), NULL);
 
-    gtk_box_pack_end(GTK_BOX(row1_hbox), trig_hbox, FALSE, TRUE, 0);
+    X->hyp = gtk_check_button_new_with_mnemonic(_("H_yp"));
+    gtk_widget_show(X->hyp);
+    gtk_box_pack_start(GTK_BOX(row2_hbox), X->hyp, FALSE, FALSE, 0);
+    g_signal_connect(G_OBJECT(X->hyp), "toggled",
+                      G_CALLBACK(hyp_cb), NULL);
 
 /* Make display type radio button widgets. */
 
@@ -982,21 +1000,7 @@
                          G_CALLBACK(disp_cb), NULL);
     }
 
-    gtk_box_pack_start(GTK_BOX(row2_hbox), disp_hbox, FALSE, TRUE, 0);
-
-/* Make Hyp and Inv trigonometric check boxes. */
-
-    X->inv = gtk_check_button_new_with_mnemonic(_("_Inv"));
-    gtk_widget_show(X->inv);
-    gtk_box_pack_end(GTK_BOX(row2_hbox), X->inv, FALSE, FALSE, 0);
-    g_signal_connect(G_OBJECT(X->inv), "toggled",
-                      G_CALLBACK(inv_cb), NULL);
-
-    X->hyp = gtk_check_button_new_with_mnemonic(_("H_yp"));
-    gtk_widget_show(X->hyp);
-    gtk_box_pack_end(GTK_BOX(row2_hbox), X->hyp, FALSE, FALSE, 0);
-    g_signal_connect(G_OBJECT(X->hyp), "toggled",
-                      G_CALLBACK(hyp_cb), NULL);
+    gtk_box_pack_end(GTK_BOX(row2_hbox), disp_hbox, FALSE, TRUE, 0);
 
     gtk_box_pack_start(GTK_BOX(vbox), row1_hbox, FALSE, FALSE, 0);
     gtk_box_pack_start(GTK_BOX(vbox), row2_hbox, FALSE, FALSE, 0);
@@ -1439,10 +1443,18 @@
 void
 make_frames()
 {
+    struct button *n;
+    GtkWidget *menu;
+
     X->clipboard_atom = gdk_atom_intern("CLIPBOARD", FALSE);
     create_kframe();                     /* Create main gcalctool window. */
     create_rframe();                     /* Create memory register window. */
     set_mode(v->modetype);
+
+    n = (struct button *) g_object_get_data(G_OBJECT(BUT_ACC), "button");
+    menu = create_menu(n->mtype, n);
+    set_accuracy_toggle(v->accuracy);
+    set_rm_zeroes_toggle(v->rm_zeroes);
 }
 
 
@@ -1727,17 +1739,11 @@
             break;
 
         case M_BASIC:
-            v->modetype = BASIC;
-            set_item(BASEITEM, DEC);
-            set_item(NUMITEM, FIX);
-            do_mode();
+            reset_mode_values(BASIC);
             break;
 
         case M_FIN:
-            v->modetype = FINANCIAL;
-            set_item(BASEITEM, DEC);
-            set_item(NUMITEM, FIX);
-            do_mode();
+            reset_mode_values(FINANCIAL);
             break;
 
         case M_SCI:
@@ -1821,6 +1827,27 @@
 
 
 static void
+reset_mode_values(enum mode_type mtype)
+{
+    v->modetype = mtype;
+    set_item(BASEITEM, DEC);
+    set_item(NUMITEM, FIX);
+    v->accuracy = 9;
+    set_accuracy_toggle(v->accuracy);
+
+    v->started = 0;          /* Hack to get do_accuracy() to just return. */
+    v->rm_zeroes = TRUE;
+    set_rm_zeroes_toggle(v->rm_zeroes);
+    put_resource(R_ZEROES, set_bool(v->rm_zeroes == TRUE));
+    v->started = 1;
+
+    show_display(v->MPdisp_val);
+    make_registers();
+    do_mode();
+}
+
+
+static void
 set_button_state(GtkWidget *w, int isSensitive)
 {
     gtk_widget_set_sensitive(w, isSensitive);
@@ -1828,6 +1855,17 @@
 
 
 void
+set_accuracy_toggle(int val)
+{
+    GtkWidget *acc;
+
+    acc = gtk_item_factory_get_widget_by_action(X->fact[(int) M_ACC], 
+                                                val + '0');
+    gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(acc), TRUE);
+}
+
+
+void
 set_display(char *str)
 {
     GtkTextBuffer *buffer;
@@ -1985,6 +2023,16 @@
     else {
         X->icon = NULL;
     }
+}
+
+
+void
+set_rm_zeroes_toggle(int state)
+{
+    GtkWidget *rmz;
+
+    rmz = gtk_item_factory_get_widget_by_action(X->fact[(int) M_ACC], 'R');
+    gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(rmz), state);
 }
 
 
