3
# -*- coding : utf-8 -*-
6
This is the "shotwell" module.
8
This module provides a wrapper for LDTP to make writing Shotwell tests easier.
13
from .main import Application
14
from ..gconfwrapper import GConf
15
from ..cmd import globals
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)
27
class Shotwell(Application):
29
Shotwell manages the Shotwell application.
31
WINDOW = _("frmShotwell")
33
MNU_IMPORT_FROM_FOLDER = _("mnuImportFromFolder...")
34
DLG_IMPORT = _("dlgImportFromFolder")
35
TXT_LOCATION = _("txtLocation")
36
BTN_CLOSE = _("btnClose")
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")
52
Application.__init__(self)
55
def import_from_folder(self, path, copy=True):
60
@param path: The path to the folder to import
62
@param copy: True, to copy the images. Falso, to just create links
64
@return int: Number of images successfully imported
67
shotwell = ooldtp.context(self.name)
69
# Click on the import folder menu item
70
shotwell.getchild(self.MNU_IMPORT_FROM_FOLDER).selectmenuitem()
73
ldtp.waittillguiexist(self.DLG_IMPORT)
76
dlgImport = ooldtp.context(self.DLG_IMPORT)
78
tglFileName = dlgImport.getchild(self.TGL_TYPEFILENAME)
80
if tglFileName.verifytoggled() == 0:
84
txtLocation = dlgImport.getchild(self.TXT_LOCATION)
85
txtLocation.settextvalue(path)
87
# Workaround due to bug in shotwell
89
ldtp.enterstring("<backspace>")
93
dlgImport.getchild(self.BTN_OK).click()
95
ldtp.waittillguiexist(self.DLG_QUESTION)
97
# Copy the images or create links
98
question = ooldtp.context(self.DLG_QUESTION)
101
question.getchild(self.BTN_COPY).click()
103
question.getchild(self.BTN_LINK).click()
105
ldtp.waittillguiexist(self.DLG_INFORMATION)
107
dlgInfo = ooldtp.context(self.DLG_INFORMATION)
109
lblSuccess = dlgInfo.getchild(self.LBL_SUCCESSFUL)
110
lblSuccess = lblSuccess.gettextvalue()
112
btn_ok = dlgInfo.getchild(self.BTN_OK)
115
# Find how many photos were successfully imported
116
pattern = re.compile("(\d+)")
118
if (re.match(pattern, lblSuccess)):
119
return re.match(pattern, lblSuccess).groups()[0]