/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-10 11:49:24 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-20060810114924-d1e0acc313c07d2b
Implemented Informations functionality; some bzrlib API changes handled.

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

    * olive/backend/info_helper.py: made it 0.9 API compatible
    * olive/backend/info.py: small bug fixed
    * olive/frontend/gtk/info.py: implemented Information window
    * olive.glade: added Informations window
    * Olive is two months old!

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