/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to tortoise-bzr.py

  • Committer: Vincent Ladeuil
  • Date: 2008-05-05 18:16:46 UTC
  • mto: (487.1.1 gtk)
  • mto: This revision was merged to the branch mainline in revision 490.
  • Revision ID: v.ladeuil+lp@free.fr-20080505181646-n95l8ltw2u6jtr26
Fix bug #187283 fix replacing _() by _i18n().

* genpot.sh 
Remove duplication. Add the ability to specify the genrated pot
file on command-line for debugging purposes.

* po/olive-gtk.pot:
Regenerated.

* __init__.py, branch.py, branchview/treeview.py, checkout.py,
commit.py, conflicts.py, diff.py, errors.py, initialize.py,
merge.py, nautilus-bzr.py, olive/__init__.py, olive/add.py,
olive/bookmark.py, olive/guifiles.py, olive/info.py,
olive/menu.py, olive/mkdir.py, olive/move.py, olive/remove.py,
olive/rename.py, push.py, revbrowser.py, status.py, tags.py:
Replace all calls to _() by calls to _i18n(), the latter being
defined in __init__.py and imported in the other modules from
there. This fix the problem encountered countless times when
running bzr selftest and getting silly error messages about
boolean not being callables.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Simple TortoiseSVN-like Bazaar plugin for the Windows Shell
2
 
# Published under the GNU GPL, v2 or later.
3
 
# Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org>
4
 
 
5
 
import pythoncom
6
 
from win32com.shell import shell, shellcon
7
 
import win32gui
8
 
import win32con
9
 
 
10
 
"""Windows shell extension that adds context menu items to Bazaar branches."""
11
 
class BazaarShellExtension:
12
 
    _reg_progid_ = "Bazaar.ShellExtension.ContextMenu"
13
 
    _reg_desc_ = "Bazaar Shell Extension"
14
 
    _reg_clsid_ = "{EEE9936B-73ED-4D45-80C9-AF918354F885}"
15
 
    _com_interfaces_ = [shell.IID_IShellExtInit, shell.IID_IContextMenu]
16
 
    _public_methods_ = [
17
 
        "Initialize", # From IShellExtInit
18
 
        "QueryContextMenu", "InvokeCommand", "GetCommandString" # IContextMenu
19
 
        ]
20
 
 
21
 
    def Initialize(self, folder, dataobj, hkey):
22
 
        self.dataobj = dataobj
23
 
 
24
 
    def QueryContextMenu(self, hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags):
25
 
        format_etc = win32con.CF_HDROP, None, 1, -1, pythoncom.TYMED_HGLOBAL
26
 
        sm = self.dataobj.GetData(format_etc)
27
 
        num_files = shell.DragQueryFile(sm.data_handle, -1)
28
 
        if num_files>1:
29
 
            msg = "&Hello from Python (with %d files selected)" % num_files
30
 
        else:
31
 
            fname = shell.DragQueryFile(sm.data_handle, 0)
32
 
            msg = "&Hello from Python (with '%s' selected)" % fname
33
 
        idCmd = idCmdFirst
34
 
        items = []
35
 
        if (uFlags & 0x000F) == shellcon.CMF_NORMAL: # Check == here, since CMF_NORMAL=0
36
 
            print "CMF_NORMAL..."
37
 
            items.append(msg)
38
 
        elif uFlags & shellcon.CMF_VERBSONLY:
39
 
            print "CMF_VERBSONLY..."
40
 
            items.append(msg + " - shortcut")
41
 
        elif uFlags & shellcon.CMF_EXPLORE:
42
 
            print "CMF_EXPLORE..."
43
 
            items.append(msg + " - normal file, right-click in Explorer")
44
 
        elif uFlags & CMF_DEFAULTONLY:
45
 
            print "CMF_DEFAULTONLY...\r\n"
46
 
        else:
47
 
            print "** unknown flags", uFlags
48
 
        win32gui.InsertMenu(hMenu, indexMenu,
49
 
                            win32con.MF_SEPARATOR|win32con.MF_BYPOSITION,
50
 
                            0, None)
51
 
        indexMenu += 1
52
 
        for item in items:
53
 
            win32gui.InsertMenu(hMenu, indexMenu,
54
 
                                win32con.MF_STRING|win32con.MF_BYPOSITION,
55
 
                                idCmd, item)
56
 
            indexMenu += 1
57
 
            idCmd += 1
58
 
 
59
 
        win32gui.InsertMenu(hMenu, indexMenu,
60
 
                            win32con.MF_SEPARATOR|win32con.MF_BYPOSITION,
61
 
                            0, None)
62
 
        indexMenu += 1
63
 
        return idCmd-idCmdFirst # Must return number of menu items we added.
64
 
 
65
 
    def InvokeCommand(self, ci):
66
 
        mask, hwnd, verb, params, dir, nShow, hotkey, hicon = ci
67
 
        # FIXME: Run the actual command
68
 
 
69
 
    def GetCommandString(self, cmd, typ):
70
 
        return "Hello from Python!!"
71
 
 
72
 
registryKeys = [
73
 
        "*\\shellex\\ContextMenuHandlers", 
74
 
        "Directory\\Background\\shellex\\ContextMenuHandlers", 
75
 
        "Directory\\shellex\\ContextMenuHandlers", 
76
 
        "Folder\\shellex\\ContextmenuHandlers"
77
 
        ]
78
 
 
79
 
def DllRegisterServer():
80
 
    import _winreg
81
 
    for keyname in registryKeys: 
82
 
            key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, keyname)
83
 
            subkey = _winreg.CreateKey(key, "TortoiseBzr")
84
 
            _winreg.SetValueEx(subkey, None, 0, _winreg.REG_SZ, BazaarShellExtension._reg_clsid_)
85
 
            _winreg.CloseKey(subkey)
86
 
            _winreg.CloseKey(key)
87
 
 
88
 
    print BazaarShellExtension._reg_desc_, "registration complete."
89
 
 
90
 
def DllUnregisterServer():
91
 
    import _winreg
92
 
    try:
93
 
        for keyname in registryKeys:
94
 
            _winreg.DeleteKey(_winreg.HKEY_CLASSES_ROOT,
95
 
                                "%s\\TortoiseBzr" % keyname)
96
 
    except WindowsError, details:
97
 
        import errno
98
 
        if details.errno != errno.ENOENT:
99
 
            raise
100
 
    print BazaarShellExtension._reg_desc_, "unregistration complete."
101
 
 
102
 
if __name__ == '__main__':
103
 
    from win32com.server import register
104
 
    register.UseCommandLine(BazaarShellExtension,
105
 
                   finalize_register = DllRegisterServer,
106
 
                   finalize_unregister = DllUnregisterServer)