~ubuntu-branches/ubuntu/saucy/monodevelop/saucy-proposed

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2010-09-10 16:54:48 UTC
  • mfrom: (19.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20100910165448-0rybfk25zd4o9431
Tags: 2.4+dfsg-2
* debian/patches/inject_Mono.Debugger.Soft_source.patch,
  debian/patches/use_system_Mono.Debugger.Soft.patch,
  debian/control:
  + Build against system Soft Debugger, since we now have a new
    enough Mono to match MonoDevelop's required API

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
using System;
2
 
using System.Collections;
3
2
using System.IO;
4
 
 
5
3
using Gtk;
6
 
 
7
 
using MonoDevelop.Components;
8
4
using MonoDevelop.Core;
9
 
using MonoDevelop.Core.Gui;
10
5
using MonoDevelop.Ide.Gui;
 
6
using MonoDevelop.Ide;
11
7
 
12
8
namespace MonoDevelop.VersionControl.Views
13
9
{
64
60
                                if (history == null)
65
61
                                        return;
66
62
                                LogView d = new LogView (filepath, isDirectory, history, vc);
67
 
                                MonoDevelop.Ide.Gui.IdeApp.Workbench.OpenDocument (d, true);
 
63
                                IdeApp.Workbench.OpenDocument (d, true);
68
64
                        }
69
65
                }
70
66
                
94
90
                        commandbar.IconSize = Gtk.IconSize.Menu;
95
91
                        box.PackStart (commandbar, false, false, 0);
96
92
                                
97
 
                        if (!isDirectory && vinfo != null) {
 
93
                        if (vinfo != null) {
98
94
                                Gtk.ToolButton button = new Gtk.ToolButton (new Gtk.Image ("vc-diff", Gtk.IconSize.Menu), GettextCatalog.GetString ("View Changes"));
99
95
                                button.IsImportant = true;
100
 
                                button.Clicked += new EventHandler (DiffButtonClicked);
101
 
                                commandbar.Insert (button, -1);
102
 
                                
103
 
                                button = new Gtk.ToolButton (new Gtk.Image (Gtk.Stock.Open, Gtk.IconSize.Menu), GettextCatalog.GetString ("View File"));
104
 
                                button.IsImportant = true;
105
 
                                button.Clicked += new EventHandler (ViewTextButtonClicked);
106
 
                                commandbar.Insert (button, -1);
 
96
                                if (isDirectory) {
 
97
                                        button.Clicked += new EventHandler (DirDiffButtonClicked);
 
98
                                        commandbar.Insert (button, -1);
 
99
                                } else {
 
100
                                        button.Clicked += new EventHandler (DiffButtonClicked);
 
101
                                        commandbar.Insert (button, -1);
 
102
                                        
 
103
                                        button = new Gtk.ToolButton (new Gtk.Image (Gtk.Stock.Open, Gtk.IconSize.Menu), GettextCatalog.GetString ("View File"));
 
104
                                        button.IsImportant = true;
 
105
                                        button.Clicked += new EventHandler (ViewTextButtonClicked);
 
106
                                        commandbar.Insert (button, -1);
 
107
                                }
107
108
                        }
108
109
                        
109
110
                        revertButton = new Gtk.ToolButton (new Gtk.Image ("vc-revert-command", Gtk.IconSize.Menu), GettextCatalog.GetString ("Revert changes from this revision"));
179
180
                        
180
181
                        TreeViewColumn colOperation = new TreeViewColumn ();
181
182
                        CellRendererText crt = new CellRendererText ();
182
 
                        CellRendererPixbuf crp = new CellRendererPixbuf ();
 
183
                        var crp = new CellRendererPixbuf ();
183
184
                        colOperation.Title = GettextCatalog.GetString ("Operation");
184
185
                        colOperation.PackStart (crp, false);
185
186
                        colOperation.PackStart (crt, true);
251
252
                                        actionIcon = ImageService.GetPixbuf ("gtk-edit", Gtk.IconSize.Menu);
252
253
                                } else {
253
254
                                        action = rp.ActionDescription;
254
 
                                        actionIcon = ImageService.GetPixbuf (MonoDevelop.Core.Gui.Stock.Empty, Gtk.IconSize.Menu);
 
255
                                        actionIcon = ImageService.GetPixbuf (MonoDevelop.Ide.Gui.Stock.Empty, Gtk.IconSize.Menu);
255
256
                                }
256
257
                                
257
258
                                Gdk.Pixbuf fileIcon = DesktopService.GetPixbufForFile (rp.Path, Gtk.IconSize.Menu);
266
267
                        new DiffWorker (Path.GetFileName (filepath), vc, vinfo.RepositoryPath, d).Start ();
267
268
                }
268
269
                
 
270
                void DirDiffButtonClicked (object src, EventArgs args) {
 
271
                        Revision d = GetSelectedRev ();
 
272
                        if (d == null)
 
273
                                return;
 
274
                        new DirectoryDiffWorker (filepath, vc, d).Start ();
 
275
                }
 
276
                
269
277
                void ViewTextButtonClicked (object src, EventArgs args) {
270
278
                        Revision d = GetSelectedRev ();
271
279
                        if (d == null)
342
350
                        }
343
351
                }
344
352
                
 
353
                /// Background worker to create a revision-specific diff for a directory
 
354
                internal class DirectoryDiffWorker: Task
 
355
                {
 
356
                        FilePath path;
 
357
                        Repository repo;
 
358
                        Revision revision;
 
359
                        string name;
 
360
                        string patch;
 
361
                        
 
362
                        public DirectoryDiffWorker (FilePath path, Repository repo, Revision revision)
 
363
                        {
 
364
                                this.path = path;
 
365
                                name = string.Format ("{0} (revision {1})", path.FileName, revision);
 
366
                                this.repo = repo;
 
367
                                this.revision = revision;
 
368
                        }
 
369
                        
 
370
                        protected override string GetDescription ()
 
371
                        {
 
372
                                return GettextCatalog.GetString ("Retrieving changes in {0} ...", name, revision);
 
373
                        }
 
374
                        
 
375
                        
 
376
                        protected override void Run ()
 
377
                        {
 
378
                                DiffInfo[] diffs = repo.PathDiff (path, revision.GetPrevious (), revision);
 
379
                                patch = repo.CreatePatch (diffs);
 
380
                        }
 
381
                        
 
382
                        protected override void Finished ()
 
383
                        {
 
384
                                if (patch != null)
 
385
                                        IdeApp.Workbench.NewDocument (name, "text/x-diff", patch);
 
386
                        }
 
387
                }
 
388
                
345
389
        }
346
390
 
347
391
        internal class HistoricalFileView
350
394
                        string mimeType = DesktopService.GetMimeTypeForUri (file);
351
395
                        if (mimeType == null || mimeType.Length == 0)
352
396
                                mimeType = "text/plain";
353
 
                        Document doc = MonoDevelop.Ide.Gui.IdeApp.Workbench.NewDocument (name, mimeType, text);
 
397
                        Document doc = IdeApp.Workbench.NewDocument (name, mimeType, text);
354
398
                        doc.IsDirty = false;
355
399
                }
356
400