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

  • Committer: David Planella
  • Date: 2010-08-21 09:38:06 UTC
  • mto: This revision was merged to the branch mainline in revision 719.
  • Revision ID: david.planella@ubuntu.com-20100821093806-9u7cq5gcaml6k2ln
Added the rest of files necessary for i18n support in the build system

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
try:
 
18
    import pygtk
 
19
    pygtk.require("2.0")
 
20
except:
 
21
    pass
 
22
 
17
23
import subprocess
18
24
 
19
 
from gi.repository import Gtk
20
 
from gi.repository import GObject
 
25
import gtk
 
26
import gobject
21
27
 
22
28
from bzrlib.config import GlobalConfig
23
 
from bzrlib.plugins.gtk.i18n import _i18n
24
 
from bzrlib.plugins.gtk.dialog import (
25
 
    error_dialog,
26
 
    warning_dialog,
27
 
    )
28
 
 
29
 
 
30
 
class ConflictsDialog(Gtk.Dialog):
 
29
from bzrlib.plugins.gtk import _i18n
 
30
 
 
31
from dialog import error_dialog, warning_dialog
 
32
from errors import show_bzr_error
 
33
 
 
34
class ConflictsDialog(gtk.Dialog):
31
35
    """ This dialog displays the list of conflicts. """
32
 
 
33
36
    def __init__(self, wt, parent=None):
34
37
        """ Initialize the Conflicts dialog. """
35
 
        super(ConflictsDialog, self).__init__(
36
 
            title="Conflicts - Olive", parent=parent, flags=0,
37
 
            buttons=(Gtk.STOCK_CLOSE, Gtk.ResponseType.CANCEL))
38
 
 
 
38
        gtk.Dialog.__init__(self, title="Conflicts - Olive",
 
39
                                  parent=parent,
 
40
                                  flags=0,
 
41
                                  buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CANCEL))
 
42
        
39
43
        # Get arguments
40
44
        self.wt = wt
41
 
 
 
45
        
42
46
        # Create the widgets
43
 
        self._scrolledwindow = Gtk.ScrolledWindow()
44
 
        self._treeview = Gtk.TreeView()
45
 
        self._label_diff3 = Gtk.Label(label=_i18n("External utility:"))
46
 
        self._entry_diff3 = Gtk.Entry()
47
 
        self._image_diff3 = Gtk.Image()
48
 
        self._button_diff3 = Gtk.Button()
49
 
        self._hbox_diff3 = Gtk.HBox()
50
 
 
 
47
        self._scrolledwindow = gtk.ScrolledWindow()
 
48
        self._treeview = gtk.TreeView()
 
49
        self._label_diff3 = gtk.Label(_i18n("External utility:"))
 
50
        self._entry_diff3 = gtk.Entry()
 
51
        self._image_diff3 = gtk.Image()
 
52
        self._button_diff3 = gtk.Button()
 
53
        self._hbox_diff3 = gtk.HBox()
 
54
        
51
55
        # Set callbacks
52
56
        self._button_diff3.connect('clicked', self._on_diff3_clicked)
53
 
 
 
57
        
54
58
        # Set properties
55
 
        self._scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC,
56
 
                                        Gtk.PolicyType.AUTOMATIC)
57
 
        self._image_diff3.set_from_stock(Gtk.STOCK_APPLY, Gtk.IconSize.BUTTON)
 
59
        self._scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC,
 
60
                                        gtk.POLICY_AUTOMATIC)
 
61
        self._image_diff3.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_BUTTON)
58
62
        self._button_diff3.set_image(self._image_diff3)
59
63
        self._entry_diff3.set_text(self._get_diff3())
60
64
        self._hbox_diff3.set_spacing(3)
61
 
        content_area = self.get_content_area()
62
 
        content_area.set_spacing(3)
 
65
        self.vbox.set_spacing(3)
63
66
        self.set_default_size(400, 300)
64
 
 
 
67
        
65
68
        # Construct dialog
66
 
        self._hbox_diff3.pack_start(self._label_diff3, False, False, 0)
67
 
        self._hbox_diff3.pack_start(self._entry_diff3, True, True, 0)
68
 
        self._hbox_diff3.pack_start(self._button_diff3, False, False, 0)
 
69
        self._hbox_diff3.pack_start(self._label_diff3, False, False)
 
70
        self._hbox_diff3.pack_start(self._entry_diff3, True, True)
 
71
        self._hbox_diff3.pack_start(self._button_diff3, False, False)
69
72
        self._scrolledwindow.add(self._treeview)
70
 
        content_area.pack_start(self._scrolledwindow, True, True, 0)
71
 
        content_area.pack_start(self._hbox_diff3, False, False, 0)
72
 
 
 
73
        self.vbox.pack_start(self._scrolledwindow, True, True)
 
74
        self.vbox.pack_start(self._hbox_diff3, False, False)
 
75
        
73
76
        # Create the conflict list
74
77
        self._create_conflicts()
75
 
 
 
78
        
76
79
        # Show the dialog
77
 
        content_area.show_all()
78
 
 
 
80
        self.vbox.show_all()
 
81
    
79
82
    def _get_diff3(self):
80
83
        """ Get the specified diff3 utility. Default is meld. """
81
84
        config = GlobalConfig()
83
86
        if diff3 is None:
84
87
            diff3 = 'meld'
85
88
        return diff3
86
 
 
 
89
    
87
90
    def _set_diff3(self, cmd):
88
91
        """ Set the default diff3 utility to cmd. """
89
92
        config = GlobalConfig()
90
93
        config.set_user_option('gconflicts_diff3', cmd)
91
 
 
 
94
    
92
95
    def _create_conflicts(self):
93
96
        """ Construct the list of conflicts. """
94
97
        if len(self.wt.conflicts()) == 0:
95
 
            self.model = Gtk.ListStore(GObject.TYPE_STRING)
 
98
            self.model = gtk.ListStore(gobject.TYPE_STRING)
96
99
            self._treeview.set_model(self.model)
97
 
            self._treeview.append_column(Gtk.TreeViewColumn(_i18n('Conflicts'),
98
 
                                         Gtk.CellRendererText(), text=0))
99
 
            self._treeview.set_headers_visible(False)
 
100
            self._treeview.append_column(gtk.TreeViewColumn(_i18n('Conflicts'),
 
101
                                         gtk.CellRendererText(), text=0))
 
102
            self._treeview.set_headers_visible(False)            
100
103
            self.model.append([ _i18n("No conflicts in working tree.") ])
101
104
            self._button_diff3.set_sensitive(False)
102
105
        else:
103
 
            self.model = Gtk.ListStore(GObject.TYPE_STRING,
104
 
                                       GObject.TYPE_STRING,
105
 
                                       GObject.TYPE_STRING)
 
106
            self.model = gtk.ListStore(gobject.TYPE_STRING,
 
107
                                       gobject.TYPE_STRING,
 
108
                                       gobject.TYPE_STRING)
106
109
            self._treeview.set_model(self.model)
107
 
            self._treeview.append_column(Gtk.TreeViewColumn(_i18n('Path'),
108
 
                                         Gtk.CellRendererText(), text=0))
109
 
            self._treeview.append_column(Gtk.TreeViewColumn(_i18n('Type'),
110
 
                                         Gtk.CellRendererText(), text=1))
 
110
            self._treeview.append_column(gtk.TreeViewColumn(_i18n('Path'),
 
111
                                         gtk.CellRendererText(), text=0))
 
112
            self._treeview.append_column(gtk.TreeViewColumn(_i18n('Type'),
 
113
                                         gtk.CellRendererText(), text=1))
111
114
            self._treeview.set_search_column(0)
112
115
            for conflict in self.wt.conflicts():
113
116
                if conflict.typestring == 'path conflict':
130
133
                    t = _i18n("deleting parent")
131
134
                else:
132
135
                    t = _i18n("unknown type of conflict")
133
 
 
134
 
                self.model.append([ conflict.path, t, conflict.typestring ])
135
 
 
 
136
                
 
137
                self.model.append([ conflict.path, t, conflict.typestring ]) 
 
138
    
136
139
    def _get_selected_file(self):
137
140
        """ Return the selected conflict's filename. """
138
141
        treeselection = self._treeview.get_selection()
139
142
        (model, iter) = treeselection.get_selected()
140
 
 
 
143
        
141
144
        if iter is None:
142
145
            return None
143
146
        else:
144
147
            return model.get_value(iter, 0)
145
 
 
 
148
    
146
149
    def _get_selected_type(self):
147
150
        """ Return the type of the selected conflict. """
148
151
        treeselection = self._treeview.get_selection()
149
152
        (model, iter) = treeselection.get_selected()
150
 
 
 
153
        
151
154
        if iter is None:
152
155
            return None
153
156
        else:
154
157
            return model.get_value(iter, 2)
155
 
 
 
158
    
156
159
    def _on_diff3_clicked(self, widget):
157
160
        """ Launch external utility to resolve conflicts. """
158
161
        self._set_diff3(self._entry_diff3.get_text())