Exemplo n.º 1
0
        void TreeSelectionChanged(object o, EventArgs args)
        {
            Revision d = SelectedRevision;

            changedpathstore.Clear();
            textviewDetails.Buffer.Clear();

            if (d == null)
            {
                return;
            }
            Gtk.TreeIter selectIter = Gtk.TreeIter.Zero;
            bool         select     = false;

            foreach (RevisionPath rp in info.Repository.GetRevisionChanges(d))
            {
                Gdk.Pixbuf actionIcon;
                string     action = null;
                if (rp.Action == RevisionAction.Add)
                {
                    action     = GettextCatalog.GetString("Add");
                    actionIcon = ImageService.GetPixbuf(Gtk.Stock.Add, Gtk.IconSize.Menu);
                }
                else if (rp.Action == RevisionAction.Delete)
                {
                    action     = GettextCatalog.GetString("Delete");
                    actionIcon = ImageService.GetPixbuf(Gtk.Stock.Remove, Gtk.IconSize.Menu);
                }
                else if (rp.Action == RevisionAction.Modify)
                {
                    action     = GettextCatalog.GetString("Modify");
                    actionIcon = ImageService.GetPixbuf("gtk-edit", Gtk.IconSize.Menu);
                }
                else if (rp.Action == RevisionAction.Replace)
                {
                    action     = GettextCatalog.GetString("Replace");
                    actionIcon = ImageService.GetPixbuf("gtk-edit", Gtk.IconSize.Menu);
                }
                else
                {
                    action     = rp.ActionDescription;
                    actionIcon = ImageService.GetPixbuf(MonoDevelop.Ide.Gui.Stock.Empty, Gtk.IconSize.Menu);
                }
                Gdk.Pixbuf fileIcon = DesktopService.GetPixbufForFile(rp.Path, Gtk.IconSize.Menu);
                var        iter     = changedpathstore.AppendValues(actionIcon, action, fileIcon, System.IO.Path.GetFileName(rp.Path), System.IO.Path.GetDirectoryName(rp.Path), rp.Path, null);
                changedpathstore.AppendValues(iter, null, null, null, null, null, rp.Path, null);
                if (rp.Path == preselectFile)
                {
                    selectIter = iter;
                    select     = true;
                }
            }
            if (!string.IsNullOrEmpty(d.Email))
            {
                imageUser.Show();
                imageUser.LoadUserIcon(d.Email, 32);
            }
            else
            {
                imageUser.Hide();
            }

            labelAuthor.Text = d.Author;
            labelDate.Text   = d.Time.ToString();
            string rev = d.Name;

            if (rev.Length > 15)
            {
                currentRevisionShortened = true;
                rev = d.ShortName;
            }
            else
            {
                currentRevisionShortened = false;
            }

            labelRevision.Text          = GettextCatalog.GetString("revision: {0}", rev);
            textviewDetails.Buffer.Text = d.Message;

            if (select)
            {
                treeviewFiles.Selection.SelectIter(selectIter);
                treeviewFiles.ExpandRow(treeviewFiles.Model.GetPath(selectIter), true);
            }
        }
Exemplo n.º 2
0
        void TreeSelectionChanged(object o, EventArgs args)
        {
            Revision d = SelectedRevision;

            changedpathstore.Clear();
            textviewDetails.Buffer.Clear();
            if (d == null)
            {
                return;
            }

            changedpathstore.AppendValues(null, null, null, GettextCatalog.GetString("Retrieving history…"), null, null, null);

            selectionCancellationTokenSource.Cancel();
            selectionCancellationTokenSource = new CancellationTokenSource();
            var token = selectionCancellationTokenSource.Token;

            Task.Run(async() => await info.Repository.GetRevisionChangesAsync(d, token)).ContinueWith(result => {
                if (IsDestroyed)
                {
                    return;
                }
                changedpathstore.Clear();
                revertButton.GetNativeWidget <Gtk.Widget> ().Sensitive = revertToButton.GetNativeWidget <Gtk.Widget> ().Sensitive = true;
                Gtk.TreeIter selectIter = Gtk.TreeIter.Zero;
                bool select             = false;
                foreach (RevisionPath rp in result.Result)
                {
                    Xwt.Drawing.Image actionIcon;
                    string action = null;
                    if (rp.Action == RevisionAction.Add)
                    {
                        action     = GettextCatalog.GetString("Add");
                        actionIcon = ImageService.GetIcon(Gtk.Stock.Add, Gtk.IconSize.Menu);
                    }
                    else if (rp.Action == RevisionAction.Delete)
                    {
                        action     = GettextCatalog.GetString("Delete");
                        actionIcon = ImageService.GetIcon(Gtk.Stock.Remove, Gtk.IconSize.Menu);
                    }
                    else if (rp.Action == RevisionAction.Modify)
                    {
                        action     = GettextCatalog.GetString("Modify");
                        actionIcon = ImageService.GetIcon("gtk-edit", Gtk.IconSize.Menu);
                    }
                    else if (rp.Action == RevisionAction.Replace)
                    {
                        action     = GettextCatalog.GetString("Replace");
                        actionIcon = ImageService.GetIcon("gtk-edit", Gtk.IconSize.Menu);
                    }
                    else
                    {
                        action     = rp.ActionDescription;
                        actionIcon = ImageService.GetIcon(MonoDevelop.Ide.Gui.Stock.Empty, Gtk.IconSize.Menu);
                    }
                    Xwt.Drawing.Image fileIcon = IdeServices.DesktopService.GetIconForFile(rp.Path, Gtk.IconSize.Menu);
                    var iter = changedpathstore.AppendValues(actionIcon, action, fileIcon, System.IO.Path.GetFileName(rp.Path), System.IO.Path.GetDirectoryName(rp.Path), rp.Path, null);
                    changedpathstore.AppendValues(iter, null, null, null, null, null, rp.Path, null);
                    if (rp.Path == preselectFile)
                    {
                        selectIter = iter;
                        select     = true;
                    }
                }
                if (!string.IsNullOrEmpty(d.Email))
                {
                    imageUser.Show();
                    imageUser.LoadUserIcon(d.Email, 32);
                }
                else
                {
                    imageUser.Hide();
                }

                labelAuthor.Text = d.Author;
                labelDate.Text   = d.Time.ToString();
                string rev       = d.Name;
                if (rev.Length > 15)
                {
                    currentRevisionShortened = true;
                    rev = d.ShortName;
                }
                else
                {
                    currentRevisionShortened = false;
                }

                labelRevision.Text          = GettextCatalog.GetString("Revision: {0}", rev);
                textviewDetails.Buffer.Text = d.Message;

                if (select)
                {
                    treeviewFiles.Selection.SelectIter(selectIter);
                    treeviewFiles.ExpandRow(treeviewFiles.Model.GetPath(selectIter), true);
                }
            }, token, TaskContinuationOptions.OnlyOnRanToCompletion, Runtime.MainTaskScheduler);
        }