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 766155 - Unable to reuse results from history
Unable to reuse results from history
Status: RESOLVED FIXED
Product: gnome-calculator
Classification: Core
Component: general
3.20.x
Other Linux
: Normal normal
: ---
Assigned To: gcalctool maintainers
gcalctool maintainers
: 770858 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2016-05-09 03:14 UTC by Robbie Smith
Modified: 2016-10-11 08:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix reusing results from the history stack (4.31 KB, patch)
2016-07-11 16:15 UTC, Antonio Ospite
committed Details | Review

Description Robbie Smith 2016-05-09 03:14:45 UTC
In the previous version of gnome-calculator (3.18.x), you were able to reuse history by clicking either the result or the calculation and that would display at the cursor point in the entry field. This behaviour seems to have changed in 3.20.x, and I'm wondering if this is a dropped feature or a bug, as it was really useful for large calculations involving multiple stages.
Comment 1 lychnus 2016-05-11 05:55:33 UTC
I can confirm this, I am running gnome-calculator on a Gnome/Arch setup.
Comment 2 Antonio Ospite 2016-07-11 13:44:26 UTC
Hi,

the regression has been introduced in commit 9bb6936ba74602ec891c1ffecdf1665dba1a1be4

Reverting it would fix the issue, however we don't want to do this because using GtkBuilder is cleaner indeed.

AFAIU the issue happens because the history entries are GtkLabels (https://git.gnome.org/browse/gnome-calculator/tree/data/history-entry.ui), and it looks like a GtkLabel cannot get the button-press-event directly, the Gtk docs say so in https://developer.gnome.org/gtk3/unstable/GtkLabel.html#gtk-label-get-layout-offsets and in fact the previous procedural code used GtkEventBox containers for the labels to get the events.

I'll see if I can do the same using GtkBuilder, but feel free to anticipate me, I am still pretty new to these things.

Ciao ciao,
   Antonio
Comment 3 Antonio Ospite 2016-07-11 16:15:45 UTC
Created attachment 331236 [details] [review]
Fix reusing results from the history stack

OK, the attached patch seems to fix it for me.
Comment 4 Antonio Ospite 2016-07-11 16:21:22 UTC
After fixing the issue I noticed that clicking on the equation in the history stack has a different behavior that clicking on the result:

- A click on the equation would replace the current expression
- A click on the result would append it to the current expression

Is this difference expected?
Comment 5 Robert Roth 2016-09-17 06:21:16 UTC
*** Bug 770858 has been marked as a duplicate of this bug. ***
Comment 6 Robert Roth 2016-10-11 07:39:40 UTC
(In reply to Antonio Ospite from comment #4)
> After fixing the issue I noticed that clicking on the equation in the
> history stack has a different behavior that clicking on the result:
> 
> - A click on the equation would replace the current expression
> - A click on the result would append it to the current expression
> 
> Is this difference expected?

I'm not sure on that, but I assume yes (this seems to be implemented for a reason), as I might have a typo in the original equation, in which case I do not want to enter it again, so I click the equation, and edit it in the equation editor, but if I just need the result, than I click that. You get what you clicked, and I feel it is natural.
Comment 7 Robert Roth 2016-10-11 07:40:19 UTC
Attachment 331236 [details] pushed as c088882 - Fix reusing results from the history stack
Comment 8 Hussam Al-Tayeb 2016-10-11 08:09:09 UTC
This is a bit confusing to me now.
Clicking on 9+4 from the history stack replaces the current equation or line. This  makes sense to me.
However clicking on 13 appends 13 to 9+4. It shows 9+413. Is this the expected behavior by design?
Comment 9 Robert Roth 2016-10-11 08:22:39 UTC
(In reply to Hussam Al-Tayeb from comment #8)
> This is a bit confusing to me now.
> Clicking on 9+4 from the history stack replaces the current equation or
> line. This  makes sense to me.
> However clicking on 13 appends 13 to 9+4. It shows 9+413. Is this the
> expected behavior by design?

Hmm... good question. It seems to make sense to append the result  e.g. if you have "9+", but indeed, appending if we have "9+4" is strange, as it's probably not something you want. However, I'm not sure what should happen when clicking the result in this case. 
* Should the result replace the current equation completely? That would break the use-case of really reusing a result in new equations.
* Maybe we should append if we have an equation ending with a binary operator, and replace otherwise? Suggestions are welcome. 
In any case, clicking the result/equation works now, so this bug seems to be fixed, we just have to define how to smartly decide whether to append or replace, as append makes sense in some cases, but doesn't make sense in other cases. Let us take that discussion to another ticket.