~ubuntu-branches/ubuntu/vivid/mago/vivid

« back to all changes in this revision

Viewing changes to mago/application/shotwell.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2011-02-08 13:32:13 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110208133213-m1og7ey0m990chg6
Tags: 0.3+bzr20-0ubuntu1
* debian/rules:
  - updated to debhelper 7
  - use dh_python2 instead of python-central
* debian/pycompat:
  - removed, no longer needed
* debian/control:
  - dropped cdbs and python-central dependencies
* bzr snapshot of the current trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
PACKAGE = "mago"
2
 
 
3
 
# -*- coding : utf-8 -*-
4
 
 
5
 
"""
6
 
This is the "shotwell" module.
7
 
 
8
 
This module provides a wrapper for LDTP to make writing Shotwell tests easier.
9
 
"""
10
 
import ooldtp
11
 
import ldtp
12
 
import os
13
 
from .main import Application
14
 
from ..gconfwrapper import GConf
15
 
from ..cmd import globals
16
 
import time
17
 
import gettext
18
 
import re
19
 
 
20
 
gettext.install (True)
21
 
gettext.bindtextdomain (PACKAGE, globals.LOCALE_SHARE)
22
 
gettext.textdomain (PACKAGE)
23
 
t = gettext.translation(PACKAGE, globals.LOCALE_SHARE, fallback = True)
24
 
_ = t.gettext
25
 
 
26
 
 
27
 
class Shotwell(Application):
28
 
    """
29
 
    Shotwell manages the Shotwell application.
30
 
    """
31
 
    WINDOW     = _("frmShotwell")
32
 
    LAUNCHER   = "shotwell"
33
 
    MNU_IMPORT_FROM_FOLDER = _("mnuImportFromFolder...")
34
 
    DLG_IMPORT = _("dlgImportFromFolder")
35
 
    TXT_LOCATION = _("txtLocation")
36
 
    BTN_CLOSE = _("btnClose")
37
 
    BTN_OK = _("btnOK")
38
 
    MNU_QUIT = _("mnuQuit")
39
 
    DLG_QUESTION = _("dlgQuestion")
40
 
    BTN_COPY = _("btnCopyintoLibrary")
41
 
    BTN_LINK = _("btnCreateLinks")
42
 
    DLG_INFORMATION = _("dlgInformation")
43
 
    DLG_WARNING = _("dlgWarning")
44
 
    LBL_SUCCESSFUL = _("*photosuccessfullyimported")
45
 
    MNU_SELECTALL = _("mnuSelectAll")
46
 
    MNU_DELETE = _("mnuMovetoTrash")
47
 
    MNU_EMPTYTRASH = _("mnuEmptyTrash")
48
 
    BTN_ONLYREMOVE = _("btnOnlyRemove")
49
 
    TGL_TYPEFILENAME = _("tbtnTypeafilename")
50
 
    
51
 
    def __init__(self):
52
 
        Application.__init__(self)
53
 
 
54
 
 
55
 
    def import_from_folder(self, path, copy=True):
56
 
        """
57
 
        It imports a folder
58
 
 
59
 
        @type path: string
60
 
        @param path: The path to the folder to import
61
 
        @type copy: boolean
62
 
        @param copy: True, to copy the images. Falso, to just create links
63
 
        
64
 
        @return int: Number of images successfully imported
65
 
        """
66
 
 
67
 
        shotwell = ooldtp.context(self.name)
68
 
        
69
 
        # Click on the import folder menu item
70
 
        shotwell.getchild(self.MNU_IMPORT_FROM_FOLDER).selectmenuitem()
71
 
 
72
 
        # Wait for the dialog
73
 
        ldtp.waittillguiexist(self.DLG_IMPORT)
74
 
        
75
 
        # Import the folder
76
 
        dlgImport = ooldtp.context(self.DLG_IMPORT)
77
 
        
78
 
        tglFileName = dlgImport.getchild(self.TGL_TYPEFILENAME)
79
 
        
80
 
        if tglFileName.verifytoggled() == 0:
81
 
            tglFileName.click()
82
 
            dlgImport.remap()
83
 
            
84
 
        txtLocation = dlgImport.getchild(self.TXT_LOCATION)
85
 
        txtLocation.settextvalue(path)
86
 
        
87
 
        # Workaround due to bug in shotwell
88
 
        ldtp.wait(2)
89
 
        ldtp.enterstring("<backspace>")
90
 
        
91
 
        ldtp.wait(2)
92
 
        # Close the dialog
93
 
        dlgImport.getchild(self.BTN_OK).click()
94
 
        
95
 
        ldtp.waittillguiexist(self.DLG_QUESTION)
96
 
        
97
 
        # Copy the images or create links
98
 
        question = ooldtp.context(self.DLG_QUESTION)
99
 
        
100
 
        if copy:
101
 
            question.getchild(self.BTN_COPY).click()
102
 
        else:
103
 
            question.getchild(self.BTN_LINK).click()
104
 
            
105
 
        ldtp.waittillguiexist(self.DLG_INFORMATION)
106
 
        
107
 
        dlgInfo = ooldtp.context(self.DLG_INFORMATION)
108
 
        
109
 
        lblSuccess = dlgInfo.getchild(self.LBL_SUCCESSFUL)
110
 
        lblSuccess = lblSuccess.gettextvalue()
111
 
 
112
 
        btn_ok = dlgInfo.getchild(self.BTN_OK)
113
 
        btn_ok.click()
114
 
                
115
 
        # Find how many photos were successfully imported
116
 
        pattern = re.compile("(\d+)")
117
 
        
118
 
        if (re.match(pattern, lblSuccess)):
119
 
            return re.match(pattern, lblSuccess).groups()[0]
120
 
        else:
121
 
            return 0
122