~openerp-dev/openerp-outlook-plugin/openerp-outlook-plugin

« back to all changes in this revision

Viewing changes to dialogs/__init__.py

  • Committer: pap(openerp)
  • Date: 2010-04-23 10:01:35 UTC
  • Revision ID: pap@tinyerp.co.in-20100423100135-sweujs3a0wz0hn60
[IMP]:added alert if mail contains attachments

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# This package defines dialog boxes used by the main
2
 
# SpamBayes Outlook 2k integration code.
3
 
import os, sys, stat
4
 
 
5
 
def LoadDialogs(rc_name = "dialogs.rc"):
6
 
    base_name = os.path.splitext(rc_name)[0]
7
 
    mod_name = "dialogs.resources." + base_name
8
 
    mod = None
9
 
    # If we are running from source code, check the .py file is up to date
10
 
    # wrt the .rc file passed in.
11
 
    # If we are running from binaries, the rc name is not used at all - we
12
 
    # assume someone running from source previously generated the .py!
13
 
    if not hasattr(sys, "frozen"):
14
 
        from resources import rc2py
15
 
        rc_path = os.path.dirname( rc2py.__file__ )
16
 
        if not os.path.isabs(rc_name):
17
 
            rc_name = os.path.join( rc_path, rc_name)
18
 
        py_name = os.path.join(rc_path, base_name + ".py")
19
 
        mtime = size = None
20
 
        if os.path.exists(py_name):
21
 
            try:
22
 
                mod = __import__(mod_name)
23
 
                mod = sys.modules[mod_name]
24
 
                mtime = mod._rc_mtime_
25
 
                size = mod._rc_size_
26
 
            except (ImportError, AttributeError):
27
 
                mtime = None
28
 
        try:
29
 
            stat_data = os.stat(rc_name)
30
 
            rc_mtime = stat_data[stat.ST_MTIME]
31
 
            rc_size = stat_data[stat.ST_SIZE]
32
 
        except OSError:
33
 
            rc_mtime = rc_size = None
34
 
        if rc_mtime!=mtime or rc_size!=size:
35
 
            # Need to generate the dialog.
36
 
            print "Generating %s from %s" % (py_name, rc_name)
37
 
            rc2py.convert(rc_name, py_name)
38
 
            if mod is not None:
39
 
                reload(mod)
40
 
    if mod is None:
41
 
        mod = __import__(mod_name)
42
 
        mod = sys.modules[mod_name]
43
 
    return mod.FakeParser()
44
 
 
45
 
def ShowDialog(parent, manager, config, idd):
46
 
    """Displays another dialog"""
47
 
    if manager.dialog_parser is None:
48
 
        manager.dialog_parser = LoadDialogs()
49
 
    import dialog_map
50
 
    commands = dialog_map.dialog_map[idd]
51
 
    if not parent:
52
 
        import win32gui
53
 
        try:
54
 
            parent = win32gui.GetActiveWindow()
55
 
        except win32gui.error:
56
 
            pass
57
 
 
58
 
    import dlgcore
59
 
    dlg = dlgcore.ProcessorDialog(parent, manager, config, idd, commands)
60
 
    return dlg.DoModal()
61
 
 
62
 
#def ShowWizard(parent, manager, idd = "IDD_WIZARD", use_existing_config = True):
63
 
#    import config_wizard, win32con
64
 
#    config = config_wizard.CreateWizardConfig(manager, use_existing_config)
65
 
#    if ShowDialog(parent, manager, config, idd) == win32con.IDOK:
66
 
#        print "Saving wizard changes"
67
 
#        config_wizard.CommitWizardConfig(manager, config)
68
 
#    else:
69
 
#        print "Cancelling wizard"
70
 
#        config_wizard.CancelWizardConfig(manager, config)
71
 
 
72
 
def MakePropertyPage(parent, manager, config, idd, yoffset=24):
73
 
    """Creates a child dialog box to use as property page in a tab control"""
74
 
    if manager.dialog_parser is None:
75
 
        manager.dialog_parser = LoadDialogs()
76
 
    import dialog_map
77
 
    commands = dialog_map.dialog_map[idd]
78
 
    if not parent:
79
 
        raise "Parent must be the tab control"
80
 
 
81
 
    import dlgcore
82
 
    dlg = dlgcore.ProcessorPage(parent, manager, config, idd, commands, yoffset)
83
 
    return dlg
84
 
 
85
 
import dlgutils
86
 
SetWaitCursor = dlgutils.SetWaitCursor