~ubuntu-branches/ubuntu/oneiric/emesene/oneiric-proposed

« back to all changes in this revision

Viewing changes to emesene/gui/base/PictureHandler.py

  • Committer: Bazaar Package Importer
  • Author(s): Devid Antonio Filoni
  • Date: 2011-03-03 14:49:13 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20110303144913-0adl9cmw2s35lvzo
Tags: 2.0~git20110303-0ubuntu1
* New upstream git revision (LP: #728469).
* Remove debian/watch, debian/emesene.xpm, debian/install and
  debian/README.source files.
* Remove 21_svn2451_fix_avatar and 20_dont_build_own_libmimic patches.
* debian/control: modify python to python (>= 2.5) in Build-Depends field.
* debian/control: remove python-libmimic from Recommends field.
* debian/control: modify python-gtk2 (>= 2.10) to python-gtk2 (>= 2.12) in
  Depends field.
* debian/control: add python-appindicator and python-xmpp to Recommends
  field.
* debian/control: add python-papyon (>= 0.5.4) and python-webkit to Depends
  field.
* debian/control: update Description field.
* debian/control: add python-setuptools to Build-Depends field.
* debian/control: move python-dbus and python-notify to Depends field.
* Update debian/copyright file.
* Update debian/links file.
* debian/menu: update description field.
* Bump Standards-Version to 3.9.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
'''This module contains the abstract class "PictureHandler", intended to save 
 
2
and resize images.'''
 
3
# -*- coding: utf-8 -*-
 
4
 
 
5
#    This file is part of emesene.
 
6
#
 
7
#    emesene is free software; you can redistribute it and/or modify
 
8
#    it under the terms of the GNU General Public License as published by
 
9
#    the Free Software Foundation; either version 3 of the License, or
 
10
#    (at your option) any later version.
 
11
#
 
12
#    emesene is distributed in the hope that it will be useful,
 
13
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
#    GNU General Public License for more details.
 
16
#
 
17
#    You should have received a copy of the GNU General Public License
 
18
#    along with emesene; if not, write to the Free Software
 
19
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
20
 
 
21
import shutil
 
22
 
 
23
 
 
24
class PictureHandler (object): 
 
25
    '''PictureHandler is an object that provides means to scale pictures and
 
26
    save them to disk. It must be subclassed overriding abstract methods with
 
27
    the actual save / scale routines.'''
 
28
    
 
29
    # This could be useful for issue #93:
 
30
    # We could check here for imagemagick or whatever
 
31
    
 
32
    def __init__(self, source_filename=None):
 
33
        '''Constructor'''
 
34
        self._source_filename = source_filename
 
35
    
 
36
    
 
37
    def resize(self, new_size):
 
38
        '''Resizes to new_size the given avatar pix'''
 
39
        if self.can_handle():
 
40
            self._resize(new_size)
 
41
    
 
42
    
 
43
    def _resize(self, new_size):
 
44
        '''This method actually resizes to new_size the given avatar pix'''
 
45
        raise NotImplementedError("Method not implemented")
 
46
        
 
47
        
 
48
    def save(self, dest_filename):
 
49
        '''Saves to disk the given avatar pix'''
 
50
        if not self.can_handle():
 
51
            shutil.copy(self._source_filename, dest_filename)
 
52
        else:
 
53
            self._save(dest_filename)
 
54
            
 
55
        
 
56
    def _save(self, dest_filename):
 
57
        '''This method actually saves the pixmap to disk'''
 
58
        raise NotImplementedError("Method not implemented")
 
59
    
 
60
        
 
61
    def can_handle(self):
 
62
        '''Return true if this object is operating on an animated image'''
 
63
        raise NotImplementedError("Method not implemented")
 
64
    
 
65
    
 
66
    @staticmethod
 
67
    def from_toolkit(pix):
 
68
        '''Builds a PictureHandler object from a pix object, whose type
 
69
        depends on the particular gui toolkit used.'''
 
70
        raise NotImplementedError("Method not implemented")
 
71
    
 
72