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

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2006-09-25 01:58:44 UTC
  • mto: (0.14.1 main)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: Szilveszter.Farkas@gmail.com-20060925015844-12e9eec2d5f41420
Huge cleanup after removing backend codebase.

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
 
from guifiles import GLADEFILENAME
27
 
 
 
24
try:
 
25
    import gtk
 
26
    import gtk.glade
 
27
    import gobject
 
28
    import pango
 
29
except:
 
30
    sys.exit(1)
 
31
 
 
32
import bzrlib
 
33
import bzrlib.errors as errors
 
34
 
 
35
if bzrlib.version_info < (0, 9):
 
36
    # function deprecated after 0.9
 
37
    from bzrlib.delta import compare_trees
 
38
 
 
39
from bzrlib.status import show_tree_status
 
40
from bzrlib.workingtree import WorkingTree
 
41
 
 
42
from dialog import OliveDialog
28
43
 
29
44
class OliveStatus:
30
45
    """ Display Status window and perform the needed actions. """
31
 
    def __init__(self, wt, wtpath):
 
46
    def __init__(self, gladefile, comm, dialog):
32
47
        """ Initialize the Status window. """
33
 
        self.glade = gtk.glade.XML(GLADEFILENAME, '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
34
55
        
35
56
        # Get the Status window widget
36
57
        self.window = self.glade.get_widget('window_status')
37
58
        
38
 
        self.wt = wt
39
 
        self.wtpath = wtpath
40
 
        
41
59
        # Check if current location is a branch
42
 
        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)
43
70
 
 
71
        self.notbranch = False
 
72
        if file_id is None:
 
73
            self.notbranch = True
 
74
            return
 
75
        
44
76
        # Set the old working tree
45
77
        self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
46
78
        
66
98
        column.add_attribute(cell, "text", 0)
67
99
        self.treeview.append_column(column)
68
100
        
69
 
        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)
70
105
 
71
106
        changes = False
72
107
        
110
145
    
111
146
    def display(self):
112
147
        """ Display the Diff window. """
113
 
        self.window.show_all()
 
148
        if self.notbranch:
 
149
            self.dialog.error_dialog(_('Directory is not a branch'),
 
150
                                     _('You can perform this action only in a branch.'))
 
151
            self.close()
 
152
        else:
 
153
            self.window.show_all()
114
154
 
115
155
    def close(self, widget=None):
116
156
        self.window.destroy()