bzr branch
http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
734.1.4
by Curtis Hovey
Updated commit to gtk3. |
1 |
from gi.repository import GObject |
734.1.1
by Curtis Hovey
Mechanical changes made by pygi.convert.sh. |
2 |
from gi.repository import Gtk |
452.5.2
by Daniel Schierbeck
Added generalized locking functionality in lock.py. |
3 |
|
4 |
||
5 |
RESPONSE_BREAK = 0 |
|
734.1.1
by Curtis Hovey
Mechanical changes made by pygi.convert.sh. |
6 |
RESPONSE_CANCEL = Gtk.ResponseType.CANCEL |
452.5.2
by Daniel Schierbeck
Added generalized locking functionality in lock.py. |
7 |
|
712
by Jelmer Vernooij
Add lock dialog. (Daniel Schierbeck) |
8 |
READ = "read" |
9 |
WRITE = "write" |
|
452.5.2
by Daniel Schierbeck
Added generalized locking functionality in lock.py. |
10 |
|
11 |
||
12 |
def acquire(branch, lock_type): |
|
13 |
if branch.get_physical_lock_status(): |
|
14 |
dialog = LockDialog(branch) |
|
15 |
response = dialog.run() |
|
16 |
dialog.destroy() |
|
17 |
||
18 |
if response == RESPONSE_BREAK: |
|
19 |
branch.break_lock() |
|
20 |
else: |
|
21 |
return False |
|
22 |
||
23 |
if lock_type == READ: |
|
24 |
branch.lock_read() |
|
25 |
elif lock_type == WRITE: |
|
26 |
branch.lock_write() |
|
27 |
||
28 |
return True |
|
29 |
||
30 |
||
31 |
def release(branch): |
|
32 |
if branch.get_physical_lock_status(): |
|
33 |
dialog = LockDialog(branch) |
|
34 |
response = dialog.run() |
|
35 |
dialog.destroy() |
|
36 |
||
37 |
if response == RESPONSE_BREAK: |
|
38 |
branch.break_lock() |
|
39 |
elif response == RESPONSE_CANCEL: |
|
40 |
return False |
|
41 |
||
42 |
branch.unlock() |
|
43 |
||
44 |
return True |
|
45 |
||
46 |
||
734.1.1
by Curtis Hovey
Mechanical changes made by pygi.convert.sh. |
47 |
class LockDialog(Gtk.Dialog): |
452.5.2
by Daniel Schierbeck
Added generalized locking functionality in lock.py. |
48 |
|
49 |
def __init__(self, branch): |
|
734.1.1
by Curtis Hovey
Mechanical changes made by pygi.convert.sh. |
50 |
GObject.GObject.__init__(self) |
452.5.2
by Daniel Schierbeck
Added generalized locking functionality in lock.py. |
51 |
|
52 |
self.branch = branch |
|
53 |
||
54 |
self.set_title('Lock Not Held') |
|
55 |
||
734.1.1
by Curtis Hovey
Mechanical changes made by pygi.convert.sh. |
56 |
self.vbox.add(Gtk.Label(label='This operation cannot be completed as ' \ |
452.5.2
by Daniel Schierbeck
Added generalized locking functionality in lock.py. |
57 |
'another application has locked the branch.')) |
58 |
||
59 |
self.add_button('Break Lock', RESPONSE_BREAK) |
|
734.1.1
by Curtis Hovey
Mechanical changes made by pygi.convert.sh. |
60 |
self.add_button(Gtk.STOCK_CANCEL, RESPONSE_CANCEL) |
452.5.2
by Daniel Schierbeck
Added generalized locking functionality in lock.py. |
61 |
|
62 |
self.vbox.show_all() |