/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: Curtis Hovey
  • Date: 2011-08-12 20:25:28 UTC
  • mto: This revision was merged to the branch mainline in revision 741.
  • Revision ID: sinzui.is@verizon.net-20110812202528-4xf4a2t23urx50d2
Updated gst to gtk3.

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