1
0
mirror of https://github.com/gryf/pygtktalog.git synced 2026-03-28 06:53:33 +01:00

279 Commits

Author SHA1 Message Date
de247e9bc8 Added branch with implementation for images in db 2012-02-21 21:13:47 +01:00
ad1703cd90 Added logic for Image and Thumbnail db objects. Added scan functionality 2011-05-15 16:50:54 +02:00
3e2634bc57 Added details/discs/files models, added scan module and its test
Changes im logging module, but also on others
2011-03-27 20:48:28 +02:00
3c6c9a552a Added observable property for discs current directory,
Clean up dialogs a bit
Some additional variables in init (mainly for about() stuff)
Rearrange video module for usage PIL, which is slightly faster than
 ImageMagick utils
2010-11-17 22:25:53 +01:00
54b6a377bf Lots of changes, callbacks for gui events, added details and so on 2010-11-07 16:34:26 +01:00
22c24fbaf7 - added version for package,
- added about signal callback,
- use sorting in additional relations in models,
- added prototype for about class/function
- corrected README for small typos, added links, conformed to be valid
  reStructuredText
2010-05-06 21:14:55 +02:00
62ab67ecc5 Resolved issue with sort order of children of the file obj. 2010-05-04 06:48:58 +02:00
7417b9e98e Introduced files treeview, refactor code for discs view, struggle with files model 2010-05-04 05:55:41 +02:00
1cf1390567 Implemented rename functionality in discs controller, reduced redundant information in discs treestore 2010-05-03 10:30:00 +02:00
5db02183a5 Added script for converting between scheme for DB in version 1.x of app and 2.x 2010-05-02 19:32:56 +02:00
3590f90751 Cleaned up the code 2010-05-02 19:24:04 +02:00
2b5b53ada1 Added popup menu for discs treeview, added separated glade files with interface and controllers 2010-05-02 19:02:35 +02:00
7536e2c60a Repaired test task 2010-05-02 11:29:53 +02:00
3b0cb80407 Added discs controller, change way that paver run application 2010-05-02 11:21:34 +02:00
9769dfdb76 Implementation of discs tree, added popup menu 2010-05-02 11:14:54 +02:00
dbb01acd3f Early design for separating main classes into smaller parts. Added logger module. 2010-04-28 21:55:49 +02:00
9b7f15122d Added requrements (SQLAlchemy, gettext) 2009-08-26 20:29:26 +00:00
1cd6ad5b84 Cleaned up messages for quit. 2009-08-26 20:20:48 +00:00
58c0c1ecdc Imports for new database handle. 2009-08-26 20:18:09 +00:00
20501fcf54 Updated locale 2009-08-26 20:16:49 +00:00
5e83363fe7 Removed unnecessary prints. 2009-08-26 20:15:26 +00:00
313db80101 Migration of database stuff into objects managed by SQLAlchemy ORM. 2009-08-26 20:12:35 +00:00
3f797b0bf8 Replace generate_pot.py script with xgettext/intltool-extract tools. Python
script have defect in multiline texts and with couple of different messages in
one line.
2009-08-26 20:10:54 +00:00
8d6cb75b8e Added tests for common DB actions 2009-07-19 18:16:47 +00:00
71162da225 Simplify db interactions. Follow KISS principle. 2009-07-19 18:16:14 +00:00
6b1fdb90e9 Added DataBase class for connectiions, schema creating and other common tasks.
This version contains copying to RAM functions.
2009-07-19 13:56:16 +00:00
c1dd854f62 removed trailing characters 2009-06-29 20:10:53 +00:00
2b47d9b869 added coverage option for nosetests 2009-06-29 20:09:59 +00:00
53c3a444e0 Separated code for geting information about movie, minor fixes 2009-06-29 20:09:06 +00:00
b54aa1849b Added additional capture() method test to cover all cases 2009-06-29 20:07:26 +00:00
37f06726b4 Small changes in README 2009-05-19 19:53:14 +00:00
e93b7291b8 Generalize locale support with pavement script. 2009-05-19 19:52:55 +00:00
ca7fdf15e8 Isolated method for gathering movie info. Now it can be changed or replaced
easely.
2009-05-19 19:52:02 +00:00
7b5c76f1d9 Added fallback to C if there is no suitable locales 2009-05-19 19:50:46 +00:00
f0f8d27d19 Added on_quit method. 2009-05-19 19:50:05 +00:00
b493b66ea8 Msg catalogs update. 2009-05-19 19:49:30 +00:00
83b9d944cf Cosmetic changes to test files for modules video and misc. 2009-05-19 19:46:45 +00:00
5ccdd8ee6f Added module with dialog helpers, and unit test 2009-05-19 19:45:56 +00:00
8013eec7d2 Removed needless test collector. Used nosetest instead. 2009-05-09 05:44:05 +00:00
14f654251d Added forgotten pot file.
Added i18n into package init.
Made some changes in README file.
2009-05-08 20:15:38 +00:00
8a24e30bde Moved start script into bin directory.
Removed makefile, substituded by the pavement script from paver package.
2009-05-08 20:14:21 +00:00
bcacb75229 cosmetic changes 2009-05-08 20:11:11 +00:00
d04a84c72d Small change to make plgen makefile target work. 2009-05-04 20:32:24 +00:00
e69e2300e8 Moved scripts into bin subdir, slightly modified Makefile, added plgen and
dist targets, removed CZYTAJTO.
2009-05-04 20:29:29 +00:00
08c38bf63d Change Makefile to make tests work, removed cleanup shell script, removed
start script. There should be created new starscript suitable for running app
from current directory and installed as an egg.
2009-05-04 16:36:39 +00:00
52b293c459 Added unit test for misc module, added initial mvc for main window. 2009-05-04 16:24:37 +00:00
bdf059d11f Moved main.glade into pygtktalog package. 2009-05-04 16:23:41 +00:00
ccec14f3ea Move misc and video modules into package pygtktalog. 2009-05-04 16:19:48 +00:00
36c4e7e4f2 Added pygtktalog module 2009-05-04 16:13:37 +00:00
b0964ca031 Removed dummy tests, remove runtests bash script, since there is make target
for invoke running tests.
2009-05-04 16:09:48 +00:00
efaccd8902 Moved test module into root catalog of the project. 2009-05-04 16:05:47 +00:00
434df58b16 Head to v.2. Now it uses gtkmvc with version 1.99, makefile, i18n. 2009-05-04 16:02:36 +00:00
56c77ae9a4 added EXIF patch and misc in lib
removed some cruft
2009-04-07 20:25:00 +00:00
c46d29a5bb added video module - replacement for midentify
added some mocks for images tests
2009-04-07 19:42:44 +00:00
5e8c33f05a changes in tests, upgrade to new EXIF module, etc 2009-04-07 19:40:15 +00:00
fb920f58bc * Removed cruft.
* Version change to 1.0.2.
2008-12-15 20:54:16 +00:00
292d290723 * Added shell script for preparing distfile.
* Added unitests.
 * Added mocks for video files.
 * Added midentify module.
2008-12-15 20:46:26 +00:00
0adcdaba8d * Lots of changes, code cleanup, import/export in GUI. 2008-12-15 20:40:24 +00:00
c2926c96d6 * Rename module to apropriate name. 2008-12-15 20:27:19 +00:00
0e22fead19 * Updated pygtkmvc to 1.2.2. 2008-11-10 13:56:42 +00:00
920ad915d1 * Moving truncated old main class into converter. Old model doesn't
needed anymore.
2008-11-10 13:33:03 +00:00
92016fe5c1 * Finally, version 1.0. 2008-11-02 19:48:41 +00:00
e9edb602e3 * Refactored Img and Thumnail classes for new media storage. 2008-11-02 19:48:22 +00:00
301161926f * Imporved simple image viewer. Now it have scrollbar, when needed. 2008-11-02 19:47:45 +00:00
e7b0288fc5 * Old version of main model. used for converter. to be deleted. 2008-11-02 19:46:35 +00:00
d04f1df252 * Image for images with no thumnail. 2008-11-02 19:45:51 +00:00
dba6f46200 * Convert from tar.bz2 database (db + images) format to pure (or
bzipped) sqlite db.
2008-11-02 19:45:12 +00:00
c1f4c0534c * Bugfix for case, when only_thumbs=True, remove images! Bug discovered
in suspiciously big katalog file.
2008-07-03 11:55:14 +00:00
9bf8eb506f * Bug fix in picture save method. 2008-06-16 12:45:54 +00:00
618d57091b * Fixed bug in case that filename has underscore in recent menu. 2008-05-28 05:54:38 +00:00
ef291c3ae6 * Removed unnecessary TODO. 2008-05-19 14:12:41 +00:00
f44f80874d * Added condition for no scale image, where image have smaller
dimensions than thumbnail.
2008-05-19 14:12:04 +00:00
400cc5ab4f * Bugfix in case of empty recent list. 2008-05-14 11:48:21 +00:00
453fb848aa * Added CZYTAJTO (polish README file).
* Changed katalog file extension from .pgt into or .tgz.
 * Removed compression choice form preferences.
2008-05-14 11:29:13 +00:00
e51a447809 * Added file with licence. 2008-05-14 08:57:00 +00:00
ea667cf03e * Changed version to 1.0 RC2.
* Bugfix in files removal. Controller should collect all file ids,
   otherwise it'll starts to remove wrong files, because in the meantime
   model removing items from liststore.
2008-05-14 08:40:33 +00:00
6709576aec * Added trees and lists refresh after remove of some branches or leafs. 2008-05-13 18:15:28 +00:00
ccc6b67dee * Removed manual katalog creation. Now it is created automaticly after
application start.
2008-05-13 18:14:35 +00:00
e0a8753c13 * Added images capital extensions to filter of extensions. 2008-05-13 15:32:46 +00:00
2729f660e9 * Cosmetic changes. 2008-05-13 15:32:14 +00:00
49bbcd8d53 * Added support for signals for global removal of images and
thumbnails.
2008-05-13 15:32:02 +00:00
42e29b36b2 * Added right click menu support under searcher window. 2008-05-13 15:31:39 +00:00
e5edc7bb7f * Added methods for global removal for images and thumbnails. 2008-05-13 15:31:09 +00:00
73754a2222 * Added popup menu for selected files in searcher window. 2008-05-13 15:30:13 +00:00
0eac79112f * Added menu items for global removal for images and thumbnails. 2008-05-13 15:29:36 +00:00
de6253dad9 * Cosmetic changes. 2008-05-13 15:28:28 +00:00
29f1266f8d * Change of behavoiur of standard filechooser dialogs. Now it would for
default open last location, where katalog file was written. If user
   changes location for some other file, then it stick to that
   directory.
2008-05-08 16:57:28 +00:00
3b95c6a16f * Change of keyboard shortcut for adding CD/DVD - it has collisions
with standard copy shortcut.
2008-05-08 16:53:55 +00:00
be69067396 * Cosmetic changes with displaying file details. 2008-05-08 16:19:20 +00:00
1eaad783f9 * Changed the way that program starts: it's possible to run it from its
directory or place in desired directory, copy pyGTKtalog script in
   place pointed in $PATH (or not), and change path to pygtktalog.py
   file.
2008-05-08 11:58:41 +00:00
d0b23f9202 * Added controller and view for search window. 2008-05-08 08:52:30 +00:00
0038a5331d * Added models for files in searcher and search history.
* Added searcher method and add history elements.
 * Clean up files model.
 * Added some internal methods.
 * Code clean up.
2008-05-08 08:52:06 +00:00
1a4bbbb653 * Added support for history of searches. 2008-05-08 08:46:23 +00:00
9f03954433 * Added controller and view for search window. 2008-05-08 08:46:04 +00:00
697bd8124c * Clean up TreeStore model for files.
* Added observer variable to main model, so that clicked file id in
   search window can be easly passed to main controller and jump to that
   file.
 * Some cosmetic changes.
2008-05-08 08:45:23 +00:00
1b0d76e6ba * Tab name change from "katalogi" to "dyski". 2008-05-08 08:42:14 +00:00
800f30fc4a * Supplemented README file.
* Changed version to 1.0 RC1!
2008-05-08 06:45:31 +00:00
20563ece6d * Removed DOS/Windows end-of-line character. 2008-05-08 06:45:08 +00:00
33b5e76f99 * Added support for "menu" key on keyboard.
* Small changes in behaviour of individual popup menus.
2008-05-06 19:17:10 +00:00
aea871b30e * Added context menu item for possibility to remove tags form file or
even files.
 * Change of a way to display files after tag click - all files, that
   have clicked tag will be appear in files TreeView.
2008-05-05 21:17:40 +00:00
574767de2a * Bug bypass with foreach method for texttagtable (it's not iterate
over all tags, no one knows why).
 * Added pictures export.
 * Added new common class for directory pick.
 * Clean up main model - tree models have to be updated, than destroyed
   and created from scratch.
2008-05-05 06:54:36 +00:00
1684065b6a * Of course, that os.chown ave 3 arguments, not two. 2008-04-25 06:57:49 +00:00
a9efa754d8 * Of course, I forgot to change variable name :/ 2008-04-25 06:53:56 +00:00
0e5b5037f9 * Bug fix in catch exception - this is not IOError. 2008-04-25 06:51:04 +00:00
6ee0520823 * Change of direcotry attributes in tar extracting function for
Python 2.4.
2008-04-25 06:43:12 +00:00
2cc803ddae * Added bug in tags :/ 2008-04-24 13:20:23 +00:00
0e9f1c5503 * Code clean up with guidlines of pain in the ass pylint.
* Added method for fetching tag for files with id, tag name and so on.
2008-04-24 13:20:01 +00:00
8080ccc7f0 * Code clean up.
* Decerased amount of class methods.
 * Added tags cloud support.
2008-04-24 13:19:13 +00:00
e774353a8b * Interface clean up.
* Refactoring method for signals doing exactly the same thing.
2008-04-24 13:17:28 +00:00
8a929adcdd * Code refactoring.
* Added add tags by drag and drop.
2008-04-17 06:52:14 +00:00
f6cdb9fb08 * Added method for retriving tag by id. 2008-04-17 06:51:37 +00:00
25da838972 * Removed database from moviedb project, and pictures from website. 2008-04-17 06:47:09 +00:00
a98ba36a23 * Added drag and drop support from files TreeView to tags cloud.
* Added tags add.
 * Code clean up.
 * Removed unnecessary imports.
 * Adapted to PEP8.
2008-04-16 14:07:18 +00:00
f98c905591 * Code clean up.
* Removed unnecessary imports.
 * Adapted to PEP8.
2008-04-16 14:05:20 +00:00
6691415f12 * Code clean up.
* Adapted to PEP8.
2008-04-16 14:04:05 +00:00
da2df60c40 * Code clean up.
* Removed unnecessary imports.
 * Adapted to PEP8.
2008-04-16 14:03:34 +00:00
da2f9cc7a7 * Small GUI changes. 2008-04-16 14:01:44 +00:00
6dac5f887c * Another bugfix in extract tar archive for Python 2.4. Damn. 2008-04-14 19:15:42 +00:00
4a5b1d433f * Bugfix in extract tar archive for Python 2.4. 2008-04-14 19:08:35 +00:00
db599beae3 * Bugfix in extract tar archive for Python 2.4. 2008-04-14 19:05:02 +00:00
81d37ba053 * Small improvements.
* Added functionality for adding thumbnails only (without big images).
2008-04-14 18:49:31 +00:00
59db470ffa * Removed unnecessary infrastructure for file details. 2008-04-14 13:32:04 +00:00
3fd3b2ec19 * Added exteranl image viewer.
* Added edit for descriptions and notes for files.
 * Added possibility for make thumbnail for any directory/file.
 * More improvements and bufixes.
2008-04-14 13:29:50 +00:00
371f702f9d * Interface clean up.
* Added popup menu for thumbnails.
2008-04-14 12:20:52 +00:00
83f76552e2 * More work on edit dialog. 2008-04-14 12:20:29 +00:00
2b27b06c24 * Interface clean up.
* Added popup menu for thumbnails.
2008-04-14 12:20:16 +00:00
66694f05c2 * Fix for missed configuration change. 2008-04-14 12:19:37 +00:00
b41df8d2d7 * Added dialog for file edit. 2008-04-11 11:47:43 +00:00
978145e089 * Small bugfixes. 2008-04-11 11:47:28 +00:00
4a4730a5bb * Fixed bug in directory sizes after files/branches removal.
* Added gThumb comments parsing.
2008-04-11 11:46:47 +00:00
55c5e981b5 * Added class GthumbCommentParser for parsing .comment/*xml files
created by gThumb.
2008-04-11 11:45:05 +00:00
afd9c34760 * Change icon size to 96x96. 2008-04-11 11:44:09 +00:00
2d010620d4 * Added preview for images file chooser.
* Path in file choosers is remebered now.
2008-04-11 11:37:18 +00:00
e3069a3e12 * Added EXIF support - parse, write to db, show in apropriate tab. 2008-04-10 12:25:35 +00:00
6de1f88d7d * Supplemented dictionary for MeteringMode and Flash. 2008-04-10 12:16:31 +00:00
6926a93223 * Force to import EXIF module form utils directory. 2008-04-10 12:15:21 +00:00
d937ecbaff * Removed cruft. 2008-04-09 17:35:00 +00:00
0f371c7fd2 * Added support for add/remove pictures for any files or directories. 2008-04-09 15:41:20 +00:00
5ffbf9a15a * Added support for add/remove pictures for any files or directories. 2008-04-09 15:41:11 +00:00
a36ca62b73 * Added statisics.
* Bug fix on files disapear in file view.
 * Code clean up.
2008-04-08 13:25:13 +00:00
344f4be232 * Code refactoring.
* Small changes in assumptions.
 * TODO supplement.
 * Moved minor features into future versions.
 * Added extensions configuration editor.
2008-04-07 19:37:06 +00:00
c6d2ea795a * Change of concept in extension handling.
* Moved tags cloud into another tab.
2008-04-07 11:02:36 +00:00
14c23170ba * Improvements, bugfixes. 2008-04-02 19:18:59 +00:00
f40106ef3e * Typo.
* Bugfix in call.
2008-03-28 19:02:13 +00:00
be230a4e9f * Added another part of tag cloud. 2008-03-28 18:18:14 +00:00
efda4661bc * Created separate module for Thumbnail class. 2008-03-28 18:17:25 +00:00
c72639af8e * Added widget for so called "tag cloud". 2008-03-26 20:39:32 +00:00
0279279083 * Added notebook widget for file preview.
* Added thumbnail preview.
2008-03-26 11:03:12 +00:00
fe5bb49fa4 * Added thumbnals generating for images.
* Lots of fixes.
2008-03-26 06:31:35 +00:00
922ec99990 * Added another section in config class for managing files extensions. 2008-03-24 12:09:29 +00:00
bc4f329d15 * Added details MVC files.
* Change of katalog file organization.
 * Small bugfixes.
 * Code clean up.
 * Added README file.
2008-03-24 09:15:05 +00:00
2a1cb3c1ba * Simple script for removing of bytecode and temporary or backup files. 2008-01-18 20:40:57 +00:00
07857c060d * Docstrings refresh. 2008-01-18 20:40:09 +00:00
347b8bca4c * Separated file info rutine into function. 2008-01-18 20:39:49 +00:00
bdd8181d8d * Imports refactoring. 2008-01-18 20:36:30 +00:00
a0b7264424 * Comments clean up.
* All strings have to be english now.
2007-12-22 16:46:53 +00:00
be20420f74 * Clean up.
* Removed cruft.
2007-10-24 17:34:07 +00:00
8fe3893cdd * Renamed controllers directory to ctrls. 2007-10-24 17:31:05 +00:00
4dcfaa51e7 * Upgrade pygtkmvc to ne version 1.2.1. 2007-10-24 17:29:31 +00:00
15cbe23161 * Moved glade files to resources. 2007-10-24 17:24:39 +00:00
624f42f685 * Fixed bugs in eject functionality. 2007-09-15 06:54:52 +00:00
f389ddc074 * Support for removing branches form database.
* Change in behaviour of TreeStore for disks - add or remove is done
   simultaneously in model and db.
2007-09-15 06:54:16 +00:00
126360c3ef * Addd support for click in update and delete. 2007-09-15 06:51:51 +00:00
851321327a * Added confirmation dialog for deleting elements. 2007-09-15 06:50:28 +00:00
e33c809825 * Added column with parent id to TreeStore. Now it can be possible to
activate items in context menu for specified files.
2007-09-12 20:42:31 +00:00
363e5289b1 * Added recent in config class.
* Added read/write recent menu with correct order into configuration
   file.
2007-09-12 20:41:18 +00:00
a08503cb02 * Added recent files menu.
* Added context menu for disk TreeView.
 * Added parameters for __open() method.
2007-09-12 20:40:14 +00:00
f978b75c7c * Changed unnecessary string into optional (debug mode). 2007-09-12 20:37:51 +00:00
4e3de66f89 * Added support for load katalog as a command line parameter. 2007-09-12 20:37:01 +00:00
1af0df2105 * Added pwd befor directory change for reference point for relative
path argument.
2007-09-12 20:36:02 +00:00
cfc22c2a42 * Added separator and find element in main menu. 2007-09-12 20:34:56 +00:00
96ceebbf88 * Path change. 2007-09-05 16:28:29 +00:00
5c1da0f9c0 * Removed old file of main window. 2007-09-05 16:21:27 +00:00
3282000e03 * Moved experimental MVC project as a current mainstream. 2007-09-05 16:13:58 +00:00
c779b83259 * Removed duplicated directories. 2007-09-05 16:10:20 +00:00
fa10153d13 * Removed old files form project. 2007-09-05 16:09:21 +00:00
1b04745ef8 * Removed old files form project. 2007-09-05 16:08:34 +00:00
0ef11257ac * Removed old GUI files. 2007-09-05 16:07:05 +00:00
8a10e49a84 * Change of concept for keeping directory structure in database.
* There was performance issue with relation parent-child in complex
   nested directory structures, and takes too much time to caculate this
   structure.
2007-09-05 16:02:44 +00:00
f42e134236 * Added information about failure of Egenix mx.DateTime import. 2007-09-05 16:01:22 +00:00
0b9c154aab * Specified width of integer for TreeView column, so that size of large
files can be fitted into it.
2007-08-30 18:49:19 +00:00
b064624c4b * Removed unnecessary print. 2007-08-30 18:48:24 +00:00
3de5c1f8cd * Added dialog for changing filename of the katalog and small cosmetic
changes in dialog for file open.
2007-08-29 20:26:10 +00:00
2eab5ff145 * Function clean up.
* Fixed performance issue with filling up TreeStore for disks tree.
2007-08-29 20:24:40 +00:00
b01223bec0 * Version bump to 0.7.
* Code clean up.
 * Added support for clicking on items in files TreeView.
 * This version is functional the same as that previous on-file shit.
2007-08-29 20:23:00 +00:00
ab3d0ea172 * Removed unnecessary gtk import inside program. 2007-08-29 20:21:06 +00:00
60fb364f3f * Dialgos code clean up.
* Added support for secondary text in dialogs.
2007-08-26 11:15:33 +00:00
a00a60a8dd * Added functions for fill TreeStore and ListStore with data.
* Added methods for fetch information about file/directory.
2007-08-26 11:14:54 +00:00
e04e77a527 * Added support for 'Cancel' buttons.
* Added setup for disks and files treemodels.
 * Code clean up.
 * Removed repetable commands, which are creating unnecessary treemodel
   objects.
2007-08-26 11:12:47 +00:00
be3e4032c7 * Changed PYTHONPATH.
* Changed name of program for way of launch with -OO option.
2007-08-26 11:10:56 +00:00
c68c108a36 * Added signal for couple of widgets.
* Added 'Cancel' button for interrupt scanning.
2007-08-26 11:10:08 +00:00
610733ca33 * Added description in docstring. 2007-08-20 17:53:55 +00:00
56e11e21ab * Change of path to project in bash starting script. 2007-07-26 08:57:35 +00:00
a9897caf79 * Change of path to project in bash starting script. 2007-07-26 08:56:22 +00:00
a48458d1f9 * Code clean up in dialog and configuration views. 2007-06-23 17:12:02 +00:00
a6019fff41 * Added helper for support CD/DVD mount, umount, eject etc. 2007-06-23 17:11:34 +00:00
df9ea38a03 * Refactored code in configuration and main controllers. 2007-06-23 17:10:54 +00:00
4edcc521cd * Refactored code in configuration and main controllers. 2007-06-23 17:10:43 +00:00
70672ec83c * Upgraded pygtkmvc to version 1.0.1. 2007-06-23 17:08:05 +00:00
653f51da15 * Upgraded pygtkmvc to version 1.0.1. 2007-06-23 17:07:59 +00:00
1e70c4f69f * Some GUI changes. 2007-06-23 17:07:32 +00:00
eac73cd58b * Added dialogs glade file. 2007-06-23 17:07:17 +00:00
fb21b274e0 * Changes except-try blocks to objects methods. 2007-06-23 17:06:59 +00:00
9f512ec834 * Changes in old version. 2007-06-23 17:06:19 +00:00
afc1e325b0 * Added configuration loading. 2007-05-07 04:41:17 +00:00
c54ca0f0bf * Fixed bug with no-displayed preferences window. 2007-05-07 04:40:05 +00:00
dc54cebd12 * Changed filename for main file. 2007-05-06 18:01:43 +00:00
3b2635d6e2 * Cahnged filename for main file. 2007-05-06 18:00:52 +00:00
da52c1aa03 * Added signal handling defined in view (through glade file). 2007-05-05 20:25:28 +00:00
e331bdbfc2 * Try for a new, nice icon. 2007-05-05 20:19:56 +00:00
3bc24ab9e8 * Dialogs for common uses. 2007-05-05 20:19:10 +00:00
871a3d9c3e * View for configuration. 2007-05-05 20:18:52 +00:00
cc151f00ca * Model for configuration. 2007-05-05 20:18:36 +00:00
386148e356 * Controller for configuration. 2007-05-05 20:18:27 +00:00
baa5f3af6e * Old version of window, methods and stuff. 2007-05-05 20:17:53 +00:00
9441ee64c5 * Description GUI for configuration. 2007-05-05 20:14:30 +00:00
793716c66d * Added imports checks.
* Added catch for keyboard interrupt exception for gracely quit.
2007-05-05 20:13:42 +00:00
98ef8ee6c7 * Added import for mx.DateTime, which is used by sqlite. 2007-05-05 20:06:34 +00:00
7e33eb55f5 * Fixed paths. 2007-05-05 20:06:02 +00:00
f695f82c1f * New version using pygtkmvc framework. 2007-05-01 19:30:22 +00:00
45859e1a3d * Changed data type for column size. 2006-12-28 11:08:07 +00:00
e3fa65da45 * Added icons next to filenames.
* Added counter for files in directory.
 * Fixed small bugs.
2006-12-28 10:03:35 +00:00
1ac3caadce * Added getParent method (maybe it can be usefull) and icons next to
filenames.
2006-12-28 10:02:20 +00:00
3ce3c7445a * Running with debug. 2006-12-25 17:10:45 +00:00
ae4019ad19 * Added signals for doubleclick in treeviews. 2006-12-25 17:09:22 +00:00
200c556ce9 * Added methods for directories tree. 2006-12-25 17:08:55 +00:00
c8dbd803f3 * Added methods for directories tree. 2006-12-25 17:08:20 +00:00
e3a08713e9 * Added row colors in treeview.
* Removed signal 'on row activated'.
2006-12-07 16:57:39 +00:00
c6510bea51 * Added row colors in treeview.
* Added signals for files and discs treeviews.
2006-12-07 16:56:39 +00:00
bccadc700a * Change of starting .py files, now it can be possible to use __debug__
variable.
2006-12-07 16:55:24 +00:00
1a308f586c * Added function responsible for opening and saving database.
* Improvements in hundred places.
2006-12-07 16:54:37 +00:00
2431521daf * Changed module function - now it'll be responsible for view
generation with data fetched from db.
2006-12-07 16:53:23 +00:00
27cc349703 * Changes in calling scan function.
* Some refactoring.
2006-12-04 17:40:39 +00:00
79f55e3756 * Change type into numeric. 2006-12-04 17:39:58 +00:00
d3c4cab0c1 * Functions and object for talk with database. 2006-12-04 17:39:14 +00:00
a2152127a3 * Added dialog for adding directory to katalog. 2006-12-03 21:02:24 +00:00
aeba13e972 * Added preferences window title. 2006-12-03 21:01:53 +00:00
716d7e2e94 * Added markers for folding code.
* Added dialog for adding directory into katalog.
2006-12-03 21:01:26 +00:00
3ff9710f5f * Added markers for folding code.
* Added dialog for adding directory into katalog.
2006-12-03 21:00:38 +00:00
f24e5f467a * Added warning widget.
* Removed useless placeholders from form.
2006-12-01 21:58:02 +00:00
420e1a7a85 * Added menu items for showing toolbar and statusbar.
* Added toolbar.
Clean up scrollbars stuff.
2006-12-01 21:57:00 +00:00
e73f9cf07a * Added switch for displaying dialogs (warninings about not saved
project, errors on mount etc) in preferences window.
2006-12-01 21:55:56 +00:00
4391eb7e5f * Code refactoring.
* Added toolbar support.
2006-12-01 21:54:20 +00:00
fa9984f188 * Change of behaviour of eject and umount functions. 2006-12-01 21:53:49 +00:00
a8953f2dea * Added __str__ method. 2006-12-01 21:53:28 +00:00
e106d3cfd2 * Added quite few new preferences option to click :). 2006-12-01 21:43:57 +00:00
48014bd0fc * Added quite few new preferences option to click :). 2006-12-01 21:43:35 +00:00
772c121f1c * Added params for window dimensions.
* Removed comments and something with code blocks.
2006-12-01 21:43:07 +00:00
9794dc365d * Added CD/DVD unmount method. 2006-12-01 21:42:06 +00:00
e08d0912bc * Added additional fields in configuration. 2006-12-01 21:41:38 +00:00
b258065896 * Added preferences panels. 2006-11-30 21:38:10 +00:00
4f92bad5a2 * Added functionality for panel switching. 2006-11-30 21:37:50 +00:00
3fbff19137 * Change application icon, added source file in Gimp xcf format. 2006-11-30 11:41:16 +00:00
fe5ac8d21a * Preferences glade file. 2006-11-30 11:40:18 +00:00
a795707afe * Added checkings for PIL library. 2006-11-30 11:39:49 +00:00
fa7217d7bc * Preferences module. 2006-11-30 11:39:23 +00:00
affbe603cb * Method for displaying preferences window. 2006-11-30 11:38:59 +00:00
652e68373f * Added helper module with functions for scanning different data types. 2006-11-30 11:38:17 +00:00
3bf471db23 * Resolved issues with array members[].
* Added __str__, which produce nice print out of current catalog
   structure.
2006-11-30 11:37:19 +00:00
dffd5f0387 * New config object doesn't read configuration - fixed.
* Added PIL field in config.
2006-11-30 11:35:40 +00:00
9feef2fb70 * Renamed module name. 2006-11-29 09:33:48 +00:00
c41444216a * Renamed module name. 2006-11-29 09:33:41 +00:00
2bfc58cb3a * Finished files/directories fetching into catalog. 2006-11-29 09:33:11 +00:00
540c22d2a3 * Dialogs interfaces. 2006-11-28 12:23:54 +00:00
3769a73861 * Empty 'starting' glade file. 2006-11-28 12:23:39 +00:00
4f4339e3f0 * Fun with fileObj class. 2006-11-28 12:22:15 +00:00
2f0134d53d * Added __str__ method. 2006-11-28 12:21:12 +00:00
ab07a478c0 * Added file object - needed for catalog scanning. 2006-11-27 14:21:45 +00:00
d619c5c2df * Refactored Qst dialog class - it has not been returned anything.
* Added dialog for entering name of a top-most element in katalog.
2006-11-27 14:21:14 +00:00
1dd78c8868 * Added about in help menu. 2006-11-27 14:19:51 +00:00
7fd763b741 * Added licence.
* Started to create files/directories represented as objects.
2006-11-27 14:18:29 +00:00
77e43c93ca * Common dialog boxes. 2006-11-26 14:18:33 +00:00
dc1c3d0149 * Added about dialog. 2006-11-26 14:17:58 +00:00
200bf90dae * Removed -*- nnd added normal comment, as statetd in
http://www.python.org/peps/pep-0263.html.
2006-11-26 11:03:13 +00:00
ffd2e0d94d * Removed unnecessary comments, added right one.
* Removed useless verifies.
2006-11-26 11:01:36 +00:00
9e6e682130 * Added eject field in config.
* Added information (written on terminal, where program is runned)
   about writing configuration in the very first time.
2006-11-26 11:00:53 +00:00
518e4658a7 * Check for mount point in fstab in every method.
* Changed return values in volmount method.
2006-11-26 10:59:57 +00:00
1b77a49958 * Added dialog in case where there is ann error in CD/DVD mount in
addCD method.
2006-11-26 10:58:37 +00:00
c7b948f1e8 * Imported old structure and data from pgsql database to sqlite.
* To change for sure.
2006-11-25 08:31:43 +00:00
103 changed files with 21887 additions and 787 deletions

674
LICENCE Normal file
View File

@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

4
MANIFEST.in Normal file
View File

@@ -0,0 +1,4 @@
include setup.py
include pavement.py
include paver-minilib.zip
include pygtktalog/locale/*/*/*.mo

182
README Normal file
View File

@@ -0,0 +1,182 @@
pyGTKtalog
==========
pyGTKtalog is Linux/FreeBSD program for indexing CD/DVD or directories on
filesystem. It is similar to `gtktalog <http://www.nongnu.org/gtktalog/>`_ or
`gwhere <http://www.gwhere.org/home.php3>`_. There is no coincidence in name of
application, because it's menat to be replacement (in some way) for gtktalog,
which seems to be dead project for years.
Current version is 1.9.
FEATURES
--------
* scan for files in selected media
* get/generate thumbnails from exif and other images
* most important exif tags
* add/edit description and notes
* fetch comments for images made in `gThumb <http://gthumb.sourceforge.net>`_
* add/remove unlimited images to any file or directory
* `tagging files <http://en.wikipedia.org/wiki/Tag_%28metadata%29>`_
* and more :)
REQUIREMENTS
------------
pyGTKtalog requires python and following libraries:
* `python 2.6 <http://www.python.org/>`_
* `pygtk 2.16 <http://www.pygtk.org>`_
* `pygtkmvc 1.99 <http://sourceforge.net/apps/trac/pygtkmvc/wiki>`_
* `sqlalchemy 0.6 <http://www.sqlalchemy.org>`_
It may work on other (lower) version of libraries, and it should work with
higher versions of libraries.
.. note::
Although pygtkmvc is `listed on pypi
<http://pypi.python.org/pypi/python-gtkmvc/>`_ it may happen that you
have to download it directly from
`sourceforge <http://sourceforge.net/apps/trac/pygtkmvc/wiki>`_ page and
install manually. I don't know about pygtk (I've installed it by my
system package manager), but all the others python libraries (sqlalchemy,
paver, nose, coverage) should be installable via `pip
<http://pypi.python.org/pypi/pip>`_
Optional modules
^^^^^^^^^^^^^^^^
* `PIL <http://www.pythonware.com/products/pil/index.htm>`_ for image manipulation
Additional pyGTKtalog uses EXIF module by Gene Cash (slightly updatetd to EXIF
2.2 by me) which is included in sources.
pyGTKtalog extensivly uses external programs in unix spirit, however there is
small possibility of using it Windows (probably with limitations) and quite big
possiblity to run it on other sofisticated unix-like systems (i.e.
BeOS/ZETA/Haiku, QNX or MacOSX).
Programs that are used:
* mencoder (provided by mplayer package)
* montage, convert from ImageMagick
For development process following programs are used:
* `gettext <http://www.gnu.org/software/gettext/gettext.html>`_
* `intltool <http://www.gnome.org/>`_
* `nose <http://code.google.com/p/python-nose/>`_
* `coverage <http://nedbatchelder.com/code/coverage/>`_
* `paver <http://code.google.com/p/paver/>`__
INSTALATION
-----------
You don't have to install it if you don't want to. You can just change current
directory to pyGTKtalog and simply run::
$ paver run
That's it. Alternatively, if you like to put it in more system wide place, all
you have to do is:
#. put pyGTKtalog directory into your destination of choice (/usr/local/share,
/opt or ~/ is typical bet)
#. copy pyGTKtalog shell script to /usr/bin, /usr/local/bin or in
other place, where PATH variable is pointing or you feel like.
#. then modify pyGTKtalog line 6 to match right pygtktalog.py directory
Then, just run pyGTKtalog script.
TODO
----
PyGTKtalog is still under heavy development, however there is small chance to
change structure of catalogs (and if it'll change, there will be transparent
function to update DB schema).
For version 1.0 there are no features to be done, just bug fixes.
There are still minor aims for versions 1.x to be done:
* consolidate popup-menus with edit menu
* add popup menu for directly removing tag from tag cloud
* implement advanced search
For version 2.0:
* Export/Import
* Icon grid in files view
* command line support: query, adding media to collection etc
* internationalization
* export to XLS
* user definied group of tags (represented by color in cloud tag)
* hiding specified files - configurable, like dot prefixed, cfg and manualy
selected
* tests
* warning about existing image in media directory
Removed:
* filetypes handling (movies, images, archives, documents etc). Now it have
common, unified external "plugin" system - simple text output from command
line programs.
* anime/movie
* title
* alt title
* type (anime movie, movie, anime oav, anime tv series, tv series, etc)
* cover/images
* genre
* lang
* sub lang
* release date (from - to)
* anidb link/imdb link
Maybe in future versions. Now text file descriptions/notes and tags have to
be enough for good and fast information search.
NOTES
-----
Catalog file is plain sqlite database (optionally compressed with bzip2). All
images are stored in ``~/.pygtktalog/images`` directory. Names for images are
generated sha512 hash from image file itself. There is small possibility for two
identical hash for different image files. However, no images are overwritten.
Thumbnail filename for each image is simply concatenation of image filename in
images directory and '_t' string.
There is also converter from old database to new for internal use only. In
public release there will be no other formats so it will be useless, and
deleted. There are some issues with converting. All thumbnails will be lost.
All images without big image will be lost. There are serious changes with
application design, and I decided, that is better to keep media unpacked on
disk, instead of pack it every time with save and unpack with open methods. New
design prevent from deleting any file from media directory (placed in
``~/.pygtktalog/images``). Functionality for exporting images and corresponding
db file is planned.
DEVELOPMENT
-----------
Several tools has been used to develop pyGTKtalog.
Paver
^^^^^
I've choose `Paver <http://www.blueskyonmars.com/projects/paver/>`_ as make
equivalent. Inside main project directory there is pavement.py script, which
provides several tasks, that can be helpfull in a work with sources. Paver is
also used to generate standard setup.py.
Nose
^^^^
BUGS
----
All bugs please report to Roman 'gryf' Dobosz <gryf73@gmail.com>.

View File

@@ -1,97 +0,0 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
config parser object
"""
#{{{ podstawowe importy i sprawdzenia
import sys
import os
from ConfigParser import ConfigParser
class Ini(object):
def __init__(self):
self.ini = []
def add_section(self, section):
self.ini.append("[%s]" % section)
def add_key(self, key, value):
self.ini.append("%s=%s" % (key, value))
def add_comment(self, comment):
self.ini.append(";%s" % comment)
def add_verb(self, verb):
self.ini.append(verb)
def show(self):
return "\n".join(self.ini)
class Config:
ini = Ini()
confd = {
'wx' : 800,
'wy' : 600,
'h' : 200,
'v' : 300,
'exportxls' : False,
'cd' : '/cdrom',
}
dictconf = {
"main window width" : "wx",
"main window height": "wy",
"horizontal panes": "h",
"vertical panes":"v",
"export xls":"exportxls",
"cd drive":"cd",
}
dbool = ('exportxls')
dstring = ('cd')
try:
path = os.environ['HOME']
except:
path = "/tmp"
def __init__(self):
self.load()
def save(self):
self.confd
newIni = Ini()
newIni.add_section("pyGTKtalog conf")
for opt in self.dictconf:
newIni.add_key(opt,self.confd[self.dictconf[opt]])
try:
f = open("%s/.pygtktalog" % self.path,"w")
except:
print "Cannot open config file %s for writing." % (self.path, "/.pygtktalog")
f.write(newIni.show())
f.close()
def load(self):
try:
# try to read config file
parser = ConfigParser()
parser.read("%s/.pygtktalog" % self.path)
for sec in parser.sections():
if sec == 'pyGTKtalog conf':
for opt in parser.options(sec):
try:
if self.dictconf[opt] in self.dbool:
self.confd[self.dictconf[opt]] = parser.getboolean(sec,opt)
elif self.dictconf[opt] in self.dstring:
self.confd[self.dictconf[opt]] = parser.get(sec,opt)
else:
self.confd[self.dictconf[opt]] = parser.getint(sec,opt)
except:
pass
except:
print "No config file"
pass

121
convert_1.x_to_2.x.py Executable file
View File

@@ -0,0 +1,121 @@
#!/usr/bin/env python
"""
Project: pyGTKtalog
Description: convert db created with v.1.x into v.2.x
Type: tool
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2009-08-14
"""
import sys
import os
import bz2
import shutil
from tempfile import mkstemp
from sqlite3 import dbapi2 as sqlite
from datetime import datetime
# import db objects just to create schema
from pygtktalog.dbobjects import File, Exif, Group, Gthumb
from pygtktalog.dbobjects import Image, Tag, Thumbnail
from pygtktalog.dbcommon import connect
def create_schema(cur):
pass
def create_temporary_db_file():
"""create temporary db file"""
fd, fname = mkstemp()
os.close(fd)
return fname
def connect_to_db(filename):
"""initialize db connection and store it in class attributes"""
db_connection = sqlite.connect(filename, \
detect_types=sqlite.PARSE_DECLTYPES | sqlite.PARSE_COLNAMES)
db_cursor = db_connection.cursor()
return db_connection, db_cursor
def opendb(filename=None):
"""try to open db file"""
db_tmp_path = create_temporary_db_file()
try:
test_file = open(filename).read(15)
except IOError:
os.unlink(db_tmp_path)
return False
if test_file == "SQLite format 3":
db_tmp = open(db_tmp_path, "wb")
db_tmp.write(open(filename).read())
db_tmp.close()
elif test_file[0:10] == "BZh91AY&SY":
open_file = bz2.BZ2File(filename)
try:
curdb = open(db_tmp_path, "w")
curdb.write(open_file.read())
curdb.close()
open_file.close()
except IOError:
# file is not bz2
os.unlink(db_tmp_path)
return False
else:
os.unlink(db_tmp_path)
return False
return connect_to_db(db_tmp_path), db_tmp_path
if __name__ == "__main__":
if len(sys.argv) != 3:
print "usage: %s src_base dst_base" % sys.argv[0]
exit()
result = opendb(sys.argv[1])
if not result:
print "unable to open src db file"
exit()
(src_con, src_c), src_tmpf = result
shutil.copy(src_tmpf, sys.argv[2])
# close src db.
src_c.close()
src_con.close()
os.unlink(src_tmpf)
# create or update shema
connect(sys.argv[2])
dst_con = sqlite.connect(sys.argv[2])
dst_c = dst_con.cursor()
sql = "select id, date from files"
for id, date in dst_c.execute(sql).fetchall():
sql = "update files set date=? where id=?"
if date and int(date) > 0:
dst_c.execute(sql, (datetime.fromtimestamp(int(date)), id))
else:
dst_c.execute(sql, (None, id))
sql = "select id, date from gthumb"
for id, date in dst_c.execute(sql).fetchall():
sql = "update gthumb set date=? where id=?"
try:
if int(date) > 0:
dst_c.execute(sql, (datetime.fromtimestamp(int(date)), id))
else:
dst_c.execute(sql, (None, id))
except:
print id, date
dst_con.commit()
dst_c.close()
dst_con.close()

View File

@@ -1,28 +0,0 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
device (cd, dvd) helper
"""
import string
import os
def volname(dev):
"""read volume name from cd/dvd"""
try:
a = open(dev,"rb")
a.seek(32808)
b = a.read(32).strip()
a.close()
except:
return None
return b
def volmount(dev):
"""mount device, return True/False"""
stout,stin,sterr = popen3("mount %s" % dev)
error = sterr.readline()
stout.close()
stin.close()
sterr.close()
return len(error) == 0

View File

@@ -1,394 +0,0 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<widget class="GtkWindow" id="main">
<property name="title" translatable="yes">mainW</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<signal name="destroy" handler="on_main_destroy_event" last_modification_time="Tue, 22 Aug 2006 19:12:49 GMT"/>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkMenuBar" id="mainMenubar">
<property name="visible">True</property>
<child>
<widget class="GtkMenuItem" id="menuitem1">
<property name="visible">True</property>
<property name="label" translatable="yes">_File</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="menuitem1_menu">
<child>
<widget class="GtkImageMenuItem" id="new1">
<property name="visible">True</property>
<property name="label">gtk-new</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_new1_activate" last_modification_time="Wed, 09 Aug 2006 17:12:54 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="open1">
<property name="visible">True</property>
<property name="label">gtk-open</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_open1_activate" last_modification_time="Wed, 09 Aug 2006 17:12:54 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="save1">
<property name="visible">True</property>
<property name="label">gtk-save</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_save1_activate" last_modification_time="Wed, 09 Aug 2006 17:12:54 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="save_as1">
<property name="visible">True</property>
<property name="label">gtk-save-as</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_save_as1_activate" last_modification_time="Wed, 09 Aug 2006 17:12:54 GMT"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator1">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="recent_files1">
<property name="visible">True</property>
<property name="label" translatable="yes">Recent files</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_recent_files1_activate" last_modification_time="Thu, 23 Nov 2006 18:29:26 GMT"/>
<child>
<widget class="GtkMenu" id="recent_files1_menu">
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separatormenuitem1">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="quit1">
<property name="visible">True</property>
<property name="label">gtk-quit</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_quit1_activate" last_modification_time="Wed, 09 Aug 2006 17:12:54 GMT"/>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="menuitem2">
<property name="visible">True</property>
<property name="label" translatable="yes">_Edit</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="menuitem2_menu">
<child>
<widget class="GtkImageMenuItem" id="properties1">
<property name="visible">True</property>
<property name="label">gtk-properties</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_properties1_activate" last_modification_time="Wed, 09 Aug 2006 17:14:08 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="cut1">
<property name="visible">True</property>
<property name="label">gtk-cut</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_cut1_activate" last_modification_time="Wed, 09 Aug 2006 17:12:54 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="copy1">
<property name="visible">True</property>
<property name="label">gtk-copy</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_copy1_activate" last_modification_time="Wed, 09 Aug 2006 17:12:54 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="paste1">
<property name="visible">True</property>
<property name="label">gtk-paste</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_paste1_activate" last_modification_time="Wed, 09 Aug 2006 17:12:54 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="delete1">
<property name="visible">True</property>
<property name="label">gtk-delete</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_delete1_activate" last_modification_time="Wed, 09 Aug 2006 17:12:54 GMT"/>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="catalog1">
<property name="visible">True</property>
<property name="label" translatable="yes">_Catalog</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="catalog1_menu">
<child>
<widget class="GtkMenuItem" id="add_cd">
<property name="visible">True</property>
<property name="label" translatable="yes">Add CD/DVD</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_add_cd_activate" last_modification_time="Fri, 24 Nov 2006 14:12:30 GMT"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="add_directory1">
<property name="visible">True</property>
<property name="label" translatable="yes">Add Directory</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_add_directory1_activate" last_modification_time="Fri, 24 Nov 2006 14:12:30 GMT"/>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="menuitem3">
<property name="visible">True</property>
<property name="label" translatable="yes">_View</property>
<property name="use_underline">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="menuitem4">
<property name="visible">True</property>
<property name="label" translatable="yes">_Help</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="menuitem4_menu">
<child>
<widget class="GtkMenuItem" id="about1">
<property name="visible">True</property>
<property name="label" translatable="yes">_About</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_about1_activate" last_modification_time="Wed, 09 Aug 2006 17:12:54 GMT"/>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkHPaned" id="hpaned1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="position">0</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="discs">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">False</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
</widget>
</child>
</widget>
<packing>
<property name="shrink">True</property>
<property name="resize">False</property>
</packing>
</child>
<child>
<widget class="GtkVPaned" id="vpaned1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="position">0</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="files">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
</widget>
</child>
</widget>
<packing>
<property name="shrink">True</property>
<property name="resize">False</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="detailplace">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="details">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="overwrite">False</property>
<property name="accepts_tab">False</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_NONE</property>
<property name="cursor_visible">False</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
</widget>
</child>
</widget>
<packing>
<property name="shrink">True</property>
<property name="resize">True</property>
</packing>
</child>
</widget>
<packing>
<property name="shrink">True</property>
<property name="resize">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkStatusbar" id="mainStatus">
<property name="visible">True</property>
<property name="has_resize_grip">False</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkProgressBar" id="progressbar1">
<property name="visible">True</property>
<property name="orientation">GTK_PROGRESS_LEFT_TO_RIGHT</property>
<property name="fraction">0</property>
<property name="pulse_step">0.10000000149</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

375
locale/pl.po Normal file
View File

@@ -0,0 +1,375 @@
#
# pygtktalog Language File
#
msgid ""
msgstr ""
"Project-Id-Version: pygtktalog\n"
"POT-Creation-Date: 2009-08-26 22:10:33.892815\n"
"Last-Translator: Roman Dobosz<gryf73@gmail.com>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: utf-8\n"
"Generated-By: slightly modified generate_pot.py\n"
#: pygtktalog/views/glade/main.glade.h:1
msgid "Add CD"
msgstr "Dodaj CD"
#: pygtktalog/views/glade/main.glade.h:2
msgid "Add CD/DVD to catalog"
msgstr "Dodaj CD/DVD do katalogu"
#: pygtktalog/views/glade/main.glade.h:3
msgid "Add Dir"
msgstr "Dodaj katalog"
#: pygtktalog/views/glade/main.glade.h:4
msgid "Add _CD/DVD"
msgstr "Dodaj _Cd/DVD"
#: pygtktalog/views/glade/main.glade.h:5
msgid "Add _Directory"
msgstr "Dodaj kata_log"
#: pygtktalog/views/glade/main.glade.h:6
#: pygtktalog/views/glade/files.glade.h:1
msgid "Add _Images"
msgstr "Dodaj _obrazy"
#: pygtktalog/views/glade/main.glade.h:7
#: pygtktalog/views/glade/files.glade.h:2
msgid "Add _Thumbnail"
msgstr "Dodaj miniaturÄ™"
#: pygtktalog/views/glade/main.glade.h:8
#: pygtktalog/views/glade/files.glade.h:3
msgid ""
"Add images to file. If file have no thumbnail,\n"
"thumbnail from first image will be generated."
msgstr ""
"Dodanie obrazów do pliku. Jeśli plik nie posiada miniatury,\n"
"zostanie wygenerowana miniatura z pierwszego obrazu."
#: pygtktalog/views/glade/main.glade.h:10
#: pygtktalog/views/glade/main.glade.h:6
msgid "Cancel"
msgstr "Analuj"
#: pygtktalog/views/glade/main.glade.h:11
#: pygtktalog/views/glade/main.glade.h:7
msgid "Catalog _statistics"
msgstr "_Statystyka katalogu"
#: pygtktalog/views/glade/main.glade.h:12
#: pygtktalog/views/glade/discs.glade.h:1
msgid "Collapse all nodes"
msgstr "Zwiń wszystkie gałęzie"
#: pygtktalog/views/glade/main.glade.h:13
#: pygtktalog/views/glade/main.glade.h:8
msgid "Create new catalog"
msgstr "UtwĂłrz nowy katalog"
#: pygtktalog/views/glade/main.glade.h:14
#: pygtktalog/views/glade/main.glade.h:9
msgid "Delete all images"
msgstr "Usuń wszystkie obrazy"
#: pygtktalog/views/glade/main.glade.h:15
#: pygtktalog/views/glade/main.glade.h:10
msgid "Delete all thumbnals"
msgstr "Usuń wszystkie miniatury"
#: pygtktalog/views/glade/main.glade.h:16
#: pygtktalog/views/glade/main.glade.h:11
msgid "Delete tag"
msgstr "Usuń tag"
#: pygtktalog/views/glade/main.glade.h:17
#: pygtktalog/views/glade/main.glade.h:12
msgid "Deletes all images from files in current colection"
msgstr "Usuwa wszystkie obrazy z plikĂłw w bieĹĽÄ…cej kolekcji"
#: pygtktalog/views/glade/main.glade.h:18
#: pygtktalog/views/glade/main.glade.h:13
msgid "Discs"
msgstr "Dyski"
#: pygtktalog/views/glade/main.glade.h:19
#: pygtktalog/views/glade/details.glade.h:1
msgid "Double click to open image"
msgstr "Dwukrotne kliknięcie otwiera obraz"
#: pygtktalog/views/glade/main.glade.h:20
#: pygtktalog/views/glade/details.glade.h:2
msgid "EXIF"
msgstr "EXIF"
#: pygtktalog/views/glade/main.glade.h:21
#: pygtktalog/views/glade/discs.glade.h:2
msgid "Expand all nodes"
msgstr "Rozwiń wszystkie gałęzie"
#: pygtktalog/views/glade/main.glade.h:22
#: pygtktalog/views/glade/main.glade.h:14
msgid "Export"
msgstr "Eksport"
#: pygtktalog/views/glade/main.glade.h:23
#: pygtktalog/views/glade/details.glade.h:3
msgid "File info"
msgstr "Informacje o pliku"
#: pygtktalog/views/glade/main.glade.h:24
#: pygtktalog/views/glade/main.glade.h:15
msgid "Find file"
msgstr "ZnajdĹş plik"
#: pygtktalog/views/glade/main.glade.h:25
#: pygtktalog/views/glade/details.glade.h:4
msgid "Images"
msgstr "Obrazy"
#: pygtktalog/views/glade/main.glade.h:26
#: pygtktalog/views/glade/main.glade.h:16
msgid "Import"
msgstr "Import"
#: pygtktalog/views/glade/main.glade.h:27
#: pygtktalog/views/glade/main.glade.h:17
msgid "Open catalog file"
msgstr "OtwĂłrz plik katalogu"
#: pygtktalog/views/glade/main.glade.h:28
#: pygtktalog/views/glade/main.glade.h:18
msgid "Quit pyGTKtalog"
msgstr "Zakończ pyGTKtalog"
#: pygtktalog/views/glade/main.glade.h:29
#: pygtktalog/views/glade/files.glade.h:5
msgid "Re_move Thumbnail"
msgstr "Usuń miniaturę"
#: pygtktalog/views/glade/main.glade.h:30
#: pygtktalog/views/glade/main.glade.h:19
msgid "Recent files"
msgstr "Ostatnio uĹĽywane pliki"
#: pygtktalog/views/glade/main.glade.h:31
#: pygtktalog/views/glade/files.glade.h:6
msgid "Rem_ove All Images"
msgstr "Usuń wszystkie obrazy"
#: pygtktalog/views/glade/main.glade.h:32
#: pygtktalog/views/glade/files.glade.h:7
msgid "Remo_ve tag"
msgstr "Usuń tag"
#: pygtktalog/views/glade/main.glade.h:33
#: pygtktalog/views/glade/main.glade.h:20
msgid "Save all images..."
msgstr "Zapisz wszytkie obrazy..."
#: pygtktalog/views/glade/main.glade.h:34
#: pygtktalog/views/glade/main.glade.h:21
msgid "Save catalog"
msgstr "Zapisz katalog"
#: pygtktalog/views/glade/main.glade.h:35
#: pygtktalog/views/glade/main.glade.h:22
msgid "Set as _thumbnail"
msgstr "Ustaw jako miniaturÄ™"
#: pygtktalog/views/glade/main.glade.h:36
#: pygtktalog/views/glade/main.glade.h:23
msgid "Status bar"
msgstr "Pasek stanu"
#: pygtktalog/views/glade/main.glade.h:37
#: pygtktalog/views/glade/main.glade.h:24
msgid "Tags"
msgstr "Tagi"
#: pygtktalog/views/glade/main.glade.h:38
#: pygtktalog/views/glade/main.glade.h:25
msgid "Toolbar"
msgstr "Pasek narzędzi"
#: pygtktalog/views/glade/main.glade.h:39
#: pygtktalog/views/glade/main.glade.h:26
msgid "_Add images"
msgstr "Dodaj obrazy"
#: pygtktalog/views/glade/main.glade.h:40
#: pygtktalog/views/glade/files.glade.h:8
msgid "_Add tag"
msgstr "_Dodaj tag"
#: pygtktalog/views/glade/main.glade.h:41
#: pygtktalog/views/glade/main.glade.h:27
msgid "_Catalog"
msgstr "_Katalog"
#: pygtktalog/views/glade/main.glade.h:42
#: pygtktalog/views/glade/discs.glade.h:3
msgid "_Collapse all"
msgstr "_Zwiń wszystko"
#: pygtktalog/views/glade/main.glade.h:43
#: pygtktalog/views/glade/discs.glade.h:4
#: pygtktalog/views/glade/files.glade.h:9
msgid "_Delete"
msgstr "_Usuń"
#: pygtktalog/views/glade/main.glade.h:44
#: pygtktalog/views/glade/main.glade.h:28
msgid "_Delete images"
msgstr "Usuń obrazy"
#: pygtktalog/views/glade/main.glade.h:45
#: pygtktalog/views/glade/main.glade.h:29
#: pygtktalog/views/glade/files.glade.h:10
#: pygtktalog/views/glade/test.glade.h:1
msgid "_Edit"
msgstr "_Edycja"
#: pygtktalog/views/glade/main.glade.h:46
#: pygtktalog/views/glade/discs.glade.h:5
msgid "_Expand all"
msgstr "_Rozwiń wszystko"
#: pygtktalog/views/glade/main.glade.h:47 pygtktalog/views/main_menu.py:19
#: pygtktalog/views/glade/main.glade.h:30
#: pygtktalog/views/glade/test.glade.h:2
msgid "_File"
msgstr "_Plik"
#: pygtktalog/views/glade/main.glade.h:48
#: pygtktalog/views/glade/main.glade.h:31
#: pygtktalog/views/glade/test.glade.h:3
msgid "_Help"
msgstr "_Pomoc"
#: pygtktalog/views/glade/main.glade.h:49
#: pygtktalog/views/glade/main.glade.h:32
msgid "_Remove Thumbnail"
msgstr "Usuń miniaturę"
#: pygtktalog/views/glade/main.glade.h:50
#: pygtktalog/views/glade/discs.glade.h:6
#: pygtktalog/views/glade/files.glade.h:11
msgid "_Rename"
msgstr "_Zmień nazwę"
#: pygtktalog/views/glade/main.glade.h:51
#: pygtktalog/views/glade/main.glade.h:33
msgid "_Save images to..."
msgstr "Zapisz obrazy do..."
#: pygtktalog/views/glade/main.glade.h:52
#: pygtktalog/views/glade/discs.glade.h:7
msgid "_Statistics"
msgstr "_Statystyka"
#: pygtktalog/views/glade/main.glade.h:53
#: pygtktalog/views/glade/discs.glade.h:8
msgid "_Update"
msgstr "_Uaktualnij"
#: pygtktalog/views/glade/main.glade.h:54
#: pygtktalog/views/glade/main.glade.h:34
#: pygtktalog/views/glade/test.glade.h:4
msgid "_View"
msgstr "_Widok"
#: pygtktalog/views/glade/main.glade.h:55
msgid "gtk-clear"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:56
#: pygtktalog/views/glade/main.glade.h:35
msgid "pyGTKtalog"
msgstr "pyGTKtalog"
#: pygtktalog/views/glade/main.glade.h:57
#: pygtktalog/views/glade/main.glade.h:36
msgid "pyGTKtalog - Image"
msgstr "pyGTKtalog - Obraz"
#: pygtktalog/controllers/main.py:47
msgid "Do you really want to quit?"
msgstr "Czy na pewno chcesz zakończyć?"
#: pygtktalog/controllers/main.py:48
msgid "Current database is not saved, any changes will be lost."
msgstr "BieĹĽÄ…cy katalog nie jest zapisany, wszelkie zmiany zostanÄ… utracone."
#: pygtktalog/controllers/main.py:48 pygtktalog/controllers/main.py:49
msgid "Quit application"
msgstr "Zakończ aplikację"
#: pygtktalog/models/main.py:16 pygtktalog/models/main.py:31
msgid "Idle"
msgstr "Bezczynny"
#: pygtktalog/controllers/files.py:33
#, fuzzy
msgid "Disc"
msgstr "Dyski"
#: pygtktalog/controllers/files.py:39
#, fuzzy
msgid "Filename"
msgstr "_Zmień nazwę"
#: pygtktalog/controllers/files.py:50
msgid "Path"
msgstr ""
#: pygtktalog/controllers/files.py:56
msgid "Size"
msgstr ""
#: pygtktalog/controllers/files.py:61
msgid "Date"
msgstr ""
#: pygtktalog/views/glade/test.glade.h:5
msgid "gtk-about"
msgstr ""
#: pygtktalog/views/glade/test.glade.h:6
msgid "gtk-copy"
msgstr ""
#: pygtktalog/views/glade/test.glade.h:7
msgid "gtk-cut"
msgstr ""
#: pygtktalog/views/glade/test.glade.h:8
msgid "gtk-delete"
msgstr ""
#: pygtktalog/views/glade/test.glade.h:9
msgid "gtk-new"
msgstr ""
#: pygtktalog/views/glade/test.glade.h:10
msgid "gtk-open"
msgstr ""
#: pygtktalog/views/glade/test.glade.h:11
msgid "gtk-paste"
msgstr ""
#: pygtktalog/views/glade/test.glade.h:12
msgid "gtk-quit"
msgstr ""
#: pygtktalog/views/glade/test.glade.h:13
msgid "gtk-save"
msgstr ""
#: pygtktalog/views/glade/test.glade.h:14
msgid "gtk-save-as"
msgstr ""

370
locale/pygtktalog.pot Normal file
View File

@@ -0,0 +1,370 @@
#
# pygtktalog Language File
#
msgid ""
msgstr ""
"Project-Id-Version: pygtktalog\n"
"POT-Creation-Date: 2009-08-26 22:10:33.892815\n"
"Last-Translator: Roman Dobosz<gryf73@gmail.com>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: utf-8\n"
#: pygtktalog/views/glade/main.glade.h:1
msgid "Add CD"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:2
msgid "Add CD/DVD to catalog"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:3
msgid "Add Dir"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:4
msgid "Add _CD/DVD"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:5
msgid "Add _Directory"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:6
#: pygtktalog/views/glade/files.glade.h:1
msgid "Add _Images"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:7
#: pygtktalog/views/glade/files.glade.h:2
msgid "Add _Thumbnail"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:8
#: pygtktalog/views/glade/files.glade.h:3
msgid ""
"Add images to file. If file have no thumbnail,\n"
"thumbnail from first image will be generated."
msgstr ""
#: pygtktalog/views/glade/main.glade.h:10
#: pygtktalog/views/glade/main.glade.h:6
msgid "Cancel"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:11
#: pygtktalog/views/glade/main.glade.h:7
msgid "Catalog _statistics"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:12
#: pygtktalog/views/glade/discs.glade.h:1
msgid "Collapse all nodes"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:13
#: pygtktalog/views/glade/main.glade.h:8
msgid "Create new catalog"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:14
#: pygtktalog/views/glade/main.glade.h:9
msgid "Delete all images"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:15
#: pygtktalog/views/glade/main.glade.h:10
msgid "Delete all thumbnals"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:16
#: pygtktalog/views/glade/main.glade.h:11
msgid "Delete tag"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:17
#: pygtktalog/views/glade/main.glade.h:12
msgid "Deletes all images from files in current colection"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:18
#: pygtktalog/views/glade/main.glade.h:13
msgid "Discs"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:19
#: pygtktalog/views/glade/details.glade.h:1
msgid "Double click to open image"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:20
#: pygtktalog/views/glade/details.glade.h:2
msgid "EXIF"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:21
#: pygtktalog/views/glade/discs.glade.h:2
msgid "Expand all nodes"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:22
#: pygtktalog/views/glade/main.glade.h:14
msgid "Export"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:23
#: pygtktalog/views/glade/details.glade.h:3
msgid "File info"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:24
#: pygtktalog/views/glade/main.glade.h:15
msgid "Find file"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:25
#: pygtktalog/views/glade/details.glade.h:4
msgid "Images"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:26
#: pygtktalog/views/glade/main.glade.h:16
msgid "Import"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:27
#: pygtktalog/views/glade/main.glade.h:17
msgid "Open catalog file"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:28
#: pygtktalog/views/glade/main.glade.h:18
msgid "Quit pyGTKtalog"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:29
#: pygtktalog/views/glade/files.glade.h:5
msgid "Re_move Thumbnail"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:30
#: pygtktalog/views/glade/main.glade.h:19
msgid "Recent files"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:31
#: pygtktalog/views/glade/files.glade.h:6
msgid "Rem_ove All Images"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:32
#: pygtktalog/views/glade/files.glade.h:7
msgid "Remo_ve tag"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:33
#: pygtktalog/views/glade/main.glade.h:20
msgid "Save all images..."
msgstr ""
#: pygtktalog/views/glade/main.glade.h:34
#: pygtktalog/views/glade/main.glade.h:21
msgid "Save catalog"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:35
#: pygtktalog/views/glade/main.glade.h:22
msgid "Set as _thumbnail"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:36
#: pygtktalog/views/glade/main.glade.h:23
msgid "Status bar"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:37
#: pygtktalog/views/glade/main.glade.h:24
msgid "Tags"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:38
#: pygtktalog/views/glade/main.glade.h:25
msgid "Toolbar"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:39
#: pygtktalog/views/glade/main.glade.h:26
msgid "_Add images"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:40
#: pygtktalog/views/glade/files.glade.h:8
msgid "_Add tag"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:41
#: pygtktalog/views/glade/main.glade.h:27
msgid "_Catalog"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:42
#: pygtktalog/views/glade/discs.glade.h:3
msgid "_Collapse all"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:43
#: pygtktalog/views/glade/discs.glade.h:4
#: pygtktalog/views/glade/files.glade.h:9
msgid "_Delete"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:44
#: pygtktalog/views/glade/main.glade.h:28
msgid "_Delete images"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:45
#: pygtktalog/views/glade/main.glade.h:29
#: pygtktalog/views/glade/files.glade.h:10
#: pygtktalog/views/glade/test.glade.h:1
msgid "_Edit"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:46
#: pygtktalog/views/glade/discs.glade.h:5
msgid "_Expand all"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:47 pygtktalog/views/main_menu.py:19
#: pygtktalog/views/glade/main.glade.h:30
#: pygtktalog/views/glade/test.glade.h:2
msgid "_File"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:48
#: pygtktalog/views/glade/main.glade.h:31
#: pygtktalog/views/glade/test.glade.h:3
msgid "_Help"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:49
#: pygtktalog/views/glade/main.glade.h:32
msgid "_Remove Thumbnail"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:50
#: pygtktalog/views/glade/discs.glade.h:6
#: pygtktalog/views/glade/files.glade.h:11
msgid "_Rename"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:51
#: pygtktalog/views/glade/main.glade.h:33
msgid "_Save images to..."
msgstr ""
#: pygtktalog/views/glade/main.glade.h:52
#: pygtktalog/views/glade/discs.glade.h:7
msgid "_Statistics"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:53
#: pygtktalog/views/glade/discs.glade.h:8
msgid "_Update"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:54
#: pygtktalog/views/glade/main.glade.h:34
#: pygtktalog/views/glade/test.glade.h:4
msgid "_View"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:55
msgid "gtk-clear"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:56
#: pygtktalog/views/glade/main.glade.h:35
msgid "pyGTKtalog"
msgstr ""
#: pygtktalog/views/glade/main.glade.h:57
#: pygtktalog/views/glade/main.glade.h:36
msgid "pyGTKtalog - Image"
msgstr ""
#: pygtktalog/controllers/main.py:47
msgid "Do you really want to quit?"
msgstr ""
#: pygtktalog/controllers/main.py:48
msgid "Current database is not saved, any changes will be lost."
msgstr ""
#: pygtktalog/controllers/main.py:48 pygtktalog/controllers/main.py:49
msgid "Quit application"
msgstr ""
#: pygtktalog/models/main.py:16 pygtktalog/models/main.py:31
msgid "Idle"
msgstr ""
#: pygtktalog/controllers/files.py:33
msgid "Disc"
msgstr ""
#: pygtktalog/controllers/files.py:39
msgid "Filename"
msgstr ""
#: pygtktalog/controllers/files.py:50
msgid "Path"
msgstr ""
#: pygtktalog/controllers/files.py:56
msgid "Size"
msgstr ""
#: pygtktalog/controllers/files.py:61
msgid "Date"
msgstr ""
#: pygtktalog/views/glade/test.glade.h:5
msgid "gtk-about"
msgstr ""
#: pygtktalog/views/glade/test.glade.h:6
msgid "gtk-copy"
msgstr ""
#: pygtktalog/views/glade/test.glade.h:7
msgid "gtk-cut"
msgstr ""
#: pygtktalog/views/glade/test.glade.h:8
msgid "gtk-delete"
msgstr ""
#: pygtktalog/views/glade/test.glade.h:9
msgid "gtk-new"
msgstr ""
#: pygtktalog/views/glade/test.glade.h:10
msgid "gtk-open"
msgstr ""
#: pygtktalog/views/glade/test.glade.h:11
msgid "gtk-paste"
msgstr ""
#: pygtktalog/views/glade/test.glade.h:12
msgid "gtk-quit"
msgstr ""
#: pygtktalog/views/glade/test.glade.h:13
msgid "gtk-save"
msgstr ""
#: pygtktalog/views/glade/test.glade.h:14
msgid "gtk-save-as"
msgstr ""

View File

@@ -1,172 +0,0 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
GUI, main window class and correspondig methods for pyGTKtalog app.
"""
import sys
import os
import mimetypes
import popen2
import pygtk
import gtk
import gtk.glade
from config import Config
class PyGTKtalog:
def __init__(self):
self.conf = Config()
self.gladefile = "glade/main.glade"
self.pygtkcat = gtk.glade.XML(self.gladefile,"main")
self.window = self.pygtkcat.get_widget("main")
self.window.set_title("pyGTKtalog")
icon = gtk.gdk.pixbuf_new_from_file("pixmaps/mainicon.png")
self.window.set_icon_list(icon)
self.progress = self.pygtkcat.get_widget("progressbar1")
self.status = self.pygtkcat.get_widget("mainStatus")
self.sbSearchCId = self.status.get_context_id('detailed res')
self.sbid = self.status.push(self.sbSearchCId, "Idle")
self.detailplaceholder = self.pygtkcat.get_widget("detailplace")
self.detailplaceholder.set_sensitive(False)
self.details = self.pygtkcat.get_widget("details")
self.details.hide()
self.widgets = ("discs","files","details",'save1','save_as1','cut1','copy1','paste1','delete1','add_cd','add_directory1')
for w in self.widgets:
a = self.pygtkcat.get_widget(w)
a.set_sensitive(False)
a = self.pygtkcat.get_widget('hpaned1')
a.set_position(self.conf.confd['h'])
a = self.pygtkcat.get_widget('vpaned1')
a.set_position(self.conf.confd['v'])
self.window.resize(self.conf.confd['wx'],self.conf.confd['wy'])
# sygnały:
dic = {"on_main_destroy_event" :self.doQuit,
"on_quit1_activate" :self.doQuit,
"on_new1_activate" :self.newDB,
"on_add_cd_activate" :self.addCD,
}
# connect signals
self.pygtkcat.signal_autoconnect(dic)
self.window.connect("delete_event", self.deleteEvent)
def storeSettings(self):
"""Store window size and pane position in config file (using config object)"""
hpan = self.pygtkcat.get_widget('hpaned1')
vpan = self.pygtkcat.get_widget('vpaned1')
self.conf.confd['wx'], self.conf.confd['wy'] = self.window.get_size()
self.conf.confd['h'],self.conf.confd['v'] = hpan.get_position(), vpan.get_position()
self.conf.save()
return
def doQuit(self, widget):
"""quit and save window parameters to config file"""
try:
if widget.title:
pass
except:
self.storeSettings()
gtk.main_quit()
return False
def newDB(self,widget):
"""create database in temporary place"""
self.window.set_title("untitled - pyGTKtalog")
for w in self.widgets:
try:
a = self.pygtkcat.get_widget(w)
a.set_sensitive(True)
# PyGTK FAQ entry 23.20
except:
pass
while gtk.events_pending():
gtk.main_iteration()
#self.details.set_sensitive(True)
#self.details.destroy()
#self.details = gtk.Button("Press mi or daj");
#self.details.set_name("details")
#self.detailplaceholder.add_with_viewport(self.details)
#self.details.show()
return
def deleteEvent(self, widget, event, data=None):
"""checkout actual database changed. If so, do the necessary ask."""
self.storeSettings()
return False
def run(self):
self.window.show();
gtk.main()
def addCD(self,widget):
self.scan(self.conf.confd['cd'])
def scan(self,path):
mime = mimetypes.MimeTypes()
extensions = ('mkv','avi','ogg','mpg','wmv','mp4')
count = 0
for root,kat,plik in os.walk(path):
for p in plik:
count+=1
frac = 1.0/count
count = 1
#self.progress.set_pulse_step(0)
for root,kat,plik in os.walk(path):
for p in plik:
if p[-3:].lower() in extensions or \
mime.guess_type(p)!= (None,None) and \
mime.guess_type(p)[0].split("/")[0] == 'video':
# video only
# TODO: parametrize this loop!
info = popen2.popen4('midentify "' + os.path.join(root,p)+'"')[0].readlines()
video_format = ''
audio_codec = ''
video_codec = ''
video_x = ''
video_y = ''
for line in info:
l = line.split('=')
val = l[1].split('\n')[0]
if l[0] == 'ID_VIDEO_FORMAT':
video_format = val
elif l[0] == 'ID_AUDIO_CODEC':
audio_codec = val
elif l[0] == 'ID_VIDEO_CODEC':
video_codec = val
elif l[0] == 'ID_VIDEO_WIDTH':
video_x = val
elif l[0] == 'ID_VIDEO_HEIGHT':
video_y = val
if self.sbid != 0:
"""jeśli jest jakiś mesedż, usuń go"""
self.status.remove(self.sbSearchCId, self.sbid)
self.sbid = self.status.push(self.sbSearchCId, "Scannig: %s" % (os.path.join(root,p)))
self.progress.set_fraction(frac * count)
count+=1
# PyGTK FAQ entry 23.20
while gtk.events_pending(): gtk.main_iteration()
if self.sbid != 0:
self.status.remove(self.sbSearchCId, self.sbid)
self.sbid = self.status.push(self.sbSearchCId, "Idle")
self.progress.set_fraction(0)

228
pavement.py Normal file
View File

@@ -0,0 +1,228 @@
"""
Project: pyGTKtalog
Description: Makefile and setup.py replacement. Used python packages -
paver, nosetests. External commands - xgettext, intltool-extract, hg,
grep.
Type: management
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2009-05-07
"""
import os
import sys
import shutil
from datetime import datetime
from paver.easy import sh, dry, call_task, options, Bunch
from paver.tasks import task, needs, help, cmdopts
from paver.setuputils import setup
from paver.misctasks import generate_setup, minilib
import paver.doctools
try:
from pylint import lint
HAVE_LINT = True
except ImportError:
HAVE_LINT = False
PO_HEADER = """#
# pygtktalog Language File
#
msgid ""
msgstr ""
"Project-Id-Version: pygtktalog\\n"
"POT-Creation-Date: %(time)s\\n"
"Last-Translator: Roman Dobosz<gryf73@gmail.com>\\n"
"MIME-Version: 1.0\\n"
"Content-Type: text/plain; charset=UTF-8\\n"
"Content-Transfer-Encoding: utf-8\\n"
"""
REV = os.popen("hg sum 2>/dev/null|grep ^Revis|cut -d ' ' -f 2").readlines()
if REV:
REV = "r" + REV[0].strip()
else:
REV = '0'
LOCALES = {'pl': 'pl_PL.utf8', 'en': 'en_EN'}
POTFILE = 'locale/pygtktalog.pot'
# distutil/setuptool setup method.
setup(
name='pyGTKtalog',
version='1.99.%s' % REV,
long_description='pyGTKtalog is application similar to WhereIsIT, '
'for collecting information on files from CD/DVD '
'or directories.',
description='pyGTKtalog is a file indexing tool written in pyGTK',
author='Roman Dobosz',
author_email='gryf73@gmail.com',
url='http://google.com',
platforms=['Linux', 'BSD'],
license='GNU General Public License (GPL)',
classifiers=['Development Status :: 2 - Pre-Alpha',
'Environment :: X11 Applications :: GTK',
'Intended Audience :: End Users/Desktop',
'License :: OSI Approved :: GNU General Public License '
'(GPL)',
'Natural Language :: English',
'Natural Language :: Polish',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python',
'Topic :: Desktop Environment',
'Topic :: Utilities'],
include_package_data=True,
exclude_package_data={'': ['*.patch']},
packages=["pygtktalog"],
scripts=['bin/gtktalog.py'],
test_suite='nose.collector'
)
options(sphinx=Bunch(builddir="build", sourcedir="source"))
@task
@needs(['locale_gen', 'minilib', 'generate_setup'])
def sdist():
"""sdist with message catalogs"""
call_task("setuptools.command.sdist")
@task
@needs(['locale_gen'])
def build():
"""build with message catalogs"""
call_task("setuptools.command.build")
@task
def clean():
"""remove 'pyo', 'pyc', 'h' and '~' files"""
# clean *.pyc, *.pyo and jEdit backup files *~
for root, dummy, files in os.walk("."):
for fname in files:
if fname.endswith(".pyc") or fname.endswith(".pyo") or \
fname.endswith("~") or fname.endswith(".h") or \
fname == '.coverage':
fdel = os.path.join(root, fname)
os.unlink(fdel)
print "deleted", fdel
@task
@needs(["clean"])
def distclean():
"""make clean, and remove any dist/build/egg stuff from project"""
for dirname in [os.path.join('pygtktalog', 'locale'), 'build', 'dist',
'pyGTKtalog.egg-info']:
if os.path.exists(dirname):
shutil.rmtree(dirname, ignore_errors=True)
print "removed directory", dirname
for filename in ['paver-minilib.zip', 'setup.py', 'test/.coverage']:
if os.path.exists(filename):
os.unlink(filename)
print "deleted", filename
@task
def run():
"""run application"""
sh("PYTHONPATH=%s:$PYTHONPATH bin/gtktalog.py" % _setup_env())
#import gtktalog
#gtktalog.run()
@task
def pot():
"""generate 'pot' file out of python/glade files"""
if not os.path.exists('locale'):
os.mkdir('locale')
if not os.path.exists(POTFILE):
fname = open(POTFILE, "w")
fname.write(PO_HEADER % {'time': datetime.now()})
cmd = "xgettext --omit-header -k_ -kN_ -j -o %s %s"
cmd_glade = "intltool-extract --type=gettext/glade %s"
for walk_tuple in os.walk("pygtktalog"):
root = walk_tuple[0]
for fname in walk_tuple[2]:
if fname.endswith(".py"):
sh(cmd % (POTFILE, os.path.join(root, fname)))
elif fname.endswith(".glade"):
sh(cmd_glade % os.path.join(root, fname))
sh(cmd % (POTFILE, os.path.join(root, fname + ".h")))
@task
@needs(['pot'])
def locale_merge():
"""create or merge if exists 'po' translation files"""
potfile = os.path.join('locale', 'pygtktalog.pot')
for lang in LOCALES:
msg_catalog = os.path.join('locale', "%s.po" % lang)
if os.path.exists(msg_catalog):
sh('msgmerge -U %s %s' % (msg_catalog, potfile))
else:
shutil.copy(potfile, msg_catalog)
@task
@needs(['locale_merge'])
def locale_gen():
"""generate message catalog file for available locale files"""
full_path = os.path.join('pygtktalog', 'locale')
if not os.path.exists(full_path):
os.mkdir(full_path)
for lang in LOCALES:
lang_path = full_path
for dirname in [lang, 'LC_MESSAGES']:
lang_path = os.path.join(lang_path, dirname)
if not os.path.exists(lang_path):
os.mkdir(lang_path)
catalog_file = os.path.join(lang_path, 'pygtktalog.mo')
msg_catalog = os.path.join('locale', "%s.po" % lang)
sh('msgfmt %s -o %s' % (msg_catalog, catalog_file))
if HAVE_LINT:
@task
def pylint():
'''Check the module you're building with pylint.'''
pylintopts = ['pygtktalog']
dry('pylint %s' % (" ".join(pylintopts)), lint.Run, pylintopts)
@task
@cmdopts([('coverage', 'c', 'display coverage information')])
def test(options):
"""run unit tests"""
cmd = "PYTHONPATH=%s:$PYTHONPATH nosetests -w test" % _setup_env()
if hasattr(options.test, 'coverage'):
cmd += " --with-coverage --cover-package pygtktalog"
os.system(cmd)
@task
@needs(['locale_gen'])
def runpl():
"""run application with pl_PL localization. This is just for my
convenience"""
os.environ['LC_ALL'] = 'pl_PL.utf8'
run()
def _setup_env():
"""Helper function to set up paths"""
# current directory
this_path = os.path.dirname(os.path.abspath(__file__))
if this_path not in sys.path:
sys.path.insert(0, this_path)
return this_path

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
pixmaps/mainicon.xcf Normal file

Binary file not shown.

BIN
pixmaps/mainicon2.xcf Normal file

Binary file not shown.

View File

@@ -1,32 +0,0 @@
#!/bin/sh
## gajim
##
## Contributors for this file:
## - Yann Le Boulanger <asterix@lagaule.org>
## - Nikos Kouremenos <kourem@gmail.com>
##
## Copyright (C) 2003-2004 Yann Le Boulanger <asterix@lagaule.org>
## Vincent Hanquez <tab@snarc.org>
## Copyright (C) 2005 Yann Le Boulanger <asterix@lagaule.org>
## Vincent Hanquez <tab@snarc.org>
## Nikos Kouremenos <nkour@jabber.org>
## Dimitur Kirov <dkirov@gmail.com>
## Travis Shirk <travis@pobox.com>
## Norman Rasmussen <norman@rasmussen.co.za>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published
## by the Free Software Foundation; version 2 only.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
if [ `id -u` -eq 0 ]; then
echo "You must not launch Gajim as root, it is INSECURE"
fi
cd /mnt/data/Python/moviedb
#export PYTHONPATH="$PYTHONPATH:/usr/lib/gajim"
exec python -OO pyGTKtalog.py $@

View File

@@ -1,64 +0,0 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
pytGTKtalog.
A wannabe replacement for excellent gtktalog application.
pyGTKtalog is an application for catalogue/index files on removable media such
a CD or DVD discs, directories on hard disks or network shares.
"""
#{{{ try to import all necessary modules
import sys
import os
try:
from config import Config
except:
print "Some fundamental files are missing. try runnig pyGTKtalog in his root directory"
sys.exit(1)
conf = Config()
try:
import pygtk
#tell pyGTK, if possible, that we want GTKv2
pygtk.require("2.0")
except:
#Some distributions come with GTK2, but not pyGTK
pass
try:
import gtk
import gtk.glade
except:
print "You need to install pyGTK or GTKv2 ",
print "or set your PYTHONPATH correctly."
print "try: export PYTHONPATH=",
print "/usr/local/lib/python2.2/site-packages/"
sys.exit(1)
try:
from pysqlite2 import dbapi2 as sqlite
except:
print "pyGTKtalog uses SQLite DB.\nYou'll need to get it and the python bindings as well.\nhttp://www.sqlite.org\nhttp://initd.org/tracker/pysqlite"
sys.exit(1)
if conf.confd['exportxls']:
try:
import pyExcelerator
except:
print "You'll need pyExcelerator, if you want to export DB to XLS format.\nhttp://sourceforge.net/projects/pyexcelerator"
sys.exit(1)
# project modules
from mainWindow import PyGTKtalog
if __name__ == "__main__":
app=PyGTKtalog()
try:
app.run()
except KeyboardInterrupt:
app.storeSettings()
gtk.main_quit

1781
pygtktalog/EXIF.py Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,83 @@
diff -au EXIF.py EXIF_mine.py
--- EXIF.py 2008-07-31 15:53:50.000000000 +0200
+++ EXIF_mine.py 2009-02-25 18:39:48.000000000 +0100
@@ -251,40 +251,54 @@
2: 'CenterWeightedAverage',
3: 'Spot',
4: 'MultiSpot',
- 5: 'Pattern'}),
+ 5: 'Pattern',
+ 6: 'Partial',
+ 255: 'other'}),
0x9208: ('LightSource',
{0: 'Unknown',
1: 'Daylight',
2: 'Fluorescent',
- 3: 'Tungsten',
- 9: 'Fine Weather',
- 10: 'Flash',
+ 3: 'Tungsten (incandescent light)',
+ 4: 'Flash',
+ 9: 'Fine weather',
+ 10: 'Cloudy weather',
11: 'Shade',
- 12: 'Daylight Fluorescent',
- 13: 'Day White Fluorescent',
- 14: 'Cool White Fluorescent',
- 15: 'White Fluorescent',
- 17: 'Standard Light A',
- 18: 'Standard Light B',
- 19: 'Standard Light C',
+ 12: 'Daylight fluorescent (D 5700 - 7100K)',
+ 13: 'Day white fluorescent (N 4600 - 5400K)',
+ 14: 'Cool white fluorescent (W 3900 - 4500K)',
+ 15: 'White fluorescent (WW 3200 - 3700K)',
+ 17: 'Standard light A',
+ 18: 'Standard light B',
+ 19: 'Standard light C',
20: 'D55',
21: 'D65',
22: 'D75',
- 255: 'Other'}),
+ 23: 'D50',
+ 24: 'ISO studio tungsten',
+ 255: 'other light source',}),
0x9209: ('Flash',
- {0: 'No',
- 1: 'Fired',
- 5: 'Fired (?)', # no return sensed
- 7: 'Fired (!)', # return sensed
- 9: 'Fill Fired',
- 13: 'Fill Fired (?)',
- 15: 'Fill Fired (!)',
- 16: 'Off',
- 24: 'Auto Off',
- 25: 'Auto Fired',
- 29: 'Auto Fired (?)',
- 31: 'Auto Fired (!)',
- 32: 'Not Available'}),
+ {0: 'Flash did not fire',
+ 1: 'Flash fired',
+ 5: 'Strobe return light not detected',
+ 7: 'Strobe return light detected',
+ 9: 'Flash fired, compulsory flash mode',
+ 13: 'Flash fired, compulsory flash mode, return light not detected',
+ 15: 'Flash fired, compulsory flash mode, return light detected',
+ 16: 'Flash did not fire, compulsory flash mode',
+ 24: 'Flash did not fire, auto mode',
+ 25: 'Flash fired, auto mode',
+ 29: 'Flash fired, auto mode, return light not detected',
+ 31: 'Flash fired, auto mode, return light detected',
+ 32: 'No flash function',
+ 65: 'Flash fired, red-eye reduction mode',
+ 69: 'Flash fired, red-eye reduction mode, return light not detected',
+ 71: 'Flash fired, red-eye reduction mode, return light detected',
+ 73: 'Flash fired, compulsory flash mode, red-eye reduction mode',
+ 77: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected',
+ 79: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light detected',
+ 89: 'Flash fired, auto mode, red-eye reduction mode',
+ 93: 'Flash fired, auto mode, return light not detected, red-eye reduction mode',
+ 95: 'Flash fired, auto mode, return light detected, red-eye reduction mode'}),
0x920A: ('FocalLength', ),
0x9214: ('SubjectArea', ),
0x927C: ('MakerNote', ),

65
pygtktalog/__init__.py Normal file
View File

@@ -0,0 +1,65 @@
"""
Project: pyGTKtalog
Description: Initialization for main module - i18n and so.
Type: core
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2009-05-05
"""
__version__ = "1.9.0"
__appname__ = "pyGTKtalog"
__copyright__ = u"\u00A9 Roman 'gryf' Dobosz"
__summary__ = "%s is simple tool for managing file collections." % __appname__
__web__ = "http://bitbucket.org/gryf"
__logo_img__ = "views/pixmaps/Giant Worms.png"
import os
import sys
import locale
import gettext
import __builtin__
import gtk.glade
from logger import get_logger
__all__ = ['controllers',
'models',
'views',
'EXIF',
'dbcommon',
'dbobjects',
'dialogs',
'logger',
'misc']
GETTEXT_DOMAIN = 'pygtktalog'
# There should be message catalogs in "locale" directory placed by setup.py
# script. If there is no such directory, let's assume that message catalogs are
# placed in system wide location such as /usr/share/locale by Linux
# distribution package maintainer.
LOCALE_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)),
'locale')
try:
locale.setlocale(locale.LC_ALL, '')
except locale.Error:
# unknown locale string, fallback to C
locale.setlocale(locale.LC_ALL, 'C')
for module in gtk.glade, gettext:
if os.path.exists(LOCALE_PATH):
module.bindtextdomain(GETTEXT_DOMAIN, LOCALE_PATH)
else:
module.bindtextdomain(GETTEXT_DOMAIN)
module.textdomain(GETTEXT_DOMAIN)
# register the gettext function for the whole interpreter as "_"
__builtin__._ = gettext.gettext
# wrap errors into usefull message
def log_exception(exc_type, exc_val, traceback):
get_logger(__name__).error(exc_val)
sys.excepthook = log_exception

View File

View File

@@ -0,0 +1,18 @@
"""
Project: pyGTKtalog
Description: Controller for Details NoteBook
Type: core
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2009-08-30
"""
from gtkmvc import Controller
class DetailsController(Controller):
"""
Controller for details NoteBook.
"""
def register_view(self, view):
"""Default view registration stuff"""
pass

View File

@@ -0,0 +1,214 @@
"""
Project: pyGTKtalog
Description: Controller for Discs TreeView
Type: core
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2009-08-30
"""
import gtk
from gtkmvc import Controller
from pygtktalog.logger import get_logger
LOG = get_logger("discs ctrl")
class DiscsController(Controller):
"""
Controller for discs TreeView
"""
def __init__(self, model, view):
"""
Initialize DiscsController
"""
LOG.debug(self.__init__.__doc__.strip())
Controller.__init__(self, model, view)
self.discs_model = self.model.discs.discs
def register_view(self, view):
"""
Do DiscTree registration
"""
LOG.debug(self.register_view.__doc__.strip())
view['discs'].set_model(self.discs_model)
# register observers
self.model.discs.register_observer(self)
# connect signals to popup menu - framework somehow omits automatic
# signal connection for subviews which are not included to widgets
# tree
sigs = {'expand_all': ('activate', self.on_expand_all_activate),
'collapse_all': ('activate', self.on_collapse_all_activate),
'update': ('activate', self.on_update_activate),
'rename': ('activate', self.on_rename_activate),
'delete': ('activate', self.on_delete_activate),
'statistics': ('activate', self.on_statistics_activate)}
for signal in sigs:
view.menu[signal].connect(sigs[signal][0], sigs[signal][1])
col = gtk.TreeViewColumn('discs_column')
cellpb = gtk.CellRendererPixbuf()
cell = gtk.CellRendererText()
# make cell text editabe
cell.set_property('editable', True)
cell.connect('edited', self.on_editing_done, self.discs_model)
# TODO: find a way how to disable default return keypress on editable
# fields
col.pack_start(cellpb, False)
col.pack_start(cell, True)
col.set_attributes(cellpb, stock_id=2)
col.set_attributes(cell, text=1)
view['discs'].append_column(col)
view['discs'].show()
# treeview signals
def on_discs_button_press_event(self, treeview, event):
"""
Handle right click on discs treeview - show popup menu.
"""
LOG.debug(self.on_discs_button_press_event.__doc__.strip())
pathinfo = treeview.get_path_at_pos(int(event.x), int(event.y))
if event.button == 3:
if pathinfo:
path = pathinfo[0]
# Make sure, that there is selected row
sel = treeview.get_selection()
sel.unselect_all()
sel.select_path(path)
self._popup_menu(sel, event, event.button)
else:
self._popup_menu(None, event, event.button)
return True
def on_discs_cursor_changed(self, treeview):
"""
Show files on right treeview, after clicking the left disc treeview.
"""
LOG.debug(self.on_discs_cursor_changed.__doc__.strip())
selection = treeview.get_selection()
path = selection.get_selected_rows()[1][0]
self.model.files.refresh(self.discs_model.get_value(\
self.discs_model.get_iter(path), 0))
def on_discs_key_release_event(self, treeview, event):
"""
Watch for specific keys
"""
LOG.debug(self.on_discs_key_release_event.__doc__.strip())
if gtk.gdk.keyval_name(event.keyval) == 'Menu':
LOG.debug('Menu key pressed')
self._popup_menu(treeview.get_selection(), event, 0)
return True
return False
def on_discs_row_activated(self, treeview, path, treecolumn):
"""
If possible, expand or collapse branch of discs tree
"""
LOG.debug(self.on_discs_row_activated.__doc__.strip())
if treeview.row_expanded(path):
treeview.collapse_row(path)
else:
treeview.expand_row(path, False)
def on_editing_done(self, cell, path, new_text, model):
"""
Store changed filename text
"""
LOG.debug(self.on_editing_done.__doc__.strip())
model[path][0].filename = new_text
model[path][1] = new_text
return
# popup menu signals
def on_expand_all_activate(self, menu_item):
"""
Expand all
"""
LOG.debug(self.on_expand_all_activate.__doc__.strip())
self.view['discs'].expand_all()
def on_collapse_all_activate(self, menu_item):
"""
Collapse all
"""
LOG.debug(self.on_collapse_all_activate.__doc__.strip())
self.view['discs'].collapse_all()
def on_update_activate(self, menu_item):
"""
Trigger update specified tree entry
"""
LOG.debug(self.on_update_activate.__doc__.strip())
raise NotImplementedError
def on_rename_activate(self, menu_item):
"""
Rename disk or directory
"""
LOG.debug(self.on_rename_activate.__doc__.strip())
treeview = self.view['discs']
selection = treeview.get_selection()
path = selection.get_selected_rows()[1][0]
treeview.set_cursor(path, treeview.get_column(0), start_editing=True)
def on_delete_activate(self, menu_item):
"""
Delete disk or directory from catalog
"""
LOG.debug(self.on_delete_activate.__doc__.strip())
raise NotImplementedError
def on_statistics_activate(self, menu_item):
"""
Show statistics for selected item
"""
LOG.debug(self.on_statistics_activate.__doc__.strip())
raise NotImplementedError
# observable properties
def property_currentdir_value_change(self, model, old, new):
"""
Change of a current dir signalized by other controllers/models
"""
LOG.debug(self.property_currentdir_value_change.__doc__.strip())
self._set_cursor_to_obj_position(new)
# private methods
def _popup_menu(self, selection, event, button):
"""
Popup menu for discs treeview. Gather information from discs model,
and trigger menu popup.
"""
LOG.debug(self._popup_menu.__doc__.strip())
if selection is None:
self.view.menu.set_menu_items_sensitivity(False)
else:
model, list_of_paths = selection.get_selected_rows()
for path in list_of_paths:
self.view.menu.set_menu_items_sensitivity(True)
self.view.menu.set_update_sensitivity(model.get_value(\
model.get_iter(path), 0).parent_id == 1)
self.view.menu['discs_popup'].popup(None, None, None,
button, event.time)
def _set_cursor_to_obj_position(self, obj):
"""
Set cursor/focus to specified object postion in Discs treeview.
"""
path = self.model.discs.find_path(obj)
self.view['discs'].expand_to_path(path)
self.view['discs'].set_cursor(path)

View File

@@ -0,0 +1,282 @@
"""
Project: pyGTKtalog
Description: Controller for Files TreeView
Type: core
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2009-08-30
"""
import gtk
from gtkmvc import Controller
from pygtktalog.pygtkutils import get_tv_item_under_cursor
from pygtktalog.logger import get_logger
LOG = get_logger("files ctrl")
class FilesController(Controller):
"""
Controller for files TreeView list.
"""
def __init__(self, model, view):
"""
FilesController initialization
"""
Controller.__init__(self, model, view)
self.DND_TARGETS = [('files_tags', 0, 69)]
self.files_model = self.model.files
def register_view(self, view):
"""
Register view, and setup columns for files treeview
"""
view['files'].set_model(self.files_model.files)
sigs = {"add_tag": ("activate", self.on_add_tag1_activate),
"delete_tag": ("activate", self.on_delete_tag_activate),
"add_thumb": ("activate", self.on_add_thumb1_activate),
"remove_thumb": ("activate", self.on_remove_thumb1_activate),
"add_image": ("activate", self.on_add_image1_activate),
"remove_image": ("activate", self.on_remove_image1_activate),
"edit": ("activate", self.on_edit2_activate),
"delete": ("activate", self.on_delete3_activate),
"rename": ("activate", self.on_rename2_activate)}
for signal in sigs:
view.menu[signal].connect(sigs[signal][0], sigs[signal][1])
view['files'].get_selection().set_mode(gtk.SELECTION_MULTIPLE)
col = gtk.TreeViewColumn(_('Disc'), gtk.CellRendererText(), text=1)
col.set_sort_column_id(1)
col.set_resizable(True)
col.set_visible(False)
view['files'].append_column(col)
col = gtk.TreeViewColumn(_('Filename'))
cellpb = gtk.CellRendererPixbuf()
cell = gtk.CellRendererText()
col.pack_start(cellpb, False)
col.pack_start(cell, True)
col.set_attributes(cellpb, stock_id=7)
col.set_attributes(cell, text=2)
col.set_sort_column_id(2)
col.set_resizable(True)
self.view['files'].append_column(col)
col = gtk.TreeViewColumn(_('Path'), gtk.CellRendererText(), text=3)
col.set_sort_column_id(3)
col.set_resizable(True)
col.set_visible(False)
self.view['files'].append_column(col)
col = gtk.TreeViewColumn(_('Size'), gtk.CellRendererText(), text=4)
col.set_sort_column_id(4)
col.set_resizable(True)
self.view['files'].append_column(col)
col = gtk.TreeViewColumn(_('Date'), gtk.CellRendererText(), text=5)
col.set_sort_column_id(5)
col.set_resizable(True)
self.view['files'].append_column(col)
self.view['files'].set_search_column(2)
# setup d'n'd support
self.view['files'].drag_source_set(gtk.gdk.BUTTON1_MASK,
self.DND_TARGETS,
gtk.gdk.ACTION_COPY)
# signals
def on_files_drag_data_get(self, treeview, context, selection,
targetType, eventTime):
"""responce to "data get" DnD signal"""
# get selection, and send it to the client
if targetType == self.DND_TARGETS[0][2]:
# get selection
treesrl = treeview.get_selection()
model, list_of_paths = treesrl.get_selected_rows()
ids = []
for path in list_of_paths:
fid = model.get_value(model.get_iter(path), 0)
ids.append(fid)
string = str(tuple(ids)).replace(",)", ")")
selection.set(selection.target, 8, string)
def on_files_button_press_event(self, treeview, event):
"""
Handle right click on files treeview - show popup menu.
"""
LOG.debug("Mouse button pressed")
pathinfo = treeview.get_path_at_pos(int(event.x), int(event.y))
if event.button == 3: # Right mouse button. Show context menu.
LOG.debug("It's a right button")
if pathinfo:
path = pathinfo[0]
# Make sure, that there is selected row
sel = treeview.get_selection()
sel.unselect_all()
sel.select_path(path)
self._popup_menu(sel, event, event.button)
else:
self._popup_menu(None, event, event.button)
return True
#try:
# selection = tree.get_selection()
# model, list_of_paths = selection.get_selected_rows()
#except TypeError:
# list_of_paths = []
#if len(list_of_paths) == 0:
# # try to select item under cursor
# try:
# path, column, x, y = tree.get_path_at_pos(int(event.x),
# int(event.y))
# except TypeError:
# # failed, do not show any popup and return
# tree.get_selection().unselect_all()
# return False
# selection.select_path(path[0])
#if len(list_of_paths) > 1:
# self.view['add_image'].set_sensitive(False)
# self.view['rename'].set_sensitive(False)
# self.view['edit'].set_sensitive(False)
#else:
# self.view['add_image'].set_sensitive(True)
# self.view['rename'].set_sensitive(True)
# self.view['edit'].set_sensitive(True)
#self.__popup_menu(event, 'files_popup')
#return True
LOG.debug("It's other button")
def on_files_cursor_changed(self, treeview):
"""Show details of selected file/directory"""
file_id = get_tv_item_under_cursor(treeview)
LOG.debug("found item: %s" % file_id)
return
def on_files_key_release_event(self, treeview, event):
"""do something with pressed keys"""
if gtk.gdk.keyval_name(event.keyval) == 'Menu':
try:
selection = treeview.get_selection()
model, list_of_paths = selection.get_selected_rows()
if not list_of_paths:
return
except TypeError:
return
self._popup_menu(selection, event, 0)
if gtk.gdk.keyval_name(event.keyval) == 'BackSpace':
row, gtk_column = self.view['files'].get_cursor()
if row and gtk_column:
fileob = self.files_model.get_value(row)
if fileob.parent.parent.id != 1:
#self.files_model.refresh(fileob.parent.parent)
# TODO: synchronize with disks
self.model.discs.currentdir = fileob.parent.parent
self.view['files'].grab_focus()
def on_files_row_activated(self, files_obj, row, column):
"""
On directory doubleclick in files listview dive into desired branch.
"""
fileob = self.files_model.get_value(row=row)
if not fileob.children:
# ONLY directories. files are omitted.
return
self.files_model.refresh(fileob)
self.model.discs.currentdir = fileob
self.view['files'].grab_focus()
# TODO: synchronize with disks
return
def on_add_tag1_activate(self, menu_item):
"""
TODO
"""
LOG.debug(self.on_add_tag1_activate.__doc__.strip())
raise NotImplementedError
def on_delete_tag_activate(self, menuitem):
"""
TODO
"""
LOG.debug(self.on_delete_tag_activate.__doc__.strip())
raise NotImplementedError
def on_add_thumb1_activate(self, menuitem):
"""
TODO
"""
LOG.debug(self.on_add_thumb1_activate.__doc__.strip())
raise NotImplementedError
def on_remove_thumb1_activate(self, menuitem):
"""
TODO
"""
LOG.debug(self.on_remove_thumb1_activate.__doc__.strip())
raise NotImplementedError
def on_add_image1_activate(self, menuitem):
"""
TODO
"""
LOG.debug(self.on_add_image1_activate.__doc__.strip())
raise NotImplementedError
def on_remove_image1_activate(self, menuitem):
"""
TODO
"""
LOG.debug(self.on_remove_image1_activate.__doc__.strip())
raise NotImplementedError
def on_edit2_activate(self, menuitem):
"""
TODO
"""
LOG.debug(self.on_edit2_activate.__doc__.strip())
raise NotImplementedError
def on_delete3_activate(self, menuitem):
"""
TODO
"""
LOG.debug(self.on_delete3_activate.__doc__.strip())
raise NotImplementedError
def on_rename2_activate(self, menuitem):
"""
TODO
"""
LOG.debug(self.on_rename2_activate.__doc__.strip())
raise NotImplementedError
# private methods
def _popup_menu(self, selection, event, button):
"""
Popup menu for files treeview. Gather information from discs model,
and trigger menu popup.
"""
LOG.debug(self._popup_menu.__doc__.strip())
if selection is None:
self.view.menu.set_menu_items_sensitivity(False)
else:
model, list_of_paths = selection.get_selected_rows()
for path in list_of_paths:
self.view.menu.set_menu_items_sensitivity(True)
self.view.menu['files_popup'].popup(None, None, None,
button, event.time)

View File

@@ -0,0 +1,201 @@
"""
Project: pyGTKtalog
Description: Controller for main window
Type: core
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2009-05-02
"""
import gtk
from gtkmvc import Controller
from pygtktalog.controllers.discs import DiscsController
from pygtktalog.controllers.files import FilesController
#from pygtktalog.controllers.details import DetailsController
#from pygtktalog.controllers.tags import TagcloudController
#from pygtktalog.dialogs import yesno, okcancel, info, warn, error
from pygtktalog.dialogs import open_catalog, save_catalog, error, yesno, about
from pygtktalog.logger import get_logger
LOG = get_logger("main controller")
class MainController(Controller):
"""
Controller for main application window
"""
TITLE = "pyGTKtalog"
UNTITLED = _("untitled")
def __init__(self, model, view):
"""
Initialize MainController, add controllers for trees and details.
"""
LOG.debug(self.__init__.__doc__.strip())
Controller.__init__(self, model, view)
# add controllers for files/tags/details components
self.discs = DiscsController(model, view.discs)
self.files = FilesController(model, view.files)
#self.details = DetailsController(model, view.details)
#self.tags = TagcloudController(model, view.tags)
def register_view(self, view):
"""
Registration view for MainController class
"""
LOG.debug(self.register_view.__doc__.strip())
LOG.debug("replace hardcoded defaults with configured!")
view['main'].set_default_size(800, 600)
view['hpaned1'].set_position(200)
if not self.model.tmp_filename:
view.set_widgets_app_sensitivity(False)
view['main'].show()
# status bar
LOG.debug("register statusbar")
self.context_id = self.view['mainStatus'].get_context_id('status')
self.statusbar_id = \
self.view['mainStatus'].push(self.context_id,
self.model.status_bar_message)
# signals
def on_main_destroy_event(self, widget, event):
"""
Window destroyed. Cleanup before quit.
"""
LOG.debug(self.on_main_destroy_event.__doc__.strip())
self.on_quit_activate(widget)
return True
def on_quit_activate(self, widget):
"""
Quit and save window parameters to config file
"""
LOG.debug(self.on_quit_activate.__doc__.strip())
#if yesno(_("Do you really want to quit?"),
# _("Current database is not saved, any changes will be "
# "lost."), _("Quit application") + " - pyGTKtalog", 0):
self.model.cleanup()
LOG.debug("quit application")
gtk.main_quit()
return False
def on_new_activate(self, widget):
"""
Create new catalog file
"""
LOG.debug(self.on_new_activate.__doc__.strip())
self.model.new()
self._set_title()
self.view.set_widgets_app_sensitivity(True)
def on_open_activate(self, widget):
"""
Open catalog file
"""
LOG.debug(self.on_open_activate.__doc__.strip())
if self.model.db_unsaved and 'confirm' in self.model.config and \
self.model.config['confirm']:
if not yesno(_("Current database is not saved"),
_("Do you really want to open new file and abandon "
"current one?"),
_("Unsaved data")):
LOG.debug("Cancel opening catalog file - unsaved data remain")
return
initial_path = None
#if self.model.config.recent and self.model.config.recent[0]:
# initial_path = os.path.dirname(self.model.config.recent[0])
#if not path:
path = open_catalog(path=initial_path)
if not path:
return
# cleanup files and details
try:
self.model.files_list.clear()
except:
pass
#self.__hide_details()
#self.view['tag_path_box'].hide()
#buf = self.view['tag_cloud_textview'].get_buffer()
#buf.set_text('')
#self.view['tag_cloud_textview'].set_buffer(buf)
if not self.model.open(path):
error(_("Cannot open file."),
_("File %s cannot be open") % path,
_("Error opening file"))
else:
#self.__generate_recent_menu()
#self.__activate_ui(path)
#self.__tag_cloud()
self.view.set_widgets_app_sensitivity()
self._set_title()
return
def on_about1_activate(self, widget):
"""Show about dialog"""
about()
def on_save_activate(self, widget):
"""
Save current catalog
"""
LOG.debug(self.on_save_activate.__doc__.strip())
if not self.model.cat_fname:
self.on_save_as_activate(widget)
else:
self.model.save()
self._set_title()
def on_save_as_activate(self, widget):
"""
Save current catalog under differnet file
"""
LOG.debug(self.on_save_as_activate.__doc__.strip())
initial_path = None
#if self.model.config.recent[0]:
# initial_path = os.path.dirname(self.model.config.recent[0])
path = save_catalog(path=initial_path)
if path:
ret, err = self.model.save(path)
if ret:
#self.model.config.add_recent(path)
self._set_title()
pass
else:
error(_("Cannot write file %s.") % path,
"%s" % err,
_("Error writing file"))
# helpers
def _set_title(self):
"""
Get title of the main window, to reflect state of the catalog file
Returns:
String with apropriate title for main form
"""
LOG.debug("change the title")
if not self.model.tmp_filename:
LOG.debug("application has been initialized, title should"
" be empty")
fname = ""
elif not self.model.cat_fname:
fname = self.UNTITLED
else:
fname = self.model.cat_fname
modified = self.model.db_unsaved and "*" or ""
self.view['main'].set_title("%s%s - %s" % (fname,
modified, self.TITLE))

View File

@@ -0,0 +1,23 @@
"""
Project: pyGTKtalog
Description: Controller for Tagcloud TextView
Type: core
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2009-08-30
"""
from gtkmvc import Controller
class TagcloudController(Controller):
"""
Controller for Tagcloud TextView
"""
#def __init__(self, model, view):
# """Initialize main controller"""
# Controller.__init__(self, model, view)
# return
def register_view(self, view):
"""Default view registration stuff"""
pass

45
pygtktalog/dbcommon.py Normal file
View File

@@ -0,0 +1,45 @@
"""
Project: pyGTKtalog
Description: Common database operations.
Type: core
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2009-08-07
"""
from sqlalchemy import MetaData, create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from pygtktalog.logger import get_logger
# setup SQLAlchemy logging facility
# TODO: Logger("sqlalchemy")
# or maybe it will be better to separate sqlalchemy stuff from application
#get_logger("sqlalchemy", 'INFO')
# Prepare SQLAlchemy objects
Meta = MetaData()
Base = declarative_base(metadata=Meta)
Session = sessionmaker()
LOG = get_logger("dbcommon")
def connect(filename=None):
"""
create engine and bind to Meta object.
Arguments:
@filename - string with absolute or relative path to sqlite database
file. If None, db in-memory will be created
"""
if not filename:
filename = ':memory:'
LOG.info("db filename: %s" % filename)
connect_string = "sqlite:///%s" % filename
engine = create_engine(connect_string)
Meta.bind = engine
Meta.create_all(checkfirst=True)

299
pygtktalog/dbobjects.py Normal file
View File

@@ -0,0 +1,299 @@
"""
Project: pyGTKtalog
Description: Definition of DB objects classes. Using SQLAlchemy.
Type: core
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2009-08-07
"""
import os
from cStringIO import StringIO
from hashlib import sha256
from sqlalchemy import Column, Table, Integer, Text, Binary, \
DateTime, ForeignKey, Sequence
from sqlalchemy.orm import relation, backref
from pygtktalog.dbcommon import Base
from pygtktalog.thumbnail import ThumbCreator
IMG_PATH = "/home/gryf/.pygtktalog/imgs/" # FIXME: should be configurable
tags_files = Table("tags_files", Base.metadata,
Column("file_id", Integer, ForeignKey("files.id")),
Column("tag_id", Integer, ForeignKey("tags.id")))
TYPE = {'root': 0, 'dir': 1, 'file': 2, 'link': 3}
class File(Base):
__tablename__ = "files"
id = Column(Integer, Sequence("file_id_seq"), primary_key=True)
parent_id = Column(Integer, ForeignKey("files.id"))
filename = Column(Text)
filepath = Column(Text)
date = Column(DateTime)
size = Column(Integer)
type = Column(Integer)
source = Column(Integer)
note = Column(Text)
description = Column(Text)
checksum = Column(Text)
thumbnail = Column(Binary)
children = relation('File',
backref=backref('parent', remote_side="File.id"),
order_by=[type, filename])
tags = relation("Tag", secondary=tags_files, order_by="Tag.tag")
#thumbnail = relation("Thumbnail", backref="file")
images = relation("Image", backref="file")
def __init__(self, filename=None, path=None, date=None, size=None,
ftype=None, src=None):
"""Create file object with empty defaults"""
self.filename = filename
self.filepath = path
self.date = date
self.size = size
self.type = ftype
self.source = src
def __repr__(self):
return "<File('%s', %s)>" % (str(self.filename), str(self.id))
def generate_checksum(self):
"""
Generate checksum of first 10MB of the file
"""
if self.type != TYPE['file']:
return
buf = open(os.path.join(self.filepath, self.filename)).read(10485760)
self.checksum = sha256(buf).hexdigest()
def get_all_children(self):
"""
Return list of all node direct and indirect children
"""
def _recursive(node):
children = []
if node.children:
for child in node.children:
children += _recursive(child)
if node != self:
children.append(node)
return children
if self.children:
return _recursive(self)
else:
return []
class Group(Base):
__tablename__ = "groups"
id = Column(Integer, Sequence("group_id_seq"), primary_key=True)
name = Column(Text)
color = Column(Text)
def __init__(self, name=None, color=None):
self.name = name
self.color = color
def __repr__(self):
return "<Group('%s', %s)>" % (str(self.name), str(self.id))
class Tag(Base):
__tablename__ = "tags"
id = Column(Integer, Sequence("tags_id_seq"), primary_key=True)
group_id = Column(Integer, ForeignKey("groups.id"))
tag = Column(Text)
group = relation('Group', backref=backref('tags', remote_side="Group.id"))
files = relation("File", secondary=tags_files)
def __init__(self, tag=None, group=None):
self.tag = tag
self.group = group
def __repr__(self):
return "<Tag('%s', %s)>" % (str(self.tag), str(self.id))
#class Thumbnail(Base):
# __tablename__ = "thumbnails"
# id = Column(Integer, Sequence("thumbnail_id_seq"), primary_key=True)
# file_id = Column(Integer, ForeignKey("files.id"))
# filename = Column(Text)
#
# def __init__(self, filename=None, file_obj=None):
# self.filename = filename
# self.file = file_obj
# if self.filename:
# self.save(self.filename)
#
# def save(self, fname):
# """
# Create file related thumbnail, add it to the file object.
# """
# new_name = sha1(str(uuid1())).hexdigest()
# new_name = [new_name[start:start+10] for start in range(0,
# len(new_name),
# 10)]
# try:
# os.makedirs(os.path.join(IMG_PATH, *new_name[:-1]))
# except OSError as exc:
# if exc.errno != errno.EEXIST:
# raise
#
# ext = os.path.splitext(self.filename)[1]
# if ext:
# new_name.append("".join([new_name.pop(), ext]))
#
# thumb = thumbnail.Thumbnail(self.filename)
# thumb_tmp_name = thumb.save()
# name, ext = os.path.splitext(new_name.pop())
# new_name.append("".join([name, "_t", '.jpg']))
# self.filename = os.path.sep.join(new_name)
# shutil.move(thumb_tmp_name, os.path.join(IMG_PATH, *new_name))
#
# def get_copy(self):
# """
# Create the very same object as self with exception of id field
# """
# thumb = Thumbnail()
# thumb.filename = self.filename
# return thumb
#
# def __repr__(self):
# return "<Thumbnail('%s', %s)>" % (str(self.filename), str(self.id))
#
class Image(Base):
__tablename__ = "images"
id = Column(Integer, Sequence("images_id_seq"), primary_key=True)
file_id = Column(Integer, ForeignKey("files.id"))
image = Column(Binary)
thumb = Column(Binary)
checksum = Column(Text)
def __init__(self, filename=None, file_obj=None):
self.file = file_obj
if filename:
self.save(filename)
def save(self, fname):
"""
Save and create coressponding thumbnail (note: it differs from file
related thumbnail!)
"""
file_buffer = StringIO()
with open(fname) as f:
file_buffer.write(f.read())
self.image = file_buffer.getvalue()
self.checksum = sha256(file_buffer.getvalue()).hexdigest()
file_buffer.seek(0)
thumb = ThumbCreator(fname).generate()
if thumb:
self.thumb = thumb.getvalue()
thumb.close()
file_buffer.close()
def get_copy(self):
"""
Create the very same object as self with exception of id field
"""
img = Image()
img.image = self.image
img.thumb = self.thumb
img.checksum = self.checksum
return img
@property
def fthumb(self):
"""
Return file-like object with thumbnail
"""
if self.thumb:
buf = StringIO()
buf.write(self.thumb)
buf.seek(0)
return buf
else:
return None
@property
def fimage(self):
"""
Return file-like object with image
"""
if self.image:
buf = StringIO()
buf.write(self.image)
buf.seek(0)
return buf
else:
return None
def __repr__(self):
return "<Image(%s)>" % str(self.id)
class Exif(Base):
__tablename__ = "exif"
id = Column(Integer, Sequence("exif_id_seq"), primary_key=True)
file_id = Column(Integer, ForeignKey("files.id"))
camera = Column(Text)
date = Column(Text)
aperture = Column(Text)
exposure_program = Column(Text)
exposure_bias = Column(Text)
iso = Column(Text)
focal_length = Column(Text)
subject_distance = Column(Text)
metering_mode = Column(Text)
flash = Column(Text)
light_source = Column(Text)
resolution = Column(Text)
orientation = Column(Text)
def __init__(self):
self.camera = None
self.date = None
self.aperture = None
self.exposure_program = None
self.exposure_bias = None
self.iso = None
self.focal_length = None
self.subject_distance = None
self.metering_mode = None
self.flash = None
self.light_source = None
self.resolution = None
self.orientation = None
def __repr__(self):
return "<Exif('%s', %s)>" % (str(self.date), str(self.id))
class Gthumb(Base):
__tablename__ = "gthumb"
id = Column(Integer, Sequence("gthumb_id_seq"), primary_key=True)
file_id = Column(Integer, ForeignKey("files.id"))
note = Column(Text)
place = Column(Text)
date = Column(DateTime)
def __init__(self, note=None, place=None, date=None):
self.note = note
self.place = place
self.date = date
def __repr__(self):
return "<Gthumb('%s', '%s', %s)>" % (str(self.date), str(self.place),
str(self.id))

231
pygtktalog/dialogs.py Normal file
View File

@@ -0,0 +1,231 @@
"""
Project: pyGTKtalog
Description: Simple dialogs for interact with user
Type: helper
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2009-05-12
"""
import os
import gtk
import pygtktalog
class Dialog(object):
"""
Show simple dialog for questions
Returns: Bool - True, if "OK" button pressed, False otherwise.
"""
def __init__(self, dialog_type, message, secondary_msg="", title=""):
"""
Initialize some defaults
"""
self.dialog = None
self.buttons = gtk.BUTTONS_OK
self.ok_default = False
self.message = message
self.secondary_msg = secondary_msg
self.type = dialog_type
self.title = title
def run(self):
"""Show the dialog"""
if self.dialog is None:
self._create_dialog()
# Change default/focus from cancel/no to ok/yes. Suitable only for
# Question dialog.
# Ofcourse, if something changes in the future, this could break
# things.
if self.ok_default:
# this is tricky: Ok/Yes buttons appears as first on the list, but
# they are visibile in oposite order. This could be a bug.
button = self.dialog.get_action_area().get_children()[0]
button.grab_default()
retval = self.dialog.run()
self.dialog.destroy()
if retval == gtk.RESPONSE_OK or retval == gtk.RESPONSE_YES:
return True
return False
def _create_dialog(self):
"""Create MessageDialog widgt"""
if self.type == gtk.MESSAGE_QUESTION and \
self.buttons not in (gtk.BUTTONS_YES_NO, gtk.BUTTONS_OK_CANCEL):
self.buttons = gtk.BUTTONS_YES_NO
self.dialog = gtk.MessageDialog(buttons=self.buttons, type=self.type,
message_format=self.message)
self.dialog.format_secondary_text(self.secondary_msg)
self.dialog.set_title(self.title)
class ChooseFile(object):
"""
Common file chooser
"""
URI = None
BUTTON_PAIRS = {'cancel': (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL),
'ok': (gtk.STOCK_OK, gtk.RESPONSE_APPLY),
'save': (gtk.STOCK_SAVE, gtk.RESPONSE_APPLY),
'open': (gtk.STOCK_OPEN, gtk.RESPONSE_APPLY)}
CHOOSER_TYPES = {'open': gtk.FILE_CHOOSER_ACTION_OPEN,
'save': gtk.FILE_CHOOSER_ACTION_SAVE}
FILTERS = {'catalogs': {'name': "Catalog files",
'patterns': ("*.sqlite", "*.sqlite.bz2")},
'all': {'name': "All files", 'patterns': ("*.*",)}}
def __init__(self, title="", buttons=('cancel', 'ok'), path=None,
chooser_type="open"):
super(ChooseFile, self).__init__()
self.path = path
self.title = title
self.action = self.CHOOSER_TYPES[chooser_type]
self.buttons = []
for button in buttons:
self.buttons.append(self.BUTTON_PAIRS[button][0])
self.buttons.append(self.BUTTON_PAIRS[button][1])
self.buttons = tuple(self.buttons)
self.confirmation = False
self.dialog = None
self.filters = []
def _mk_dialog(self):
"""
Create FileChooserDialog object
"""
self.dialog = gtk.FileChooserDialog(self.title, None, self.action,
self.buttons)
self.dialog.set_action(gtk.FILE_CHOOSER_ACTION_SAVE)
self.dialog.set_default_response(gtk.RESPONSE_OK)
self.dialog.set_do_overwrite_confirmation(self.confirmation)
self.dialog.set_title(self.title)
if self.URI:
self.dialog.set_current_folder_uri(self.URI)
elif self.path and os.path.exists(self.path):
self.path = "file://" + os.path.abspath(self.path)
self.dialog.set_current_folder_uri(self.path)
for filtr in self._get_filters():
self.dialog.add_filter(filtr)
def _get_filters(self):
"""
"""
filters = []
for filter_def in self.filters:
filtr = gtk.FileFilter()
filtr.set_name(self.FILTERS[filter_def]['name'])
for pat in self.FILTERS[filter_def]['patterns']:
filtr.add_pattern(pat)
filters.append(filtr)
return filters
def run(self):
"""
Show dialog, get response.
Returns:
Returns: String - with filename, None otherwise.
"""
if self.dialog is None:
self._mk_dialog()
response = self.dialog.run()
filename = None
if response == gtk.RESPONSE_APPLY:
filename = self.dialog.get_filename()
self.__class__.URI = self.dialog.get_current_folder_uri()
self.dialog.destroy()
return filename
def yesno(message, secondarymsg="", title="", default=False):
"""Question with yes-no buttons. Returns False on 'no', True on 'yes'"""
dialog = Dialog(gtk.MESSAGE_QUESTION, message, secondarymsg, title)
dialog.buttons = gtk.BUTTONS_YES_NO
dialog.ok_default = default
return dialog.run()
def okcancel(message, secondarymsg="", title="", default=False):
"""Question with ok-cancel buttons. Returns False on 'cancel', True on
'ok'"""
dialog = Dialog(gtk.MESSAGE_QUESTION, message, secondarymsg, title)
dialog.buttons = gtk.BUTTONS_OK_CANCEL
dialog.ok_default = default
return dialog.run()
def info(message, secondarymsg="", title="", button=gtk.BUTTONS_OK):
"""Info dialog. Button defaults to gtk.BUTTONS_OK, but can be changed with
gtk.BUTTONS_CANCEL, gtk.BUTTONS_CLOSE or gtk.BUTTONS_NONE.
Always returns True."""
dialog = Dialog(gtk.MESSAGE_INFO, message, secondarymsg, title)
dialog.buttons = button
dialog.run()
return True
def warn(message, secondarymsg="", title="", button=gtk.BUTTONS_OK):
"""Warning dialog. Button defaults to gtk.BUTTONS_OK, but can be changed
with gtk.BUTTONS_CANCEL, gtk.BUTTONS_CLOSE or gtk.BUTTONS_NONE.
Always returns True."""
dialog = Dialog(gtk.MESSAGE_WARNING, message, secondarymsg, title)
dialog.buttons = button
dialog.run()
return True
def error(message, secondarymsg="", title="", button=gtk.BUTTONS_OK):
"""Error dialog. Button defaults to gtk.BUTTONS_OK, but can be changed with
gtk.BUTTONS_CANCEL, gtk.BUTTONS_CLOSE or gtk.BUTTONS_NONE.
Always returns True."""
dialog = Dialog(gtk.MESSAGE_ERROR, message, secondarymsg, title)
dialog.buttons = button
dialog.run()
return True
def open_catalog(title=_("Open catalog"), path=None):
"""
Request filename from user to open.
Returns: string - full path and filename or None
"""
requester = ChooseFile(title)
requester.filters = ['catalogs', 'all']
return requester.run()
def save_catalog(title=_("Open catalog"), path=None):
"""
Request filename from user for save.
Returns: string - full path and filename or None
"""
requester = ChooseFile(title, chooser_type="save")
requester.filters = ['catalogs', 'all']
requester.confirmation = True
return requester.run()
def about():
"""
Show About dialog
"""
dialog = gtk.AboutDialog()
dialog.set_version(pygtktalog.__version__)
dialog.set_program_name(pygtktalog.__appname__)
dialog.set_copyright(pygtktalog.__copyright__)
dialog.set_comments(pygtktalog.__summary__)
dialog.set_website(pygtktalog.__web__)
dialog.set_logo(gtk.gdk.pixbuf_new_from_file(\
os.path.join(os.path.dirname(__file__), pygtktalog.__logo_img__)))
dialog.run()
dialog.destroy()

81
pygtktalog/logger.py Normal file
View File

@@ -0,0 +1,81 @@
"""
Project: pyGTKtalog
Description: Logging functionality
Type: core
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2009-09-02
"""
import os
import sys
import logging
LEVEL = {'DEBUG': logging.DEBUG,
'INFO': logging.INFO,
'WARN': logging.WARN,
'ERROR': logging.ERROR,
'CRITICAL': logging.CRITICAL}
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(8)
RESET_SEQ = "\033[0m"
COLOR_SEQ = "\033[1;%dm"
BOLD_SEQ = "\033[1m"
COLORS = {'WARNING': YELLOW,
'INFO': GREEN,
'DEBUG': BLUE,
'CRITICAL': WHITE,
'ERROR': RED}
class ColoredFormatter(logging.Formatter):
def __init__(self, msg, use_color=True):
logging.Formatter.__init__(self, msg)
self.use_color = use_color
def format(self, record):
levelname = record.levelname
if self.use_color and levelname in COLORS:
levelname_color = COLOR_SEQ % (30 + COLORS[levelname]) \
+ levelname + RESET_SEQ
record.levelname = levelname_color
return logging.Formatter.format(self, record)
#def get_logger(module_name, level='INFO', to_file=False):
#def get_logger(module_name, level='DEBUG', to_file=True):
def get_logger(module_name, level='DEBUG', to_file=False):
"""
Prepare and return log object. Standard formatting is used for all logs.
Arguments:
@module_name - String name for Logger object.
@level - Log level (as string), one of DEBUG, INFO, WARN, ERROR and
CRITICAL.
@to_file - If True, additionally stores full log in file inside
.pygtktalog config directory and to stderr, otherwise log
is only redirected to stderr.
Returns: object of logging.Logger class
"""
path = os.path.join(os.path.expanduser("~"), ".pygtktalog", "app.log")
#path = "/dev/null"
log = logging.getLogger(module_name)
log.setLevel(LEVEL[level])
console_handler = logging.StreamHandler(sys.stderr)
console_formatter = ColoredFormatter("%(filename)s:%(lineno)s - "
"%(levelname)s - %(message)s")
console_handler.setFormatter(console_formatter)
log.addHandler(console_handler)
if to_file:
file_handler = logging.FileHandler(path)
file_formatter = logging.Formatter("%(asctime)s %(levelname)6s "
"%(filename)s: %(lineno)s - "
"%(message)s")
file_handler.setFormatter(file_formatter)
file_handler.setLevel(LEVEL[level])
log.addHandler(file_handler)
return log

22
pygtktalog/misc.py Normal file
View File

@@ -0,0 +1,22 @@
"""
Project: pyGTKtalog
Description: Misc functions used more than once in src
Type: lib
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2009-04-05
"""
def float_to_string(float_length):
"""
Parse float digit into time string
Arguments:
@number - digit to be converted into time.
Returns HH:MM:SS formatted string
"""
hour = int(float_length / 3600)
float_length -= hour*3600
minutes = int(float_length / 60)
float_length -= minutes * 60
sec = int(float_length)
return "%02d:%02d:%02d" % (hour, minutes, sec)

View File

View File

@@ -0,0 +1,31 @@
"""
Project: pyGTKtalog
Description: Model(s) for details part of the application
Type: core
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2010-11-09
"""
import gtk
import gobject
from gtkmvc import Model
class DetailsModel(Model):
"""
Main model for application.
It is responsible for communicate with database objects and I/O
operations.
"""
exif = gtk.ListStore(gobject.TYPE_PYOBJECT,
gobject.TYPE_STRING,
gobject.TYPE_STRING,
gobject.TYPE_STRING,
gobject.TYPE_UINT64,
gobject.TYPE_STRING,
gobject.TYPE_INT,
str)
__observables__ = ['exif']

107
pygtktalog/models/discs.py Normal file
View File

@@ -0,0 +1,107 @@
"""
Project: pyGTKtalog
Description: Model for discs representation
Type: core
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2009-05-02
"""
import gtk
import gobject
from gtkmvc import Model
from pygtktalog.dbobjects import File
from pygtktalog.dbcommon import Session
from pygtktalog.logger import get_logger
LOG = get_logger("discs model")
class DiscsModel(Model):
"""
Model for discs representation.
"""
currentdir = None
__observables__ = ("currentdir",)
def __init__(self):
"""
Initialization. Make some nice defaults.
"""
Model.__init__(self)
self.discs = gtk.TreeStore(gobject.TYPE_PYOBJECT,
gobject.TYPE_STRING,
str)
self.files_model = None
def clear(self):
"""
Make TreeStore empty
"""
self.discs.clear()
def refresh(self, session=Session()):
"""
Read objects from database, fill TreeStore model with discs
information
Arguments:
@session current sqlalchemy.orm.session.Session object
"""
LOG.debug("session obj: %s" % str(session))
dirs = session.query(File).filter(File.type == 1)
dirs = dirs.order_by(File.filename).all()
def get_children(parent_id=1, iterator=None):
"""
Get all children of the selected parent.
Arguments:
@parent_id - integer with id of the parent (from db)
@iterator - gtk.TreeIter, which points to a path inside model
"""
for fileob in dirs:
if fileob.parent_id == parent_id:
myiter = self.discs.insert_before(iterator, None)
self.discs.set_value(myiter, 0, fileob)
self.discs.set_value(myiter, 1, fileob.filename)
if iterator is None:
self.discs.set_value(myiter, 2, gtk.STOCK_CDROM)
else:
self.discs.set_value(myiter, 2, gtk.STOCK_DIRECTORY)
get_children(fileob.id, myiter)
return
get_children()
return True
def find_path(self, obj):
"""
Return path of specified File object (which should be the first one)
"""
path = None
gtkiter = self.discs.get_iter_first()
def get_children(iterator):
"""
Iterate through entire TreeModel, and return path for specified in
outter scope File object
"""
if self.discs.get_value(iterator, 0) == obj:
return self.discs.get_path(iterator)
if self.discs.iter_has_child(iterator):
path = get_children(self.discs.iter_children(iterator))
if path:
return path
iterator = self.discs.iter_next(iterator)
if iterator is None:
return None
return get_children(iterator)
path = get_children(gtkiter)
LOG.debug("found path for object '%s': %s" % (str(obj), str(path)))
return path

View File

@@ -0,0 +1,79 @@
"""
Project: pyGTKtalog
Description: Model for files representation
Type: core
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2010-11-12
"""
import gtk
import gobject
from gtkmvc import Model
from pygtktalog.dbcommon import Session
from pygtktalog.logger import get_logger
LOG = get_logger("files model")
class FilesModel(Model):
"""
Model for files representation
"""
def __init__(self):
"""
Initialization. Make some nice defaults.
"""
Model.__init__(self)
self.files = gtk.ListStore(gobject.TYPE_PYOBJECT,
gobject.TYPE_STRING,
gobject.TYPE_STRING,
gobject.TYPE_STRING,
gobject.TYPE_UINT64,
gobject.TYPE_STRING,
gobject.TYPE_INT,
str)
self.discs_model = None
def clear(self):
"""
Cleanup ListStore model
"""
self.files.clear()
def refresh(self, fileob):
"""
Update files ListStore
Arguments:
fileob - File object
"""
LOG.info("found %d files for File object: %s" % (len(fileob.children),
str(fileob)))
self.files.clear()
for child in fileob.children:
myiter = self.files.insert_before(None, None)
self.files.set_value(myiter, 0, child)
self.files.set_value(myiter, 1, child.parent_id \
if child.parent_id != 1 else None)
self.files.set_value(myiter, 2, child.filename)
self.files.set_value(myiter, 3, child.filepath)
self.files.set_value(myiter, 4, child.size)
self.files.set_value(myiter, 5, child.date)
self.files.set_value(myiter, 6, 1)
self.files.set_value(myiter, 7, gtk.STOCK_DIRECTORY \
if child.type == 1 else gtk.STOCK_FILE)
def get_value(self, row=None, fiter=None, column=0):
"""
TODO:
"""
if row:
fiter = self.files.get_iter(row)
if not fiter:
LOG.error("ERROR: there is no way to determine gtk_iter object!"
" Please specify valid row or gtk_iter!")
return None
return self.files.get_value(fiter, column)

289
pygtktalog/models/main.py Normal file
View File

@@ -0,0 +1,289 @@
"""
Project: pyGTKtalog
Description: Model for main application
Type: core
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2009-05-02
"""
import os
import bz2
from string import printable
from tempfile import mkstemp
import gtk
import gobject
from gtkmvc import ModelMT
from sqlalchemy import create_engine
from pygtktalog.dbobjects import File, Exif, Group, Gthumb
from pygtktalog.dbobjects import Image, Tag, Thumbnail
from pygtktalog.dbcommon import connect, Meta, Session
from pygtktalog.logger import get_logger
from pygtktalog.models.details import DetailsModel
from pygtktalog.models.discs import DiscsModel
from pygtktalog.models.files import FilesModel
LOG = get_logger("main model")
class MainModel(ModelMT):
"""
Main model for application.
It is responsible for communicate with database objects and I/O
operations.
"""
status_bar_message = _("Idle")
current_disc = None
__observables__ = ("status_bar_message", "current_disc")
def __init__(self, filename=None):
"""
Initialization. Make some nice defaults.
Arguments:
filename - String that indicates optionally compressed with bzip2
file containing sqlite3 database.
"""
ModelMT.__init__(self)
# Opened/saved database location in filesystem. Could be compressed.
self.cat_fname = filename
# Temporary (usually in /tmp) working database.
self.tmp_filename = None
self.config = {}
# SQLAlchemy session object for internal use
self._session = None
# Flag indicates, that db was compressed
# TODO: make it depend on configuration
self.compressed = False
self.db_unsaved = None
self.discs = DiscsModel()
self.files = FilesModel()
if self.cat_fname:
self.open(self.cat_fname)
def open(self, filename):
"""
Open catalog file and read db
Arguments:
@filename - see MainModel __init__ docstring.
Returns: Bool - true for success, false otherwise.
"""
LOG.debug("filename: '%s'", filename)
self.unsaved_project = False
if not os.path.exists(filename):
LOG.warn("db file '%s' doesn't exist.", filename)
return False
if not os.path.isfile(filename):
LOG.warn("db file '%s' is not a regular file.", filename)
return False
self.cat_fname = filename
if self._open_or_decompress():
return self.discs.refresh(self._session)
else:
return False
def save(self, filename=None):
"""
Save tared directory at given catalog fielname
Arguments:
@filename - see MainModel __init__ docstring.
Returns: tuple:
Bool - true for success, false otherwise.
String or None - error message
"""
if not filename and not self.cat_fname:
LOG.debug("no filename detected!")
return False, None
if filename:
if not '.sqlite' in filename:
filename += '.sqlite'
else:
filename = filename[:filename.rindex('.sqlite')] + '.sqlite'
if 'compress' in self.config and self.config['compress']:
filename += '.bz2'
self.cat_fname = filename
val, err = self._compress_and_save()
if not val:
self.cat_fname = None
return val, err
def new(self):
"""
Create new catalog
"""
self.cleanup()
self._create_temp_db_file()
self._create_schema()
self.discs.clear()
self.files.clear()
self.db_unsaved = False
def cleanup(self):
"""
Remove temporary directory tree from filesystem
"""
if self._session:
self._session.close()
self._session = None
if self.tmp_filename is None:
return
try:
os.unlink(self.tmp_filename)
except OSError:
LOG.error("temporary db file doesn't exists!")
except TypeError:
# TODO: file does not exist - create? print error message?
LOG.error("temporary db file doesn't exists!")
else:
LOG.debug("file %s succesfully deleted", self.tmp_filename)
def _examine_file(self, filename):
"""
Try to recognize file.
Arguments:
@filename - String with full path to file to examine
Returns: 'sql', 'bz2' or None for file sqlite, compressed with bzip2
or other respectively
"""
try:
head_of_file = open(filename).read(15)
LOG.debug("head of file: %s", filter(lambda x: x in printable,
head_of_file))
except IOError:
LOG.exception("Error opening file '%s'!", filename)
self.cleanup()
self.cat_fname = None
self.tmp_filename = None
return None
if head_of_file == "SQLite format 3":
LOG.debug("File format: uncompressed sqlite")
return 'sql'
elif head_of_file[0:10] == "BZh91AY&SY":
LOG.debug("File format: bzip2")
return 'bz2'
else:
return None
def _open_or_decompress(self):
"""
Try to open file, which user thinks is our catalog file.
Returns: Bool - true for success, false otherwise
"""
filename = os.path.abspath(self.cat_fname)
LOG.info("catalog file: %s", filename)
if self._session:
self.cleanup()
self._create_temp_db_file()
LOG.debug("tmp database file: %s", str(self.tmp_filename))
examine = self._examine_file(filename)
if examine == "sql":
db_tmp = open(self.tmp_filename, "wb")
db_tmp.write(open(filename).read())
db_tmp.close()
elif examine == "bz2":
open_file = bz2.BZ2File(filename)
try:
db_tmp = open(self.tmp_filename, "w")
db_tmp.write(open_file.read())
db_tmp.close()
open_file.close()
except IOError:
self.cleanup()
self.cat_fname = None
self.internal_dirname = None
LOG.exception("File is probably not a bz2!")
return False
if self._examine_file(self.tmp_filename) is not 'sql':
LOG.error("Error opening file '%s' - not a catalog file!",
self.tmp_filename)
self.cleanup()
self.cat_fname = None
self.tmp_filename = None
return False
else:
LOG.error("Error opening file '%s' - not a catalog file!",
self.tmp_filename)
self.cleanup()
self.cat_fname = None
self.internal_dirname = None
return False
connect(os.path.abspath(self.tmp_filename))
self._session = Session()
LOG.debug("session obj: %s" % str(self._session))
return True
def _create_temp_db_file(self):
"""
Create new DB file, populate schema.
"""
fd, self.tmp_filename = mkstemp()
LOG.debug("new db filename: %s" % self.tmp_filename)
# close file descriptor, otherwise it can be source of app crash!
# http://www.logilab.org/blogentry/17873
os.close(fd)
def _create_schema(self):
"""
"""
self._session = Session()
LOG.debug("session obj: %s" % str(self._session))
connect(os.path.abspath(self.tmp_filename))
root = File()
root.id = 1
root.filename = 'root'
root.size = 0
root.source = 0
root.type = 0
root.parent_id = 1
self._session.add(root)
self._session.commit()
def _compress_and_save(self):
"""
Create (and optionaly compress) tar archive from working directory and
write it to specified file.
"""
# flush all changes
self._session.commit()
try:
if 'compress' in self.config and self.config['compress']:
output_file = bz2.BZ2File(self.cat_fname, "w")
else:
output_file = open(self.cat_fname, "w")
LOG.debug("save (and optionally compress) successed")
except IOError, (errno, strerror):
LOG.error("error saving or compressing file", errno, strerror)
return False, strerror
dbpath = open(self.tmp_filename)
output_file.write(dbpath.read())
dbpath.close()
output_file.close()
self.db_unsaved = False
return True, None

25
pygtktalog/pygtkutils.py Normal file
View File

@@ -0,0 +1,25 @@
"""
Project: pyGTKtalog
Description: pyGTK common utility functions
Type: tility
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2010-11-07 13:30:37
"""
def get_tv_item_under_cursor(treeview):
"""
Get item (most probably id of the row) form tree view under cursor.
Arguments:
@treeview - gtk.TreeView
Returns:
Item in first column of TreeModel, which TreeView is connected with,
None in other cases
"""
path, column = treeview.get_cursor()
if path and column:
model = treeview.get_model()
tm_iter = model.get_iter(path)
item_id = model.get_value(tm_iter, 0)
return item_id
return None

665
pygtktalog/scan.py Normal file
View File

@@ -0,0 +1,665 @@
"""
Project: pyGTKtalog
Description: Filesystem scan and file automation layer
Type: core
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2011-03-27
"""
import os
import sys
import re
from datetime import datetime
import mimetypes
from pygtktalog.dbobjects import File, Image, TYPE
from pygtktalog.thumbnail import ThumbCreator
from pygtktalog.dbcommon import Session
from pygtktalog.logger import get_logger
from pygtktalog.video import Video
LOG = get_logger(__name__)
PAT = re.compile("(\[[^\]]*\]"
".*\(\d\d\d\d\))"
"\s[^\[]*\[.{8}\]"
".[a-zA-Z0-9]*$")
#PAT = re.compile(r'(?P<group>\[[^\]]*\]\s)?'
# r'(?P<title>.*)\s'
# r'(?P<year>\(\d{4}\))\s'
# r'(?P<kind>.*)'
# r'(?P<checksum>\[[A-Z0-9]{8}\])'
# r'\.(?P<extension>(avi|asf|mpeg|mpg|mp4|ogm|ogv|mkv|mov|wmv'
# r'|rm|rmvb|flv|jpg|png|gif|nfo))\.?(conf)?$')
class NoAccessError(Exception):
pass
class Scan(object):
"""
Retrieve and identify all files recursively on given path
"""
def __init__(self, path):
"""
Initialize
@Arguments:
@path - string with initial root directory to scan
"""
self.abort = False
self.path = path.rstrip(os.path.sep)
self._files = []
self._existing_files = [] # for re-use purpose in adding
self._existing_branch = [] # for branch storage, mainly for updating
self._session = Session()
self.files_count = self._get_files_count()
self.current_count = 0
def add_files(self):
"""
Returns list, which contain object, modification date and file
size.
"""
self._files = []
self._existing_branch = []
LOG.debug("given path: %s" % self.path)
# See, if file exists. If not it would raise OSError exception
os.stat(self.path)
if not os.access(self.path, os.R_OK | os.X_OK) \
or not os.path.isdir(self.path):
raise NoAccessError("Access to %s is forbidden" % self.path)
directory = os.path.basename(self.path)
path = os.path.dirname(self.path)
if not self._recursive(None, directory, path, 0):
return None
# add only first item from _files, because it is a root of the other,
# so other will be automatically added aswell.
self._session.add(self._files[0])
self._session.commit()
return self._files
def update_files(self, node_id):
"""
Updtate DB contents of provided node.
"""
self.current_count = 0
old_node = self._session.query(File).get(node_id)
if old_node is None:
LOG.warning("No such object in db: %s", node_id)
return
parent = old_node.parent
self._files = []
self._existing_branch = old_node.get_all_children()
self._existing_branch.insert(0, old_node)
# Break the chain of parent-children relations
for fobj in self._existing_branch:
fobj.parent = None
update_path = os.path.join(old_node.filepath, old_node.filename)
# refresh objects
self._get_all_files()
LOG.debug("path for update: %s" % update_path)
# See, if file exists. If not it would raise OSError exception
os.stat(update_path)
if not os.access(update_path, os.R_OK | os.X_OK) \
or not os.path.isdir(update_path):
raise NoAccessError("Access to %s is forbidden" % update_path)
directory = os.path.basename(update_path)
path = os.path.dirname(update_path)
if not self._recursive(parent, directory, path, 0):
return None
# update branch
#self._session.merge(self._files[0])
self._session.query(File).filter(File.parent==None).delete()
self._session.commit()
return self._files
def _get_dirsize(self, path):
"""
Returns sum of all files under specified path (also in subdirs)
"""
size = 0
for root, dirs, files in os.walk(path):
for fname in files:
try:
size += os.stat(os.path.join(root, fname)).st_size
except OSError:
LOG.warning("Cannot access file "
"%s" % os.path.join(root, fname))
return size
def _gather_information(self, fobj):
"""
Try to guess type and gather information about File object if possible
"""
mimedict = {'audio': self._audio,
'video': self._video,
'image': self._image}
fp = os.path.join(fobj.filepath.encode(sys.getfilesystemencoding()),
fobj.filename.encode(sys.getfilesystemencoding()))
mimeinfo = mimetypes.guess_type(fp)
if mimeinfo[0] and mimeinfo[0].split("/")[0] in mimedict.keys():
mimedict[mimeinfo[0].split("/")[0]](fobj, fp)
else:
LOG.debug("Filetype not supported " + str(mimeinfo) + " " + fp)
pass
def _audio(self, fobj, filepath):
return
def _image(self, fobj, filepath):
#Thumbnail(filepath, fobj)
return
def _video(self, fobj, filepath):
"""
Make captures for a movie. Save it under uniq name.
"""
result = PAT.search(fobj.filename)
if result:
self._check_related(fobj, result.groups()[0])
vid = Video(filepath)
fobj.description = vid.get_formatted_tags()
preview_fn = vid.capture()
if preview_fn:
Image(preview_fn, fobj)
def _check_related(self, fobj, pattern):
"""
Try to search for related files which belongs to specified File
object and pattern. If found, additional objects are created.
"""
for filen in os.listdir(fobj.filepath):
if pattern in filen and \
os.path.splitext(filen)[1] in (".jpg", ".png", ".gif"):
full_fname = os.path.join(fobj.filepath, filen)
LOG.debug('found cover file: %s' % full_fname)
Image(full_fname, fobj)
if not fobj.thumbnail:
fthumb = ThumbCreator(full_fname).generate()
fobj.thumbnail = fthumb.getvalue()
fthumb.close()
def _name_matcher(self, fpath, fname, media=False):
"""
Try to match special pattern to filename which may be looks like this:
[aXXo] Batman (1989) [D3ADBEEF].avi
[aXXo] Batman (1989) [D3ADBEEF].avi.conf
[aXXo] Batman (1989) cover [BEEFD00D].jpg
[aXXo] Batman (1989) cover2 [FEEDD00D].jpg
[aXXo] Batman (1989) trailer [B00B1337].avi
or
Batman (1989) [D3ADBEEF].avi (and so on)
For media=False it will return True for filename, that matches
pattern, and there are at least one corresponding media files (avi,
mpg, mov and so on) _in case the filename differs from media_. This is
usfull for not storing covers, nfo, conf files in the db.
For kind == 2 it will return all images and other files that should be
gather due to video file examinig as a dict of list (conf, nfo and
images).
"""
# TODO: dokonczyc to na podstawie tego cudowanego patternu u gory.
return
def _get_all_files(self):
self._existing_files = self._session.query(File).all()
def _mk_file(self, fname, path, parent, ftype=TYPE['file']):
"""
Create and return File object
"""
fullpath = os.path.join(path, fname)
fname = fname.decode(sys.getfilesystemencoding())
path = path.decode(sys.getfilesystemencoding())
if ftype == TYPE['link']:
fname = fname + " -> " + os.readlink(fullpath)
fob = {'filename': fname,
'path': path,
'ftype': ftype}
try:
fob['date'] = datetime.fromtimestamp(os.stat(fullpath).st_mtime)
fob['size'] = os.stat(fullpath).st_size
except OSError:
# in case of dead softlink, we will have no time and size
fob['date'] = None
fob['size'] = 0
fobj = self._get_old_file(fob, ftype)
if fobj:
LOG.debug("found existing file in db: %s" % str(fobj))
fobj.size = fob['size'] # TODO: update whole tree sizes (for directories/discs)
fobj.filepath = fob['path']
fobj.type = fob['ftype']
else:
fobj = File(**fob)
if parent is None:
fobj.parent_id = 1
else:
fobj.parent = parent
self._files.append(fobj)
return fobj
def _recursive(self, parent, fname, path, size):
"""
Do the walk through the file system
@Arguments:
@parent - directory File object which is parent for the current
scope
@fname - string that hold filename
@path - full path for further scanning
@size - size of the object
"""
if self.abort:
return False
fullpath = os.path.join(path, fname)
parent = self._mk_file(fname, path, parent, TYPE['dir'])
parent.size = self._get_dirsize(fullpath)
parent.type = TYPE['dir']
root, dirs, files = os.walk(fullpath).next()
for fname in files:
fpath = os.path.join(root, fname)
self.current_count += 1
LOG.debug("Processing %s [%s/%s]", fname, self.current_count,
self.files_count)
result = PAT.search(fname)
test_ = False
if result and os.path.splitext(fpath)[1] in ('.jpg', '.gif',
'.png'):
newpat = result.groups()[0]
matching_files = []
for fn_ in os.listdir(root):
if newpat in fn_:
matching_files.append(fn_)
if len(matching_files) > 1:
LOG.debug('found cover "%s" in group: %s, skipping', fname,
str(matching_files))
test_ = True
if test_:
continue
if os.path.islink(fpath):
fob = self._mk_file(fname, root, parent, TYPE['link'])
else:
fob = self._mk_file(fname, root, parent)
existing_obj = self._object_exists(fob)
if existing_obj:
fob.tags = existing_obj.tags
fob.thumbnail = existing_obj.thumbnail
fob.images = [img.get_copy() \
for img in existing_obj.images] # TODO: many-to-many?
else:
LOG.debug("gather information for %s",
os.path.join(root, fname))
self._gather_information(fob)
size += fob.size
if fob not in self._existing_files:
self._existing_files.append(fob)
for dirname in dirs:
dirpath = os.path.join(root, dirname)
if not os.access(dirpath, os.R_OK|os.X_OK):
LOG.info("Cannot access directory %s" % dirpath)
continue
if os.path.islink(dirpath):
fob = self._mk_file(dirname, root, parent, TYPE['link'])
else:
LOG.debug("going into %s" % os.path.join(root, dirname))
self._recursive(parent, dirname, fullpath, size)
LOG.debug("size of items: %s" % parent.size)
return True
def _get_old_file(self, fdict, ftype):
"""
Search for object with provided data in dictionary in stored branch
(which is updating). Return such object on success, remove it from
list.
"""
for index, obj in enumerate(self._existing_branch):
if ftype == TYPE['link'] and fdict['filename'] == obj.filename:
return self._existing_branch.pop(index)
elif fdict['filename'] == obj.filename and \
fdict['date'] == obj.date and \
ftype == TYPE['file'] and \
fdict['size'] in (obj.size, 0):
obj = self._existing_branch.pop(index)
obj.size = fdict['size']
return obj
elif fdict['filename'] == obj.filename:
obj = self._existing_branch.pop(index)
obj.size = fdict['date']
return obj
return False
def _object_exists(self, fobj):
"""
Perform check if current File object already exists in collection. If
so, return first matching one, None otherwise.
"""
for efobj in self._existing_files:
if efobj.size == fobj.size \
and efobj.type == fobj.type \
and efobj.date == fobj.date \
and efobj.filename == fobj.filename:
return efobj
return None
def _get_files_count(self):
count = 0
for root, dirs, files in os.walk(self.path):
count += len(files)
LOG.debug("count of files: %s", count)
return count
class asdScan(object):
"""
Retrieve and identify all files recursively on given path
"""
def __init__(self, path, tree_model):
self.path = path
self.abort = False
self.label = None
self.DIR = None
self.source = None
def scan(self):
"""
scan content of the given path
"""
self.busy = True
# count files in directory tree
LOG.debug("Calculating number of files in directory tree...")
step = 0
try:
for root, dirs, files in os.walk(self.path):
step += len(files)
except Exception, ex:
LOG.warning("exception on file %s: %s: %s" \
% (self.path, ex.__class__.__name__, str(ex)))
pass
step = 1 / float(step or 1)
self.count = 0
def _recurse(parent_id, name, path, date, size, filetype,
discs_tree_iter=None):
"""recursive scans given path"""
if self.abort:
return -1
_size = size
if parent_id == 1:
sql = """INSERT INTO
files(parent_id, filename, filepath, date,
size, type, source)
VALUES(?,?,?,?,?,?,?)"""
print(sql, (parent_id, name, path, date, size,
filetype, self.source))
else:
sql = """INSERT INTO
files(parent_id, filename, filepath, date, size, type)
VALUES(?,?,?,?,?,?)"""
print(sql, (parent_id, name, path,
date, size, filetype))
sql = """SELECT seq FROM sqlite_sequence WHERE name='files'"""
print(sql)
currentid = None #db_cursor.fetchone()[0]
try:
root, dirs, files = os.walk(path).next()
except:
LOG.warning("Cannot access ", path)
return 0
#############
# directories
for i in dirs:
j = i #j = self.__decode_filename(i)
current_dir = os.path.join(root, i)
try:
st = os.stat(current_dir)
st_mtime = st.st_mtime
except OSError:
st_mtime = 0
# do NOT follow symbolic links
if os.path.islink(current_dir):
l = self.__decode_filename(os.readlink(current_dir))
sql = """INSERT INTO
files(parent_id, filename, filepath, date, size, type)
VALUES(?,?,?,?,?,?)"""
print(sql, (currentid, j + " -> " + l,
current_dir, st_mtime, 0,
self.LIN))
dirsize = 0
else:
myit = None
dirsize = _recurse(currentid, j, current_dir,
st_mtime, 0, self.DIR, myit)
if dirsize == -1:
break
else:
_size = _size + dirsize
########
# files:
for i in files:
if self.abort:
break
self.count = self.count + 1
current_file = os.path.join(root, i)
try:
st = os.stat(current_file)
st_mtime = st.st_mtime
st_size = st.st_size
except OSError:
st_mtime = 0
st_size = 0
_size = _size + st_size
j = i #self.__decode_filename(i)
# do NOT follow symbolic links
if os.path.islink(current_file):
l = self.__decode_filename(os.readlink(current_file))
sql = """INSERT INTO
files(parent_id, filename, filepath, date, size, type)
VALUES(?,?,?,?,?,?)"""
print(sql, (currentid, j + " -> " + l,
current_file, st_mtime, 0,
self.LIN))
else:
sql = """INSERT INTO
files(parent_id, filename, filepath, date, size, type)
VALUES(?,?,?,?,?,?)"""
print(sql, (currentid, j, current_file,
st_mtime, st_size, self.FIL))
if self.count % 32 == 0:
update = True
else:
update = False
###########################
# fetch details about files
if self.config.confd['retrive']:
update = True
exif = None
sql = """SELECT seq FROM sqlite_sequence
WHERE name='files'"""
print(sql)
fileid = 1 # dummy!
ext = i.split('.')[-1].lower()
# Video
if ext in self.MOV:
v = Video(current_file)
cfn = v.capture()
img = Img(cfn, self.image_path)
th = img.save()
if th:
sql = """INSERT INTO
thumbnails(file_id, filename)
VALUES(?, ?)"""
print(sql, (fileid, th + "_t"))
sql = """INSERT INTO images(file_id, filename)
VALUES(?, ?)"""
print(sql, (fileid, th))
os.unlink(cfn)
# Images - thumbnails and exif data
if self.config.confd['thumbs'] and ext in self.IMG:
thumb = Thumbnail(current_file, self.image_path)
th, exif = thumb.save()
if th:
sql = """INSERT INTO
thumbnails(file_id, filename)
VALUES(?, ?)"""
print(sql, (fileid, th))
# exif - store data in exif table
jpg = ['jpg', 'jpeg']
if self.config.confd['exif'] and ext in jpg:
p = None
if self.config.confd['thumbs'] and exif:
p = ParseExif(exif_dict=exif)
else:
p = ParseExif(exif_file=current_file)
if not p.exif_dict:
p = None
if p:
p = p.parse()
p = list(p)
p.insert(0, fileid)
sql = """INSERT INTO exif (file_id,
camera,
date,
aperture,
exposure_program,
exposure_bias,
iso,
focal_length,
subject_distance,
metering_mode,
flash,
light_source,
resolution,
orientation)
values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"""
print(sql, (tuple(p)))
# gthumb - save comments from gThumb program
if self.config.confd['gthumb']:
gt = GthumbCommentParser(root, i)
cmnts = gt.parse()
if cmnts:
sql = """insert into gthumb(file_id,
note,
place,
date)
values(?,?,?,?)"""
print(sql, (fileid,
cmnts['note'],
cmnts['place'],
cmnts['date']))
if 'keywords' in cmnts:
# TODO: add gthumb keywords to tags
pass
# Extensions - user defined actions
if ext in self.config.confd['extensions'].keys():
cmd = self.config.confd['extensions'][ext]
arg = current_file.replace('"', '\\"')
output = os.popen(cmd % arg).readlines()
desc = ''
for line in output:
desc += line
sql = """UPDATE files SET description=?
WHERE id=?"""
print(sql, (desc, fileid))
### end of scan
if update:
self.statusmsg = "Scannig: %s" % current_file
self.progress = step * self.count
sql = """UPDATE files SET size=? WHERE id=?"""
print(sql, (_size, currentid))
if self.abort:
return -1
else:
return _size
if _recurse(1, self.label, self.path, 0, 0, self.DIR) == -1:
LOG.debug("interrupted self.abort = True")
else:
LOG.debug("recursive goes without interrupt")
if self.currentid:
LOG.debug("removing old branch")
self.statusmsg = "Removing old branch..."
self.currentid = None
self.busy = False
# refresh discs tree
self.statusmsg = "Idle"
self.progress = 0
self.abort = False

106
pygtktalog/thumbnail.py Normal file
View File

@@ -0,0 +1,106 @@
"""
Project: pyGTKtalog
Description: Create thumbnail for sepcified image by its filename
Type: lib
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2011-05-15
"""
import os
import sys
from cStringIO import StringIO
from tempfile import mkstemp
import Image
from pygtktalog.logger import get_logger
from pygtktalog import EXIF
LOG = get_logger(__name__)
class ThumbCreator(object):
"""
Class for generate/extract thumbnail from image file
"""
def __init__(self, filename):
self.thumb_x = 160
self.thumb_y = 160
self.filename = filename.decode(sys.getfilesystemencoding())
self.fobj = StringIO()
def generate(self):
"""
Generate and return file-like object with thumbnail
"""
exif = {}
orientations = {2: Image.FLIP_LEFT_RIGHT, # Mirrored horizontal
3: Image.ROTATE_180, # Rotated 180
4: Image.FLIP_TOP_BOTTOM, # Mirrored vertical
5: Image.ROTATE_90, # Mirrored horizontal then
# rotated 90 CCW
6: Image.ROTATE_270, # Rotated 90 CW
7: Image.ROTATE_270, # Mirrored horizontal then
# rotated 90 CW
8: Image.ROTATE_90} # Rotated 90 CCW
flips = {7: Image.FLIP_LEFT_RIGHT, 5: Image.FLIP_LEFT_RIGHT}
exif = self._get_exif()
file_desc, thumb_fn = mkstemp(suffix=".jpg")
os.close(file_desc)
if 'JPEGThumbnail' not in exif:
LOG.debug("no exif thumb for file %s; creating." % self.filename)
thumb = self._scale_image()
if thumb:
thumb.save(self.fobj, "JPEG")
else:
LOG.debug("exif thumb for filename %s" % self.filename)
exif_thumbnail = exif['JPEGThumbnail']
self.fobj.write(exif_thumbnail)
self.fobj.seek(0)
if 'Image Orientation' in exif:
orient = exif['Image Orientation'].values[0]
if orient > 1 and orient in orientations:
thumb_image = Image.open(self.fobj)
tmp_thumb_img = thumb_image.transpose(orientations[orient])
if orient in flips:
tmp_thumb_img = tmp_thumb_img.transpose(flips[orient])
self.fobj.seek(0)
self.fobj.truncate()
tmp_thumb_img.save(self.fobj, 'JPEG')
return self.fobj
def _get_exif(self):
"""
Get exif (if available), return as a dict
"""
image_file = open(self.filename, 'rb')
try:
exif = EXIF.process_file(image_file)
except Exception:
exif = {}
LOG.info("Exif crashed on '%s'." % self.filename)
finally:
image_file.close()
return exif
def _scale_image(self):
"""
Create thumbnail. returns image object or None
"""
try:
image_thumb = Image.open(self.filename).convert('RGB')
except:
return None
it_x, it_y = image_thumb.size
if it_x > self.thumb_x or it_y > self.thumb_y:
image_thumb.thumbnail((self.thumb_x, self.thumb_y),
Image.ANTIALIAS)
return image_thumb

281
pygtktalog/video.py Normal file
View File

@@ -0,0 +1,281 @@
"""
Project: pyGTKtalog
Description: Gather video file information, make "screenshot" with content
of the movie file. Uses external tools like mplayer.
Type: lib
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2009-04-04
"""
import os
import shutil
from tempfile import mkdtemp, mkstemp
import math
import Image
from pygtktalog.misc import float_to_string
from pygtktalog.logger import get_logger
LOG = get_logger("Video")
class Video(object):
"""Class for retrive midentify script output and put it in dict.
Usually there is no need for such a detailed movie/clip information.
Midentify script belongs to mplayer package.
"""
def __init__(self, filename, out_width=1024):
"""
Init class instance.
Arguments:
@filename - Filename of a video file (required).
@out_width - width of final image to be scaled to.
"""
self.filename = filename
self.out_width = out_width
self.tags = {}
output = self._get_movie_info()
attrs = {'ID_VIDEO_WIDTH': ['width', int],
'ID_VIDEO_HEIGHT': ['height', int],
# length is in seconds
'ID_LENGTH': ['length', lambda x: int(x.split(".")[0])],
'ID_START_TIME': ['start', self._get_start_pos],
'ID_DEMUXER': ['container', self._return_lower],
'ID_VIDEO_FORMAT': ['video_format', self._return_lower],
'ID_VIDEO_CODEC': ['video_codec', self._return_lower],
'ID_AUDIO_CODEC': ['audio_codec', self._return_lower],
'ID_AUDIO_FORMAT': ['audio_format', self._return_lower],
'ID_AUDIO_NCH': ['audio_no_channels', int]}
# TODO: what about audio/subtitle language/existence?
for key in output:
if key in attrs:
self.tags[attrs[key][0]] = attrs[key][1](output[key])
if 'length' in self.tags and self.tags['length'] > 0:
start = self.tags.get('start', 0)
length = self.tags['length'] - start
hours = length / 3600
seconds = length - hours * 3600
minutes = seconds / 60
seconds -= minutes * 60
length_str = "%02d:%02d:%02d" % (hours, minutes, seconds)
self.tags['duration'] = length_str
def capture(self):
"""
Extract images for given video filename and montage it into one, big
picture, similar to output from Windows Media Player thing, but without
captions and time (who need it anyway?).
Returns: image filename or None
NOTE: You should remove returned file manually, or move it in some
other place, otherwise it stays in filesystem.
"""
if not ('length' in self.tags and 'width' in self.tags):
# no length or width
return None
if not (self.tags['length'] > 0 and self.tags['width'] > 0):
# zero length or wight
return None
# Calculate number of pictures. Base is equivalent 72 pictures for
# 1:30:00 movie length
scale = int(10 * math.log(self.tags['length'], math.e) - 11)
if scale < 1:
return None
no_pictures = self.tags['length'] / scale
if no_pictures > 8:
no_pictures = (no_pictures / 8) * 8 # only multiple of 8, please.
else:
# for really short movies
no_pictures = 4
tempdir = mkdtemp()
file_desc, image_fn = mkstemp(suffix=".jpg")
os.close(file_desc)
self._make_captures(tempdir, no_pictures)
self._make_montage(tempdir, image_fn, no_pictures)
shutil.rmtree(tempdir)
return image_fn
def get_formatted_tags(self):
"""
Return formatted tags as a string
"""
out_tags = u''
if 'container' in self.tags:
out_tags += u"Container: %s\n" % self.tags['container']
if 'width' in self.tags and 'height' in self.tags:
out_tags += u"Resolution: %sx%s\n" % (self.tags['width'],
self.tags['height'])
if 'duration' in self.tags:
out_tags += u"Duration: %s\n" % self.tags['duration']
if 'video_codec' in self.tags:
out_tags += "Video codec: %s\n" % self.tags['video_codec']
if 'video_format' in self.tags:
out_tags += "Video format: %s\n" % self.tags['video_format']
if 'audio_codec' in self.tags:
out_tags += "Audio codec: %s\n" % self.tags['audio_codec']
if 'audio_format' in self.tags:
out_tags += "Audio format: %s\n" % self.tags['audio_format']
if 'audio_no_channels' in self.tags:
out_tags += "Audio channels: %s\n" % self.tags['audio_no_channels']
return out_tags
def _get_movie_info(self):
"""
Gather movie file information with midentify shell command.
Returns: dict of command output. Each dict element represents pairs:
variable=value, for example output from midentify will be:
ID_VIDEO_ID=0
ID_AUDIO_ID=1
....
ID_AUDIO_CODEC=mp3
ID_EXIT=EOF
so method returns dict:
{'ID_VIDEO_ID': '0',
'ID_AUDIO_ID': 1,
....
'ID_AUDIO_CODEC': 'mp3',
'ID_EXIT': 'EOF'}
"""
output = os.popen('midentify "%s"' % self.filename).readlines()
return_dict = {}
for line in output:
line = line.strip()
key = line.split('=')
if len(key) > 1:
return_dict[key[0]] = line.replace("%s=" % key[0], "")
return return_dict
def _make_captures(self, directory, no_pictures):
"""
Make screens with mplayer into given directory
Arguments:
@directory - full output directory name
@no_pictures - number of pictures to take
"""
step = float(self.tags['length'] / (no_pictures + 1))
current_time = 0
for dummy in range(1, no_pictures + 1):
current_time += step
time = float_to_string(current_time)
cmd = "mplayer \"%s\" -ao null -brightness 0 -hue 0 " \
"-saturation 0 -contrast 0 -vf-clr -vo jpeg:outdir=\"%s\" -ss %s" \
" -frames 1 2>/dev/null"
os.popen(cmd % (self.filename, directory, time)).readlines()
try:
shutil.move(os.path.join(directory, "00000001.jpg"),
os.path.join(directory, "picture_%s.jpg" % time))
except IOError, (errno, strerror):
LOG.error('error capturing file from movie "%s" at position '
'%s. Errors: %s, %s', self.filename, time, errno,
strerror)
def _make_montage(self, directory, image_fn, no_pictures):
"""
Generate one big image from screnshots and optionally resize it. Uses
PIL package to create output image.
Arguments:
@directory - source directory containing images
@image_fn - destination final image
@no_pictures - number of pictures
timeit result:
python /usr/lib/python2.6/timeit.py -n 1 -r 1 'from \
pygtktalog.video import Video; v = Video("/home/gryf/t/a.avi"); \
v.capture()'
1 loops, best of 1: 18.8 sec per loop
"""
row_length = 4
if no_pictures < 8:
row_length = 2
if not (self.tags['width'] * row_length) > self.out_width:
for i in [8, 6, 5]:
if (no_pictures % i) == 0 and \
(i * self.tags['width']) <= self.out_width:
row_length = i
break
coef = float(self.out_width - row_length - 1) / \
(self.tags['width'] * row_length)
if coef < 1:
dim = (int(self.tags['width'] * coef),
int(self.tags['height'] * coef))
else:
dim = int(self.tags['width']), int(self.tags['height'])
ifn_list = os.listdir(directory)
ifn_list.sort()
img_list = [Image.open(os.path.join(directory, fn)).resize(dim) \
for fn in ifn_list]
rows = no_pictures / row_length
cols = row_length
isize = (cols * dim[0] + cols + 1,
rows * dim[1] + rows + 1)
inew = Image.new('RGB', isize, (80, 80, 80))
for irow in range(no_pictures * row_length):
for icol in range(row_length):
left = 1 + icol * (dim[0] + 1)
right = left + dim[0]
upper = 1 + irow * (dim[1] + 1)
lower = upper + dim[1]
bbox = (left, upper, right, lower)
try:
img = img_list.pop(0)
except:
break
inew.paste(img, bbox)
inew.save(image_fn, 'JPEG')
def _return_lower(self, chain):
"""
Return lowercase version of provided string argument
Arguments:
@chain string to be lowered
Returns:
@string with lowered string
"""
return str(chain).lower()
def _get_start_pos(self, chain):
"""
Return integer for starting point of the movie
"""
try:
return int(chain.split(".")[0])
except:
return 0
def __str__(self):
str_out = ''
for key in self.tags:
str_out += "%20s: %s\n" % (key, self.tags[key])
return str_out

View File

View File

@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.4.5 on Sat Aug 29 15:13:44 2009 -->
<glade-interface>
<widget class="GtkWindow" id="top_details">
<child>
<widget class="GtkNotebook" id="notebook_details">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkHBox" id="fileinfo">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow4">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkTextView" id="description">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="editable">False</property>
<property name="wrap_mode">GTK_WRAP_WORD</property>
<property name="left_margin">2</property>
<property name="right_margin">2</property>
<property name="cursor_visible">False</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkViewport" id="thumb_box">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="resize_mode">GTK_RESIZE_QUEUE</property>
<child>
<widget class="GtkImage" id="thumb">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xpad">3</property>
<property name="ypad">3</property>
<property name="stock">gtk-missing-image</property>
<property name="icon_size">6</property>
</widget>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="nb_fileinfo">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">File info</property>
</widget>
<packing>
<property name="type">tab</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="img_container">
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkIconView" id="images">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="tooltip" translatable="yes">Double click to open image</property>
</widget>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Images</property>
</widget>
<packing>
<property name="type">tab</property>
<property name="position">1</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="exifinfo">
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkTreeView" id="exif_tree">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="rules_hint">True</property>
</widget>
</child>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">EXIF</property>
</widget>
<packing>
<property name="type">tab</property>
<property name="position">2</property>
<property name="tab_fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

View File

@@ -0,0 +1,76 @@
<?xml version="1.0"?>
<glade-interface>
<!-- interface-requires gtk+ 2.6 -->
<!-- interface-naming-policy toplevel-contextual -->
<widget class="GtkWindow" id="top_discs">
<child>
<widget class="GtkTreeView" id="discs">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">False</property>
<property name="rules_hint">True</property>
<signal name="button_press_event" handler="on_discs_button_press_event"/>
<signal name="cursor_changed" handler="on_discs_cursor_changed"/>
<signal name="row_activated" handler="on_discs_row_activated"/>
<signal name="key_release_event" handler="on_discs_key_release_event"/>
</widget>
</child>
</widget>
<widget class="GtkMenu" id="discs_popup">
<child>
<widget class="GtkMenuItem" id="expand_all">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Expand all nodes</property>
<property name="label" translatable="yes">_Expand all</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_expand_all_activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="collapse_all">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Collapse all nodes</property>
<property name="label" translatable="yes">_Collapse all</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_collapse_all_activate"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="update">
<property name="visible">True</property>
<property name="label" translatable="yes">_Update</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_update_activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="rename">
<property name="visible">True</property>
<property name="label" translatable="yes">_Rename</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_rename_activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="delete">
<property name="visible">True</property>
<property name="label" translatable="yes">_Delete</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_delete_activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="statistics">
<property name="visible">True</property>
<property name="label" translatable="yes">_Statistics</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_statistics_activate"/>
</widget>
</child>
</widget>
</glade-interface>

View File

@@ -0,0 +1,122 @@
<?xml version="1.0"?>
<glade-interface>
<!-- interface-requires gtk+ 2.6 -->
<!-- interface-naming-policy toplevel-contextual -->
<widget class="GtkWindow" id="top_files">
<child>
<widget class="GtkTreeView" id="files">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="rules_hint">True</property>
<signal name="button_press_event" handler="on_files_button_press_event"/>
<signal name="cursor_changed" handler="on_files_cursor_changed"/>
<signal name="row_activated" handler="on_files_row_activated"/>
<signal name="drag_data_get" handler="on_files_drag_data_get"/>
<signal name="key_release_event" handler="on_files_key_release_event"/>
</widget>
</child>
</widget>
<widget class="GtkMenu" id="files_popup">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkMenuItem" id="add_tag">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">_Add tag</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_add_tag1_activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="delete_tag">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Remo_ve tag</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_delete_tag_activate"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="add_thumb">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Add _Thumbnail</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_add_thumb1_activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="remove_thumb">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Re_move Thumbnail</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_remove_thumb1_activate"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator1">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="add_image">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="has_tooltip">True</property>
<property name="tooltip" translatable="yes">Add images to file. If file have no thumbnail,
thumbnail from first image will be generated.</property>
<property name="label" translatable="yes">Add _Images</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_add_image1_activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="remove_image">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Rem_ove All Images</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_remove_image1_activate"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator2">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="edit">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">_Edit</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_edit2_activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="delete">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">_Delete</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_delete3_activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="rename">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">_Rename</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_rename2_activate"/>
</widget>
</child>
</widget>
</glade-interface>

View File

@@ -0,0 +1,729 @@
<?xml version="1.0"?>
<glade-interface>
<!-- interface-requires gtk+ 2.16 -->
<!-- interface-naming-policy toplevel-contextual -->
<widget class="GtkWindow" id="main">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="title" translatable="yes">pyGTKtalog</property>
<signal name="destroy" handler="on_main_destroy_event"/>
<signal name="delete_event" handler="on_main_destroy_event"/>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="orientation">vertical</property>
<child>
<widget class="GtkMenuBar" id="mainMenubar">
<property name="visible">True</property>
<child>
<widget class="GtkMenuItem" id="file1">
<property name="visible">True</property>
<property name="label" translatable="yes">_File</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="file1_menu">
<child>
<widget class="GtkImageMenuItem" id="new1">
<property name="label">gtk-new</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_new_activate"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="open1">
<property name="label">gtk-open</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_open_activate"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="save1">
<property name="label">gtk-save</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_save_activate"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="save_as1">
<property name="label">gtk-save-as</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_save_as_activate"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator1">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="import">
<property name="visible">True</property>
<property name="label" translatable="yes">Import</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_import_activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="export">
<property name="visible">True</property>
<property name="label" translatable="yes">Export</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_export_activate"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator13">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="recent_files1">
<property name="visible">True</property>
<property name="label" translatable="yes">Recent files</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_recent_files1_activate"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separatorseparator">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="quit1">
<property name="label">gtk-quit</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_quit_activate"/>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="edit1">
<property name="visible">True</property>
<property name="label" translatable="yes">_Edit</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_edit1_activate"/>
<child>
<widget class="GtkMenu" id="edit1_menu">
<child>
<widget class="GtkImageMenuItem" id="delete1">
<property name="label">gtk-delete</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_delete1_activate"/>
<accelerator key="Delete" signal="activate"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator5">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="find1">
<property name="label">gtk-find</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_find_activate"/>
<accelerator key="f" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator2">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="properties1">
<property name="label">gtk-preferences</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_preferences_activate"/>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="catalog1">
<property name="visible">True</property>
<property name="label" translatable="yes">_Catalog</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="catalog1_menu">
<child>
<widget class="GtkMenuItem" id="add_cd">
<property name="visible">True</property>
<property name="label" translatable="yes">Add _CD/DVD</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_add_cd_activate"/>
<accelerator key="e" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="add_directory1">
<property name="visible">True</property>
<property name="label" translatable="yes">Add _Directory</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_add_directory_activate"/>
<accelerator key="d" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator3">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="del_all_images">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="tooltip" translatable="yes">Deletes all images from files in current colection</property>
<property name="label" translatable="yes">Delete all images</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_del_all_images_activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="del_all_thumb">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Delete all thumbnals</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_del_all_thumb_activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="save_all_img">
<property name="visible">True</property>
<property name="label" translatable="yes">Save all images...</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_save_all_img_activate"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator12">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="stat1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Catalog _statistics</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_stat1_activate"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator6">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="cancel1">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_cancel_clicked"/>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="view1">
<property name="visible">True</property>
<property name="label" translatable="yes">_View</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="view1_menu">
<child>
<widget class="GtkCheckMenuItem" id="toolbar1">
<property name="visible">True</property>
<property name="label" translatable="yes">Toolbar</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_toolbar1_activate"/>
</widget>
</child>
<child>
<widget class="GtkCheckMenuItem" id="status_bar1">
<property name="visible">True</property>
<property name="label" translatable="yes">Status bar</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_status_bar1_activate"/>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="help1">
<property name="visible">True</property>
<property name="label" translatable="yes">_Help</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="help1_menu">
<child>
<widget class="GtkImageMenuItem" id="about1">
<property name="label">gtk-about</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_about1_activate"/>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkToolbar" id="maintoolbar">
<property name="visible">True</property>
<property name="toolbar_style">both</property>
<child>
<widget class="GtkToolButton" id="tb_new">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Create new catalog</property>
<property name="stock_id">gtk-new</property>
<signal name="clicked" handler="on_new_activate"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="tb_open">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Open catalog file</property>
<property name="stock_id">gtk-open</property>
<signal name="clicked" handler="on_open_activate"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="tb_save">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Save catalog</property>
<property name="stock_id">gtk-save</property>
<signal name="clicked" handler="on_save_activate"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkToolItem" id="toolitem2">
<property name="visible">True</property>
<child>
<widget class="GtkVSeparator" id="vseparator1">
<property name="visible">True</property>
</widget>
</child>
</widget>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="tb_addcd">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Add CD/DVD to catalog</property>
<property name="label" translatable="yes">Add CD</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-cdrom</property>
<signal name="clicked" handler="on_add_cd_activate"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="tb_adddir">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Add Dir</property>
<property name="stock_id">gtk-directory</property>
<signal name="clicked" handler="on_add_directory_activate"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="tb_find">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Find file</property>
<property name="stock_id">gtk-find</property>
<signal name="clicked" handler="on_find_activate"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkToolItem" id="toolitem3">
<property name="visible">True</property>
<child>
<widget class="GtkVSeparator" id="vseparator2">
<property name="visible">True</property>
</widget>
</child>
</widget>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="cancel">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="label" translatable="yes">Cancel</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-cancel</property>
<signal name="clicked" handler="on_cancel_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="tb_quit">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Quit pyGTKtalog</property>
<property name="stock_id">gtk-quit</property>
<signal name="clicked" handler="on_quit_activate"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="tag_path_box">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">1</property>
<property name="spacing">2</property>
<child>
<widget class="GtkEntry" id="tag_path">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="editable">False</property>
<property name="shadow_type">etched-in</property>
<property name="caps_lock_warning">False</property>
<property name="secondary_icon_stock">gtk-clear</property>
<property name="secondary_icon_activatable">True</property>
<property name="secondary_icon_sensitive">True</property>
</widget>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="clear">
<property name="label">gtk-clear</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="on_clear_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkHPaned" id="hpaned1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkNotebook" id="nb_dirs">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow_discs">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<child>
<placeholder/>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Discs</property>
</widget>
<packing>
<property name="tab_fill">False</property>
<property name="type">tab</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow3">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Tags</property>
</widget>
<packing>
<property name="position">1</property>
<property name="tab_fill">False</property>
<property name="type">tab</property>
</packing>
</child>
</widget>
<packing>
<property name="resize">False</property>
<property name="shrink">True</property>
</packing>
</child>
<child>
<widget class="GtkVPaned" id="vpaned1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="orientation">vertical</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow_files">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<property name="shadow_type">in</property>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="resize">False</property>
<property name="shrink">True</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="resize">True</property>
<property name="shrink">False</property>
</packing>
</child>
</widget>
<packing>
<property name="position">3</property>
</packing>
</child>
<child>
<widget class="GtkHSeparator" id="hseparator1">
<property name="visible">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="padding">1</property>
<property name="position">4</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="statusprogress">
<property name="visible">True</property>
<child>
<widget class="GtkStatusbar" id="mainStatus">
<property name="visible">True</property>
<property name="has_resize_grip">False</property>
</widget>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkProgressBar" id="progressbar1">
<property name="visible">True</property>
<property name="pulse_step">0.10000000149</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">5</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class="GtkWindow" id="win_exifinfo">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkHBox" id="exif_hbox">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<placeholder/>
</child>
</widget>
</child>
</widget>
<widget class="GtkWindow" id="image_show">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="title" translatable="yes">pyGTKtalog - Image</property>
<property name="destroy_with_parent">True</property>
<child>
<widget class="GtkImage" id="img">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="stock">gtk-missing-image</property>
</widget>
</child>
</widget>
<widget class="GtkMenu" id="img_popup">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkMenuItem" id="img_add">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">_Add images</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_img_add_activate"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator9">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="img_delete">
<property name="visible">True</property>
<property name="label" translatable="yes">_Delete images</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_img_delete_activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="img_thumbset">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Set as _thumbnail</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_img_thumbset_activate"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator10">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="img_save">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">_Save images to...</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_img_save_activate"/>
</widget>
</child>
</widget>
<widget class="GtkMenu" id="th_popup">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkMenuItem" id="th_delete">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">_Remove Thumbnail</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_th_delete_activate"/>
</widget>
</child>
</widget>
<widget class="GtkMenu" id="tag_popup">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkMenuItem" id="delete_tag2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Delete tag</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_delete_tag2_activate"/>
</widget>
</child>
</widget>
</glade-interface>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<glade-interface>
<!-- interface-requires gtk+ 2.6 -->
<!-- interface-naming-policy toplevel-contextual -->
<widget class="GtkWindow" id="top_tags">
<child>
<widget class="GtkTextView" id="tag_cloud_textview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="wrap_mode">word</property>
<property name="cursor_visible">False</property>
<signal name="visibility_notify_event" handler="on_tag_cloud_textview_visibility_notify_event"/>
<signal name="drag_motion" handler="on_tag_cloud_textview_drag_motion"/>
<signal name="event_after" handler="on_tag_cloud_textview_event_after"/>
<signal name="drag_drop" handler="on_tag_cloud_textview_drag_drop"/>
<signal name="drag_leave" handler="on_tag_cloud_textview_drag_leave"/>
<signal name="drag_data_received" handler="on_tag_cloud_textview_drag_data_received"/>
</widget>
</child>
</widget>
</glade-interface>

View File

@@ -0,0 +1,210 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.4.5 on Fri Oct 23 18:28:53 2009 -->
<glade-interface>
<widget class="GtkWindow" id="window1">
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="orientation">GTK_ORIENTATION_VERTICAL</property>
<property name="orientation">GTK_ORIENTATION_VERTICAL</property>
<child>
<widget class="GtkMenuBar" id="menubar1">
<property name="visible">True</property>
<child>
<widget class="GtkMenuItem" id="menuitem1">
<property name="visible">True</property>
<property name="label" translatable="yes">_File</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="menu1">
<property name="visible">True</property>
<child>
<widget class="GtkImageMenuItem" id="imagemenuitem1">
<property name="visible">True</property>
<property name="label" translatable="yes">gtk-new</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="imagemenuitem2">
<property name="visible">True</property>
<property name="label" translatable="yes">gtk-open</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="imagemenuitem3">
<property name="visible">True</property>
<property name="label" translatable="yes">gtk-save</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="imagemenuitem4">
<property name="visible">True</property>
<property name="label" translatable="yes">gtk-save-as</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separatormenuitem1">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="imagemenuitem5">
<property name="visible">True</property>
<property name="label" translatable="yes">gtk-quit</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="menuitem2">
<property name="visible">True</property>
<property name="label" translatable="yes">_Edit</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="menu2">
<property name="visible">True</property>
<child>
<widget class="GtkImageMenuItem" id="imagemenuitem6">
<property name="visible">True</property>
<property name="label" translatable="yes">gtk-cut</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="imagemenuitem7">
<property name="visible">True</property>
<property name="label" translatable="yes">gtk-copy</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="imagemenuitem8">
<property name="visible">True</property>
<property name="label" translatable="yes">gtk-paste</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="imagemenuitem9">
<property name="visible">True</property>
<property name="label" translatable="yes">gtk-delete</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="menuitem3">
<property name="visible">True</property>
<property name="label" translatable="yes">_View</property>
<property name="use_underline">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="menuitem4">
<property name="visible">True</property>
<property name="label" translatable="yes">_Help</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="menu3">
<property name="visible">True</property>
<child>
<widget class="GtkImageMenuItem" id="imagemenuitem10">
<property name="visible">True</property>
<property name="label" translatable="yes">gtk-about</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<widget class="GtkHPaned" id="hpaned1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<widget class="GtkViewport" id="viewport1">
<property name="visible">True</property>
<property name="resize_mode">GTK_RESIZE_QUEUE</property>
<child>
<widget class="GtkTreeView" id="treeview1">
<property name="visible">True</property>
<property name="can_focus">True</property>
</widget>
</child>
</widget>
<packing>
<property name="resize">False</property>
<property name="shrink">True</property>
</packing>
</child>
<child>
<widget class="GtkTextView" id="textview1">
<property name="visible">True</property>
<property name="can_focus">True</property>
</widget>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
</packing>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox2">
<property name="visible">True</property>
<child>
<widget class="GtkStatusbar" id="statusbar1">
<property name="visible">True</property>
<property name="spacing">2</property>
<property name="has_resize_grip">False</property>
</widget>
</child>
<child>
<widget class="GtkProgressBar" id="progressbar1">
<property name="visible">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

189
pygtktalog/views/main.py Normal file
View File

@@ -0,0 +1,189 @@
"""
Project: pyGTKtalog
Description: View for main window
Type: core
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2009-05-02
"""
import os.path
from gtkmvc import View
def get_glade(glade_filename):
"""
Return full path to specified glade file
"""
return os.path.join(os.path.dirname(__file__), "glade", glade_filename)
class MainView(View):
"""
Create window from glade file. Note, that glade file is placed in view
module under glade subdirectory.
"""
glade = get_glade("main.glade")
top = "main"
def __init__(self, top="main"):
"""
Initialize view
"""
View.__init__(self)
self.app_sensitive = None
self['tag_path_box'].hide()
self.discs = DiscsView()
#self['scrolledwindow_discs'].add_with_viewport(\
# self.discs.get_top_widget())
self['scrolledwindow_discs'].add(self.discs.get_top_widget())
self.files = FilesView()
self['scrolledwindow_files'].add_with_viewport(\
self.files.get_top_widget())
self.details = DetailsView()
self['vpaned1'].add2(self.details.get_top_widget())
def set_widgets_scan_sensitivity(self, sensitive=True):
"""
Activate/deactivate selected widgets while scanning is active
"""
pass
def set_widgets_app_sensitivity(self, sensitive=True):
"""
Enable/disable widgets for empty application. Usefull for first run
of an application (without any db filename as an argument).
"""
if self.app_sensitive is sensitive:
return
for widget in ['scrolledwindow_discs', 'scrolledwindow_files',
'tb_save', 'tb_addcd', 'tb_adddir', 'tb_find',
'edit1', 'catalog1', 'save1', 'save_as1', 'import',
'export']:
self[widget].set_sensitive(sensitive)
# widgets from subclasses
self.details['notebook_details'].set_sensitive(sensitive)
class DiscsView(View):
"""
Separate Discs TreeView subview.
"""
glade = get_glade("discs.glade")
top = 'discs'
def __init__(self):
"""
Initialize view
"""
View.__init__(self)
self.menu = DiscsPopupView()
class DiscsPopupView(View):
"""
Separate Discs PopUp subview.
"""
glade = get_glade("discs.glade")
top = 'discs_popup'
def __init__(self):
"""
Initialize view
"""
View.__init__(self)
def set_update_sensitivity(self, state):
"""
Set sensitivity for 'update' popup menu item
Arguments:
@state - Bool, if True update menu item will be sensitive,
otherwise not
"""
self['update'].set_sensitive(state)
def set_menu_items_sensitivity(self, state):
"""
Set sensitivity for couple of popup menu items, which should be
disabled if user right-clicks on no item in treeview.
Arguments:
@state - Bool, if True update menu item will be sensitive,
otherwise not
"""
for item in ['update', 'rename', 'delete', 'statistics']:
self[item].set_sensitive(state)
class FilesView(View):
"""
Separate subview of Files TreeView as a table.
"""
glade = get_glade("files.glade")
top = 'files'
def __init__(self):
"""
Initialize view
"""
View.__init__(self)
self.menu = FilesPopupView()
class FilesPopupView(View):
"""
Separate Files PopUp subview.
"""
glade = get_glade("files.glade")
top = 'files_popup'
def __init__(self):
"""
Initialize view
"""
View.__init__(self)
def set_menu_items_sensitivity(self, state):
"""
Set sensitivity for couple of popup menu items, which should be
disabled if user right-clicks on no item in treeview.
Arguments:
@state - Bool, if True update menu item will be sensitive,
otherwise not
"""
for item in ["add_tag", "delete_tag", "add_thumb", "remove_thumb",
"add_image", "remove_image", "edit", "delete", "rename"]:
self[item].set_sensitive(state)
class TagcloudView(View):
"""
Textview subview with clickable tags.
"""
glade = get_glade("tagcloud.glade")
top = 'tag_cloud_textview'
def __init__(self):
"""
Initialize view
"""
View.__init__(self)
class DetailsView(View):
"""
Notebook subview containing tabs with details and possibly Exif, images
assocated with object and alternatively thumbnail.
"""
glade = get_glade("details.glade")
top = 'notebook_details'
def __init__(self):
"""
Initialize view
"""
View.__init__(self)

View File

@@ -0,0 +1,36 @@
"""
Project: pyGTKtalog
Description: Menu for the main window
Type: interface
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2010-03-14 21:31:57
"""
import gtk
from gtkmvc import View
class MainMenu(View):
def __init__(self):
View.__init__(self)
self['mainMenu'] = gtk.MenuBar()
self['file_menu'] = gtk.MenuItem(_("_File"))
accel_group = gtk.AccelGroup()
menu_items = (("/_File", None, None, 0, "<Branch>"),
("/File/_New", "<control>N", None, 0, None),
("/File/_Open", "<control>O", None, 0, None),
("/File/_Save", "<control>S", None, 0, None),
("/File/Save _As", None, None, 0, None),
("/File/sep1", None, None, 0, "<Separator>"),
("/File/Quit", "<control>Q", gtk.main_quit, 0, None),
("/_Options", None, None, 0, "<Branch>"),
("/Options/Test", None, None, 0, None),
("/_Help", None, None, 0, "<LastBranch>"),
("/_Help/About", None, None, 0, None),)
item_factory = gtk.ItemFactory(gtk.MenuBar, "<main>", accel_group)
item_factory.create_items(menu_items)

View File

@@ -0,0 +1,18 @@
"""
Project: pyGTKtalog
Description: Toolbar for the main window
Type: interface
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2010-04-20 18:47:49
"""
import gtk
from gtkmvc import View
class ToolBar(View):
def __init__(self):
View.__init__(self)
self['maintoolbar'] = gtk.Toolbar()

View File

@@ -0,0 +1,803 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--*- mode: xml -*-->
<glade-interface>
<widget class="GtkDialog" id="config">
<property name="width_request">550</property>
<property name="height_request">400</property>
<property name="title" translatable="yes">Preferences - pyGTKtalog</property>
<property name="modal">True</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<child>
<widget class="GtkHPaned" id="hpaned1">
<property name="width_request">168</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="position">140</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkTreeView" id="category_tree">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">False</property>
<property name="rules_hint">True</property>
<signal name="cursor_changed" handler="on_category_tree_cursor_changed"/>
</widget>
</child>
</widget>
<packing>
<property name="resize">False</property>
<property name="shrink">True</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<child>
<widget class="GtkLabel" id="desc">
<property name="visible">True</property>
<property name="xpad">3</property>
<property name="ypad">3</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<child>
<widget class="GtkViewport" id="pref_group">
<property name="visible">True</property>
<child>
<widget class="GtkVBox" id="main_group_holder">
<property name="visible">True</property>
<child>
<widget class="GtkVBox" id="disk_group">
<property name="border_width">1</property>
<child>
<widget class="GtkFrame" id="frame2">
<property name="visible">True</property>
<property name="border_width">5</property>
<property name="label_xalign">0</property>
<child>
<widget class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="has_focus">True</property>
<property name="border_width">5</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="border_width">5</property>
<property name="n_rows">2</property>
<property name="n_columns">3</property>
<property name="column_spacing">3</property>
<property name="row_spacing">3</property>
<child>
<widget class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Mount point:</property>
<property name="mnemonic_widget">mnt_entry</property>
</widget>
<packing>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="mnt_entry">
<property name="width_request">100</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_mnt">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Browse...</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_button_mnt_clicked"/>
<signal name="activate" handler="on_button_mnt_activate"/>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="ejt_entry">
<property name="width_request">100</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_ejt">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Browse...</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_button_ejt_clicked"/>
<signal name="activate" handler="on_button_ejt_activate"/>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Eject program:</property>
<property name="mnemonic_widget">ejt_entry</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;CD/DVD drive options&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkVBox" id="general_group">
<property name="border_width">1</property>
<child>
<widget class="GtkFrame" id="frame3">
<property name="visible">True</property>
<property name="border_width">5</property>
<property name="label_xalign">0</property>
<child>
<widget class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="has_focus">True</property>
<property name="border_width">5</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkVBox" id="vbox4">
<property name="visible">True</property>
<child>
<widget class="GtkCheckButton" id="ch_win">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Save main window size</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="ch_pan">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Save paned window sizes</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="ch_eject">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Eject CD/DVD after scan</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="ch_compress">
<property name="can_focus">True</property>
<property name="label" translatable="yes">Compress collection</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="ch_imageviewer">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Use external image viewer</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_ch_imageviewer_toggled"/>
</widget>
<packing>
<property name="position">4</property>
</packing>
</child>
<child>
<widget class="GtkTable" id="table4">
<property name="visible">True</property>
<property name="border_width">5</property>
<property name="n_rows">1</property>
<property name="n_columns">3</property>
<property name="column_spacing">3</property>
<property name="row_spacing">3</property>
<child>
<widget class="GtkLabel" id="label_imv">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Image viewer:</property>
<property name="mnemonic_widget">mnt_entry</property>
</widget>
<packing>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="entry_imv">
<property name="width_request">100</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_imv">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Browse...</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_button_imv_clicked"/>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
</widget>
<packing>
<property name="position">5</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;General options&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
</child>
<child>
<widget class="GtkFrame" id="frame5">
<property name="visible">True</property>
<property name="border_width">5</property>
<property name="label_xalign">0</property>
<child>
<widget class="GtkAlignment" id="alignment5">
<property name="visible">True</property>
<property name="has_focus">True</property>
<property name="border_width">5</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkVBox" id="vbox7">
<property name="visible">True</property>
<child>
<widget class="GtkCheckButton" id="ch_xls">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Export to XLS</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Misc&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame6">
<property name="visible">True</property>
<property name="border_width">5</property>
<property name="label_xalign">0</property>
<child>
<widget class="GtkAlignment" id="alignment6">
<property name="visible">True</property>
<property name="has_focus">True</property>
<property name="border_width">5</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkVBox" id="vbox8">
<property name="visible">True</property>
<child>
<widget class="GtkCheckButton" id="ch_quit">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Confirm quit if there are unsaved data</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="ch_warnnew">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Confirm "new" if there are unsaved data</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="ch_wrnmount">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Warn about mount/umount errors</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="ch_wrndel">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Warn on delete</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label10">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Confirmations&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="scan_group">
<property name="border_width">1</property>
<child>
<widget class="GtkFrame" id="frame4">
<property name="visible">True</property>
<property name="border_width">5</property>
<property name="label_xalign">0</property>
<child>
<widget class="GtkAlignment" id="alignment4">
<property name="visible">True</property>
<property name="has_focus">True</property>
<property name="border_width">5</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkVBox" id="vbox6">
<property name="visible">True</property>
<child>
<widget class="GtkCheckButton" id="ch_thumb">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Create thumbnails for images</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="ch_exif">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Scan EXIF data</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="ch_gthumb">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Include gThumb image description</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkCheckButton" id="ch_retrive">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Retrive extra information</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_ch_retrive_toggled"/>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="ft_group">
<property name="border_width">1</property>
<child>
<widget class="GtkFrame" id="frame7">
<property name="visible">True</property>
<property name="border_width">5</property>
<property name="label_xalign">0</property>
<child>
<widget class="GtkAlignment" id="alignment7">
<property name="visible">True</property>
<property name="has_focus">True</property>
<property name="border_width">5</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkVBox" id="ext_ed">
<property name="visible">True</property>
<property name="border_width">5</property>
<child>
<widget class="GtkTable" id="table3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="row_spacing">3</property>
<child>
<widget class="GtkEntry" id="ext_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Extension:</property>
<property name="justify">GTK_JUSTIFY_RIGHT</property>
<property name="mnemonic_widget">ext_entry</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Command:</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="com_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">3</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="ext_add">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Add/Change</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_ext_add_clicked"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="ext_del">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Delete</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_ext_del_clicked"/>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow3">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkTreeView" id="extension_tree">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="rules_hint">True</property>
<signal name="cursor_changed" handler="on_extension_tree_cursor_changed"/>
</widget>
</child>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Files extensions&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="position">3</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
</packing>
</child>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="cancelbutton1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="response_id">-6</property>
<signal name="clicked" handler="on_cancelbutton_clicked"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="okbutton1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="label">gtk-save</property>
<property name="use_stock">True</property>
<property name="response_id">-5</property>
<signal name="clicked" handler="on_okbutton_clicked"/>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

View File

@@ -0,0 +1,838 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--*- mode: xml -*-->
<glade-interface>
<widget class="GtkDialog" id="inputDialog">
<property name="visible">True</property>
<property name="title" translatable="yes">Disk label - pyGTKtalog</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<child>
<widget class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="xpad">3</property>
<property name="label" translatable="yes">Disk label</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="volname">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="activates_default">True</property>
<signal name="activate" handler="on_volname_activate"/>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="cancelbutton1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="response_id">-6</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="okbutton1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="response_id">-5</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class="GtkDialog" id="addDirDialog">
<property name="visible">True</property>
<property name="title" translatable="yes">dialog1</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox2">
<property name="visible">True</property>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="border_width">3</property>
<child>
<widget class="GtkFrame" id="frame2">
<property name="visible">True</property>
<property name="border_width">3</property>
<property name="label_xalign">0</property>
<child>
<widget class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="border_width">3</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">3</property>
<property name="column_spacing">3</property>
<property name="row_spacing">3</property>
<child>
<placeholder/>
</child>
<child>
<widget class="GtkButton" id="browse">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Browse...</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_browse_clicked"/>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Select directory:</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Disk Label:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="directory">
<property name="visible">True</property>
<property name="can_focus">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="dirvolname">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="text" translatable="yes">New</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Select directory and enter label&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area2">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="cancelbutton2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="response_id">-6</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="okbutton2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="response_id">-5</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class="GtkDialog" id="statDialog">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">pyGTKtalog - stats</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">2</property>
<child>
<widget class="GtkTable" id="table2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="n_rows">4</property>
<property name="n_columns">2</property>
<property name="column_spacing">2</property>
<child>
<widget class="GtkLabel" id="size_label">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Total size:</property>
<property name="justify">GTK_JUSTIFY_RIGHT</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="files_label">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Number of files:</property>
<property name="justify">GTK_JUSTIFY_RIGHT</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="dirs_label">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Number of directories:</property>
<property name="justify">GTK_JUSTIFY_RIGHT</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="discs_label">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Number of discs:</property>
<property name="justify">GTK_JUSTIFY_RIGHT</property>
</widget>
<packing>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="size_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="editable">False</property>
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="files_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="editable">False</property>
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="dirs_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="editable">False</property>
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="discs_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="editable">False</property>
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="button1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">gtk-close</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
</widget>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class="GtkDialog" id="renameDialog">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">pyGTKtalog - rename</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox4">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">2</property>
<child>
<widget class="GtkHBox" id="hbox3">
<property name="visible">True</property>
<child>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="xpad">3</property>
<property name="label" translatable="yes">Rename</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="name">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="activates_default">True</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area4">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="button2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="response_id">-6</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="button3">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">gtk-ok</property>
<property name="use_stock">True</property>
<property name="response_id">-5</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class="GtkDialog" id="file_editDialog">
<property name="width_request">500</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">5</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox5">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">2</property>
<child>
<widget class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label_xalign">0</property>
<child>
<widget class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="top_padding">3</property>
<property name="bottom_padding">3</property>
<property name="left_padding">12</property>
<property name="right_padding">3</property>
<child>
<widget class="GtkEntry" id="filename_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">&lt;b&gt;Filename&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label_xalign">0</property>
<child>
<widget class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="top_padding">3</property>
<property name="bottom_padding">3</property>
<property name="left_padding">12</property>
<property name="right_padding">3</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkTextView" id="description_text">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">&lt;b&gt;Description&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame4">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label_xalign">0</property>
<child>
<widget class="GtkAlignment" id="alignment4">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="top_padding">3</property>
<property name="bottom_padding">3</property>
<property name="left_padding">12</property>
<property name="right_padding">3</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkTextView" id="note_text">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">&lt;b&gt;Note&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area5">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="cancel">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="response_id">-6</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="ok">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">gtk-save</property>
<property name="use_stock">True</property>
<property name="response_id">-5</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class="GtkDialog" id="tagsDialog">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">5</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox6">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">2</property>
<child>
<widget class="GtkVBox" id="vbox3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Fill field below with comma separated keywords you will desired to tag selected files.</property>
<property name="wrap">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="padding">3</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="tag_entry1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_focus">True</property>
<property name="is_focus">True</property>
<property name="can_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="activates_default">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area6">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="cancel4">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="response_id">-6</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="button5">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">gtk-ok</property>
<property name="use_stock">True</property>
<property name="response_id">-5</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class="GtkDialog" id="tagRemove">
<property name="width_request">600</property>
<property name="height_request">400</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">pyGTKtalog - remove tags</property>
<property name="modal">True</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox7">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">2</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow3">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkTreeView" id="treeview1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="headers_clickable">True</property>
<property name="rules_hint">True</property>
</widget>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area7">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="cancel5">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="response_id">-6</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="ok2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">gtk-remove</property>
<property name="use_stock">True</property>
<property name="response_id">-5</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

View File

@@ -0,0 +1,276 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.4.0 on Tue May 13 10:23:51 2008 -->
<glade-interface>
<widget class="GtkWindow" id="search_window">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">3</property>
<signal name="delete_event" handler="on_search_window_delete_event"/>
<child>
<widget class="GtkVBox" id="vbox3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkHBox" id="hbox3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">3</property>
<child>
<widget class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Search for:</property>
</widget>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<widget class="GtkComboBoxEntry" id="comboboxentry">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child internal-child="entry">
<widget class="GtkEntry" id="search_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<signal name="activate" handler="on_search_activate"/>
</widget>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkButton" id="search_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">gtk-find</property>
<property name="use_stock">True</property>
<property name="response_id">1</property>
<signal name="clicked" handler="on_search_activate"/>
</widget>
<packing>
<property name="expand">False</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label_xalign">0</property>
<child>
<widget class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="top_padding">3</property>
<property name="bottom_padding">3</property>
<property name="left_padding">12</property>
<property name="right_padding">3</property>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow3">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkTreeView" id="result">
<property name="width_request">600</property>
<property name="height_request">300</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="headers_clickable">True</property>
<property name="rules_hint">True</property>
<signal name="row_activated" handler="on_result_row_activated"/>
<signal name="button_release_event" handler="on_result_button_release_event"/>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkStatusbar" id="statusbar">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">2</property>
<property name="has_resize_grip">False</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">&lt;b&gt;Search results&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">3</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="close">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">gtk-close</property>
<property name="use_stock">True</property>
<property name="response_id">-6</property>
<signal name="clicked" handler="on_close_clicked"/>
</widget>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class="GtkMenu" id="files_popup">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkMenuItem" id="add_tag">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">_Add tag</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_add_tag_activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="delete_tag">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Remo_ve tag</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_delete_tag_activate"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator16">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="add_thumb">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Add _Thumbnail</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_add_thumb_activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="remove_thumb">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Re_move Thumbnail</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_remove_thumb_activate"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator17">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="add_image">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="tooltip" translatable="yes">Add images to file. If file have no thumbnail,
thumbnail from first image will be generated.</property>
<property name="label" translatable="yes">Add _Images</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_add_image_activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="remove_image">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Rem_ove All Images</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_remove_image_activate"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator18">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="edit">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">_Edit</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_edit_activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="delete">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">_Delete</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_delete_activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="rename">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">_Rename</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_rename_activate"/>
</widget>
</child>
</widget>
</glade-interface>

25
src/__init__.py Normal file
View File

@@ -0,0 +1,25 @@
# This Python file uses the following encoding: utf-8
#
# Author: Roman 'gryf' Dobosz gryf@elysium.pl
#
# Copyright (C) 2007 by Roman 'gryf' Dobosz
#
# This file is part of pyGTKtalog.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# -------------------------------------------------------------------------

25
src/ctrls/__init__.py Normal file
View File

@@ -0,0 +1,25 @@
# This Python file uses the following encoding: utf-8
#
# Author: Roman 'gryf' Dobosz gryf@elysium.pl
#
# Copyright (C) 2007 by Roman 'gryf' Dobosz
#
# This file is part of pyGTKtalog.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# -------------------------------------------------------------------------

282
src/ctrls/c_config.py Normal file
View File

@@ -0,0 +1,282 @@
# This Python file uses the following encoding: utf-8
#
# Author: Roman 'gryf' Dobosz gryf@elysium.pl
#
# Copyright (C) 2007 by Roman 'gryf' Dobosz
#
# This file is part of pyGTKtalog.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# -------------------------------------------------------------------------
from gtkmvc import Controller
import views.v_dialogs as Dialogs
import gtk
class ConfigController(Controller):
category_dict = {
'Disk options':'disk_group',
'General':'general_group',
'Scan options':'scan_group',
'Files extensions':'ft_group',
}
category_order = ['General', 'Disk options', 'Scan options',
'Files extensions',]
def __init__(self, model):
Controller.__init__(self, model)
return
def register_view(self, view):
Controller.register_view(self, view)
# get data from Config object and put it into view
self.view['mnt_entry'].set_text(self.model.confd['cd'])
self.view['ejt_entry'].set_text(self.model.confd['ejectapp'])
self.view['ch_win'].set_active(self.model.confd['savewin'])
self.view['ch_pan'].set_active(self.model.confd['savepan'])
self.view['ch_eject'].set_active(self.model.confd['eject'])
self.view['ch_xls'].set_active(self.model.confd['exportxls'])
self.view['ch_quit'].set_active(self.model.confd['confirmquit'])
self.view['ch_wrnmount'].set_active(self.model.confd['mntwarn'])
self.view['ch_wrndel'].set_active(self.model.confd['delwarn'])
self.view['ch_warnnew'].set_active(self.model.confd['confirmabandon'])
self.view['ch_thumb'].set_active(self.model.confd['thumbs'])
self.view['ch_exif'].set_active(self.model.confd['exif'])
self.view['ch_gthumb'].set_active(self.model.confd['gthumb'])
self.view['ch_compress'].set_active(self.model.confd['compress'])
self.view['ch_retrive'].set_active(self.model.confd['retrive'])
self.view['ch_imageviewer'].set_active(self.model.confd['imgview'])
self.view['entry_imv'].set_text(self.model.confd['imgprog'])
self.__toggle_scan_group()
# initialize tree view
self.__setup_category_tree()
# initialize models for files extensions
vi = self.view['extension_tree']
vi.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
#self.view['extension_tree'].set_model(self.model.ext_tree)
self.__setup_extension_tree()
self.view['config'].show()
return
#################
# connect signals
def on_extension_tree_cursor_changed(self, tree):
model = tree.get_model()
selected = model.get_value(model.get_iter(tree.get_cursor()[0]), 0)
ext = self.model.confd['extensions']
self.view['ext_entry'].set_text(selected)
self.view['com_entry'].set_text(ext[selected])
def on_category_tree_cursor_changed(self, tree):
"""change view to selected row corresponding to group of properties"""
model = tree.get_model()
selected = model.get_value(model.get_iter(tree.get_cursor()[0]), 0)
iterator = tree.get_model().get_iter_first();
while iterator != None:
if model.get_value(iterator, 0) == selected:
self.view[self.category_dict[model.get_value(iterator,
0)]].show()
self.view['desc'].set_markup("<b>%s</b>" % selected)
else:
self.view[self.category_dict[model.get_value(iterator,
0)]].hide()
iterator = tree.get_model().iter_next(iterator);
return
def on_cancelbutton_clicked(self, button):
self.view['config'].destroy()
return
def on_okbutton_clicked(self, button):
# get data from view and put it into Config object
self.model.confd['cd'] = self.view['mnt_entry'].get_text()
self.model.confd['ejectapp'] = self.view['ejt_entry'].get_text()
self.model.confd['savewin'] = self.view['ch_win'].get_active()
self.model.confd['savepan'] = self.view['ch_pan'].get_active()
self.model.confd['eject'] = self.view['ch_eject'].get_active()
self.model.confd['exportxls'] = self.view['ch_xls'].get_active()
self.model.confd['confirmquit'] = self.view['ch_quit'].get_active()
self.model.confd['mntwarn'] = self.view['ch_wrnmount'].get_active()
self.model.confd['delwarn'] = self.view['ch_wrndel'].get_active()
v = self.view['ch_warnnew']
self.model.confd['confirmabandon'] = v.get_active()
self.model.confd['thumbs'] = self.view['ch_thumb'].get_active()
self.model.confd['exif'] = self.view['ch_exif'].get_active()
self.model.confd['gthumb'] = self.view['ch_gthumb'].get_active()
self.model.confd['compress'] = self.view['ch_compress'].get_active()
self.model.confd['retrive'] = self.view['ch_retrive'].get_active()
self.model.confd['imgview'] = self.view['ch_imageviewer'].get_active()
self.model.confd['imgprog'] = self.view['entry_imv'].get_text()
self.model.save()
self.view['config'].destroy()
def on_button_ejt_clicked(self, button):
fn = self.__show_filechooser("Choose eject program")
self.view['ejt_entryentry_imv'].set_text(fn)
def on_button_mnt_clicked(self, button):
fn = self.__show_filechooser("Choose mount point")
self.view['mnt_entry'].set_text(fn)
def on_ch_retrive_toggled(self, widget):
self.__toggle_scan_group()
def on_ch_imageviewer_toggled(self, checkbox):
state = self.view['ch_imageviewer'].get_active()
for i in ['label_imv', 'entry_imv', 'button_imv']:
self.view[i].set_sensitive(state)
def on_button_imv_clicked(self, widget):
fn = self.__show_filechooser("Choose image viewer")
self.view['entry_imv'].set_text(fn)
def on_ext_add_clicked(self, widget):
ext = self.view['ext_entry'].get_text().lower()
com = self.view['com_entry'].get_text()
if len(ext) == 0 and len(com) == 0:
Dialogs.Err("Config - pyGTKtalog", "Error",
"Extension and command required")
return
if len(com) == 0:
Dialogs.Err("Config - pyGTKtalog", "Error", "Command is empty")
return
if len(ext) == 0:
Dialogs.Err("Config - pyGTKtalog", "Error", "Extension is empty")
return
if ext in self.model.confd['extensions'].keys():
obj = Dialogs.Qst('Alter extension',
'Alter extension?',
'Extension "%s" will be altered.' % ext)
if not obj.run():
return
self.model.confd['extensions'][ext] = com
self.__setup_extension_tree()
return
def on_ext_del_clicked(self, widget):
v = self.view['extension_tree']
model, selection = v.get_selection().get_selected_rows()
if len(selection) == 0:
Dialogs.Err("Config - pyGTKtalog", "Error", "No item selected")
return
elif len(selection) == 1:
sufix = ''
else:
sufix = "s"
if self.model.confd['delwarn']:
obj = Dialogs.Qst('Delete extension%s' % sufix,
'Delete extension%s?' % sufix,
'Object%s will be permanently removed.' % sufix)
if not obj.run():
return
for i in selection:
m = self.model.confd['extensions']
m.pop(model.get_value(model.get_iter(i), 0))
self.__setup_extension_tree()
return
############################
# private controller methods
def __setup_extension_tree(self):
self.model.refresh_ext()
self.view['extension_tree'].set_model(self.model.ext_tree)
for i in self.view['extension_tree'].get_columns():
self.view['extension_tree'].remove_column(i)
cell = gtk.CellRendererText()
column = gtk.TreeViewColumn("Extension", cell, text=0)
column.set_resizable(True)
self.view['extension_tree'].append_column(column)
column = gtk.TreeViewColumn("Command", cell, text=1)
column.set_resizable(True)
self.view['extension_tree'].append_column(column)
def __toggle_scan_group(self):
for i in ('ch_thumb','ch_exif','ch_gthumb'):
self.view[i].set_sensitive(self.view['ch_retrive'].get_active())
return
def __setup_category_tree(self):
category_tree = self.view['category_tree']
category_tree.set_model(self.model.category_tree)
self.model.category_tree.clear()
for i in self.category_order:
myiter = self.model.category_tree.insert_before(None,None)
self.model.category_tree.set_value(myiter,0,i)
cell = gtk.CellRendererText()
column = gtk.TreeViewColumn("Name",cell,text=0)
column.set_resizable(True)
category_tree.append_column(column)
def __show_filechooser(self, title):
"""dialog for choose eject"""
fn = None
dialog = gtk.FileChooserDialog(
title=title,
action=gtk.FILE_CHOOSER_ACTION_OPEN,
buttons=(gtk.STOCK_CANCEL,
gtk.RESPONSE_CANCEL,
gtk.STOCK_OPEN,
gtk.RESPONSE_OK))
dialog.set_default_response(gtk.RESPONSE_OK)
response = dialog.run()
if response == gtk.RESPONSE_OK:
if __debug__:
print "c_config.py: __show_filechooser()",
print dialog.get_filename()
fn = dialog.get_filename()
dialog.destroy()
return fn
def __show_dirchooser(self):
"""dialog for point the mountpoint"""
dialog = gtk.FileChooserDialog(
title="Choose mount point",
action=gtk.FILE_CHOOSER_ACTION_OPEN,
buttons=(gtk.STOCK_CANCEL,
gtk.RESPONSE_CANCEL,
gtk.STOCK_OPEN,
gtk.RESPONSE_OK))
dialog.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
dialog.set_filename(self.view['mnt_entry'].get_text())
dialog.set_default_response(gtk.RESPONSE_OK)
response = dialog.run()
if response == gtk.RESPONSE_OK:
self.view['mnt_entry'].set_text(dialog.get_filename())
dialog.destroy()
pass # end of class

1696
src/ctrls/c_main.py Normal file

File diff suppressed because it is too large Load Diff

379
src/ctrls/c_search.py Normal file
View File

@@ -0,0 +1,379 @@
# This Python file uses the following encoding: utf-8
#
# Author: Roman 'gryf' Dobosz gryf@elysium.pl
#
# Copyright (C) 2007 by Roman 'gryf' Dobosz
#
# This file is part of pyGTKtalog.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# -------------------------------------------------------------------------
import gtk
from gtkmvc import Controller
import views.v_dialogs as Dialogs
class SearchController(Controller):
"""Controller for main application window"""
def __init__(self, model):
"""Initialize controller"""
Controller.__init__(self, model)
self.search_string = ""
return
def register_view(self, view):
Controller.register_view(self, view)
# Setup TreeView result widget, as columned list
v = self.view['result']
v.set_model(self.model.search_list)
v.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
c = gtk.TreeViewColumn('Disc', gtk.CellRendererText(), text=1)
c.set_sort_column_id(1)
c.set_resizable(True)
v.append_column(c)
c = gtk.TreeViewColumn('Filename')
cellpb = gtk.CellRendererPixbuf()
cell = gtk.CellRendererText()
c.pack_start(cellpb, False)
c.pack_start(cell, True)
c.set_attributes(cellpb, stock_id=7)
c.set_attributes(cell, text=2)
c.set_sort_column_id(2)
c.set_resizable(True)
v.append_column(c)
c = gtk.TreeViewColumn('Path', gtk.CellRendererText(), text=3)
c.set_sort_column_id(3)
c.set_resizable(True)
v.append_column(c)
c = gtk.TreeViewColumn('Size', gtk.CellRendererText(), text=4)
c.set_sort_column_id(4)
c.set_resizable(True)
v.append_column(c)
c = gtk.TreeViewColumn('Date', gtk.CellRendererText(), text=5)
c.set_sort_column_id(5)
c.set_resizable(True)
v.append_column(c)
v.set_search_column(2)
# combobox
self.view['comboboxentry'].set_model(self.model.search_history)
self.view['comboboxentry'].set_text_column(0)
# statusbar
self.context_id = self.view['statusbar'].get_context_id('search')
self.view['statusbar'].pop(self.context_id)
self.view['search_window'].show()
self.model.search_created = True;
return
#########################################################################
# Connect signals from GUI, like menu objects, toolbar buttons and so on.
def on_search_window_delete_event(self, window, event):
"""if window was closed, reset attributes"""
self.model.point = None
self.model.search_created = False;
return False
def on_close_clicked(self, button):
"""close search window"""
self.model.point = None
self.model.search_created = False;
self.view['search_window'].destroy()
def on_search_activate(self, entry):
"""find button or enter pressed on entry search. Do the search"""
search_txt = self.view['search_entry'].get_text()
self.search_string = search_txt
found = self.model.search(search_txt)
self.model.add_search_history(search_txt)
self.__set_status_bar(found)
def on_result_row_activated(self, treeview, path, treecolumn):
"""result treeview row activated, change models 'point' observable
variable to id of elected item. rest is all in main controler hands."""
model = treeview.get_model()
s_iter = model.get_iter(path)
self.model.point = model.get_value(s_iter, 0)
def on_result_button_release_event(self, tree, event):
if event.button == 3: # Right mouse button. Show context menu.
try:
selection = tree.get_selection()
model, list_of_paths = selection.get_selected_rows()
except TypeError:
list_of_paths = []
if len(list_of_paths) == 0:
# try to select item under cursor
try:
path, column, x, y = tree.get_path_at_pos(int(event.x),
int(event.y))
except TypeError:
# failed, do not show any popup and return
tree.get_selection().unselect_all()
return False
selection.select_path(path[0])
if len(list_of_paths) > 1:
self.view['add_image'].set_sensitive(False)
self.view['rename'].set_sensitive(False)
self.view['edit'].set_sensitive(False)
else:
self.view['add_image'].set_sensitive(True)
self.view['rename'].set_sensitive(True)
self.view['edit'].set_sensitive(True)
self.view['files_popup'].popup(None, None, None, 0, 0)
self.view['files_popup'].show_all()
return True
def on_add_tag_activate(self, menu_item):
"""Add tags to selected files"""
tags = Dialogs.TagsDialog().run()
if not tags:
return
ids = self.__get_tv_selection_ids(self.view['result'])
for item_id in ids:
self.model.add_tags(item_id, tags)
self.model.unsaved_project = True
return
def on_delete_tag_activate(self, menu_item):
ids = self.__get_tv_selection_ids(self.view['result'])
if not ids:
Dialogs.Inf("Remove tags", "No files selected",
"You have to select some files first.")
return
tags = self.model.get_tags_by_file_id(ids)
if tags:
d = Dialogs.TagsRemoveDialog(tags)
retcode, retval = d.run()
if retcode=="ok" and not retval:
Dialogs.Inf("Remove tags", "No tags selected",
"You have to select any tag to remove from files.")
return
elif retcode == "ok" and retval:
self.model.delete_tags(ids, retval)
found = self.model.search(self.search_string)
self.__set_status_bar(found)
def on_add_thumb_activate(self, menu_item):
image, only_thumbs = Dialogs.LoadImageFile().run()
if not image:
return
ids = self.__get_tv_selection_ids(self.view['result'])
for item_id in ids:
self.model.add_thumbnail(image, item_id)
self.model.unsaved_project = True
return
def on_remove_thumb_activate(self, menu_item):
if self.model.config.confd['delwarn']:
title = 'Delete thumbnails'
question = 'Delete thumbnails?'
description = "Thumbnails for selected items will be permanently"
description += " removed from catalog."
obj = Dialogs.Qst(title, question, description)
if not obj.run():
return
try:
ids = self.__get_tv_selection_ids(self.view['result'])
for item_id in ids:
self.model.del_thumbnail(item_id)
except:
if __debug__:
print "c_search.py: on_remove_thumb_activate(): error on",
print "getting selected items or removing thumbnails"
return
self.model.unsaved_project = True
return
def on_add_image_activate(self, menu_item):
dialog = Dialogs.LoadImageFile(True)
msg = "Don't copy images. Generate only thumbnails."
toggle = gtk.CheckButton(msg)
toggle.show()
dialog.dialog.set_extra_widget(toggle)
images, only_thumbs = dialog.run()
if not images:
return
for image in images:
try:
selection = self.view['result'].get_selection()
model, list_of_paths = selection.get_selected_rows()
fid = model.get_value(model.get_iter(list_of_paths[0]), 0)
except:
try:
path, column = self.view['result'].get_cursor()
model = self.view['result'].get_model()
fiter = model.get_iter(path)
fid = model.get_value(fiter, 0)
except:
return
self.model.add_image(image, fid, only_thumbs)
self.model.unsaved_project = True
return
def on_remove_image_activate(self, menu_item):
if self.model.config.confd['delwarn']:
title = 'Delete images'
question = 'Delete all images?'
description = 'All images for selected items will be permanently'
description += ' removed from catalog.'
obj = Dialogs.Qst(title, question, description)
if not obj.run():
return
try:
ids = self.__get_tv_selection_ids(self.view['result'])
for item_id in ids:
self.model.del_images(item_id)
except:
if __debug__:
print "c_search.py: on_remove_thumb_activate(): error on",
print "getting selected items or removing thumbnails"
return
self.model.unsaved_project = True
return
def on_edit_activate(self, menu_item):
try:
selection = self.view['result'].get_selection()
model, list_of_paths = selection.get_selected_rows()
fid = model.get_value(model.get_iter(list_of_paths[0]), 0)
except TypeError:
if __debug__:
print "c_main.py: on_edit2_activate(): 0",
print "zaznaczonych wierszy"
return
val = self.model.get_file_info(fid)
ret = Dialogs.EditDialog(val).run()
if ret:
self.model.rename(fid, ret['filename'])
self.model.update_desc_and_note(fid,
ret['description'], ret['note'])
self.model.unsaved_project = True
def on_delete_activate(self, menu_item):
dmodel = self.model.discs_tree
try:
selection = self.view['result'].get_selection()
model, list_of_paths = selection.get_selected_rows()
except TypeError:
return
if not list_of_paths:
Dialogs.Inf("Delete files", "No files selected",
"You have to select at least one file to delete.")
return
if self.model.config.confd['delwarn']:
description = "Selected files and directories will be "
description += "permanently\n removed from catalog."
obj = Dialogs.Qst("Delete files", "Delete files?", description)
if not obj.run():
return
def foreach_searchtree(zmodel, zpath, ziter, d):
if d[0] == zmodel.get_value(ziter, 0):
d[1].append(zpath)
return False
ids = []
for p in list_of_paths:
ids.append(model.get_value(model.get_iter(p), 0))
for fid in ids:
# delete from db
self.model.delete(fid)
self.model.unsaved_project = True
found = self.model.search(self.search_string)
self.__set_status_bar(found)
return
def on_rename_activate(self, menu_item):
try:
selection = self.view['result'].get_selection()
model, list_of_paths = selection.get_selected_rows()
fid = model.get_value(model.get_iter(list_of_paths[0]), 0)
except TypeError:
if __debug__:
print "c_main.py: on_edit2_activate(): 0",
print "zaznaczonych wierszy"
return
fid = model.get_value(model.get_iter(list_of_paths[0]), 0)
name = model.get_value(model.get_iter(list_of_paths[0]),2)
new_name = Dialogs.InputNewName(name).run()
if __debug__:
print "c_search.py: on_rename_activate(): label:", new_name
if new_name and new_name != name:
self.model.rename(fid, new_name)
self.model.unsaved_project = True
return
#####################
# observed properetis
#########################
# private class functions
def __set_status_bar(self, found):
"""sets number of founded items in statusbar"""
if found == 0:
msg = "No files found."
elif found == 1:
msg = "Found 1 file."
else:
msg = "Found %d files." % found
self.view['statusbar'].push(self.context_id, "%s" % msg)
def __get_tv_selection_ids(self, treeview):
"""get selection from treeview and return coresponding ids' from
connected model or None"""
ids = []
try:
selection = treeview.get_selection()
model, list_of_paths = selection.get_selected_rows()
for path in list_of_paths:
ids.append(model.get_value(model.get_iter(path), 0))
return ids
except:
# DEBUG: treeview have no selection or smth is broken
if __debug__:
print "c_search.py: __get_tv_selection_ids(): error on",
print "getting selected items"
return
return None
pass # end of class

49
src/gtkmvc/__init__.py Normal file
View File

@@ -0,0 +1,49 @@
# Author: Roberto Cavada <cavada@fbk.eu>
#
# Copyright (c) 2005 by Roberto Cavada
#
# pygtkmvc is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# pygtkmvc is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110, USA.
#
# For more information on pygtkmvc see <http://pygtkmvc.sourceforge.net>
# or email to the author Roberto Cavada <cavada@fbk.eu>.
# Please report bugs to <cavada@fbk.eu>.
__all__ = ["model", "view", "controller", "observable", "observer", "support"]
__version = (1,2,2)
from model import Model, TreeStoreModel, ListStoreModel, TextBufferModel
from model_mt import ModelMT
from controller import Controller
from view import View
from observer import Observer
import observable
import adapters
def get_version(): return __version
def require(ver):
if isinstance(ver, str): ver = ver.split(".")
ver = tuple(map(int, ver))
if get_version() < ver:
raise AssertionError("gtkmvc required version '%s', found '%s'"\
% (ver, get_version()))
pass
return

View File

@@ -0,0 +1,25 @@
# Author: Roberto Cavada <cavada@fbk.eu>
#
# Copyright (c) 2007 by Roberto Cavada
#
# pygtkmvc is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# pygtkmvc is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110, USA.
#
# For more information on pygtkmvc see <http://pygtkmvc.sourceforge.net>
# or email to the author Roberto Cavada <cavada@fbk.eu>.
# Please report bugs to <cavada@fbk.eu>.
from gtkmvc.adapters.basic import Adapter, UserClassAdapter, RoUserClassAdapter
from gtkmvc.adapters.containers import StaticContainerAdapter

View File

@@ -0,0 +1,428 @@
# Author: Roberto Cavada <cavada@fbk.eu>
#
# Copyright (c) 2007 by Roberto Cavada
#
# pygtkmvc is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# pygtkmvc is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110, USA.
#
# For more information on pygtkmvc see <http://pygtkmvc.sourceforge.net>
# or email to the author Roberto Cavada <cavada@fbk.eu>.
# Please report bugs to <cavada@fbk.eu>.
import types
import gtk
import time
from gtkmvc.adapters.default import *
from gtkmvc.observer import Observer
# ----------------------------------------------------------------------
class Adapter (Observer):
def __init__(self, model, prop_name,
prop_read=None, prop_write=None,
value_error=None):
"""
Creates a new adapter that handles setting of value of a
model single model property when a corresponding widgets set
is changed and viceversa when the property is also
observable.
This class handles only assignments to properties. For other
kinds of setting (e.g. user-defined classes used as
observable properties, containers, etc.) use other types of
Adapters derived from this class.
prop_name is the model's property name (as a string). It is
possible to use a dotted notation to identify a property
contained into a hierarchy of models. For example 'a.b.c'
identifies property 'c' into model 'b' inside model 'a',
where model 'a' is an attribute of given top level model.
Last name must be an observable or non-observable attribute,
and previous names (if specified) must all refer to
instances of class Model. First name from the left must be
the name of a model instance inside the given model.
prop_{write,read} are two optional functions that apply
custom modifications to the value of the property before
setting and reading it. Both take a value and must return a
transformed value whose type must be compatible with the
type of the property.
value_error can be a function (or a method) to be called
when a ValueError exception occurs while trying to set a
wrong value for the property inside the model. The function
will receive: the adapter, the property name and the value
coming from the widget that offended the model.
"""
# registration is delayed, as we need to create possible
# listener before:
Observer.__init__(self)
self._prop_name = prop_name
self._prop_read = prop_read
self._prop_write = prop_write
self._value_error = value_error
self._wid = None
self._wid_info = {}
# this flag is set when self is changing the property or the
# widget, in order to avoid infinite looping.
self._itsme = False
self._connect_model(model)
return
def connect_widget(self, wid,
getter=None, setter=None,
signal=None, arg=None, update=True):
"""
Called when the widget is instantiated, and the adapter is
ready to connect the widget and the property inside the
observed model. arg is the (optional) argument that will be
passed when connecting the signal.
getter and setter are the (optional) methods used
for reading and writing the widget's value. When not
specified, default getter and setter will be guessed by
looking at the widget type the adapter will be connected
with. Guessing is carried out by querying information
specified into module 'adapters.default'.
Finally, if update is false, the widget will not be updated
"""
if self._wid_info.has_key(wid):
raise ValueError("Widget " + str(wid) + " was already connected")
wid_type = None
if None in (getter, setter, signal):
w = search_adapter_info(wid)
if getter is None: getter = w[GETTER]
if setter is None:
setter = w[SETTER]
wid_type = w[WIDTYPE]
pass
if signal is None: signal = w[SIGNAL]
pass
# saves information about the widget
self._wid_info[wid] = (getter, setter, wid_type)
# connects the widget
if signal:
if arg: wid.connect(signal, self._on_wid_changed, arg)
else: wid.connect(signal, self._on_wid_changed)
pass
self._wid = wid
# updates the widget:
if update: self.update_widget()
return
def update_model(self):
"""Forces the property to be updated from the value hold by
the widget. This method should be called directly by the
user in very unusual conditions."""
self._write_property(self._read_widget())
return
def update_widget(self):
"""Forces the widget to be updated from the property
value. This method should be called directly by the user
when the property is not observable, or in very unusual
conditions."""
self._write_widget(self._read_property())
return
# ----------------------------------------------------------------------
# Private methods
# ----------------------------------------------------------------------
def _connect_model(self, model):
"""
Used internally to connect the property into the model, and
register self as a value observer for that property"""
parts = self._prop_name.split(".")
if len(parts) > 1:
# identifies the model
models = parts[:-1]
for name in models:
model = getattr(model, name)
if not isinstance(model, gtkmvc.Model):
raise TypeError("Attribute '" + name +
"' was expected to be a Model, but found: " +
str(model))
pass
prop = parts[-1]
else: prop = parts[0]
# prop is inside model?
if not hasattr(model, prop):
raise ValueError("Attribute '" + prop +
"' not found in model " + str(model))
# is it observable?
if model.has_property(prop):
# we need to create an observing method before registering
self._add_method(self._get_observer_src(prop))
pass
self._prop = getattr(model, prop)
self._prop_name = prop
# registration of model:
self.register_model(model)
return
def _get_observer_src(self, prop_name):
"""This is the code for an value change observer"""
return """def property_%s_value_change(self, model, old, new):
if self._itsme or old == new: return
self._on_prop_changed()""" % prop_name
def _add_method(self, src):
"""Private service to add a new method to the instance,
given method code"""
from gtkmvc.support.utils import get_function_from_source
import new
func = get_function_from_source(src)
meth = new.instancemethod(func, self, self.__class__)
setattr(self, func.__name__, meth)
return
def _get_property(self):
"""Private method that returns the value currently stored
into the property"""
return getattr(self.get_model(), self._prop_name)
#return self._prop # bug fix reported by A. Dentella
def _set_property(self, val):
"""Private method that sets the value currently of the property."""
return setattr(self.get_model(), self._prop_name, val)
def _read_property(self, *args):
"""Returns the (possibly transformed) value that is stored
into the property"""
if self._prop_read: return self._prop_read(self._get_property(*args))
return self._get_property(*args)
def _write_property(self, val, *args):
"""Sets the value of property. Given val is transformed
accodingly to prop_write function when specified at
construction-time. A try to cast the value to the property
type is given."""
# 'finally' would be better here, but not supported in 2.4 :(
try:
totype = type(self._get_property(*args))
val_prop = self._cast_value(val, totype)
if self._prop_write: val_prop = self._prop_write(val_prop)
self._itsme = True
self._set_property(val_prop, *args)
except ValueError:
self._itsme = False
if self._value_error: self._value_error(self, self._prop_name, val)
else: raise
pass
except: self._itsme = False; raise
self._itsme = False
return
def _read_widget(self):
"""Returns the value currently stored into the widget, after
transforming it accordingly to possibly specified function."""
getter = self._wid_info[self._wid][0]
return getter(self._wid)
def _write_widget(self, val):
"""Writes value into the widget. If specified, user setter
is invoked."""
self._itsme = True
try:
setter = self._wid_info[self._wid][1]
wtype = self._wid_info[self._wid][2]
if wtype is not None: setter(self._wid, self._cast_value(val, wtype))
else: setter(self._wid, val)
finally:
self._itsme = False
pass
return
def _cast_value(self, val, totype):
"""Casts given val to given totype. Raises TypeError if not able to cast."""
t = type(val)
if issubclass(t, totype): return val
if issubclass(totype, types.StringType): return str(val)
if issubclass(t, types.StringType):
if issubclass(totype, types.IntType):
if val: return int(float(val))
return 0
if issubclass(totype, types.FloatType):
if val: return float(val)
return 0.0
pass
raise TypeError("Not able to cast " + str(t) + " to " + str(totype))
# ----------------------------------------------------------------------
# Callbacks and observation
# ----------------------------------------------------------------------
def _on_wid_changed(self, wid):
"""Called when the widget is changed"""
if self._itsme: return
self.update_model()
return
def _on_prop_changed(self):
"""Called by the observation code, when the value in the
observed property is changed"""
if not self._itsme: self.update_widget()
return
pass # end of class Adapter
#----------------------------------------------------------------------
class UserClassAdapter (Adapter):
"""
This class handles the communication between a widget and a
class instance (possibly observable) that is a property inside
the model. The value to be shown is taken and stored by using a
getter and a setter. getter and setter can be: names of user
class methods, bound or unbound methods of the user class, or a
function that will receive the user class instance and possible
arguments whose number depends on whether it is a getter or a
setter."""
def __init__(self, model, prop_name,
getter, setter,
prop_read=None, prop_write=None,
value_error=None):
Adapter.__init__(self, model, prop_name,
prop_read, prop_write, value_error)
self._getter = self._resolve_to_func(getter)
self._setter = self._resolve_to_func(setter)
return
# ----------------------------------------------------------------------
# Private methods
# ----------------------------------------------------------------------
def _resolve_to_func(self, what):
"""This method resolves whatever is passed: a string, a
bound or unbound method, a function, to make it a
function. This makes internal handling of setter and getter
uniform and easier."""
if isinstance(what, types.StringType):
what = getattr(Adapter._get_property(self), what)
pass
# makes it an unbounded function if needed
if type(what) == types.MethodType: what = what.im_func
if not type(what) == types.FunctionType: raise TypeError("Expected a method name, a method or a function")
return what
def _get_observer_src(self, prop_name):
"""This is the code for a method after_change observer"""
return """def property_%s_after_change(self, model, \
instance, meth_name, res, args, kwargs):
if self._itsme: return
self._on_prop_changed(instance, meth_name, res, args, kwargs)""" % prop_name
def _on_prop_changed(self, instance, meth_name, res, args, kwargs):
"""Called by the observation code, when a modifying method
is called"""
Adapter._on_prop_changed(self)
return
def _get_property(self, *args):
"""Private method that returns the value currently stored
into the property"""
val = self._getter(Adapter._get_property(self), *args)
if self._prop_read: return self._prop_read(val, *args)
return val
def _set_property(self, val, *args):
"""Private method that sets the value currently of the property"""
if self._prop_write: val = self._prop_write(val)
return self._setter(Adapter._get_property(self), val, *args)
pass # end of class UserClassAdapter
# ----------------------------------------------------------------------
#----------------------------------------------------------------------
class RoUserClassAdapter (UserClassAdapter):
"""
This class is for Read-Only user classes. RO classes are those
whose setting methods do not change the instance, but return a
new instance that has been changed accordingly to the setters
semantics. An example is python datetime class, whose replace
method does not change the instance it is invoked on, but
returns a new datetime instance.
This class is likely to be used very rarely.
"""
def __init__(self, model, prop_name,
getter, setter,
prop_read=None, prop_write=None,
value_error=None):
UserClassAdapter.__init__(self, model, prop_name,
getter, setter,
prop_read, prop_write, value_error)
return
# ----------------------------------------------------------------------
# Private methods
# ----------------------------------------------------------------------
def _set_property(self, val, *args):
"""Private method that sets the value currently of the property"""
val = UserClassAdapter._set_property(self, val, *args)
if val: Adapter._set_property(self, val, *args)
return val
pass # end of class RoUserClassAdapter
# ----------------------------------------------------------------------

View File

@@ -0,0 +1,217 @@
# Author: Roberto Cavada <cavada@fbk.eu>
#
# Copyright (c) 2007 by Roberto Cavada
#
# pygtkmvc is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# pygtkmvc is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110, USA.
#
# For more information on pygtkmvc see <http://pygtkmvc.sourceforge.net>
# or email to the author Roberto Cavada <cavada@fbk.eu>.
# Please report bugs to <cavada@fbk.eu>.
import types
import gtk
from gtkmvc.adapters.basic import UserClassAdapter, Adapter
from gtkmvc.adapters.default import *
from gtkmvc.observer import Observer
from gtkmvc.support.wrappers import ObsMapWrapper
# ----------------------------------------------------------------------
class StaticContainerAdapter (UserClassAdapter):
"""
This class can be used to bound a set of widgets to a property
that is a container, like a tuple, a list or a map, or in
general a class that implements __getitem__ and __setitem__
methods.
From the other hand, the set of widgets can be a list provided
by the user, or a container widget like a Box, a notebook, etc.
Widgets will be linked by their position when the property is
list-like, or by their name when the property is map-like.
This class supports only properties that are static containers,
i.e. those containers that do not change their length
dynamically. If the container grows up in length, no change will
occur in the view-side.
"""
def __init__(self, model, prop_name,
prop_read=None, prop_write=None, value_error=None):
UserClassAdapter.__init__(self, model, prop_name,
lambda c,i: c.__getitem__(i),
lambda c,v,i: c.__setitem__(i,v),
prop_read, prop_write,
value_error)
prop = Adapter._get_property(self)
#prop = self._get_property() # bug fix reported by A. Dentella
if not (hasattr(prop, "__getitem__") and
hasattr(prop, "__setitem__")):
raise TypeError("Property " + self._prop_name +
" is not a valid container")
self._prop_is_map = isinstance(prop, types.DictType) or \
isinstance(prop, ObsMapWrapper)
# contained widgets
self._idx2wid = {}
self._wid2idx = {}
self._widgets = None
return
def connect_widget(self, wid, getters=None, setters=None,
signals=None, arg=None):
"""
Called when the widget is instantiated, and the adapter is
ready to connect the widgets inside it (if a container) or
each widget if wid is a list of widgets. getters and setters
can be None, a function or a list or a map of
functions. signals can be None, a signal name, or a list or
a map of signal names. When maps are used, keys can be
widgets or widget names. The length of the possible lists or
maps must be lesser or equal to the number of widgets that
will be connected.
"""
if isinstance(wid, gtk.Container): self._widgets = wid.get_children()
elif isinstance(wid, types.ListType) or isinstance(wid, types.TupleType): self._widgets = wid
else: raise TypeError("widget must be either a gtk.Container or a list or tuple")
# prepares the mappings:
for idx, w in enumerate(self._widgets):
if self._prop_is_map: idx=w.get_name()
self._idx2wid[idx] = w
self._wid2idx[w] = idx
pass
# prepares the lists for signals
getters = self.__handle_par("getters", getters)
setters = self.__handle_par("setters", setters)
signals = self.__handle_par("signals", signals)
for wi,ge,se,si in zip(self._widgets, getters, setters, signals):
if type(ge) == types.MethodType: ge = ge.im_func
if type(se) == types.MethodType: se = se.im_func
UserClassAdapter.connect_widget(self, wi, ge, se, si, arg, False)
pass
self.update_widget()
self._wid = wid
return
def update_model(self, idx=None):
"""Updates the value of property at given index. If idx is
None, all controlled indices will be updated. This method
should be called directly by the user in very unusual
conditions."""
if idx is None:
for w in self._widgets:
idx = self._get_idx_from_widget(w)
self._write_property(self._read_widget(idx), idx)
pass
pass
else: self._write_property(self._read_widget(idx), idx)
return
def update_widget(self, idx=None):
"""Forces the widget at given index to be updated from the
property value. If index is not given, all controlled
widgets will be updated. This method should be called
directly by the user when the property is not observable, or
in very unusual conditions."""
if idx is None:
for w in self._widgets:
idx = self._get_idx_from_widget(w)
self._write_widget(self._read_property(idx), idx)
pass
else: self._write_widget(self._read_property(idx), idx)
return
# ----------------------------------------------------------------------
# Private methods
# ----------------------------------------------------------------------
def _get_idx_from_widget(self, wid):
"""Given a widget, returns the corresponding index for the
model. Returned value can be either an integer or a string"""
return self._wid2idx[wid]
def _get_widget_from_idx(self, idx):
"""Given an index, returns the corresponding widget for the view.
Given index can be either an integer or a string"""
return self._idx2wid[idx]
def _read_widget(self, idx):
sav = self._wid
self._wid = self._get_widget_from_idx(idx)
val = UserClassAdapter._read_widget(self)
self._wid = sav
return val
def _write_widget(self, val, idx):
sav = self._wid
self._wid = self._get_widget_from_idx(idx)
UserClassAdapter._write_widget(self, val)
self._wid = sav
return
# This is a private service to factorize code of connect_widget
def __handle_par(self, name, par):
if par is None or type(par) in (types.FunctionType,
types.MethodType, types.StringType):
par = [par] * len(self._widgets)
pass
elif isinstance(par, types.DictType):
val = []
for w in self._widgets:
if par.has_key(w): val.append(par[w])
elif par.has_key(w.get_name()): val.append(par[w.get_name()])
else: val.append(None)
pass
par = val
pass
elif isinstance(par, types.ListType) or isinstance(par, types.TupleType):
par = list(par)
par.extend([None]*(len(self._widgets)-len(par)))
pass
else: raise TypeError("Parameter %s has an invalid type (should be None, a sequence or a string)" % name)
return par
# Callbacks:
def _on_wid_changed(self, wid):
"""Called when the widget is changed"""
if self._itsme: return
self.update_model(self._get_idx_from_widget(wid))
return
def _on_prop_changed(self, instance, meth_name, res, args, kwargs):
"""Called by the observation code, we are interested in
__setitem__"""
if not self._itsme and meth_name == "__setitem__": self.update_widget(args[0])
return
pass # end of class StaticContainerAdapter

View File

@@ -0,0 +1,55 @@
__all__ = ("search_adapter_info",
"SIGNAL", "GETTER", "SETTER", "WIDTYPE")
import types
import gtk
# ----------------------------------------------------------------------
# This list defines a default behavior for widgets.
# If no particular behaviour has been specified, adapters will
# use information contained into this list to create themself.
# This list is ordered: the earlier a widget occurs, the better it
# will be matched by the search function.
# ----------------------------------------------------------------------
__def_adapter = [ # class, default signal, getter, setter, value type
(gtk.Entry, "changed", gtk.Entry.get_text, gtk.Entry.set_text, types.StringType),
(gtk.Label, None, gtk.Label.get_text, gtk.Label.set_text, types.StringType),
(gtk.Arrow, None, lambda a: a.get_property("arrow-type"),
lambda a,v: a.set(v,a.get_property("shadow-type")), gtk.ArrowType),
(gtk.ToggleButton, "toggled", gtk.ToggleButton.get_active, gtk.ToggleButton.set_active, types.BooleanType),
(gtk.CheckMenuItem, "toggled", gtk.CheckMenuItem.get_active, gtk.CheckMenuItem.set_active, types.BooleanType),
(gtk.Expander, "activate", lambda w: not w.get_expanded(), gtk.Expander.set_expanded, types.BooleanType),
(gtk.ColorButton, "color-set", gtk.ColorButton.get_color, gtk.ColorButton.set_color, gtk.gdk.Color),
(gtk.ColorSelection, "color-changed", gtk.ColorSelection.get_current_color, gtk.ColorSelection.set_current_color, gtk.gdk.Color),
]
if gtk.pygtk_version >= (2,10,0):
# conditionally added support
__def_adapter.append(
(gtk.LinkButton, "clicked", gtk.LinkButton.get_uri, gtk.LinkButton.set_uri, types.StringType))
pass
# constants to access values:
SIGNAL =1
GETTER =2
SETTER =3
WIDTYPE =4
# ----------------------------------------------------------------------
# To optimize the search
__memoize__ = {}
def search_adapter_info(wid):
"""Given a widget returns the default tuple found in __def_adapter"""
t = type(wid)
if __memoize__.has_key(t): return __memoize__[t]
for w in __def_adapter:
if isinstance(wid, w[0]):
__memoize__[t] = w
return w
pass
raise TypeError("Adapter type " + str(t) + " not found among supported adapters")

218
src/gtkmvc/controller.py Normal file
View File

@@ -0,0 +1,218 @@
# Author: Roberto Cavada <cavada@fbk.eu>
#
# Copyright (c) 2005 by Roberto Cavada
#
# pygtkmvc is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# pygtkmvc is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110, USA.
#
# For more information on pygtkmvc see <http://pygtkmvc.sourceforge.net>
# or email to the author Roberto Cavada <cavada@fbk.eu>.
# Please report bugs to <cavada@fbk.eu>.
from gtkmvc.observer import Observer
import types
class Controller (Observer):
"""
We put all of our gtk signal handlers into a class. This lets
us bind all of them at once, because their names are in the
class dict. This class automatically register its instances as
observers into the corresponding model. Also, when a view is
created, the view calls method register_view, which can be
oveloaded in order to connect signals and perform other specific
operation. A controller possibly handles and contains also a set
of adapters that makes easier to connect widgets and observable
properties into the model.
parameter spurious controls the way spurious value change
notifications are handled. If True, assignments to observable
properties that do not actually change the value are
notified anyway."""
def __init__(self, model, spurious=False):
Observer.__init__(self, model, spurious)
self.view = None
self.__adapters = []
return
def register_view(self, view):
"""
This method is called by the framework when registering a
view. Derived classes can exploit this call to connect
signals manually, create and connect treeview, textview,
etc.
"""
assert(self.view is None)
self.view = view
self.register_adapters()
return
def register_adapters(self):
"""
This method is called by register_view during view
registration process, when it is time to possibly create all
adapters. model and view can safely be taken from self.model
and self.view. Derived classes can specilize this method. In
this implementation the method does nothing.
"""
assert(self.model is not None)
assert(self.view is not None)
return
def adapt(self, *args):
"""
Adapts a set of (observable) properties and a set of
widgets, by connecting them.
This method can be used to simplify the creation of one or
more adapters, by letting the framework do most of the work
needed to connect ('adapt') properties from one hand, and
widgets on the other.
This method is provided in three flavours:
1. An instance of an Adapter class can be created by the
caller and passed as a unique argument. The adapter must
be already fully configured.
2. The name of a model's property is passed as a unique
argument. A correponding widget name is searched and if
found, an adapter is created. Name matching is performed
by searching into view's widget names for words that end
with the given property name. Matching is case
insensitive and words can be separated by spaces,
underscore (_) and CapitalizedWords. For example property
'prop' will match widget 'cb_prop'. If no matches or
multiple matches are found, a ValueError will be raised.
The way names are matched can be customized by deriving
method match_prop_name.
3. Two strings can be passed, respectively containing the
name of an observable property in the model, and the name
of a widget in the view.
Flavour 1 allows for a full control, but flavour 2 and 3
make easier to create adpaters with basic (default)
behaviour.
This method can be called into the method register_adapters
which derived classes can specialise.
"""
# checks arguments
n = len(args)
if n not in (1,2): raise TypeError("adapt() takes 1 or 2 arguments (%d given)" % n)
if n == 1: #one argument
from gtkmvc.adapters.basic import Adapter
if isinstance(args[0], Adapter): adapters = (args[0],)
elif isinstance(args[0], types.StringType):
prop_name = args[0]
names = []
for k in self.view:
if self.__match_prop_name(prop_name, k): names.append(k)
pass
if len(names) != 1:
raise ValueError("%d widget candidates match property '%s': %s" % \
(len(names), prop_name, names))
wid_name = names[0]
adapters = self.__create_adapters__(prop_name, wid_name)
pass
else: raise TypeError("Argument of adapt() must be an Adapter or a string")
else: # two arguments
if not (isinstance(args[0], types.StringType) and
isinstance(args[1], types.StringType)):
raise TypeError("Arguments of adapt() must be two strings")
# retrieves both property and widget, and creates an adapter
prop_name, wid_name = args
adapters = self.__create_adapters__(prop_name, wid_name)
pass
for ad in adapters: self.__adapters.append(ad)
return
def __match_prop_name(self, prop_name, wid_name):
"""
Used internally when searching for a suitable widget. To customize
its behaviour, re-implement this method into derived classes
"""
return wid_name.lower().endswith(prop_name.lower())
def __create_adapters__(self, prop_name, wid_name):
"""
Private service that looks at property and widgets types,
and possibly creates one or more (best) fitting adapters
that are returned as a list.
"""
from gtkmvc.adapters.basic import Adapter, RoUserClassAdapter
from gtkmvc.adapters.containers import StaticContainerAdapter
import gtk
res = []
wid = self.view[wid_name]
if wid is None: raise ValueError("Widget '%s' not found" % wid_name)
# Decides the type of adapters to be created.
if isinstance(wid, gtk.Calendar):
# calendar creates three adapter for year, month and day
ad = RoUserClassAdapter(self.model, prop_name,
lambda d: d.year, lambda d,y: d.replace(year=y))
ad.connect_widget(wid, lambda c: c.get_date()[0],
lambda c,y: c.select_month(c.get_date()[1], y),
"day-selected")
res.append(ad) # year
ad = RoUserClassAdapter(self.model, prop_name,
lambda d: d.month, lambda d,m: d.replace(month=m))
ad.connect_widget(wid, lambda c: c.get_date()[1]+1,
lambda c,m: c.select_month(m-1, c.get_date()[0]),
"day-selected")
res.append(ad) # month
ad = RoUserClassAdapter(self.model, prop_name,
lambda d: d.day, lambda d,v: d.replace(day=v))
ad.connect_widget(wid, lambda c: c.get_date()[2],
lambda c,d: c.select_day(d),
"day-selected")
res.append(ad) # day
return res
try: # tries with StaticContainerAdapter
ad = StaticContainerAdapter(self.model, prop_name)
ad.connect_widget(wid)
res.append(ad)
except TypeError:
# falls back to a simple adapter
ad = Adapter(self.model, prop_name)
ad.connect_widget(wid)
res.append(ad)
pass
return res
pass # end of class Controller

336
src/gtkmvc/model.py Normal file
View File

@@ -0,0 +1,336 @@
# Author: Roberto Cavada <cavada@fbk.eu>
#
# Copyright (c) 2005 by Roberto Cavada
#
# pygtkmvc is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# pygtkmvc is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110, USA.
#
# For more information on pygtkmvc see <http://pygtkmvc.sourceforge.net>
# or email to the author Roberto Cavada <cavada@fbk.eu>.
# Please report bugs to <cavada@fbk.eu>.
import support.metaclasses
from support.wrappers import ObsWrapperBase
from observable import Signal
class Model (object):
"""
This class is the application model base class. It handles a set
of observable properties which you are interested in showing by
one ore more view - via one or more observers of course. The
mechanism is the following:
1. You are interested in showing a set of model property, that
you can declare in the __properties__ member map.
2. You define one or more observers that observe one or more
properties you registered. When someone changes a property
value the model notifies the changing to each observer.
The property-observer[s] association is given by the implicit
rule in observers method names: if you want the model notified
the changing event of the value of the property 'p' you have to
define the method called 'property_p_value_change' in each
listening observer class.
Notice that tipically 'controllers' implement the observer
pattern. The notification method gets the emitting model, the
old value for the property and the new one. Properties
functionalities are automatically provided by the
ObservablePropertyMeta meta-class."""
__metaclass__ = support.metaclasses.ObservablePropertyMeta
__properties__ = {} # override this
def __init__(self):
object.__init__(self)
self.__observers = []
# keys are properties names, values are methods inside the observer:
self.__value_notifications = {}
self.__instance_notif_before = {}
self.__instance_notif_after = {}
self.__signal_notif = {}
for key in (self.__properties__.keys() + self.__derived_properties__.keys()):
self.register_property(key)
pass
return
def register_property(self, name):
"""Registers an existing property to be monitored, and sets
up notifiers for notifications"""
if not self.__value_notifications.has_key(name):
self.__value_notifications[name] = []
pass
# registers observable wrappers
prop = getattr(self, "_prop_%s" % name)
if isinstance(prop, ObsWrapperBase):
prop.__set_model__(self, name)
if isinstance(prop, Signal):
if not self.__signal_notif.has_key(name):
self.__signal_notif[name] = []
pass
pass
else:
if not self.__instance_notif_before.has_key(name):
self.__instance_notif_before[name] = []
pass
if not self.__instance_notif_after.has_key(name):
self.__instance_notif_after[name] = []
pass
pass
pass
return
def has_property(self, name):
"""Returns true if given property name refers an observable
property inside self or inside derived classes"""
return self.__properties__.has_key(name) or \
self.__derived_properties__.has_key(name)
def register_observer(self, observer):
if observer in self.__observers: return # not already registered
self.__observers.append(observer)
for key in (self.__properties__.keys() + self.__derived_properties__.keys()):
self.__add_observer_notification(observer, key)
pass
return
def unregister_observer(self, observer):
if observer not in self.__observers: return
for key in (self.__properties__.keys() + self.__derived_properties__.keys()):
self.__remove_observer_notification(observer, key)
pass
self.__observers.remove(observer)
return
def _reset_property_notification(self, prop_name):
"""Called when it has be done an assignment that changes the
type of a property or the instance of the property has been
changed to a different instance. In this case it must be
unregistered and registered again"""
self.register_property(prop_name)
for observer in self.__observers:
self.__remove_observer_notification(observer, prop_name)
self.__add_observer_notification(observer, prop_name)
pass
return
def __add_observer_notification(self, observer, prop_name):
"""Searches in the observer for any possible listener, and
stores the notification methods to be called later"""
method_name = "property_%s_value_change" % prop_name
if hasattr(observer, method_name):
method = getattr(observer, method_name)
if method not in self.__value_notifications[prop_name]:
list.append(self.__value_notifications[prop_name], method)
pass
pass
# is it a signal?
orig_prop = getattr(self, "_prop_%s" % prop_name)
if isinstance(orig_prop, Signal):
method_name = "property_%s_signal_emit" % prop_name
if hasattr(observer, method_name):
method = getattr(observer, method_name)
if method not in self.__signal_notif[prop_name]:
list.append(self.__signal_notif[prop_name], method)
pass
pass
pass
# is it an instance change notification type?
elif isinstance(orig_prop, ObsWrapperBase):
method_name = "property_%s_before_change" % prop_name
if hasattr(observer, method_name):
method = getattr(observer, method_name)
if method not in self.__instance_notif_before[prop_name]:
list.append(self.__instance_notif_before[prop_name], method)
pass
pass
method_name = "property_%s_after_change" % prop_name
if hasattr(observer, method_name):
method = getattr(observer, method_name)
if method not in self.__instance_notif_after[prop_name]:
list.append(self.__instance_notif_after[prop_name], method)
pass
pass
pass
return
def __remove_observer_notification(self, observer, prop_name):
if self.__value_notifications.has_key(prop_name):
method_name = "property_%s_value_change" % prop_name
if hasattr(observer, method_name):
method = getattr(observer, method_name)
if method in self.__value_notifications[prop_name]:
self.__value_notifications[prop_name].remove(method)
pass
pass
pass
orig_prop = getattr(self, "_prop_%s" % prop_name)
# is it a signal?
if isinstance(orig_prop, Signal):
method_name = "property_%s_signal_emit" % prop_name
if hasattr(observer, method_name):
method = getattr(observer, method_name)
if method in self.__signal_notif[prop_name]:
self.__signal_notif[prop_name].remove(method)
pass
pass
pass
# is it an instance change notification type?
elif isinstance(orig_prop, ObsWrapperBase):
if self.__instance_notif_before.has_key(prop_name):
method_name = "property_%s_before_change" % prop_name
if hasattr(observer, method_name):
method = getattr(observer, method_name)
if method in self.__instance_notif_before[prop_name]:
self.__instance_notif_before[prop_name].remove(method)
pass
pass
pass
if self.__instance_notif_after.has_key(prop_name):
method_name = "property_%s_after_change" % prop_name
if hasattr(observer, method_name):
method = getattr(observer, method_name)
if method in self.__instance_notif_after[prop_name]:
self.__instance_notif_after[prop_name].remove(method)
pass
pass
pass
pass
return
def __notify_observer__(self, observer, method, *args, **kwargs):
"""This can be overridden by derived class in order to call
the method in a different manner (for example, in
multithreading, or a rpc, etc.) This implementation simply
calls the given method with the given arguments"""
return method(*args, **kwargs)
# ---------- Notifiers:
def notify_property_value_change(self, prop_name, old, new):
assert(self.__value_notifications.has_key(prop_name))
for method in self.__value_notifications[prop_name] :
obs = method.im_self
# notification occurs checking spuriousness of the observer
if old != new or obs.accepts_spurious_change():
self.__notify_observer__(obs, method,
self, old, new) # notifies the change
pass
pass
return
def notify_method_before_change(self, prop_name, instance, meth_name,
args, kwargs):
assert(self.__instance_notif_before.has_key(prop_name))
for method in self.__instance_notif_before[prop_name] :
self.__notify_observer__(method.im_self, method, self, instance,
meth_name, args, kwargs) # notifies the change
pass
return
def notify_method_after_change(self, prop_name, instance, meth_name,
res, args, kwargs):
assert(self.__instance_notif_after.has_key(prop_name))
for method in self.__instance_notif_after[prop_name] :
self.__notify_observer__(method.im_self, method, self, instance,
meth_name, res, args, kwargs) # notifies the change
pass
return
def notify_signal_emit(self, prop_name, args, kwargs):
assert(self.__signal_notif.has_key(prop_name))
for method in self.__signal_notif[prop_name] :
self.__notify_observer__(method.im_self, method, self,
args, kwargs) # notifies the signal emit
pass
return
pass # end of class Model
# ----------------------------------------------------------------------
import gtk
# ----------------------------------------------------------------------
class TreeStoreModel (Model, gtk.TreeStore):
"""Use this class as base class for your model derived by
gtk.TreeStore"""
__metaclass__ = support.metaclasses.ObservablePropertyGObjectMeta
def __init__(self, column_type, *args):
Model.__init__(self)
gtk.TreeStore.__init__(self, column_type, *args)
return
pass
# ----------------------------------------------------------------------
class ListStoreModel (Model, gtk.ListStore):
"""Use this class as base class for your model derived by
gtk.ListStore"""
__metaclass__ = support.metaclasses.ObservablePropertyGObjectMeta
def __init__(self, column_type, *args):
Model.__init__(self)
gtk.ListStore.__init__(self, column_type, *args)
return
pass
# ----------------------------------------------------------------------
class TextBufferModel (Model, gtk.TextBuffer):
"""Use this class as base class for your model derived by
gtk.TextBuffer"""
__metaclass__ = support.metaclasses.ObservablePropertyGObjectMeta
def __init__(self, table=None):
Model.__init__(self)
gtk.TextBuffer.__init__(self, table)
return
pass

124
src/gtkmvc/model_mt.py Normal file
View File

@@ -0,0 +1,124 @@
# Author: Roberto Cavada <cavada@fbk.eu>
#
# Copyright (c) 2006 by Roberto Cavada
#
# pygtkmvc is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# pygtkmvc is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110, USA.
#
# For more information on pygtkmvc see <http://pygtkmvc.sourceforge.net>
# or email to the author Roberto Cavada <cavada@fbk.eu>.
# Please report bugs to <cavada@fbk.eu>.
from gtkmvc.model import Model
import support.metaclasses
try: import threading as _threading
except ImportError: import dummy_threading as _threading
import gobject
if hasattr(gobject, "threads_init"): gobject.threads_init()
else: import gtk; gtk.threads_init()
class ModelMT (Model):
"""A base class for models whose observable properties can be
changed by threads different than gtk main thread. Notification is
performed by exploiting the gtk idle loop only if needed,
otherwise the standard notification system (direct method call) is
used. In this model, the observer is expected to run in the gtk
main loop thread."""
__metaclass__ = support.metaclasses.ObservablePropertyMetaMT
def __init__(self):
Model.__init__(self)
self.__observer_threads = {}
self._prop_lock = _threading.Lock()
return
def register_observer(self, observer):
Model.register_observer(self, observer)
self.__observer_threads[observer] = _threading.currentThread()
return
def unregister_observer(self, observer):
Model.unregister_observer(self, observer)
del self.__observer_threads[observer]
return
# ---------- Notifiers:
def __notify_observer__(self, observer, method, *args, **kwargs):
"""This makes a call either through the gtk.idle list or a
direct method call depending whether the caller's thread is
different from the observer's thread"""
assert self.__observer_threads.has_key(observer)
if _threading.currentThread() == self.__observer_threads[observer]:
# standard call
return Model.__notify_observer__(self, observer, method,
*args, **kwargs)
# multi-threading call
gobject.idle_add(self.__idle_callback, observer, method, args, kwargs)
return
def __idle_callback(self, observer, method, args, kwargs):
method(*args, **kwargs)
return False
pass # end of class
import gtk
# ----------------------------------------------------------------------
class TreeStoreModelMT (ModelMT, gtk.TreeStore):
"""Use this class as base class for your model derived by
gtk.TreeStore"""
__metaclass__ = support.metaclasses.ObservablePropertyGObjectMetaMT
def __init__(self, column_type, *args):
ModelMT.__init__(self)
gtk.TreeStore.__init__(self, column_type, *args)
return
pass
# ----------------------------------------------------------------------
class ListStoreModelMT (ModelMT, gtk.ListStore):
"""Use this class as base class for your model derived by
gtk.ListStore"""
__metaclass__ = support.metaclasses.ObservablePropertyGObjectMetaMT
def __init__(self, column_type, *args):
ModelMT.__init__(self)
gtk.ListStore.__init__(self, column_type, *args)
return
pass
# ----------------------------------------------------------------------
class TextBufferModelMT (ModelMT, gtk.TextBuffer):
"""Use this class as base class for your model derived by
gtk.TextBuffer"""
__metaclass__ = support.metaclasses.ObservablePropertyGObjectMetaMT
def __init__(self, table=None):
ModelMT.__init__(self)
gtk.TextBuffer.__init__(self, table)
return
pass

69
src/gtkmvc/observable.py Normal file
View File

@@ -0,0 +1,69 @@
# -------------------------------------------------------------------------
# Author: Roberto Cavada <cavada@fbk.eu>
#
# Copyright (C) 2006 by Roberto Cavada
#
# pygtkmvc is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# pygtkmvc is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# 51 Franklin Street, Fifth Floor,
# Boston, MA 02110, USA.ridge, MA 02139, USA.
#
# For more information on pygtkmvc see <http://pygtkmvc.sourceforge.net>
# or email to the author <cavada@fbk.eu>.
# -------------------------------------------------------------------------
from support import decorators
from support.wrappers import ObsWrapperBase
# ----------------------------------------------------------------------
class Observable (ObsWrapperBase):
def __init__(self):
ObsWrapperBase.__init__(self)
return
pass # end of class
@decorators.good_decorator
def observed(func):
"""Use this decorator to make your class methods observable.
Your observer will receive at most two notifications:
- property_<name>_before_change
- property_<name>_after_change
"""
def wrapper(*args, **kwargs):
self = args[0]
assert(isinstance(self, Observable))
self._notify_method_before(self, func.__name__, args, kwargs)
res = func(*args, **kwargs)
self._notify_method_after(self, func.__name__, res, args, kwargs)
return res
return wrapper
# ----------------------------------------------------------------------
class Signal (Observable):
"""Base class for signals properties"""
def __init__(self):
Observable.__init__(self)
return
def emit(self, *args, **kwargs):
return self.__get_model__().notify_signal_emit(
self.__get_prop_name__(), args, kwargs)
pass # end of class

91
src/gtkmvc/observer.py Normal file
View File

@@ -0,0 +1,91 @@
# -------------------------------------------------------------------------
# Author: Roberto Cavada <cavada@fbk.eu>
#
# Copyright (C) 2006 by Roberto Cavada
#
# pygtkmvc is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# pygtkmvc is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110, USA.
#
# For more information on pygtkmvc see <http://pygtkmvc.sourceforge.net>
# or email to the author Roberto Cavada <cavada@fbk.eu>.
# Please report bugs to <cavada@fbk.eu>.
# -------------------------------------------------------------------------
class Observer (object):
"""Use this class as base class of all observers"""
def __init__(self, model=None, spurious=False):
"""
When parameter spurious is set to False
(default value) the observer declares that it is not
interested in receiving value-change notifications when
property's value does not really change. This happens when a
property got assigned to a value that is the same it had
before being assigned.
A notification was used to be sent to the observer even in
this particular condition, because spurious (non-changing)
assignments were used as signals when signals were not
supported by early version of the framework. The observer
was in charge of deciding what to do with spurious
assignments, by checking if the old and new values were
different at the beginning of the notification code. With
latest version providing new notification types like
signals, this requirement seems to be no longer needed, and
delivering a notification is no longer a sensible
behaviour.
This is the reason for providing parameter
spurious that changes the previous behaviour
but keeps availability of a possible backward compatible
feature.
"""
self.model = None
self.__accepts_spurious__ = spurious
self.register_model(model)
return
def register_model(self, model):
self.unregister_model()
self.model = model
if self.model: self.model.register_observer(self)
return
def accepts_spurious_change(self):
"""
Returns True if this observer is interested in receiving
spurious value changes. This is queried by the model when
notifying a value change."""
return self.__accepts_spurious__
def unregister_model(self):
if self.model:
self.model.unregister_observer(self)
self.model = None
pass
return
def __del__(self):
self.unregister_model()
return
def get_model(self): return self.model
pass # end of class

View File

@@ -0,0 +1,26 @@
# Author: Roberto Cavada <cavada@fbk.eu>
#
# Copyright (c) 2005 by Roberto Cavada
#
# pygtkmvc is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# pygtkmvc is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110, USA.
#
# For more information on pygtkmvc see <http://pygtkmvc.sourceforge.net>
# or email to the author Roberto Cavada <cavada@fbk.eu>.
# Please report bugs to <cavada@fbk.eu>.
__all__ = ["metaclass_base", "metaclasses", "wrappers", "decorators",
"factories"]

View File

@@ -0,0 +1,44 @@
# -------------------------------------------------------------------------
# Author: Roberto Cavada <cavada@fbk.eu>
#
# Copyright (C) 2006 by Roberto Cavada
#
# pygtkmvc is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# pygtkmvc is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110, USA.
#
# For more information on pygtkmvc see <http://pygtkmvc.sourceforge.net>
# or email to the author Roberto Cavada <cavada@fbk.eu>.
# Please report bugs to <cavada@fbk.eu>.
# -------------------------------------------------------------------------
# This file contains decorators to be used (privately) by other parts
# of the framework
def good_decorator(decorator):
"""This decorator makes decorators behave well wrt to decorated
functions names, doc, etc."""
def new_decorator(f):
g = decorator(f)
g.__name__ = f.__name__
g.__doc__ = f.__doc__
g.__dict__.update(f.__dict__)
return g
new_decorator.__name__ = decorator.__name__
new_decorator.__doc__ = decorator.__doc__
new_decorator.__dict__.update(decorator.__dict__)
return new_decorator

View File

@@ -0,0 +1,24 @@
# Author: Roberto Cavada <cavada@fbk.eu>
#
# Copyright (c) 2005 by Roberto Cavada
#
# pygtkmvc is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# pygtkmvc is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110, USA.
#
# For more information on pygtkmvc see <http://pygtkmvc.sourceforge.net>
# or email to the author Roberto Cavada <cavada@fbk.eu>.
# Please report bugs to <cavada@fbk.eu>.

View File

@@ -0,0 +1,86 @@
# -------------------------------------------------------------------------
# Author: Roberto Cavada <cavada@fbk.eu>
#
# Copyright (C) 2008 by Roberto Cavada
#
# pygtkmvc is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# pygtkmvc is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110, USA.
#
# For more information on pygtkmvc see <http://pygtkmvc.sourceforge.net>
# or email to the author Roberto Cavada <cavada@fbk.eu>.
# Please report bugs to <cavada@fbk.eu>.
# -------------------------------------------------------------------------
import new
from gtkmvc import Model
from noconflict import get_noconflict_metaclass
class ModelFactory (object):
"""This factory constructs classes for models. Use it to build
the classes to derive your own models"""
__memoized = {}
@staticmethod
def __fix_bases(base_classes, have_mt):
"""This function check whether base_classes contains a Model
instance. If not, choose the best fitting class for
model. Furthermore, it makes the list in a cannonical
ordering form in a way that ic can be used as memoization
key"""
fixed = list(base_classes)
contains_model = False
for b in fixed:
if isinstance(fixed, Model): contains_model = True; break
pass
# adds a model when user is lazy
if not contains_model:
if have_mt:
from gtkmvc.model_mt import ModelMT
fixed.insert(0, ModelMT)
else: fixed.insert(0, Model)
pass
class ModelFactoryWrap (object):
__metaclass__ = get_noconflict_metaclass(tuple(fixed), (), ())
def __init__(self, *args, **kwargs): pass
pass
fixed.append(ModelFactoryWrap)
fixed.sort()
return tuple(fixed)
@staticmethod
def make(base_classes=(), have_mt=False):
"""Use this static method to build a model class that
possibly derives from other classes. If have_mt is True,
then returned class will take into account multi-threading
issues when dealing with observable properties."""
good_bc = ModelFactory.__fix_bases(base_classes, have_mt)
print "Base classes are:", good_bc
key = "".join(map(str, good_bc))
if ModelFactory.__memoized.has_key(key):
return ModelFactory.__memoized[key]
cls = new.classobj('', good_bc, {'__module__': '__main__', '__doc__': None})
ModelFactory.__memoized[key] = cls
return cls
#__
#make = staticmethod(make)
pass # end of class

View File

@@ -0,0 +1,240 @@
# Author: Roberto Cavada <cavada@fbk.eu>
#
# Copyright (c) 2005 by Roberto Cavada
#
# pygtkmvc is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# pygtkmvc is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110, USA.
#
# For more information on pygtkmvc see <http://pygtkmvc.sourceforge.net>
# or email to the author Roberto Cavada <cavada@fbk.eu>.
# Please report bugs to <cavada@fbk.eu>.
import new
import re
import types
import gtkmvc.support.wrappers as wrappers
from gtkmvc.support.utils import get_function_from_source
# ----------------------------------------------------------------------
VERBOSE_LEVEL = 5
class PropertyMeta (type):
"""This is a meta-class that provides auto-property support.
The idea is to allow programmers to define some properties which
will be automatically connected to auto-generated code which handles
access to those properties.
How can you use this meta-class?
First, '__metaclass__ = PropertyMeta' must be class member of the class
you want to make the automatic properties handling.
Second, '__properties__' must be a map containing the properties names
as keys, values will be initial values for properties.
That's all: after the instantiation, your class will contain all properties
you named inside '__properties__'. Each of them will be also associated
to a couple of automatically-generated functions which get and set the
property value inside a generated member variable.
About names: suppose the property is called 'x'. The generated variable
(which keeps the real value of the property x) is called _prop_x.
The getter is called get_prop_x(self), and the setter is called
'set_prop_x(self, value)'.
Customization:
The base implementation of getter is to return the value stored in the
variable associated to the property. The setter simply sets its value.
Programmers can override basic behaviour for getters or setters simply by
defining their getters and setters (see at the names convention above).
The customized function can lie everywhere in the user classes hierarchy.
Every overridden function will not be generated by the metaclass.
To supply your own methods is good for few methods, but can result in a
very unconfortable way for many methods. In this case you can extend
the meta-class, and override methods get_[gs]etter_source with your
implementation (this can be probably made better).
An example is provided in meta-class PropertyMetaVerbose below.
"""
def __init__(cls, name, bases, dict):
"""class constructor"""
properties = {}
type.__init__(cls, name, bases, dict)
props = getattr(cls, '__properties__', {})
setattr(cls, '__derived_properties__', {})
der_props = getattr(cls, '__derived_properties__')
# Calculates derived properties:
for base in bases:
maps = ( getattr(base, '__properties__', {}),
getattr(base, '__derived_properties__', {}) )
for _map in maps:
for p in _map.keys():
if not props.has_key(p) and not der_props.has_key(p):
der_props[p] = _map[p]
pass
pass
pass
pass
# Generates code for all properties (but not for derived props):
props = getattr(cls, '__properties__', {})
for prop in props.keys():
type(cls).__create_prop_accessors__(cls, prop, props[prop])
pass
return
def __msg__(cls, msg, level):
"""if level is less or equal to VERBOSE_LEVEL, ths message will
be printed"""
if level <= VERBOSE_LEVEL: print msg
return
def __create_prop_accessors__(cls, prop_name, default_val):
"""Private method that creates getter and setter, and the
corresponding property"""
getter_name = "get_prop_%s" % prop_name
setter_name = "set_prop_%s" % prop_name
members_names = cls.__dict__.keys()
# checks if accessors are already defined:
if getter_name not in members_names:
src = type(cls).get_getter_source(cls, getter_name, prop_name)
func = get_function_from_source(src)
setattr(cls, getter_name, func)
else:
cls.__msg__("Warning: Custom member '%s' overloads generated accessor of property '%s'" \
% (getter_name, prop_name), 2)
pass
if setter_name not in members_names:
src = type(cls).get_setter_source(cls, setter_name, prop_name)
func = get_function_from_source(src)
setattr(cls, setter_name, func)
else:
cls.__msg__("Warning: Custom member '%s' overloads generated accessor of property '%s'" \
% (setter_name, prop_name), 2)
pass
prop = property(getattr(cls, getter_name), getattr(cls, setter_name))
if prop_name in members_names:
cls.__msg__("Warning: automatic property builder overrids property %s in class %s" \
% (prop_name, cls.__name__), 2)
pass
setattr(cls, prop_name, prop)
varname = "_prop_%s" % prop_name
if not varname in members_names: cls.__create_property(varname, default_val)
else: cls.__msg__("Warning: automatic property builder found a possible clashing for variable %s inside class %s" \
% (varname, cls.__name__), 2)
return
def __create_property(cls, name, default_val):
setattr(cls, name, cls.create_value(name, default_val))
return
def check_value_change(cls, old, new):
"""Checks whether the value of the property changed in type
or if the instance has been changed to a different instance.
If true, a call to model._reset_property_notification should
be called in order to re-register the new property instance
or type"""
return type(old) != type(new) or \
isinstance(old, wrappers.ObsWrapperBase) and (old != new)
def create_value(cls, prop_name, val, model=None):
"""This is used to create a value to be assigned to a
property. Depending on the type of the value, different values
are created and returned. For example, for a list, a
ListWrapper is created to wrap it, and returned for the
assignment. model is different from model when the value is
changed (a model exists). Otherwise, during property creation
model is None"""
if isinstance(val, tuple):
# this might be a class instance to be wrapped
if len(val) == 3 and \
isinstance(val[1], val[0]) and \
(isinstance(val[2], tuple) or isinstance(val[2], list)):
res = wrappers.ObsUserClassWrapper(val[1], val[2])
if model: res.__set_model__(model, prop_name)
return res
pass
elif isinstance(val, list):
res = wrappers.ObsListWrapper(val)
if model: res.__set_model__(model, prop_name)
return res
elif isinstance(val, dict):
res = wrappers.ObsMapWrapper(val)
if model: res.__set_model__(model, prop_name)
return res
return val
# ------------------------------------------------------------
# Services
# ------------------------------------------------------------
# Override these:
def get_getter_source(cls, getter_name, prop_name):
"""This must be overridden if you need a different implementation.
Simply the generated implementation returns the variable name
_prop_name"""
return "def %s(self): return self._prop_%s" % (getter_name, prop_name)
def get_setter_source(cls, setter_name, prop_name):
"""This must be overridden if you need a different implementation.
Simply the generated implementation sets the variable _prop_name"""
return "def %s(self, val): self._prop_%s = val" \
% (setter_name, prop_name)
pass # end of class
# ----------------------------------------------------------------------
# What follows underneath is a set of examples of usage
## class PropertyMetaVerbose (PropertyMeta):
## """An example of customization"""
## def get_getter_source(cls, getter_name, prop_name):
## return "def %s(self): print 'Calling %s!'; return self._prop_%s" \
## % (getter_name, getter_name, prop_name)
## def get_setter_source(cls, setter_name, prop_name):
## return "def %s(self, val): print 'Calling %s!'; self._prop_%s = val;" \
## % (setter_name, setter_name, prop_name)
## pass #end of class
# ----------------------------------------------------------------------
## class User:
## """An example of usage"""
## __metaclass__ = PropertyMetaVerbose
## __properties__ = {'x':10, 'y':20}
## def __init__(self):
## print self.x # x is 10
## self.x = self.y + 10 # x is now 30
## return
## pass
# ----------------------------------------------------------------------

View File

@@ -0,0 +1,82 @@
# Author: Roberto Cavada <cavada@fbk.eu>
#
# Copyright (c) 2005 by Roberto Cavada
#
# pygtkmvc is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# pygtkmvc is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110, USA.
#
# For more information on pygtkmvc see <http://pygtkmvc.sourceforge.net>
# or email to the author Roberto Cavada <cavada@fbk.eu>.
# Please report bugs to <cavada@fbk.eu>.
from metaclass_base import PropertyMeta
import types
class ObservablePropertyMeta (PropertyMeta):
"""Classes instantiated by this meta-class must provide a method named
notify_property_change(self, prop_name, old, new)"""
def __init__(cls, name, bases, dict):
PropertyMeta.__init__(cls, name, bases, dict)
return
def get_setter_source(cls, setter_name, prop_name):
return """def %(setter)s(self, val):
old = self._prop_%(prop)s
new = type(self).create_value('%(prop)s', val, self)
self._prop_%(prop)s = new
if type(self).check_value_change(old, new): self._reset_property_notification('%(prop)s')
self.notify_property_value_change('%(prop)s', old, val)
return
""" % {'setter':setter_name, 'prop':prop_name}
pass #end of class
class ObservablePropertyMetaMT (ObservablePropertyMeta):
"""This class provides multithreading support for accesing
properties, through a locking mechanism. It is assumed a lock is
owned by the class that uses it. A Lock object called _prop_lock
is assumed to be a member of the using class. see for example class
ModelMT"""
def __init__(cls, name, bases, dict):
ObservablePropertyMeta.__init__(cls, name, bases, dict)
return
def get_setter_source(cls, setter_name, prop_name):
return """def %(setter)s(self, val):
old = self._prop_%(prop)s
new = type(self).create_value('%(prop)s', val, self)
self._prop_lock.acquire()
self._prop_%(prop)s = new
self._prop_lock.release()
if type(self).check_value_change(old, new): self._reset_property_notification('%(prop)s')
self.notify_property_value_change('%(prop)s', old, val)
return
""" % {'setter':setter_name, 'prop':prop_name}
pass #end of class
try:
from gobject import GObjectMeta
class ObservablePropertyGObjectMeta (ObservablePropertyMeta, GObjectMeta): pass
class ObservablePropertyGObjectMetaMT (ObservablePropertyMetaMT, GObjectMeta): pass
except:
class ObservablePropertyGObjectMeta (ObservablePropertyMeta): pass
class ObservablePropertyGObjectMetaMT (ObservablePropertyMetaMT): pass
pass

View File

@@ -0,0 +1,65 @@
# Author: Michele Simionato <michelesimionato@libero.it>
# Copyright (C) 2004 by Michele Simionato
# License: Python License (version not specified)
# Last Updated: 2nd of March 2007, 10:23 GMT
#
# Any serious user of metaclasses has been bitten at least once by
# the infamous metaclass/metatype conflict. This script contains a
# general recipe to solve the problem, as well as some theory and
# some examples.
import inspect, types, __builtin__
############## preliminary: two utility functions #####################
def skip_redundant(iterable, skipset=None):
"Redundant items are repeated items or items in the original skipset."
if skipset is None: skipset = set()
for item in iterable:
if item not in skipset:
skipset.add(item)
yield item
def remove_redundant(metaclasses):
skipset = set([types.ClassType])
for meta in metaclasses: # determines the metaclasses to be skipped
skipset.update(inspect.getmro(meta)[1:])
return tuple(skip_redundant(metaclasses, skipset))
##################################################################
## now the core of the module: two mutually recursive functions ##
##################################################################
memoized_metaclasses_map = {}
def get_noconflict_metaclass(bases, left_metas, right_metas):
"""Not intended to be used outside of this module, unless you know
what you are doing."""
# make tuple of needed metaclasses in specified priority order
metas = left_metas + tuple(map(type, bases)) + right_metas
needed_metas = remove_redundant(metas)
# return existing confict-solving meta, if any
if needed_metas in memoized_metaclasses_map:
return memoized_metaclasses_map[needed_metas]
# nope: compute, memoize and return needed conflict-solving meta
elif not needed_metas: # wee, a trivial case, happy us
meta = type
elif len(needed_metas) == 1: # another trivial case
meta = needed_metas[0]
# check for recursion, can happen i.e. for Zope ExtensionClasses
elif needed_metas == bases:
raise TypeError("Incompatible root metatypes", needed_metas)
else: # gotta work ...
metaname = '_' + ''.join([m.__name__ for m in needed_metas])
meta = classmaker()(metaname, needed_metas, {})
memoized_metaclasses_map[needed_metas] = meta
return meta
def classmaker(left_metas=(), right_metas=()):
def make_class(name, bases, adict):
metaclass = get_noconflict_metaclass(bases, left_metas, right_metas)
return metaclass(name, bases, adict)
return make_class

View File

@@ -0,0 +1,4 @@
class A (object):
a = 10
pass

View File

@@ -0,0 +1,39 @@
# Author: Roberto Cavada <cavada@fbk.eu>
#
# Copyright (c) 2007 by Roberto Cavada
#
# pygtkmvc is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# pygtkmvc is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110, USA.
#
# For more information on pygtkmvc see <http://pygtkmvc.sourceforge.net>
# or email to the author Roberto Cavada <cavada@fbk.eu>.
# Please report bugs to <cavada@fbk.eu>.
def get_function_from_source(source):
"""Given source code of a function, a function object is
returned"""
import re
m = re.compile("def\s+(\w+)\s*\(.*\):").match(source)
if m is None: raise ValueError("Given source is not a valid function:\n"+
source)
name = m.group(1)
exec source
code = eval("%s.func_code" % name)
import new
return new.function(code, globals(), name)

View File

@@ -0,0 +1,162 @@
# -------------------------------------------------------------------------
# Author: Roberto Cavada <cavada@fbk.eu>
#
# Copyright (C) 2006 by Roberto Cavada
#
# pygtkmvc is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# pygtkmvc is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110, USA.
#
# For more information on pygtkmvc see <http://pygtkmvc.sourceforge.net>
# or email to the author Roberto Cavada <cavada@fbk.eu>.
# Please report bugs to <cavada@fbk.eu>.
# -------------------------------------------------------------------------
import new
# ----------------------------------------------------------------------
class ObsWrapperBase (object):
"""
This class is a base class wrapper for user-defined classes and
containers like lists and maps.
"""
def __init__(self):
self.__prop_name = None
self.__gtkmvc_model = None
return
def __set_model__(self, model, prop_name):
self.__prop_name = prop_name
self.__gtkmvc_model = model
return
def __get_prop_name__(self): return self.__prop_name
def __get_model__(self): return self.__gtkmvc_model
def _notify_method_before(self, instance, name, args, kwargs):
self.__get_model__().notify_method_before_change(self.__prop_name,
instance,
name, args, kwargs)
return
def _notify_method_after(self, instance, name, res_val, args, kwargs):
self.__get_model__().notify_method_after_change(self.__prop_name,
instance,
name, res_val, args, kwargs)
return
pass
# ----------------------------------------------------------------------
class ObsWrapper (ObsWrapperBase):
"""
Base class for wrappers, like user-classes and sequences.
"""
def __init__(self, obj, method_names):
ObsWrapperBase.__init__(self)
self._obj = obj
self.__doc__ = obj.__doc__
for name in method_names:
if hasattr(self._obj, name):
src = self.__get_wrapper_code(name)
exec src
code = eval("%s.func_code" % name)
func = new.function(code, globals())
meth = new.instancemethod(func, self, type(self).__name__)
setattr(self, name, meth)
pass
pass
return
def __get_wrapper_code(self, name):
return """def %(name)s(self, *args, **kwargs):
self._notify_method_before(self._obj, "%(name)s", args, kwargs)
res = self._obj.%(name)s(*args, **kwargs)
self._notify_method_after(self._obj, "%(name)s", res, args, kwargs)
return res""" % {'name' : name}
# For all fall backs
def __getattr__(self, name): return getattr(self._obj, name)
def __repr__(self): return self._obj.__repr__()
def __str__(self): return self._obj.__str__()
pass #end of class
# ----------------------------------------------------------------------
class ObsSeqWrapper (ObsWrapper):
def __init__(self, obj, method_names):
ObsWrapper.__init__(self, obj, method_names)
return
def __setitem__(self, key, val):
self._notify_method_before(self._obj, "__setitem__", (key,val), {})
res = self._obj.__setitem__(key, val)
self._notify_method_after(self._obj, "__setitem__", res, (key,val), {})
return res
def __delitem__(self, key):
self._notify_method_before(self._obj, "__delitem__", (key,), {})
res = self._obj.__delitem__(key)
self._notify_method_after(self._obj, "__delitem__", res, (key,), {})
return res
def __getitem__(self, key):
return self._obj.__getitem__(key)
pass #end of class
# ----------------------------------------------------------------------
class ObsMapWrapper (ObsSeqWrapper):
def __init__(self, m):
methods = ("clear", "pop", "popitem", "update",
"setdefault")
ObsSeqWrapper.__init__(self, m, methods)
return
pass #end of class
# ----------------------------------------------------------------------
class ObsListWrapper (ObsSeqWrapper):
def __init__(self, l):
methods = ("append", "extend", "insert",
"pop", "remove", "reverse", "sort")
ObsSeqWrapper.__init__(self, l, methods)
return
pass #end of class
# ----------------------------------------------------------------------
class ObsUserClassWrapper (ObsWrapper):
def __init__(self, user_class_instance, obs_method_names):
ObsWrapper.__init__(self, user_class_instance, obs_method_names)
return
pass #end of class

215
src/gtkmvc/view.py Normal file
View File

@@ -0,0 +1,215 @@
# Author: Roberto Cavada <cavada@fbk.eu>
# Modified by: Guillaume Libersat <glibersat AT linux62.org>
#
# Copyright (c) 2005 by Roberto Cavada
# Copyright (c) 2007 by Guillaume Libersat
#
# pygtkmvc is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# pygtkmvc is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110, USA.
#
# For more information on pygtkmvc see <http://pygtkmvc.sourceforge.net>
# or email to the author Roberto Cavada <cavada@fbk.eu>.
# Please report bugs to <cavada@fbk.eu>.
import gtk.glade
from controller import Controller
import types
class View (object):
def __init__(self, controller, glade_filename=None,
glade_top_widget_name=None, parent_view=None, register=True):
"""If register is False you *must* call 'controller.register_view(self)'
from the derived class constructor (i.e. registration is delayed)
If filename is not given (or None) all following parameters must be
not given (or None). In that case widgets must be connected manually.
glade_top_widget_name can be either a string name or list of names."""
self.manualWidgets = {}
self.autoWidgets = None
self.xmlWidgets = []
# Sets a callback for custom widgets
gtk.glade.set_custom_handler(self._custom_widget_create)
if (( type(glade_top_widget_name) == types.StringType)
or (glade_top_widget_name is None) ):
wids = (glade_top_widget_name,)
else: wids = glade_top_widget_name # Already a list or tuple
# retrieves XML objects from glade
if (glade_filename is not None):
for i in range(0,len(wids)):
self.xmlWidgets.append(gtk.glade.XML(glade_filename, wids[i]))
pass
pass
# top widget list or singleton:
if (glade_top_widget_name is not None):
if len(wids) > 1:
self.m_topWidget = []
for i in range(0, len(wids)):
self.m_topWidget.append(self[wids[i]])
pass
else: self.m_topWidget = self[wids[0]]
else: self.m_topWidget = None
if (glade_filename is not None): self.__autoconnect_signals(controller)
if (register): controller.register_view(self)
if (not parent_view is None): self.set_parent_view(parent_view)
return
# Gives us the ability to do: view['widget_name'].action()
# Returns None if no widget name has been found.
def __getitem__(self, key):
wid = None
if self.autoWidgets:
if self.autoWidgets.has_key(key): wid = self.autoWidgets[key]
pass
else:
for xml in self.xmlWidgets:
wid = xml.get_widget(key)
if wid is not None: break
pass
pass
if wid is None:
# try with manually-added widgets:
if self.manualWidgets.has_key(key):
wid = self.manualWidgets[key]
pass
pass
return wid
# You can also add a single widget:
def __setitem__(self, key, wid):
self.manualWidgets[key] = wid
if (self.m_topWidget is None): self.m_topWidget = wid
return
def show(self):
ret = True
top = self.get_top_widget()
if type(top) in (types.ListType, types.TupleType):
for t in top:
if t is not None: ret = ret and t.show()
pass
elif (top is not None): ret = top.show_all()
else: ret = False
return ret
def hide(self):
top = self.get_top_widget()
if type(top) in (types.ListType, types.TupleType):
for t in top:
if t is not None: t.hide_all()
pass
elif top is not None: top.hide_all()
return
# Returns the top-level widget, or a list of top widgets
def get_top_widget(self):
return self.m_topWidget
# Set parent view:
def set_parent_view(self, parent_view):
top = self.get_top_widget()
if type(top) in (types.ListType, types.TupleType):
for t in top:
if t is not None:
t.set_transient_for(parent_view.get_top_widget())
pass
pass
elif (top is not None):
top.set_transient_for(parent_view.get_top_widget())
pass
return
# Set the transient for the view:
def set_transient(self, transient_view):
top = self.get_top_widget()
if type(top) in (types.ListType, types.TupleType):
for t in top:
if t is not None:
transient_view.get_top_widget().set_transient_for(t)
pass
pass
elif (top is not None):
transient_view.get_top_widget().set_transient_for(top)
pass
return
# Finds the right callback for custom widget creation and calls it
# Returns None if an undefined or invalid handler is found
def _custom_widget_create(self, glade, function_name, widget_name,
str1, str2, int1, int2):
# This code was kindly provided by Allan Douglas <zalguod at
# users.sourceforge.net>
if function_name is not None:
handler = getattr(self, function_name, None)
if handler is not None: return handler(str1, str2, int1, int2)
pass
return None
# implements the iteration protocol
def __iter__(self):
# pre-calculates the auto widgets if needed:
if self.autoWidgets is None:
self.autoWidgets = {}
for xml in self.xmlWidgets:
for wid in xml.get_widget_prefix(""):
wname = gtk.glade.get_widget_name(wid)
assert not self.autoWidgets.has_key(wname)
self.autoWidgets[wname] = wid
pass
pass
pass
self.__idx = 0
self.__max1 = len(self.autoWidgets)
self.__max2 = self.__max1 + len(self.manualWidgets)
return self
# implements the iteration protocol
def next(self):
if self.__idx >= self.__max2: raise StopIteration()
if self.__idx >= self.__max1: m = self.manualWidgets
else: m = self.autoWidgets
self.__idx += 1
return m.keys()[self.__idx-1]
# performs Controller's signals auto-connection:
def __autoconnect_signals(self, controller):
dic = {}
for name in dir(controller):
method = getattr(controller, name)
if (not callable(method)): continue
assert(not dic.has_key(name)) # not already connected!
dic[name] = method
pass
for xml in self.xmlWidgets: xml.signal_autoconnect(dic)
return
pass # end of class View

25
src/lib/__init__.py Normal file
View File

@@ -0,0 +1,25 @@
# This Python file uses the following encoding: utf-8
#
# Author: Roman 'gryf' Dobosz gryf@elysium.pl
#
# Copyright (C) 2007 by Roman 'gryf' Dobosz
#
# This file is part of pyGTKtalog.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# -------------------------------------------------------------------------

86
src/lib/device_helper.py Normal file
View File

@@ -0,0 +1,86 @@
"""
Project: pyGTKtalog
Description: Simple functions for device management.
Type: lib
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2008-12-15
"""
import os
import locale
import gettext
from src.lib.globs import APPL_SHORT_NAME
locale.setlocale(locale.LC_ALL, '')
gettext.install(APPL_SHORT_NAME, 'locale', unicode=True)
def volname(mntp):
"""read volume name from cd/dvd"""
dev = mountpoint_to_dev(mntp)
label = None
if dev != None:
try:
disk = open(dev, "rb")
disk.seek(32808)
label = disk.read(32).strip()
disk.close()
except IOError:
return None
return label
def volmount(mntp):
"""
Mount device.
@param mountpoint
@returns tuple with bool status of mount, and string with error message
"""
_in, _out, _err = os.popen3("mount %s" % mntp)
inf = _err.readlines()
if len(inf) > 0:
return False, inf[0].strip()
else:
return True, ''
def volumount(mntp):
"""mount device, return 'ok' or error message"""
_in, _out, _err = os.popen3("umount %s" % mntp)
inf = _err.readlines()
if len(inf) > 0:
return inf[0].strip()
return 'ok'
def check_mount(dev):
"""Refresh the entries from fstab or mount."""
mounts = os.popen('mount')
for line in mounts.readlines():
parts = line.split()
device = parts
if device[0] == dev:
return True
return False
def mountpoint_to_dev(mntp):
"""guess device name by mountpoint from fstab"""
fstab = open("/etc/fstab")
device = None
for line in fstab.readlines():
output = line.split()
# lengtht of single valid fstab line is at least 5
if len(output) > 5 and output[1] == mntp and output[0][0] != '#':
device = output[0]
fstab.close()
return device
def eject_cd(eject_app, cdrom):
"""mount device, return 'ok' or error message"""
if len(eject_app) > 0:
_in, _out, _err = os.popen3("%s %s" % (eject_app, cdrom))
inf = _err.readlines()
if len(inf) > 0 and inf[0].strip() != '':
return inf[0].strip()
return 'ok'
return _("Eject program not specified")

41
src/lib/globs.py Normal file
View File

@@ -0,0 +1,41 @@
# This Python file uses the following encoding: utf-8
#
# Author: Roman 'gryf' Dobosz gryf@elysium.pl
#
# Copyright (C) 2007 by Roman 'gryf' Dobosz
#
# This file is part of pyGTKtalog.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# -------------------------------------------------------------------------
import os.path
import sys
if sys.argv[0]:
top_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
else:
top_dir = "."
# ----------------------------------------------------------------------
TOPDIR = top_dir
RESOURCES_DIR = os.path.join(TOPDIR, "resources")
GLADE_DIR = os.path.join(RESOURCES_DIR, "glade")
STYLES_DIR = os.path.join(RESOURCES_DIR, "styles")
APPL_SHORT_NAME = "pygtktalog"
APPL_VERSION = (1, 0, 2)
# ----------------------------------------------------------------------

82
src/lib/gthumb.py Normal file
View File

@@ -0,0 +1,82 @@
# This Python file uses the following encoding: utf-8
#
# Author: Roman 'gryf' Dobosz gryf@elysium.pl
#
# Copyright (C) 2007 by Roman 'gryf' Dobosz
#
# This file is part of pyGTKtalog.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# -------------------------------------------------------------------------
from xml.dom import minidom
import gzip
import os
from datetime import date
class GthumbCommentParser(object):
"""Read and return comments created eith gThumb program"""
def __init__(self, image_path, image_filename):
self.path = image_path
self.filename = image_filename
def parse(self):
"""Return dictionary with apropriate fields, or None if no comment
available"""
try:
gzf = gzip.open(os.path.join(self.path, '.comments',
self.filename + '.xml'))
except:
return None
try:
xml = gzf.read()
gzf.close()
except:
gzf.close()
return None
if not xml:
return None
retval = {}
doc = minidom.parseString(xml)
try:
retval['note'] = doc.getElementsByTagName('Note').item(0)
retval['note'] = retval['note'].childNodes.item(0).data
except: retval['note'] = None
try:
retval['place'] = doc.getElementsByTagName('Place').item(0)
retval['place'] = retval['place'].childNodes.item(0).data
except: retval['place'] = None
try:
d = doc.getElementsByTagName('Time').item(0).childNodes
d = d.item(0).data
if int(d) > 0: retval['date'] = date.fromtimestamp(int(d))
else: retval['date'] = None
except: retval['date'] = None
try:
retval['keywords'] = doc.getElementsByTagName('Keywords').item(0)
retval['keywords'] = retval['keywords'].childNodes.item(0)
retval['keywords'] = retval['keywords'].data.split(',')
except: pass
if len(retval) > 0: return retval
else: return None

77
src/lib/img.py Normal file
View File

@@ -0,0 +1,77 @@
# This Python file uses the following encoding: utf-8
#
# Author: Roman 'gryf' Dobosz gryf@elysium.pl
#
# Copyright (C) 2007 by Roman 'gryf' Dobosz
#
# This file is part of pyGTKtalog.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# -------------------------------------------------------------------------
from shutil import copy
from os import path
from hashlib import sha512
import Image
class Img(object):
def __init__(self, filename, base=''):
self.root = 'images'
self.x = 160
self.y = 160
self.filename = filename
self.base = base
f = open(filename, "r")
self.sha512 = sha512(f.read()).hexdigest()
f.close()
def save(self):
"""Save image and asociated thumbnail into specific directory structure
returns filename for image"""
image_filename = path.join(self.base, self.sha512)
thumbnail = path.join(self.base, self.sha512 + "_t")
# check wheter image already exists
if path.exists(image_filename) and path.exists(thumbnail):
if __debug__:
print "image", self.filename, "with hash",
print self.sha512, "already exist"
return self.sha512
if not path.exists(thumbnail):
im = self.__scale_image()
im.save(thumbnail, "JPEG")
# copy image
if not path.exists(image_filename):
copy(self.filename, image_filename)
return self.sha512
# private class functions
def __scale_image(self):
"""create thumbnail. returns image object or None"""
try:
im = Image.open(self.filename).convert('RGB')
except:
return None
x, y = im.size
if x > self.x or y > self.y:
im.thumbnail((self.x, self.y), Image.ANTIALIAS)
return im

2397
src/lib/no_thumb.py Normal file

File diff suppressed because it is too large Load Diff

117
src/lib/parse_exif.py Normal file
View File

@@ -0,0 +1,117 @@
import re
import EXIF
class ParseExif(object):
def __init__(self, exif_dict=None, exif_file=None):
self.camera = None
self.date = None
self.aperture = None
self.exposure_program = None
self.exposure_bias = None
self.iso = None
self.focal_length = None
self.subject_distance = None
self.metering_mode = None
self.flash = None
self.light_source = None
self.resolution = None
self.orientation = None
self.exif_dict = exif_dict
if not self.exif_dict:
try:
f = open(exif_file, 'rb')
e = EXIF.process_file(f)
if len(e.keys()) >0:
self.exif_dict = e
f.close()
except:
pass
def parse(self):
try:
self.camera = "%s" % self.exif_dict['Image Make']
self.camera = self.camera.strip()
except: pass
try:
model = "%s" % self.exif_dict['Image Model']
self.camera += ", " + model.strip()
except: pass
try:
self.date = "%s" % self.exif_dict['EXIF DateTimeOriginal']
p = re.compile('[\d,:]+')
if not p.match(self.date):
self.date = None
except: pass
try:
self.aperture = "%s" % self.exif_dict['EXIF FNumber']
if len(self.aperture.split("/")) == 2:
self.aperture += '.'
self.aperture = "%.1f" % eval(self.aperture)
self.aperture = "f/%.1f" % float(self.aperture)
self.aperture = self.aperture.replace('.',',')
except: pass
try: self.exposure_program = "%s" % \
self.exif_dict['EXIF ExposureProgram']
except: pass
try:
self.exposure_bias = "%s" % \
self.exif_dict['EXIF ExposureBiasValue']
if len(self.exposure_bias.split("/")) == 2:
self.exposure_bias += '.'
self.exposure_bias = "%.1f" % eval(self.exposure_bias)
self.exposure_bias = "%.1f" % float(self.exposure_bias)
self.exposure_bias = self.exposure_bias.replace('.',',')
except: pass
try: self.iso = "%s" % self.exif_dict['EXIF ISOSpeedRatings']
except: pass
try:
self.focal_length = "%s" % self.exif_dict['EXIF FocalLength']
if len(self.focal_length.split("/")) == 2:
self.focal_length += '.'
self.focal_length = "%.2f" % eval(self.focal_length)
self.focal_length = "%.2f mm" % float(self.focal_length)
self.focal_length = self.focal_length.replace('.',',')
except: pass
try:
self.subject_distance = "%s" % \
self.exif_dict['EXIF SubjectDistance']
if len(self.subject_distance.split("/")) == 2:
self.subject_distance += '.'
self.subject_distance = "%.3f" % eval(self.subject_distance)
self.subject_distance = "%.3f m" % float(self.subject_distance)
self.subject_distance = self.subject_distance.replace('.',',')
except: pass
try: self.metering_mode = "%s" % self.exif_dict['EXIF MeteringMode']
except: pass
try: self.flash = "%s" % self.exif_dict['EXIF Flash']
except: pass
try: self.light_source = "%s" % self.exif_dict['EXIF LightSource']
except: pass
try: self.resolution = "%s" % self.exif_dict['Image XResolution']
except: pass
try: self.resolution = self.resolution + " x %s" % \
self.exif_dict['Image YResolution']
except: pass
try: self.resolution = self.resolution + " (%s)" % \
self.exif_dict['Image ResolutionUnit']
except: pass
try: self.orientation = "%s" % self.exif_dict['Image Orientation']
except: pass
return (self.camera, self.date, self.aperture, self.exposure_program,
self.exposure_bias, self.iso, self.focal_length,
self.subject_distance, self.metering_mode, self.flash,
self.light_source, self.resolution, self.orientation)

83
src/lib/thumbnail.py Normal file
View File

@@ -0,0 +1,83 @@
"""
Project: pyGTKtalog
Description: Thumbnail helper
Type: library
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2012-02-19
"""
from hashlib import sha256
from cStringIO import StringIO
from lib import EXIF
import Image
class Thumbnail(object):
"""Class for generate/extract thumbnail from image file"""
def __init__(self, fp, base=''):
self.thumb_x = 160
self.thumb_y = 160
self.base = base
self.sha256 = sha256(fp.read(10485760)).hexdigest()
fp.seek(0)
self.fp = fp
def save(self):
"""Save thumbnail into specific directory structure
return exif obj and fp to thumbnail"""
exif = {}
orientations = {2: Image.FLIP_LEFT_RIGHT, # Mirrored horizontal
3: Image.ROTATE_180, # Rotated 180
4: Image.FLIP_TOP_BOTTOM, # Mirrored vertical
5: Image.ROTATE_90, # Mirrored horizontal then
# rotated 90 CCW
6: Image.ROTATE_270, # Rotated 90 CW
7: Image.ROTATE_270, # Mirrored horizontal then
# rotated 90 CW
8: Image.ROTATE_90} # Rotated 90 CCW
flips = {7: Image.FLIP_LEFT_RIGHT, 5: Image.FLIP_LEFT_RIGHT}
try:
exif = EXIF.process_file(self.fp)
except:
self.fp.seek(0)
thumb_file = StringIO()
if 'JPEGThumbnail' in exif:
thumb_file.write(exif['JPEGThumbnail'])
if 'Image Orientation' in exif:
orient = exif['Image Orientation'].values[0]
if orient > 1 and orient in orientations:
tmp_thumb_img = StringIO()
thumb_image = Image.open(self.fp)
tmp_thumb_img = thumb_image.transpose(orientations[orient])
if orient in flips:
tmp_thumb_img = tmp_thumb_img.transpose(flips[orient])
if tmp_thumb_img:
thumb_file.seek(0)
tmp_thumb_img.save(thumb_file, 'JPEG')
tmp_thumb_img.close()
else:
thumb = self.__scale_image()
if thumb:
thumb.save(self.thumbnail_path, "JPEG")
return exif, thumb_file
def __scale_image(self):
"""create thumbnail. returns image object or None"""
try:
image_thumb = Image.open(self.fp).convert('RGB')
except:
return None
it_x, it_y = image_thumb.size
if it_x > self.thumb_x or it_y > self.thumb_y:
image_thumb.thumbnail((self.thumb_x, self.thumb_y),
Image.ANTIALIAS)
return image_thumb

25
src/models/__init__.py Normal file
View File

@@ -0,0 +1,25 @@
# This Python file uses the following encoding: utf-8
#
# Author: Roman 'gryf' Dobosz gryf@elysium.pl
#
# Copyright (C) 2007 by Roman 'gryf' Dobosz
#
# This file is part of pyGTKtalog.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# -------------------------------------------------------------------------

340
src/models/m_config.py Normal file
View File

@@ -0,0 +1,340 @@
# This Python file uses the following encoding: utf-8
#
# Author: Roman 'gryf' Dobosz gryf@elysium.pl
#
# Copyright (C) 2007 by Roman 'gryf' Dobosz
#
# This file is part of pyGTKtalog.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# -------------------------------------------------------------------------
from gtkmvc import Model
import os
import gtk
import gobject
from ConfigParser import ConfigParser
class Ini(object):
def __init__(self):
self.ini = []
def add_section(self, section):
self.ini.append("[%s]" % section)
def add_key(self, key, value):
self.ini.append("%s=%s" % (key, value))
def add_comment(self, comment):
self.ini.append(";%s" % comment)
def add_verb(self, verb):
self.ini.append(verb)
def show(self):
return "\n".join(self.ini)
class ConfigModel(Model):
ini = Ini()
__properties__ = {}
filetype_list = ['Images', 'Movies']
confd = {
'savewin': True,
'savepan': True,
'wx': 800,
'wy': 600,
'h': 200,
'v': 300,
'eject': True,
'compress': True,
'exportxls': False,
'confirmquit': True,
'confirmabandon': True,
'mntwarn': True,
'delwarn': True,
'cd': '/mnt/cdrom',
'ejectapp': 'eject -r',
'imgview': False,
'imgprog': 'gqview',
'retrive': False,
'thumbs': True,
'exif': True,
'gthumb': False,
'extensions': {'bmp':'identify %s',
'gif':'identify "%s"',
'jpg':'identify "%s"',
'jpeg':'identify "%s"',
'png':'identify "%s"',
'avi':'midentify "%s"',
'mkv':'midentify "%s"',
'mpg':'midentify "%s"',
'mpeg':'midentify "%s"',
'wmv':'midentify "%s"',
},
'showtoolbar':True,
'showstatusbar':True,
}
dictconf = {
"save main window size": "savewin",
"save panes size": "savepan",
"main window width": "wx",
"main window height": "wy",
"horizontal panes": "h",
"vertical panes":"v",
"export xls":"exportxls",
"cd drive":"cd",
"eject command":"ejectapp",
"eject":"eject",
"image support":"thumbs",
'confirm quit':'confirmquit',
'warn mount/umount errors':'mntwarn',
'warn on delete':'delwarn',
'confirm abandon current catalog':'confirmabandon',
'show toolbar':'showtoolbar',
'show statusbar and progress bar':'showstatusbar',
'compress catalog':'compress',
'retrive extra informatin':'retrive',
'scan exif data':'exif',
'include gthumb image description':'gthumb',
'use external image viewer':'imgview',
'external image viewer program':'imgprog',
}
dbool = (
'exportxls',
'thumbs',
'savewin',
'savepan',
'eject',
'gthumb',
'exif',
'confirmquit',
'mntwarn',
'delwarn',
'confirmabandon',
'showtoolbar',
'showstatusbar',
'delwarn',
'compress',
'retrive',
'imgview',
)
recent = []
search_history = []
RECENT_MAX = 10
HISTORY_MAX = 20
dstring = ('cd','ejectapp','imgprog')
try:
path = os.path.join(os.environ['HOME'], ".pygtktalog")
except KeyError:
raise KeyError, "Cannot stat path for current user home!"
path = os.path.join(path, "config.ini")
def __init__(self):
Model.__init__(self)
self.category_tree = gtk.ListStore(gobject.TYPE_STRING)
self.refresh_ext()
return
def refresh_ext(self):
self.ext_tree = gtk.ListStore(gobject.TYPE_STRING,
gobject.TYPE_STRING)
keys = sorted(self.confd['extensions'].keys())
for i in keys:
myiter = self.ext_tree.insert_before(None,None)
self.ext_tree.set_value(myiter, 0, i)
self.ext_tree.set_value(myiter, 1, self.confd['extensions'][i])
def save(self):
try:
os.lstat(self.path)
except:
print "Saving preferences to %s." % self.path
if __debug__:
print "m_config.py: save() Saving preferences to",
print "%s" % self.path
newIni = Ini()
# main section
newIni.add_section("pyGTKtalog conf")
for opt in self.dictconf:
newIni.add_key(opt,self.confd[self.dictconf[opt]])
# recent section
newIni.add_section("pyGTKtalog recent")
count = 1
max_count = self.RECENT_MAX + 1
for opt in self.recent:
if count < max_count:
newIni.add_key(count, opt)
else:
break
count+=1
# search history section
newIni.add_section("search history")
count = 1
max_count = self.HISTORY_MAX + 1
for opt in self.search_history:
if count < max_count:
newIni.add_key(count, opt)
else:
break
count+=1
# extensions sections
newIni.add_section("extensions")
count = 1
for i in self.confd['extensions']:
newIni.add_key(i, self.confd['extensions'][i])
count+=1
# write config
try:
f = open(self.path, "w")
success = True
except:
if __debug__:
print "m_config.py: save() Cannot open config file",
print "%s for writing." % self.path
success = False
f.write(newIni.show())
f.close()
return success
def load(self):
try:
# try to read config file
parser = ConfigParser()
parser.read(self.path)
r = {}
h = {}
self.recent = []
self.search_history = []
for sec in parser.sections():
if sec == 'pyGTKtalog conf':
for opt in parser.options(sec):
i = self.dictconf[opt]
try:
if self.dictconf[opt] in self.dbool:
self.confd[i] = parser.getboolean(sec, opt)
elif self.dictconf[opt] in self.dstring:
self.confd[i] = parser.get(sec, opt)
else:
self.confd[i] = parser.getint(sec, opt)
except:
if __debug__:
print "m_config.py: load() failed to parse",
print "option:", opt
pass
elif sec == 'pyGTKtalog recent':
for opt in parser.options(sec):
try:
r[int(opt)] = parser.get(sec, opt)
except:
if __debug__:
print "m_config.py: load() failed to parse",
print "option:", opt
pass
elif sec == 'search history':
for opt in parser.options(sec):
try:
h[int(opt)] = parser.get(sec, opt)
except:
if __debug__:
print "m_config.py: load() failed to parse",
print "option:", opt
pass
elif sec == 'extensions':
self.confd['extensions'] = {}
for opt in parser.options(sec):
try:
self.confd['extensions'][opt] = parser.get(sec,
opt)
except:
if __debug__:
print "m_config.py: load() failed to parse",
print "option:", opt
pass
for i in range(1, self.RECENT_MAX + 1):
if i in r:
self.recent.append(r[i])
for i in range(1, self.HISTORY_MAX + 1):
if i in h:
self.search_history.append(h[i])
except:
if __debug__:
print "m_config.py: load() load config file failed"
pass
def add_recent(self, path):
if not path:
return
if path in self.recent:
self.recent.remove(path)
self.recent.insert(0,path)
return
self.recent.insert(0,path)
if len(self.recent) > self.RECENT_MAX:
self.recent = self.recent[:self.RECENT_MAX]
return
def add_search_history(self, text):
if not text:
return
if text in self.search_history:
self.search_history.remove(text)
self.search_history.insert(0, text)
return
self.search_history.insert(0, text)
if len(self.search_history) > self.HISTORY_MAX:
self.search_history = self.search_history[:self.HISTORY_MAX]
return
def __str__(self):
"""show prefs in string way"""
string = "[varname]\tvalue\n"
for i in self.confd:
string+="%s\t%s\n" % (i,self.confd[i])
return string

2002
src/models/m_main.py Normal file

File diff suppressed because it is too large Load Diff

25
src/views/__init__.py Normal file
View File

@@ -0,0 +1,25 @@
# This Python file uses the following encoding: utf-8
#
# Author: Roman 'gryf' Dobosz gryf@elysium.pl
#
# Copyright (C) 2007 by Roman 'gryf' Dobosz
#
# This file is part of pyGTKtalog.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# -------------------------------------------------------------------------

36
src/views/v_config.py Normal file
View File

@@ -0,0 +1,36 @@
# This Python file uses the following encoding: utf-8
#
# Author: Roman 'gryf' Dobosz gryf@elysium.pl
#
# Copyright (C) 2007 by Roman 'gryf' Dobosz
#
# This file is part of pyGTKtalog.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# -------------------------------------------------------------------------
from gtkmvc import View
import os.path
import lib.globs
class ConfigView(View):
"""Preferences window from glade file """
GLADE = os.path.join(lib.globs.GLADE_DIR, "config.glade")
def __init__(self, ctrl):
View.__init__(self, ctrl, self.GLADE)
return
pass # end of class

653
src/views/v_dialogs.py Normal file
View File

@@ -0,0 +1,653 @@
# This Python file uses the following encoding: utf-8
#
# Author: Roman 'gryf' Dobosz gryf@elysium.pl
#
# Copyright (C) 2007 by Roman 'gryf' Dobosz
#
# This file is part of pyGTKtalog.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# -------------------------------------------------------------------------
import gtk
import gobject
import os
import lib.globs
class Qst(object):
"""Show simple dialog for questions
if "OK" button pressed, return "True"
"Cancel" button return "False"
"""
def __init__(self, title="", message="", secondarymsg=""):
self.dialog = gtk.MessageDialog(
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
type = gtk.MESSAGE_QUESTION,
buttons = gtk.BUTTONS_OK_CANCEL,
message_format = message,
)
self.dialog.set_title(title)
self.dialog.format_secondary_text(secondarymsg)
def run(self):
retval = self.dialog.run()
self.dialog.destroy()
if retval == gtk.RESPONSE_OK:
return True
return False
class Inf(object):
"""Show simple dialog for notices"""
def __init__(self, title="", message="", secondarymsg=""):
self.dialog = gtk.MessageDialog(
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
type = gtk.MESSAGE_INFO,
buttons = gtk.BUTTONS_OK,
message_format = message,
)
self.dialog.set_title(title)
self.dialog.format_secondary_text(secondarymsg)
self.dialog.connect('response',
lambda dialog, response: self.ret(response))
self.dialog.show()
def ret(self,result):
self.dialog.destroy()
return True
class Wrn(object):
"""Show simple dialog for warnings"""
def __init__(self, title="", message="", secondarymsg=""):
self.dialog = gtk.MessageDialog(
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
type = gtk.MESSAGE_WARNING,
buttons = gtk.BUTTONS_CLOSE,
message_format = message,
)
self.dialog.set_title(title)
self.dialog.format_secondary_text(secondarymsg)
self.dialog.connect('response',
lambda dialog, response: self.ret(response))
self.dialog.show()
def ret(self,result):
self.dialog.destroy()
return True
class Err(object):
"""Show simple dialog for errors"""
def __init__(self, title="", message="", secondarymsg=""):
self.dialog = gtk.MessageDialog(
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
type = gtk.MESSAGE_ERROR,
buttons = gtk.BUTTONS_CLOSE,
message_format = message)
self.dialog.set_title(title)
self.dialog.format_secondary_text(secondarymsg)
self.dialog.connect('response',
lambda dialog, response: self.ret(response))
self.dialog.run()
def ret(self,result):
self.dialog.destroy()
return True
class Abt(object):
"""Show simple about dialog"""
def __init__(self, name=None, ver="", title="", authors=[],licence=""):
self.dialog = gtk.AboutDialog()
self.dialog.set_title(title)
self.dialog.set_version(ver)
self.dialog.set_license(licence)
self.dialog.set_name(name)
self.dialog.set_authors(authors)
self.dialog.connect('response',
lambda dialog, response: self.dialog.destroy())
self.dialog.show()
class InputDiskLabel(object):
"""Sepcific dialog for quering user for a disc label"""
def __init__(self, label=""):
self.gladefile = os.path.join(lib.globs.GLADE_DIR, "dialogs.glade")
self.label = ""
if label!= None:
self.label = label
def run(self):
gladexml = gtk.glade.XML(self.gladefile, "inputDialog")
dialog = gladexml.get_widget("inputDialog")
entry = gladexml.get_widget("volname")
entry.set_text(self.label)
result = dialog.run()
dialog.destroy()
if result == gtk.RESPONSE_OK:
return entry.get_text()
return None
class InputNewName(object):
"""Sepcific dialog for quering user for a disc label"""
def __init__(self, name=""):
self.gladefile = os.path.join(lib.globs.GLADE_DIR, "dialogs.glade")
self.label = ""
self.name = name
def run(self):
gladexml = gtk.glade.XML(self.gladefile, "renameDialog")
dialog = gladexml.get_widget("renameDialog")
entry = gladexml.get_widget("name")
entry.set_text(self.name)
result = dialog.run()
dialog.destroy()
if result == gtk.RESPONSE_OK:
return entry.get_text()
return None
class PointDirectoryToAdd(object):
"""Sepcific dialog for quering user for selecting directory to add"""
URI="file://"+os.path.abspath(os.path.curdir)
def __init__(self,volname='',dirname=''):
self.gladefile = os.path.join(lib.globs.GLADE_DIR, "dialogs.glade")
self.gladexml = gtk.glade.XML(self.gladefile, "addDirDialog")
self.volname = self.gladexml.get_widget("dirvolname")
self.volname.set_text(volname)
self.directory = self.gladexml.get_widget("directory")
self.directory.set_text(dirname)
sigs = {"on_browse_activate":self.show_dirchooser,
"on_browse_clicked":self.show_dirchooser}
self.gladexml.signal_autoconnect(sigs)
def show_dirchooser(self,widget):
"""dialog for point the mountpoint"""
dialog = gtk.FileChooserDialog(
title="Choose directory to add",
action=gtk.FILE_CHOOSER_ACTION_OPEN,
buttons=(
gtk.STOCK_CANCEL,
gtk.RESPONSE_CANCEL,
gtk.STOCK_OPEN,
gtk.RESPONSE_OK))
dialog.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
dialog.set_default_response(gtk.RESPONSE_OK)
if self.URI:
dialog.set_current_folder_uri(self.URI)
response = dialog.run()
if response == gtk.RESPONSE_OK:
self.directory.set_text(dialog.get_filename())
self.__class__.URI = dialog.get_current_folder_uri()
dialog.destroy()
def run(self):
dialog = self.gladexml.get_widget("addDirDialog")
ch = True
result = dialog.run()
while ch:
if result == gtk.RESPONSE_OK and (self.volname.get_text()=='' or \
self.directory.get_text() == ''):
a = Err("Error - pyGTKtalog",
"There are fields needed to be filled.",
"Cannot add directory without path and disc label.")
ch = True
result = dialog.run()
else:
ch = False
dialog.destroy()
if result == gtk.RESPONSE_OK:
return self.volname.get_text(),self.directory.get_text()
else:
return None,None
class SelectDirectory(object):
"""Sepcific dialog for quering user for selecting directory to add"""
URI="file://"+os.path.abspath(os.path.curdir)
def __init__(self, title=None):
if title:
self.title = title
else:
self.title = "Choose directory"
def run(self):
"""dialog for point the mountpoint"""
dialog = gtk.FileChooserDialog(
title = self.title,
action = gtk.FILE_CHOOSER_ACTION_OPEN,
buttons = (
gtk.STOCK_CANCEL,
gtk.RESPONSE_CANCEL,
gtk.STOCK_OPEN,
gtk.RESPONSE_OK))
dialog.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
dialog.set_default_response(gtk.RESPONSE_OK)
retval = None
if self.URI:
dialog.set_current_folder_uri(self.URI)
response = dialog.run()
if response == gtk.RESPONSE_OK:
retval = dialog.get_filename()
self.__class__.URI = dialog.get_current_folder_uri()
dialog.destroy()
return retval
class ChooseFilename(object):
"""Dialog for quering user for selecting filename"""
URI=None
def __init__(self, path=None, title=''):
self.path = path
self.dialog = gtk.FileChooserDialog(
title="",
action=gtk.FILE_CHOOSER_ACTION_SAVE,
buttons=(
gtk.STOCK_CANCEL,
gtk.RESPONSE_CANCEL,
gtk.STOCK_SAVE,
gtk.RESPONSE_OK))
self.dialog.set_action(gtk.FILE_CHOOSER_ACTION_SAVE)
self.dialog.set_default_response(gtk.RESPONSE_OK)
self.dialog.set_do_overwrite_confirmation(True)
self.dialog.set_title(title)
f = gtk.FileFilter()
f.set_name("Catalog files")
f.add_pattern("*.sqlite")
f.add_pattern("*.sqlite.bz2")
self.dialog.add_filter(f)
f = gtk.FileFilter()
f.set_name("All files")
f.add_pattern("*.*")
self.dialog.add_filter(f)
def run(self):
if self.URI:
self.dialog.set_current_folder_uri(self.URI)
elif self.path and os.path.exists(self.path):
self.path = "file://"+os.path.abspath(self.path)
self.dialog.set_current_folder_uri(self.path)
response = self.dialog.run()
if response == gtk.RESPONSE_OK:
filename = self.dialog.get_filename()
self.__class__.URI = self.dialog.get_current_folder_uri()
self.dialog.destroy()
return filename
else:
self.dialog.destroy()
return None
pass
class ChooseDBFilename(ChooseFilename):
"""Sepcific dialog for quering user for selecting filename for database"""
URI=None
def __init__(self, path=None):
ChooseFilename.__init__(self)
self.dialog.set_title('Save catalog as...')
f = gtk.FileFilter()
f.set_name("Catalog files")
f.add_pattern("*.sqlite")
f.add_pattern("*.sqlite.bz2")
self.dialog.add_filter(f)
f = gtk.FileFilter()
f.set_name("All files")
f.add_pattern("*.*")
self.dialog.add_filter(f)
def run(self):
if self.URI:
self.dialog.set_current_folder_uri(self.URI)
elif self.path and os.path.exists(self.path):
self.path = "file://"+os.path.abspath(self.path)
self.dialog.set_current_folder_uri(self.path)
response = self.dialog.run()
if response == gtk.RESPONSE_OK:
filename = self.dialog.get_filename()
self.__class__.URI = self.dialog.get_current_folder_uri()
self.dialog.destroy()
return filename
else:
self.dialog.destroy()
return None
pass
class LoadDBFile(object):
"""Specific class for displaying openFile dialog. It has veryfication
for file existence."""
URI = None
def __init__(self, path=None):
self.path = path
self.dialog = gtk.FileChooserDialog(
title="Open catalog",
action=gtk.FILE_CHOOSER_ACTION_OPEN,
buttons=(
gtk.STOCK_CANCEL,
gtk.RESPONSE_CANCEL,
gtk.STOCK_OPEN,
gtk.RESPONSE_OK))
self.dialog.set_default_response(gtk.RESPONSE_OK)
f = gtk.FileFilter()
f.set_name("Catalog files")
f.add_pattern("*.sqlite")
f.add_pattern("*.sqlite.bz2")
self.dialog.add_filter(f)
f = gtk.FileFilter()
f.set_name("All files")
f.add_pattern("*.*")
self.dialog.add_filter(f)
def show_dialog(self):
response = self.dialog.run()
filename = None
if response == gtk.RESPONSE_OK:
try:
filename = self.dialog.get_filename()
except:
pass
#self.dialog.destroy()
return 'ok',filename
else:
return 'cancel',None
def run(self):
if self.URI:
self.dialog.set_current_folder_uri(self.URI)
elif self.path and os.path.exists(self.path):
self.path = "file://"+os.path.abspath(self.path)
self.dialog.set_current_folder_uri(self.path)
res,filename = self.show_dialog()
ch = True
while ch:
if res == 'cancel':
self.dialog.destroy()
return None
try:
os.stat(filename)
self.__class__.URI = self.dialog.get_current_folder_uri()
self.dialog.destroy()
return filename
except:
a = Err("Error - pyGTKtalog","File doesn't exist.",
"The file that you choose does not exist." + \
" Choose another one, or cancel operation.")
ch = True
res, filename = self.show_dialog()
class LoadImageFile(object):
"""class for displaying openFile dialog. It have possibility of multiple
selection."""
URI="file://"+os.path.abspath(os.path.curdir)
def __init__(self, multiple=False):
self.dialog = gtk.FileChooserDialog(
title="Select image",
action=gtk.FILE_CHOOSER_ACTION_OPEN,
buttons=(
gtk.STOCK_CANCEL,
gtk.RESPONSE_CANCEL,
gtk.STOCK_OPEN,
gtk.RESPONSE_OK))
self.dialog.set_select_multiple(multiple)
self.dialog.set_default_response(gtk.RESPONSE_OK)
f = gtk.FileFilter()
f.set_name("All Images")
for i in ['*.jpg', '*.jpeg', '*.gif', '*.png', '*.tif', '*.tiff',
'*.tga', '*.pcx', '*.bmp', '*.xbm', '*.xpm', '*.jp2',
'*.jpx', '*.pnm', '*.JPG', '*.JPEG', '*.GIF', '*.PNG',
'*.TIF', '*.TIFF', '*.TGA', '*.PCX', '*.BMP', '*.XBM',
'*.XPM', '*.JP2', '*.JPX', '*.PNM']:
f.add_pattern(i)
self.dialog.add_filter(f)
f = gtk.FileFilter()
f.set_name("All files")
f.add_pattern("*.*")
self.dialog.add_filter(f)
self.preview = gtk.Image()
self.dialog.set_preview_widget(self.preview)
self.dialog.connect("update-preview", self.update_preview_cb)
def run(self):
if self.URI:
self.dialog.set_current_folder_uri(self.URI)
response = self.dialog.run()
filenames = None
only_thumbs = False
if response == gtk.RESPONSE_OK:
try:
if self.dialog.get_select_multiple():
filenames = self.dialog.get_filenames()
else:
filenames = self.dialog.get_filename()
if self.dialog.get_extra_widget().get_active():
only_thumbs = True
except:
pass
self.__class__.URI = self.dialog.get_current_folder_uri()
self.dialog.destroy()
return filenames, only_thumbs
def update_preview_cb(self, widget):
filename = self.dialog.get_preview_filename()
try:
pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(filename, 128, 128)
self.preview.set_from_pixbuf(pixbuf)
have_preview = True
except:
have_preview = False
self.dialog.set_preview_widget_active(have_preview)
return
class StatsDialog(object):
"""Sepcific dialog for display stats"""
def __init__(self, values={}):
self.gladefile = os.path.join(lib.globs.GLADE_DIR, "dialogs.glade")
self.values = values
def run(self):
gladexml = gtk.glade.XML(self.gladefile, "statDialog")
dialog = gladexml.get_widget("statDialog")
if 'discs' in self.values:
entry = gladexml.get_widget("discs_entry")
entry.set_text(str(self.values['discs']))
else:
label = gladexml.get_widget("discs_label")
entry = gladexml.get_widget("discs_entry")
label.hide()
entry.hide()
if 'dirs' in self.values:
entry = gladexml.get_widget("dirs_entry")
entry.set_text(str(self.values['dirs']))
else:
label = gladexml.get_widget("dirs_label")
entry = gladexml.get_widget("dirs_entry")
label.hide()
entry.hide()
if 'files' in self.values:
entry = gladexml.get_widget("files_entry")
entry.set_text(str(self.values['files']))
if 'size' in self.values:
entry = gladexml.get_widget("size_entry")
entry.set_text(str(self.values['size']))
result = dialog.run()
dialog.destroy()
if result == gtk.RESPONSE_OK:
return entry.get_text()
return None
class TagsDialog(object):
"""Sepcific dialog for display stats"""
def __init__(self):
self.gladefile = os.path.join(lib.globs.GLADE_DIR, "dialogs.glade")
def run(self):
gladexml = gtk.glade.XML(self.gladefile, "tagsDialog")
dialog = gladexml.get_widget("tagsDialog")
entry = gladexml.get_widget("tag_entry1")
result = dialog.run()
dialog.destroy()
if result == gtk.RESPONSE_OK:
return entry.get_text()
return None
class TagsRemoveDialog(object):
"""Sepcific dialog for display stats"""
def __init__(self, tag_dict=None):
self.gladefile = os.path.join(lib.globs.GLADE_DIR, "dialogs.glade")
self.tag_dict = tag_dict
def run(self):
if not self.tag_dict:
return None
gladexml = gtk.glade.XML(self.gladefile, "tagRemove")
dialog = gladexml.get_widget("tagRemove")
# declare model
model = gtk.ListStore(gobject.TYPE_INT,
gobject.TYPE_STRING, gobject.TYPE_BOOLEAN)
# sort dict
values = self.tag_dict.values()
values.sort()
keys = []
for val in values:
for d_key, d_value in self.tag_dict.items():
if d_value == val:
keys.append(d_key)
# fill model with dict
for count in range(len(keys)):
myiter = model.insert_before(None, None)
model.set_value(myiter, 0, keys[count])
model.set_value(myiter, 1, values[count])
model.set_value(myiter, 2, None)
def toggle(cell, path, model):
model[path][2] = not model[path][2]
def toggle_all(column, model):
for row in model:
row[2] = not row[2]
treeview = gladexml.get_widget("treeview1")
treeview.set_model(model)
renderer = gtk.CellRendererText()
column = gtk.TreeViewColumn("Tag", renderer, text=1)
column.set_property('expand', True)
treeview.append_column(column)
renderer = gtk.CellRendererToggle()
renderer.set_property('activatable', True)
renderer.connect('toggled', toggle, model)
column = gtk.TreeViewColumn("Toggle", renderer)
column.add_attribute(renderer, "active", 2)
column.set_property('expand', False)
column.set_property("clickable", True)
column.connect("clicked", toggle_all, model)
treeview.append_column(column)
result = dialog.run()
dialog.destroy()
if result == gtk.RESPONSE_OK:
ids = []
for i in model:
if i[2]:
ids.append(i[0])
return "ok", ids
return None, None
class EditDialog(object):
"""Sepcific dialog for display stats"""
def __init__(self, values={}):
self.gladefile = os.path.join(lib.globs.GLADE_DIR, "dialogs.glade")
self.values = values
def run(self):
gladexml = gtk.glade.XML(self.gladefile, "file_editDialog")
dialog = gladexml.get_widget("file_editDialog")
filename = gladexml.get_widget("filename_entry")
filename.set_text(str(self.values['filename']))
description = gladexml.get_widget("description_text")
note = gladexml.get_widget("note_text")
if 'description' in self.values:
buff = gtk.TextBuffer()
buff.set_text(str(self.values['description']))
description.set_buffer(buff)
if 'note' in self.values:
buff = gtk.TextBuffer()
buff.set_text(str(self.values['note']))
note.set_buffer(buff)
result = dialog.run()
if result == gtk.RESPONSE_OK:
d = description.get_buffer()
n = note.get_buffer()
retval = {'filename': filename.get_text(),
'description': d.get_text(d.get_start_iter(),
d.get_end_iter()),
'note': n.get_text(n.get_start_iter(), n.get_end_iter())}
dialog.destroy()
return retval
dialog.destroy()
return None

68
src/views/v_image.py Normal file
View File

@@ -0,0 +1,68 @@
# This Python file uses the following encoding: utf-8
#
# Author: Roman 'gryf' Dobosz gryf@elysium.pl
#
# Copyright (C) 2007 by Roman 'gryf' Dobosz
#
# This file is part of pyGTKtalog.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# -------------------------------------------------------------------------
import gtk
class ImageView(object):
"""simple image viewer. no scaling, no zooming, no rotating.
simply show stupid image"""
def __init__(self, image_filename):
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
image = gtk.Image()
image.set_from_file(image_filename)
pixbuf = image.get_pixbuf()
pic_width = pixbuf.get_width() + 23
pic_height = pixbuf.get_height() + 23
screen_width = gtk.gdk.screen_width()
screen_height = gtk.gdk.screen_height()
need_vieport = False
if pic_height > (screen_height - 128):
height = screen_height - 128
need_vieport = True
else:
height = screen_height - 128
if pic_width > (screen_width - 128):
width = screen_width - 128
need_vieport = True
else:
width = pic_width
if need_vieport:
window.resize(width, height)
viewport = gtk.ScrolledWindow()
viewport.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
viewport.add_with_viewport(image)
window.add(viewport)
else:
window.add(image)
window.show_all()
return
pass # end of class

44
src/views/v_main.py Normal file
View File

@@ -0,0 +1,44 @@
# This Python file uses the following encoding: utf-8
#
# Author: Roman 'gryf' Dobosz gryf@elysium.pl
#
# Copyright (C) 2007 by Roman 'gryf' Dobosz
#
# This file is part of pyGTKtalog.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# -------------------------------------------------------------------------
import os.path
import lib.globs
from gtkmvc import View
class MainView(View):
"""This handles only the graphical representation of the
application. The widgets set is loaded from glade file"""
GLADE = os.path.join(lib.globs.GLADE_DIR, "main.glade")
def __init__(self, ctrl):
View.__init__(self, ctrl, self.GLADE)
# hide v2.0 features
self['separatormenuitem4'].hide()
self['list1'].hide()
self['thumbnails1'].hide()
return
pass # end of class

38
src/views/v_search.py Normal file
View File

@@ -0,0 +1,38 @@
# This Python file uses the following encoding: utf-8
#
# Author: Roman 'gryf' Dobosz gryf@elysium.pl
#
# Copyright (C) 2007 by Roman 'gryf' Dobosz
#
# This file is part of pyGTKtalog.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# -------------------------------------------------------------------------
from gtkmvc import View
import os.path
import lib.globs
class SearchView(View):
"""Search window from glade file """
GLADE = os.path.join(lib.globs.GLADE_DIR, "search.glade")
def __init__(self, ctrl):
View.__init__(self, ctrl, self.GLADE)
return
pass # end of class

0
test/unit/__init__.py Normal file
View File

View File

@@ -0,0 +1,28 @@
"""
Project: pyGTKtalog
Description: Tests for DataBase class.
Type: test
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2009-07-19
"""
import unittest
import os
from pygtktalog.dbcommon import connect, Meta, Session, Base
class TestDataBase(unittest.TestCase):
"""
Class responsible for database connection and schema creation
"""
def test_connect(self):
"""
Test connection to database. Memory and file method will be tested.
"""
connect(":memory:")
if __name__ == "__main__":
os.chdir(os.path.join(os.path.abspath(os.path.dirname(__file__)), "../"))
unittest.main()

77
test/unit/dialogs_test.py Normal file
View File

@@ -0,0 +1,77 @@
"""
Project: pyGTKtalog
Description: Test simple dialogs
Type: test
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2009-05-19
"""
import unittest
import os
import gtk
from pygtktalog.dialogs import Dialog, yesno, okcancel, info, warn, error
class MessageDialogMock(gtk.MessageDialog):
"""Mock class for MessageDialog, which shouldn't be displayed in a test"""
def run(self):
"""Carefull! only for MESSAGE_INFO return value is RESPONSE_OK!"""
if self.get_property('message-type') == gtk.MESSAGE_INFO:
return gtk.RESPONSE_OK
else:
return gtk.RESPONSE_CANCEL
class TestDialog(unittest.TestCase):
"""Tests for Dialog class"""
def test_dialog_create(self):
"""Test dialog creation and run method"""
# overwrite MessageDialog class in gtk module
gtk.MessageDialog = MessageDialogMock
dialog = Dialog(gtk.MESSAGE_INFO, 'msg', 'secondarymsg', 'title')
self.assertTrue(dialog.buttons == gtk.BUTTONS_OK, "dialog should have"
" gtk.BUTTONS_OK")
self.assertTrue(dialog.run(), "dialog should return True")
dialog = Dialog(gtk.MESSAGE_QUESTION, 'msg', 'secondarymsg', 'title')
self.assertFalse(dialog.run(), "dialog should return False")
# NOTE: dialog should be run before test against buttons attribute
self.assertTrue(dialog.buttons == gtk.BUTTONS_YES_NO,
"dialog should have gtk.BUTTONS_YES_NO")
dialog = Dialog(gtk.MESSAGE_QUESTION, 'msg', 'secondarymsg', 'title')
dialog.buttons = gtk.BUTTONS_OK
dialog.ok_default = True
self.assertFalse(dialog.run(), "dialog should return True")
def test_error(self):
"""Test error function"""
result = error('msg', 'secondarymsg', 'title')
self.assertTrue(result, "Should return True")
def test_warn(self):
"""Test warn function"""
result = warn('msg', 'secondarymsg', 'title')
self.assertTrue(result, "Should return True")
def test_info(self):
"""Test info function"""
result = info('msg', 'secondarymsg', 'title')
self.assertTrue(result, "Should return True")
def test_yesno(self):
"""Test yesno function"""
result = yesno('msg', 'secondarymsg', 'title')
self.assertFalse(result, "Should return False")
def test_okcancel(self):
"""Test yesno function"""
result = okcancel('msg', 'secondarymsg', 'title')
self.assertFalse(result, "Should return False")
if __name__ == "__main__":
os.chdir(os.path.join(os.path.abspath(os.path.dirname(__file__)), "../"))
unittest.main()

View File

@@ -0,0 +1,8 @@
"""
Project: pyGTKtalog
Description: Tests for main view class.
Type: test
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2010-03-14
"""

Some files were not shown because too many files have changed in this diff Show More