/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 olive/info.py

  • Committer: Jasper Groenewegen
  • Date: 2008-07-27 12:01:40 UTC
  • mfrom: (576.3.2 improve-merge)
  • mto: This revision was merged to the branch mainline in revision 579.
  • Revision ID: colbrac@xs4all.nl-20080727120140-1agdlzkc9fumjk5f
Merge merge dialog improvements

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
import sys
 
17
import os
18
18
 
19
19
try:
20
20
    import pygtk
21
21
    pygtk.require("2.0")
22
22
except:
23
23
    pass
24
 
try:
25
 
    import gtk
26
 
    import gtk.glade
27
 
    import gobject
28
 
    import pango
29
 
except:
30
 
    sys.exit(1)
31
 
 
32
 
import olive.backend.errors as errors
33
 
import olive.backend.info as info
34
 
 
35
 
class OliveInfo:
 
24
 
 
25
import gtk
 
26
 
 
27
import bzrlib.errors as errors
 
28
 
 
29
from bzrlib.plugins.gtk import _i18n, icon_path
 
30
from bzrlib.plugins.gtk.dialog import error_dialog
 
31
 
 
32
 
 
33
def info(location):
 
34
    """ Get info about branch, working tree, and repository
 
35
    
 
36
    :param location: the location of the branch/working tree/repository
 
37
    
 
38
    :return: the information in dictionary format
 
39
    
 
40
    The following informations are delivered (if available):
 
41
    ret['location']['lightcoroot']: Light checkout root
 
42
    ret['location']['sharedrepo']: Shared repository
 
43
    ret['location']['repobranch']: Repository branch
 
44
    ret['location']['cobranch']: Checkout of branch
 
45
    ret['location']['repoco']: Repository checkout
 
46
    ret['location']['coroot']: Checkout root
 
47
    ret['location']['branchroot']: Branch root
 
48
    ret['related']['parentbranch']: Parent branch
 
49
    ret['related']['publishbranch']: Publish to branch
 
50
    ret['format']['control']: Control format
 
51
    ret['format']['workingtree']: Working tree format
 
52
    ret['format']['branch']: Branch format
 
53
    ret['format']['repository']: Repository format
 
54
    ret['locking']['workingtree']: Working tree lock status
 
55
    ret['locking']['branch']: Branch lock status
 
56
    ret['locking']['repository']: Repository lock status
 
57
    ret['missing']['branch']: Missing revisions in branch
 
58
    ret['missing']['workingtree']: Missing revisions in working tree
 
59
    ret['wtstats']['unchanged']: Unchanged files
 
60
    ret['wtstats']['modified']: Modified files
 
61
    ret['wtstats']['added']: Added files
 
62
    ret['wtstats']['removed']: Removed files
 
63
    ret['wtstats']['renamed']: Renamed files
 
64
    ret['wtstats']['unknown']: Unknown files
 
65
    ret['wtstats']['ignored']: Ingnored files
 
66
    ret['wtstats']['subdirs']: Versioned subdirectories
 
67
    ret['brstats']['revno']: Revisions in branch
 
68
    ret['brstats']['commiters']: Number of commiters
 
69
    ret['brstats']['age']: Age of branch in days
 
70
    ret['brstats']['firstrev']: Time of first revision
 
71
    ret['brstats']['lastrev']: Time of last revision
 
72
    ret['repstats']['revisions']: Revisions in repository
 
73
    ret['repstats']['size']: Size of repository in bytes
 
74
    """
 
75
    import bzrlib.bzrdir as bzrdir
 
76
    
 
77
    import info_helper
 
78
    
 
79
    ret = {}
 
80
    try:
 
81
        a_bzrdir = bzrdir.BzrDir.open_containing(location)[0]
 
82
    except errors.NotBranchError:
 
83
        raise errors.NotBranchError(location)
 
84
 
 
85
    try:
 
86
        working = a_bzrdir.open_workingtree()
 
87
        working.lock_read()
 
88
        try:
 
89
            branch = working.branch
 
90
            repository = branch.repository
 
91
            control = working.bzrdir
 
92
            
 
93
            ret['location'] = info_helper.get_location_info(repository, branch, working)
 
94
            ret['related'] = info_helper.get_related_info(branch)
 
95
            ret['format'] = info_helper.get_format_info(control, repository, branch, working)
 
96
            ret['locking'] = info_helper.get_locking_info(repository, branch, working)
 
97
            ret['missing'] = {}
 
98
            ret['missing']['branch'] = info_helper.get_missing_revisions_branch(branch)
 
99
            ret['missing']['workingtree'] = info_helper.get_missing_revisions_working(working)
 
100
            ret['wtstats'] = info_helper.get_working_stats(working)
 
101
            ret['brstats'] = info_helper.get_branch_stats(branch)
 
102
            ret['repstats'] = info_helper.get_repository_stats(repository)
 
103
        finally:
 
104
            working.unlock()
 
105
            return ret
 
106
        return
 
107
    except (errors.NoWorkingTree, errors.NotLocalUrl):
 
108
        pass
 
109
 
 
110
    try:
 
111
        branch = a_bzrdir.open_branch()
 
112
        repository = branch.repository
 
113
        control = a_bzrdir
 
114
        branch.lock_read()
 
115
        try:
 
116
            ret['location'] = info_helper.get_location_info(repository, branch)
 
117
            ret['related'] = info_helper.get_related_info(branch)
 
118
            ret['format'] = info_helper.get_format_info(control, repository, branch)
 
119
            ret['locking'] = info_helper.get_locking_info(repository, branch)
 
120
            ret['missing']['branch'] = info_helper.get_missing_revisions_branch(branch)
 
121
            ret['brstats'] = info_helper.get_branch_stats(branch)
 
122
            ret['repstats'] = info_helper.get_repository_stats(repository)
 
123
        finally:
 
124
            branch.unlock()
 
125
            return ret
 
126
        return
 
127
    except errors.NotBranchError:
 
128
        pass
 
129
 
 
130
    try:
 
131
        repository = a_bzrdir.open_repository()
 
132
        repository.lock_read()
 
133
        try:
 
134
            ret['location'] = info_helper.get_location_info(repository)
 
135
            ret['format'] = info_helper.get_format_info(control, repository)
 
136
            ret['locking'] = info_helper.get_locking_info(repository)
 
137
            ret['repstats'] = info_helper.get_repository_stats(repository)
 
138
        finally:
 
139
            repository.unlock()
 
140
        return ret
 
141
    except errors.NoRepositoryPresent:
 
142
        pass
 
143
 
 
144
 
 
145
class InfoDialog(object):
36
146
    """ Display Informations window and perform the needed actions. """
37
 
    def __init__(self, gladefile, comm, dialog):
 
147
    
 
148
    def __init__(self, branch):
38
149
        """ Initialize the Informations window. """
39
 
        self.gladefile = gladefile
40
 
        self.glade = gtk.glade.XML(self.gladefile, 'window_info', 'olive-gtk')
41
 
        
42
 
        # Communication object
43
 
        self.comm = comm
44
 
        # Dialog object
45
 
        self.dialog = dialog
46
 
        
47
 
        # Get the Informations window widget
48
 
        self.window = self.glade.get_widget('window_info')
49
 
        
50
150
        # Check if current location is a branch
51
151
        self.notbranch = False
52
152
        try:
53
 
            self.ret = info.info(self.comm.get_path())
 
153
            self.ret = info(branch.base)
54
154
        except errors.NotBranchError:
55
155
            self.notbranch = True
56
156
            return
57
 
        except:
58
 
            raise
59
 
        
60
 
        # Dictionary for signal_autoconnect
61
 
        dic = { "on_button_info_close_clicked": self.close,
62
 
                "on_expander_info_location_activate": self.activate,
63
 
                "on_expander_info_related_activate": self.activate,
64
 
                "on_expander_info_format_activate": self.activate,
65
 
                "on_expander_info_locking_activate": self.activate,
66
 
                "on_expander_info_missing_activate": self.activate,
67
 
                "on_expander_info_wtstats_activate": self.activate,
68
 
                "on_expander_info_brstats_activate": self.activate,
69
 
                "on_expander_info_repstats_activate": self.activate }
70
 
        
71
 
        # Connect the signals to the handlers
72
 
        self.glade.signal_autoconnect(dic)
73
 
        
 
157
        
 
158
        # Create the window
 
159
        self.window = gtk.Dialog(title="Olive - Information",
 
160
                                  parent = None,
 
161
                                  flags=0,
 
162
                                  buttons=None)
 
163
        self.window.set_icon_list(gtk.gdk.pixbuf_new_from_file(icon_path("oliveicon2.png")),
 
164
                                  gtk.gdk.pixbuf_new_from_file(icon_path("olive-gtk.png")))
 
165
        self.window.vbox.set_spacing(3)
 
166
        self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_NORMAL)
 
167
        
 
168
        infokeylist = ( ('location', _i18n("Location"), (
 
169
                            ('lightcoroot', _i18n("Light checkout root")),
 
170
                            ('sharedrepo', _i18n("Shared repository")),
 
171
                            ('repobranch', _i18n("Repository branch")),
 
172
                            ('cobranch', _i18n("Checkout of branch")),
 
173
                            ('repoco', _i18n("Repository checkout")),
 
174
                            ('coroot', _i18n("Checkout root")),
 
175
                            ('branchroot', _i18n("Branch root")),
 
176
                            )),
 
177
                        ('related', _i18n("Related branches"), (
 
178
                            ('parentbranch', _i18n("Parent branch")),
 
179
                            ('publishbranch', _i18n("Publish to branch")),
 
180
                            )),
 
181
                        ('format', _i18n("Format"), (
 
182
                            ('control', _i18n("Control format")),
 
183
                            ('workingtree', _i18n("Working tree format")),
 
184
                            ('branch', _i18n("Branch format")),
 
185
                            ('repository', _i18n("Repository format")),
 
186
                            )),
 
187
                        ('locking', _i18n("Lock status"), (
 
188
                            ('workingtree', _i18n("Working tree lock status")),
 
189
                            ('branch', _i18n("Branch lock status")),
 
190
                            ('repository', _i18n("Repository lock status")),
 
191
                            )),
 
192
                        #('missing', _i18n("Missing revisions"), (
 
193
                        #    ('branch', _i18n("Missing revisions in branch")),
 
194
                        #    ('workingtree', _i18n("Missing revisions in working tree")),
 
195
                        #    )), # Missing is 'temporary' disabled
 
196
                        ('wtstats', _i18n("In the working tree"), (
 
197
                            ('unchanged', _i18n("Unchanged files")),
 
198
                            ('modified', _i18n("Modified files")),
 
199
                            ('added', _i18n("Added files")),
 
200
                            ('removed', _i18n("Removed files")),
 
201
                            ('renamed', _i18n("Renamed files")),
 
202
                            ('unknown', _i18n("Unknown files")),
 
203
                            ('ignored', _i18n("Ignored files")),
 
204
                            ('subdirs', _i18n("Versioned subdirectories")),
 
205
                            )),
 
206
                        ('brstats', _i18n("Branch history"), (
 
207
                            ('revno', _i18n("Revisions in branch")),
 
208
                            ('commiters', _i18n("Number of commiters")),
 
209
                            ('age', _i18n("Age of branch in days")),
 
210
                            ('firstrev', _i18n("Time of first revision")),
 
211
                            ('lastrev', _i18n("Time of last revision")),
 
212
                            )),
 
213
                        ('repstats', _i18n("Revision store"), (
 
214
                            ('revisions', _i18n("Revisions in repository")),
 
215
                            ('size', _i18n("Size of repository in bytes")),
 
216
                            )),
 
217
                        )
 
218
               
74
219
        # Generate status output
75
 
        self._generate_info()
76
 
 
77
 
    def _generate_info(self):
 
220
        self._generate_info(infokeylist)
 
221
        
 
222
        button_close = gtk.Button(stock=gtk.STOCK_CLOSE)        
 
223
        button_close.connect('clicked', self.close)
 
224
        self.window.action_area.pack_end(button_close)
 
225
        self.window.set_focus(button_close)
 
226
    
 
227
    def _generate_info(self, infokeylist):
78
228
        """ Generate 'bzr info' output. """
79
 
        # location
80
 
        if self.ret.has_key('location'):
81
 
            display = False
82
 
            e = self.glade.get_widget('expander_info_location')
83
 
            if self.ret['location'].has_key('lightcoroot'):
84
 
                ll = self.glade.get_widget('label_info_location_lightcoroot_label')
85
 
                l = self.glade.get_widget('label_info_location_lightcoroot')
86
 
                l.set_text(self.ret['location']['lightcoroot'])
87
 
                ll.show()
88
 
                l.show()
89
 
                if not display:
90
 
                    e.set_expanded(True)
91
 
                    e.show()
92
 
                    display = True
93
 
            if self.ret['location'].has_key('sharedrepo'):
94
 
                ll = self.glade.get_widget('label_info_location_sharedrepo_label')
95
 
                l = self.glade.get_widget('label_info_location_sharedrepo')
96
 
                l.set_text(self.ret['location']['sharedrepo'])
97
 
                ll.show()
98
 
                l.show()
99
 
                if not display:
100
 
                    e.set_expanded(True)
101
 
                    e.show()
102
 
                    display = True
103
 
            if self.ret['location'].has_key('repobranch'):
104
 
                ll = self.glade.get_widget('label_info_location_repobranch_label')
105
 
                l = self.glade.get_widget('label_info_location_repobranch')
106
 
                l.set_text(self.ret['location']['repobranch'])
107
 
                ll.show()
108
 
                l.show()
109
 
                if not display:
110
 
                    e.set_expanded(True)
111
 
                    e.show()
112
 
                    display = True
113
 
            if self.ret['location'].has_key('cobranch'):
114
 
                ll = self.glade.get_widget('label_info_location_cobranch_label')
115
 
                l = self.glade.get_widget('label_info_location_cobranch')
116
 
                l.set_text(self.ret['location']['cobranch'])
117
 
                ll.show()
118
 
                l.show()
119
 
                if not display:
120
 
                    e.set_expanded(True)
121
 
                    e.show()
122
 
                    display = True
123
 
            if self.ret['location'].has_key('repoco'):
124
 
                ll = self.glade.get_widget('label_info_location_repoco_label')
125
 
                l = self.glade.get_widget('label_info_location_repoco')
126
 
                l.set_text(self.ret['location']['repoco'])
127
 
                ll.show()
128
 
                l.show()
129
 
                if not display:
130
 
                    e.set_expanded(True)
131
 
                    e.show()
132
 
                    display = True
133
 
            if self.ret['location'].has_key('coroot'):
134
 
                ll = self.glade.get_widget('label_info_location_coroot_label')
135
 
                l = self.glade.get_widget('label_info_location_coroot')
136
 
                l.set_text(self.ret['location']['coroot'])
137
 
                ll.show()
138
 
                l.show()
139
 
                if not display:
140
 
                    e.set_expanded(True)
141
 
                    e.show()
142
 
                    display = True
143
 
            if self.ret['location'].has_key('branchroot'):
144
 
                ll = self.glade.get_widget('label_info_location_branchroot_label')
145
 
                l = self.glade.get_widget('label_info_location_branchroot')
146
 
                l.set_text(self.ret['location']['branchroot'])
147
 
                ll.show()
148
 
                l.show()
149
 
                if not display:
150
 
                    e.set_expanded(True)
151
 
                    e.show()
152
 
                    display = True
153
 
        # related
154
 
        if self.ret.has_key('related'):
155
 
            display = False
156
 
            e = self.glade.get_widget('expander_info_related')
157
 
            if self.ret['related'].has_key('parentbranch'):
158
 
                ll = self.glade.get_widget('label_info_related_parentbranch_label')
159
 
                l = self.glade.get_widget('label_info_related_parentbranch')
160
 
                l.set_text(self.ret['related']['parentbranch'])
161
 
                ll.show()
162
 
                l.show()
163
 
                if not display:
164
 
                    e.set_expanded(True)
165
 
                    e.show()
166
 
                    display = True
167
 
            if self.ret['related'].has_key('publishbranch'):
168
 
                ll = self.glade.get_widget('label_info_related_publishbranch_label')
169
 
                l = self.glade.get_widget('label_info_related_publishbranch')
170
 
                l.set_text(self.ret['related']['publishbranch'])
171
 
                ll.show()
172
 
                l.show()
173
 
                if not display:
174
 
                    e.set_expanded(True)
175
 
                    e.show()
176
 
                    display = True
177
 
        # format
178
 
        if self.ret.has_key('format'):
179
 
            display = False
180
 
            e = self.glade.get_widget('expander_info_format')
181
 
            if self.ret['format'].has_key('control'):
182
 
                ll = self.glade.get_widget('label_info_format_control_label')
183
 
                l = self.glade.get_widget('label_info_format_control')
184
 
                l.set_text(self.ret['format']['control'])
185
 
                ll.show()
186
 
                l.show()
187
 
                if not display:
188
 
                    e.set_expanded(True)
189
 
                    e.show()
190
 
                    display = True
191
 
            if self.ret['format'].has_key('workingtree'):
192
 
                ll = self.glade.get_widget('label_info_format_workingtree_label')
193
 
                l = self.glade.get_widget('label_info_format_workingtree')
194
 
                l.set_text(self.ret['format']['workingtree'])
195
 
                ll.show()
196
 
                l.show()
197
 
                if not display:
198
 
                    e.set_expanded(True)
199
 
                    e.show()
200
 
                    display = True
201
 
            if self.ret['format'].has_key('branch'):
202
 
                ll = self.glade.get_widget('label_info_format_branch_label')
203
 
                l = self.glade.get_widget('label_info_format_branch')
204
 
                l.set_text(self.ret['format']['branch'])
205
 
                ll.show()
206
 
                l.show()
207
 
                if not display:
208
 
                    e.set_expanded(True)
209
 
                    e.show()
210
 
                    display = True
211
 
            if self.ret['format'].has_key('repository'):
212
 
                ll = self.glade.get_widget('label_info_format_repository_label')
213
 
                l = self.glade.get_widget('label_info_format_repository')
214
 
                l.set_text(self.ret['format']['repository'])
215
 
                ll.show()
216
 
                l.show()
217
 
                if not display:
218
 
                    e.set_expanded(True)
219
 
                    e.show()
220
 
                    display = True
221
 
        # locking
222
 
        if self.ret.has_key('locking'):
223
 
            display = False
224
 
            e = self.glade.get_widget('expander_info_locking')
225
 
            if self.ret['locking'].has_key('workingtree'):
226
 
                ll = self.glade.get_widget('label_info_locking_workingtree_label')
227
 
                l = self.glade.get_widget('label_info_locking_workingtree')
228
 
                l.set_text(self.ret['locking']['workingtree'])
229
 
                ll.show()
230
 
                l.show()
231
 
                if not display:
232
 
                    e.set_expanded(True)
233
 
                    e.show()
234
 
                    display = True
235
 
            if self.ret['locking'].has_key('branch'):
236
 
                ll = self.glade.get_widget('label_info_locking_branch_label')
237
 
                l = self.glade.get_widget('label_info_locking_branch')
238
 
                l.set_text(self.ret['locking']['branch'])
239
 
                ll.show()
240
 
                l.show()
241
 
                if not display:
242
 
                    e.set_expanded(True)
243
 
                    e.show()
244
 
                    display = True
245
 
            if self.ret['locking'].has_key('repository'):
246
 
                ll = self.glade.get_widget('label_info_locking_repository_label')
247
 
                l = self.glade.get_widget('label_info_locking_repository')
248
 
                l.set_text(self.ret['locking']['repository'])
249
 
                ll.show()
250
 
                l.show()
251
 
                if not display:
252
 
                    e.set_expanded(True)
253
 
                    e.show()
254
 
                    display = True
255
 
        # missing - temporary disabled
256
 
        """
257
 
        if self.ret.has_key('missing'):
258
 
            display = False
259
 
            e = self.glade.get_widget('expander_info_missing')
260
 
            if self.ret['missing'].has_key('branch'):
261
 
                ll = self.glade.get_widget('label_info_missing_branch_label')
262
 
                l = self.glade.get_widget('label_info_missing_branch')
263
 
                l.set_text(self.ret['missing']['branch'])
264
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
265
 
                ll.show()
266
 
                l.show()
267
 
                if not display:
268
 
                    e.set_expanded(True)
269
 
                    e.show()
270
 
                    display = True
271
 
            if self.ret['missing'].has_key('workingtree'):
272
 
                ll = self.glade.get_widget('label_info_missing_workingtree_label')
273
 
                l = self.glade.get_widget('label_info_missing_workingtree')
274
 
                l.set_text(self.ret['missing']['branch'])
275
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
276
 
                ll.show()
277
 
                l.show()
278
 
                if not display:
279
 
                    e.set_expanded(True)
280
 
                    e.show()
281
 
                    display = True
282
 
        """
283
 
        # working tree stats
284
 
        if self.ret.has_key('wtstats'):
285
 
            display = False
286
 
            e = self.glade.get_widget('expander_info_wtstats')
287
 
            if self.ret['wtstats'].has_key('unchanged'):
288
 
                ll = self.glade.get_widget('label_info_wtstats_unchanged_label')
289
 
                l = self.glade.get_widget('label_info_wtstats_unchanged')
290
 
                l.set_text(str(self.ret['wtstats']['unchanged']))
291
 
                ll.show()
292
 
                l.show()
293
 
                if not display:
294
 
                    e.set_expanded(True)
295
 
                    e.show()
296
 
                    display = True
297
 
            if self.ret['wtstats'].has_key('modified'):
298
 
                ll = self.glade.get_widget('label_info_wtstats_modified_label')
299
 
                l = self.glade.get_widget('label_info_wtstats_modified')
300
 
                l.set_text(str(self.ret['wtstats']['modified']))
301
 
                ll.show()
302
 
                l.show()
303
 
                if not display:
304
 
                    e.set_expanded(True)
305
 
                    e.show()
306
 
                    display = True
307
 
            if self.ret['wtstats'].has_key('added'):
308
 
                ll = self.glade.get_widget('label_info_wtstats_added_label')
309
 
                l = self.glade.get_widget('label_info_wtstats_added')
310
 
                l.set_text(str(self.ret['wtstats']['added']))
311
 
                ll.show()
312
 
                l.show()
313
 
                if not display:
314
 
                    e.set_expanded(True)
315
 
                    e.show()
316
 
                    display = True
317
 
            if self.ret['wtstats'].has_key('removed'):
318
 
                ll = self.glade.get_widget('label_info_wtstats_removed_label')
319
 
                l = self.glade.get_widget('label_info_wtstats_removed')
320
 
                l.set_text(str(self.ret['wtstats']['removed']))
321
 
                ll.show()
322
 
                l.show()
323
 
                if not display:
324
 
                    e.set_expanded(True)
325
 
                    e.show()
326
 
                    display = True
327
 
            if self.ret['wtstats'].has_key('renamed'):
328
 
                ll = self.glade.get_widget('label_info_wtstats_renamed_label')
329
 
                l = self.glade.get_widget('label_info_wtstats_renamed')
330
 
                l.set_text(str(self.ret['wtstats']['renamed']))
331
 
                ll.show()
332
 
                l.show()
333
 
                if not display:
334
 
                    e.set_expanded(True)
335
 
                    e.show()
336
 
                    display = True
337
 
            if self.ret['wtstats'].has_key('unknown'):
338
 
                ll = self.glade.get_widget('label_info_wtstats_unknown_label')
339
 
                l = self.glade.get_widget('label_info_wtstats_unknown')
340
 
                l.set_text(str(self.ret['wtstats']['unknown']))
341
 
                ll.show()
342
 
                l.show()
343
 
                if not display:
344
 
                    e.set_expanded(True)
345
 
                    e.show()
346
 
                    display = True
347
 
            if self.ret['wtstats'].has_key('ignored'):
348
 
                ll = self.glade.get_widget('label_info_wtstats_ignored_label')
349
 
                l = self.glade.get_widget('label_info_wtstats_ignored')
350
 
                l.set_text(str(self.ret['wtstats']['ignored']))
351
 
                ll.show()
352
 
                l.show()
353
 
                if not display:
354
 
                    e.set_expanded(True)
355
 
                    e.show()
356
 
                    display = True
357
 
            if self.ret['wtstats'].has_key('subdirs'):
358
 
                ll = self.glade.get_widget('label_info_wtstats_subdirs_label')
359
 
                l = self.glade.get_widget('label_info_wtstats_subdirs')
360
 
                l.set_text(str(self.ret['wtstats']['subdirs']))
361
 
                ll.show()
362
 
                l.show()
363
 
                if not display:
364
 
                    e.set_expanded(True)
365
 
                    e.show()
366
 
                    display = True
367
 
        # branch stats
368
 
        if self.ret.has_key('brstats'):
369
 
            display = False
370
 
            e = self.glade.get_widget('expander_info_brstats')
371
 
            if self.ret['brstats'].has_key('revno'):
372
 
                ll = self.glade.get_widget('label_info_brstats_revno_label')
373
 
                l = self.glade.get_widget('label_info_brstats_revno')
374
 
                l.set_text(str(self.ret['brstats']['revno']))
375
 
                ll.show()
376
 
                l.show()
377
 
                if not display:
378
 
                    e.set_expanded(True)
379
 
                    e.show()
380
 
                    display = True
381
 
            if self.ret['brstats'].has_key('commiters'):
382
 
                ll = self.glade.get_widget('label_info_brstats_commiters_label')
383
 
                l = self.glade.get_widget('label_info_brstats_commiters')
384
 
                l.set_text(str(self.ret['brstats']['commiters']))
385
 
                ll.show()
386
 
                l.show()
387
 
                if not display:
388
 
                    e.set_expanded(True)
389
 
                    e.show()
390
 
                    display = True
391
 
            if self.ret['brstats'].has_key('age'):
392
 
                ll = self.glade.get_widget('label_info_brstats_age_label')
393
 
                l = self.glade.get_widget('label_info_brstats_age')
394
 
                l.set_text('%d days' % self.ret['brstats']['age'])
395
 
                ll.show()
396
 
                l.show()
397
 
                if not display:
398
 
                    e.set_expanded(True)
399
 
                    e.show()
400
 
                    display = True
401
 
            if self.ret['brstats'].has_key('firstrev'):
402
 
                ll = self.glade.get_widget('label_info_brstats_firstrev_label')
403
 
                l = self.glade.get_widget('label_info_brstats_firstrev')
404
 
                l.set_text(self.ret['brstats']['firstrev'])
405
 
                ll.show()
406
 
                l.show()
407
 
                if not display:
408
 
                    e.set_expanded(True)
409
 
                    e.show()
410
 
                    display = True
411
 
            if self.ret['brstats'].has_key('lastrev'):
412
 
                ll = self.glade.get_widget('label_info_brstats_lastrev_label')
413
 
                l = self.glade.get_widget('label_info_brstats_lastrev')
414
 
                l.set_text(self.ret['brstats']['lastrev'])
415
 
                ll.show()
416
 
                l.show()
417
 
                if not display:
418
 
                    e.set_expanded(True)
419
 
                    e.show()
420
 
                    display = True
421
 
        # repository stats
422
 
        if self.ret.has_key('repstats'):
423
 
            display = False
424
 
            e = self.glade.get_widget('expander_info_repstats')
425
 
            if self.ret['repstats'].has_key('revisions'):
426
 
                ll = self.glade.get_widget('label_info_repstats_revisions_label')
427
 
                l = self.glade.get_widget('label_info_repstats_revisions')
428
 
                l.set_text(str(self.ret['repstats']['revisions']))
429
 
                ll.show()
430
 
                l.show()
431
 
                if not display:
432
 
                    e.set_expanded(True)
433
 
                    e.show()
434
 
                    display = True
435
 
            if self.ret['repstats'].has_key('size'):
436
 
                ll = self.glade.get_widget('label_info_repstats_size_label')
437
 
                l = self.glade.get_widget('label_info_repstats_size')
438
 
                l.set_text('%d KiB' % (self.ret['repstats']['size'] / 1024))
439
 
                ll.show()
440
 
                l.show()
441
 
                if not display:
442
 
                    e.set_expanded(True)
443
 
                    e.show()
444
 
                    display = True
 
229
        for key, keystring, subkeylist in infokeylist:
 
230
            if self.ret.has_key(key):
 
231
                tablelength = 0
 
232
                for subkey, subkeystring in subkeylist:
 
233
                    if self.ret[key].has_key(subkey):
 
234
                        tablelength += 1
 
235
                if tablelength == 0:
 
236
                    pass
 
237
                else:
 
238
                    exec "exp_%s = gtk.Expander('<b>%s</b>')"%(key, keystring)
 
239
                    eval("exp_%s.set_use_markup(True)"%key)
 
240
                    eval("exp_%s.connect('activate', self.activate)"%key)
 
241
                    
 
242
                    exec "alignment_%s = gtk.Alignment()"%key
 
243
                    eval("alignment_%s.set_padding(0, 0, 24, 0)"%key)
 
244
                    eval("exp_%s.add(alignment_%s)"%(key, key))
 
245
                    
 
246
                    exec "table_%s = gtk.Table(tablelength, 2)"%key
 
247
                    eval("table_%s.set_col_spacings(12)"%key)
 
248
                    eval("alignment_%s.add(table_%s)"%(key, key))
 
249
                    
 
250
                    tablepos = 0
 
251
                    for subkey, subkeystring in subkeylist:
 
252
                        if self.ret[key].has_key(subkey):
 
253
                            exec "%s_%s_label = gtk.Label('%s:')"%(key,subkey, subkeystring)
 
254
                            eval("table_%s.attach(%s_%s_label, 0, 1, %i, %i, gtk.FILL)"%(key, key, subkey, tablepos, tablepos + 1))
 
255
                            eval("%s_%s_label.set_alignment(0, 0.5)"%(key, subkey))
 
256
                            
 
257
                            exec "%s_%s = gtk.Label('%s')"%(key, subkey, str(self.ret[key][subkey]))
 
258
                            eval("table_%s.attach(%s_%s, 1, 2, %i, %i, gtk.FILL)"%(key, key, subkey, tablepos, tablepos + 1))
 
259
                            eval("%s_%s.set_alignment(0, 0.5)"%(key, subkey))
 
260
                            tablepos += 1
 
261
                    eval("exp_%s.set_expanded(True)"%key)
 
262
                    eval("self.window.vbox.pack_start(exp_%s, False, True, 0)"%key)
445
263
    
446
264
    def activate(self, expander):
447
265
        """ Redraw the window. """
451
269
    def display(self):
452
270
        """ Display the Informations window. """
453
271
        if self.notbranch:
454
 
            self.dialog.error_dialog(_('Directory is not a branch'),
455
 
                                     _('You can perform this action only in a branch.'))
 
272
            error_dialog(_i18n('Directory is not a branch'),
 
273
                         _i18n('You can perform this action only in a branch.'))
456
274
            self.close()
457
275
        else:
458
 
            self.window.show()
459
 
 
 
276
            self.window.show_all()
 
277
    
460
278
    def close(self, widget=None):
461
279
        self.window.destroy()