/b-gtk/fix-viz

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

« back to all changes in this revision

Viewing changes to annotate/config.py

  • Committer: Vincent Ladeuil
  • Date: 2009-12-02 11:12:51 UTC
  • Revision ID: v.ladeuil+lp@free.fr-20091202111251-sh0xqyqtuvitonne
Fix regressions in tests about merge being more strict by default.

* tests/test_commit.py:
(TestPendingRevisions.test_pending_revisions_multi_merge)
(TestCommitDialog.test_pending_multiple): Since there are pending
merges, we should force the merge to avoid the UncommittedChanges
exception.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
import gtk.gdk
20
20
 
21
 
from bzrlib.config import config_dir
 
21
from bzrlib import config
22
22
import bzrlib.util.configobj.configobj as configobj
23
23
 
24
24
 
25
 
gannotate_configspec = (
26
 
    "[window]",
27
 
    "width = integer(default=750)",
28
 
    "height = integer(default=550)",
29
 
    "maximized = boolean(default=False)",
30
 
    "x = integer(default=0)",
31
 
    "y = integer(default=0)",
32
 
    "pane_position = integer(default=325)",
33
 
    "[spans]",
34
 
    "max_custom_spans = integer(default=4)",
35
 
    "custom_spans = float_list()"
36
 
)
37
 
 
38
 
gannotate_config_filename = os.path.join(config_dir(), "gannotate.conf")
 
25
def gannotate_config_filename():
 
26
    return os.path.join(config.config_dir(), "gannotate.conf")
39
27
 
40
28
 
41
29
class GAnnotateConfig(configobj.ConfigObj):
47
35
    """
48
36
 
49
37
    def __init__(self, window):
50
 
        configobj.ConfigObj.__init__(self, gannotate_config_filename,
51
 
                                     configspec=gannotate_configspec)
 
38
        configobj.ConfigObj.__init__(self, gannotate_config_filename())
52
39
        self.window = window
53
40
        self.pane = window.pane
54
 
        
55
 
        self.initial_comment = ["gannotate plugin configuration"]
56
 
        self['window']['width'] = 750
57
 
        self['window']['height'] = 550
58
 
        self['window']['maximized'] = False
59
 
        self['window']['x'] = 0
60
 
        self['window']['y'] = 0
61
 
        self['window']['pane_position'] = 325
62
 
        self['spans']['max_custom_spans'] = 4
63
 
        self['spans']['custom_spans'] = []
 
41
 
 
42
        if 'window' not in self:
 
43
            # Set default values, configobj expects strings here
 
44
            self.initial_comment = ["gannotate plugin configuration"]
 
45
            self['window'] = {}
 
46
            self['window']['width'] = '750'
 
47
            self['window']['height'] = '550'
 
48
            self['window']['maximized'] = 'False'
 
49
            self['window']['x'] = '0'
 
50
            self['window']['y'] = '0'
 
51
            self['window']['pane_position'] = '325'
64
52
 
65
53
        self.apply()
66
54
        self._connect_signals()
68
56
    def apply(self):
69
57
        """Apply properties and such from gannotate.conf, or
70
58
        gannotate_configspec defaults."""
71
 
        self.pane.set_position(self["window"]["pane_position"])
72
 
        self.window.set_default_size(self["window"]["width"],
73
 
                                     self["window"]["height"])
74
 
        self.window.move(self["window"]["x"], self["window"]["y"])
 
59
        self.pane.set_position(self['window'].as_int('pane_position'))
 
60
        self.window.set_default_size(self['window'].as_int('width'),
 
61
                                     self['window'].as_int('height'))
 
62
        self.window.move(self['window'].as_int('x'), self['window'].as_int('y'))
75
63
 
76
 
        if self["window"]["maximized"]:
 
64
        if self['window'].as_bool('maximized'):
77
65
            self.window.maximize()
78
66
 
79
 
        # XXX Don't know how to set an empty list as default in
80
 
        # gannotate_configspec.
81
67
    def _connect_signals(self):
82
68
        self.window.connect("destroy", self._write)
83
69
        self.window.connect("configure-event", self._save_window_props)
91
77
            self["window"]["width"], self["window"]["height"] = w.get_size()
92
78
            self["window"]["x"], self["window"]["y"] = w.get_position()
93
79
            maximized = False
94
 
 
95
80
        self["window"]["maximized"] = maximized
96
 
        
97
81
        return False
98
82
 
99
83
    def _save_pane_props(self, w, gparam):
102
86
 
103
87
        return False
104
88
 
105
 
    def _save_custom_spans(self, w, *args):
106
 
        self["spans"]["custom_spans"] = w.custom_spans
107
 
 
108
 
        return False
109
 
 
110
89
    def _write(self, *args):
111
90
        self.write()
112
91