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

Proposed by marvil07
Status: Merged
Approved by: Alex Launi
Approved revision: no longer in the revision history of the source branch.
Merged at revision: not available
Proposed branch: lp://qastaging/~marvil07/do-plugins/GNOME-Calculator
Merge into: lp://qastaging/do-plugins
Diff against target: 231 lines (+155/-0)
7 files modified
DoPlugins.mds (+4/-0)
GNOME-Calculator/GNOME-Calculator.mdp (+29/-0)
GNOME-Calculator/Makefile.am (+15/-0)
GNOME-Calculator/Resources/GNOME-Calculator.addin.xml.in (+26/-0)
GNOME-Calculator/src/GCalcToolAction.cs (+78/-0)
Makefile.am (+1/-0)
configure.ac (+2/-0)
To merge this branch: bzr merge lp://qastaging/~marvil07/do-plugins/GNOME-Calculator
Reviewer Review Type Date Requested Status
Alex Launi (community) Approve
Review via email: mp+14635@code.qastaging.launchpad.net
To post a comment you must log in.
Revision history for this message
marvil07 (marvil07) wrote :

This is a really tiny plugin for solving expression trough gcalctool. the default calculator un GNOME Desktop(so, the probability that a gnome user have it installed is high).

Revision history for this message
Alex Launi (alexlauni) wrote :

You need to catch errors, for instance your SupportsItem should try to now allow things that aren't valid mathematical expressions, and catch the errors for expressions that slip through. If I pass "one plus one" gcalctool returns Error -1 (worthless error message). Do should display something like "Sorry I couldn't understand your expression, try another way". Ideally it should be able to parse for valid expressions.

review: Disapprove
Revision history for this message
Alex Launi (alexlauni) wrote :

Do the stuff we talked about in IRC and we'll be good to go

review: Approve
Revision history for this message
marvil07 (marvil07) wrote :

stuff commited :-)

670. By Alex Launi

merge GNOME calculator plugin

671. By Alex Launi

fix the GNOME Calculator action name and go OCD on some bracket placements

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'DoPlugins.mds'
2--- DoPlugins.mds 2009-10-02 02:12:39 +0000
3+++ DoPlugins.mds 2009-11-09 06:39:10 +0000
4@@ -77,6 +77,7 @@
5 <Entry build="True" name="Qalculate" configuration="Debug" />
6 <Entry build="True" name="Baconator" configuration="Debug" />
7 <Entry build="True" name="Chromium" configuration="Debug" />
8+ <Entry build="True" name="GNOME-Calculator" configuration="Debug" />
9 </Configuration>
10 <Configuration name="Release" ctype="CombineConfiguration">
11 <Entry build="True" name="Rhythmbox" configuration="Release" />
12@@ -155,6 +156,7 @@
13 <Entry build="True" name="Qalculate" configuration="Release" />
14 <Entry build="True" name="Baconator" configuration="Release" />
15 <Entry build="True" name="Chromium" configuration="Release" />
16+ <Entry build="True" name="GNOME-Calculator" configuration="Release" />
17 </Configuration>
18 </Configurations>
19 <StartMode startupentry="Rhythmbox" single="True">
20@@ -234,6 +236,7 @@
21 <Execute type="None" entry="Qalculate" />
22 <Execute type="None" entry="Baconator" />
23 <Execute type="None" entry="Chromium" />
24+ <Execute type="None" entry="GNOME-Calculator" />
25 </StartMode>
26 <MonoDevelop.ChangeLogAddIn.ChangeLogInfo policy="UpdateNearestChangeLog" />
27 <Entries>
28@@ -313,5 +316,6 @@
29 <Entry filename="Qalculate/Qalculate.mdp" />
30 <Entry filename="Baconator/Baconator.mdp" />
31 <Entry filename="Chromium/Chromium.mdp" />
32+ <Entry filename="GNOME-Calculator/GNOME-Calculator.mdp" />
33 </Entries>
34 </Combine>
35\ No newline at end of file
36
37=== added directory 'GNOME-Calculator'
38=== added file 'GNOME-Calculator/GNOME-Calculator.mdp'
39--- GNOME-Calculator/GNOME-Calculator.mdp 1970-01-01 00:00:00 +0000
40+++ GNOME-Calculator/GNOME-Calculator.mdp 2009-11-09 06:39:10 +0000
41@@ -0,0 +1,29 @@
42+<Project name="GNOME-Calculator" fileversion="2.0" language="C#" clr-version="Net_2_0" targetFramework="3.5" ctype="DotNetProject">
43+ <Configurations active="Debug">
44+ <Configuration name="Debug" ctype="DotNetProjectConfiguration">
45+ <Output directory="bin/Debug" assembly="GNOME-Calculator" />
46+ <Build debugmode="True" target="Library" />
47+ <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_2_0" />
48+ <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" definesymbols="DEBUG" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
49+ </Configuration>
50+ <Configuration name="Release" ctype="DotNetProjectConfiguration">
51+ <Output directory="bin/Release" assembly="GNOME-Calculator" />
52+ <Build debugmode="False" target="Library" />
53+ <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_2_0" />
54+ <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
55+ </Configuration>
56+ </Configurations>
57+ <Contents>
58+ <File name="." subtype="Directory" buildaction="Compile" />
59+ <File name="src" subtype="Directory" buildaction="Compile" />
60+ <File name="src/GCalcToolAction.cs" subtype="Code" buildaction="Compile" />
61+ <File name="Resources/GNOME-Calculator.addin.xml" subtype="Code" buildaction="EmbedAsResource" />
62+ </Contents>
63+ <References>
64+ <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
65+ <ProjectReference type="Gac" localcopy="True" refto="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
66+ <ProjectReference type="Gac" localcopy="True" refto="Mono.Addins, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
67+ <ProjectReference type="Gac" localcopy="True" refto="Do.Universe, Version=0.9.0.0, Culture=neutral" />
68+ <ProjectReference type="Gac" localcopy="True" refto="Do.Platform, Version=0.9.0.0, Culture=neutral" />
69+ </References>
70+</Project>
71
72=== added file 'GNOME-Calculator/Makefile.am'
73--- GNOME-Calculator/Makefile.am 1970-01-01 00:00:00 +0000
74+++ GNOME-Calculator/Makefile.am 2009-11-09 06:39:10 +0000
75@@ -0,0 +1,15 @@
76+include $(top_srcdir)/build.rules.mk
77+
78+ASSEMBLY=GNOME-Calculator
79+
80+FILES = \
81+ src/GCalcToolAction.cs
82+
83+RESOURCES = \
84+ Resources/GNOME-Calculator.addin.xml
85+
86+REFERENCES = \
87+ System \
88+ System.Core \
89+ $(DO_PLATFORM_LIBS) \
90+ $(DO_UNIVERSE_LIBS)
91
92=== added directory 'GNOME-Calculator/Resources'
93=== added file 'GNOME-Calculator/Resources/GNOME-Calculator.addin.xml.in'
94--- GNOME-Calculator/Resources/GNOME-Calculator.addin.xml.in 1970-01-01 00:00:00 +0000
95+++ GNOME-Calculator/Resources/GNOME-Calculator.addin.xml.in 2009-11-09 06:39:10 +0000
96@@ -0,0 +1,26 @@
97+<Addin
98+ id="GNOME-Calculator"
99+ namespace="Do"
100+ version="0.1"
101+ name="GNOME Calculator"
102+ description="Add, subtract, multiply, and more."
103+ author="Marco Antonio Villegas Vega"
104+ category="Community"
105+ defaultEnabled="false"
106+ url="http://do.davebsd.com/wiki/GNOME_Calculator_Plugin"
107+>
108+
109+ <Runtime>
110+ <Import assembly="GNOME-Calculator.dll"/>
111+ </Runtime>
112+
113+ <Localizer type="Gettext" catalog="gnome-do-plugins" location="/usr/local/share/locale" />
114+
115+ <Dependencies>
116+ <Addin id="Universe" version="1.0" />
117+ </Dependencies>
118+
119+ <Extension path= "/Do/Action">
120+ <Action type="GnomeCalculator.Calculate" />
121+ </Extension>
122+</Addin>
123
124=== added directory 'GNOME-Calculator/src'
125=== added file 'GNOME-Calculator/src/GCalcToolAction.cs'
126--- GNOME-Calculator/src/GCalcToolAction.cs 1970-01-01 00:00:00 +0000
127+++ GNOME-Calculator/src/GCalcToolAction.cs 2009-11-09 06:39:10 +0000
128@@ -0,0 +1,78 @@
129+/**
130+ * GNOME Do is the legal property of its developers. Please refer to the
131+ * COPYRIGHT file distributed with this source distribution.
132+ *
133+ * This program is free software: you can redistribute it and/or modify
134+ * it under the terms of the GNU General Public License as published by
135+ * the Free Software Foundation, either version 3 of the License, or
136+ * (at your option) any later version.
137+ *
138+ * This program is distributed in the hope that it will be useful,
139+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
140+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
141+ * GNU General Public License for more details.
142+ *
143+ * You should have received a copy of the GNU General Public License
144+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
145+ */
146+
147+using Do.Universe;
148+using Do.Universe.Common;
149+using Mono.Addins;
150+using System;
151+using System.Collections.Generic;
152+using System.Diagnostics;
153+using System.Linq;
154+using System.Text.RegularExpressions;
155+
156+namespace GnomeCalculator
157+{
158+
159+ public class Calculate : Act
160+ {
161+
162+ public Calculate()
163+ {
164+ }
165+
166+ public override string Name
167+ {
168+ get { return "GNOME Calculator"; }
169+ }
170+
171+ public override string Description
172+ {
173+ get { return AddinManager.CurrentLocalizer.GetString ("Use GNOME Calculator to make simple calculations."); }
174+ }
175+
176+ public override string Icon
177+ {
178+ get { return "accessories-calculator"; }
179+ }
180+
181+ public override IEnumerable<Type> SupportedItemTypes
182+ {
183+ get { yield return typeof (ITextItem); }
184+ }
185+
186+ public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
187+ {
188+ string expression = (items.First () as ITextItem).Text;
189+ string result = "";
190+ string error = AddinManager.CurrentLocalizer.GetString ("Sorry I couldn't understand your expression, try another way");
191+
192+ ProcessStartInfo ps = new ProcessStartInfo ("gcalctool", "-s " + expression);
193+ ps.UseShellExecute = false;
194+ ps.RedirectStandardOutput = true;
195+ Process p = Process.Start (ps);
196+
197+ result = p.StandardOutput.ReadToEnd ();
198+ p.WaitForExit ();
199+ if (p.ExitCode != 0) {
200+ result = error;
201+ }
202+
203+ yield return new TextItem (result);
204+ }
205+ }
206+}
207
208=== modified file 'Makefile.am'
209--- Makefile.am 2009-09-21 12:21:23 +0000
210+++ Makefile.am 2009-11-09 06:39:10 +0000
211@@ -25,6 +25,7 @@
212 File \
213 Firefox \
214 Flickr \
215+ GNOME-Calculator \
216 GNOME-Dictionary \
217 GNOME-Screenshot \
218 GNOME-Session \
219
220=== modified file 'configure.ac'
221--- configure.ac 2009-10-01 04:57:09 +0000
222+++ configure.ac 2009-11-09 06:39:10 +0000
223@@ -282,6 +282,8 @@
224 Firefox/Resources/Firefox.addin.xml
225 Flickr/Makefile
226 Flickr/Resources/Flickr.addin.xml
227+GNOME-Calculator/Makefile
228+GNOME-Calculator/Resources/GNOME-Calculator.addin.xml
229 GNOME-Dictionary/Makefile
230 GNOME-Dictionary/Resources/GNOME-Dictionary.addin.xml
231 GNOME-Screenshot/Makefile

Subscribers

People subscribed via source and target branches