After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 114364 - constants can be modified in unexpected way
constants can be modified in unexpected way
Status: RESOLVED FIXED
Product: gnome-calculator
Classification: Core
Component: general
unspecified
Other All
: Normal major
: ---
Assigned To: Rich Burridge
Rich Burridge
Depends on:
Blocks:
 
 
Reported: 2003-06-03 21:03 UTC by Abel Cheung
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: 2.3/2.4


Attachments
Fix for the propsed solution. (10.44 KB, text/plain)
2003-06-24 14:52 UTC, Rich Burridge
Details

Description Abel Cheung 2003-06-03 21:03:51 UTC
Constants values can be changed through changing base
(hexadecimal <-> decimal, etc). Here is the steps reproducing
the effect (I'll take 2^20 as example):

1. switch to hexadecimal mode.
2. press 'constant' button, 2^20 becomes 100000.
3. choose 'modify constants', then save them.
4. switch back to decimal mode.
5. 2^20 is still 100000, but now it's base 10 instead of base 16.
Comment 1 Rich Burridge 2003-06-10 21:47:56 UTC
Cc:'ing Calum Benson, the HCI guy on this as the
potential fix could involve an HCI change.

I can see exactly where this is happening. In the
cfframe_response_cb() function in gtk.c there is:

...
  if (X->CFtype == M_CON) {
      MPstr_to_num(item.value, DEC, v->MPcon_vals[i]);
      STRCPY(v->con_names[i], item.description);
      put_constant(i, item.value, item.description);
...

I can easily fix gcalctool to convert/store the correct 
number, but I need to know the answer to one question.

If you are editing a constant, should the new value you
enter be in the current base the calculator is in (as
defined by the Bin/Oct/Dec/Hex toggle below the display
or should you always be entering constants in Dec?

I think it should be the former, which would make it much
easier for users to enter Bin/Oct/Hex constants, but I 
want Calum to give feedback before I just fix it this way.
Comment 2 Abel Cheung 2003-06-12 03:28:36 UTC
If Bin/Oct/Hex constants can be entered, then this feature
must be very clearly stated in the constant editor window,
otherwise people will expect it's decimal only. :-)

But regardless of what user has entered, I think the best
way is to store the number internally as decimal, and convert
to other bases when displaying, so there's no confusion on
which base the constant is in.

One question though... will precision be lost in such conversion?
Comment 3 Calum Benson 2003-06-13 17:12:24 UTC
I guess the question is 'would you ever want to enter a constant in
something other than decimal'... admittedly I'm not much of a hex or
binary-head, but I can't think of many situations where I'd want to.  

R.I.P. is right, I think if constants in other bases were to be
allowed you might have to tweak the UI a bit, e.g. to pop up a simple
entry dialog when you edited a constant, rather than allowing editing
directly in-place:

        +-------------------------+
 Value: |                         |
        +-------------------------+
        [x] Hex  [ ] Bin  [ ]  Dec

                     [Cancel][ OK ]

where the base defaulted to the currently-selected base for new
constants, and the base in which the constant was originally entered
for existing ones.
Comment 4 Rich Burridge 2003-06-18 17:34:47 UTC
(cc:'ing Breda as there as possibly some UI changes coming up
 here, that will affect the online help documentation).

I've been thinking some more on this, and I think the best
way to solve this problem is as follows:

* when you change numeric base and then display the constant
  values in the Con menu, the values are shown in the current
  base.

* when you select "Edit Constants" from the Con menu, the values
  of each constant are shown in Decimal. I believe we should add
  another line just below "Click a value or description to edit it:".
  Something along the lines of:
  "All constant values are in decimal".

Calum/Breda: does this fix (and the suggested wording) sound 
okay to you?
Comment 5 Breda McColgan 2003-06-23 20:48:33 UTC
Rich, I think your approach is fine for now. If you later discover
that people would like to enter constants in other numeric bases, you
could then implement Calum's suggestion. I'd change the proposed new
text for the Edit Constants dialog to the following, if you have room:
"All constant values are specified in the decimal numeric base"

I suggest making the following changes to the Help:

3.4.10 To Use Constant Values

Replace the introductory text above the table describing the
constants. Use the following text instead:
"
The gcalctool application provides ten default constant values. The
following table shows the constant values that are displayed when you
use the decimal numeric base:
"

Add the following Note to the end of Section 3.4.10:
"
Note:
When you click on Con, the constant values are displayed in the
current numeric base. However, in the Edit Constants window, all
constant values are specified in the decimal numeric base, even if the
current numeric base is not decimal.
"

If you're happy with this suggested change, I'll check the updated
manual into CVS.
Comment 6 Rich Burridge 2003-06-23 20:56:51 UTC
Hi Breda. Hold off on your help changes with this one for
a wee bit please. I've still got to convince Calum this is the
best way to fix this (for this first release). Thanks.
Comment 7 Rich Burridge 2003-06-24 14:52:38 UTC
Created attachment 17735 [details]
Fix for the propsed solution.
Comment 8 Rich Burridge 2003-06-24 14:55:31 UTC
I've checked the proposed fix into CVS HEAD. Fixed in
v4.2.93. It uses the wording you suggested for the
"Edit Constants" popup Breda.

Calum, if you want the fix tweaked in any way, just let
me know.

Breda, could you please go ahead and integrate the help
file changes as suggested.

Thanks.
Comment 9 Breda McColgan 2003-06-24 17:43:59 UTC
Hi Rich,

I don't think you've convinced Calum yet :) 
If you don't mind, I'll hold off on updating the documentation for
now, rather than have to undo my changes later, should you decide to
follow Calum's suggestion. 

Actually, now that I've spoken to Calum about this, I'm inclined to
agree that it is inconsistent to do things differently in the Edit
Constants dialog. Perhaps the easiest thing would be to display the
constants in decimal numeric base all the time? 

OTOH, is it likely that someone would want to see/use the non-decimal
value of the constant? If so, then I think you should implement
Calum's suggestion.

I'll wait until ye reach a final decision before updating the
documentation :)
Comment 10 Rich Burridge 2003-06-24 18:01:25 UTC
As mentioned to Calum on IRC yesterday, calctool,
the precursor to gcalctool that was in OpenWindows
DeskSet, just used to show constants in decimal base.
It would definitely be possible to easily do this.
I.e. the constant menu items are always in decimal.
The changes I just made to "fix" this now make this
a one-line change.

Calum, can you give the yay/nay on this asap please.
I'd really like to get it resolved before the July
4th forced vacation, and give Breda a chasnce to update
the online help accordingly before thenm too.

Thanks.
Comment 11 Calum Benson 2003-06-24 19:04:52 UTC
Yes, I think I'd be happiest with the calctool approach until we've
got a more solid requirement for anything more complex.  

(Might still want to clarify on the Constants menu/dialog when
operating in a non-decimal base that all the constants shown are in
decimal, but I don't have gcalctool running at the moment so I'm not
sure know how easy/ugly/necessary that would be.)
Comment 12 Rich Burridge 2003-06-24 19:11:30 UTC
Okay, will fix this way (this afternoon when I return to
the office). Note it will have the label on the "Edit
Constants" to say that all constants are in decimal, otherwise
to fix this would be a 7 line change. ;-)  More later...

Thanks.
Comment 13 Rich Burridge 2003-06-24 22:21:25 UTC
The items in the constants menu are now
always displayed in the decimal numeric base. 
This is consistent with the way that calctool 
in the OpenWindows DeskSet worked. Checked
into CVS HEAD. Refixed in v4.2.94.

Breda, could you check your online help changes
in now please! ;-)

Thanks.
Comment 14 Breda McColgan 2003-06-25 10:51:41 UTC
Okay, here's the new proposal for the Help update :)

The only change in Section 3.4.10 ("To Use Constant Values") is in the
first paragraph, which now becomes two paragraphs. The extra sentence
is added to the first of these new paragraphs.

Original text:
"Click on Con to display the list of defined constant values. Select a
constant from the menu to enter its value in the display area. If you
use the keyboard shortcut #, you can use the keyboard to specify the
constant, as shown in the following example:"

New text:
"Click on Con to display the list of defined constant values. All
constant values are specified in decimal numeric base, even if the
current numeric base is not decimal.

Select a constant from the menu to enter its value in the display
area. If you use the keyboard shortcut #, you can use the keyboard to
specify the constant, as shown in the following example:"


Is this proposed change ok with you?
Comment 15 Rich Burridge 2003-06-25 14:44:54 UTC
Hi Breda. It looks great. Please commit. Thanks!
Comment 16 Breda McColgan 2003-06-25 15:48:40 UTC
Changes made in gcalctool Manual V2.4, now committed into CVS :)