Merge lp:~marvil07/do-plugins/GNOME-Calculator into lp:do-plugins

Proposed by marvil07
Status: Needs review
Proposed branch: lp:~marvil07/do-plugins/GNOME-Calculator
Merge into: lp:do-plugins
Diff against target: 27 lines (+10/-1)
1 file modified
GNOME-Calculator/src/GCalcToolAction.cs (+10/-1)
To merge this branch: bzr merge lp:~marvil07/do-plugins/GNOME-Calculator
Reviewer Review Type Date Requested Status
marvil07 (community) answering Needs Information
Chris S. Needs Information
Review via email: mp+14964@code.launchpad.net
To post a comment you must log in.
Revision history for this message
marvil07 (marvil07) wrote :

use "=" as the identifier for expressions to process inside gnome-calculator

Revision history for this message
Chris S. (cszikszoy) wrote :

Why limit the possible items for the GNOME Calculator action to just those that have an "=" at the beginning?

review: Needs Information
Revision history for this message
marvil07 (marvil07) wrote :

Hi Chris,

Thanks for the review!

Originally, when I write GNOME-Calculator Alex suggest me to make a regex filter for it.

This patch is a simple solution to avoid having a regex(I tried it, but it's hard[1] I think) to filter the input.

Also, IIRC this is also a solution in other software that do the same, so why not follow a good desition :-)

[1] http://git.gnome.org/cgit/gcalctool/tree/src/mp-equation-parser.y

review: Needs Information (answering)
Revision history for this message
marvil07 (marvil07) wrote :

I did not say any reason :(

The main reason is for avoid having this plugin suggested if we do not want to use it(we decide it by not prefixing the expression with "=")

Unmerged revisions

674. By marvil07

filter expression for gnome-calculator plugin using "=" at the start

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'GNOME-Calculator/src/GCalcToolAction.cs'
2--- GNOME-Calculator/src/GCalcToolAction.cs 2009-11-10 03:14:57 +0000
3+++ GNOME-Calculator/src/GCalcToolAction.cs 2009-11-17 20:40:24 +0000
4@@ -54,13 +54,22 @@
5 get { yield return typeof (ITextItem); }
6 }
7
8+ public override bool SupportsItem (Item item)
9+ {
10+ if (item is ITextItem) {
11+ string text = item.ToString();
12+ return text.StartsWith("=");
13+ }
14+ return false;
15+ }
16+
17 public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
18 {
19 string expression = (items.First () as ITextItem).Text;
20 string result = "";
21 string error = AddinManager.CurrentLocalizer.GetString ("Sorry I couldn't understand your expression, try another way");
22
23- ProcessStartInfo ps = new ProcessStartInfo ("gcalctool", "-s \"" + expression + "\"");
24+ ProcessStartInfo ps = new ProcessStartInfo ("gcalctool", "-s \"" + expression.Substring(1) + "\"");
25 ps.UseShellExecute = false;
26 ps.RedirectStandardOutput = true;
27 Process p = Process.Start (ps);

Subscribers

People subscribed via source and target branches