/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: 2008-05-05 18:16:46 UTC
  • mto: (487.1.1 gtk)
  • mto: This revision was merged to the branch mainline in revision 490.
  • Revision ID: v.ladeuil+lp@free.fr-20080505181646-n95l8ltw2u6jtr26
Fix bug #187283 fix replacing _() by _i18n().

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

* po/olive-gtk.pot:
Regenerated.

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

Show diffs side-by-side

added added

removed removed

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