/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/status.py

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2006-08-15 17:37:54 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-20060815173754-9877ef0e3e64660e
Some small tweaks in the .desktop file.

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

    * icons/olive-gtk.png: added application icon

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    pygtk.require("2.0")
22
22
except:
23
23
    pass
24
 
 
25
 
import gtk
26
 
import gtk.glade
27
 
import gobject
28
 
import pango
 
24
try:
 
25
    import gtk
 
26
    import gtk.glade
 
27
    import gobject
 
28
    import pango
 
29
except:
 
30
    sys.exit(1)
29
31
 
30
32
import bzrlib
31
33
import bzrlib.errors as errors
32
34
 
 
35
if bzrlib.version_info < (0, 9):
 
36
    # function deprecated after 0.9
 
37
    from bzrlib.delta import compare_trees
 
38
 
33
39
from bzrlib.status import show_tree_status
34
40
from bzrlib.workingtree import WorkingTree
35
41
 
36
 
from dialog import error_dialog
37
 
 
38
 
from olive import gladefile
 
42
from dialog import OliveDialog
39
43
 
40
44
class OliveStatus:
41
45
    """ Display Status window and perform the needed actions. """
42
 
    def __init__(self, wt, wtpath):
 
46
    def __init__(self, gladefile, comm, dialog):
43
47
        """ Initialize the Status window. """
44
 
        self.glade = gtk.glade.XML(gladefile, 'window_status')
 
48
        self.gladefile = gladefile
 
49
        self.glade = gtk.glade.XML(self.gladefile, 'window_status')
 
50
        
 
51
        # Communication object
 
52
        self.comm = comm
 
53
        # Dialog object
 
54
        self.dialog = dialog
45
55
        
46
56
        # Get the Status window widget
47
57
        self.window = self.glade.get_widget('window_status')
48
 
        self.wt = wt
49
 
        self.wtpath = wtpath
50
58
        
51
59
        # Check if current location is a branch
52
 
        file_id = self.wt.path2id(wtpath)
 
60
        try:
 
61
            (self.wt, path) = WorkingTree.open_containing(self.comm.get_path())
 
62
            branch = self.wt.branch
 
63
        except errors.NotBranchError:
 
64
            self.notbranch = True
 
65
            return
 
66
        except:
 
67
            raise
 
68
        
 
69
        file_id = self.wt.path2id(path)
53
70
 
 
71
        self.notbranch = False
 
72
        if file_id is None:
 
73
            self.notbranch = True
 
74
            return
 
75
        
54
76
        # Set the old working tree
55
77
        self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
56
78
        
76
98
        column.add_attribute(cell, "text", 0)
77
99
        self.treeview.append_column(column)
78
100
        
79
 
        delta = self.wt.changes_from(self.old_tree)
 
101
        if bzrlib.version_info < (0, 9):
 
102
            delta = compare_trees(self.old_tree, self.wt)
 
103
        else:
 
104
            delta = self.wt.changes_from(self.old_tree)
80
105
 
81
 
        changes = False
82
 
        
83
106
        if len(delta.added):
84
 
            changes = True
85
 
            titer = self.model.append(None, [ _('Added'), None ])
 
107
            titer = self.model.append(None, [ "Added", None ])
86
108
            for path, id, kind in delta.added:
87
109
                self.model.append(titer, [ path, path ])
88
110
 
89
111
        if len(delta.removed):
90
 
            changes = True
91
 
            titer = self.model.append(None, [ _('Removed'), None ])
 
112
            titer = self.model.append(None, [ "Removed", None ])
92
113
            for path, id, kind in delta.removed:
93
114
                self.model.append(titer, [ path, path ])
94
115
 
95
116
        if len(delta.renamed):
96
 
            changes = True
97
 
            titer = self.model.append(None, [ _('Renamed'), None ])
 
117
            titer = self.model.append(None, [ "Renamed", None ])
98
118
            for oldpath, newpath, id, kind, text_modified, meta_modified \
99
119
                    in delta.renamed:
100
120
                self.model.append(titer, [ oldpath, newpath ])
101
121
 
102
122
        if len(delta.modified):
103
 
            changes = True
104
 
            titer = self.model.append(None, [ _('Modified'), None ])
 
123
            titer = self.model.append(None, [ "Modified", None ])
105
124
            for path, id, kind, text_modified, meta_modified in delta.modified:
106
125
                self.model.append(titer, [ path, path ])
107
126
        
108
127
        done_unknown = False
109
128
        for path in self.wt.unknowns():
110
 
            changes = True
111
129
            if not done_unknown:
112
 
                titer = self.model.append(None, [ _('Unknown'), None ])
 
130
                titer = self.model.append(None, [ "Unknown", None ])
113
131
                done_unknown = True
114
132
            self.model.append(titer, [ path, path ])
115
133
 
116
 
        if not changes:
117
 
            self.model.append(None, [ _('No changes.'), None ])
118
 
 
119
134
        self.treeview.expand_all()
120
135
    
121
136
    def display(self):
122
137
        """ Display the Diff window. """
123
 
        self.window.show_all()
 
138
        if self.notbranch:
 
139
            self.dialog.error_dialog('Directory is not a branch',
 
140
                                     'You can perform this action only in a branch.')
 
141
            self.close()
 
142
        else:
 
143
            self.window.show_all()
124
144
 
125
145
    def close(self, widget=None):
126
146
        self.window.destroy()