~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/LogWidget.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
                        }
51
51
                }
52
52
                
53
 
                public Toolbar CommandBar {
54
 
                        get {
55
 
                                return commandBar;
56
 
                        }
57
 
                }
58
 
                
59
 
                
60
53
                ListStore logstore = new ListStore (typeof (Revision));
61
54
                FileTreeView treeviewFiles;
62
55
                TreeStore changedpathstore;
63
 
                Gtk.ToolButton revertButton, revertToButton;
 
56
                Gtk.Button revertButton, revertToButton;
64
57
                SearchEntry searchEntry;
65
58
                string currentFilter;
66
59
                
122
115
                        this.info = info;
123
116
                        if (info.Document != null)
124
117
                                this.preselectFile = info.Item.Path;
 
118
 
 
119
                        var separator = new HeaderBox ();
 
120
                        separator.SetMargins (1, 0, 0, 0);
 
121
                        separator.HeightRequest = 4;
 
122
                        separator.ShowAll ();
125
123
                        
126
 
                        revertButton = new Gtk.ToolButton (new Gtk.Image ("vc-revert-command", Gtk.IconSize.Menu), GettextCatalog.GetString ("Revert changes from this revision"));
127
 
                        revertButton.IsImportant = true;
 
124
                        hpaned1 = hpaned1.ReplaceWithWidget (new HPanedThin (), true);
 
125
                        vpaned1 = vpaned1.ReplaceWithWidget (new VPanedThin () { HandleWidget = separator }, true);
 
126
 
 
127
                        revertButton = new DocumentToolButton ("vc-revert-command", GettextCatalog.GetString ("Revert changes from this revision"));
128
128
//                      revertButton.Sensitive = false;
129
129
                        revertButton.Clicked += new EventHandler (RevertRevisionClicked);
130
 
                        CommandBar.Insert (revertButton, -1);
131
 
                        
132
 
                        revertToButton = new Gtk.ToolButton (new Gtk.Image ("vc-revert-command", Gtk.IconSize.Menu), GettextCatalog.GetString ("Revert to this revision"));
133
 
                        revertToButton.IsImportant = true;
 
130
 
 
131
                        revertToButton = new DocumentToolButton ("vc-revert-command", GettextCatalog.GetString ("Revert to this revision"));
134
132
//                      revertToButton.Sensitive = false;
135
133
                        revertToButton.Clicked += new EventHandler (RevertToRevisionClicked);
136
 
                        CommandBar.Insert (revertToButton, -1);
137
 
                        
138
 
                        Gtk.ToolItem item = new Gtk.ToolItem ();
139
 
                        Gtk.HBox a = new Gtk.HBox ();
140
 
                        item.Add (a);
 
134
 
141
135
                        searchEntry = new SearchEntry ();
142
136
                        searchEntry.WidthRequest = 200;
143
137
                        searchEntry.ForceFilterButtonVisible = true;
145
139
                        searchEntry.Changed += HandleSearchEntryFilterChanged;
146
140
                        searchEntry.Ready = true;
147
141
                        searchEntry.Show ();
148
 
                        a.PackEnd (searchEntry, false, false, 0);
149
 
                        CommandBar.Insert (item, -1);
150
 
                        ((Gtk.Toolbar.ToolbarChild)CommandBar[item]).Expand = true;
151
 
                        
152
 
                        CommandBar.ShowAll ();
153
 
                        
 
142
 
154
143
                        messageRenderer.Ellipsize = Pango.EllipsizeMode.End;
155
144
                        TreeViewColumn colRevMessage = new TreeViewColumn ();
156
145
                        colRevMessage.Title = GettextCatalog.GetString ("Message");
235
224
                        labelAuthor.Text = "";
236
225
                        labelDate.Text = "";
237
226
                        labelRevision.Text = "";
 
227
 
 
228
                        vbox2.Remove (scrolledwindow1);
 
229
                        HeaderBox tb = new HeaderBox ();
 
230
                        tb.Show ();
 
231
                        tb.SetMargins (1, 0, 0, 0);
 
232
                        tb.ShowTopShadow = true;
 
233
                        tb.ShadowSize = 4;
 
234
                        tb.SetPadding (8, 8, 8, 8);
 
235
                        tb.UseChildBackgroundColor = true;
 
236
                        tb.Add (scrolledwindow1);
 
237
                        vbox2.PackStart (tb, true, true, 0);
 
238
                }
 
239
 
 
240
                protected override void OnRealized ()
 
241
                {
 
242
                        base.OnRealized ();
 
243
                        var c = new HslColor (Style.Base (StateType.Normal));
 
244
                        c.L *= 0.8;
 
245
                        commitBox.ModifyBg (StateType.Normal, c);
 
246
 
 
247
                        var tcol = new Gdk.Color (255, 251, 242);
 
248
                        textviewDetails.ModifyBase (StateType.Normal, tcol);
 
249
                        scrolledwindow1.ModifyBase (StateType.Normal, tcol);
 
250
                }
 
251
 
 
252
                internal void SetToolbar (DocumentToolbar toolbar)
 
253
                {
 
254
                        toolbar.Add (revertButton);
 
255
                        toolbar.Add (revertToButton);
 
256
 
 
257
                        Gtk.HBox a = new Gtk.HBox ();
 
258
                        a.PackEnd (searchEntry, false, false, 0);
 
259
                        toolbar.Add (a, true);
 
260
 
 
261
                        toolbar.ShowAll ();
238
262
                }
239
263
                
240
264
                bool filtering;
307
331
                
308
332
                void HandleTreeviewFilesTestExpandRow (object o, TestExpandRowArgs args)
309
333
                {
310
 
                        string[] diff = changedpathstore.GetValue (args.Iter, colDiff) as string[];
311
 
                        if (diff != null) {
312
 
                                return;
313
 
                        }
314
334
                        TreeIter iter;
315
335
                        if (changedpathstore.IterChildren (out iter, args.Iter)) {
 
336
                                string[] diff = changedpathstore.GetValue (iter, colDiff) as string[];
 
337
                                if (diff != null)
 
338
                                        return;
 
339
 
316
340
                                string path = (string)changedpathstore .GetValue (args.Iter, colPath);
317
341
                                changedpathstore.SetValue (iter, colDiff, new string[] { GettextCatalog.GetString ("Loading data...") });
318
342
                                var rev = SelectedRevision;
338
362
                                                return;
339
363
                                        }
340
364
                                        string[] lines;
341
 
                                        var changedDocument = new Mono.TextEditor.TextDocument (text);
342
 
                                        if (prevRev == null) {
343
 
                                                lines = new string[changedDocument.LineCount];
344
 
                                                for (int i = 0; i < changedDocument.LineCount; i++) {
345
 
                                                        lines[i] = "+ " + changedDocument.GetLineText (i + 1).TrimEnd ('\r','\n');
346
 
                                                }
347
 
                                                
 
365
                                        // Indicator that the file was binary
 
366
                                        if (text == null) {
 
367
                                                lines = new [] { " Binary files differ" };
348
368
                                        } else {
349
 
                                                string prevRevisionText = "";
350
 
                                                try {
351
 
                                                        prevRevisionText = info.Repository.GetTextAtRevision (path, prevRev);
352
 
                                                } catch (Exception e) {
353
 
                                                        // The file did not exist at this point in time, so just treat it as empty
 
369
                                                var changedDocument = new Mono.TextEditor.TextDocument (text);
 
370
                                                if (prevRev == null) {
 
371
                                                        lines = new string[changedDocument.LineCount];
 
372
                                                        for (int i = 0; i < changedDocument.LineCount; i++) {
 
373
                                                                lines[i] = "+ " + changedDocument.GetLineText (i + 1).TrimEnd ('\r','\n');
 
374
                                                        }
 
375
                                                } else {
 
376
                                                        string prevRevisionText = "";
 
377
                                                        try {
 
378
                                                                prevRevisionText = info.Repository.GetTextAtRevision (path, prevRev);
 
379
                                                        } catch (Exception e) {
 
380
                                                                // The file did not exist at this point in time, so just treat it as empty
 
381
                                                        }
 
382
                                                        
 
383
                                                        var originalDocument = new Mono.TextEditor.TextDocument (prevRevisionText);
 
384
                                                        originalDocument.FileName = "Revision " + prevRev.ToString ();
 
385
                                                        changedDocument.FileName = "Revision " + rev.ToString ();
 
386
                                                        lines = Mono.TextEditor.Utils.Diff.GetDiffString (originalDocument, changedDocument).Split ('\n');
354
387
                                                }
355
 
                                                
356
 
                                                var originalDocument = new Mono.TextEditor.TextDocument (prevRevisionText);
357
 
                                                originalDocument.FileName = "Revision " + prevRev.ToString ();
358
 
                                                changedDocument.FileName = "Revision " + rev.ToString ();
359
 
                                                lines = Mono.TextEditor.Utils.Diff.GetDiffString (originalDocument, changedDocument).Split ('\n');
360
388
                                        }
361
389
                                        Application.Invoke (delegate {
362
390
                                                changedpathstore.SetValue (iter, colDiff, lines);
473
501
                        if (img.LoadOperation.IsCompleted)
474
502
                                renderer.Pixbuf = img.Pixbuf;
475
503
                        else {
 
504
                                renderer.Pixbuf = null;
476
505
                                img.LoadOperation.Completed += delegate {
477
506
                                        Gtk.Application.Invoke (delegate {
478
507
                                                if (logstore.IterIsValid (iter))
588
617
                        labelRevision.Text = GettextCatalog.GetString ("revision: {0}", rev);
589
618
                        textviewDetails.Buffer.Text = d.Message;
590
619
                        
591
 
                        if (select)
 
620
                        if (select) {
592
621
                                treeviewFiles.Selection.SelectIter (selectIter);
 
622
                                treeviewFiles.ExpandRow (treeviewFiles.Model.GetPath (selectIter), true);
 
623
                        }
593
624
                }
594
625
                
595
626
                void UpdateHistory ()