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

  • Committer: rodney.dawes at canonical
  • Date: 2008-10-25 06:02:09 UTC
  • Revision ID: rodney.dawes@canonical.com-20081025060209-irlizouino63cs1m
        * preferences/__init__.py:
        Remove the dialog separator
        Remove useless extra call to self._create_pages()
        Make the default window size smaller
        Set the default border width on various widgets
        Set the current notebook page to the first one

        * preferences/identity.py:
        Set various border widths appropriately
        Align the labels to the left
        Remove the unneeded bold markup from the labels
        Change the "User Id" label to "E-Mail"
        Align the radio group labels to the top of the groups

        * preferences/plugins.py:
        Set various border widths appropriately
        Set the default paned position to something more sensible
        Set the shadow type on the treeview's scrolled window to in
        Align the Author and Version labels to the left

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
 
from gi.repository import Gtk
18
 
from bzrlib.plugins.gtk import window
19
 
from bzrlib.plugins.gtk.i18n import _i18n
20
 
 
21
 
 
22
 
class StatusWindow(window.Window):
 
17
try:
 
18
    import pygtk
 
19
    pygtk.require("2.0")
 
20
except:
 
21
    pass
 
22
 
 
23
import gtk
 
24
from bzrlib.plugins.gtk import _i18n
 
25
 
 
26
 
 
27
class StatusDialog(gtk.Dialog):
23
28
    """ Display Status window and perform the needed actions. """
24
 
 
25
29
    def __init__(self, wt, wtpath, revision=None):
26
30
        """ Initialize the Status window. """
27
 
        super(StatusWindow, self).__init__()
 
31
        super(StatusDialog, self).__init__(flags=gtk.DIALOG_MODAL, buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
28
32
        self.set_title("Working tree changes")
 
33
        self.set_default_response(gtk.RESPONSE_CLOSE)
29
34
        self._create()
30
35
        self.wt = wt
31
36
        self.wtpath = wtpath
32
37
 
33
38
        if revision is None:
34
39
            revision = self.wt.branch.last_revision()
35
 
 
 
40
            
36
41
        # Set the old working tree
37
42
        self.old_tree = self.wt.branch.repository.revision_tree(revision)
38
43
        # Generate status output
40
45
 
41
46
    def _create(self):
42
47
        self.set_default_size(400, 300)
43
 
        sw = Gtk.ScrolledWindow()
44
 
        sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
45
 
        sw.set_shadow_type(Gtk.ShadowType.IN)
46
 
        self.treeview = Gtk.TreeView()
 
48
        self.set_has_separator(False)
 
49
        sw = gtk.ScrolledWindow()
 
50
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
 
51
        sw.set_shadow_type(gtk.SHADOW_IN)
 
52
        self.treeview = gtk.TreeView()
47
53
        sw.add(self.treeview)
48
 
        self.add(sw)
 
54
        self.vbox.pack_start(sw, True, True)
 
55
        self.vbox.show_all()
49
56
 
50
57
        # sane border and spacing widths (as recommended by GNOME HIG) 
51
58
        self.set_border_width(5)
52
59
        sw.set_border_width(5)
53
 
        self.show_all()
 
60
        self.vbox.set_spacing(2)
 
61
        self.action_area.set_border_width(5)
54
62
 
55
63
 
56
64
    def row_diff(self, tv, path, tvc):
59
67
            return
60
68
        from bzrlib.plugins.gtk.diff import DiffWindow
61
69
        window = DiffWindow()
62
 
        window.set_diff("Working tree changes", self.wt, self.old_tree)
 
70
        window.set_diff("Working tree changes", self.old_tree, self.wt)
63
71
        window.set_file(file)
64
72
        window.show()
65
73
 
66
74
 
67
75
    def _generate_status(self):
68
76
        """ Generate 'bzr status' output. """
69
 
        self.model = Gtk.TreeStore(str, str)
 
77
        self.model = gtk.TreeStore(str, str)
70
78
        self.treeview.set_headers_visible(False)
71
79
        self.treeview.set_model(self.model)
72
80
        self.treeview.connect("row-activated", self.row_diff)
73
 
 
74
 
        cell = Gtk.CellRendererText()
 
81
        
 
82
        cell = gtk.CellRendererText()
75
83
        cell.set_property("width-chars", 20)
76
 
        column = Gtk.TreeViewColumn()
77
 
        column.pack_start(cell, True)
 
84
        column = gtk.TreeViewColumn()
 
85
        column.pack_start(cell, expand=True)
78
86
        column.add_attribute(cell, "text", 0)
79
87
        self.treeview.append_column(column)
80
 
 
 
88
        
81
89
        delta = self.wt.changes_from(self.old_tree)
82
90
 
83
91
        changes = False
84
 
 
 
92
        
85
93
        if len(delta.added):
86
94
            changes = True
87
95
            titer = self.model.append(None, [ _i18n('Added'), None ])
106
114
            titer = self.model.append(None, [ _i18n('Modified'), None ])
107
115
            for path, id, kind, text_modified, meta_modified in delta.modified:
108
116
                self.model.append(titer, [ path, path ])
109
 
 
 
117
        
110
118
        done_unknown = False
111
119
        for path in self.wt.unknowns():
112
120
            changes = True
119
127
            self.model.append(None, [ _i18n('No changes.'), None ])
120
128
 
121
129
        self.treeview.expand_all()
122
 
 
 
130
    
123
131
    def close(self, widget=None):
124
132
        self.window.destroy()