Merge lp:~joerlend.schinstad-deactivatedaccount/quidgets/main into lp:quidgets

Proposed by Jo-Erlend Schinstad
Status: Superseded
Proposed branch: lp:~joerlend.schinstad-deactivatedaccount/quidgets/main
Merge into: lp:quidgets
Diff against target: 7507 lines (+7330/-0) (has conflicts)
31 files modified
.bzr-builddeb/default.conf (+2/-0)
.quickly (+3/-0)
Copyright (+14/-0)
LICENSE (+676/-0)
debian/changelog (+65/-0)
debian/compat (+1/-0)
debian/control (+36/-0)
debian/copyright (+22/-0)
debian/python-quickly.widgets.install (+1/-0)
debian/rules (+7/-0)
debian/source/format (+1/-0)
po/quickly-widgets.pot (+182/-0)
quickly/prompts/__init__.py (+1024/-0)
quickly/tests/test_prompts.py (+37/-0)
quickly/widgets/asynch_task_progressbox.py (+310/-0)
quickly/widgets/conventions.py (+40/-0)
quickly/widgets/couch_grid.py (+455/-0)
quickly/widgets/dictionary_grid.py (+525/-0)
quickly/widgets/grid_column.py (+884/-0)
quickly/widgets/grid_filter.py (+845/-0)
quickly/widgets/media_player_box.py (+510/-0)
quickly/widgets/press_and_hold_button.py (+76/-0)
quickly/widgets/tests/_trial_temp/test.log (+1/-0)
quickly/widgets/tests/test_asycnh_task_progress_box.py (+51/-0)
quickly/widgets/tests/test_couch_grid.py (+284/-0)
quickly/widgets/tests/test_dictionary_grid.py (+276/-0)
quickly/widgets/tests/test_grid_filter.py (+138/-0)
quickly/widgets/text_editor.py (+398/-0)
quickly/widgets/url_fetch_progressbox.py (+125/-0)
quickly/widgets/web_cam_box.py (+297/-0)
setup.py (+44/-0)
Conflict adding file .quickly.  Moved existing file to .quickly.moved.
Conflict adding file Copyright.  Moved existing file to Copyright.moved.
Conflict adding file LICENSE.  Moved existing file to LICENSE.moved.
Conflict adding file __init__.py.  Moved existing file to __init__.py.moved.
Conflict adding file debian.  Moved existing file to debian.moved.
Conflict adding file po.  Moved existing file to po.moved.
Conflict adding file quickly.  Moved existing file to quickly.moved.
Conflict adding file setup.py.  Moved existing file to setup.py.moved.
To merge this branch: bzr merge lp:~joerlend.schinstad-deactivatedaccount/quidgets/main
Reviewer Review Type Date Requested Status
Rick Spencer Needs Fixing
Review via email: mp+69034@code.launchpad.net

Description of the change

I've fixed a couple of bugs, created a GridColumn superclass and made StringColumn and CheckColumn descendants of it. That made it possible to remove some duplicated code and there were some errors, such as an erroneously pasted docstring in an irrelevant place.

The DictionaryGrid and CouchGrids editable property can now be toggled without the widget redrawing itself. The code should be easier to read and maintain and it should be easier to provide new column types.

To post a comment you must log in.
Revision history for this message
Rick Spencer (rick-rickspencer3) wrote :

Hi Joe.

I really like the new code and functionality. Thanks so much for this!

Unfortunately, there are a lot of test failures now. Can I ask you to get to the bottom of those? For example, the test_headings_no_stored_records in test_couch_grid fails.

To run the tests:

1. cd to your project dir and
2. $touch __init__.py
3. type PYTHONPAH="./" trial quickly.widgets

This should run the tests from the code that you just modified.

Could you please see what is causing the test failures? Sometimes, you just need to fix up the tests a bit, and sometimes, the tests found possible bugs. Note that I wrote most of the tests to in response to other bug reports, so they guard against regressions.

Also, feel free to add more tests!

Thanks again, this is a great contribution.

Cheers, Rick

review: Needs Fixing
Revision history for this message
Jo-Erlend Schinstad (joerlend.schinstad-deactivatedaccount) wrote :

Well. I had introduced a bug that caused most of the errors, but it was really easily fixed. But I would like to further clean up that code. I see no reason why _initialize_renderer should have its own function just for a few lines of code. But that isn't important. It works.

There was one other issue, and it wasn't really introduced by me, but just uncovered. There is a very weird if-clause in CouchGrid init that does absolutely nothing. When I fixed the if clause to do what it _has to_ be intended to do, then one of the tests fails.

I've had a look at it, and it seems that when you add a dictionary to the CouchGrid, then two empty columns are added to the store between the values from the dicts and the final desktopcouch dict. I believe this is what's causing it, but I don't know how to fix it yet and I need to understand it better.

So in essence, it's safe to merge my branch.

161. By Michael Terry

* debian/control, debian/compat, debian/rules:
  - Convert to dh 8
  - Convert to dh_python2
  - Remove obsolete langpack.make include, causing FTBFS (LP: #835770)
* __init__.py:
  - Remove, it was getting installed to an inappropriately global
    location (LP: #826062)

162. By Rick Spencer

merge in bug fixes from jo-erlend bug #812266, bug #812281, and bug #812038

163. By Jo-Erlend Schinstad

Fixes bug https://bugs.launchpad.net/quidgets/+bug/841357

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory '.bzr-builddeb'
2=== added file '.bzr-builddeb/default.conf'
3--- .bzr-builddeb/default.conf 1970-01-01 00:00:00 +0000
4+++ .bzr-builddeb/default.conf 2011-08-09 11:40:13 +0000
5@@ -0,0 +1,2 @@
6+[BUILDDEB]
7+native = True
8
9=== added file '.quickly'
10--- .quickly 1970-01-01 00:00:00 +0000
11+++ .quickly 2011-08-09 11:40:13 +0000
12@@ -0,0 +1,3 @@
13+project = quidgets
14+template = python-library
15+format = 0.3
16
17=== renamed file '.quickly' => '.quickly.moved'
18=== added file 'Copyright'
19--- Copyright 1970-01-01 00:00:00 +0000
20+++ Copyright 2011-08-09 11:40:13 +0000
21@@ -0,0 +1,14 @@
22+# Copyright (C) 2010 Rick Spencer <rick.spencer@canonical.com>
23+### BEGIN AUTOMATIC LICENSE GENERATION
24+#This program is free software: you can redistribute it and/or modify it
25+#under the terms of the GNU General Public License version 3, as published
26+#by the Free Software Foundation.
27+#
28+#This program is distributed in the hope that it will be useful, but
29+#WITHOUT ANY WARRANTY; without even the implied warranties of
30+#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
31+#PURPOSE. See the GNU General Public License for more details.
32+#
33+#You should have received a copy of the GNU General Public License along
34+#with this program. If not, see <http://www.gnu.org/licenses/>.
35+### END AUTOMATIC LICENSE GENERATION
36
37=== renamed file 'Copyright' => 'Copyright.moved'
38=== added file 'LICENSE'
39--- LICENSE 1970-01-01 00:00:00 +0000
40+++ LICENSE 2011-08-09 11:40:13 +0000
41@@ -0,0 +1,676 @@
42+
43+ GNU GENERAL PUBLIC LICENSE
44+ Version 3, 29 June 2007
45+
46+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
47+ Everyone is permitted to copy and distribute verbatim copies
48+ of this license document, but changing it is not allowed.
49+
50+ Preamble
51+
52+ The GNU General Public License is a free, copyleft license for
53+software and other kinds of works.
54+
55+ The licenses for most software and other practical works are designed
56+to take away your freedom to share and change the works. By contrast,
57+the GNU General Public License is intended to guarantee your freedom to
58+share and change all versions of a program--to make sure it remains free
59+software for all its users. We, the Free Software Foundation, use the
60+GNU General Public License for most of our software; it applies also to
61+any other work released this way by its authors. You can apply it to
62+your programs, too.
63+
64+ When we speak of free software, we are referring to freedom, not
65+price. Our General Public Licenses are designed to make sure that you
66+have the freedom to distribute copies of free software (and charge for
67+them if you wish), that you receive source code or can get it if you
68+want it, that you can change the software or use pieces of it in new
69+free programs, and that you know you can do these things.
70+
71+ To protect your rights, we need to prevent others from denying you
72+these rights or asking you to surrender the rights. Therefore, you have
73+certain responsibilities if you distribute copies of the software, or if
74+you modify it: responsibilities to respect the freedom of others.
75+
76+ For example, if you distribute copies of such a program, whether
77+gratis or for a fee, you must pass on to the recipients the same
78+freedoms that you received. You must make sure that they, too, receive
79+or can get the source code. And you must show them these terms so they
80+know their rights.
81+
82+ Developers that use the GNU GPL protect your rights with two steps:
83+(1) assert copyright on the software, and (2) offer you this License
84+giving you legal permission to copy, distribute and/or modify it.
85+
86+ For the developers' and authors' protection, the GPL clearly explains
87+that there is no warranty for this free software. For both users' and
88+authors' sake, the GPL requires that modified versions be marked as
89+changed, so that their problems will not be attributed erroneously to
90+authors of previous versions.
91+
92+ Some devices are designed to deny users access to install or run
93+modified versions of the software inside them, although the manufacturer
94+can do so. This is fundamentally incompatible with the aim of
95+protecting users' freedom to change the software. The systematic
96+pattern of such abuse occurs in the area of products for individuals to
97+use, which is precisely where it is most unacceptable. Therefore, we
98+have designed this version of the GPL to prohibit the practice for those
99+products. If such problems arise substantially in other domains, we
100+stand ready to extend this provision to those domains in future versions
101+of the GPL, as needed to protect the freedom of users.
102+
103+ Finally, every program is threatened constantly by software patents.
104+States should not allow patents to restrict development and use of
105+software on general-purpose computers, but in those that do, we wish to
106+avoid the special danger that patents applied to a free program could
107+make it effectively proprietary. To prevent this, the GPL assures that
108+patents cannot be used to render the program non-free.
109+
110+ The precise terms and conditions for copying, distribution and
111+modification follow.
112+
113+ TERMS AND CONDITIONS
114+
115+ 0. Definitions.
116+
117+ "This License" refers to version 3 of the GNU General Public License.
118+
119+ "Copyright" also means copyright-like laws that apply to other kinds of
120+works, such as semiconductor masks.
121+
122+ "The Program" refers to any copyrightable work licensed under this
123+License. Each licensee is addressed as "you". "Licensees" and
124+"recipients" may be individuals or organizations.
125+
126+ To "modify" a work means to copy from or adapt all or part of the work
127+in a fashion requiring copyright permission, other than the making of an
128+exact copy. The resulting work is called a "modified version" of the
129+earlier work or a work "based on" the earlier work.
130+
131+ A "covered work" means either the unmodified Program or a work based
132+on the Program.
133+
134+ To "propagate" a work means to do anything with it that, without
135+permission, would make you directly or secondarily liable for
136+infringement under applicable copyright law, except executing it on a
137+computer or modifying a private copy. Propagation includes copying,
138+distribution (with or without modification), making available to the
139+public, and in some countries other activities as well.
140+
141+ To "convey" a work means any kind of propagation that enables other
142+parties to make or receive copies. Mere interaction with a user through
143+a computer network, with no transfer of a copy, is not conveying.
144+
145+ An interactive user interface displays "Appropriate Legal Notices"
146+to the extent that it includes a convenient and prominently visible
147+feature that (1) displays an appropriate copyright notice, and (2)
148+tells the user that there is no warranty for the work (except to the
149+extent that warranties are provided), that licensees may convey the
150+work under this License, and how to view a copy of this License. If
151+the interface presents a list of user commands or options, such as a
152+menu, a prominent item in the list meets this criterion.
153+
154+ 1. Source Code.
155+
156+ The "source code" for a work means the preferred form of the work
157+for making modifications to it. "Object code" means any non-source
158+form of a work.
159+
160+ A "Standard Interface" means an interface that either is an official
161+standard defined by a recognized standards body, or, in the case of
162+interfaces specified for a particular programming language, one that
163+is widely used among developers working in that language.
164+
165+ The "System Libraries" of an executable work include anything, other
166+than the work as a whole, that (a) is included in the normal form of
167+packaging a Major Component, but which is not part of that Major
168+Component, and (b) serves only to enable use of the work with that
169+Major Component, or to implement a Standard Interface for which an
170+implementation is available to the public in source code form. A
171+"Major Component", in this context, means a major essential component
172+(kernel, window system, and so on) of the specific operating system
173+(if any) on which the executable work runs, or a compiler used to
174+produce the work, or an object code interpreter used to run it.
175+
176+ The "Corresponding Source" for a work in object code form means all
177+the source code needed to generate, install, and (for an executable
178+work) run the object code and to modify the work, including scripts to
179+control those activities. However, it does not include the work's
180+System Libraries, or general-purpose tools or generally available free
181+programs which are used unmodified in performing those activities but
182+which are not part of the work. For example, Corresponding Source
183+includes interface definition files associated with source files for
184+the work, and the source code for shared libraries and dynamically
185+linked subprograms that the work is specifically designed to require,
186+such as by intimate data communication or control flow between those
187+subprograms and other parts of the work.
188+
189+ The Corresponding Source need not include anything that users
190+can regenerate automatically from other parts of the Corresponding
191+Source.
192+
193+ The Corresponding Source for a work in source code form is that
194+same work.
195+
196+ 2. Basic Permissions.
197+
198+ All rights granted under this License are granted for the term of
199+copyright on the Program, and are irrevocable provided the stated
200+conditions are met. This License explicitly affirms your unlimited
201+permission to run the unmodified Program. The output from running a
202+covered work is covered by this License only if the output, given its
203+content, constitutes a covered work. This License acknowledges your
204+rights of fair use or other equivalent, as provided by copyright law.
205+
206+ You may make, run and propagate covered works that you do not
207+convey, without conditions so long as your license otherwise remains
208+in force. You may convey covered works to others for the sole purpose
209+of having them make modifications exclusively for you, or provide you
210+with facilities for running those works, provided that you comply with
211+the terms of this License in conveying all material for which you do
212+not control copyright. Those thus making or running the covered works
213+for you must do so exclusively on your behalf, under your direction
214+and control, on terms that prohibit them from making any copies of
215+your copyrighted material outside their relationship with you.
216+
217+ Conveying under any other circumstances is permitted solely under
218+the conditions stated below. Sublicensing is not allowed; section 10
219+makes it unnecessary.
220+
221+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
222+
223+ No covered work shall be deemed part of an effective technological
224+measure under any applicable law fulfilling obligations under article
225+11 of the WIPO copyright treaty adopted on 20 December 1996, or
226+similar laws prohibiting or restricting circumvention of such
227+measures.
228+
229+ When you convey a covered work, you waive any legal power to forbid
230+circumvention of technological measures to the extent such circumvention
231+is effected by exercising rights under this License with respect to
232+the covered work, and you disclaim any intention to limit operation or
233+modification of the work as a means of enforcing, against the work's
234+users, your or third parties' legal rights to forbid circumvention of
235+technological measures.
236+
237+ 4. Conveying Verbatim Copies.
238+
239+ You may convey verbatim copies of the Program's source code as you
240+receive it, in any medium, provided that you conspicuously and
241+appropriately publish on each copy an appropriate copyright notice;
242+keep intact all notices stating that this License and any
243+non-permissive terms added in accord with section 7 apply to the code;
244+keep intact all notices of the absence of any warranty; and give all
245+recipients a copy of this License along with the Program.
246+
247+ You may charge any price or no price for each copy that you convey,
248+and you may offer support or warranty protection for a fee.
249+
250+ 5. Conveying Modified Source Versions.
251+
252+ You may convey a work based on the Program, or the modifications to
253+produce it from the Program, in the form of source code under the
254+terms of section 4, provided that you also meet all of these conditions:
255+
256+ a) The work must carry prominent notices stating that you modified
257+ it, and giving a relevant date.
258+
259+ b) The work must carry prominent notices stating that it is
260+ released under this License and any conditions added under section
261+ 7. This requirement modifies the requirement in section 4 to
262+ "keep intact all notices".
263+
264+ c) You must license the entire work, as a whole, under this
265+ License to anyone who comes into possession of a copy. This
266+ License will therefore apply, along with any applicable section 7
267+ additional terms, to the whole of the work, and all its parts,
268+ regardless of how they are packaged. This License gives no
269+ permission to license the work in any other way, but it does not
270+ invalidate such permission if you have separately received it.
271+
272+ d) If the work has interactive user interfaces, each must display
273+ Appropriate Legal Notices; however, if the Program has interactive
274+ interfaces that do not display Appropriate Legal Notices, your
275+ work need not make them do so.
276+
277+ A compilation of a covered work with other separate and independent
278+works, which are not by their nature extensions of the covered work,
279+and which are not combined with it such as to form a larger program,
280+in or on a volume of a storage or distribution medium, is called an
281+"aggregate" if the compilation and its resulting copyright are not
282+used to limit the access or legal rights of the compilation's users
283+beyond what the individual works permit. Inclusion of a covered work
284+in an aggregate does not cause this License to apply to the other
285+parts of the aggregate.
286+
287+ 6. Conveying Non-Source Forms.
288+
289+ You may convey a covered work in object code form under the terms
290+of sections 4 and 5, provided that you also convey the
291+machine-readable Corresponding Source under the terms of this License,
292+in one of these ways:
293+
294+ a) Convey the object code in, or embodied in, a physical product
295+ (including a physical distribution medium), accompanied by the
296+ Corresponding Source fixed on a durable physical medium
297+ customarily used for software interchange.
298+
299+ b) Convey the object code in, or embodied in, a physical product
300+ (including a physical distribution medium), accompanied by a
301+ written offer, valid for at least three years and valid for as
302+ long as you offer spare parts or customer support for that product
303+ model, to give anyone who possesses the object code either (1) a
304+ copy of the Corresponding Source for all the software in the
305+ product that is covered by this License, on a durable physical
306+ medium customarily used for software interchange, for a price no
307+ more than your reasonable cost of physically performing this
308+ conveying of source, or (2) access to copy the
309+ Corresponding Source from a network server at no charge.
310+
311+ c) Convey individual copies of the object code with a copy of the
312+ written offer to provide the Corresponding Source. This
313+ alternative is allowed only occasionally and noncommercially, and
314+ only if you received the object code with such an offer, in accord
315+ with subsection 6b.
316+
317+ d) Convey the object code by offering access from a designated
318+ place (gratis or for a charge), and offer equivalent access to the
319+ Corresponding Source in the same way through the same place at no
320+ further charge. You need not require recipients to copy the
321+ Corresponding Source along with the object code. If the place to
322+ copy the object code is a network server, the Corresponding Source
323+ may be on a different server (operated by you or a third party)
324+ that supports equivalent copying facilities, provided you maintain
325+ clear directions next to the object code saying where to find the
326+ Corresponding Source. Regardless of what server hosts the
327+ Corresponding Source, you remain obligated to ensure that it is
328+ available for as long as needed to satisfy these requirements.
329+
330+ e) Convey the object code using peer-to-peer transmission, provided
331+ you inform other peers where the object code and Corresponding
332+ Source of the work are being offered to the general public at no
333+ charge under subsection 6d.
334+
335+ A separable portion of the object code, whose source code is excluded
336+from the Corresponding Source as a System Library, need not be
337+included in conveying the object code work.
338+
339+ A "User Product" is either (1) a "consumer product", which means any
340+tangible personal property which is normally used for personal, family,
341+or household purposes, or (2) anything designed or sold for incorporation
342+into a dwelling. In determining whether a product is a consumer product,
343+doubtful cases shall be resolved in favor of coverage. For a particular
344+product received by a particular user, "normally used" refers to a
345+typical or common use of that class of product, regardless of the status
346+of the particular user or of the way in which the particular user
347+actually uses, or expects or is expected to use, the product. A product
348+is a consumer product regardless of whether the product has substantial
349+commercial, industrial or non-consumer uses, unless such uses represent
350+the only significant mode of use of the product.
351+
352+ "Installation Information" for a User Product means any methods,
353+procedures, authorization keys, or other information required to install
354+and execute modified versions of a covered work in that User Product from
355+a modified version of its Corresponding Source. The information must
356+suffice to ensure that the continued functioning of the modified object
357+code is in no case prevented or interfered with solely because
358+modification has been made.
359+
360+ If you convey an object code work under this section in, or with, or
361+specifically for use in, a User Product, and the conveying occurs as
362+part of a transaction in which the right of possession and use of the
363+User Product is transferred to the recipient in perpetuity or for a
364+fixed term (regardless of how the transaction is characterized), the
365+Corresponding Source conveyed under this section must be accompanied
366+by the Installation Information. But this requirement does not apply
367+if neither you nor any third party retains the ability to install
368+modified object code on the User Product (for example, the work has
369+been installed in ROM).
370+
371+ The requirement to provide Installation Information does not include a
372+requirement to continue to provide support service, warranty, or updates
373+for a work that has been modified or installed by the recipient, or for
374+the User Product in which it has been modified or installed. Access to a
375+network may be denied when the modification itself materially and
376+adversely affects the operation of the network or violates the rules and
377+protocols for communication across the network.
378+
379+ Corresponding Source conveyed, and Installation Information provided,
380+in accord with this section must be in a format that is publicly
381+documented (and with an implementation available to the public in
382+source code form), and must require no special password or key for
383+unpacking, reading or copying.
384+
385+ 7. Additional Terms.
386+
387+ "Additional permissions" are terms that supplement the terms of this
388+License by making exceptions from one or more of its conditions.
389+Additional permissions that are applicable to the entire Program shall
390+be treated as though they were included in this License, to the extent
391+that they are valid under applicable law. If additional permissions
392+apply only to part of the Program, that part may be used separately
393+under those permissions, but the entire Program remains governed by
394+this License without regard to the additional permissions.
395+
396+ When you convey a copy of a covered work, you may at your option
397+remove any additional permissions from that copy, or from any part of
398+it. (Additional permissions may be written to require their own
399+removal in certain cases when you modify the work.) You may place
400+additional permissions on material, added by you to a covered work,
401+for which you have or can give appropriate copyright permission.
402+
403+ Notwithstanding any other provision of this License, for material you
404+add to a covered work, you may (if authorized by the copyright holders of
405+that material) supplement the terms of this License with terms:
406+
407+ a) Disclaiming warranty or limiting liability differently from the
408+ terms of sections 15 and 16 of this License; or
409+
410+ b) Requiring preservation of specified reasonable legal notices or
411+ author attributions in that material or in the Appropriate Legal
412+ Notices displayed by works containing it; or
413+
414+ c) Prohibiting misrepresentation of the origin of that material, or
415+ requiring that modified versions of such material be marked in
416+ reasonable ways as different from the original version; or
417+
418+ d) Limiting the use for publicity purposes of names of licensors or
419+ authors of the material; or
420+
421+ e) Declining to grant rights under trademark law for use of some
422+ trade names, trademarks, or service marks; or
423+
424+ f) Requiring indemnification of licensors and authors of that
425+ material by anyone who conveys the material (or modified versions of
426+ it) with contractual assumptions of liability to the recipient, for
427+ any liability that these contractual assumptions directly impose on
428+ those licensors and authors.
429+
430+ All other non-permissive additional terms are considered "further
431+restrictions" within the meaning of section 10. If the Program as you
432+received it, or any part of it, contains a notice stating that it is
433+governed by this License along with a term that is a further
434+restriction, you may remove that term. If a license document contains
435+a further restriction but permits relicensing or conveying under this
436+License, you may add to a covered work material governed by the terms
437+of that license document, provided that the further restriction does
438+not survive such relicensing or conveying.
439+
440+ If you add terms to a covered work in accord with this section, you
441+must place, in the relevant source files, a statement of the
442+additional terms that apply to those files, or a notice indicating
443+where to find the applicable terms.
444+
445+ Additional terms, permissive or non-permissive, may be stated in the
446+form of a separately written license, or stated as exceptions;
447+the above requirements apply either way.
448+
449+ 8. Termination.
450+
451+ You may not propagate or modify a covered work except as expressly
452+provided under this License. Any attempt otherwise to propagate or
453+modify it is void, and will automatically terminate your rights under
454+this License (including any patent licenses granted under the third
455+paragraph of section 11).
456+
457+ However, if you cease all violation of this License, then your
458+license from a particular copyright holder is reinstated (a)
459+provisionally, unless and until the copyright holder explicitly and
460+finally terminates your license, and (b) permanently, if the copyright
461+holder fails to notify you of the violation by some reasonable means
462+prior to 60 days after the cessation.
463+
464+ Moreover, your license from a particular copyright holder is
465+reinstated permanently if the copyright holder notifies you of the
466+violation by some reasonable means, this is the first time you have
467+received notice of violation of this License (for any work) from that
468+copyright holder, and you cure the violation prior to 30 days after
469+your receipt of the notice.
470+
471+ Termination of your rights under this section does not terminate the
472+licenses of parties who have received copies or rights from you under
473+this License. If your rights have been terminated and not permanently
474+reinstated, you do not qualify to receive new licenses for the same
475+material under section 10.
476+
477+ 9. Acceptance Not Required for Having Copies.
478+
479+ You are not required to accept this License in order to receive or
480+run a copy of the Program. Ancillary propagation of a covered work
481+occurring solely as a consequence of using peer-to-peer transmission
482+to receive a copy likewise does not require acceptance. However,
483+nothing other than this License grants you permission to propagate or
484+modify any covered work. These actions infringe copyright if you do
485+not accept this License. Therefore, by modifying or propagating a
486+covered work, you indicate your acceptance of this License to do so.
487+
488+ 10. Automatic Licensing of Downstream Recipients.
489+
490+ Each time you convey a covered work, the recipient automatically
491+receives a license from the original licensors, to run, modify and
492+propagate that work, subject to this License. You are not responsible
493+for enforcing compliance by third parties with this License.
494+
495+ An "entity transaction" is a transaction transferring control of an
496+organization, or substantially all assets of one, or subdividing an
497+organization, or merging organizations. If propagation of a covered
498+work results from an entity transaction, each party to that
499+transaction who receives a copy of the work also receives whatever
500+licenses to the work the party's predecessor in interest had or could
501+give under the previous paragraph, plus a right to possession of the
502+Corresponding Source of the work from the predecessor in interest, if
503+the predecessor has it or can get it with reasonable efforts.
504+
505+ You may not impose any further restrictions on the exercise of the
506+rights granted or affirmed under this License. For example, you may
507+not impose a license fee, royalty, or other charge for exercise of
508+rights granted under this License, and you may not initiate litigation
509+(including a cross-claim or counterclaim in a lawsuit) alleging that
510+any patent claim is infringed by making, using, selling, offering for
511+sale, or importing the Program or any portion of it.
512+
513+ 11. Patents.
514+
515+ A "contributor" is a copyright holder who authorizes use under this
516+License of the Program or a work on which the Program is based. The
517+work thus licensed is called the contributor's "contributor version".
518+
519+ A contributor's "essential patent claims" are all patent claims
520+owned or controlled by the contributor, whether already acquired or
521+hereafter acquired, that would be infringed by some manner, permitted
522+by this License, of making, using, or selling its contributor version,
523+but do not include claims that would be infringed only as a
524+consequence of further modification of the contributor version. For
525+purposes of this definition, "control" includes the right to grant
526+patent sublicenses in a manner consistent with the requirements of
527+this License.
528+
529+ Each contributor grants you a non-exclusive, worldwide, royalty-free
530+patent license under the contributor's essential patent claims, to
531+make, use, sell, offer for sale, import and otherwise run, modify and
532+propagate the contents of its contributor version.
533+
534+ In the following three paragraphs, a "patent license" is any express
535+agreement or commitment, however denominated, not to enforce a patent
536+(such as an express permission to practice a patent or covenant not to
537+sue for patent infringement). To "grant" such a patent license to a
538+party means to make such an agreement or commitment not to enforce a
539+patent against the party.
540+
541+ If you convey a covered work, knowingly relying on a patent license,
542+and the Corresponding Source of the work is not available for anyone
543+to copy, free of charge and under the terms of this License, through a
544+publicly available network server or other readily accessible means,
545+then you must either (1) cause the Corresponding Source to be so
546+available, or (2) arrange to deprive yourself of the benefit of the
547+patent license for this particular work, or (3) arrange, in a manner
548+consistent with the requirements of this License, to extend the patent
549+license to downstream recipients. "Knowingly relying" means you have
550+actual knowledge that, but for the patent license, your conveying the
551+covered work in a country, or your recipient's use of the covered work
552+in a country, would infringe one or more identifiable patents in that
553+country that you have reason to believe are valid.
554+
555+ If, pursuant to or in connection with a single transaction or
556+arrangement, you convey, or propagate by procuring conveyance of, a
557+covered work, and grant a patent license to some of the parties
558+receiving the covered work authorizing them to use, propagate, modify
559+or convey a specific copy of the covered work, then the patent license
560+you grant is automatically extended to all recipients of the covered
561+work and works based on it.
562+
563+ A patent license is "discriminatory" if it does not include within
564+the scope of its coverage, prohibits the exercise of, or is
565+conditioned on the non-exercise of one or more of the rights that are
566+specifically granted under this License. You may not convey a covered
567+work if you are a party to an arrangement with a third party that is
568+in the business of distributing software, under which you make payment
569+to the third party based on the extent of your activity of conveying
570+the work, and under which the third party grants, to any of the
571+parties who would receive the covered work from you, a discriminatory
572+patent license (a) in connection with copies of the covered work
573+conveyed by you (or copies made from those copies), or (b) primarily
574+for and in connection with specific products or compilations that
575+contain the covered work, unless you entered into that arrangement,
576+or that patent license was granted, prior to 28 March 2007.
577+
578+ Nothing in this License shall be construed as excluding or limiting
579+any implied license or other defenses to infringement that may
580+otherwise be available to you under applicable patent law.
581+
582+ 12. No Surrender of Others' Freedom.
583+
584+ If conditions are imposed on you (whether by court order, agreement or
585+otherwise) that contradict the conditions of this License, they do not
586+excuse you from the conditions of this License. If you cannot convey a
587+covered work so as to satisfy simultaneously your obligations under this
588+License and any other pertinent obligations, then as a consequence you may
589+not convey it at all. For example, if you agree to terms that obligate you
590+to collect a royalty for further conveying from those to whom you convey
591+the Program, the only way you could satisfy both those terms and this
592+License would be to refrain entirely from conveying the Program.
593+
594+ 13. Use with the GNU Affero General Public License.
595+
596+ Notwithstanding any other provision of this License, you have
597+permission to link or combine any covered work with a work licensed
598+under version 3 of the GNU Affero General Public License into a single
599+combined work, and to convey the resulting work. The terms of this
600+License will continue to apply to the part which is the covered work,
601+but the special requirements of the GNU Affero General Public License,
602+section 13, concerning interaction through a network will apply to the
603+combination as such.
604+
605+ 14. Revised Versions of this License.
606+
607+ The Free Software Foundation may publish revised and/or new versions of
608+the GNU General Public License from time to time. Such new versions will
609+be similar in spirit to the present version, but may differ in detail to
610+address new problems or concerns.
611+
612+ Each version is given a distinguishing version number. If the
613+Program specifies that a certain numbered version of the GNU General
614+Public License "or any later version" applies to it, you have the
615+option of following the terms and conditions either of that numbered
616+version or of any later version published by the Free Software
617+Foundation. If the Program does not specify a version number of the
618+GNU General Public License, you may choose any version ever published
619+by the Free Software Foundation.
620+
621+ If the Program specifies that a proxy can decide which future
622+versions of the GNU General Public License can be used, that proxy's
623+public statement of acceptance of a version permanently authorizes you
624+to choose that version for the Program.
625+
626+ Later license versions may give you additional or different
627+permissions. However, no additional obligations are imposed on any
628+author or copyright holder as a result of your choosing to follow a
629+later version.
630+
631+ 15. Disclaimer of Warranty.
632+
633+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
634+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
635+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
636+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
637+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
638+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
639+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
640+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
641+
642+ 16. Limitation of Liability.
643+
644+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
645+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
646+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
647+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
648+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
649+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
650+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
651+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
652+SUCH DAMAGES.
653+
654+ 17. Interpretation of Sections 15 and 16.
655+
656+ If the disclaimer of warranty and limitation of liability provided
657+above cannot be given local legal effect according to their terms,
658+reviewing courts shall apply local law that most closely approximates
659+an absolute waiver of all civil liability in connection with the
660+Program, unless a warranty or assumption of liability accompanies a
661+copy of the Program in return for a fee.
662+
663+ END OF TERMS AND CONDITIONS
664+
665+ How to Apply These Terms to Your New Programs
666+
667+ If you develop a new program, and you want it to be of the greatest
668+possible use to the public, the best way to achieve this is to make it
669+free software which everyone can redistribute and change under these terms.
670+
671+ To do so, attach the following notices to the program. It is safest
672+to attach them to the start of each source file to most effectively
673+state the exclusion of warranty; and each file should have at least
674+the "copyright" line and a pointer to where the full notice is found.
675+
676+ <one line to give the program's name and a brief idea of what it does.>
677+ Copyright (C) <year> <name of author>
678+
679+ This program is free software: you can redistribute it and/or modify
680+ it under the terms of the GNU General Public License as published by
681+ the Free Software Foundation, either version 3 of the License, or
682+ (at your option) any later version.
683+
684+ This program is distributed in the hope that it will be useful,
685+ but WITHOUT ANY WARRANTY; without even the implied warranty of
686+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
687+ GNU General Public License for more details.
688+
689+ You should have received a copy of the GNU General Public License
690+ along with this program. If not, see <http://www.gnu.org/licenses/>.
691+
692+Also add information on how to contact you by electronic and paper mail.
693+
694+ If the program does terminal interaction, make it output a short
695+notice like this when it starts in an interactive mode:
696+
697+ <program> Copyright (C) <year> <name of author>
698+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
699+ This is free software, and you are welcome to redistribute it
700+ under certain conditions; type `show c' for details.
701+
702+The hypothetical commands `show w' and `show c' should show the appropriate
703+parts of the General Public License. Of course, your program's commands
704+might be different; for a GUI interface, you would use an "about box".
705+
706+ You should also get your employer (if you work as a programmer) or school,
707+if any, to sign a "copyright disclaimer" for the program, if necessary.
708+For more information on this, and how to apply and follow the GNU GPL, see
709+<http://www.gnu.org/licenses/>.
710+
711+ The GNU General Public License does not permit incorporating your program
712+into proprietary programs. If your program is a subroutine library, you
713+may consider it more useful to permit linking proprietary applications with
714+the library. If this is what you want to do, use the GNU Lesser General
715+Public License instead of this License. But first, please read
716+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
717+
718
719=== renamed file 'LICENSE' => 'LICENSE.moved'
720=== added file '__init__.py'
721=== renamed file '__init__.py' => '__init__.py.moved'
722=== added directory 'debian'
723=== renamed directory 'debian' => 'debian.moved'
724=== added file 'debian/changelog'
725--- debian/changelog 1970-01-01 00:00:00 +0000
726+++ debian/changelog 2011-08-09 11:40:13 +0000
727@@ -0,0 +1,65 @@
728+quickly-widgets (11.03.1) natty; urgency=low
729+
730+ * New upstream release
731+ * debian/copyright:
732+ - Update to latest version of spec
733+ * debian/source/format:
734+ - Use '3.0 (native)'
735+
736+ -- Michael Terry <mterry@ubuntu.com> Thu, 03 Feb 2011 13:14:25 -0500
737+
738+quickly-widgets (11.03.0.1) natty; urgency=low
739+
740+ * debian/control:
741+ - Whoops, should have renamed the package to python-quickly.widgets,
742+ not python-quickly-widgets.
743+
744+ -- Michael Terry <mterry@ubuntu.com> Mon, 06 Dec 2010 15:24:15 -0500
745+
746+quickly-widgets (11.03) natty; urgency=low
747+
748+ * New upstream release
749+ * debian/control:
750+ - Rename to python-quickly-widgets (LP: #517179)
751+ - No-change update to Standards-Version 3.9.1
752+
753+ -- Michael Terry <mterry@ubuntu.com> Mon, 06 Dec 2010 14:55:52 -0500
754+
755+quickly-widgets (10.09) maverick; urgency=low
756+
757+ * New upstream release (LP: #637188)
758+
759+ -- Didier Roche <didrocks@ubuntu.com> Mon, 13 Sep 2010 15:52:56 +0200
760+
761+quickly-widgets (10.04.1) lucid; urgency=low
762+
763+ * New bugfix release (LP: #555935)
764+
765+ -- Didier Roche <didrocks@ubuntu.com> Tue, 06 Apr 2010 12:10:58 +0200
766+
767+quickly-widgets (10.04) lucid; urgency=low
768+
769+ * New bugfix release
770+ * debian/control:
771+ - depends on python-quickly-core (LP: #519633)
772+ - bump Standards-Version to 3.8.4
773+
774+ -- Didier Roche <didrocks@ubuntu.com> Fri, 02 Apr 2010 10:33:44 +0200
775+
776+quickly-widgets (10.02.2) lucid; urgency=low
777+
778+ * Add a dependency on quickly (LP: #517441)
779+
780+ -- Brian Murray <brian@ubuntu.com> Fri, 12 Feb 2010 15:52:09 -0800
781+
782+quickly-widgets (10.02.1) lucid; urgency=low
783+
784+ * Remove __init__.py file conflicting with Quickly
785+
786+ -- Didier Roche <didrocks@ubuntu.com> Wed, 03 Feb 2010 15:11:09 -0800
787+
788+quickly-widgets (10.02) lucid; urgency=low
789+
790+ * This is the initial release
791+
792+ -- Didier Roche <didrocks@ubuntu.com> Wed, 03 Feb 2010 11:27:01 -0800
793
794=== added file 'debian/compat'
795--- debian/compat 1970-01-01 00:00:00 +0000
796+++ debian/compat 2011-08-09 11:40:13 +0000
797@@ -0,0 +1,1 @@
798+6
799
800=== added file 'debian/control'
801--- debian/control 1970-01-01 00:00:00 +0000
802+++ debian/control 2011-08-09 11:40:13 +0000
803@@ -0,0 +1,36 @@
804+Source: quickly-widgets
805+Section: python
806+Priority: extra
807+Build-Depends: cdbs (>= 0.4.43),
808+ debhelper (>= 6),
809+ python,
810+ python-central (>= 0.6.11),
811+ python-distutils-extra (>= 2.10)
812+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
813+Standards-Version: 3.9.1
814+XS-Python-Version: current
815+
816+Package: python-quickly.widgets
817+Architecture: all
818+XB-Python-Version: ${python:Versions}
819+Depends: ${misc:Depends},
820+ ${python:Depends},
821+ python-quickly-core,
822+ python-gobject,
823+ python-testtools,
824+ python-pygame,
825+ python-gtk2
826+Provides: ${python:Provides}
827+Replaces: quickly-widgets (<< 11.03)
828+Conflicts: quickly-widgets (<< 11.03)
829+Description: Library for easing some PyGtk coding tasks
830+ Library for easing some PyGtk coding tasks. Note that this is experimental,
831+ the API will change, there are bugs.
832+
833+Package: quickly-widgets
834+Architecture: all
835+Section: oldlibs
836+Depends: ${misc:Depends}, python-quickly.widgets
837+Description: Transitional package for python-quickly.widgets
838+ This is a transitional package for python-quickly.widgets and can be safely
839+ removed after the installation is complete.
840
841=== added file 'debian/copyright'
842--- debian/copyright 1970-01-01 00:00:00 +0000
843+++ debian/copyright 2011-08-09 11:40:13 +0000
844@@ -0,0 +1,22 @@
845+Format: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=166
846+Upstream-Name: Quickly Widgets
847+Upstream-Contact: Rick Spencer <rick.spencer@canonical.com>
848+Source: https://code.launchpad.net/~quickly-committers/quidgets/trunk
849+
850+Files: *
851+Copyright: 2010,2011 Rick Spencer <rick.spencer@canonical.com>
852+License: GPL-3
853+ This program is free software: you can redistribute it and/or modify
854+ it under the terms of the GNU General Public License as published by
855+ the Free Software Foundation, version 3 of the License.
856+ .
857+ This program is distributed in the hope that it will be useful,
858+ but WITHOUT ANY WARRANTY; without even the implied warranty of
859+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
860+ GNU General Public License for more details.
861+ .
862+ You should have received a copy of the GNU General Public License
863+ along with this program. If not, see <http://www.gnu.org/licenses/>.
864+ .
865+ On Debian systems, the full text of the GNU General Public License
866+ version 3 can be found in the file /usr/share/common-licenses/GPL-3.
867
868=== added file 'debian/python-quickly.widgets.install'
869--- debian/python-quickly.widgets.install 1970-01-01 00:00:00 +0000
870+++ debian/python-quickly.widgets.install 2011-08-09 11:40:13 +0000
871@@ -0,0 +1,1 @@
872+debian/tmp/usr/lib/
873
874=== added file 'debian/rules'
875--- debian/rules 1970-01-01 00:00:00 +0000
876+++ debian/rules 2011-08-09 11:40:13 +0000
877@@ -0,0 +1,7 @@
878+#!/usr/bin/make -f
879+
880+DEB_PYTHON_SYSTEM := pycentral
881+
882+include /usr/share/cdbs/1/rules/debhelper.mk
883+include /usr/share/cdbs/1/class/python-distutils.mk
884+include /usr/share/cdbs/1/rules/langpack.mk
885
886=== added directory 'debian/source'
887=== added file 'debian/source/format'
888--- debian/source/format 1970-01-01 00:00:00 +0000
889+++ debian/source/format 2011-08-09 11:40:13 +0000
890@@ -0,0 +1,1 @@
891+3.0 (native)
892
893=== added directory 'po'
894=== renamed directory 'po' => 'po.moved'
895=== added file 'po/quickly-widgets.pot'
896--- po/quickly-widgets.pot 1970-01-01 00:00:00 +0000
897+++ po/quickly-widgets.pot 2011-08-09 11:40:13 +0000
898@@ -0,0 +1,182 @@
899+# SOME DESCRIPTIVE TITLE.
900+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
901+# This file is distributed under the same license as the PACKAGE package.
902+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
903+#
904+#, fuzzy
905+msgid ""
906+msgstr ""
907+"Project-Id-Version: PACKAGE VERSION\n"
908+"Report-Msgid-Bugs-To: \n"
909+"POT-Creation-Date: 2011-02-03 13:16-0500\n"
910+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
911+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
912+"Language-Team: LANGUAGE <LL@li.org>\n"
913+"Language: \n"
914+"MIME-Version: 1.0\n"
915+"Content-Type: text/plain; charset=CHARSET\n"
916+"Content-Transfer-Encoding: 8bit\n"
917+
918+#: ../quickly/widgets/grid_column.py:762
919+msgid "yes"
920+msgstr ""
921+
922+#: ../quickly/widgets/web_cam_box.py:123
923+msgid "Cannot display web cam output. Ignoring play command"
924+msgstr ""
925+
926+#: ../quickly/widgets/web_cam_box.py:159
927+msgid "/Pictures/"
928+msgstr ""
929+
930+#: ../quickly/widgets/media_player_box.py:169
931+msgid ""
932+"WARNING: MediaPlayerBox window not realized.\n"
933+" Will try to play anyway, but bad things could happen\n"
934+" if there is video to play"
935+msgstr ""
936+
937+#: ../quickly/widgets/url_fetch_progressbox.py:59
938+#, python-format
939+msgid "Downloading %s"
940+msgstr ""
941+
942+#: ../quickly/prompts/__init__.py:105 ../quickly/prompts/__init__.py:149
943+msgid "Input String"
944+msgstr ""
945+
946+#: ../quickly/prompts/__init__.py:105 ../quickly/prompts/__init__.py:149
947+msgid "Input a String:"
948+msgstr ""
949+
950+#: ../quickly/prompts/__init__.py:172 ../quickly/prompts/__init__.py:220
951+msgid "Choose Date"
952+msgstr ""
953+
954+#: ../quickly/prompts/__init__.py:172 ../quickly/prompts/__init__.py:220
955+msgid "Choose a Date:"
956+msgstr ""
957+
958+#: ../quickly/prompts/__init__.py:247 ../quickly/prompts/__init__.py:306
959+#: ../quickly/prompts/__init__.py:387
960+msgid "Enter Number"
961+msgstr ""
962+
963+#: ../quickly/prompts/__init__.py:247 ../quickly/prompts/__init__.py:306
964+#: ../quickly/prompts/__init__.py:387
965+msgid "Enter an Integer Value:"
966+msgstr ""
967+
968+#: ../quickly/prompts/__init__.py:324 ../quickly/prompts/__init__.py:433
969+#: ../quickly/prompts/__init__.py:494
970+msgid "Enter Price"
971+msgstr ""
972+
973+#: ../quickly/prompts/__init__.py:324 ../quickly/prompts/__init__.py:433
974+#: ../quickly/prompts/__init__.py:494
975+msgid "Choose a Price:"
976+msgstr ""
977+
978+#: ../quickly/prompts/__init__.py:525
979+msgid "Choose Yes or No"
980+msgstr ""
981+
982+#: ../quickly/prompts/__init__.py:576
983+msgid "Choose an option"
984+msgstr ""
985+
986+#: ../quickly/prompts/__init__.py:623
987+msgid "Warning"
988+msgstr ""
989+
990+#: ../quickly/prompts/__init__.py:642
991+msgid "Error"
992+msgstr ""
993+
994+#: ../quickly/prompts/__init__.py:662
995+msgid "Information"
996+msgstr ""
997+
998+#: ../quickly/prompts/__init__.py:726 ../quickly/prompts/__init__.py:871
999+msgid "Choose an Image"
1000+msgstr ""
1001+
1002+#: ../quickly/prompts/__init__.py:894
1003+msgid "Choose a Directory"
1004+msgstr ""
1005+
1006+#: ../quickly/widgets/asynch_task_progressbox.py:160
1007+msgid "Working"
1008+msgstr ""
1009+
1010+#: ../quickly/widgets/grid_filter.py:113
1011+msgid "M_atch All of the following"
1012+msgstr ""
1013+
1014+#: ../quickly/widgets/grid_filter.py:117
1015+msgid "Match any _of the following"
1016+msgstr ""
1017+
1018+#: ../quickly/widgets/grid_filter.py:403
1019+msgid "contains"
1020+msgstr ""
1021+
1022+#: ../quickly/widgets/grid_filter.py:404
1023+msgid "does not contain"
1024+msgstr ""
1025+
1026+#: ../quickly/widgets/grid_filter.py:405
1027+msgid "starts with"
1028+msgstr ""
1029+
1030+#: ../quickly/widgets/grid_filter.py:406
1031+msgid "ends with"
1032+msgstr ""
1033+
1034+#: ../quickly/widgets/grid_filter.py:440
1035+msgid "has any of these tags"
1036+msgstr ""
1037+
1038+#: ../quickly/widgets/grid_filter.py:441
1039+msgid "has all of these tags"
1040+msgstr ""
1041+
1042+#: ../quickly/widgets/grid_filter.py:442
1043+msgid "does not have one of these tags"
1044+msgstr ""
1045+
1046+#: ../quickly/widgets/grid_filter.py:443
1047+msgid "does not have any of these tags"
1048+msgstr ""
1049+
1050+#: ../quickly/widgets/grid_filter.py:630
1051+msgid "before"
1052+msgstr ""
1053+
1054+#: ../quickly/widgets/grid_filter.py:631
1055+msgid "on or before"
1056+msgstr ""
1057+
1058+#: ../quickly/widgets/grid_filter.py:632
1059+msgid "on"
1060+msgstr ""
1061+
1062+#: ../quickly/widgets/grid_filter.py:633
1063+msgid "on or after"
1064+msgstr ""
1065+
1066+#: ../quickly/widgets/grid_filter.py:634
1067+msgid "after"
1068+msgstr ""
1069+
1070+#: ../quickly/widgets/grid_filter.py:722
1071+msgid "checked"
1072+msgstr ""
1073+
1074+#: ../quickly/widgets/grid_filter.py:723
1075+msgid "not Checked"
1076+msgstr ""
1077+
1078+#: ../quickly/widgets/grid_filter.py:724
1079+msgid "unset"
1080+msgstr ""
1081
1082=== added directory 'quickly'
1083=== renamed directory 'quickly' => 'quickly.moved'
1084=== added directory 'quickly/prompts'
1085=== added file 'quickly/prompts/__init__.py'
1086--- quickly/prompts/__init__.py 1970-01-01 00:00:00 +0000
1087+++ quickly/prompts/__init__.py 2011-08-09 11:40:13 +0000
1088@@ -0,0 +1,1024 @@
1089+### BEGIN LICENSE
1090+# Copyright (C) 2010 Rick Spencer rick.spencer@canonical.com
1091+#This program is free software: you can redistribute it and/or modify it
1092+#under the terms of the GNU General Public License version 3, as published
1093+#by the Free Software Foundation.
1094+#
1095+#This program is distributed in the hope that it will be useful, but
1096+#WITHOUT ANY WARRANTY; without even the implied warranties of
1097+#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1098+#PURPOSE. See the GNU General Public License for more details.
1099+#
1100+#You should have received a copy of the GNU General Public License along
1101+#with this program. If not, see <http://www.gnu.org/licenses/>.
1102+### END LICENSE
1103+
1104+import gtk
1105+import gobject
1106+import os
1107+import glib
1108+import gettext
1109+from gettext import gettext as _
1110+gettext.textdomain('quickly-widgets')
1111+
1112+#TODO: stop using **kwargs and go back to named arguments so you can pass them from the function to the class
1113+
1114+class Prompt(gtk.Dialog):
1115+ """A base class for some quickly.prompts - creates Ok and Cancel buttons,
1116+ displays a title and a label.
1117+
1118+ qiuckly.prompts.Prompt is intended for receiving information back
1119+ from users. If you only want to display a message, use a
1120+ quickly.prompts.Alert.
1121+
1122+ Useful subclasses and helper functions are provided:
1123+ quickly.prompts.string() uses quickly.prompts.StringPrompt
1124+ quickly.prompts.date() uses quickly.prompts.DatePrompt
1125+ quickly.prompts.integer() uses quickly.prompts.IntegerPrompt
1126+ quickly.prompts.decimal() uses quickly.prompts.DecimalPrompt
1127+ quickly.prompts.price() uses quickly.prompts.PricePrompt
1128+
1129+ Using
1130+ A quickly.prompts.prompt object is not intended to be used without
1131+ configuring or extending it. Otherwise, it will only display a
1132+ blank dialog with OK and Cancel buttons and a label.
1133+
1134+ Configuring
1135+ #add some widgets to the prompt using the
1136+ #the prompt's content_box member (which is a gtk.VBox)
1137+ #These widgets will appear below the label
1138+ #StringPrompt works similar to this:
1139+ p = quickly.prompts.Prompt(title,text)
1140+ entry = gtk.Entry()
1141+ entry.set_text(default_value)
1142+ entry.set_activates_default(True)
1143+ entry.show()
1144+ p.content_box.pack_end(entry, True, True, 5)
1145+ response = p.run()
1146+ if response = gtk.RESPONSE_OK:
1147+ my_string = entry.get_text()
1148+
1149+ #A Prompt is a gtk.Dialog, so you can use gtk.DialogMembers
1150+ action_area = p.get_action_area()
1151+
1152+ Extending
1153+ #Typically you will add widgets to a prompt and override the
1154+ #get_value function to return the appropriate value entered by the user.
1155+ #String prompt is implemented as follows:
1156+ class StringPrompt(Prompt):
1157+ def __init__(self, title = "Input String",
1158+ text = "Input a String:", default_value = ""):
1159+ Prompt.__init__(self, title, text)
1160+ self._entry = gtk.Entry()
1161+ self._entry.set_text(default_value)
1162+ self._entry.set_activates_default(True)
1163+ self._entry.show()
1164+ self.content_box.pack_end(self._entry, True, True, 5)
1165+
1166+ def get_value(self):
1167+ return self._entry.get_text()
1168+
1169+ """
1170+
1171+ def __init__(self, title, text):
1172+ """Creates a Prompt
1173+ arguments:
1174+ title - The title for the dialog window
1175+ text - The string to display in the Prompts label
1176+
1177+ """
1178+
1179+ gtk.Dialog.__init__(self, title, None, gtk.DIALOG_MODAL,(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK))
1180+ self.set_has_separator(False)
1181+ content_area = self.get_content_area()
1182+ content_area.set_border_width(5)
1183+ self.set_default_response(gtk.RESPONSE_OK)
1184+
1185+ self.content_box = gtk.VBox(False, 10)
1186+ label = gtk.Label(text)
1187+ label.set_line_wrap(True)
1188+ self.content_box.pack_start(label,False, False, 5)
1189+ content_area.pack_start(self.content_box)
1190+ self.content_box.show()
1191+ label.show()
1192+
1193+def string(title = _("Input String"), text = _("Input a String:"), default_value = ""):
1194+ """string - prompts to enter a string via a dialog box.
1195+
1196+ aguments:
1197+ title - a string to be the title of the dialog
1198+ text - a string to provide a prompt for the user within dialog
1199+ default_value - a string to see the entry in the dialog box
1200+
1201+ returns a tuple of (gtk.DialogResponse, string value)
1202+ gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise
1203+ the user cancelled (gtk.RESPONSE_CANCEL) or dismissed the dialog
1204+ (gtk.RESPONSE_DELETE_EVENT)
1205+
1206+ """
1207+
1208+ sp = StringPrompt(title, text, default_value)
1209+ response = sp.run()
1210+ val = sp.get_value()
1211+ sp.destroy()
1212+ return (response, val)
1213+
1214+class StringPrompt(Prompt):
1215+ """A class for receiving a string from a user
1216+
1217+ Using
1218+ #Collect a string from the user by using the
1219+ #quickly.prompts.string() helper function
1220+ reponse, val = string("String select test","String select test")
1221+ if response == gtk.RESPONSE_OK:
1222+ my_string = val
1223+
1224+ Configuring
1225+ #Add widgets to the conent_box member
1226+ sp = StringPrompt(title, text, default_string)
1227+ sp.content_box.pack_end(my_additional_widget)
1228+
1229+ #Modify the _entry member
1230+ sp._entry.set_max_length(144)
1231+
1232+ Extending
1233+ A StringPrompt is a Prompt which is gtk.Dialog
1234+
1235+ """
1236+
1237+ def __init__(self, title = _("Input String"), text = _("Input a String:"), default_value = ""):
1238+ """Create a StringPrompt
1239+ arguments:
1240+ title - a string to be the title of the dialog
1241+ text - a string to provide a prompt for the user within dialog
1242+ default_value - a string to see the entry in the dialog box
1243+
1244+ """
1245+
1246+ Prompt.__init__(self, title, text)
1247+ self._entry = gtk.Entry()
1248+ self._entry.set_text(default_value)
1249+ self._entry.set_activates_default(True)
1250+ self._entry.show()
1251+ self.content_box.pack_end(self._entry, True, True, 5)
1252+
1253+ def get_value(self):
1254+ """get_value - returns the value the user has entered into the gtk.Entry
1255+
1256+ """
1257+
1258+ return self._entry.get_text()
1259+
1260+def date(title = _("Choose Date"), text = _("Choose a Date:"), default_value = None):
1261+ """date - prompts to enter a date using a calendar via a dialog box.
1262+
1263+ aguments:
1264+ title - a string to be the title of the dialog
1265+ text - a string to provide a prompt for the user within dialog
1266+ default_value - a tuple in the form of integers for (year,month,day)
1267+ where month is zero indexed (Jaunary is 0, December is 11)
1268+
1269+ returns a tuple of (gtk.DialogResponse, tuple)
1270+ The returnd tuple is in the form of integers for (year,month,day)
1271+ where month is zero indexed (Jaunary is 0, December is 11)
1272+
1273+ gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise
1274+ the user cancelled (gtk.RESPONSE_CANCEL) or dismissed the dialog
1275+ (gtk.RESPONSE_DELETE_EVENT)
1276+
1277+ """
1278+ dp = DatePrompt(title, text, default_value)
1279+
1280+ response = dp.run()
1281+ val = dp.get_value()
1282+ dp.destroy()
1283+ return (response, val)
1284+
1285+class DatePrompt(Prompt):
1286+ """A class for receiving a date from a user
1287+
1288+ Using
1289+ #Collect a date from the user by using the
1290+ #quickly.prompts.date() helper function
1291+ reponse, val = date("Date prompt title","Date prompt message")
1292+ if response == gtk.RESPONSE_OK:
1293+ my_date = val
1294+
1295+ Configuring
1296+ #Add widgets to the content_box member
1297+ dp = DatePrompt(title, text, default_integer)
1298+ dp.content_box.pack_end(my_additional_widget)
1299+
1300+ #Modify the _calendar member
1301+ dp._calendar.set_display_options(gtk.CALENDAR_SHOW_DAY_NAMES)
1302+
1303+ Extending
1304+ A DatePrompt is a Prompt which is a gtk.Dialog.
1305+
1306+ """
1307+
1308+ def __init__(self, title = _("Choose Date"), text = _("Choose a Date:"), default_value = None):
1309+ """Creates a DatePrompt
1310+ title - a string to be the title of the dialog
1311+ text - a string to provide a prompt for the user within dialog
1312+ default_value - a tuple in the form of integers for (year,month,day)
1313+ where month is zero indexed (Jaunary is 0, December is 11)
1314+
1315+ """
1316+ Prompt.__init__(self, title, text)
1317+ self._calendar = gtk.Calendar()
1318+ self._calendar.show()
1319+ self.content_box.pack_end(self._calendar, True, True, 5)
1320+
1321+ if default_value is not None and len(default_value) is 3:
1322+ year, month, day = default_value
1323+ self._calendar.select_month(month, year)
1324+ self._calendar.select_day(day)
1325+
1326+ def get_value(self):
1327+ """get_value - return the date currently set in the _calendar member
1328+ A tuple is in the form of integers for (year,month,day)
1329+ where month is zero indexed (Jaunary is 0, December is 11)
1330+
1331+ """
1332+
1333+ return self._calendar.get_date()
1334+
1335+def integer(title = _("Enter Number"), text = _("Enter an Integer Value:"),
1336+ default_value=0, min_value = -1000000000, max_value=1000000000,
1337+ step = 1):
1338+ """integer - prompts to enter an integer using a spinner via a dialog box.
1339+
1340+ arguments:
1341+ title - a string to be the title of the dialog
1342+ text - a string to provide a prompt for the user within dialog
1343+ default_value - an integer to display by default, should be greater than
1344+
1345+ keyword arguments:
1346+ the min_value and less then the max_value
1347+ min_value - the lowest number accepted by the spinner,
1348+ defaults to -1000000000
1349+ step - set the incriments for each click of the spinner buttons,
1350+ defaults to 1
1351+ max_value, the highest number accepted by the spinner,
1352+ defaults to 1000000000
1353+
1354+ returns a tuple of (gtk.DialogResponse, integer)
1355+
1356+ gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise
1357+ the user cancelled (gtk.RESPONSE_CANCEL) or dismissed the dialog
1358+ (gtk.RESPONSE_DELETE_EVENT)
1359+
1360+ """
1361+
1362+ ip = IntegerPrompt(title,text,default_value, min_value, max_value, step)
1363+ response = ip.run()
1364+ val = ip.get_value()
1365+ ip.destroy()
1366+ return (response, val)
1367+
1368+
1369+class IntegerPrompt(Prompt):
1370+ """A Prompt for collecting an integer number value from user. Uses
1371+ a gtk.Spinner for data entry.
1372+
1373+
1374+ Using
1375+ #Collect an integer value from the user by using the
1376+ #quickly.prompts.integer() helper function
1377+ reponse, val = integer("Integer prompt title","Integer prompt message")
1378+ if response == gtk.RESPONSE_OK:
1379+ my_date = val
1380+
1381+ Configuring
1382+ #Add widgets to the content_box member
1383+ dp = IntegerPrompt(title, text, default_date)
1384+ dp.content_box.pack_end(my_additional_widget)
1385+
1386+ #Modify the _spinner member
1387+ dp._spinner.set_value(20)
1388+
1389+ Extending
1390+ An IntegerPrompt is a Prompt which is a gtk.Dialog
1391+
1392+ """
1393+
1394+ def __init__(self, title=_("Enter Number"), text=_("Enter an Integer Value:"),
1395+ default_value=0, min_value = -1000000000, max_value=1000000000,
1396+ step = 1):
1397+ """Creates an Integer Prompt
1398+
1399+ """
1400+
1401+ Prompt.__init__(self, title, text)
1402+ adj = gtk.Adjustment(default_value,min_value,max_value,step)
1403+ self._spinner = gtk.SpinButton(adj,1,0)
1404+ self._spinner.set_activates_default(True)
1405+ self._spinner.show()
1406+ self._spinner.set_numeric(True)
1407+ self.content_box.pack_end(self._spinner, True, True, 5)
1408+
1409+ def get_value(self):
1410+ return self._spinner.get_value_as_int()
1411+
1412+def decimal(title=_("Enter Price"), text=_("Choose a Price:"),
1413+ default_value=0, min_value=-1000000000, max_value=1000000000,
1414+ step=1,digits=20):
1415+ """decimal - prompts to enter a number that inlcudes
1416+ decimal places using a spinner via a dialog box.
1417+
1418+ aguments:
1419+ title - a string to be the title of the dialog
1420+ text - a string to provide a prompt for the user within dialog
1421+
1422+ keyword arguments:
1423+ default_value - an integer to display by default, should be greater than
1424+ the min_value and less then the max_value
1425+ min_value - the lowest number accepted by the spinner,
1426+ defaults to -1000000000
1427+ step - set the incriments for each click of the spinner buttons,
1428+ defaults to 1
1429+ max_value, the highest number accepted by the spinner,
1430+ defaults to 1000000000
1431+ digits - the number of decimal places to include, defaults to 20
1432+ supports a maximum of 20 decimal places. Values great than 20 will
1433+ be converted to 20, and values less than 0 will be converted to 0
1434+
1435+ returns a tuple of (gtk.DialogResponse, number)
1436+
1437+ gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise
1438+ the user cancelled (gtk.RESPONSE_CANCEL) or dismissed the dialog
1439+ (gtk.RESPONSE_DELETE_EVENT)
1440+
1441+ """
1442+
1443+ dp = DecimalPrompt(title, text, default_value, min_value, max_value,
1444+ step, digits)
1445+ response = dp.run()
1446+ val = dp.get_value()
1447+ dp.destroy()
1448+ return (response, val)
1449+
1450+class DecimalPrompt(Prompt):
1451+ """A Prompt for collecting a decimal number value from user. Uses
1452+ a gtk.Spinner for data entry.
1453+
1454+ Using
1455+ #Collect a number from the user by using the
1456+ #quickly.prompts.decimal() helper function
1457+ reponse, val = decimal("Decimal prompt title","Decimal prompt message")
1458+ if response == gtk.RESPONSE_OK:
1459+ my_date = val
1460+
1461+ Configuring
1462+ #Add widgets to the content_box member
1463+ dp = DecimalPrompt(title, text, default_number)
1464+ dp.content_box.pack_end(my_additional_widget)
1465+
1466+ #Modify the _spinner member
1467+ dp._spinner.set_value(20.0)
1468+
1469+ Extending
1470+ An DecimalPrompt is a Prompt which is a gtk.Dialog
1471+
1472+
1473+ """
1474+
1475+ def __init__(self, title=_("Enter Number"), text=_("Enter an Integer Value:"),
1476+ default_value=0, min_value=-1000000000, max_value=1000000000,
1477+ step=1, digits=20):
1478+ """Creates a DecimalPrompt
1479+ arguments:
1480+ title - a string to be the title of the dialog
1481+ text - a string to provide a prompt for the user within dialog
1482+ default_value - an integer to display by default, should be greater than
1483+
1484+ keyword arguments:
1485+ default_value - an integer to display by default, should be greater than
1486+ the min_value and less then the max_value
1487+ min_value - the lowest number accepted by the spinner,
1488+ defaults to -1000000000
1489+ step - set the incriments for each click of the spinner buttons,
1490+ defaults to 1
1491+ max_value, the highest number accepted by the spinner,
1492+ defaults to 1000000000
1493+ digits - the number of decimal places to include, defaults to 20
1494+ supports a maximum of 20 decimal places. Values great than 20 will
1495+ be converted to 20, and values less than 0 will be converted to 0
1496+
1497+ returns a tuple of (gtk.DialogResponse, number)
1498+
1499+ gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise
1500+ the user cancelled (gtk.RESPONSE_CANCEL) or dismissed the dialog
1501+ (gtk.RESPONSE_DELETE_EVENT)
1502+
1503+ """
1504+
1505+ Prompt.__init__(self, title, text)
1506+
1507+ self._adjustment = gtk.Adjustment(default_value,min_value,max_value,step)
1508+ if digits > 20:
1509+ digits = 20
1510+ if digits < 0:
1511+ digits = 0
1512+ self._spinner = gtk.SpinButton(self._adjustment,1,digits)
1513+ self._spinner.set_activates_default(True)
1514+ self._spinner.show()
1515+ self._spinner.set_numeric(True)
1516+ self.content_box.pack_end(self._spinner, True, True, 5)
1517+
1518+ def get_value(self):
1519+ return self._spinner.get_value()
1520+
1521+def price(title=_("Enter Price"), text=_("Choose a Price:"),
1522+ default_value=0, min_value=-1000000000, max_value=1000000000,
1523+ step=1):
1524+ """price - prompts to enter a number up to the
1525+ hundreths place using a spinner via a dialog box.
1526+
1527+ aguments:
1528+ title - a string to be the title of the dialog
1529+ text - a string to provide a prompt for the user within dialog
1530+ default_value - an integer to display by default, should be greater than
1531+
1532+ keyword arguments:
1533+ the min_value and less then the max_value
1534+ min_value - the lowest number accepted by the spinner,
1535+ defaults to -1000000000
1536+ max_value, the highest number accepted by the spinner,
1537+ defaults to 1000000000
1538+ step - set the incriments for each click of the spinner buttons,
1539+ defaults to 1
1540+
1541+ returns a tuple of (gtk.DialogResponse, number)
1542+
1543+ gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise
1544+ the user cancelled (gtk.RESPONSE_CANCEL) or dismissed the dialog
1545+ (gtk.RESPONSE_DELETE_EVENT)
1546+
1547+ """
1548+
1549+ pp = PricePrompt(title, text, default_value, min_value, max_value,
1550+ step)
1551+ response = pp.run()
1552+ val = pp.get_value()
1553+ pp.destroy()
1554+ return (response, val)
1555+
1556+class PricePrompt(DecimalPrompt):
1557+ """A Prompt for collecting a decimal number value from the user,
1558+ formatted with two decimal places appropriate for entering
1559+ a currence ammount. Uses a gtk.Spinner for data entry.
1560+
1561+ Using
1562+ #Collect a number from the user by using the
1563+ #quickly.prompts.price() helper function
1564+ reponse, val = price("Price prompt title","Price prompt message")
1565+ if response == gtk.RESPONSE_OK:
1566+ my_date = val
1567+
1568+ Configuring
1569+ #Add widgets to the content_box member
1570+ pp = PricePrompt(title, text, default_number)
1571+ pp.content_box.pack_end(my_additional_widget)
1572+
1573+ #Modify the _spinner member
1574+ pp._spinner.set_value(20.00)
1575+
1576+ Extending
1577+ An PricePrompt is Decimal Prompt which is a Prompt which is a gtk.Dialog
1578+
1579+
1580+ """
1581+
1582+ def __init__(self, title=_("Enter Price"), text=_("Choose a Price:"),
1583+ default_value=0, min_value=-1000000000, max_value=1000000000,
1584+ step=1):
1585+ """Creates a DecimalPrompt
1586+ arguments:
1587+ title - a string to be the title of the dialog
1588+ text - a string to provide a prompt for the user within dialog
1589+ default_value - an integer to display by default, should be greater than
1590+
1591+ keywrod arguments:
1592+ keyword arguments:
1593+ the min_value and less then the max_value
1594+ min_value - the lowest number accepted by the spinner,
1595+ defaults to -1000000000
1596+ max_value, the highest number accepted by the spinner,
1597+ defaults to 1000000000
1598+ step - set the incriments for each click of the spinner buttons,
1599+ defaults to 1
1600+
1601+ returns a tuple of (gtk.DialogResponse, number)
1602+
1603+ gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise
1604+ the user cancelled (gtk.RESPONSE_CANCEL) or dismissed the dialog
1605+ (gtk.RESPONSE_DELETE_EVENT)
1606+
1607+ """
1608+
1609+ DecimalPrompt.__init__(self,title,text,default_value,min_value,
1610+ max_value, step)
1611+ self._spinner.set_digits(2)
1612+
1613+def yes_no(title = _("Choose Yes or No"), text = "", yes="", no=""):
1614+ """yes_no - prompts the user to choose between two options,
1615+ one "yes" and one "no", though typically the button labels
1616+ should be set as verbs.
1617+
1618+ aguments:
1619+ title - a string to be the title of the dialog
1620+ text - a string, typically a question, prompting the
1621+ user to choose Yes or No
1622+ yes - a string that is a verb representing the Yes action
1623+ no - a string that is a verb representing the No action
1624+
1625+ returns a gtk.DialogResponse
1626+ gtk.RESPONSE_YES means the user clicked the "YES" button, otherwise
1627+ gtk.RESPONSE_NO means the user clicked the "NO" button, otherwise
1628+ the user dismissed the dialogv(gtk.RESPONSE_DELETE_EVENT)
1629+
1630+ """
1631+ yn = YesNoPrompt(title,text,yes,no)
1632+ response = yn.run()
1633+ yn.destroy()
1634+ return response
1635+
1636+class YesNoPrompt(gtk.Dialog):
1637+ """A prompt to collect a user choice between two options,
1638+ one "yes" and one "no", though typically the button labels
1639+ should be set as verbs.
1640+
1641+ Using
1642+ #Collect a response from the user using the
1643+ #quickly.prompts.yes_no() helper function
1644+ reponse = decimal(title,message,"Do it", "Don't do it")
1645+ if response == gtk.RESPONSE_YES:
1646+ yes = True
1647+ else:
1648+ yes = False
1649+
1650+ Configuring
1651+ #Add widgets to the content_box member
1652+ dp = DecimalPrompt(title, text, default_number)
1653+ dp.content_box.pack_end(my_additional_widget)
1654+
1655+ #add a widget to the response by creating it and
1656+ #passing it in with a Gtk.RESPONSE_ID
1657+ dp.add_action_widget(new_widget, response_id)
1658+
1659+ Extending
1660+ An YesNoPrompt is a gtk.Dialog
1661+
1662+ """
1663+
1664+ def __init__(self, title=_("Choose an option"),text="",yes="",no=""):
1665+ """creaets a YesNoPrompt.
1666+
1667+ aguments:
1668+ title - a string to be the title of the dialog
1669+ text - a string, typically a question, prompting the
1670+ user to choose Yes or No
1671+ yes - a string that is a verb representing the Yes action
1672+ no - a string that is a verb representing the No action
1673+
1674+ """
1675+
1676+ gtk.Dialog.__init__(self, title, None, gtk.DIALOG_MODAL)
1677+
1678+ if no == "":
1679+ no_button = gtk.Button(stock=gtk.STOCK_NO)
1680+ else:
1681+ no_button = gtk.Button(label=no)
1682+ self.add_action_widget(no_button,gtk.RESPONSE_NO)
1683+ no_button.show()
1684+
1685+ if yes == "":
1686+ yes_button = gtk.Button(stock=gtk.STOCK_YES)
1687+ else:
1688+ yes_button = gtk.Button(label=yes)
1689+ self.add_action_widget(yes_button,gtk.RESPONSE_YES)
1690+ yes_button.show()
1691+ yes_button.set_flags(gtk.CAN_DEFAULT)
1692+
1693+
1694+ self.set_has_separator(False)
1695+ content_area = self.get_content_area()
1696+ content_area.set_border_width(5)
1697+ self.set_default_response(gtk.RESPONSE_YES)
1698+
1699+ self.content_box = gtk.HBox(False, 10)
1700+ img = gtk.Image()
1701+ img.set_from_stock(gtk.STOCK_DIALOG_QUESTION,gtk.ICON_SIZE_DIALOG)
1702+ self.content_box.pack_start(img)
1703+ label = gtk.Label(text)
1704+ label.set_line_wrap(True)
1705+ self.content_box.pack_start(label,False, False, 5)
1706+ content_area.pack_start(self.content_box)
1707+ self.content_box.show()
1708+ label.show()
1709+ img.show()
1710+
1711+def warning(title = _("Warning"), text = ""):
1712+ """warning - displays a warning to the user, includes an appropriate icon
1713+ and an OK button
1714+
1715+ aguments:
1716+ title - a string to be the title of the dialog
1717+ text - a string describing the warning
1718+
1719+ returns a gtk.DialogResponse
1720+ gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise
1721+ the user dismissed the dialogv(gtk.RESPONSE_DELETE_EVENT)
1722+
1723+ """
1724+
1725+ w = Alert(title,text,gtk.STOCK_DIALOG_WARNING)
1726+ response = w.run()
1727+ w.destroy()
1728+ return response
1729+
1730+def error(title = _("Error"), text = ""):
1731+ """error - displays an error to the user, includes an appropriate icon
1732+ and an OK button
1733+
1734+ aguments:
1735+ title - a string to be the title of the dialog
1736+ text - a string describing the error
1737+
1738+ returns a gtk.DialogResponse
1739+ gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise
1740+ the user dismissed the dialogv(gtk.RESPONSE_DELETE_EVENT)
1741+
1742+ """
1743+
1744+ e = Alert(title,text,gtk.STOCK_DIALOG_ERROR)
1745+ response = e.run()
1746+ e.destroy()
1747+ return response
1748+
1749+
1750+def info(title = _("Information"), text = ""):
1751+ """info - displays information to the user, includes an appropriate
1752+ icon and an OK button
1753+
1754+ aguments:
1755+ title - a string to be the title of the dialog
1756+ text - a string providing the information
1757+
1758+ returns a gtk.DialogResponse
1759+ gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise
1760+ the user dismissed the dialogv(gtk.RESPONSE_DELETE_EVENT)
1761+
1762+ """
1763+
1764+ i = Alert(title,text,gtk.STOCK_DIALOG_INFO)
1765+ response = i.run()
1766+ i.destroy()
1767+ return response
1768+
1769+class Alert(gtk.Dialog):
1770+ """Displays an icon, a message, and an OK button to users.
1771+ Used by quickly.prompts.info(), quickly.prompts.warning(),
1772+ and quickly.prompts.error().
1773+
1774+ Using
1775+ #Display a message to the user using one of the helper functions
1776+ quickly.prompts.info(title,useful_message)
1777+
1778+ Configuring
1779+ #Add widgets to the content_box member
1780+ alert = Alert(title, text, image)
1781+ alert.content_box.pack_end(my_additional_widget)
1782+
1783+ #change the image by passing in a stock gtk image
1784+ alert.set_image(stock_image)
1785+
1786+ Extending
1787+ An Alert is a gtk.Dialog.
1788+
1789+ """
1790+
1791+ def __init__(self,title="",text="",image=None):
1792+ gtk.Dialog.__init__(self, title,None,gtk.DIALOG_MODAL,(gtk.STOCK_OK, gtk.RESPONSE_OK))
1793+ self.set_has_separator(False)
1794+ content_area = self.get_content_area()
1795+ content_area.set_border_width(5)
1796+ self.set_default_response(gtk.RESPONSE_OK)
1797+
1798+ self.content_box = gtk.HBox(False, 10)
1799+ label = gtk.Label(text)
1800+ label.set_line_wrap(True)
1801+ self._image = gtk.Image()
1802+ self._image.set_from_stock(image,gtk.ICON_SIZE_DIALOG)
1803+ self.content_box.pack_start(self._image, False, False, 5)
1804+ self.content_box.pack_end(label,False, False, 5)
1805+ content_area.pack_start(self.content_box)
1806+ self.content_box.show()
1807+ label.show()
1808+ self._image.show()
1809+
1810+ def set_image(self, image):
1811+ self._image.set_from_stock(image,gtk.ICON_SIZE_DIALOG)
1812+
1813+
1814+def save_image_file(title=_("Choose an Image"),path=None):
1815+ """save_image_file - prompts the user to choose an image file
1816+
1817+ aguments:
1818+ title - a string to be the title of the dialog
1819+ path - a string providing a path to a directory where the
1820+ dialog should start. Defaults to Pictures directory.
1821+
1822+ returns a gtk.DialogResponse
1823+ gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise
1824+ the user clicked "Cancel" or the userdismissed the
1825+ dialogv(gtk.RESPONSE_DELETE_EVENT)
1826+
1827+ """
1828+
1829+ sid = SaveImageDialog(title,path)
1830+ response = sid.run()
1831+ value = sid.get_filename()
1832+ sid.destroy()
1833+ return (response, value)
1834+
1835+
1836+class ImageDialog(gtk.FileChooserDialog):
1837+ """A base class for OpenImageDialog and SaveImageDialog
1838+
1839+ Sets up typical mime types and file name patterns suitable
1840+ for saving images.
1841+
1842+ This class is not typically used configured or extended directly,
1843+ but rather through OpenImageDialog and SaveImageDialog.
1844+
1845+ """
1846+
1847+
1848+ def __init__(self, action, button, title="", path=None):
1849+ """Create an ImageDialog.
1850+
1851+ arguments:
1852+ action - a file chooser action, either gtk.FILE_CHOOSER_ACTION_SAVE
1853+ or gtk.FILE_CHOOSER_ACTION_OPEN
1854+ button - a gtk stock button for the intended action, either
1855+ gtk.STOCK_SAVE or gtk.STOCK_OPEN
1856+
1857+ keyword arguments:
1858+ title - a title for the dialog, defaults to an empty string
1859+ path - a directory path to initially open to, defaults to
1860+ ~/Pictures
1861+
1862+ """
1863+
1864+ gtk.FileChooserDialog.__init__(self,title,
1865+ None,
1866+ action,
1867+ (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
1868+ button, gtk.RESPONSE_OK))
1869+
1870+ self.set_default_response(gtk.RESPONSE_OK)
1871+
1872+ if path == None:
1873+ path = glib.get_user_special_dir(glib.USER_DIRECTORY_PICTURES)
1874+ self.set_current_folder(path)
1875+
1876+ self._filter = gtk.FileFilter()
1877+ self._filter.set_name("All files")
1878+ self._filter.add_pattern("*")
1879+ self.add_filter(self._filter)
1880+
1881+ self._filter = gtk.FileFilter()
1882+ self._filter.set_name("Images")
1883+ self._filter.add_mime_type("image/png")
1884+ self._filter.add_mime_type("image/jpeg")
1885+ self._filter.add_mime_type("image/gif")
1886+ self._filter.add_pattern("*.png")
1887+ self._filter.add_pattern("*.jpg")
1888+ self._filter.add_pattern("*.gif")
1889+ self._filter.add_pattern("*.tif")
1890+ self._filter.add_pattern("*.xpm")
1891+ self.add_filter(self._filter)
1892+ self.set_do_overwrite_confirmation(True)
1893+
1894+class SaveImageDialog(ImageDialog):
1895+ """
1896+ A dialog to prompt the user for a place to save an image file.
1897+
1898+ Using
1899+ #Collect a location using the quickly.prompts.save_image_file()
1900+ #helper function
1901+ response, path = save_image_file(title)
1902+ if response == gtk.RESPONSE_OK:
1903+ save_to_path = path
1904+
1905+ Configuring
1906+ #Modify the _filter member
1907+ sid._filter.add_mime_type("image/svg")
1908+ sid._filter.add_pattern("*.svg")
1909+
1910+ Extending
1911+ A SaveImageDialog is an ImageDialog which is a gtk.FileChooserDialog
1912+
1913+ """
1914+
1915+ def __init__(self, title="Choose File Location", path=None):
1916+ """Create a SaveImageDialog.
1917+
1918+ keyword arguments:
1919+ title - a title for the dialog, defaults to an empty string
1920+ path - a directory path to initially open to, defaults to
1921+ ~/Pictures
1922+
1923+ """
1924+
1925+ ImageDialog.__init__(self,gtk.FILE_CHOOSER_ACTION_SAVE, gtk.STOCK_SAVE, title,path)
1926+
1927+class OpenImageDialog(ImageDialog):
1928+ """
1929+ A dialog to prompt the user for an image to open
1930+
1931+ Using
1932+ #Collect a location using the quickly.prompts.open_image_file()
1933+ #helper function
1934+ response, path = open_image_file(title)
1935+ if response == gtk.RESPONSE_OK:
1936+ path_to_image = path
1937+
1938+ Configuring
1939+ #Modify the _filter member
1940+ sid._filter.add_mime_type("image/svg")
1941+ sid._filter.add_pattern("*.svg")
1942+
1943+ Extending
1944+ A SaveImageDialog is an ImageDialog which is a gtk.FileChooserDialog
1945+
1946+ """
1947+
1948+ def __init__(self, title="Choose File Location", path=None):
1949+ """Create an OpenImageDialog.
1950+
1951+ keyword arguments:
1952+ title - a title for the dialog, defaults to an empty string
1953+ path - a directory path to initially open to, defaults to
1954+ ~/Pictures
1955+
1956+ """
1957+ ImageDialog.__init__(self,gtk.FILE_CHOOSER_ACTION_OPEN, gtk.STOCK_OPEN, title,path)
1958+
1959+def open_image_file(title=_("Choose an Image"),path=None):
1960+ """open_image_file - prompts the user to choose an image file
1961+
1962+ aguments:
1963+ title - a string to be the title of the dialog
1964+ path - a string providing a path to a directory where the
1965+ dialog should start. Defaults to Pictures directory.
1966+
1967+ returns a tuple of (gtk.DialogResponse, str)
1968+ gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise
1969+ the user cancelled (gtk.RESPONSE_CANCEL) or dismissed the dialog
1970+ (gtk.RESPONSE_DELETE_EVENT)
1971+ The str is the path to the image chosen by the user, if any.
1972+
1973+
1974+ """
1975+
1976+ oid = OpenImageDialog(title,path)
1977+ response = oid.run()
1978+ value = oid.get_filename()
1979+ oid.destroy()
1980+ return (response, value)
1981+
1982+def choose_directory(title=_("Choose a Directory"),path=None):
1983+ """choose_directory - prompts the user to choose an directory
1984+
1985+ aguments:
1986+ title - a string to be the title of the dialog
1987+ path - a string providing a path to a directory where the
1988+ dialog should start.
1989+
1990+
1991+ returns a tuple of (gtk.DialogResponse, str)
1992+ gtk.RESPONSE_OK means the user clicked the "OK" button, otherwise
1993+ the user cancelled (gtk.RESPONSE_CANCEL) or dismissed the dialog
1994+ (gtk.RESPONSE_DELETE_EVENT)
1995+ The str is the path to the directory chosen by the user, if any.
1996+
1997+ """
1998+
1999+ dcd = DirectoryChooserDialog(title, path)
2000+ response = dcd.run()
2001+ value = dcd.get_filename()
2002+ dcd.destroy()
2003+ return (response, value)
2004+
2005+class DirectoryChooserDialog(gtk.FileChooserDialog):
2006+ """A Dialog to prompt the user to choose a directory path.
2007+
2008+ Using
2009+ #prompt the user to provide a directory path using
2010+ quickly.prompts.choose_directory(title)
2011+
2012+ Configuring
2013+ #A DirectoryChooseDialog is a gtk.FileChooserDialog, so you can
2014+ #use gtk.FileChooseDialog members
2015+ dcd = DirectoryChooserDialog(title)
2016+ dcd.set_local_only(False)
2017+
2018+ Extending
2019+ #A DirectoryChooseDialog is a gtk.FileChooserDialog
2020+
2021+ """
2022+
2023+ def __init__(self, title, path=None):
2024+ """Creates a DirectoryChooseDialog
2025+
2026+ arguments:
2027+ title - A title for the dialog
2028+
2029+ keyword arguments:
2030+ path - a default location for opening the dialogs
2031+
2032+ """
2033+
2034+ gtk.FileChooserDialog.__init__(self, title,
2035+ None,
2036+ gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
2037+ (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
2038+ gtk.STOCK_OPEN, gtk.RESPONSE_OK))
2039+ self.set_default_response(gtk.RESPONSE_OK)
2040+ if path is not None:
2041+ self.set_current_folder(path)
2042+
2043+
2044+if __name__ == "__main__":
2045+ """test code to try out the dialogs"""
2046+ #these don't have return values to test for
2047+ warning("Warning Prompt","Warning Prompt")
2048+ info("Information Prompt","Information Prompt")
2049+ error("Error Prompt","Error Prompt")
2050+
2051+ #the rest of values to test for
2052+ response, val = choose_directory("directory choose test")
2053+ if response == gtk.RESPONSE_OK:
2054+ print "response was OK"
2055+ else:
2056+ print "response was not OK"
2057+ print "selected directory was " + val
2058+
2059+ response, val = open_image_file("image open test")
2060+ if response == gtk.RESPONSE_OK:
2061+ print "response was OK"
2062+ else:
2063+ print "response was not OK"
2064+ print "selected locations was " + str(val)
2065+
2066+ response, val = save_image_file("image save test")
2067+ if response == gtk.RESPONSE_OK:
2068+ print "response was OK"
2069+ else:
2070+ print "response was not OK"
2071+ print "selected locations was " + str(val)
2072+
2073+ reponse, val = string("String select test","String select test")
2074+ if response == gtk.RESPONSE_OK:
2075+ print "response was OK"
2076+ else:
2077+ print "response was not OK"
2078+ print "string was " + str(val)
2079+
2080+ reponse, val = date("Date select test","Date select test")
2081+ if response == gtk.RESPONSE_OK:
2082+ print "response was OK"
2083+ else:
2084+ print "response was not OK"
2085+ print "date was " + str(val)
2086+
2087+ reponse, val = integer("Integer select test","Integer select test",default_value=20)
2088+ if response == gtk.RESPONSE_OK:
2089+ print "response was OK"
2090+ else:
2091+ print "response was not OK"
2092+ print "integer was " + str(val)
2093+
2094+ reponse, val = decimal("Price select test","Price select test",default_value=20,digits=5)
2095+ if response == gtk.RESPONSE_OK:
2096+ print "response was OK"
2097+ else:
2098+ print "response was not OK"
2099+ print "decimal was " + str(val)
2100+
2101+ reponse, val = price("Price select test","Price select test",default_value=20)
2102+ if response == gtk.RESPONSE_OK:
2103+ print "response was OK"
2104+ else:
2105+ print "response was not OK"
2106+ print "price was " + str(val)
2107+
2108+ response = yes_no("Yes/No Test","Yes/No Test", "_Yes Verb","_No Verb")
2109+ if response == gtk.RESPONSE_YES:
2110+ print "response was yes"
2111+
2112+
2113
2114=== added directory 'quickly/tests'
2115=== added file 'quickly/tests/__init__.py'
2116=== added file 'quickly/tests/test_prompts.py'
2117--- quickly/tests/test_prompts.py 1970-01-01 00:00:00 +0000
2118+++ quickly/tests/test_prompts.py 2011-08-09 11:40:13 +0000
2119@@ -0,0 +1,37 @@
2120+# -*- coding: utf-8 -*-
2121+### BEGIN LICENSE
2122+# Copyright (C) 2010 Rick Spencer rick.spencer@canonical.com
2123+#This program is free software: you can redistribute it and/or modify it
2124+#under the terms of the GNU General Public License version 3, as published
2125+#by the Free Software Foundation.
2126+#
2127+#This program is distributed in the hope that it will be useful, but
2128+#WITHOUT ANY WARRANTY; without even the implied warranties of
2129+#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
2130+#PURPOSE. See the GNU General Public License for more details.
2131+#
2132+#You should have received a copy of the GNU General Public License along
2133+#with this program. If not, see <http://www.gnu.org/licenses/>.
2134+### END LICENSE
2135+
2136+"""Tests for the DictionaryGrid"""
2137+
2138+from testtools import TestCase
2139+import quickly.prompts
2140+
2141+class TestDictionaryGrid(TestCase):
2142+ """Test the CouchGrid functionality"""
2143+
2144+ def setUp(self):
2145+ pass
2146+
2147+ def tearDown(self):
2148+ pass
2149+
2150+ def test_string_prompt(self):
2151+ """Test a simple creating An AsynchTaskProgressBox
2152+ and then adding keys and dictionaries after creation
2153+
2154+ """
2155+ pass
2156+ #response, val = quickly.prompts.string()
2157
2158=== added directory 'quickly/widgets'
2159=== added file 'quickly/widgets/__init__.py'
2160=== added file 'quickly/widgets/asynch_task_progressbox.py'
2161--- quickly/widgets/asynch_task_progressbox.py 1970-01-01 00:00:00 +0000
2162+++ quickly/widgets/asynch_task_progressbox.py 2011-08-09 11:40:13 +0000
2163@@ -0,0 +1,310 @@
2164+### BEGIN LICENSE
2165+# Copyright (C) 2010 Rick Spencer rick.spencer@canonical.com
2166+#This program is free software: you can redistribute it and/or modify it
2167+#under the terms of the GNU General Public License version 3, as published
2168+#by the Free Software Foundation.
2169+#
2170+#This program is distributed in the hope that it will be useful, but
2171+#WITHOUT ANY WARRANTY; without even the implied warranties of
2172+#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
2173+#PURPOSE. See the GNU General Public License for more details.
2174+#
2175+#You should have received a copy of the GNU General Public License along
2176+#with this program. If not, see <http://www.gnu.org/licenses/>.
2177+### END LICENSE
2178+
2179+try:
2180+ import pygtk
2181+ pygtk.require("2.0")
2182+ import gtk
2183+ import threading
2184+ import time
2185+ import gobject
2186+ import gettext
2187+ from gettext import gettext as _
2188+ gettext.textdomain('quickly-widgets')
2189+
2190+except:
2191+ print "couldn't load depencies"
2192+
2193+class AsynchTaskProgressBox( gtk.HBox ):
2194+ """AsynchTaskProgressBox: encapsulates a pulstating progressbar, a cancel
2195+ button, and a long running task. Use an AsynchTaskProgressBox when you want
2196+ a window to perform a long running task in the background without freezing
2197+ the UI for the user.
2198+
2199+ """
2200+
2201+ def __init__(self, run_function, params = None, cancelable = True):
2202+ """Create an AsycnTaskProgressBox
2203+
2204+ Keyword arguments:
2205+ run_function -- the function to run asynchronously
2206+ params -- optional dictionary of parameters to be pass into run_function
2207+ cancelable -- optional value to determine whether to show cancel button. Defaults to True.
2208+ Do not use a value with the key of 'kill' in the params dictionary
2209+
2210+ """
2211+
2212+ gtk.HBox.__init__( self, False, 2 )
2213+
2214+ self.progressbar = gtk.ProgressBar()
2215+ self.progressbar.show()
2216+ self.pack_start(self.progressbar, True)
2217+
2218+ self.cancel_button = gtk.Button(stock=gtk.STOCK_CANCEL)
2219+ if cancelable:
2220+ self.cancel_button.show()
2221+ if params is None:
2222+ params = {}
2223+ params["update_progress_function"] = self.update
2224+ self.cancel_button.set_sensitive(False)
2225+ self.cancel_button.connect("clicked",self.__stop_clicked)
2226+ self.pack_end(self.cancel_button, False)
2227+
2228+ self.run_function = run_function
2229+ self.pulse_thread = None
2230+ self.work_thread = None
2231+ self.params = params
2232+
2233+ self.connect("destroy", self.__destroy)
2234+
2235+ __gsignals__ = {'complete' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
2236+ (gobject.TYPE_PYOBJECT,)),
2237+ 'cancelrequested' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
2238+ (gobject.TYPE_PYOBJECT,))
2239+ }
2240+
2241+ def start(self, caption = "Working"):
2242+ """executes run_function asynchronously and starts pulsating the progressbar
2243+ Keyword arguments:
2244+ caption -- optional text to display in the progressbar
2245+ """
2246+ #Throw an exception if the user tries to start an operating thread
2247+ if self.pulse_thread != None:
2248+ raise RuntimeError("AsynchTaskProgressBox already started.")
2249+
2250+ #Create and start a thread to run the users task
2251+ #pass in a callback and the user's params
2252+ self.work_thread = KillableThread(self.run_function, self.__on_complete, self.params)
2253+ self.work_thread.start()
2254+
2255+ #create a thread to display the user feedback
2256+ self.pulse_thread = PulseThread(self.progressbar, caption)
2257+ self.pulse_thread.start()
2258+
2259+ #enable the button so the user can try to kill the task
2260+ self.cancel_button.set_sensitive( True )
2261+
2262+ def update(self, fraction = None, displaytext = "Working"):
2263+ """updates the progress bar with a given percentage and/or changes the
2264+ caption.
2265+ Keyword arguments:
2266+ fraction -- the current percentage complete
2267+ displaytext -- the new caption to display"""
2268+ if self.pulse_thread != None:
2269+ self.pulse_thread.update(fraction, displaytext)
2270+
2271+ #call back function for after run_function returns
2272+ def __on_complete( self, data ):
2273+ self.emit("complete", data)
2274+ self.kill()
2275+
2276+ #call back function for cancel button
2277+ def __stop_clicked( self, widget, data = None ):
2278+ self.cancel()
2279+
2280+ def cancel(self):
2281+ self.kill()
2282+ #emit the cancelrequested event
2283+ #note that this only signals that the kill function was called
2284+ #the thread may or may not have actually stopped
2285+ self.emit("cancelrequested", self)
2286+
2287+ def kill( self ):
2288+ """
2289+ Stops pulstating the progressbar if the progressbar is working.
2290+ Sets the value of 'kill' to True in the run_function.
2291+
2292+ """
2293+
2294+ #stop the pulse_thread and remove a reference to it if there is one
2295+ if self.pulse_thread != None:
2296+ self.pulse_thread.kill()
2297+ self.pulse_thread = None
2298+
2299+ #disable the cancel button since the task is about to be told to stop
2300+ gobject.idle_add(self.__disable_cancel_button)
2301+
2302+ #tell the users function tostop if it's thread exists
2303+ if self.work_thread != None:
2304+ self.work_thread.kill()
2305+
2306+ #called when the widget is destroyed, attempts to clean up
2307+ #the work thread and the pulse thread
2308+ def __destroy(self, widget, data = None):
2309+ if self.work_thread != None:
2310+ self.work_thread.kill()
2311+ if self.pulse_thread != None:
2312+ self.pulse_thread.kill()
2313+
2314+ def __disable_cancel_button(self):
2315+ gtk.gdk.threads_enter()
2316+ self.cancel_button.set_sensitive( False )
2317+ gtk.gdk.threads_leave()
2318+
2319+class PulseThread ( threading.Thread ):
2320+ """Class for use by AsynchTaskProgressBox. Not for general use.
2321+
2322+ """
2323+ def __init__(self,progressbar,displaytext = _("Working")):
2324+ threading.Thread.__init__(self)
2325+ self.displaytext = displaytext
2326+ self.setDaemon(False)
2327+ self.progressbar = progressbar
2328+ self.__kill = False
2329+ self.fraction = float(0)
2330+
2331+ def kill(self):
2332+ self.__kill = True
2333+
2334+ def update(self, fraction, displaytext):
2335+ self.displaytext = displaytext
2336+ self.fraction = fraction
2337+
2338+ #As a subclass of Thread, this function runs when start() is called
2339+ #It will cause the progressbar to pulse, showing that a task is running
2340+ def run ( self ):
2341+ self.progressbar.set_text(self.displaytext)
2342+ #keep running until the __kill flag is set to True
2343+ while not self.__kill:
2344+ time.sleep(.1)
2345+ #get ahold of the UI thread and command the progress bar to pulse
2346+ gtk.gdk.threads_enter()
2347+ if self.fraction == 0:
2348+ self.progressbar.pulse()
2349+ else:
2350+ self.progressbar.set_fraction(self.fraction)
2351+ self.progressbar.set_text(self.displaytext)
2352+ gtk.gdk.threads_leave()
2353+ #before exiting, reset the progressbar to show that no task is running
2354+ gtk.gdk.threads_enter()
2355+ self.progressbar.set_fraction(0)
2356+ self.progressbar.set_text("")
2357+ gtk.gdk.threads_leave()
2358+
2359+class KillableThread( threading.Thread ):
2360+ """Class for use by AsynchTaskProgressBox. Not for general use.
2361+
2362+ """
2363+ def __init__(self,run_function, on_complete, params = None):
2364+ threading.Thread.__init__(self)
2365+ self.setDaemon(False)
2366+ self.run_function = run_function
2367+ self.params = params
2368+ self.on_complete = on_complete
2369+
2370+ #As a subclass of Thread, this function runs when start() is called
2371+ #It will run the user's function on this thread
2372+ def run( self ):
2373+ #set up params and include the kill flag
2374+ if self.params == None:
2375+ self.params = {}
2376+ self.params["kill"] = False
2377+ #tell the function to run
2378+ data = self.run_function(self.params)
2379+ #return any data from the function so it can be sent in the complete signal
2380+ self.on_complete(data)
2381+
2382+ #Tell the user's function that it should stop
2383+ #Note the user's function may not check this
2384+ def kill( self ):
2385+ self.params["kill"] = True
2386+
2387+class TestWindow(gtk.Window):
2388+ """For testing and demonstrating AsycnTaskProgressBox.
2389+
2390+ """
2391+ def __init__(self):
2392+ #create a window a VBox to hold the controls
2393+ gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
2394+ self.set_title("AsynchTaskProgressBox Test Window")
2395+ windowbox = gtk.VBox(False, 2)
2396+ windowbox.show()
2397+ self.add(windowbox)
2398+
2399+ #create params for use by the function that should run asynchronously
2400+ params = {"start": 100, "stop": 110}
2401+
2402+ #pass in the function and the params, then add to the window
2403+ self.thread_progressbox = AsynchTaskProgressBox(self.asynch_function, params)
2404+ self.thread_progressbox.show()
2405+ windowbox.add(self.thread_progressbox)
2406+
2407+ #start the task, and set the text for the progressbar to "Testing"
2408+ #This will start the function and start the progressbar pulsating
2409+ self.thread_progressbox.start("Testing")
2410+
2411+ #connect to the complete event to respond when the task is complete
2412+ self.thread_progressbox.connect("complete",self.complete_function)
2413+
2414+ #connect to the cancel requested event for demonstration purposes
2415+ self.thread_progressbox.connect("cancelrequested", self.canceled_function)
2416+
2417+ #create a button for starting the task and add it to the window
2418+ start_button = gtk.Button(stock=gtk.STOCK_EXECUTE)
2419+ start_button.show()
2420+ windowbox.add(start_button)
2421+ start_button.connect("clicked",self.start_clicked)
2422+ self.show()
2423+
2424+ #finish wiring up the window
2425+ self.connect("destroy", self.destroy)
2426+
2427+ #start up gtk.main in a threaded environment
2428+ gtk.gdk.threads_init()
2429+ gtk.gdk.threads_enter()
2430+ gtk.main()
2431+ gtk.gdk.threads_leave()
2432+
2433+ #called when the window is destroyed
2434+ def destroy(self, widget, data = None):
2435+ gtk.main_quit()
2436+
2437+ #start the AsynchTaskProgressBox when the button is clicked
2438+ def start_clicked(self, widget, data = None):
2439+ self.thread_progressbox.start("Testing")
2440+
2441+ #The function to run asynchronously
2442+ def asynch_function( self, params ):
2443+ # do something interminate and cpu intensive at startup
2444+ print "starting..."
2445+ time.sleep(2)
2446+ #pull values from the params that were set above
2447+ total = float(abs(params["stop"]-params["start"]))
2448+ for x in range(params["start"],params["stop"]):
2449+ #check if to see if the user has told the task to stop
2450+ if params["kill"] == True:
2451+ #return a string if the user stopped the task
2452+ return "stopped at " + str(x)
2453+ else:
2454+ #if the user did not try to stop the task, go ahead and do something
2455+ print x
2456+ fraction=abs(x-params["start"])/total
2457+ # call the update_progress_function function with the current percentage and caption
2458+ params["update_progress_function"](fraction=fraction, displaytext=str(x))
2459+ #this is a processor intensive task, so
2460+ #sleep the loop to keep the UI from bogging down
2461+ time.sleep(.5)
2462+ #if the loop completes, return a string
2463+ return "counted all"
2464+
2465+ #called when the task completes
2466+ def complete_function(self, widget, data = None):
2467+ print "returned " + str(data)
2468+
2469+ def canceled_function(self, widget, data=None):
2470+ print "cancel requested"
2471+if __name__== "__main__":
2472+ test = TestWindow()
2473+
2474
2475=== added file 'quickly/widgets/conventions.py'
2476--- quickly/widgets/conventions.py 1970-01-01 00:00:00 +0000
2477+++ quickly/widgets/conventions.py 2011-08-09 11:40:13 +0000
2478@@ -0,0 +1,40 @@
2479+### BEGIN LICENSE
2480+# Copyright (C) 2010 Rick Spencer rick.spencer@canonical.com
2481+#This program is free software: you can redistribute it and/or modify it
2482+#under the terms of the GNU General Public License version 3, as published
2483+#by the Free Software Foundation.
2484+#
2485+#This program is distributed in the hope that it will be useful, but
2486+#WITHOUT ANY WARRANTY; without even the implied warranties of
2487+#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
2488+#PURPOSE. See the GNU General Public License for more details.
2489+#
2490+#You should have received a copy of the GNU General Public License along
2491+#with this program. If not, see <http://www.gnu.org/licenses/>.
2492+### END LICENSE
2493+
2494+import gtk
2495+import gobject
2496+from grid_column import StringColumn, CurrencyColumn, CheckColumn
2497+from grid_column import IntegerColumn, TagsColumn, DateColumn
2498+
2499+def get_column(key, index, dictionary_index, editable):
2500+ if key.lower() == "id":
2501+ return IntegerColumn(key, index, dictionary_index, editable)
2502+ elif key.endswith("?"):
2503+ return CheckColumn(key, index, dictionary_index, editable)
2504+ elif key.lower().endswith(" price") or key.lower() == "price":
2505+ return CurrencyColumn(key, index, dictionary_index, editable)
2506+ elif key.lower() == "tags":
2507+ return TagsColumn(key, index, dictionary_index, editable)
2508+ elif key.lower().endswith(" count") or key.lower() == "count":
2509+ return IntegerColumn(key, index, dictionary_index, editable)
2510+ elif key.lower().endswith(" date") or key.lower() == "date":
2511+ return DateColumn(key, index, dictionary_index, editable)
2512+
2513+ else:
2514+ return StringColumn(key, index, dictionary_index, editable)
2515+
2516+
2517+
2518+
2519
2520=== added file 'quickly/widgets/couch_grid.py'
2521--- quickly/widgets/couch_grid.py 1970-01-01 00:00:00 +0000
2522+++ quickly/widgets/couch_grid.py 2011-08-09 11:40:13 +0000
2523@@ -0,0 +1,455 @@
2524+# -*- coding: utf-8 -*-
2525+### BEGIN LICENSE
2526+# Copyright (C) 2010 Rick Spencer rick.spencer@canonical.com
2527+#This program is free software: you can redistribute it and/or modify it
2528+#under the terms of the GNU General Public License version 3, as published
2529+#by the Free Software Foundation.
2530+#
2531+#This program is distributed in the hope that it will be useful, but
2532+#WITHOUT ANY WARRANTY; without even the implied warranties of
2533+#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
2534+#PURPOSE. See the GNU General Public License for more details.
2535+#
2536+#You should have received a copy of the GNU General Public License along
2537+#with this program. If not, see <http://www.gnu.org/licenses/>.
2538+### END LICENSE
2539+
2540+"""A Treeview for Desktop CouchDB
2541+Displays and persists data in desktopcouch, handles presentation
2542+of the UI in a Gtk.TreeView, as well handles persistence to a backend
2543+desktopcouch database.
2544+
2545+Using
2546+#define the database and record type
2547+database = "couch_widget_test"
2548+record_type="test_record_type"
2549+
2550+#create a dictionary if you don't already have one
2551+dicts = [{"test?":True,"price":100,"foo count":100,"Key4":"1004"},
2552+ {"test?":True,"price":100,"foo count":100,"Key4":"1004"},
2553+ {"test?":True,"price":100,"foo count":100,"Key4":"1004"}]
2554+
2555+#create the CouchGrid
2556+cg = CouchGrid(database, record_type=record_type, dictionaries=dicts)
2557+
2558+Configuring
2559+#Define columns to display
2560+keys=["price","test?"]
2561+cg = CouchGrid(database, record_type=record_type, dictionaries=dicts,keys=keys)
2562+
2563+#Define column types to use
2564+hints = {"price": StringColumn}
2565+cg = CouchGrid(database, record_type=record_type, dictionaries=dicts,keys=keys, type_hints = hints)
2566+
2567+#A CouchGrid is a Dictionary Grid whcih is a TreeView,
2568+#so you can use DicationaryGrid and TreeView members
2569+cg.editable = True
2570+cg.get_column(0).set_title("Price")
2571+
2572+Extending
2573+To change the way CouchGrid persists data, change _refresh_treeview to
2574+handle persistence of data if needed, calling DictionaryGrid._populate_treeivew
2575+to handle the UI. You should do the same with append_row.
2576+
2577+You may also want to override _edited and _edited_toggled to handle persistence
2578+when the UI is changed.
2579+
2580+It is only useful to extend CouchGrid if you are using desktopcouch for
2581+persistence. Otherwise, derive from DictionaryGrid.
2582+
2583+"""
2584+
2585+import gtk
2586+import gobject
2587+from desktopcouch.records.server import CouchDatabase
2588+from desktopcouch.records.record import Record
2589+from quickly.widgets.dictionary_grid import DictionaryGrid
2590+from quickly.widgets.grid_column import CheckColumn
2591+
2592+#TODO: a delete_selected_rows function would be nice and not too hard
2593+
2594+class CouchGrid(DictionaryGrid):
2595+ def __init__(
2596+ self, database_name, record_type=None, dictionaries=None, editable=False, keys=None, type_hints=None, uri=None):
2597+ """Create a new Couchwidget
2598+ arguments:
2599+ database_name - specify the name of the database in the desktop
2600+ couchdb to use. If the specified database does not exist, it
2601+ will be created.
2602+
2603+ optional arguments:
2604+ record_type - a string to specify the record_type to use in
2605+ retrieving and creating records. Note that if no records exist
2606+ in the CouchDB then the keys argument must also be used or
2607+ a RuntimeError will result.
2608+
2609+ dictionaries - a list of dictionaries to initialize in the
2610+ grid. If these haven't been added to desktopcouch, they will
2611+ be automatically persisted and updated using the record_type
2612+ specified. Any previously saved data of the same record_type will
2613+ also be displayed.
2614+
2615+ keys - a list of strings specifying keys to use in
2616+ the columns of the CouchGrid. The keys will also be used for the
2617+ column titles and keys in desktop couch.
2618+
2619+ If a record does not contain a value for a specified key
2620+ the CouchGrid will simply display an empty cell of the
2621+ appropriate type. If the widget is set to editable,
2622+ the user will be able to add values to the database.
2623+
2624+ The types for the columns will be inferred by the key based on
2625+ some conventions. the key "id" is assumed to be an integer, as
2626+ is any key ending in " count". A key ending in "?" is assumed
2627+ to be a Boolean displayed with a checkbox. The key "price" is
2628+ assumed to be currency, as is any key ending in "count". There
2629+ may be others. Defaults can be overridden using type-hints. All
2630+ other keys will be assumed to be strings.
2631+
2632+ type-hints - a dictionary containing keys specificed for the
2633+ TreeView and GridColumns. Used to override types inferred
2634+ by convention, or for changing the type of a column from
2635+ the default of a string to something else.
2636+
2637+ uri - A uri for the DesktopCouch. This is only used to
2638+ choose a Couch database running remotely. The default is
2639+ to use the local desktopcouch database.
2640+
2641+ """
2642+
2643+ if type(database_name) is not type(str()):
2644+ raise TypeError("database_name is required and must be a string")
2645+
2646+ #set up the database before trying to use it
2647+ self.uri = uri
2648+ self._record_type = None
2649+ self._db = None
2650+ if record_type is not None:
2651+ self._record_type = record_type
2652+
2653+ #QUESTION: What is the purpose of this?
2654+ #if dictionaries is not None and keys is None:
2655+ # DictionaryGrid.__init__(self, None, editable, keys, type_hints)
2656+ #else:
2657+ # DictionaryGrid.__init__(self, None, editable, keys, type_hints)
2658+
2659+ # Have to leave it in for now. But this is certainly a bug.
2660+ # Note: adding dicts to a CG adds to empty cols in the model between the key values and the couch dict.
2661+ if dictionaries is not None and keys is None:
2662+ DictionaryGrid.__init__(self, None, editable, keys, type_hints)
2663+ else:
2664+ DictionaryGrid.__init__(self, None, editable, keys, type_hints)
2665+
2666+
2667+ """
2668+ if dictionaries is not None and keys is not None:
2669+ DictionaryGrid.__init__(self, dictionaries, editable, keys, type_hints)
2670+ elif keys is None:
2671+ DictionaryGrid.__init__(self, dictionaries, editable, None, type_hints)
2672+ elif dictionaries is None:
2673+ DictionaryGrid.__init__(self, None, editable, keys, type_hints)
2674+ """
2675+
2676+
2677+ if self.uri:
2678+ self._db = CouchDatabase(database_name, create=True, uri=self.uri)
2679+ else:
2680+ self._db = CouchDatabase(database_name, create=True)
2681+
2682+ if dictionaries is not None:
2683+ for d in dictionaries:
2684+ self._persist_dict_to_couch(d)
2685+
2686+ self._refresh_treeview()
2687+
2688+ @property
2689+ def database(self):
2690+ """database - gets an instance to the CouchDB.
2691+ Set to a string to change the database.
2692+
2693+ """
2694+ return self._db
2695+
2696+ @database.setter
2697+ def database(self, db_name):
2698+ if self.uri:
2699+ self._db = CouchDatabase(db_name, create=True, uri=self.uri)
2700+ else:
2701+ self._db = CouchDatabase(db_name, create=True)
2702+ if self.record_type != None:
2703+ self._refresh_treeview()#first time treeview is reset
2704+
2705+ @property
2706+ def record_type(self):
2707+ """record_type - a string specifying the record type of
2708+ the documents to retrieve from the CouchDB.
2709+
2710+ Will cause the TreeView to refresh when set.
2711+ """
2712+ return self._record_type
2713+
2714+ @record_type.setter
2715+ def record_type(self, record_type):
2716+
2717+ #store the record type string
2718+ self._record_type = record_type
2719+ self._refresh_treeview()
2720+
2721+ @property
2722+ def selected_record_ids(self):
2723+ """ selected_record_ids - a list of document ids that are
2724+ selected in the CouchGrid. Throws an IndexError if
2725+ a specified id is not found in the list when setting
2726+ this property.
2727+
2728+ This property is read/write
2729+
2730+ """
2731+ ids = []
2732+ for row in self.selected_rows:
2733+ id_ = None
2734+
2735+ if "__desktopcouch_id" in row:
2736+ id_ = row["__desktopcouch_id"]
2737+ ids.append(id_)
2738+ return ids
2739+
2740+ @selected_record_ids.setter
2741+ def selected_record_ids(self, indexes):
2742+ rows = [] #a list of rows to select
2743+ for id in indexes:
2744+ id_found = False #track if the id was found
2745+
2746+ for i,r in enumerate(self.list_store):
2747+ dictionary = r[len(self.keys)] #this dictionary always last column
2748+ if "__desktopcouch_id" in dictionary:
2749+ if dictionary["__desktopcouch_id"] == id:
2750+ id_found = True #id was good
2751+ if r not in rows: #don't have duplicates to select
2752+ rows.append(i)
2753+ if not id_found: #stop if a requested id was not in the list
2754+ raise IndexError("id %s not found" %id)
2755+
2756+ #select the requested ids
2757+ selection = self.get_selection()
2758+ selection.unselect_all()
2759+ for r in rows:
2760+ selection.select_path(r)
2761+
2762+ def remove_selected_rows(self, delete=False):
2763+ rows_to_delete = self.selected_rows
2764+ if delete:
2765+ for r in rows_to_delete:
2766+ self.database.delete_record(r["__desktopcouch_id"])
2767+ DictionaryGrid.remove_selected_rows(self)
2768+
2769+ def _refresh_treeview(self):
2770+ """
2771+ _refresh_treeview: internal function to handle rebuilding
2772+ the gtk.TreeView along with columns and cell renderers. extends
2773+ DictionaryGrid._refresh_treeview by retrieving stored desktopcouch
2774+ records before calling DictionaryGrid._refresh_treeview.
2775+
2776+ _refresh_treeview is not typically called directly,
2777+ but may be useful to override in subclasses.
2778+
2779+ """
2780+
2781+ #if the database is not set up, just return
2782+ if self._db is None or self._record_type is None:
2783+ return
2784+
2785+ #if keys aren't set, infer them from the collection
2786+ if len(self._dictionaries) > 0 and self.keys is None:
2787+ self._infer_keys_from_dictionaries()
2788+
2789+ #retrieve the docs for the record_type, if any
2790+ results = self._db.get_records(
2791+ record_type=self._record_type,create_view=True)
2792+
2793+
2794+ #if there are no rows and no keys set, there is no
2795+ #way to build the grid, just raise an error
2796+ if len(results) == 0 and self._keys is None:
2797+ raise RuntimeError("Cannot infer columns for CouchGrid")
2798+
2799+ dicts = []
2800+ for r in results:
2801+ d = r.value
2802+
2803+ #hmmm, maybe make these so they get hidden rather than delete them
2804+ #hide the desktopcouch variabls
2805+ for key in d:
2806+ if key.startswith("_") and not key.startswith("__desktopcouch"):
2807+ d["__desktopcouch" + key] = d[key]
2808+ del(d[key])
2809+
2810+ d["__record_type"] = d["record_type"]
2811+ del(d["record_type"])
2812+ dicts.append(d)
2813+
2814+ self._dictionaries = dicts
2815+ DictionaryGrid._refresh_treeview(self)
2816+
2817+ for c in self.get_columns():
2818+ if type(c) == CheckColumn:
2819+ c.renderer.connect("toggled",self._edited_toggled, c)
2820+ else:
2821+ c.renderer.connect("edited",self._edited, c)
2822+
2823+ def append_row(self, dictionary):
2824+ """append_row: add a row to the TreeView and to DesktopCouch.
2825+ If keys are already set up only the the keys in the dictionary
2826+ matching the keys used for columns will be displayed, though
2827+ all the key value pairs will be saved to the DesktopCouch.
2828+ If no keys are set up, and this is the first row, keys will be
2829+ inferred from the dictionary keys.
2830+
2831+ arguments:
2832+ dictionary - a dictionary to add to the Treeview and to DesktopCouch
2833+
2834+ """
2835+
2836+ if dictionary is None:
2837+ dictionary = {}
2838+
2839+ #Here we add rows to desktopcouch if needed
2840+ if "__desktopcouch_id" not in dictionary:
2841+ self._persist_dict_to_couch(dictionary)
2842+ DictionaryGrid.append_row(self,dictionary)
2843+
2844+ def _persist_dict_to_couch(self,dictionary):
2845+ """ _persist_dict_to_couch - internal implementation. may be useful
2846+ a subclass of CouchGrid, but not normally called directly.
2847+
2848+ """
2849+
2850+ dictionary["record_type"] = self.record_type
2851+ rec = Record(dictionary)
2852+ #meh, best not to save an empty row
2853+ if len(dictionary) > 1:
2854+ doc_id = self._db.put_record(rec)
2855+ dictionary["__desktopcouch_id"] = doc_id
2856+ dictionary["__record_type"] = self.record_type
2857+ del(dictionary["record_type"])
2858+
2859+ def _edited_toggled(self, cell, path, col):
2860+ """ _edited_toggled - internal signal handler.
2861+ Updates the database if a cell in the Treeview
2862+ has been edited special cased for CheckColumns.
2863+
2864+ """
2865+
2866+ iter = self.list_store.get_iter(path)
2867+ key = col.key
2868+ active = not cell.get_active()
2869+ self._edited(cell, path, active, col)
2870+
2871+ def _edited(self, cell, path, new_val, col):
2872+ """ _edited - internal signal handler.
2873+ Updates the database if a cell in the Treeview
2874+ has been edited.
2875+
2876+ """
2877+ iter = self.list_store.get_iter(path)
2878+ key = col.key
2879+ dictionary = self.list_store.get_value(iter,len(self.keys))
2880+
2881+ if "__desktopcouch_id" not in dictionary: #the row has not been stored
2882+ #create a document
2883+ dictionary["record_type"] = self.record_type
2884+ rec = Record(dictionary)
2885+ doc_id = self._db.put_record(rec)
2886+ dictionary["__desktopcouch_id"] = doc_id
2887+ self.list_store.set_value(iter, len(self.keys), dictionary)
2888+
2889+ else: #it has been saved
2890+ #get the record id from the dictionary
2891+ #then update the datbase with the change
2892+ id = dictionary["__desktopcouch_id"]
2893+ key = col.key
2894+ self._db.update_fields(id,{key:new_val})
2895+
2896+def __show_selected(widget, row, widgets):
2897+ """Test function for selection properties of CouchGrid"""
2898+ tv, cg = widgets
2899+ disp = "Rows:\n"
2900+ for r in cg.selected_rows:
2901+ disp += str(r) + "\n"
2902+
2903+ disp += "\n\n_Ids:\n"
2904+ for r in cg.selected_record_ids:
2905+ disp += str(r) + "\n"
2906+
2907+ tv.get_buffer().set_text(disp)
2908+
2909+def __select_ids(widget, widgets):
2910+ """Test function for selecting ids."""
2911+ entry, cg, lbl = widgets
2912+ cg.selected_record_ids = entry.get_text().split(",")
2913+
2914+if __name__ == "__main__":
2915+ """creates a test CouchGrid if called directly"""
2916+
2917+ from quickly.widgets.grid_column import StringColumn
2918+
2919+ #create and show a test window and container
2920+ win = gtk.Window(gtk.WINDOW_TOPLEVEL)
2921+ win.set_title("CouchGrid Test Window")
2922+ win.connect("destroy",gtk.main_quit)
2923+ win.show()
2924+ vbox = gtk.VBox(False, False)
2925+ vbox.show()
2926+ win.add(vbox)
2927+
2928+ #create a test widget with test database values
2929+ dicts = [{"test?":True,"price":100,"foo count":100,"Key4":"1004"},
2930+ {"test?":True,"price":100,"foo count":100,"Key4":"1004"},
2931+ {"test?":True,"price":100,"foo count":100,"Key4":"1004"}]
2932+
2933+ #create some settings
2934+ database = "couch_widget_test"
2935+ record_type="test_record_type"
2936+ keys=["price","test?"]
2937+ hints = {"price": StringColumn}
2938+
2939+ #create it and part a bit
2940+ cg = CouchGrid(database, record_type=record_type, dictionaries=dicts,keys=keys, type_hints = hints)
2941+ cg.editable = True
2942+ cg.get_column(0).set_title("Price")
2943+
2944+ #finish out and run the test UI
2945+ cg.show()
2946+ vbox.pack_start(cg, False, True)
2947+ hbox = gtk.HBox(False, 5)
2948+ hbox.show()
2949+ tv = gtk.TextView()
2950+ tv.show()
2951+ tv.set_wrap_mode(gtk.WRAP_CHAR)
2952+ tv.set_size_request(300,-1)
2953+ cg.connect("selection-changed",__show_selected, (tv,cg))
2954+
2955+ id_vbox = gtk.VBox(False, 5)
2956+ id_vbox.show()
2957+
2958+ fb_lbl = gtk.Label("paste ids into the edit box to select them")
2959+ fb_lbl.show()
2960+
2961+ entry = gtk.Entry()
2962+ entry.show()
2963+
2964+ btn = gtk.Button("select ids")
2965+ btn.show()
2966+ btn.connect("clicked", __select_ids, (entry,cg, fb_lbl))
2967+
2968+ id_vbox.pack_start(fb_lbl, False, False)
2969+ id_vbox.pack_start(entry, False, False)
2970+ id_vbox.pack_end(btn, False, False)
2971+
2972+ hbox.pack_start(tv, False, False)
2973+ vbox.pack_end(hbox, False, False)
2974+ hbox.pack_end(id_vbox, False, False)
2975+
2976+ #run the test app
2977+ gtk.main()
2978+
2979
2980=== added file 'quickly/widgets/dictionary_grid.py'
2981--- quickly/widgets/dictionary_grid.py 1970-01-01 00:00:00 +0000
2982+++ quickly/widgets/dictionary_grid.py 2011-08-09 11:40:13 +0000
2983@@ -0,0 +1,525 @@
2984+#!/usr/bin/env python
2985+# -*- coding: utf-8 -*-
2986+### BEGIN LICENSE
2987+# Copyright (C) 2010 Rick Spencer rick.spencer@canonical.com
2988+#This program is free software: you can redistribute it and/or modify it
2989+#under the terms of the GNU General Public License version 3, as published
2990+#by the Free Software Foundation.
2991+#
2992+#This program is distributed in the hope that it will be useful, but
2993+#WITHOUT ANY WARRANTY; without even the implied warranties of
2994+#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
2995+#PURPOSE. See the GNU General Public License for more details.
2996+#
2997+#You should have received a copy of the GNU General Public License along
2998+#with this program. If not, see <http://www.gnu.org/licenses/>.
2999+### END LICENSE
3000+"""A gtk.TreeView for Dictionaries
3001+Displays and persists data in a gtk.TreeView. Handles the
3002+set up of the gtk.TreeView, gtk.ListModel, gtk.TreeViewColumns,
3003+and gtk.CellRenderers.
3004+
3005+Using
3006+#create a dictionary if you don't already have one
3007+dicts = [{"test?":True,"price":100,"foo count":100,"Key4":"1004"},
3008+ {"test?":True,"price":100,"foo count":100,"Key4":"1004"},
3009+ {"test?":True,"price":100,"foo count":100,"Key4":"1004"}]
3010+
3011+#create the DictionaryGrid
3012+dg = DictionaryGrid(dictionaries=dicts)
3013+
3014+Configuring
3015+#set UI to be editable
3016+dg.editable = True
3017+
3018+#Define columns to display
3019+keys=["price","test?"]
3020+dg = DictionaryGrid(dictionaries=dicts,keys=keys)
3021+
3022+#Define column types to use
3023+hints = {"price": StringColumn}
3024+dg = CouchGrid(dictionaries=dicts,keys=keys, type_hints = hints)
3025+
3026+#A CouchGrid is gtk.TreeView, so you can use gtk.TreeView members
3027+dg.get_column(0).set_title("Price")
3028+
3029+#Use the selection-changed signal and read from the DictionaryGrid
3030+dg.connect("selection-changed", __handle_selection_changed)
3031+def __handle_selection_changed(widget, dictionaries, data = None):
3032+ for dictionary in dictionaries:
3033+ print dictionary["price"]
3034+
3035+#Use the cell-edited signal to track changes
3036+dg.connect("cell-edited", __handle_edited_cells)
3037+def __handle_edited_cells(widget, cell, row, key, new_value, data=None):
3038+ print new_value
3039+
3040+Extending
3041+To change what a DictionaryGrid does every time it builds itself
3042+override DictionaryGrid._refresh_treeview. Here you can read data
3043+form a data store, change the way the columns from
3044+quickly.widgetsgrid_column are built, etc...
3045+
3046+To change what a DictionaryGrid does every time a row of data is
3047+add, override "append_row". Here you can change add data to store
3048+with the dictionary being added, change the data itself, change
3049+how the data is being displayed, etc...
3050+
3051+"""
3052+
3053+import gtk
3054+import gobject
3055+import conventions
3056+from quickly.widgets.grid_column import StringColumn
3057+from grid_column import CheckColumn
3058+
3059+class DictionaryGrid(gtk.TreeView):
3060+ __gtype_name__ = "DictionaryGrid"
3061+
3062+ def __init__(self, dictionaries=None, editable = False, keys=None, type_hints=None):
3063+ """
3064+ Creates a new DictionaryGrid
3065+ arguments:
3066+
3067+ dictionaries - a list of dictionaries to initialize in the
3068+ grid.
3069+
3070+ keys - a list of strings specifying keys to use in
3071+ the columns of the DictionaryGrid.
3072+
3073+ The types for the columns will be inferred by the key based on
3074+ some conventions. the key "id" is assumed to be an integer, as
3075+ is any key ending in " count". A key ending in "?" is assumed
3076+ to be a Boolean displayed with a checkbox. The key "price" is
3077+ assumed to be currency, as is any key ending in "count". There
3078+ may be others. Defaults can be overridden using type-hints. All
3079+ other keys will be assumed to be strings.
3080+
3081+ type-hints - a dictionary containing keys specificed for the
3082+ TreeView and GridColumns. Used to override types inferred
3083+ by convention, or for changing the type of a column from
3084+ the default of a string to something else.
3085+
3086+ """
3087+
3088+ gtk.TreeView.__init__(self)
3089+ self.list_store = None
3090+ self.unfiltered_store = None
3091+ self._keys = keys
3092+ self._editable = editable
3093+ if dictionaries is None:
3094+ self._dictionaries = []
3095+ else:
3096+ self._dictionaries = dictionaries
3097+ if type_hints is None:
3098+ self._type_hints = {}
3099+ else:
3100+ self._type_hints = type_hints
3101+ self.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
3102+ self._refresh_treeview()
3103+
3104+ #signal handlers to track selection in the treeview
3105+ #utlmiately these all emit the "selection_changed signal
3106+ self.connect("cursor_changed", self.__selection_changed)
3107+ self.connect("move-cursor", self.__cursor_moved)
3108+ self.connect("select-all", self.__selection_all)
3109+ self.connect("select-cursor-row", self.__selection_changed)
3110+ self.connect("unselect-all", self.__selection_none)
3111+ self.connect("toggle-cursor-row", self.__selection_changed)
3112+
3113+ def __cursor_moved(self, grid, step, count, data=None):
3114+ self.__selection_changed(self)
3115+
3116+ def __selection_all(self, treeview, data=None):
3117+ self.emit("selection-changed", self.rows)
3118+
3119+ def __selection_none(self, treeview, data=None):
3120+ self.emit("selection-changed", [])
3121+
3122+ def __selection_changed(self, treeiew, data=None):
3123+ self.emit("selection-changed", self.selected_rows)
3124+
3125+ def __edited_toggled(self, cell, path, col):
3126+ iter = self.get_model().get_iter(path)
3127+ key = col.key
3128+ active = not cell.get_active()
3129+ self.__edited(cell, path, active, col)
3130+
3131+ def __edited(self, cell, path, new_val, col):
3132+ """ _edited - internal signal handler.
3133+ Updates the database if a cell in the Treeview
3134+ has been edited.
3135+
3136+ """
3137+ iter = self.get_model().get_iter(path)
3138+ row_dict = self.get_model().get_value(iter,len(self.keys))
3139+ key = col.key
3140+ dictionary = self.get_model().get_value(iter,len(self.keys))
3141+ self.emit("cell-edited",cell, path, key, new_val, row_dict)
3142+
3143+ @property
3144+ def keys(self):
3145+ """ keys - A list of strings to act as keys for the
3146+ backing dictionaries and the default titles for the columns.
3147+
3148+ Setting this property will cause the widget to reload.
3149+
3150+ """
3151+
3152+ return self._keys
3153+
3154+ @keys.setter
3155+ def keys(self, keys):
3156+ self._keys = keys
3157+ self._refresh_treeview()
3158+
3159+ @property
3160+ def editable(self):
3161+ """editable - bool value, True to make editable
3162+
3163+ Setting this property will cause the widget to reload.
3164+
3165+ """
3166+ return self._editable
3167+
3168+ @editable.setter
3169+ def editable(self, editable):
3170+ #refresh the treeview if possible
3171+ #self._refresh_treeview()
3172+
3173+ # Refreshing the treeview has no benefits but many negative
3174+ # side effects. Better to loop over the columns, setting the property
3175+ # on each renderer. The columns should probably expose this property
3176+ # themselves, but for now this works.
3177+
3178+ for column in self.get_columns():
3179+ column.renderer.set_property("editable", editable)
3180+ self._editable = editable
3181+
3182+ @property
3183+ def columns(self):
3184+ """ columns - A dictionary of the GridColumns indexed by the
3185+ keys for that column. This allows access to columns by the key,
3186+ for example to change the title of a specific column:
3187+ grid.columns["complete?"].set_title(_("Completed"))
3188+
3189+ This property is read only.
3190+
3191+ """
3192+
3193+ cols = {}
3194+ for c in self.get_columns():
3195+ cols[c.key] = c
3196+ return cols
3197+
3198+ def set_column_titles(self, titles):
3199+ """set_column_titles - sets the specified titles for the GridColumns
3200+ in the DictionaryGrid. Use a dictionary of strings indexed by keys.
3201+ For example:
3202+ titles = {"complete?":_("Complete"),"id":_("ID")}
3203+ grid.set_column_titles(titles)
3204+
3205+ """
3206+
3207+ for t in titles:
3208+ if t in self.columns:
3209+ self.columns[t].set_title(titles[t])
3210+
3211+ def get_dictionaries_copy(self):
3212+ """get_dictionaries_copy -returns a copy of the dictionaries in
3213+ the dictionary grid.
3214+
3215+ """
3216+ return self._dictionaries[:]
3217+
3218+ def _infer_keys_from_dictionaries(self):
3219+ """_infer_keys_from_dictionaries: an internal function to
3220+ set _keys suitable for column titles from a set of dictionaries.
3221+
3222+ _infer_keys_from_dictionaries is not typically called directly,
3223+ but may be useful to override in subclasses.
3224+
3225+ """
3226+ key_collector = []
3227+ for r in self._dictionaries:
3228+ for k in r.keys():
3229+ if k not in key_collector and not k.startswith("__"):
3230+ key_collector.append(k)
3231+
3232+ self._keys = key_collector
3233+
3234+ def _refresh_treeview(self):
3235+ """
3236+ _refresh_treeview: internal function to handle rebuilding
3237+ the gtk.TreeView along with columns and cell renderers..
3238+
3239+ _refresh_treeview is not typically called directly,
3240+ but may be useful to override in subclasses.
3241+
3242+ """
3243+
3244+ #if keys are already set, set up titles and columns
3245+ if self.keys is not None:
3246+ self.__reset_model()
3247+
3248+ #if keys aren't set, infer them from the collection
3249+ if len(self._dictionaries) > 0 and self.keys is None:
3250+ self._infer_keys_from_dictionaries()
3251+ self.__reset_model()
3252+
3253+ for dictionary in self._dictionaries:
3254+ #lists have to match the list_store columns in length
3255+ #so we have to make rows as long as the headerings
3256+ #note that the last value is reserved for extra data
3257+ self.append_row(dictionary)
3258+
3259+ #apply the model to the Treeview if possible
3260+ if self.list_store != None:
3261+ self.unfiltered_store = self.list_store
3262+ self.set_model(self.list_store)
3263+
3264+ def append_row(self, dictionary):
3265+ """append_row: add a row to the TreeView. If keys are already set up
3266+ only the the keys in the dictionary matching the keys used
3267+ for columns will be used. If no keys are set up, and this is the
3268+ first row, keys will be inferred from the dictionary keys.
3269+
3270+ arguments:
3271+ dictionary - a dictionary to the TreeView.
3272+
3273+ """
3274+
3275+ new_row = []
3276+
3277+ for i, k in enumerate(self.keys):
3278+ if k in dictionary:
3279+ display_val = self.__columns_map[k].display_val(dictionary[k])
3280+ real_val = self.__columns_map[k].real_val(dictionary[k])
3281+ #TODO: store a "real_val" instead of display val
3282+ #that was "converted_val"
3283+ dictionary[k] = real_val
3284+ else:
3285+ display_val = self.__columns_map[k].default_display_val()
3286+ new_row.append(display_val)
3287+ new_row.append(dictionary)
3288+ self.list_store.append(new_row)
3289+
3290+ @property
3291+ def rows(self):
3292+ """ rows - returns a list of dictionaries
3293+ for each row in the grid.
3294+
3295+ This property is read only.
3296+
3297+ """
3298+ model = self.get_model()
3299+ rows = [] #list of rows to return
3300+ model.foreach(self.__append_dict, rows)
3301+ return rows
3302+
3303+ def __append_dict(self, model, path, iter, rows):
3304+ """ __append_dict: internal function, do not call directly"""
3305+
3306+ row = model.get_value(iter,len(self.keys))
3307+ rows.append(row)
3308+
3309+ @property
3310+ def selected_rows(self):
3311+ """ selected_rows - returns a list of dictionaries
3312+ for each row selected.
3313+
3314+ This property is read only.
3315+
3316+ """
3317+
3318+ #get the selected rows in the ListStore
3319+ selection = self.get_selection()
3320+ model, model_rows = selection.get_selected_rows()
3321+
3322+ rows = [] #list of rows to return
3323+
3324+ for mr in model_rows:
3325+ row = {} #a row to be added to the list of rows
3326+ iter = model.get_iter(mr)
3327+
3328+ row = model.get_value(iter,len(self.keys))
3329+ rows.append(row)
3330+ return rows
3331+
3332+ def remove_selected_rows(self):
3333+ """
3334+ remove_selected_rows: removes the rows currently selected
3335+ in the TreeView UI from the TreeView as well as the backing
3336+ gtk.ListStore.
3337+
3338+ """
3339+
3340+ #get the selected rows, and return if nothing is selected
3341+ model, rows = self.get_selection().get_selected_rows()
3342+
3343+ if len(rows) == 0:
3344+ return
3345+
3346+ #store the last selected row to reselect after removal
3347+ next_to_select = rows[-1][0] + 1 - len(rows)
3348+
3349+ #loop through and remove
3350+
3351+ if type(model) is not gtk.ListStore:
3352+ iters = [model.get_model().get_iter(path) for path in rows]
3353+ store_iters = []
3354+
3355+ for i in iters:
3356+ store_iters.append(model.get_model().convert_iter_to_child_iter(i))
3357+
3358+ for store_iter in store_iters:
3359+ self.unfiltered_store.remove(store_iter)
3360+
3361+ else:
3362+ iters = [model.get_iter(path) for path in rows]
3363+
3364+ for i in iters:
3365+ model.remove(i)
3366+
3367+ #select a row for the user, nicer that way
3368+ rows_remaining = len(self.get_model())
3369+
3370+ #don't try to select anything if there are no rows left
3371+ if rows_remaining < 1:
3372+ return
3373+
3374+ #select the next row down, unless it's out of range
3375+ #in which case just select the last row
3376+ if next_to_select < rows_remaining:
3377+ self.get_selection().select_path(next_to_select)
3378+ else:
3379+ self.get_selection().select_path(rows_remaining - 1)
3380+
3381+
3382+ def __reset_model(self):
3383+ """ __reset_model - internal funciton, do not call directly.
3384+ This function is typically called when the TreeView needs
3385+ to be rebuilt. Creates new columns.
3386+
3387+ """
3388+
3389+ #remove the current columns from the TreeView
3390+ cols = self.get_columns()
3391+ for c in cols:
3392+ self.remove_column(c)
3393+
3394+ #reinitialize the column variables
3395+ col_count = len(self.keys) + 1
3396+ col_types = []
3397+ self.__columns_map = {}
3398+
3399+ #create a column for each key
3400+ for i, k in enumerate(self.keys):
3401+ #use any supllied columns
3402+ if k in self._type_hints:
3403+ column = self._type_hints[k](k,i,len(self.keys))
3404+ else:
3405+ #no column supplied, use conventions to get a column
3406+ column = conventions.get_column(k,i,len(self.keys), self.editable)
3407+
3408+ #add the created column, and remember it's key
3409+ self.append_column(column)
3410+ self.__columns_map[k] = column
3411+
3412+ #store the into for creating the list store
3413+ col_types.append(column.column_type)
3414+
3415+ #create the liststore with the designated types
3416+ #the last column is always for storing the backing dict
3417+ col_types.append(gobject.TYPE_PYOBJECT)
3418+ self.list_store = gtk.ListStore(*col_types)
3419+
3420+ for c in self.get_columns():
3421+ self.__last_sorted_col = None
3422+ c.list_store = self.list_store
3423+
3424+ #TODO: store and delete these, this is a leak
3425+ c.connect("clicked",self.__remove_sort_icon)
3426+
3427+ #connect to the edit events to rip it a
3428+ if type(c) == CheckColumn:
3429+ c.renderer.connect("toggled",self.__edited_toggled, c)
3430+ else:
3431+ c.renderer.connect("edited",self.__edited, c)
3432+
3433+
3434+ def __remove_sort_icon(self, column):
3435+ """__remove_sort_icon: internal function used in handling
3436+ display of sort buttons. Do not call this function directly.
3437+
3438+ """
3439+
3440+ if self.__last_sorted_col is not None:
3441+ if self.__last_sorted_col is not column:
3442+ self.__last_sorted_col.set_sort_indicator(False)
3443+ self.__last_sorted_col = column
3444+
3445+ __gsignals__ = {'cell-edited' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
3446+ (gobject.TYPE_PYOBJECT,gobject.TYPE_PYOBJECT,gobject.TYPE_PYOBJECT,gobject.TYPE_PYOBJECT,gobject.TYPE_PYOBJECT)),
3447+
3448+ 'selection-changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
3449+ (gobject.TYPE_PYOBJECT,))
3450+ }
3451+
3452+def __show_selected(widget, selected_rows, data=None):
3453+ """handles displaying text for test app"""
3454+
3455+ tv.get_buffer().set_text(str(selected_rows))
3456+
3457+def __on_edited(widget, cell, row, key, new_value, row_dict, tv):
3458+ """handles displaying text for test app"""
3459+
3460+ string = "row: " + str(row)
3461+ string += ", key: " + str(key)
3462+ string += ", new value: " + str(new_value)
3463+ string += "\n" + str(row_dict)
3464+ tv.get_buffer().set_text(string)
3465+
3466+if __name__ == "__main__":
3467+ """creates a test DictionaryGrid if called directly"""
3468+
3469+ dicts = [{"key?": True, "price":0.00,"tags" : "aaa bbb ccc","_foo":"bar","bing count":20},
3470+ {"ID": 11, "key?": False, "price":2.00,"tags" : "bbb ccc ddd","_foo":"bar"},
3471+ {"key?": True, "price":33.00,"tags" : "ccc ddd eee","_foo":"bar","bing count":15},
3472+ {"ID": 3, "tags" : "ddd eee fff","_foo":"bar"},
3473+ {"ID": 4, "price":5.00,"_foo":"bar"}]
3474+ #create and show a test window
3475+ win = gtk.Window(gtk.WINDOW_TOPLEVEL)
3476+ win.set_title("DictionaryGrid Test Window")
3477+ win.connect("destroy",gtk.main_quit)
3478+ win.show()
3479+
3480+ #create a top level container
3481+ vbox = gtk.VBox(False, False)
3482+ vbox.show()
3483+ win.add(vbox)
3484+
3485+ #create a test widget with test database values
3486+ grid = DictionaryGrid(dicts, editable=True)#, ["ID","tags","price","bing count","key?"])
3487+
3488+ #allow editing
3489+ #grid.editable = True
3490+
3491+ #show the control, add it to the window, and run the main loop
3492+ grid.show()
3493+ vbox.pack_start(grid, False, True)
3494+
3495+ #create a test display area
3496+ hbox = gtk.HBox(False, 5)
3497+ hbox.show()
3498+ tv = gtk.TextView()
3499+ tv.show()
3500+ grid.connect("selection-changed",__show_selected, tv)
3501+ grid.connect("cell-edited",__on_edited, tv)
3502+
3503+ hbox.pack_start(tv, False, False)
3504+ vbox.pack_end(hbox, False, False)
3505+
3506+ #run the test app
3507+ gtk.main()
3508+
3509
3510=== added file 'quickly/widgets/grid_column.py'
3511--- quickly/widgets/grid_column.py 1970-01-01 00:00:00 +0000
3512+++ quickly/widgets/grid_column.py 2011-08-09 11:40:13 +0000
3513@@ -0,0 +1,884 @@
3514+# -*- coding: utf-8 -*-
3515+### BEGIN LICENSE
3516+# Copyright (C) 2010 Rick Spencer rick.spencer@canonical.com
3517+#This program is free software: you can redistribute it and/or modify it
3518+#under the terms of the GNU General Public License version 3, as published
3519+#by the Free Software Foundation.
3520+#
3521+#This program is distributed in the hope that it will be useful, but
3522+#WITHOUT ANY WARRANTY; without even the implied warranties of
3523+#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
3524+#PURPOSE. See the GNU General Public License for more details.
3525+#
3526+#You should have received a copy of the GNU General Public License along
3527+#with this program. If not, see <http://www.gnu.org/licenses/>.
3528+### END LICENSE
3529+"""Specializations of Gtk.TreeViewColumns designer to work with
3530+DictionaryGrid and descendants.
3531+
3532+Using
3533+Grid columns are not normally created directly, but rather created
3534+automatically when a DictionaryGrid displays it's data. See the
3535+DictionaryGrid documentation for how to use type hints and conventions
3536+to control the type of column used for a key in a dictionary.
3537+
3538+Customizing
3539+The column types in this module are all descendants of gtk.TreeView, so
3540+you can use all of the gtk.TreeView methods and properties to control
3541+how a grid column looks or works.
3542+
3543+#Find a grid column and change the title
3544+for c in my_dictionary_grid.get_columns():
3545+ if c.key = my_key:
3546+ c.set_title("New Title")
3547+
3548+Extending
3549+To display data in a column with a string, such as to display words and
3550+numbers, you should extend StringColumn. Otherwise, extend gtk.TreeView
3551+directly. In either case, you will need to implement a set of functions.
3552+
3553+A Grid Column must track two different data, a "real" value, which is tracked
3554+in the dictionary for the row, and the "display" value, which is used
3555+to determine a value to display to users. For example, CheckColumn stores
3556+a real value of True, False, or None, but a display value of -1, 0, or 1,
3557+and uses the display value to set the checkbox in it's CellRenderer.
3558+
3559+Every new column must have the following function to support real
3560+and display values:
3561+
3562+display_val(self, val) - takes a real value and returns the cooresponding
3563+display value
3564+
3565+real_val(self, val) - takes a display value and returns the cooresponding
3566+real value
3567+
3568+default_display_val(self) - reutrn the value to display in the case where
3569+a row does not contain a key, value pair for the specified column. For example
3570+StringColumn returns an empty string ("")
3571+
3572+A new column type will often require a specially configured gtk.CellRenderer.
3573+If you are deriving from StringColumn, but are using a custom renderer,
3574+you need to override the _initialize_renderer method, and set the
3575+columns renderer property to the renderer. You should also connect the
3576+CellRenderer's edit signal to a function that will update the underlying
3577+dictionary when the cell is edited.
3578+
3579+
3580+For instance, a CurrencyColumn has the following implemention for
3581+_initialize_renderer:
3582+
3583+ def _initialize_renderer( self, editable, index ):
3584+ self.renderer = gtk.CellRendererSpin()
3585+ adj = gtk.Adjustment(0,-10000000000,10000000000,1)
3586+ self.renderer.set_property("adjustment", adj)
3587+ self.renderer.set_property("editable", editable)
3588+ self.renderer.set_property("digits",2)
3589+ self.renderer.connect("edited", self._cell_edited)
3590+
3591+You also need to define two class variable:
3592+1. column_type, the gobject type for the column's display value.
3593+This is needed so that the DictionaryGrid can create a ListStore
3594+
3595+2. default_filter, the grid_filter type to use in cases where a
3596+GridFilter is associate with the column.
3597+
3598+For example, CurrencyColumn defines the following class variables:
3599+column_type = gobject.TYPE_STRING
3600+default_filter = grid_filter.NumericFilterBox
3601+
3602+"""
3603+
3604+
3605+
3606+import sys
3607+import datetime
3608+import gettext
3609+from gettext import gettext as _
3610+gettext.textdomain('quickly-widgets')
3611+
3612+try:
3613+ import pygtk
3614+ pygtk.require("2.0")
3615+ import gtk
3616+ import gobject
3617+ import grid_filter
3618+
3619+
3620+except Exception, inst:
3621+ print "some dependencies for GridFilter are not available"
3622+ raise inst
3623+
3624+class GridColumn( gtk.TreeViewColumn ):
3625+ """GridColumn - Base class that provides features that is important
3626+ to all columns used in a DictionaryGrid or decendants. Currently
3627+ it's useful only to StringColumn and CheckColumn, but should make it
3628+ easier to make new "top-level" column types.
3629+ """
3630+
3631+ def __init__(self, key, index, dictionary_index, renderer, editable=True, format_function = None ):
3632+ gtk.TreeViewColumn.__init__(self, key, renderer, text=index)
3633+
3634+ self.set_clickable(True)
3635+ self.set_resizable(True)
3636+
3637+ self.index = index
3638+ self.key = key
3639+ self.dictionary_index = dictionary_index
3640+ self.list_store = None
3641+
3642+
3643+ self.connect('clicked', self.sort_rows)
3644+
3645+
3646+ def sort_rows(self, widget):
3647+ sort_order = widget.get_sort_order()
3648+
3649+ rows = [tuple(r) + (i,) for i, r in enumerate(self.list_store)]
3650+
3651+ # I NEED TO HAVE A LOOK AT THIS IF-BLOCK. At least, it needs a comment.
3652+ if sort_order == gtk.SORT_ASCENDING:
3653+ sort_order = gtk.SORT_DESCENDING
3654+ else:
3655+ sort_order = gtk.SORT_ASCENDING
3656+
3657+ self.set_sort_order(sort_order)
3658+ self.set_sort_indicator(True)
3659+
3660+ if sort_order == gtk.SORT_ASCENDING:
3661+ rows.sort(self._sort_ascending)
3662+ else:
3663+ rows.sort(self._sort_descending)
3664+
3665+ self.list_store.reorder([r[-1] for r in rows])
3666+
3667+
3668+class StringColumn( GridColumn ):
3669+
3670+ """StringColumn - Displays strings and tracks data as string.
3671+ Uses a CellRendererText for display and editing. Not typically created
3672+ directly in code, but rather created by a DictionaryGrid or descendant.
3673+
3674+ Suitable as a base class for any column that needs to display a string.
3675+
3676+ """
3677+
3678+ column_type = gobject.TYPE_STRING
3679+ __sort_order = None
3680+ default_filter = grid_filter.StringFilterBox
3681+ def __init__(self, key, index, dictionary_index, editable=True, format_function = None ):
3682+ """Creates a StringColumn
3683+
3684+ Arguments:
3685+ key - the key from the dict for the row. Also used as the title for the
3686+ column by default.
3687+
3688+ index - the position of the column in the grid.
3689+
3690+ dictionary_index - the index in the ListStore where the dictionary
3691+ for the row is stored. Typically len(dict).
3692+
3693+ editable - False if the column does not allow the user to edit the
3694+ values in the column. Defaults to True.
3695+
3696+ format_function - and optional function to handle formatting of
3697+ of the string to display. Defaults to None.
3698+ """
3699+
3700+
3701+ self._initialize_renderer(editable, index)
3702+ GridColumn.__init__( self, key, index, dictionary_index, self.renderer, editable, format_function)
3703+
3704+ if format_function is not None:
3705+ self.set_cell_data_func(self.renderer, self._on_format, format_function)
3706+
3707+ def _sort_ascending(self, x, y):
3708+ """_sort_ascending - internal sort function that sorts two values
3709+ in the column from least value to greatest value.
3710+
3711+ returns 1 if x > y, 0 if x = y, -1 if x < y
3712+
3713+ arguments:
3714+ x - the value being compared to
3715+ y - the value being compared
3716+
3717+ """
3718+
3719+ x = x[self.index]
3720+ y = y[self.index]
3721+ if x > y:
3722+ return 1
3723+ elif x == y:
3724+ return 0
3725+ elif x < y:
3726+ return -1
3727+
3728+ def _sort_descending(self, x, y):
3729+ """_sort_descending - internal sort function that sorts two values
3730+ in the column from greatest value to least value. May need to be
3731+ implimented or overriden in specialized columns.
3732+
3733+ returns 1 if x < y, 0 if x = y, -1 if x > y
3734+
3735+ arguments:
3736+ x - the value being compared to
3737+ y - the value being compared
3738+
3739+ """
3740+ x = x[self.index]
3741+ y = y[self.index]
3742+ if x > y:
3743+ return -1
3744+ elif x == y:
3745+ return 0
3746+ elif x < y:
3747+ return 1
3748+
3749+ def _on_format(self,column, cell_renderer, tree_model, iter, format_function):
3750+ """on format - internal signal handler called when the column needs
3751+ to reformat the display value. Typically called after editing or when
3752+ a value is first inserted.
3753+
3754+ arguments:
3755+ column - the index of the column, not typically needed
3756+
3757+ cell_renderer - a reference to the specific cell_renderer that is
3758+ formatting the string
3759+
3760+ tree_model - the gtk.ListStore that is the backing data for the
3761+ DictionaryGrid that contains the column.
3762+
3763+ iter - an iterator that references the row of the the DictionaryGrid
3764+ containing the cell that needs to be formatted.
3765+
3766+ format_function - a function that takes the string and performs the
3767+ actual formatting.
3768+
3769+ """
3770+
3771+ string = format_function(tree_model.get_value(iter, self.index), cell_renderer)
3772+ if string != None:
3773+ cell_renderer.set_property('text', string)
3774+
3775+ def _initialize_renderer( self, editable, index ):
3776+ """_initialize_renderer - internal function called to set up the
3777+ CellRenderer for the column.
3778+
3779+ arguments:
3780+
3781+ editable - True if the column should support user editing.
3782+
3783+ index - the position of the column in the grid
3784+
3785+ """
3786+
3787+ self.renderer = gtk.CellRendererText()
3788+ self.renderer.mode = gtk.CELL_RENDERER_MODE_EDITABLE
3789+ self.renderer.set_property("editable", editable)
3790+ self.renderer.connect("edited", self._cell_edited)
3791+
3792+ def _cell_edited(self, cellrenderertext, path, new_text, data=None):
3793+ """ _cell_edited - internal signal handler called when a
3794+ cell in the column is edited.
3795+
3796+ arguments:
3797+
3798+ cellrenderertext - the CellRenderer that was edited
3799+
3800+ path - path to the row in the treeview
3801+
3802+ new_text - the text was in the cell after the editing
3803+
3804+ """
3805+
3806+ #get an iterator that points to the edited row
3807+ if self.list_store is not None:
3808+ iter = self.list_store.get_iter(path)
3809+ #update the ListStore with the new text
3810+ self.list_store.set_value(iter, self.index, self.display_val(new_text))
3811+
3812+ dictionary = self.list_store.get_value(iter,self.dictionary_index)
3813+ dictionary[self.key] = self.real_val(new_text)
3814+
3815+ def display_val(self, val):
3816+ """display_val - takes a real value and returns the cooresponding
3817+ display value
3818+
3819+ arguments:
3820+
3821+ val - the real value to convert
3822+
3823+ """
3824+
3825+ if val == None:
3826+ return self.default_display_val()
3827+ else:
3828+ return str(val)
3829+
3830+ def real_val(self, val):
3831+ """real_val - takes a display value and returns the cooresponding
3832+ real value.
3833+
3834+ arguments:
3835+
3836+ val - the display value to convert
3837+
3838+ """
3839+
3840+ #in a StringColumn, the backing data and the display data are the same
3841+ return self.display_val(val)
3842+
3843+ def default_display_val(self):
3844+ """default_dislay_val - return the value to display in the case
3845+ where there is no real value for the column for the row.
3846+
3847+ """
3848+
3849+ #display an empty string if there is no string for the cell
3850+ return ""
3851+
3852+class CurrencyColumn( StringColumn ):
3853+ """CurrencyColumn - display data in currency format. Uses a gtk.Spinner
3854+ to display data and support editing if enabled. Store real values as float.
3855+
3856+ Inherits from StringColumn.
3857+
3858+ """
3859+
3860+ column_type = gobject.TYPE_STRING
3861+ default_filter = grid_filter.NumericFilterBox
3862+ def __init__(self, key, index,dictionary_index, editable=True ):
3863+ """Creates a CurrencyColumn
3864+
3865+ Arguments:
3866+ key - the key from the dict for the row. Also used as the title for the
3867+ column by default.
3868+
3869+ index - the position of the column in the grid.
3870+
3871+ dictionary_index - the index in the ListStore where the dictionary
3872+ for the row is stored. Typically len(dict).
3873+
3874+ editable - False if the column does not allow the user to edit the
3875+ values in the column. Defaults to True.
3876+
3877+ """
3878+
3879+ StringColumn.__init__( self, key, index, dictionary_index, editable, self._currency_format)
3880+
3881+ def _initialize_renderer( self, editable, index ):
3882+ """_initialize_renderer - internal function called to set up the
3883+ CellRenderer for the column.
3884+
3885+ arguments:
3886+
3887+ editable - True if the column should support user editing.
3888+
3889+ index - the position of the column in the grid
3890+
3891+ """
3892+
3893+ self.renderer = gtk.CellRendererSpin()
3894+ adj = gtk.Adjustment(0,-10000000000,10000000000,1)
3895+ self.renderer.set_property("adjustment", adj)
3896+ self.renderer.set_property("editable", editable)
3897+ self.renderer.set_property("digits",2)
3898+ self.renderer.connect("edited", self._cell_edited)
3899+
3900+ #make sure the value was edited to something that can be
3901+ #turned into an int
3902+ try:
3903+ float(new_text)
3904+ except:
3905+ return
3906+
3907+ #get an iterator that points to the edited row
3908+ if self.list_store is not None:
3909+
3910+ iter = self.list_store.get_iter(path)
3911+ #update the ListStore with the new text
3912+ self.list_store.set_value(iter, self.index, self.display_val(new_text))
3913+ dictionary = self.list_store.get_value(iter,self.dictionary_index)
3914+ dictionary[self.key] = self.real_val(new_text)
3915+
3916+
3917+ def display_val(self, val):
3918+ """display_val - takes a real value and returns the cooresponding
3919+ display value
3920+
3921+ arguments:
3922+
3923+ val - the real value to convert
3924+
3925+ """
3926+
3927+ try:
3928+ return str(float(val))
3929+ except:
3930+ return ""
3931+
3932+
3933+ def real_val(self, val):
3934+ """real_val - takes a display value and returns the cooresponding
3935+ real value.
3936+
3937+ arguments:
3938+
3939+ val - the display value to convert
3940+
3941+ """
3942+
3943+ try:
3944+ return float(val)
3945+ except:
3946+ return 0.0
3947+
3948+ def default_display_val(self):
3949+ """default_dislay_val - return the value to display in the case
3950+ where there is no real value for the column for the row.
3951+
3952+ """
3953+
3954+ return ""
3955+
3956+ def _sort_ascending(self, x, y):
3957+ x = x[self.index]
3958+ y = y[self.index]
3959+ if x == "" and y == "":
3960+ return 0
3961+ if x == "" and y != "":
3962+ return -1
3963+ if x != "" and y == "":
3964+ return 1
3965+
3966+ x = float(x)
3967+ y = float(y)
3968+ if x > y:
3969+ return 1
3970+ elif x == y:
3971+ return 0
3972+ elif x < y:
3973+ return -1
3974+
3975+ def _sort_descending(self, x, y):
3976+ x = x[self.index]
3977+ y = y[self.index]
3978+ if x == "" and y == "":
3979+ return 0
3980+ if x == "" and y != "":
3981+ return 1
3982+ if x != "" and y == "":
3983+ return -1
3984+
3985+ x = float(x)
3986+ y = float(y)
3987+ if x > y:
3988+ return -1
3989+ elif x == y:
3990+ return 0
3991+ elif x < y:
3992+ return 1
3993+
3994+ def _currency_format(self, val, cell_renderer):
3995+ try:
3996+ return "%.2f" % float(val)
3997+ except:
3998+ return ""
3999+
4000+class TagsColumn( StringColumn ):
4001+ """TagsColumn - A specialization of a StringColumn that differs
4002+ only in that it uses a TagsFilterBox for filtering in any
4003+ attached GridFilter.
4004+
4005+ """
4006+
4007+ column_type = gobject.TYPE_STRING
4008+ default_filter = grid_filter.TagsFilterBox
4009+
4010+
4011+class IntegerColumn( StringColumn ):
4012+ """IntegerColumn - display data in Integer format. Uses a gtk.Spinner
4013+ to display data and support editing if enabled. Store real values as int.
4014+
4015+ Inherits from StringColumn.
4016+
4017+ """
4018+
4019+ column_type = gobject.TYPE_STRING
4020+ default_filter = grid_filter.IntegerFilterBox
4021+
4022+ def __init__(self, key, index, dictionary_index, editable=True ):
4023+ """Creates an IntegerColumn
4024+
4025+ Arguments:
4026+ key - the key from the dict for the row. Also used as the title for the
4027+ column by default.
4028+
4029+ index - the position of the column in the grid.
4030+
4031+ dictionary_index - the index in the ListStore where the dictionary
4032+ for the row is stored. Typically len(dict).
4033+
4034+ editable - False if the column does not allow the user to edit the
4035+ values in the column. Defaults to True.
4036+
4037+ """
4038+
4039+ StringColumn.__init__( self, key, index, dictionary_index, editable)
4040+
4041+ def _initialize_renderer( self, editable, index ):
4042+ self.renderer = gtk.CellRendererSpin()
4043+ adj = gtk.Adjustment(0,-10000000000,10000000000,1)
4044+ self.renderer.set_property("adjustment", adj)
4045+ self.renderer.set_property("editable", editable)
4046+ self.renderer.connect("edited", self._cell_edited)
4047+
4048+ def _cell_edited(self, cellrenderertext, path, new_text, data=None):
4049+ """ __edited - internal signal handler.
4050+ Updates the dictionary if a cell in the Treeview
4051+ has been edited.
4052+
4053+ """
4054+
4055+ #make sure the value was edited to something that can be
4056+ #turned into an int
4057+ try:
4058+ int(new_text)
4059+ except:
4060+ return
4061+
4062+ #get an iterator that points to the edited row
4063+ if self.list_store is not None:
4064+
4065+ iter = self.list_store.get_iter(path)
4066+ #update the ListStore with the new text
4067+ self.list_store.set_value(iter, self.index, self.display_val(new_text))
4068+ dictionary = self.list_store.get_value(iter,self.dictionary_index)
4069+ dictionary[self.key] = self.real_val(new_text)
4070+
4071+
4072+ def display_val(self, val):
4073+ """display_val - takes a real value and returns the cooresponding
4074+ display value
4075+
4076+ arguments:
4077+
4078+ val - the real value to convert
4079+
4080+ """
4081+
4082+ try:
4083+ return str(int(val))
4084+ except:
4085+ return ""
4086+
4087+ def real_val(self, val):
4088+ """real_val - takes a display value and returns the cooresponding
4089+ real value.
4090+
4091+ arguments:
4092+
4093+ val - the display value to convert
4094+
4095+ """
4096+
4097+ try:
4098+ return int(val)
4099+ except:
4100+ return 0
4101+
4102+
4103+ def default_display_val(self):
4104+ """default_dislay_val - return the value to display in the case
4105+ where there is no real value for the column for the row.
4106+
4107+ """
4108+
4109+ return ""
4110+
4111+ def _sort_ascending(self, x, y):
4112+ x = x[self.index]
4113+ y = y[self.index]
4114+ if x == "" and y == "":
4115+ return 0
4116+ if x == "" and y != "":
4117+ return -1
4118+ if x != "" and y == "":
4119+ return 1
4120+
4121+ x = int(x)
4122+ y = int(y)
4123+ if x > y:
4124+ return 1
4125+ elif x == y:
4126+ return 0
4127+ elif x < y:
4128+ return -1
4129+
4130+ def _sort_descending(self, x, y):
4131+ x = x[self.index]
4132+ y = y[self.index]
4133+ if x == "" and y == "":
4134+ return 0
4135+ if x == "" and y != "":
4136+ return 1
4137+ if x != "" and y == "":
4138+ return -1
4139+
4140+ x = int(x)
4141+ y = int(y)
4142+ if x > y:
4143+ return -1
4144+ elif x == y:
4145+ return 0
4146+ elif x < y:
4147+ return 1
4148+
4149+
4150+class CheckColumn( GridColumn ):
4151+ """CheckColumn - display data as checkboxes. Store real values as bool.
4152+
4153+ Inherits from gtk.TreeViewColumn.
4154+
4155+ """
4156+
4157+ column_type = gobject.TYPE_INT
4158+ default_filter = grid_filter.CheckFilterBox
4159+
4160+ def __init__(self, key, index, dictionary_index, editable=True, format_function = None ):
4161+ """Creates a StringColumn
4162+
4163+ Arguments:
4164+ key - the key from the dict for the row. Also used as the title for the
4165+ column by default.
4166+
4167+ index - the position of the column in the grid.
4168+
4169+ dictionary_index - the index in the ListStore where the dictionary
4170+ for the row is stored. Typically len(dict).
4171+
4172+ editable - False if the column does not allow the user to edit the
4173+ values in the column. Defaults to True.
4174+
4175+ format_function - and optional function to handle formatting of
4176+ of the string to display. Defaults to None.
4177+ """
4178+
4179+ # self.key is set in GridColumn, but needs to be set for tests to pass. Fix.
4180+ self.key = key
4181+ self._initialize_renderer(editable, index)
4182+ GridColumn.__init__( self, key, index, dictionary_index, self.renderer, editable, format_function)
4183+
4184+ self.set_cell_data_func(self.renderer, self._on_format)
4185+ self.extra_format_function = format_function
4186+
4187+ def _sort_ascending(self, x, y):
4188+ x = x[self.index]
4189+ y = y[self.index]
4190+ return y - x
4191+
4192+ def _sort_descending(self, x, y):
4193+ x = x[self.index]
4194+ y = y[self.index]
4195+ return x - y
4196+
4197+ def _on_format(self,column, cell_renderer, tree_model, iter):
4198+ cell_val = tree_model.get_value(iter, self.index)
4199+ cell_renderer.set_property('inconsistent', False)
4200+ if cell_val == 1:
4201+ cell_renderer.set_active(True)
4202+ elif cell_val == 0:
4203+ cell_renderer.set_active(False)
4204+ else:
4205+ cell_renderer.set_property('inconsistent', True)
4206+ #TODO: show it checked, unchecked, inconsistent ... based (-1,0,1)
4207+ if self.extra_format_function != None:
4208+ self.extra_format_function()
4209+
4210+ def _initialize_renderer( self, editable, index ):
4211+ self.renderer = gtk.CellRendererToggle()
4212+ self.renderer.set_property("activatable", editable)
4213+ col = gtk.TreeViewColumn(self.key, self.renderer, active=index)
4214+ self.renderer.connect("toggled", self.toggled)
4215+
4216+ def toggled(self, cell, path, data=None):
4217+ #get an iterator that points to the edited row
4218+ new_val = not cell.get_active()
4219+ if self.list_store is not None:
4220+ iter = self.list_store.get_iter(path)
4221+ #update the ListStore with the new text
4222+ self.list_store.set_value(iter, self.index, new_val)
4223+
4224+ dictionary = self.list_store.get_value(iter,self.dictionary_index)
4225+ dictionary[self.key] = new_val
4226+
4227+ def display_val(self, val):
4228+ """display_val - takes a real value and returns the cooresponding
4229+ display value
4230+
4231+ arguments:
4232+
4233+ val - the real value to convert
4234+
4235+ """
4236+
4237+ if type(val) is bool:
4238+ if val:
4239+ return 1
4240+ else:
4241+ return 0
4242+ elif type(val) is str:
4243+ if val.lower() == _("yes"):
4244+ return 1
4245+ else:
4246+ return 0
4247+ elif type(val) is None:
4248+ return self.default_display_val()
4249+ else:
4250+ return bool(val)
4251+
4252+ def default_display_val(self):
4253+ """default_dislay_val - return the value to display in the case
4254+ where there is no real value for the column for the row.
4255+
4256+ """
4257+
4258+ return -1
4259+
4260+
4261+ def real_val(self, val):
4262+ """real_val - takes a display value and returns the cooresponding
4263+ real value.
4264+
4265+ arguments:
4266+
4267+ val - the display value to convert
4268+
4269+ """
4270+
4271+ if type(val) is type(True):
4272+ return val
4273+ elif type(val) is type("a"):
4274+ if val.lower() == "yes":
4275+ return True
4276+ else:
4277+ return False
4278+ else:
4279+ return bool(val)
4280+
4281+class DateColumn( StringColumn ):
4282+ """DateColumn - display data in date format. Uses a gtk.Calendar
4283+ to display data and support editing if enabled. Store real values as tuple.
4284+
4285+ Inherits from StringColumn.
4286+
4287+ """
4288+
4289+ column_type = gobject.TYPE_STRING
4290+ default_filter = grid_filter.DateFilterBox
4291+
4292+ def __init__(self, key, index,dictionary_index, editable=True ):
4293+ """Creates a Date
4294+
4295+ Arguments:
4296+ key - the key from the dict for the row. Also used as the title for the
4297+ column by default.
4298+ index - the position of the column in the grid.
4299+
4300+ dictionary_index - the index in the ListStore where the dictionary
4301+ for the row is stored. Typically len(dict).
4302+
4303+ editable - False if the column does not allow the user to edit the
4304+ values in the column. Defaults to True.
4305+
4306+ """
4307+ self._editable = editable
4308+ StringColumn.__init__( self, key, index, dictionary_index, editable)
4309+
4310+ def _initialize_renderer( self, editable, index ):
4311+ """_initialize_renderer - internal function called to set up the
4312+ CellRenderer for the column.
4313+
4314+ arguments:
4315+
4316+ editable - True if the column should support user editing.
4317+
4318+ index - the position of the column in the grid
4319+
4320+ """
4321+
4322+ self.renderer = CellRendererDate()
4323+ self.renderer.set_property('editable',self._editable)
4324+ self.renderer.connect("edited", self._cell_edited)
4325+
4326+class CellRendererDate(gtk.CellRendererText):
4327+ def __init__(self):
4328+ gtk.CellRendererText.__init__(self)
4329+ self.date_format = '%Y-%m-%d'
4330+
4331+ self.calendar_window = None
4332+ self.calendar = None
4333+
4334+ def _create_calendar(self, treeview):
4335+ self.calendar_window = gtk.Dialog(parent=treeview.get_toplevel())
4336+ self.calendar_window.action_area.hide()
4337+ self.calendar_window.set_decorated(False)
4338+ self.calendar_window.set_property('skip-taskbar-hint', True)
4339+
4340+ self.calendar = gtk.Calendar()
4341+ self.calendar.display_options(gtk.CALENDAR_SHOW_DAY_NAMES | gtk.CALENDAR_SHOW_HEADING)
4342+ self.calendar.connect('day-selected-double-click', self._day_selected, None)
4343+ self.calendar.connect('key-press-event', self._day_selected)
4344+ self.calendar.connect('focus-out-event', self._selection_cancelled)
4345+ self.calendar_window.set_transient_for(None) # cancel the modality of dialog
4346+ self.calendar_window.vbox.pack_start(self.calendar)
4347+
4348+ # necessary for getting the (width, height) of calendar_window
4349+ self.calendar.show()
4350+ self.calendar_window.realize()
4351+
4352+ def do_start_editing(self, event, treeview, path, background_area, cell_area, flags):
4353+ if not self.get_property('editable'):
4354+ return
4355+
4356+ if not self.calendar_window:
4357+ self._create_calendar(treeview)
4358+
4359+ # select cell's previously stored date if any exists - or today
4360+ if self.get_property('text'):
4361+ date = datetime.datetime.strptime(self.get_property('text'), self.date_format)
4362+ else:
4363+ date = datetime.datetime.today()
4364+
4365+ self.calendar.freeze() # prevent flicker
4366+ (year, month, day) = (date.year, date.month - 1, date.day) # datetime's month starts from one
4367+ self.calendar.select_month(int(month), int(year))
4368+ self.calendar.select_day(int(day))
4369+ self.calendar.thaw()
4370+
4371+ # position the popup below the edited cell (and try hard to keep the popup within the toplevel window)
4372+ (tree_x, tree_y) = treeview.get_bin_window().get_origin()
4373+ (tree_w, tree_h) = treeview.window.get_geometry()[2:4]
4374+ (calendar_w, calendar_h) = self.calendar_window.window.get_geometry()[2:4]
4375+ x = tree_x + min(cell_area.x, tree_w - calendar_w + treeview.get_visible_rect().x)
4376+ y = tree_y + min(cell_area.y, tree_h - calendar_h + treeview.get_visible_rect().y)
4377+ self.calendar_window.move(x, y)
4378+
4379+ response = self.calendar_window.run()
4380+ self.calendar_window.hide()
4381+ if response == gtk.RESPONSE_OK:
4382+ (year, month, day) = self.calendar.get_date()
4383+ date = datetime.date(year, month + 1, day).strftime(self.date_format) # gtk.Calendar's month starts from zero
4384+ self.emit('edited', path, date)
4385+
4386+ return None # don't return any editable, our gtk.Dialog did the work already
4387+
4388+ def _day_selected(self, calendar, event):
4389+ # event == None for day selected via doubleclick
4390+ if not event or event.type == gtk.gdk.KEY_PRESS and gtk.gdk.keyval_name(event.keyval) == 'Return':
4391+ self.calendar_window.response(gtk.RESPONSE_OK)
4392+ return True
4393+
4394+ def _selection_cancelled(self, calendar, event):
4395+ self.calendar_window.response(gtk.RESPONSE_CANCEL)
4396+ return True
4397+
4398
4399=== added file 'quickly/widgets/grid_filter.py'
4400--- quickly/widgets/grid_filter.py 1970-01-01 00:00:00 +0000
4401+++ quickly/widgets/grid_filter.py 2011-08-09 11:40:13 +0000
4402@@ -0,0 +1,845 @@
4403+# -*- coding: utf-8 -*-
4404+### BEGIN LICENSE
4405+# Copyright (C) 2010 Rick Spencer rick.spencer@canonical.com
4406+#This program is free software: you can redistribute it and/or modify it
4407+#under the terms of the GNU General Public License version 3, as published
4408+#by the Free Software Foundation.
4409+#
4410+#This program is distributed in the hope that it will be useful, but
4411+#WITHOUT ANY WARRANTY; without even the implied warranties of
4412+#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
4413+#PURPOSE. See the GNU General Public License for more details.
4414+#
4415+#You should have received a copy of the GNU General Public License along
4416+#with this program. If not, see <http://www.gnu.org/licenses/>.
4417+### END LICENSE
4418+
4419+"""Widgets and Objects for filtering a DictionaryGrid
4420+GridFilter is as gtk.VBox that provides filtering UI for a
4421+DictionaryGrid. Provides multiple filters, and choosing
4422+between "And" and "Or" filtering. Provides default filters appropriate
4423+for each column.
4424+
4425+GridFilter row is a gtk.HBox that is a container for displaying FilterCombos.
4426+
4427+FilterCombos display a filter and handle filtering of rows to
4428+display and hide in the associated DictionaryGrid. The GridColumns
4429+determine the type of filter to use by default.
4430+
4431+Using
4432+#create a DictionaryGrid and use it to create a GridFilter
4433+grid = DictionaryGrid(dictionaries=dicts)
4434+grid.show()
4435+
4436+filt = GridFilter(grid)
4437+filt.show()
4438+
4439+Configuring
4440+#Create a custom filter combo and use it for a column
4441+#the filter functions should take a stored value and a value to filter against
4442+for each row and return True if the results should cause the row to
4443+be displayed and False if the row should not be displayed
4444+
4445+blank_filter = BlankFilterBox()
4446+blank_filter.append("=",custom_equals_function )
4447+blank_filter.append("<>",custom_no_equals_function )
4448+
4449+filter_hints = {"status":blank_filter}
4450+filt = GridFilter(grid, filter_hints)
4451+filt.show()
4452+
4453+Extending
4454+A custom filter combo is easiest to create by deriving from BlankFilterBox
4455+and using the BlankFilterBox.append function to display new filters.
4456+
4457+class StringFilterBox( BlankFilterBox ):
4458+ def __init__(self):
4459+ BlankFilterBox.__init__(self)
4460+ self.append("contains",lambda x,y: x.find(y) > -1)
4461+ self.append("does not contain",lambda x,y: x.find(y) == -1)
4462+ self.append("starts with",lambda x,y: x.startswith(y))
4463+ self.append("ends with",lambda x,y: x.endswith(y))
4464+
4465+Filter UI could be created to use widgets other than gtk.Combo so long as
4466+the widget has a get_model function that returns a gtk.ListStore with
4467+filtering functions stored as the last value (column) in the liststore.
4468+
4469+"""
4470+
4471+import sys
4472+import datetime
4473+import gettext
4474+from gettext import gettext as _
4475+gettext.textdomain('quickly-widgets')
4476+
4477+try:
4478+ import pygtk
4479+ pygtk.require("2.0")
4480+ import gtk
4481+ import gobject
4482+
4483+except Exception, inst:
4484+ print "some dependencies for GridFilter are not available"
4485+ raise inst
4486+
4487+class GridFilter( gtk.VBox ):
4488+ """GridFilter: A widget that provides a user interface for filtering a
4489+ treeview. A GridFilter hosts one ore more GridRows, which in turn host
4490+ an active filter.
4491+
4492+ """
4493+ def __init__(self, grid, filter_hints={} ):
4494+ """Create a GridFilter for filtering an associated treeview.
4495+ This class is used by BugsPane.
4496+
4497+ arguments:
4498+ grid - A DictionaryGrid to filter
4499+
4500+ options arguments:
4501+ filter_hints - a dictionary of column keys to FilterCombo types to
4502+ provide custom filtering.
4503+
4504+ """
4505+
4506+ gtk.VBox.__init__( self, False, 10 )
4507+ self.grid = grid
4508+ self.store = grid.get_model()
4509+ self.filter_hints = filter_hints
4510+
4511+ #create the and/or radio buttons
4512+ radio_box = gtk.HBox(False,2)
4513+ radio_box.show()
4514+ self.pack_start(radio_box, False, False)
4515+ self.and_button = gtk.RadioButton(None,_("M_atch All of the following"), True)
4516+ self.and_button.show()
4517+ self.and_button.connect("toggled",self.__filter_changed)
4518+ radio_box.pack_start(self.and_button, False, False)
4519+ or_button = gtk.RadioButton(self.and_button,_("Match any _of the following"), True)
4520+ or_button.show()
4521+ radio_box.pack_start(or_button, False, False)
4522+ self.rows = []
4523+ self._add_row(self)
4524+
4525+ def _add_row(self, widget, data=None):
4526+ """_add_row: internal signal handler that receives a request
4527+ from a FilterRow to add a new row. Sets up and adds the row to the GridFilter.
4528+
4529+ Do not call directly
4530+ """
4531+
4532+ #TODO: I suppose this is leaking references to filter rows
4533+ row = FilterRow(self.grid, len(self.rows) > 0, self.filter_hints )
4534+ row.connect('add_row_requested',self._add_row)
4535+ row.connect('remove_row_requested',self._remove_row)
4536+ row.connect('refilter_requested',self.__filter_changed)
4537+ row.show()
4538+ self.rows.append(row)
4539+ self.pack_start(row, False, False)
4540+
4541+ def _remove_row(self, widget, data=None):
4542+ """_remove_row: internal signal handler that receives a
4543+ request from a FilterRow to remove itself from the GridFilter.
4544+
4545+ Do not call directly
4546+ """
4547+
4548+ self.rows.remove(widget)
4549+ self.remove(widget)
4550+ self.__filter_changed(self)
4551+
4552+ def __filter_changed(self,widget, data=None):
4553+ """__filter_changed: internal signal handler that handles
4554+ requests to reapply the fitlers in the GridFilter's FilterRows.
4555+
4556+ """
4557+
4558+ filt = self.store.filter_new()
4559+ sort_mod = gtk.TreeModelSort(filt)
4560+ filt.set_visible_func(self.__filter_func, data )
4561+ filt.refilter()
4562+ self.grid.set_model(sort_mod)
4563+
4564+ def __filter_func(self, model, iter, data):
4565+ """filter_func: called for each row in the treeview model in response to
4566+ a __filter_changed signal. Determines for each row whether it should be
4567+ visible based on the FilterRows in the GridFilter.
4568+
4569+
4570+ Do not call directly
4571+ """
4572+ #determine whether this is an "and" or an "or" filter
4573+ match_all = self.and_button.get_active()
4574+
4575+ for r in self.rows:
4576+ rez = r.is_match(iter.copy(),model) #check the result of each filter
4577+ if match_all: #if it's an "and" filter
4578+ if not rez: #and if the filter does not match
4579+ return False #then the row should not be visible
4580+ else: #but if it's an "or" filter
4581+ if rez: #and it is a match
4582+ return True #return that the row should be visible
4583+ return match_all #all filters match an "and" or none matched an "or"
4584+
4585+class FilterRow( gtk.HBox):
4586+ """FilterRow: A widget that displays a single filter in a GridFilter.
4587+ Typically, this class will not be used directly, but only via a GridFilter.
4588+
4589+ """
4590+ wait_for_input = False
4591+
4592+ def __init__(self, grid, removable=True, filter_hints={}):
4593+ """Create a FilterRow to be used in a GridFilter.
4594+ A FitlerRow is comprised of a combo that lists the treeview headings.
4595+ The combo stores the string to display for the heading, as well as
4596+ the widget that is used to filter each heading. When the user changes
4597+ the value in the dropdown, the FilterRow retrieves the correct filter from
4598+ the combo, and displays that filter to the user.
4599+
4600+ The FilterRow also handles offering UI for the user to add and remove
4601+ FilterRows for the GridFilter containing it.
4602+
4603+ grid -
4604+
4605+ keyword arguments:
4606+ removable - True if the row should be able to be removed from the GridFilter
4607+ Typicall False for the first row.
4608+
4609+ filter_hints - a dictionary of keys mapped to custom filters to apply to the
4610+ column designated by the key
4611+
4612+ """
4613+
4614+ gtk.HBox.__init__( self, False, 10 )
4615+ self.store = grid.get_model()
4616+ self.grid = grid
4617+
4618+ heading_combo_store = gtk.ListStore(gobject.TYPE_STRING,gobject.TYPE_PYOBJECT,gobject.TYPE_INT)
4619+
4620+ #apply default combos
4621+ for i, k in enumerate(self.grid.keys):
4622+ if k in filter_hints:
4623+ filt_combo = filter_hints[k]
4624+ else:
4625+ filt_combo = grid.get_columns()[i].default_filter()
4626+
4627+ column_title = grid.get_columns()[i].get_title()
4628+ heading_combo_store.append([column_title,filt_combo,i])
4629+
4630+ filt_combo.connect("changed",self.__filter_changed)
4631+ filt_combo.show()
4632+
4633+ self.column_combo = gtk.ComboBox(heading_combo_store)
4634+ cell = gtk.CellRendererText()
4635+ self.column_combo.pack_start(cell, True)
4636+ self.column_combo.add_attribute(cell, 'text', 0)
4637+
4638+ self.filter_space = gtk.HBox(False,1)
4639+ self.filter_space.show()
4640+
4641+ self.column_combo.show()
4642+ vb = gtk.VBox(False, 5)
4643+ vb.show()
4644+ vb.pack_start(self.column_combo, True, False)
4645+ self.pack_start(vb,False, False)
4646+ self.column_combo.connect("changed",self.__column_changed)
4647+ self.column_combo.set_active(0)
4648+
4649+ self.pack_start(self.filter_space, False, False)
4650+
4651+ button_box = gtk.HBox(False,2)
4652+ button_box.show()
4653+ self.pack_start(button_box,False,False)
4654+
4655+ #add a button that can create a new row in the grid filter
4656+ add_button = gtk.Button(stock = gtk.STOCK_ADD)
4657+ add_button.show()
4658+ vb2 = gtk.VBox(False, 5)
4659+ vb2.show()
4660+ vb2.pack_start(add_button, True, False)
4661+ button_box.pack_start(vb2, False, False)
4662+ add_button.connect("clicked",lambda x: self.emit('add_row_requested',self) )
4663+
4664+ #add a button to remove the row if applicable
4665+ if removable:
4666+ rm_button = gtk.Button(stock = gtk.STOCK_REMOVE)
4667+ rm_button.show()
4668+ vb3 = gtk.VBox(False, 5)
4669+ vb3.show()
4670+ vb3.pack_start(rm_button, True, False)
4671+ rm_button.connect('clicked', lambda x: self.emit("remove_row_requested",self) )
4672+ button_box.pack_start(vb3)
4673+
4674+ __gsignals__ = {'add_row_requested' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
4675+ (gobject.TYPE_PYOBJECT,)),
4676+ 'remove_row_requested' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
4677+ (gobject.TYPE_PYOBJECT,)),
4678+ 'refilter_requested' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
4679+ (gobject.TYPE_PYOBJECT,))
4680+ }
4681+
4682+ def __column_changed(self, widget, data = None):
4683+ """column_changed: internal signal handler for the user changing
4684+ the combo for the column that they wish to apply the filter to.
4685+ removes the other filter widgets and replaces them widgets stored in
4686+ the filter widget.
4687+
4688+ """
4689+
4690+ if len(self.filter_space.get_children()) > 0:
4691+ self.filter_space.remove(self.filter_space.get_children()[0])
4692+ iter = widget.get_model().get_iter(widget.get_active())
4693+ filter_box = widget.get_model().get_value(iter,1)
4694+ self.filter_space.pack_start(filter_box, False, False)
4695+
4696+ def __filter_changed(self,widget, data=None):
4697+ """filter_changed: internal signal handler called when the FilterRow has changed.
4698+ Used to tell the GridFilter to refilter. Only emits if the filter is
4699+ active (a heading is selected in the combo and the user has entered
4700+ text in the filter.
4701+
4702+ """
4703+
4704+ #if not self.wait_for_input:
4705+ #if self.__get_current_filter_combo().get_active > -1:
4706+ self.emit('refilter_requested',self)
4707+
4708+ def __get_current_filter_combo(self):
4709+ """get_current_filter_combo: internal function that retrieves
4710+ the combobox stored for the filter for the user selected treeview column.
4711+
4712+ """
4713+ iter = self.column_combo.get_model().get_iter(self.column_combo.get_active())
4714+ return self.column_combo.get_model().get_value(iter,1)
4715+
4716+ def is_match(self, store_iter, model):
4717+ """is_match: returns true if the filter set in the FilterRow matches
4718+ the value specified in the column and row. Used to determine whether
4719+ to hide or show a row.
4720+
4721+ Typically called for each treeview row and each FilterRow in response
4722+ to a change in one of the FilterRows.
4723+
4724+ arguments:
4725+ store_iter: the iter pointing the the row in the treeview to test
4726+ model: the treeview model containing the rows being tested
4727+
4728+ """
4729+ col_iter = self.column_combo.get_model().get_iter(self.column_combo.get_active())
4730+ filter_widget = self.column_combo.get_model().get_value(col_iter,1)
4731+ treeview_col = self.column_combo.get_model().get_value(col_iter,2)
4732+
4733+ orig_val = model.get_value(store_iter.copy(), treeview_col)
4734+ return filter_widget.filter(orig_val)
4735+
4736+class BlankFilterBox( gtk.HBox):
4737+ """BlankFilterBox provides a base class for FilterCombos, as
4738+ well as an empty combo that can be used without subclassing
4739+ by calling BlankFilterBox.append
4740+
4741+ """
4742+ __gsignals__ = {'changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
4743+ (gobject.TYPE_PYOBJECT,)),
4744+ }
4745+
4746+
4747+ def __init__(self):
4748+ """create a BlankFilterBox
4749+
4750+ """
4751+
4752+ gtk.HBox.__init__(self,False)
4753+ self.__combo_store = gtk.ListStore(gobject.TYPE_STRING,gobject.TYPE_PYOBJECT)
4754+ self.combo = gtk.ComboBox(self.__combo_store)
4755+ cell = gtk.CellRendererText()
4756+ self.combo.pack_start(cell, True)
4757+ self.combo.add_attribute(cell, 'text', 0)
4758+ self.combo.show()
4759+ self.combo.connect("changed",self.__changed)
4760+ self.entry = gtk.Entry()
4761+ self.entry.show()
4762+ self.entry.connect("changed",self.__changed)
4763+ self.pack_start(self.combo, False, False)
4764+ self.pack_start(self.entry)
4765+
4766+ def filter(self, orig_val):
4767+ if self.combo.get_active() == -1:
4768+ return True
4769+ filt_iter = self.combo.get_model().get_iter(self.combo.get_active())
4770+ filt_func = self.combo.get_model().get_value(filt_iter,1)
4771+ target_val = self.entry.get_text()
4772+ return filt_func(orig_val, self.entry.get_text())
4773+
4774+ def __changed(self, widget, data=None):
4775+ self.emit("changed",data)
4776+
4777+ def append(self, text, func):
4778+ """append: adds a row to the FilterCombo that includes a
4779+ string to display in the combo, and a function to determine
4780+ if a row should displayed or hidden by the filter.
4781+
4782+ func should take a value indicated by text, and a value entered by
4783+ the user in the supplied gtk.TextEntry, and return True if the
4784+ row should be displayed or False if it should be hidden.
4785+
4786+ """
4787+
4788+ self.__combo_store.append([text, func])
4789+
4790+class StringFilterBox( BlankFilterBox ):
4791+ """StringFilterBox: A default string filter class for use in a FilterRow.
4792+
4793+ Lets the user specify if the row should be displayed based on
4794+ containing, not containing, starting with, or ending with a user specified
4795+ string.
4796+
4797+
4798+ """
4799+ def __init__(self):
4800+ """create a StringFilterBox.
4801+
4802+ """
4803+
4804+ BlankFilterBox.__init__(self)
4805+ self.append(_("contains"),self.contains)
4806+ self.append(_("does not contain"),self.not_contains)
4807+ self.append(_("starts with"),self.starts_with)
4808+ self.append(_("ends with"),self.ends_with)
4809+
4810+ def contains(self, orig_val, target_val):
4811+ if len(self.entry.get_text()) == 0 or orig_val is None:
4812+ return True
4813+ return orig_val.find(target_val) > -1
4814+
4815+ def not_contains(self, orig_val, target_val):
4816+ if len(target_val) == 0 or orig_val is None:
4817+ return True
4818+ return orig_val.find(target_val) == -1
4819+
4820+ def starts_with(self, orig_val, target_val):
4821+ if len(target_val) == 0 or orig_val is None:
4822+ return True
4823+ return orig_val.startswith(target_val)
4824+
4825+ def ends_with(self, orig_val, target_val):
4826+ if len(target_val) == 0 or orig_val is None:
4827+ return True
4828+ return orig_val.endswith(target_val)
4829+
4830+
4831+class TagsFilterBox( BlankFilterBox ):
4832+ """TagsFilterBox: A default tag filter class for use in a FilterRow.
4833+
4834+ Lets the user specify if the row should be displayed based on
4835+ containing a one tag or all tags. Assumes tags are seperated by
4836+ spaces.
4837+
4838+ """
4839+
4840+ def __init__(self):
4841+ BlankFilterBox.__init__(self)
4842+ self.append(_("has any of these tags"), self._filter_any)
4843+ self.append(_("has all of these tags"), self._filter_all)
4844+ self.append(_("does not have one of these tags"), self._filter_not)
4845+ self.append(_("does not have any of these tags"), self._filter_not_all)
4846+
4847+ def _filter_any(self, orig_val, target_val):
4848+ """
4849+ _filter_any: filter function that hides rows
4850+ if none of the tags supplied in "bugs_tags_s" are found
4851+ in the gtk.TextEntry.
4852+
4853+ Do not call directly
4854+
4855+ """
4856+
4857+ if len(target_val) == 0:
4858+ return True
4859+
4860+ tags_on_bug = orig_val.split()
4861+ tags_in_filter = target_val.split()
4862+
4863+ for tag in tags_in_filter:
4864+ if tag in tags_on_bug:
4865+ return True
4866+ return False
4867+
4868+ def _filter_all(self, orig_val, target_val):
4869+ """
4870+ _filter_any: filter function that hides rows
4871+ if not all of the tags supplied in "bugs_tags_s" are found
4872+ in the gtk.TextEntry.
4873+
4874+ Do not call directly
4875+
4876+ """
4877+ if len(target_val) == 0:
4878+ return True
4879+
4880+ tags_on_bug = orig_val.split()
4881+ tags_in_filter = self.entry.get_text().split()
4882+
4883+ for tag in tags_in_filter:
4884+ if tag not in tags_on_bug:
4885+ return False
4886+ return True
4887+
4888+ def _filter_not(self, orig_val, target_val):
4889+ """
4890+ _filter_not: filter function that hides rows
4891+ if one of the tags supplied in "bugs_tags_s" are found
4892+ in the gtk.TextEntry.
4893+
4894+ Do not call directly
4895+
4896+ """
4897+ if len(target_val) == 0:
4898+ return True
4899+
4900+ tags_on_bug = orig_val.split()
4901+ tags_in_filter = target_val.split()
4902+
4903+ for tag in tags_in_filter:
4904+ if tag not in tags_on_bug:
4905+ return True
4906+ return False
4907+
4908+ def _filter_not_all(self, orig_val, target_val):
4909+ """
4910+ _filter_not all: filter function that hides rows
4911+ if all of the tags supplied in "bugs_tags_s" are found
4912+ in the gtk.TextEntry.
4913+
4914+ Do not call directly
4915+
4916+ """
4917+ if len(self.entry.get_text()) == 0:
4918+ return True
4919+
4920+ tags_on_bug = orig_val.split()
4921+ tags_in_filter = target_val.split()
4922+
4923+ for tag in tags_in_filter:
4924+ if tag in tags_on_bug:
4925+ return False
4926+ return True
4927+
4928+class IntegerFilterBox( gtk.HBox ):
4929+ """
4930+
4931+ """
4932+ __gsignals__ = {'changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
4933+ (gobject.TYPE_PYOBJECT,)),
4934+ }
4935+
4936+ def __init__(self):
4937+ gtk.HBox.__init__(self, False, 10)
4938+ self.__combo_store = gtk.ListStore(gobject.TYPE_STRING,gobject.TYPE_PYOBJECT)
4939+ self.combo = gtk.ComboBox(self.__combo_store)
4940+ cell = gtk.CellRendererText()
4941+ self.combo.pack_start(cell, True)
4942+ self.combo.add_attribute(cell, 'text', 0)
4943+ self.combo.show()
4944+ self.combo.connect("changed",self.__changed)
4945+ adj = gtk.Adjustment(0,-1000000000,1000000000,1)
4946+
4947+ self.spinner = gtk.SpinButton(adj,1,0)
4948+ self.spinner.set_activates_default(True)
4949+ self.spinner.show()
4950+ self.spinner.set_numeric(True)
4951+
4952+ self.spinner.connect("value-changed",self.__changed)
4953+ self.pack_start(self.combo, False, False)
4954+ self.pack_start(self.spinner)
4955+
4956+ self.__combo_store.append(["=",self._equals])
4957+ self.__combo_store.append(["<",self._less_than])
4958+ self.__combo_store.append([">",self._greater_than])
4959+ self.__combo_store.append(["<=",self._less_than_equals])
4960+ self.__combo_store.append([">=",self._greater_than_equals])
4961+
4962+ def __changed(self, widget, data=None):
4963+ self.emit("changed",data)
4964+
4965+ def filter(self, orig_val):
4966+ if self.combo.get_active() == -1:
4967+ return True
4968+
4969+ filt_iter = self.combo.get_model().get_iter(self.combo.get_active())
4970+ filt_func = self.combo.get_model().get_value(filt_iter,1)
4971+
4972+ try:
4973+ target_val = int(self.spinner.get_value_as_int())
4974+
4975+
4976+ except Exception, inst:
4977+ print inst
4978+ return False
4979+
4980+ return filt_func(orig_val, target_val)
4981+
4982+ def _equals(self, orig_val, target_val):
4983+ if orig_val == "":
4984+ return False
4985+ return int(orig_val) == target_val
4986+
4987+ def _less_than(self, orig_val, target_val):
4988+ if orig_val == "":
4989+ return False
4990+ return int(orig_val) < target_val
4991+
4992+ def _greater_than(self, orig_val, target_val):
4993+ if orig_val == "":
4994+ return False
4995+ return int(orig_val) > target_val
4996+
4997+ def _less_than_equals(self, orig_val, target_val):
4998+ if orig_val == "":
4999+ return False
5000+ return int(orig_val) <= target_val
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: