author | TK Soh <teekaysoh@yahoo.com> |
Sat, 05 Jul 2008 04:12:16 +0100 | |
changeset 1174 | 4b30a3efa4b9 |
parent 1153 | e677decc9814 |
permissions | -rw-r--r-- |
710
c0cde6f2994f
hggtk/history: log filter dialog is basically complete
Steve Borho <steve@borho.org>
parents:
693
diff
changeset
|
1 |
#_ |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
2 |
# Configuration dialog for TortoiseHg and Mercurial |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
3 |
# |
1007
21db5ba22a08
hggtk/thgconfig: new ui.merge behavior
Steve Borho <steve@borho.org>
parents:
1005
diff
changeset
|
4 |
# Copyright (C) 2008 Steve Borho <steve@borho.org> |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
5 |
# Copyright (C) 2007 TK Soh <teekaysoh@gmail.com> |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
6 |
# |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
7 |
|
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
8 |
import gtk |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
9 |
import gobject |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
10 |
import os |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
11 |
import pango |
1013
517a26313bcd
hggtk/thgconfig: make new filemerge code hg version safe
Steve Borho <steve@borho.org>
parents:
1007
diff
changeset
|
12 |
from mercurial import hg, ui, cmdutil, util |
1091
e8e11990a43e
hggtk: RepoError is no longer in mercurial.hg as of Mercurial 1.0
TK Soh <teekaysoh@yahoo.com>
parents:
1075
diff
changeset
|
13 |
from mercurial.repo import RepoError |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
14 |
from dialog import error_dialog, question_dialog |
478
1802cca094cd
hggtk: move history functions to shlib
Steve Borho <steve@borho.org>
parents:
468
diff
changeset
|
15 |
import shlib |
463
bd4e1edb03da
hggtk/thgconfig: add write back and history
Steve Borho <steve@borho.org>
parents:
462
diff
changeset
|
16 |
import shelve |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
17 |
import iniparse |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
18 |
|
463
bd4e1edb03da
hggtk/thgconfig: add write back and history
Steve Borho <steve@borho.org>
parents:
462
diff
changeset
|
19 |
_unspecstr = '<unspecified>' |
bd4e1edb03da
hggtk/thgconfig: add write back and history
Steve Borho <steve@borho.org>
parents:
462
diff
changeset
|
20 |
|
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
21 |
class ConfigDialog(gtk.Dialog): |
515
0d20d0631472
hggtk/sync: make adding new paths more efficient
Steve Borho <steve@borho.org>
parents:
514
diff
changeset
|
22 |
def __init__(self, root='', |
0d20d0631472
hggtk/sync: make adding new paths more efficient
Steve Borho <steve@borho.org>
parents:
514
diff
changeset
|
23 |
configrepo=False, |
0d20d0631472
hggtk/sync: make adding new paths more efficient
Steve Borho <steve@borho.org>
parents:
514
diff
changeset
|
24 |
focusfield=None, |
0d20d0631472
hggtk/sync: make adding new paths more efficient
Steve Borho <steve@borho.org>
parents:
514
diff
changeset
|
25 |
newpath=None): |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
26 |
""" Initialize the Dialog. """ |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
27 |
gtk.Dialog.__init__(self, parent=None, flags=0, |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
28 |
buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)) |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
29 |
|
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
30 |
self.ui = ui.ui() |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
31 |
try: |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
32 |
repo = hg.repository(self.ui, path=root) |
1091
e8e11990a43e
hggtk: RepoError is no longer in mercurial.hg as of Mercurial 1.0
TK Soh <teekaysoh@yahoo.com>
parents:
1075
diff
changeset
|
33 |
except RepoError: |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
34 |
repo = None |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
35 |
if configrepo: |
1120
08eca2607f01
hggtk/dialog: set transient parent for all message dialogs
TK Soh <teekaysoh@yahoo.com>
parents:
1115
diff
changeset
|
36 |
error_dialog(self, 'No repository found', 'no repo at ' + root) |
479
8b2e93d9fa0e
hggtk/thgconfig: safe method to close dialog in __init__
Steve Borho <steve@borho.org>
parents:
478
diff
changeset
|
37 |
self.response(gtk.RESPONSE_CANCEL) |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
38 |
|
505
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
39 |
# Catch close events |
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
40 |
self.connect('delete-event', self._delete) |
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
41 |
self.connect('response', self._response) |
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
42 |
|
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
43 |
if configrepo: |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
44 |
self.ui = repo.ui |
513
d2fe94cd1f7b
hggtk: use configured repository name in window titles
Steve Borho <steve@borho.org>
parents:
511
diff
changeset
|
45 |
name = repo.ui.config('web', 'name') or os.path.basename(repo.root) |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
46 |
self.rcpath = [os.sep.join([repo.root, '.hg', 'hgrc'])] |
513
d2fe94cd1f7b
hggtk: use configured repository name in window titles
Steve Borho <steve@borho.org>
parents:
511
diff
changeset
|
47 |
self.set_title('TortoiseHg Configure Repository - ' + name) |
1115
5aa431c9b9c4
hggtk/thgconfig: pass repository root to incoming command
Steve Borho <steve@borho.org>
parents:
1106
diff
changeset
|
48 |
self.root = repo.root |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
49 |
else: |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
50 |
self.rcpath = util.user_rcpath() |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
51 |
self.set_title('TortoiseHg Configure User-Global Settings') |
1115
5aa431c9b9c4
hggtk/thgconfig: pass repository root to incoming command
Steve Borho <steve@borho.org>
parents:
1106
diff
changeset
|
52 |
self.root = None |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
53 |
|
510
4028d7330575
nautilus: use menusettings.ico for thgconfig
Steve Borho <steve@borho.org>
parents:
505
diff
changeset
|
54 |
shlib.set_tortoise_icon(self, 'menusettings.ico') |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
55 |
self.ini = self.load_config(self.rcpath) |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
56 |
|
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
57 |
# Create a new notebook, place the position of the tabs |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
58 |
self.notebook = notebook = gtk.Notebook() |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
59 |
notebook.set_tab_pos(gtk.POS_TOP) |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
60 |
self.vbox.pack_start(notebook) |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
61 |
notebook.show() |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
62 |
self.show_tabs = True |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
63 |
self.show_border = True |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
64 |
|
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
65 |
self._btn_apply = gtk.Button("Apply") |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
66 |
self._btn_apply.connect('clicked', self._apply_clicked) |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
67 |
self.action_area.pack_end(self._btn_apply) |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
68 |
|
505
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
69 |
self.dirty = False |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
70 |
self.pages = [] |
502
390b62dba0fb
hggtk/thgconfig: make tooltip object class global
Steve Borho <steve@borho.org>
parents:
501
diff
changeset
|
71 |
self.tooltips = gtk.Tooltips() |
1054
be9114b959cc
hggtk: use new Settings class in clone and config dialogs
TK Soh <teekaysoh@yahoo.com>
parents:
1035
diff
changeset
|
72 |
self.history = shlib.Settings('config_history') |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
73 |
|
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
74 |
# create pages for each section of configuration file |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
75 |
self._tortoise_info = ( |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
76 |
('Commit Tool', 'tortoisehg.commit', ['qct', 'internal'], |
515
0d20d0631472
hggtk/sync: make adding new paths more efficient
Steve Borho <steve@borho.org>
parents:
514
diff
changeset
|
77 |
'Select commit tool launched by TortoiseHg. Qct is' |
0d20d0631472
hggtk/sync: make adding new paths more efficient
Steve Borho <steve@borho.org>
parents:
514
diff
changeset
|
78 |
' not included, must be installed separately'), |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
79 |
('Visual Diff Tool', 'tortoisehg.vdiff', [], |
693
2d0374103f0b
hggtk/thgconfig: add graphlimit to tortoisehg tab
Steve Borho <steve@borho.org>
parents:
584
diff
changeset
|
80 |
'Specify the visual diff tool; must be extdiff command'), |
754
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
741
diff
changeset
|
81 |
('Visual Editor', 'tortoisehg.editor', [], |
1ff419edc547
hggtk/gdialog: refactor file edit and diff view
Steve Borho <steve@borho.org>
parents:
741
diff
changeset
|
82 |
'Specify the visual editor used to view files, etc'), |
941
0fd0fcc15287
hggtk/vis: add generic author coloring feature
Steve Borho <steve@borho.org>
parents:
835
diff
changeset
|
83 |
('Author Coloring', 'tortoisehg.authorcolor', ['False', 'True'], |
0fd0fcc15287
hggtk/vis: add generic author coloring feature
Steve Borho <steve@borho.org>
parents:
835
diff
changeset
|
84 |
'Color changesets by author name. If not enabled,' |
0fd0fcc15287
hggtk/vis: add generic author coloring feature
Steve Borho <steve@borho.org>
parents:
835
diff
changeset
|
85 |
' the changes are colored green for merge, red for' |
0fd0fcc15287
hggtk/vis: add generic author coloring feature
Steve Borho <steve@borho.org>
parents:
835
diff
changeset
|
86 |
' non-trivial parents, black for normal. Default: False'), |
0fd0fcc15287
hggtk/vis: add generic author coloring feature
Steve Borho <steve@borho.org>
parents:
835
diff
changeset
|
87 |
('Log Batch Size', 'tortoisehg.graphlimit', ['500'], |
693
2d0374103f0b
hggtk/thgconfig: add graphlimit to tortoisehg tab
Steve Borho <steve@borho.org>
parents:
584
diff
changeset
|
88 |
'The number of revisions to read and display in the' |
1035
81aa30e7e43c
hggtk/thgconfig: add tortoisehg.overlayicons option
TK Soh <teekaysoh@yahoo.com>
parents:
1031
diff
changeset
|
89 |
' changelog viewer in a single batch. Default: 500'), |
1153
e677decc9814
changeset: copy hash to clipboard is now optional, default: False
Steve Borho <steve@borho.org>
parents:
1120
diff
changeset
|
90 |
('Copy Hash', 'tortoisehg.copyhash', ['False', 'True'], |
e677decc9814
changeset: copy hash to clipboard is now optional, default: False
Steve Borho <steve@borho.org>
parents:
1120
diff
changeset
|
91 |
'Allow the changelog viewer to copy hash of currently' |
e677decc9814
changeset: copy hash to clipboard is now optional, default: False
Steve Borho <steve@borho.org>
parents:
1120
diff
changeset
|
92 |
' selected changeset into the clipboard. Default: False'), |
1104
668051bcb725
hggtk/thgconfig: add 'localdisks' to overlayicons option list
TK Soh <teekaysoh@yahoo.com>
parents:
1101
diff
changeset
|
93 |
('Overlay Icons', 'tortoisehg.overlayicons', |
1106
f0e19333bdaf
overlay: use True/False in tortoisehg.overlayicons for consistency
TK Soh <teekaysoh@yahoo.com>
parents:
1105
diff
changeset
|
94 |
['False', 'True', 'localdisks'], |
f0e19333bdaf
overlay: use True/False in tortoisehg.overlayicons for consistency
TK Soh <teekaysoh@yahoo.com>
parents:
1105
diff
changeset
|
95 |
'Display overlay icons in Explorer windows.' |
f0e19333bdaf
overlay: use True/False in tortoisehg.overlayicons for consistency
TK Soh <teekaysoh@yahoo.com>
parents:
1105
diff
changeset
|
96 |
' Default: True')) |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
97 |
self.tortoise_frame = self.add_page(notebook, 'TortoiseHG') |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
98 |
self.fill_frame(self.tortoise_frame, self._tortoise_info) |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
99 |
|
460
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
100 |
self._user_info = ( |
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
101 |
('Username', 'ui.username', [], |
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
102 |
'Name associated with commits'), |
1017
33753d10447f
hggtk/thgconfig: add diff tab, move ui.merge to user tab
Steve Borho <steve@borho.org>
parents:
1013
diff
changeset
|
103 |
('3-way Merge Tool', 'ui.merge', [], |
33753d10447f
hggtk/thgconfig: add diff tab, move ui.merge to user tab
Steve Borho <steve@borho.org>
parents:
1013
diff
changeset
|
104 |
'Graphical merge program for resolving merge conflicts. If left' |
1031
893b9d91abb9
hggtk/thgconfig: improve description of ui.merge
Steve Borho <steve@borho.org>
parents:
1017
diff
changeset
|
105 |
' unspecified, Mercurial will use the first applicable tool it finds' |
893b9d91abb9
hggtk/thgconfig: improve description of ui.merge
Steve Borho <steve@borho.org>
parents:
1017
diff
changeset
|
106 |
' on your system or use its internal merge tool that leaves conflict' |
893b9d91abb9
hggtk/thgconfig: improve description of ui.merge
Steve Borho <steve@borho.org>
parents:
1017
diff
changeset
|
107 |
' markers in place.'), |
460
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
108 |
('Editor', 'ui.editor', [], |
515
0d20d0631472
hggtk/sync: make adding new paths more efficient
Steve Borho <steve@borho.org>
parents:
514
diff
changeset
|
109 |
'The editor to use during a commit and other' |
0d20d0631472
hggtk/sync: make adding new paths more efficient
Steve Borho <steve@borho.org>
parents:
514
diff
changeset
|
110 |
' instances where Mercurial needs multiline input from' |
0d20d0631472
hggtk/sync: make adding new paths more efficient
Steve Borho <steve@borho.org>
parents:
514
diff
changeset
|
111 |
' the user. Only required by CLI commands.'), |
460
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
112 |
('Verbose', 'ui.verbose', ['False', 'True'], |
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
113 |
'Increase the amount of output printed'), |
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
114 |
('Debug', 'ui.debug', ['False', 'True'], |
462
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
115 |
'Print debugging information')) |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
116 |
self.user_frame = self.add_page(notebook, 'User') |
460
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
117 |
self.fill_frame(self.user_frame, self._user_info) |
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
118 |
|
462
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
119 |
self._paths_info = ( |
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
120 |
('default', 'paths.default', [], |
504
89a6d32fd308
hggtk/thgconfig: better multiline tooltip format
Steve Borho <steve@borho.org>
parents:
502
diff
changeset
|
121 |
'Directory or URL to use when pulling if no source is specified.' |
89a6d32fd308
hggtk/thgconfig: better multiline tooltip format
Steve Borho <steve@borho.org>
parents:
502
diff
changeset
|
122 |
' Default is set to repository from which the current repository was cloned.'), |
462
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
123 |
('default-push', 'paths.default-push', [], |
504
89a6d32fd308
hggtk/thgconfig: better multiline tooltip format
Steve Borho <steve@borho.org>
parents:
502
diff
changeset
|
124 |
'Optional. Directory or URL to use when pushing if no' |
89a6d32fd308
hggtk/thgconfig: better multiline tooltip format
Steve Borho <steve@borho.org>
parents:
502
diff
changeset
|
125 |
' destination is specified.''')) |
462
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
126 |
self.paths_frame = self.add_page(notebook, 'Paths') |
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
127 |
vbox = self.fill_frame(self.paths_frame, self._paths_info) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
128 |
|
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
129 |
self.pathtree = gtk.TreeView() |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
130 |
self.pathsel = self.pathtree.get_selection() |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
131 |
self.pathsel.connect("changed", self._pathlist_rowchanged) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
132 |
column = gtk.TreeViewColumn('Peer Repository Paths', |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
133 |
gtk.CellRendererText(), text=2) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
134 |
self.pathtree.append_column(column) |
501
00a0c59456ef
hggtk/thgconfig: make path list scrollable
Steve Borho <steve@borho.org>
parents:
495
diff
changeset
|
135 |
scrolledwindow = gtk.ScrolledWindow() |
00a0c59456ef
hggtk/thgconfig: make path list scrollable
Steve Borho <steve@borho.org>
parents:
495
diff
changeset
|
136 |
scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) |
00a0c59456ef
hggtk/thgconfig: make path list scrollable
Steve Borho <steve@borho.org>
parents:
495
diff
changeset
|
137 |
scrolledwindow.add(self.pathtree) |
00a0c59456ef
hggtk/thgconfig: make path list scrollable
Steve Borho <steve@borho.org>
parents:
495
diff
changeset
|
138 |
vbox.add(scrolledwindow) |
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
139 |
|
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
140 |
self.pathlist = [] |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
141 |
if 'paths' in list(self.ini): |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
142 |
for name in self.ini['paths']: |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
143 |
if name in ('default', 'default-push'): continue |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
144 |
self.pathlist.append((name, self.ini['paths'][name])) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
145 |
self.curpathrow = 0 |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
146 |
|
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
147 |
buttonbox = gtk.HBox() |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
148 |
self.addButton = gtk.Button("Add") |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
149 |
self.addButton.connect('clicked', self._add_path) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
150 |
buttonbox.pack_start(self.addButton) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
151 |
|
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
152 |
self._delpathbutton = gtk.Button("Remove") |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
153 |
self._delpathbutton.connect('clicked', self._remove_path) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
154 |
buttonbox.pack_start(self._delpathbutton) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
155 |
|
505
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
156 |
self._refreshpathbutton = gtk.Button("Refresh") |
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
157 |
self._refreshpathbutton.connect('clicked', self._refresh_path) |
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
158 |
buttonbox.pack_start(self._refreshpathbutton) |
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
159 |
|
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
160 |
self._testpathbutton = gtk.Button("Test") |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
161 |
self._testpathbutton.connect('clicked', self._test_path) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
162 |
buttonbox.pack_start(self._testpathbutton) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
163 |
|
550
f849eb848b58
hggtk/thgconfig: more layout tweaks
Steve Borho <steve@borho.org>
parents:
532
diff
changeset
|
164 |
table = gtk.Table(2, 2, False) |
f849eb848b58
hggtk/thgconfig: more layout tweaks
Steve Borho <steve@borho.org>
parents:
532
diff
changeset
|
165 |
lbl = gtk.Label('Name:') |
f849eb848b58
hggtk/thgconfig: more layout tweaks
Steve Borho <steve@borho.org>
parents:
532
diff
changeset
|
166 |
lbl.set_alignment(1.0, 0.0) |
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
167 |
self._pathnameedit = gtk.Entry() |
732
cfca0575b11c
hggtk/thgconfig: usability improvements for paths page
Steve Borho <steve@borho.org>
parents:
710
diff
changeset
|
168 |
self._pathnameedit.set_sensitive(False) |
550
f849eb848b58
hggtk/thgconfig: more layout tweaks
Steve Borho <steve@borho.org>
parents:
532
diff
changeset
|
169 |
table.attach(lbl, 0, 1, 0, 1, gtk.FILL, 0, 4, 3) |
f849eb848b58
hggtk/thgconfig: more layout tweaks
Steve Borho <steve@borho.org>
parents:
532
diff
changeset
|
170 |
table.attach(self._pathnameedit, 1, 2, 0, 1, |
f849eb848b58
hggtk/thgconfig: more layout tweaks
Steve Borho <steve@borho.org>
parents:
532
diff
changeset
|
171 |
gtk.FILL|gtk.EXPAND, 0, 4, 3) |
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
172 |
|
550
f849eb848b58
hggtk/thgconfig: more layout tweaks
Steve Borho <steve@borho.org>
parents:
532
diff
changeset
|
173 |
lbl = gtk.Label('Path:') |
f849eb848b58
hggtk/thgconfig: more layout tweaks
Steve Borho <steve@borho.org>
parents:
532
diff
changeset
|
174 |
lbl.set_alignment(1.0, 0.0) |
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
175 |
self._pathpathedit = gtk.Entry() |
732
cfca0575b11c
hggtk/thgconfig: usability improvements for paths page
Steve Borho <steve@borho.org>
parents:
710
diff
changeset
|
176 |
self._pathpathedit.set_sensitive(False) |
550
f849eb848b58
hggtk/thgconfig: more layout tweaks
Steve Borho <steve@borho.org>
parents:
532
diff
changeset
|
177 |
table.attach(lbl, 0, 1, 1, 2, gtk.FILL, 0, 4, 3) |
f849eb848b58
hggtk/thgconfig: more layout tweaks
Steve Borho <steve@borho.org>
parents:
532
diff
changeset
|
178 |
table.attach(self._pathpathedit, 1, 2, 1, 2, |
f849eb848b58
hggtk/thgconfig: more layout tweaks
Steve Borho <steve@borho.org>
parents:
532
diff
changeset
|
179 |
gtk.FILL|gtk.EXPAND, 0, 4, 3) |
f849eb848b58
hggtk/thgconfig: more layout tweaks
Steve Borho <steve@borho.org>
parents:
532
diff
changeset
|
180 |
|
f849eb848b58
hggtk/thgconfig: more layout tweaks
Steve Borho <steve@borho.org>
parents:
532
diff
changeset
|
181 |
vbox.pack_start(table, False, False, 4) |
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
182 |
vbox.pack_start(buttonbox, False, False, 4) |
516
16a3c8dc9c1d
hggtk/thgconfig: move focus_field and new_path into class methods
Steve Borho <steve@borho.org>
parents:
515
diff
changeset
|
183 |
self.refresh_path_list() |
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
184 |
|
550
f849eb848b58
hggtk/thgconfig: more layout tweaks
Steve Borho <steve@borho.org>
parents:
532
diff
changeset
|
185 |
|
460
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
186 |
self._web_info = ( |
468
0bc221b3b35d
hggtk/thgconfig: web.name was missing
Steve Borho <steve@borho.org>
parents:
467
diff
changeset
|
187 |
('Name', 'web.name', ['unknown'], |
515
0d20d0631472
hggtk/sync: make adding new paths more efficient
Steve Borho <steve@borho.org>
parents:
514
diff
changeset
|
188 |
'Repository name to use in the web interface. Default' |
0d20d0631472
hggtk/sync: make adding new paths more efficient
Steve Borho <steve@borho.org>
parents:
514
diff
changeset
|
189 |
' is the working directory.'), |
460
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
190 |
('Description', 'web.description', ['unknown'], |
515
0d20d0631472
hggtk/sync: make adding new paths more efficient
Steve Borho <steve@borho.org>
parents:
514
diff
changeset
|
191 |
'Textual description of the repository''s purpose or' |
0d20d0631472
hggtk/sync: make adding new paths more efficient
Steve Borho <steve@borho.org>
parents:
514
diff
changeset
|
192 |
' contents.'), |
460
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
193 |
('Contact', 'web.contact', ['unknown'], |
515
0d20d0631472
hggtk/sync: make adding new paths more efficient
Steve Borho <steve@borho.org>
parents:
514
diff
changeset
|
194 |
'Name or email address of the person in charge of the' |
0d20d0631472
hggtk/sync: make adding new paths more efficient
Steve Borho <steve@borho.org>
parents:
514
diff
changeset
|
195 |
' repository.'), |
1094
7286fbfae1e3
hggtk/thgconfig: add coal to web style list
Steve Borho <steve@borho.org>
parents:
1075
diff
changeset
|
196 |
('Style', 'web.style', ['default', 'gitweb', 'coal', 'old'], |
460
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
197 |
'Which template map style to use'), |
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
198 |
('Archive Formats', 'web.allow_archive', ['bz2', 'gz', 'zip'], |
515
0d20d0631472
hggtk/sync: make adding new paths more efficient
Steve Borho <steve@borho.org>
parents:
514
diff
changeset
|
199 |
'Comma separated list of archive formats allowed for' |
0d20d0631472
hggtk/sync: make adding new paths more efficient
Steve Borho <steve@borho.org>
parents:
514
diff
changeset
|
200 |
' downloading'), |
460
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
201 |
('Port', 'web.port', ['8000'], 'Port to listen on'), |
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
202 |
('Push Requires SSL', 'web.push_ssl', ['True', 'False'], |
515
0d20d0631472
hggtk/sync: make adding new paths more efficient
Steve Borho <steve@borho.org>
parents:
514
diff
changeset
|
203 |
'Whether to require that inbound pushes be transported' |
0d20d0631472
hggtk/sync: make adding new paths more efficient
Steve Borho <steve@borho.org>
parents:
514
diff
changeset
|
204 |
' over SSL to prevent password sniffing.'), |
460
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
205 |
('Stripes', 'web.stripes', ['1', '0'], |
515
0d20d0631472
hggtk/sync: make adding new paths more efficient
Steve Borho <steve@borho.org>
parents:
514
diff
changeset
|
206 |
'How many lines a "zebra stripe" should span in multiline' |
0d20d0631472
hggtk/sync: make adding new paths more efficient
Steve Borho <steve@borho.org>
parents:
514
diff
changeset
|
207 |
' output. Default is 1; set to 0 to disable.'), |
460
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
208 |
('Max Files', 'web.maxfiles', ['10'], |
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
209 |
'Maximum number of files to list per changeset.'), |
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
210 |
('Max Changes', 'web.maxfiles', ['10'], |
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
211 |
'Maximum number of changes to list on the changelog.'), |
583
54f1548985e6
hggtk/thgconfig: fix two fields on web tab
Steve Borho <steve@borho.org>
parents:
550
diff
changeset
|
212 |
('Allow Push', 'web.allow_push', ['*'], |
504
89a6d32fd308
hggtk/thgconfig: better multiline tooltip format
Steve Borho <steve@borho.org>
parents:
502
diff
changeset
|
213 |
'Whether to allow pushing to the repository. If empty or not' |
89a6d32fd308
hggtk/thgconfig: better multiline tooltip format
Steve Borho <steve@borho.org>
parents:
502
diff
changeset
|
214 |
' set, push is not allowed. If the special value "*", any remote' |
89a6d32fd308
hggtk/thgconfig: better multiline tooltip format
Steve Borho <steve@borho.org>
parents:
502
diff
changeset
|
215 |
' user can push, including unauthenticated users. Otherwise, the' |
89a6d32fd308
hggtk/thgconfig: better multiline tooltip format
Steve Borho <steve@borho.org>
parents:
502
diff
changeset
|
216 |
' remote user must have been authenticated, and the authenticated' |
89a6d32fd308
hggtk/thgconfig: better multiline tooltip format
Steve Borho <steve@borho.org>
parents:
502
diff
changeset
|
217 |
' user name must be present in this list (separated by whitespace' |
89a6d32fd308
hggtk/thgconfig: better multiline tooltip format
Steve Borho <steve@borho.org>
parents:
502
diff
changeset
|
218 |
' or ","). The contents of the allow_push list are examined after' |
89a6d32fd308
hggtk/thgconfig: better multiline tooltip format
Steve Borho <steve@borho.org>
parents:
502
diff
changeset
|
219 |
' the deny_push list.'), |
583
54f1548985e6
hggtk/thgconfig: fix two fields on web tab
Steve Borho <steve@borho.org>
parents:
550
diff
changeset
|
220 |
('Deny Push', 'web.deny_push', ['*'], |
504
89a6d32fd308
hggtk/thgconfig: better multiline tooltip format
Steve Borho <steve@borho.org>
parents:
502
diff
changeset
|
221 |
'Whether to deny pushing to the repository. If empty or not set,' |
89a6d32fd308
hggtk/thgconfig: better multiline tooltip format
Steve Borho <steve@borho.org>
parents:
502
diff
changeset
|
222 |
' push is not denied. If the special value "*", all remote users' |
89a6d32fd308
hggtk/thgconfig: better multiline tooltip format
Steve Borho <steve@borho.org>
parents:
502
diff
changeset
|
223 |
' are denied push. Otherwise, unauthenticated users are all' |
89a6d32fd308
hggtk/thgconfig: better multiline tooltip format
Steve Borho <steve@borho.org>
parents:
502
diff
changeset
|
224 |
' denied, and any authenticated user name present in this list' |
89a6d32fd308
hggtk/thgconfig: better multiline tooltip format
Steve Borho <steve@borho.org>
parents:
502
diff
changeset
|
225 |
' (separated by whitespace or ",") is also denied. The contents' |
89a6d32fd308
hggtk/thgconfig: better multiline tooltip format
Steve Borho <steve@borho.org>
parents:
502
diff
changeset
|
226 |
' of the deny_push list are examined before the allow_push list.'), |
460
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
227 |
('Encoding', 'web.encoding', ['UTF-8'], |
462
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
228 |
'Character encoding name')) |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
229 |
self.web_frame = self.add_page(notebook, 'Web') |
460
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
230 |
self.fill_frame(self.web_frame, self._web_info) |
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
231 |
|
584
8128816c1f76
hggtk/thgconfig: add a 'Proxy' tab
Steve Borho <steve@borho.org>
parents:
583
diff
changeset
|
232 |
self._proxy_info = ( |
8128816c1f76
hggtk/thgconfig: add a 'Proxy' tab
Steve Borho <steve@borho.org>
parents:
583
diff
changeset
|
233 |
('host', 'http_proxy.host', [], |
8128816c1f76
hggtk/thgconfig: add a 'Proxy' tab
Steve Borho <steve@borho.org>
parents:
583
diff
changeset
|
234 |
'Host name and (optional) port of proxy server, for' |
8128816c1f76
hggtk/thgconfig: add a 'Proxy' tab
Steve Borho <steve@borho.org>
parents:
583
diff
changeset
|
235 |
' example "myproxy:8000"'), |
8128816c1f76
hggtk/thgconfig: add a 'Proxy' tab
Steve Borho <steve@borho.org>
parents:
583
diff
changeset
|
236 |
('no', 'http_proxy.no', [], |
8128816c1f76
hggtk/thgconfig: add a 'Proxy' tab
Steve Borho <steve@borho.org>
parents:
583
diff
changeset
|
237 |
'Optional. Comma-separated list of host names that' |
8128816c1f76
hggtk/thgconfig: add a 'Proxy' tab
Steve Borho <steve@borho.org>
parents:
583
diff
changeset
|
238 |
' should bypass the proxy'), |
8128816c1f76
hggtk/thgconfig: add a 'Proxy' tab
Steve Borho <steve@borho.org>
parents:
583
diff
changeset
|
239 |
('passwd', 'http_proxy.passwd', [], |
8128816c1f76
hggtk/thgconfig: add a 'Proxy' tab
Steve Borho <steve@borho.org>
parents:
583
diff
changeset
|
240 |
'Optional. Password to authenticate with at the' |
8128816c1f76
hggtk/thgconfig: add a 'Proxy' tab
Steve Borho <steve@borho.org>
parents:
583
diff
changeset
|
241 |
' proxy server'), |
8128816c1f76
hggtk/thgconfig: add a 'Proxy' tab
Steve Borho <steve@borho.org>
parents:
583
diff
changeset
|
242 |
('user', 'http_proxy.user', [], |
8128816c1f76
hggtk/thgconfig: add a 'Proxy' tab
Steve Borho <steve@borho.org>
parents:
583
diff
changeset
|
243 |
'Optional. User name to authenticate with at the' |
8128816c1f76
hggtk/thgconfig: add a 'Proxy' tab
Steve Borho <steve@borho.org>
parents:
583
diff
changeset
|
244 |
' proxy server')) |
8128816c1f76
hggtk/thgconfig: add a 'Proxy' tab
Steve Borho <steve@borho.org>
parents:
583
diff
changeset
|
245 |
self.proxy_frame = self.add_page(notebook, 'Proxy') |
8128816c1f76
hggtk/thgconfig: add a 'Proxy' tab
Steve Borho <steve@borho.org>
parents:
583
diff
changeset
|
246 |
self.fill_frame(self.proxy_frame, self._proxy_info) |
8128816c1f76
hggtk/thgconfig: add a 'Proxy' tab
Steve Borho <steve@borho.org>
parents:
583
diff
changeset
|
247 |
|
460
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
248 |
self._email_info = ( |
532
d23efae1e61e
hggtk/thgconfig: pack (lbl, combo) pairs into a table
Steve Borho <steve@borho.org>
parents:
524
diff
changeset
|
249 |
('From', 'email.from', [], |
460
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
250 |
'Email address to use in "From" header and SMTP envelope'), |
532
d23efae1e61e
hggtk/thgconfig: pack (lbl, combo) pairs into a table
Steve Borho <steve@borho.org>
parents:
524
diff
changeset
|
251 |
('To', 'email.to', [], |
524
d7752204a49c
hggtk: fix tooltips on Windows
Steve Borho <steve@borho.org>
parents:
516
diff
changeset
|
252 |
'Comma-separated list of recipient email addresses'), |
532
d23efae1e61e
hggtk/thgconfig: pack (lbl, combo) pairs into a table
Steve Borho <steve@borho.org>
parents:
524
diff
changeset
|
253 |
('Cc', 'email.cc', [], |
524
d7752204a49c
hggtk: fix tooltips on Windows
Steve Borho <steve@borho.org>
parents:
516
diff
changeset
|
254 |
'Comma-separated list of carbon copy recipient email' |
515
0d20d0631472
hggtk/sync: make adding new paths more efficient
Steve Borho <steve@borho.org>
parents:
514
diff
changeset
|
255 |
' addresses'), |
532
d23efae1e61e
hggtk/thgconfig: pack (lbl, combo) pairs into a table
Steve Borho <steve@borho.org>
parents:
524
diff
changeset
|
256 |
('Bcc', 'email.bcc', [], |
524
d7752204a49c
hggtk: fix tooltips on Windows
Steve Borho <steve@borho.org>
parents:
516
diff
changeset
|
257 |
'Comma-separated list of blind carbon copy recipient' |
d7752204a49c
hggtk: fix tooltips on Windows
Steve Borho <steve@borho.org>
parents:
516
diff
changeset
|
258 |
' email addresses'), |
532
d23efae1e61e
hggtk/thgconfig: pack (lbl, combo) pairs into a table
Steve Borho <steve@borho.org>
parents:
524
diff
changeset
|
259 |
('method', 'email.method', ['smtp'], |
504
89a6d32fd308
hggtk/thgconfig: better multiline tooltip format
Steve Borho <steve@borho.org>
parents:
502
diff
changeset
|
260 |
'Optional. Method to use to send email messages. If value is "smtp" (default),' |
89a6d32fd308
hggtk/thgconfig: better multiline tooltip format
Steve Borho <steve@borho.org>
parents:
502
diff
changeset
|
261 |
' use SMTP (configured below). Otherwise, use as name of program to run that' |
89a6d32fd308
hggtk/thgconfig: better multiline tooltip format
Steve Borho <steve@borho.org>
parents:
502
diff
changeset
|
262 |
' acts like sendmail (takes "-f" option for sender, list of recipients on' |
89a6d32fd308
hggtk/thgconfig: better multiline tooltip format
Steve Borho <steve@borho.org>
parents:
502
diff
changeset
|
263 |
' command line, message on stdin). Normally, setting this to "sendmail" or' |
89a6d32fd308
hggtk/thgconfig: better multiline tooltip format
Steve Borho <steve@borho.org>
parents:
502
diff
changeset
|
264 |
' "/usr/sbin/sendmail" is enough to use sendmail to send messages.'), |
532
d23efae1e61e
hggtk/thgconfig: pack (lbl, combo) pairs into a table
Steve Borho <steve@borho.org>
parents:
524
diff
changeset
|
265 |
('SMTP Host', 'smtp.host', [], 'Host name of mail server'), |
d23efae1e61e
hggtk/thgconfig: pack (lbl, combo) pairs into a table
Steve Borho <steve@borho.org>
parents:
524
diff
changeset
|
266 |
('SMTP Port', 'smtp.port', ['25'], |
460
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
267 |
'Port to connect to on mail server. Default: 25'), |
532
d23efae1e61e
hggtk/thgconfig: pack (lbl, combo) pairs into a table
Steve Borho <steve@borho.org>
parents:
524
diff
changeset
|
268 |
('SMTP TLS', 'smtp.tls', ['False', 'True'], |
460
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
269 |
'Connect to mail server using TLS. Default: False'), |
532
d23efae1e61e
hggtk/thgconfig: pack (lbl, combo) pairs into a table
Steve Borho <steve@borho.org>
parents:
524
diff
changeset
|
270 |
('SMTP Username', 'smtp.username', [], |
460
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
271 |
'Username to authenticate to SMTP server with'), |
532
d23efae1e61e
hggtk/thgconfig: pack (lbl, combo) pairs into a table
Steve Borho <steve@borho.org>
parents:
524
diff
changeset
|
272 |
('SMTP Password', 'smtp.password', [], |
460
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
273 |
'Password to authenticate to SMTP server with'), |
532
d23efae1e61e
hggtk/thgconfig: pack (lbl, combo) pairs into a table
Steve Borho <steve@borho.org>
parents:
524
diff
changeset
|
274 |
('Local Hostname', 'smtp.local_hostname', [], |
460
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
275 |
'Hostname the sender can use to identify itself to MTA')) |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
276 |
self.email_frame = self.add_page(notebook, 'Email') |
460
c01a9772cd0a
hggtk/thgconfig: Fill in remaining configurables
Steve Borho <steve@borho.org>
parents:
458
diff
changeset
|
277 |
self.fill_frame(self.email_frame, self._email_info) |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
278 |
|
1017
33753d10447f
hggtk/thgconfig: add diff tab, move ui.merge to user tab
Steve Borho <steve@borho.org>
parents:
1013
diff
changeset
|
279 |
self._diff_info = ( |
33753d10447f
hggtk/thgconfig: add diff tab, move ui.merge to user tab
Steve Borho <steve@borho.org>
parents:
1013
diff
changeset
|
280 |
('Git Format', 'diff.git', ['False', 'True'], |
33753d10447f
hggtk/thgconfig: add diff tab, move ui.merge to user tab
Steve Borho <steve@borho.org>
parents:
1013
diff
changeset
|
281 |
'Use git extended diff format.'), |
33753d10447f
hggtk/thgconfig: add diff tab, move ui.merge to user tab
Steve Borho <steve@borho.org>
parents:
1013
diff
changeset
|
282 |
('No Dates', 'diff.nodates', ['False', 'True'], |
33753d10447f
hggtk/thgconfig: add diff tab, move ui.merge to user tab
Steve Borho <steve@borho.org>
parents:
1013
diff
changeset
|
283 |
'Do no include dates in diff headers.'), |
33753d10447f
hggtk/thgconfig: add diff tab, move ui.merge to user tab
Steve Borho <steve@borho.org>
parents:
1013
diff
changeset
|
284 |
('Show Function', 'diff.showfunc', ['False', 'True'], |
33753d10447f
hggtk/thgconfig: add diff tab, move ui.merge to user tab
Steve Borho <steve@borho.org>
parents:
1013
diff
changeset
|
285 |
'Show which function each change is in.'), |
33753d10447f
hggtk/thgconfig: add diff tab, move ui.merge to user tab
Steve Borho <steve@borho.org>
parents:
1013
diff
changeset
|
286 |
('Ignore White Space', 'diff.ignorews', ['False', 'True'], |
33753d10447f
hggtk/thgconfig: add diff tab, move ui.merge to user tab
Steve Borho <steve@borho.org>
parents:
1013
diff
changeset
|
287 |
'Ignore white space when comparing lines.'), |
33753d10447f
hggtk/thgconfig: add diff tab, move ui.merge to user tab
Steve Borho <steve@borho.org>
parents:
1013
diff
changeset
|
288 |
('Ignore WS Amount', 'diff.ignorewsamount', ['False', 'True'], |
33753d10447f
hggtk/thgconfig: add diff tab, move ui.merge to user tab
Steve Borho <steve@borho.org>
parents:
1013
diff
changeset
|
289 |
'Ignore changes in the amount of white space.'), |
33753d10447f
hggtk/thgconfig: add diff tab, move ui.merge to user tab
Steve Borho <steve@borho.org>
parents:
1013
diff
changeset
|
290 |
('Ignore Blank Lines', 'diff.ignoreblanklines', |
33753d10447f
hggtk/thgconfig: add diff tab, move ui.merge to user tab
Steve Borho <steve@borho.org>
parents:
1013
diff
changeset
|
291 |
['False', 'True'], |
33753d10447f
hggtk/thgconfig: add diff tab, move ui.merge to user tab
Steve Borho <steve@borho.org>
parents:
1013
diff
changeset
|
292 |
'Ignore changes whose lines are all blank.'), |
33753d10447f
hggtk/thgconfig: add diff tab, move ui.merge to user tab
Steve Borho <steve@borho.org>
parents:
1013
diff
changeset
|
293 |
) |
33753d10447f
hggtk/thgconfig: add diff tab, move ui.merge to user tab
Steve Borho <steve@borho.org>
parents:
1013
diff
changeset
|
294 |
self.diff_frame = self.add_page(notebook, 'Diff') |
33753d10447f
hggtk/thgconfig: add diff tab, move ui.merge to user tab
Steve Borho <steve@borho.org>
parents:
1013
diff
changeset
|
295 |
self.fill_frame(self.diff_frame, self._diff_info) |
462
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
296 |
|
505
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
297 |
# Force dialog into clean state in the beginning |
1174
4b30a3efa4b9
thgconfig: disable Apply button on startup
TK Soh <teekaysoh@yahoo.com>
parents:
1153
diff
changeset
|
298 |
self._refresh_vlist() |
505
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
299 |
self._btn_apply.set_sensitive(False) |
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
300 |
self.dirty = False |
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
301 |
|
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
302 |
def _delete(self, widget, event): |
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
303 |
return True |
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
304 |
|
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
305 |
def _response(self, widget, response_id): |
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
306 |
if self.dirty: |
1120
08eca2607f01
hggtk/dialog: set transient parent for all message dialogs
TK Soh <teekaysoh@yahoo.com>
parents:
1115
diff
changeset
|
307 |
if question_dialog(self, 'Quit without saving?', |
514
74bba69787cc
hggtk/thgconfig: clarify warning message
Steve Borho <steve@borho.org>
parents:
513
diff
changeset
|
308 |
'Yes to abandon changes, No to continue') != gtk.RESPONSE_YES: |
505
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
309 |
widget.emit_stop_by_name('response') |
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
310 |
|
516
16a3c8dc9c1d
hggtk/thgconfig: move focus_field and new_path into class methods
Steve Borho <steve@borho.org>
parents:
515
diff
changeset
|
311 |
def focus_field(self, focusfield): |
16a3c8dc9c1d
hggtk/thgconfig: move focus_field and new_path into class methods
Steve Borho <steve@borho.org>
parents:
515
diff
changeset
|
312 |
'''Set page and focus to requested datum''' |
16a3c8dc9c1d
hggtk/thgconfig: move focus_field and new_path into class methods
Steve Borho <steve@borho.org>
parents:
515
diff
changeset
|
313 |
for page_num, (vbox, info, widgets) in enumerate(self.pages): |
16a3c8dc9c1d
hggtk/thgconfig: move focus_field and new_path into class methods
Steve Borho <steve@borho.org>
parents:
515
diff
changeset
|
314 |
for w, (label, cpath, values, tip) in enumerate(info): |
16a3c8dc9c1d
hggtk/thgconfig: move focus_field and new_path into class methods
Steve Borho <steve@borho.org>
parents:
515
diff
changeset
|
315 |
if cpath == focusfield: |
16a3c8dc9c1d
hggtk/thgconfig: move focus_field and new_path into class methods
Steve Borho <steve@borho.org>
parents:
515
diff
changeset
|
316 |
self.notebook.set_current_page(page_num) |
16a3c8dc9c1d
hggtk/thgconfig: move focus_field and new_path into class methods
Steve Borho <steve@borho.org>
parents:
515
diff
changeset
|
317 |
widgets[w].grab_focus() |
16a3c8dc9c1d
hggtk/thgconfig: move focus_field and new_path into class methods
Steve Borho <steve@borho.org>
parents:
515
diff
changeset
|
318 |
return |
16a3c8dc9c1d
hggtk/thgconfig: move focus_field and new_path into class methods
Steve Borho <steve@borho.org>
parents:
515
diff
changeset
|
319 |
|
16a3c8dc9c1d
hggtk/thgconfig: move focus_field and new_path into class methods
Steve Borho <steve@borho.org>
parents:
515
diff
changeset
|
320 |
def new_path(self, newpath): |
16a3c8dc9c1d
hggtk/thgconfig: move focus_field and new_path into class methods
Steve Borho <steve@borho.org>
parents:
515
diff
changeset
|
321 |
'''Add a new path to [paths], give default name, focus''' |
16a3c8dc9c1d
hggtk/thgconfig: move focus_field and new_path into class methods
Steve Borho <steve@borho.org>
parents:
515
diff
changeset
|
322 |
self.pathlist.append(('new', newpath)) |
16a3c8dc9c1d
hggtk/thgconfig: move focus_field and new_path into class methods
Steve Borho <steve@borho.org>
parents:
515
diff
changeset
|
323 |
self.curpathrow = len(self.pathlist)-1 |
16a3c8dc9c1d
hggtk/thgconfig: move focus_field and new_path into class methods
Steve Borho <steve@borho.org>
parents:
515
diff
changeset
|
324 |
self.refresh_path_list() |
16a3c8dc9c1d
hggtk/thgconfig: move focus_field and new_path into class methods
Steve Borho <steve@borho.org>
parents:
515
diff
changeset
|
325 |
self.notebook.set_current_page(2) |
16a3c8dc9c1d
hggtk/thgconfig: move focus_field and new_path into class methods
Steve Borho <steve@borho.org>
parents:
515
diff
changeset
|
326 |
self._pathnameedit.grab_focus() |
835
117ca72eeda0
hggtk/thgconfig: set dirty mark when adding new path
Steve Borho <steve@borho.org>
parents:
754
diff
changeset
|
327 |
self.dirty_event() |
516
16a3c8dc9c1d
hggtk/thgconfig: move focus_field and new_path into class methods
Steve Borho <steve@borho.org>
parents:
515
diff
changeset
|
328 |
|
505
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
329 |
def dirty_event(self, *args): |
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
330 |
if not self.dirty: |
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
331 |
self._btn_apply.set_sensitive(True) |
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
332 |
self.dirty = True |
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
333 |
|
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
334 |
def _add_path(self, *args): |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
335 |
if len(self.pathlist): |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
336 |
self.pathlist.append(self.pathlist[self.curpathrow]) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
337 |
else: |
732
cfca0575b11c
hggtk/thgconfig: usability improvements for paths page
Steve Borho <steve@borho.org>
parents:
710
diff
changeset
|
338 |
self.pathlist.append(('new', 'http://')) |
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
339 |
self.curpathrow = len(self.pathlist)-1 |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
340 |
self.refresh_path_list() |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
341 |
self._pathnameedit.grab_focus() |
505
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
342 |
self.dirty_event() |
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
343 |
|
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
344 |
def _remove_path(self, *args): |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
345 |
del self.pathlist[self.curpathrow] |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
346 |
if self.curpathrow > len(self.pathlist)-1: |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
347 |
self.curpathrow = len(self.pathlist)-1 |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
348 |
self.refresh_path_list() |
505
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
349 |
self.dirty_event() |
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
350 |
|
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
351 |
def _test_path(self, *args): |
1115
5aa431c9b9c4
hggtk/thgconfig: pass repository root to incoming command
Steve Borho <steve@borho.org>
parents:
1106
diff
changeset
|
352 |
if not self.root: |
5aa431c9b9c4
hggtk/thgconfig: pass repository root to incoming command
Steve Borho <steve@borho.org>
parents:
1106
diff
changeset
|
353 |
error_dialog('No Repository Found', |
5aa431c9b9c4
hggtk/thgconfig: pass repository root to incoming command
Steve Borho <steve@borho.org>
parents:
1106
diff
changeset
|
354 |
'Path testing cannot work without a repository') |
5aa431c9b9c4
hggtk/thgconfig: pass repository root to incoming command
Steve Borho <steve@borho.org>
parents:
1106
diff
changeset
|
355 |
return |
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
356 |
testpath = self._pathpathedit.get_text() |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
357 |
if not testpath: |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
358 |
return |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
359 |
if testpath[0] == '~': |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
360 |
testpath = os.path.expanduser(testpath) |
1115
5aa431c9b9c4
hggtk/thgconfig: pass repository root to incoming command
Steve Borho <steve@borho.org>
parents:
1106
diff
changeset
|
361 |
cmdline = ['hg', 'incoming', '--repository', self.root, '--verbose', testpath] |
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
362 |
from hgcmd import CmdDialog |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
363 |
dlg = CmdDialog(cmdline) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
364 |
dlg.run() |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
365 |
dlg.hide() |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
366 |
|
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
367 |
def _refresh_path(self, *args): |
732
cfca0575b11c
hggtk/thgconfig: usability improvements for paths page
Steve Borho <steve@borho.org>
parents:
710
diff
changeset
|
368 |
name, path = (self._pathnameedit.get_text(), |
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
369 |
self._pathpathedit.get_text()) |
732
cfca0575b11c
hggtk/thgconfig: usability improvements for paths page
Steve Borho <steve@borho.org>
parents:
710
diff
changeset
|
370 |
if name == 'default': |
cfca0575b11c
hggtk/thgconfig: usability improvements for paths page
Steve Borho <steve@borho.org>
parents:
710
diff
changeset
|
371 |
vbox, info, widgets = self.pages[2] |
cfca0575b11c
hggtk/thgconfig: usability improvements for paths page
Steve Borho <steve@borho.org>
parents:
710
diff
changeset
|
372 |
widgets[0].child.set_text(path) |
cfca0575b11c
hggtk/thgconfig: usability improvements for paths page
Steve Borho <steve@borho.org>
parents:
710
diff
changeset
|
373 |
del self.pathlist[self.curpathrow] |
cfca0575b11c
hggtk/thgconfig: usability improvements for paths page
Steve Borho <steve@borho.org>
parents:
710
diff
changeset
|
374 |
elif name == 'default-push': |
cfca0575b11c
hggtk/thgconfig: usability improvements for paths page
Steve Borho <steve@borho.org>
parents:
710
diff
changeset
|
375 |
vbox, info, widgets = self.pages[2] |
cfca0575b11c
hggtk/thgconfig: usability improvements for paths page
Steve Borho <steve@borho.org>
parents:
710
diff
changeset
|
376 |
widgets[1].child.set_text(path) |
cfca0575b11c
hggtk/thgconfig: usability improvements for paths page
Steve Borho <steve@borho.org>
parents:
710
diff
changeset
|
377 |
del self.pathlist[self.curpathrow] |
cfca0575b11c
hggtk/thgconfig: usability improvements for paths page
Steve Borho <steve@borho.org>
parents:
710
diff
changeset
|
378 |
else: |
cfca0575b11c
hggtk/thgconfig: usability improvements for paths page
Steve Borho <steve@borho.org>
parents:
710
diff
changeset
|
379 |
self.pathlist[self.curpathrow] = (name, path) |
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
380 |
self.refresh_path_list() |
505
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
381 |
self.dirty_event() |
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
382 |
|
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
383 |
def _pathlist_rowchanged(self, sel): |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
384 |
model, iter = sel.get_selected() |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
385 |
if not iter: |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
386 |
return |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
387 |
self._pathnameedit.set_text(model.get(iter, 0)[0]) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
388 |
self._pathpathedit.set_text(model.get(iter, 1)[0]) |
732
cfca0575b11c
hggtk/thgconfig: usability improvements for paths page
Steve Borho <steve@borho.org>
parents:
710
diff
changeset
|
389 |
self._pathnameedit.set_sensitive(True) |
cfca0575b11c
hggtk/thgconfig: usability improvements for paths page
Steve Borho <steve@borho.org>
parents:
710
diff
changeset
|
390 |
self._pathpathedit.set_sensitive(True) |
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
391 |
self.curpathrow = model.get(iter, 3)[0] |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
392 |
|
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
393 |
def refresh_path_list(self): |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
394 |
model = gtk.ListStore(gobject.TYPE_PYOBJECT, |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
395 |
gobject.TYPE_PYOBJECT, |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
396 |
gobject.TYPE_STRING, |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
397 |
gobject.TYPE_PYOBJECT) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
398 |
row = 0 |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
399 |
for (name, path) in self.pathlist: |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
400 |
iter = model.insert_before(None, None) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
401 |
model.set_value(iter, 0, name) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
402 |
model.set_value(iter, 1, path) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
403 |
model.set_value(iter, 2, "%s = %s" % (name, path)) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
404 |
model.set_value(iter, 3, row) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
405 |
row += 1 |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
406 |
self.pathtree.set_model(model) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
407 |
if len(self.pathlist): |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
408 |
self._delpathbutton.set_sensitive(True) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
409 |
self._testpathbutton.set_sensitive(True) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
410 |
self._refreshpathbutton.set_sensitive(True) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
411 |
else: |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
412 |
self._delpathbutton.set_sensitive(False) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
413 |
self._testpathbutton.set_sensitive(False) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
414 |
self._refreshpathbutton.set_sensitive(False) |
732
cfca0575b11c
hggtk/thgconfig: usability improvements for paths page
Steve Borho <steve@borho.org>
parents:
710
diff
changeset
|
415 |
self._pathnameedit.set_text('') |
cfca0575b11c
hggtk/thgconfig: usability improvements for paths page
Steve Borho <steve@borho.org>
parents:
710
diff
changeset
|
416 |
self._pathpathedit.set_text('') |
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
417 |
self._pathnameedit.set_sensitive(False) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
418 |
self._pathpathedit.set_sensitive(False) |
732
cfca0575b11c
hggtk/thgconfig: usability improvements for paths page
Steve Borho <steve@borho.org>
parents:
710
diff
changeset
|
419 |
if self.curpathrow >= 0 and self.curpathrow < len(self.pathlist): |
cfca0575b11c
hggtk/thgconfig: usability improvements for paths page
Steve Borho <steve@borho.org>
parents:
710
diff
changeset
|
420 |
self.pathsel.select_path(self.curpathrow) |
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
421 |
|
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
422 |
def fill_frame(self, frame, info): |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
423 |
widgets = [] |
532
d23efae1e61e
hggtk/thgconfig: pack (lbl, combo) pairs into a table
Steve Borho <steve@borho.org>
parents:
524
diff
changeset
|
424 |
table = gtk.Table(len(info), 2, False) |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
425 |
vbox = gtk.VBox() |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
426 |
frame.add(vbox) |
532
d23efae1e61e
hggtk/thgconfig: pack (lbl, combo) pairs into a table
Steve Borho <steve@borho.org>
parents:
524
diff
changeset
|
427 |
vbox.pack_start(table, False, False, 2) |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
428 |
|
532
d23efae1e61e
hggtk/thgconfig: pack (lbl, combo) pairs into a table
Steve Borho <steve@borho.org>
parents:
524
diff
changeset
|
429 |
for row, (label, cpath, values, tooltip) in enumerate(info): |
970
e5d92b531b70
hggtk/thgconfig: add separators between value types
Steve Borho <steve@borho.org>
parents:
941
diff
changeset
|
430 |
vlist = gtk.ListStore(str, bool) |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
431 |
combo = gtk.ComboBoxEntry(vlist, 0) |
505
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
432 |
combo.connect("changed", self.dirty_event) |
970
e5d92b531b70
hggtk/thgconfig: add separators between value types
Steve Borho <steve@borho.org>
parents:
941
diff
changeset
|
433 |
combo.set_row_separator_func(lambda model, iter: model[iter][1]) |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
434 |
widgets.append(combo) |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
435 |
|
532
d23efae1e61e
hggtk/thgconfig: pack (lbl, combo) pairs into a table
Steve Borho <steve@borho.org>
parents:
524
diff
changeset
|
436 |
lbl = gtk.Label(label + ':') |
d23efae1e61e
hggtk/thgconfig: pack (lbl, combo) pairs into a table
Steve Borho <steve@borho.org>
parents:
524
diff
changeset
|
437 |
lbl.set_alignment(1.0, 0.0) |
524
d7752204a49c
hggtk: fix tooltips on Windows
Steve Borho <steve@borho.org>
parents:
516
diff
changeset
|
438 |
eventbox = gtk.EventBox() |
532
d23efae1e61e
hggtk/thgconfig: pack (lbl, combo) pairs into a table
Steve Borho <steve@borho.org>
parents:
524
diff
changeset
|
439 |
eventbox.add(lbl) |
d23efae1e61e
hggtk/thgconfig: pack (lbl, combo) pairs into a table
Steve Borho <steve@borho.org>
parents:
524
diff
changeset
|
440 |
table.attach(eventbox, 0, 1, row, row+1, gtk.FILL, 0, 4, 3) |
d23efae1e61e
hggtk/thgconfig: pack (lbl, combo) pairs into a table
Steve Borho <steve@borho.org>
parents:
524
diff
changeset
|
441 |
table.attach(combo, 1, 2, row, row+1, gtk.FILL|gtk.EXPAND, 0, 4, 3) |
524
d7752204a49c
hggtk: fix tooltips on Windows
Steve Borho <steve@borho.org>
parents:
516
diff
changeset
|
442 |
self.tooltips.set_tip(eventbox, tooltip) |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
443 |
|
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
444 |
self.pages.append((vbox, info, widgets)) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
445 |
return vbox |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
446 |
|
1101
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
447 |
def _refresh_vlist(self): |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
448 |
for vbox, info, widgets in self.pages: |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
449 |
for row, (label, cpath, values, tooltip) in enumerate(info): |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
450 |
combo = widgets[row] |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
451 |
vlist = combo.get_model() |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
452 |
vlist.clear() |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
453 |
|
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
454 |
# Get currently configured value from this config file |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
455 |
curvalue = self.get_ini_config(cpath) |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
456 |
|
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
457 |
if cpath == 'tortoisehg.vdiff': |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
458 |
# Special case, add extdiff.cmd.* to possible values |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
459 |
for name, value in self.ui.configitems('extdiff'): |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
460 |
if name.startswith('cmd.') and name[4:] not in values: |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
461 |
values.append(name[4:]) |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
462 |
elif cpath == 'ui.merge': |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
463 |
# Special case, add [merge-tools] to possible values |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
464 |
try: |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
465 |
from mercurial import filemerge |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
466 |
tools = [] |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
467 |
for key, value in self.ui.configitems('merge-tools'): |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
468 |
t = key.split('.')[0] |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
469 |
if t not in tools: |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
470 |
tools.append(t) |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
471 |
for t in tools: |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
472 |
# Ensure the tool is installed |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
473 |
if filemerge._findtool(self.ui, t): |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
474 |
values.append(t) |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
475 |
except ImportError: |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
476 |
pass |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
477 |
|
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
478 |
currow = None |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
479 |
vlist.append([_unspecstr, False]) |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
480 |
if values: |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
481 |
vlist.append(['Suggested', True]) |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
482 |
for v in values: |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
483 |
vlist.append([v, False]) |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
484 |
if v == curvalue: |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
485 |
currow = len(vlist) - 1 |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
486 |
if cpath in self.history.get_keys(): |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
487 |
separator = False |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
488 |
for v in self.history.mrul(cpath): |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
489 |
if v in values: continue |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
490 |
if not separator: |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
491 |
vlist.append(['History', True]) |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
492 |
separator = True |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
493 |
vlist.append([v, False]) |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
494 |
if v == curvalue: |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
495 |
currow = len(vlist) - 1 |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
496 |
|
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
497 |
if curvalue is None: |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
498 |
combo.set_active(0) |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
499 |
elif currow is None: |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
500 |
combo.child.set_text(curvalue) |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
501 |
else: |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
502 |
combo.set_active(currow) |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
503 |
|
462
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
504 |
def add_page(self, notebook, tab): |
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
505 |
frame = gtk.Frame() |
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
506 |
frame.set_border_width(10) |
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
507 |
frame.set_size_request(508, 500) |
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
508 |
frame.show() |
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
509 |
|
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
510 |
label = gtk.Label(tab) |
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
511 |
notebook.append_page(frame, label) |
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
512 |
return frame |
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
513 |
|
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
514 |
def get_ini_config(self, cpath): |
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
515 |
'''Retrieve a value from the parsed config file''' |
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
516 |
try: |
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
517 |
# Presumes single section/key level depth |
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
518 |
section, key = cpath.split('.', 1) |
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
519 |
return self.ini[section][key] |
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
520 |
except KeyError: |
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
521 |
return None |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
522 |
|
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
523 |
def load_config(self, rcpath): |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
524 |
for fn in rcpath: |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
525 |
if os.path.exists(fn): |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
526 |
break |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
527 |
else: |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
528 |
fn = rcpath[0] |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
529 |
f = open(fn, "w") |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
530 |
f.write("# Generated by tortoisehg-config\n") |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
531 |
f.close() |
463
bd4e1edb03da
hggtk/thgconfig: add write back and history
Steve Borho <steve@borho.org>
parents:
462
diff
changeset
|
532 |
self.fn = fn |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
533 |
return iniparse.INIConfig(file(fn)) |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
534 |
|
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
535 |
def record_new_value(self, cpath, newvalue, keephistory=True): |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
536 |
section, key = cpath.split('.', 1) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
537 |
if newvalue == _unspecstr: |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
538 |
try: |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
539 |
del self.ini[section][key] |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
540 |
except KeyError: |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
541 |
pass |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
542 |
return |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
543 |
if section not in list(self.ini): |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
544 |
self.ini.new_namespace(section) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
545 |
self.ini[section][key] = newvalue |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
546 |
if not keephistory: |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
547 |
return |
1075
896539c063a7
hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents:
1054
diff
changeset
|
548 |
if cpath not in self.history.get_keys(): |
896539c063a7
hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents:
1054
diff
changeset
|
549 |
self.history.set_value(cpath, []) |
896539c063a7
hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents:
1054
diff
changeset
|
550 |
elif newvalue in self.history.get_keys(): |
896539c063a7
hggtk/shlib: revise Settings class
TK Soh <teekaysoh@yahoo.com>
parents:
1054
diff
changeset
|
551 |
self.history.get_value(cpath).remove(newvalue) |
1099
e79119854335
hggtk/thgconfig: use MRU lists to manage recently used data
TK Soh <teekaysoh@yahoo.com>
parents:
1095
diff
changeset
|
552 |
self.history.mrul(cpath).add(newvalue) |
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
553 |
|
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
554 |
def _apply_clicked(self, *args): |
463
bd4e1edb03da
hggtk/thgconfig: add write back and history
Steve Borho <steve@borho.org>
parents:
462
diff
changeset
|
555 |
# Reload history, since it may have been modified externally |
1054
be9114b959cc
hggtk: use new Settings class in clone and config dialogs
TK Soh <teekaysoh@yahoo.com>
parents:
1035
diff
changeset
|
556 |
self.history.read() |
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
557 |
|
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
558 |
# flush changes on paths page |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
559 |
if len(self.pathlist): |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
560 |
self._refresh_path(None) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
561 |
refreshlist = [] |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
562 |
for (name, path) in self.pathlist: |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
563 |
cpath = '.'.join(['paths', name]) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
564 |
self.record_new_value(cpath, path, False) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
565 |
refreshlist.append(name) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
566 |
if 'paths' not in list(self.ini): |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
567 |
self.ini.new_namespace('paths') |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
568 |
for name in list(self.ini.paths): |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
569 |
if name not in refreshlist: |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
570 |
del self.ini['paths'][name] |
741
87e53aca19da
hggtk/thgconfig: careful handling when no 'extra' paths defined
Steve Borho <steve@borho.org>
parents:
732
diff
changeset
|
571 |
elif 'paths' in list(self.ini): |
732
cfca0575b11c
hggtk/thgconfig: usability improvements for paths page
Steve Borho <steve@borho.org>
parents:
710
diff
changeset
|
572 |
for name in list(self.ini.paths): |
741
87e53aca19da
hggtk/thgconfig: careful handling when no 'extra' paths defined
Steve Borho <steve@borho.org>
parents:
732
diff
changeset
|
573 |
if name not in ('default', 'default-push'): |
87e53aca19da
hggtk/thgconfig: careful handling when no 'extra' paths defined
Steve Borho <steve@borho.org>
parents:
732
diff
changeset
|
574 |
del self.ini['paths'][name] |
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
575 |
|
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
576 |
# Flush changes on all pages |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
577 |
for vbox, info, widgets in self.pages: |
463
bd4e1edb03da
hggtk/thgconfig: add write back and history
Steve Borho <steve@borho.org>
parents:
462
diff
changeset
|
578 |
for w, (label, cpath, values, tip) in enumerate(info): |
505
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
579 |
newvalue = widgets[w].child.get_text() |
464
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
580 |
self.record_new_value(cpath, newvalue) |
b764763affee
hggtk/thgconfig: fill in paths page
Steve Borho <steve@borho.org>
parents:
463
diff
changeset
|
581 |
|
1054
be9114b959cc
hggtk: use new Settings class in clone and config dialogs
TK Soh <teekaysoh@yahoo.com>
parents:
1035
diff
changeset
|
582 |
self.history.write() |
1101
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
583 |
self._refresh_vlist() |
56b35d77b290
hggtk/thgconfig: add new data to drop-down lists
TK Soh <teekaysoh@yahoo.com>
parents:
1100
diff
changeset
|
584 |
|
463
bd4e1edb03da
hggtk/thgconfig: add write back and history
Steve Borho <steve@borho.org>
parents:
462
diff
changeset
|
585 |
try: |
bd4e1edb03da
hggtk/thgconfig: add write back and history
Steve Borho <steve@borho.org>
parents:
462
diff
changeset
|
586 |
f = open(self.fn, "w") |
bd4e1edb03da
hggtk/thgconfig: add write back and history
Steve Borho <steve@borho.org>
parents:
462
diff
changeset
|
587 |
f.write(str(self.ini)) |
bd4e1edb03da
hggtk/thgconfig: add write back and history
Steve Borho <steve@borho.org>
parents:
462
diff
changeset
|
588 |
f.close() |
bd4e1edb03da
hggtk/thgconfig: add write back and history
Steve Borho <steve@borho.org>
parents:
462
diff
changeset
|
589 |
except IOError, e: |
1120
08eca2607f01
hggtk/dialog: set transient parent for all message dialogs
TK Soh <teekaysoh@yahoo.com>
parents:
1115
diff
changeset
|
590 |
error_dialog(self, 'Unable to write back configuration file', str(e)) |
505
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
591 |
|
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
592 |
self._btn_apply.set_sensitive(False) |
de71f8622487
hggtk/thgconfig: add dirty status indications
Steve Borho <steve@borho.org>
parents:
504
diff
changeset
|
593 |
self.dirty = False |
463
bd4e1edb03da
hggtk/thgconfig: add write back and history
Steve Borho <steve@borho.org>
parents:
462
diff
changeset
|
594 |
return 0 |
bd4e1edb03da
hggtk/thgconfig: add write back and history
Steve Borho <steve@borho.org>
parents:
462
diff
changeset
|
595 |
|
511
2a1431624462
hggtk/thgconfig: simplify specification of user/repo mode on command line
Steve Borho <steve@borho.org>
parents:
510
diff
changeset
|
596 |
def run(root='', cmdline=[], files=[], **opts): |
516
16a3c8dc9c1d
hggtk/thgconfig: move focus_field and new_path into class methods
Steve Borho <steve@borho.org>
parents:
515
diff
changeset
|
597 |
dialog = ConfigDialog(root, bool(files)) |
16a3c8dc9c1d
hggtk/thgconfig: move focus_field and new_path into class methods
Steve Borho <steve@borho.org>
parents:
515
diff
changeset
|
598 |
dialog.show_all() |
16a3c8dc9c1d
hggtk/thgconfig: move focus_field and new_path into class methods
Steve Borho <steve@borho.org>
parents:
515
diff
changeset
|
599 |
dialog.connect('response', gtk.main_quit) |
462
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
600 |
if '--focusfield' in cmdline: |
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
601 |
field = cmdline[cmdline.index('--focusfield')+1] |
516
16a3c8dc9c1d
hggtk/thgconfig: move focus_field and new_path into class methods
Steve Borho <steve@borho.org>
parents:
515
diff
changeset
|
602 |
dialog.focus_field(field) |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
603 |
gtk.gdk.threads_init() |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
604 |
gtk.gdk.threads_enter() |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
605 |
gtk.main() |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
606 |
gtk.gdk.threads_leave() |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
607 |
|
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
608 |
if __name__ == "__main__": |
465
0aa72237e8bb
hggtk/thgconfig: minor doc improvements
Steve Borho <steve@borho.org>
parents:
464
diff
changeset
|
609 |
# example command lines |
462
e578c40cf513
hggtk/thgconfig: add --focusfield argument
Steve Borho <steve@borho.org>
parents:
460
diff
changeset
|
610 |
# python hggtk/thgconfig.py --focusfield ui.editor |
511
2a1431624462
hggtk/thgconfig: simplify specification of user/repo mode on command line
Steve Borho <steve@borho.org>
parents:
510
diff
changeset
|
611 |
# python hggtk/thgconfig.py --focusfield paths.default --configrepo |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
612 |
import sys |
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
613 |
opts = {} |
511
2a1431624462
hggtk/thgconfig: simplify specification of user/repo mode on command line
Steve Borho <steve@borho.org>
parents:
510
diff
changeset
|
614 |
opts['root'] = os.getcwd() |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
615 |
opts['cmdline'] = sys.argv |
511
2a1431624462
hggtk/thgconfig: simplify specification of user/repo mode on command line
Steve Borho <steve@borho.org>
parents:
510
diff
changeset
|
616 |
opts['files'] = '--configrepo' in sys.argv and ['.'] or [] |
458
865ad7102c65
hggtk: initial commit of config tool and iniparse
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
617 |
run(**opts) |