/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-07 16:51:21 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-20060807165121-10fe27c374bbdffd
Added new artwork.

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

    * olive.galde: added custom artwork (icons)
    * icons/*: new icons for the toolbar
    * setup.py: install the icons

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
 
from bzrlib.plugins.gtk import (
25
 
    _i18n,
26
 
    window,
27
 
    )
28
 
 
29
 
 
30
 
class StatusWindow(window.Window):
 
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
 
 
34
if (bzrlib.version_info[0] == 0) and (bzrlib.version_info[1] < 9):
 
35
    # function deprecated after 0.9
 
36
    from bzrlib.delta import compare_trees
 
37
 
 
38
from bzrlib.status import show_tree_status
 
39
from bzrlib.workingtree import WorkingTree
 
40
 
 
41
from dialog import OliveDialog
 
42
 
 
43
class OliveStatus:
31
44
    """ Display Status window and perform the needed actions. """
32
 
    def __init__(self, wt, wtpath, revision=None):
33
 
        """ Initialize the Status window. """
34
 
        super(StatusWindow, self).__init__()
35
 
        self.set_title("Working tree changes")
36
 
        self._create()
37
 
        self.wt = wt
38
 
        self.wtpath = wtpath
39
 
 
40
 
        if revision is None:
41
 
            revision = self.wt.branch.last_revision()
42
 
 
 
45
    def __init__(self, gladefile, comm):
 
46
        """ Initialize the Diff window. """
 
47
        self.gladefile = gladefile
 
48
        self.glade = gtk.glade.XML(self.gladefile, 'window_status')
 
49
        
 
50
        self.comm = comm
 
51
        
 
52
        self.dialog = OliveDialog(self.gladefile)
 
53
        
 
54
        # Check if current location is a branch
 
55
        try:
 
56
            (self.wt, path) = WorkingTree.open_containing(self.comm.get_path())
 
57
            branch = self.wt.branch
 
58
        except errors.NotBranchError:
 
59
            self.notbranch = True
 
60
            return
 
61
        except:
 
62
            raise
 
63
        
 
64
        file_id = self.wt.path2id(path)
 
65
 
 
66
        self.notbranch = False
 
67
        if file_id is None:
 
68
            self.notbranch = True
 
69
            return
 
70
        
43
71
        # Set the old working tree
44
 
        self.old_tree = self.wt.branch.repository.revision_tree(revision)
 
72
        self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
 
73
        
 
74
        # Get the Diff window widget
 
75
        self.window = self.glade.get_widget('window_status')
 
76
        
 
77
        # Dictionary for signal_autoconnect
 
78
        dic = { "on_button_status_close_clicked": self.close }
 
79
        
 
80
        # Connect the signals to the handlers
 
81
        self.glade.signal_autoconnect(dic)
 
82
        
45
83
        # Generate status output
46
84
        self._generate_status()
47
85
 
48
 
    def _create(self):
49
 
        self.set_default_size(400, 300)
50
 
        sw = gtk.ScrolledWindow()
51
 
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
52
 
        sw.set_shadow_type(gtk.SHADOW_IN)
53
 
        self.treeview = gtk.TreeView()
54
 
        sw.add(self.treeview)
55
 
        self.add(sw)
56
 
 
57
 
        # sane border and spacing widths (as recommended by GNOME HIG) 
58
 
        self.set_border_width(5)
59
 
        sw.set_border_width(5)
60
 
        self.show_all()
61
 
 
62
 
 
63
 
    def row_diff(self, tv, path, tvc):
64
 
        file = self.model[path][1]
65
 
        if file is None:
66
 
            return
67
 
        from bzrlib.plugins.gtk.diff import DiffWindow
68
 
        window = DiffWindow()
69
 
        window.set_diff("Working tree changes", self.wt, self.old_tree)
70
 
        window.set_file(file)
71
 
        window.show()
72
 
 
73
 
 
74
86
    def _generate_status(self):
75
87
        """ Generate 'bzr status' output. """
76
88
        self.model = gtk.TreeStore(str, str)
77
 
        self.treeview.set_headers_visible(False)
 
89
        self.treeview = self.glade.get_widget('treeview_status')
78
90
        self.treeview.set_model(self.model)
79
 
        self.treeview.connect("row-activated", self.row_diff)
80
 
 
 
91
        
81
92
        cell = gtk.CellRendererText()
82
93
        cell.set_property("width-chars", 20)
83
94
        column = gtk.TreeViewColumn()
84
95
        column.pack_start(cell, expand=True)
85
96
        column.add_attribute(cell, "text", 0)
86
97
        self.treeview.append_column(column)
87
 
 
88
 
        delta = self.wt.changes_from(self.old_tree)
89
 
 
90
 
        changes = False
 
98
        
 
99
        if (bzrlib.version_info[0] == 0) and (bzrlib.version_info[1] < 9):
 
100
            delta = compare_trees(self.old_tree, self.wt)
 
101
        else:
 
102
            delta = self.wt.changes_from(self.old_tree)
91
103
 
92
104
        if len(delta.added):
93
 
            changes = True
94
 
            titer = self.model.append(None, [ _i18n('Added'), None ])
 
105
            titer = self.model.append(None, [ "Added", None ])
95
106
            for path, id, kind in delta.added:
96
107
                self.model.append(titer, [ path, path ])
97
108
 
98
109
        if len(delta.removed):
99
 
            changes = True
100
 
            titer = self.model.append(None, [ _i18n('Removed'), None ])
 
110
            titer = self.model.append(None, [ "Removed", None ])
101
111
            for path, id, kind in delta.removed:
102
112
                self.model.append(titer, [ path, path ])
103
113
 
104
114
        if len(delta.renamed):
105
 
            changes = True
106
 
            titer = self.model.append(None, [ _i18n('Renamed'), None ])
 
115
            titer = self.model.append(None, [ "Renamed", None ])
107
116
            for oldpath, newpath, id, kind, text_modified, meta_modified \
108
117
                    in delta.renamed:
109
118
                self.model.append(titer, [ oldpath, newpath ])
110
119
 
111
120
        if len(delta.modified):
112
 
            changes = True
113
 
            titer = self.model.append(None, [ _i18n('Modified'), None ])
 
121
            titer = self.model.append(None, [ "Modified", None ])
114
122
            for path, id, kind, text_modified, meta_modified in delta.modified:
115
123
                self.model.append(titer, [ path, path ])
116
 
 
 
124
        
117
125
        done_unknown = False
118
126
        for path in self.wt.unknowns():
119
 
            changes = True
120
127
            if not done_unknown:
121
 
                titer = self.model.append(None, [ _i18n('Unknown'), None ])
 
128
                titer = self.model.append(None, [ "Unknown", None ])
122
129
                done_unknown = True
123
130
            self.model.append(titer, [ path, path ])
124
131
 
125
 
        if not changes:
126
 
            self.model.append(None, [ _i18n('No changes.'), None ])
127
 
 
128
132
        self.treeview.expand_all()
 
133
    
 
134
    def display(self):
 
135
        """ Display the Diff window. """
 
136
        if self.notbranch:
 
137
            self.dialog.error_dialog('Directory is not a branch.')
 
138
        else:
 
139
            self.window.show_all()
129
140
 
130
141
    def close(self, widget=None):
131
142
        self.window.destroy()