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

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2006-08-20 13:02:35 UTC
  • mto: (0.14.1 main) (93.1.1 win32.bialix)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: Szilveszter.Farkas@gmail.com-20060820130235-62c9c5753f5d8774
Gettext support added.

2006-08-20  Szilveszter Farkas <Szilveszter.Farkas@gmail.com>

    * po/hu.po: added Hungarian traslation
    * Added gettext support to all files.
    * genpot.sh: added olive-gtk.pot generator script

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
 
18
 
17
19
try:
18
20
    import pygtk
19
21
    pygtk.require("2.0")
20
22
except:
21
23
    pass
22
 
 
23
 
import gtk
24
 
import gtk.glade
25
 
 
26
 
import bzrlib.errors as errors
27
 
 
28
 
from bzrlib.plugins.gtk import _i18n
29
 
from bzrlib.plugins.gtk.dialog import error_dialog
30
 
from guifiles import GLADEFILENAME
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
 
        return
142
 
    except errors.NoRepositoryPresent:
143
 
        pass
144
 
 
 
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
145
34
 
146
35
class OliveInfo:
147
36
    """ Display Informations window and perform the needed actions. """
148
 
    def __init__(self, branch):
 
37
    def __init__(self, gladefile, comm, dialog):
149
38
        """ Initialize the Informations window. """
150
 
        self.glade = gtk.glade.XML(GLADEFILENAME, 'window_info', 'olive-gtk')
 
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
151
46
        
152
47
        # Get the Informations window widget
153
48
        self.window = self.glade.get_widget('window_info')
155
50
        # Check if current location is a branch
156
51
        self.notbranch = False
157
52
        try:
158
 
            self.ret = info(branch.base)
 
53
            self.ret = info.info(self.comm.get_path())
159
54
        except errors.NotBranchError:
160
55
            self.notbranch = True
161
56
            return
 
57
        except:
 
58
            raise
162
59
        
163
60
        # Dictionary for signal_autoconnect
164
61
        dic = { "on_button_info_close_clicked": self.close,
187
84
                ll = self.glade.get_widget('label_info_location_lightcoroot_label')
188
85
                l = self.glade.get_widget('label_info_location_lightcoroot')
189
86
                l.set_text(self.ret['location']['lightcoroot'])
 
87
                ll.set_markup('<b>' + ll.get_text() + '</b>')
190
88
                ll.show()
191
89
                l.show()
192
90
                if not display:
197
95
                ll = self.glade.get_widget('label_info_location_sharedrepo_label')
198
96
                l = self.glade.get_widget('label_info_location_sharedrepo')
199
97
                l.set_text(self.ret['location']['sharedrepo'])
 
98
                ll.set_markup('<b>' + ll.get_text() + '</b>')
200
99
                ll.show()
201
100
                l.show()
202
101
                if not display:
207
106
                ll = self.glade.get_widget('label_info_location_repobranch_label')
208
107
                l = self.glade.get_widget('label_info_location_repobranch')
209
108
                l.set_text(self.ret['location']['repobranch'])
 
109
                ll.set_markup('<b>' + ll.get_text() + '</b>')
210
110
                ll.show()
211
111
                l.show()
212
112
                if not display:
217
117
                ll = self.glade.get_widget('label_info_location_cobranch_label')
218
118
                l = self.glade.get_widget('label_info_location_cobranch')
219
119
                l.set_text(self.ret['location']['cobranch'])
 
120
                ll.set_markup('<b>' + ll.get_text() + '</b>')
220
121
                ll.show()
221
122
                l.show()
222
123
                if not display:
227
128
                ll = self.glade.get_widget('label_info_location_repoco_label')
228
129
                l = self.glade.get_widget('label_info_location_repoco')
229
130
                l.set_text(self.ret['location']['repoco'])
 
131
                ll.set_markup('<b>' + ll.get_text() + '</b>')
230
132
                ll.show()
231
133
                l.show()
232
134
                if not display:
237
139
                ll = self.glade.get_widget('label_info_location_coroot_label')
238
140
                l = self.glade.get_widget('label_info_location_coroot')
239
141
                l.set_text(self.ret['location']['coroot'])
 
142
                ll.set_markup('<b>' + ll.get_text() + '</b>')
240
143
                ll.show()
241
144
                l.show()
242
145
                if not display:
247
150
                ll = self.glade.get_widget('label_info_location_branchroot_label')
248
151
                l = self.glade.get_widget('label_info_location_branchroot')
249
152
                l.set_text(self.ret['location']['branchroot'])
 
153
                ll.set_markup('<b>' + ll.get_text() + '</b>')
250
154
                ll.show()
251
155
                l.show()
252
156
                if not display:
261
165
                ll = self.glade.get_widget('label_info_related_parentbranch_label')
262
166
                l = self.glade.get_widget('label_info_related_parentbranch')
263
167
                l.set_text(self.ret['related']['parentbranch'])
 
168
                ll.set_markup('<b>' + ll.get_text() + '</b>')
264
169
                ll.show()
265
170
                l.show()
266
171
                if not display:
271
176
                ll = self.glade.get_widget('label_info_related_publishbranch_label')
272
177
                l = self.glade.get_widget('label_info_related_publishbranch')
273
178
                l.set_text(self.ret['related']['publishbranch'])
 
179
                ll.set_markup('<b>' + ll.get_text() + '</b>')
274
180
                ll.show()
275
181
                l.show()
276
182
                if not display:
285
191
                ll = self.glade.get_widget('label_info_format_control_label')
286
192
                l = self.glade.get_widget('label_info_format_control')
287
193
                l.set_text(self.ret['format']['control'])
 
194
                ll.set_markup('<b>' + ll.get_text() + '</b>')
288
195
                ll.show()
289
196
                l.show()
290
197
                if not display:
295
202
                ll = self.glade.get_widget('label_info_format_workingtree_label')
296
203
                l = self.glade.get_widget('label_info_format_workingtree')
297
204
                l.set_text(self.ret['format']['workingtree'])
 
205
                ll.set_markup('<b>' + ll.get_text() + '</b>')
298
206
                ll.show()
299
207
                l.show()
300
208
                if not display:
305
213
                ll = self.glade.get_widget('label_info_format_branch_label')
306
214
                l = self.glade.get_widget('label_info_format_branch')
307
215
                l.set_text(self.ret['format']['branch'])
 
216
                ll.set_markup('<b>' + ll.get_text() + '</b>')
308
217
                ll.show()
309
218
                l.show()
310
219
                if not display:
315
224
                ll = self.glade.get_widget('label_info_format_repository_label')
316
225
                l = self.glade.get_widget('label_info_format_repository')
317
226
                l.set_text(self.ret['format']['repository'])
 
227
                ll.set_markup('<b>' + ll.get_text() + '</b>')
318
228
                ll.show()
319
229
                l.show()
320
230
                if not display:
329
239
                ll = self.glade.get_widget('label_info_locking_workingtree_label')
330
240
                l = self.glade.get_widget('label_info_locking_workingtree')
331
241
                l.set_text(self.ret['locking']['workingtree'])
 
242
                ll.set_markup('<b>' + ll.get_text() + '</b>')
332
243
                ll.show()
333
244
                l.show()
334
245
                if not display:
339
250
                ll = self.glade.get_widget('label_info_locking_branch_label')
340
251
                l = self.glade.get_widget('label_info_locking_branch')
341
252
                l.set_text(self.ret['locking']['branch'])
 
253
                ll.set_markup('<b>' + ll.get_text() + '</b>')
342
254
                ll.show()
343
255
                l.show()
344
256
                if not display:
349
261
                ll = self.glade.get_widget('label_info_locking_repository_label')
350
262
                l = self.glade.get_widget('label_info_locking_repository')
351
263
                l.set_text(self.ret['locking']['repository'])
 
264
                ll.set_markup('<b>' + ll.get_text() + '</b>')
352
265
                ll.show()
353
266
                l.show()
354
267
                if not display:
391
304
                ll = self.glade.get_widget('label_info_wtstats_unchanged_label')
392
305
                l = self.glade.get_widget('label_info_wtstats_unchanged')
393
306
                l.set_text(str(self.ret['wtstats']['unchanged']))
 
307
                ll.set_markup('<b>' + ll.get_text() + '</b>')
394
308
                ll.show()
395
309
                l.show()
396
310
                if not display:
401
315
                ll = self.glade.get_widget('label_info_wtstats_modified_label')
402
316
                l = self.glade.get_widget('label_info_wtstats_modified')
403
317
                l.set_text(str(self.ret['wtstats']['modified']))
 
318
                ll.set_markup('<b>' + ll.get_text() + '</b>')
404
319
                ll.show()
405
320
                l.show()
406
321
                if not display:
411
326
                ll = self.glade.get_widget('label_info_wtstats_added_label')
412
327
                l = self.glade.get_widget('label_info_wtstats_added')
413
328
                l.set_text(str(self.ret['wtstats']['added']))
 
329
                ll.set_markup('<b>' + ll.get_text() + '</b>')
414
330
                ll.show()
415
331
                l.show()
416
332
                if not display:
421
337
                ll = self.glade.get_widget('label_info_wtstats_removed_label')
422
338
                l = self.glade.get_widget('label_info_wtstats_removed')
423
339
                l.set_text(str(self.ret['wtstats']['removed']))
 
340
                ll.set_markup('<b>' + ll.get_text() + '</b>')
424
341
                ll.show()
425
342
                l.show()
426
343
                if not display:
431
348
                ll = self.glade.get_widget('label_info_wtstats_renamed_label')
432
349
                l = self.glade.get_widget('label_info_wtstats_renamed')
433
350
                l.set_text(str(self.ret['wtstats']['renamed']))
 
351
                ll.set_markup('<b>' + ll.get_text() + '</b>')
434
352
                ll.show()
435
353
                l.show()
436
354
                if not display:
441
359
                ll = self.glade.get_widget('label_info_wtstats_unknown_label')
442
360
                l = self.glade.get_widget('label_info_wtstats_unknown')
443
361
                l.set_text(str(self.ret['wtstats']['unknown']))
 
362
                ll.set_markup('<b>' + ll.get_text() + '</b>')
444
363
                ll.show()
445
364
                l.show()
446
365
                if not display:
451
370
                ll = self.glade.get_widget('label_info_wtstats_ignored_label')
452
371
                l = self.glade.get_widget('label_info_wtstats_ignored')
453
372
                l.set_text(str(self.ret['wtstats']['ignored']))
 
373
                ll.set_markup('<b>' + ll.get_text() + '</b>')
454
374
                ll.show()
455
375
                l.show()
456
376
                if not display:
461
381
                ll = self.glade.get_widget('label_info_wtstats_subdirs_label')
462
382
                l = self.glade.get_widget('label_info_wtstats_subdirs')
463
383
                l.set_text(str(self.ret['wtstats']['subdirs']))
 
384
                ll.set_markup('<b>' + ll.get_text() + '</b>')
464
385
                ll.show()
465
386
                l.show()
466
387
                if not display:
475
396
                ll = self.glade.get_widget('label_info_brstats_revno_label')
476
397
                l = self.glade.get_widget('label_info_brstats_revno')
477
398
                l.set_text(str(self.ret['brstats']['revno']))
 
399
                ll.set_markup('<b>' + ll.get_text() + '</b>')
478
400
                ll.show()
479
401
                l.show()
480
402
                if not display:
485
407
                ll = self.glade.get_widget('label_info_brstats_commiters_label')
486
408
                l = self.glade.get_widget('label_info_brstats_commiters')
487
409
                l.set_text(str(self.ret['brstats']['commiters']))
 
410
                ll.set_markup('<b>' + ll.get_text() + '</b>')
488
411
                ll.show()
489
412
                l.show()
490
413
                if not display:
495
418
                ll = self.glade.get_widget('label_info_brstats_age_label')
496
419
                l = self.glade.get_widget('label_info_brstats_age')
497
420
                l.set_text('%d days' % self.ret['brstats']['age'])
 
421
                ll.set_markup('<b>' + ll.get_text() + '</b>')
498
422
                ll.show()
499
423
                l.show()
500
424
                if not display:
505
429
                ll = self.glade.get_widget('label_info_brstats_firstrev_label')
506
430
                l = self.glade.get_widget('label_info_brstats_firstrev')
507
431
                l.set_text(self.ret['brstats']['firstrev'])
 
432
                ll.set_markup('<b>' + ll.get_text() + '</b>')
508
433
                ll.show()
509
434
                l.show()
510
435
                if not display:
515
440
                ll = self.glade.get_widget('label_info_brstats_lastrev_label')
516
441
                l = self.glade.get_widget('label_info_brstats_lastrev')
517
442
                l.set_text(self.ret['brstats']['lastrev'])
 
443
                ll.set_markup('<b>' + ll.get_text() + '</b>')
518
444
                ll.show()
519
445
                l.show()
520
446
                if not display:
529
455
                ll = self.glade.get_widget('label_info_repstats_revisions_label')
530
456
                l = self.glade.get_widget('label_info_repstats_revisions')
531
457
                l.set_text(str(self.ret['repstats']['revisions']))
 
458
                ll.set_markup('<b>' + ll.get_text() + '</b>')
532
459
                ll.show()
533
460
                l.show()
534
461
                if not display:
539
466
                ll = self.glade.get_widget('label_info_repstats_size_label')
540
467
                l = self.glade.get_widget('label_info_repstats_size')
541
468
                l.set_text('%d KiB' % (self.ret['repstats']['size'] / 1024))
 
469
                ll.set_markup('<b>' + ll.get_text() + '</b>')
542
470
                ll.show()
543
471
                l.show()
544
472
                if not display:
554
482
    def display(self):
555
483
        """ Display the Informations window. """
556
484
        if self.notbranch:
557
 
            error_dialog(_i18n('Directory is not a branch'),
558
 
                         _i18n('You can perform this action only in a branch.'))
 
485
            self.dialog.error_dialog(_('Directory is not a branch'),
 
486
                                     _('You can perform this action only in a branch.'))
559
487
            self.close()
560
488
        else:
561
489
            self.window.show()