GNOME Bugzilla – Bug 114364
constants can be modified in unexpected way
Last modified: 2004-12-22 21:47:04 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.
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.
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?
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.
(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?
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.
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.
Created attachment 17735 [details] Fix for the propsed solution.
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.
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 :)
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.
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.)
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.
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.
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?
Hi Breda. It looks great. Please commit. Thanks!
Changes made in gcalctool Manual V2.4, now committed into CVS :)