~ubuntu-branches/ubuntu/natty/mago/natty

« back to all changes in this revision

Viewing changes to mago/application/main.py

  • Committer: Bazaar Package Importer
  • Author(s): Ara Pulido
  • Date: 2010-10-18 16:08:42 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20101018160842-6euef3m6mqxjlcai
Tags: 0.3-0ubuntu1
* New upstream release:
  + Added i18n support
  + Tests working on Maverick 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
PACKAGE = "mago"
 
2
 
1
3
"""
2
4
main module contains the definition of the main Application class
3
5
that is used to wrap applications functionality
4
6
"""
5
7
import ldtp, ooldtp
6
8
import os
 
9
from ..cmd import globals
 
10
import gettext
 
11
 
 
12
gettext.install (True)
 
13
gettext.bindtextdomain (PACKAGE, globals.LOCALE_SHARE)
 
14
gettext.textdomain (PACKAGE)
 
15
t = gettext.translation(PACKAGE, globals.LOCALE_SHARE, fallback = True)
 
16
_ = t.gettext
7
17
 
8
18
class Application:
9
19
    """
18
28
    CLOSE_NAME: Close object name
19
29
    """
20
30
    CLOSE_TYPE = 'menu'
21
 
    CLOSE_NAME = 'mnuQuit'
 
31
    CLOSE_NAME = _('mnuQuit')
22
32
    LAUNCHER_ARGS = []
23
33
    WINDOW     = ''
24
 
    TOP_PANEL = 'frmTopExpandedEdgePanel'
 
34
    TOP_PANEL = _('frmTopExpandedEdgePanel')
25
35
 
26
36
 
27
37
    def __init__(self, name = None, close_type= None, close_name= None):
108
118
        except ldtp.LdtpExecutionError, msg:
109
119
            raise ldtp.LdtpExecutionError, "Mmm, something went wrong when closing the application: " + str(msg)
110
120
 
111
 
    def save(self, save_menu='mnuSave'):
 
121
    def save(self, save_menu=_('mnuSave')):
112
122
        """
113
123
        Given an application, it tries to save the current document.
114
124
        This method gives very basic functionality. Please, override this method in the subclasses for error checking.
140
150
                raise ldtp.LdtpExecutionError, "We couldn't write text."
141
151
        else:
142
152
            try:
143
 
                app_txt_field = app.getchild(txt_field)
 
153
                app_txt_fields = app.getchild(txt_field, "text")
144
154
            except ldtp.LdtpExecutionError:
145
155
                raise ldtp.LdtpExecutionError, "The " + txt_field + " text field was not found."
146
156
            try:
147
 
                app_txt_field.settextvalue(text)
 
157
                for field in app_txt_fields:
 
158
                    field.settextvalue(text)
148
159
            except ldtp.LdtpExecutionError:
149
160
                raise ldtp.LdtpExecutionError, "We couldn't write text."
150
161