protected override void Update(CommandArrayInfo info) { var files = DesktopService.RecentFiles.GetFiles(); if (files.Count == 0) { return; } int i = 0; foreach (var ri in files) { string acceleratorKeyPrefix = i < 10 ? "_" + ((i + 1) % 10).ToString() + " " : ""; var cmd = new CommandInfo(acceleratorKeyPrefix + ri.DisplayName.Replace("_", "__")) { Description = GettextCatalog.GetString("Open {0}", ri.FileName) }; Gdk.Pixbuf icon = DesktopService.GetPixbufForFile(ri.FileName, IconSize.Menu); #pragma warning disable 618 if (icon != null) { cmd.Icon = ImageService.GetStockId(icon, IconSize.Menu); } #pragma warning restore 618 info.Add(cmd, ri.FileName); i++; } }
protected virtual void OnTitleChanged(EventArgs e) { fileTypeCondition.SetFileName(content.ContentName ?? content.UntitledName); tab.Text = Title; tab.Notify = show_notification; tab.Dirty = content.IsDirty; if (content.ContentName != null && content.ContentName != "") { tab.Tooltip = content.ContentName; } try { if (content.StockIconId != null) { tab.Icon = ImageService.GetPixbuf(content.StockIconId, IconSize.Menu); } else if (content.ContentName != null && content.ContentName.IndexOfAny(new char[] { '*', '+' }) == -1) { tab.Icon = DesktopService.GetPixbufForFile(content.ContentName, Gtk.IconSize.Menu); } } catch (Exception ex) { LoggingService.LogError(ex.ToString()); tab.Icon = DesktopService.GetPixbufForType("gnome-fs-regular", Gtk.IconSize.Menu); } if (TitleChanged != null) { TitleChanged(this, e); } }
public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { ProjectFile file = (ProjectFile)dataObject; label = GLib.Markup.EscapeText(file.Link.IsNullOrEmpty ? file.FilePath.FileName : file.Link.FileName); if (!File.Exists(file.FilePath)) { label = "<span foreground='red'>" + label + "</span>"; } icon = DesktopService.GetPixbufForFile(file.FilePath, Gtk.IconSize.Menu); if (file.IsLink && icon != null) { var overlay = ImageService.GetPixbuf("md-link-overlay", Gtk.IconSize.Menu); var cached = Context.GetComposedIcon(icon, overlay); if (cached != null) { icon = cached; } else { var res = icon.Copy(); overlay.Composite(res, 0, 0, icon.Width, icon.Width, 0, 0, 1, 1, Gdk.InterpType.Bilinear, 255); Context.CacheComposedIcon(icon, overlay, res); icon = res; } } }
public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { ProjectFile file = (ProjectFile)dataObject; label = GLib.Markup.EscapeText(file.Link.IsNullOrEmpty ? file.FilePath.FileName : file.Link.FileName); if (!File.Exists(file.FilePath)) { label = "<span foreground='red'>" + label + "</span>"; } icon = DesktopService.GetPixbufForFile(file.FilePath, Gtk.IconSize.Menu); if (file.IsLink && icon != null) { icon = icon.Copy(); using (Gdk.Pixbuf overlay = Gdk.Pixbuf.LoadFromResource("Icons.16x16.LinkOverlay.png")) { overlay.Composite(icon, 0, 0, icon.Width, icon.Width, 0, 0, 1, 1, Gdk.InterpType.Bilinear, 255); } } }
public FileListItem(string fullname, string size, string lastModified) { this.size = size; this.lastModified = lastModified; //FIXME: This is because //home/blah is not the same as /home/blah according to Icon.LookupSync, if we get weird behaviours, lets look at this again, see if we still need it. FullName = fullname.Substring(1); icon = DesktopService.GetPixbufForFile(FullName, Gtk.IconSize.Menu); }
public FileListItem(string name) { FileInfo fi = new FileInfo(name); this.size = Math.Round((double)fi.Length / 1024).ToString() + " KB"; this.lastModified = fi.LastWriteTime.ToString(); FullName = System.IO.Path.GetFullPath(name); icon = DesktopService.GetPixbufForFile(FullName, Gtk.IconSize.Menu); }
void Populate() { store.Clear(); DirectoryInfo di = new DirectoryInfo(CurrentDir); try { DirectoryInfo[] dirs = di.GetDirectories(); foreach (DirectoryInfo d in dirs) { if (ignoreHidden) { if (!d.Name.StartsWith(".") && NotHidden(d.Name)) { store.AppendValues(DesktopService.GetPixbufForFile(System.IO.Path.Combine(CurrentDir, d.Name), Gtk.IconSize.Menu), d.Name); } } else { store.AppendValues(DesktopService.GetPixbufForFile(System.IO.Path.Combine(CurrentDir, d.Name), Gtk.IconSize.Menu), d.Name); } } if (init == true) { tv.Selection.SelectPath(new Gtk.TreePath("0")); } string[] filesaux = Directory.GetFiles(CurrentDir); files.Clear(); for (int cont = 0; cont < filesaux.Length; cont++) { if (ignoreHidden) { if (NotHidden(System.IO.Path.GetFileName(filesaux[cont]))) { files.Add(filesaux[cont]); } } else { files.Add(filesaux[cont]); } } } catch (System.UnauthorizedAccessException) { files.Clear(); store.Clear(); store.AppendValues(null, GettextCatalog.GetString("Access denied")); } catch (Exception ex) { string message = GettextCatalog.GetString("Could not access to directory: ") + CurrentDir; LoggingService.LogError(message, ex); MessageService.ShowException(ex, message); } }
public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { SolutionFolderFileNode file = (SolutionFolderFileNode)dataObject; label = file.FileName.FileName; if (!System.IO.File.Exists(file.FileName)) { label = "<span foreground='red'>" + label + "</span>"; } icon = DesktopService.GetPixbufForFile(file.FileName, Gtk.IconSize.Menu); }
TreeIter GetFile (Change change) { TextReplaceChange replaceChange = change as TextReplaceChange; if (replaceChange == null) return TreeIter.Zero; TreeIter result; if (!fileDictionary.TryGetValue (replaceChange.FileName, out result)) fileDictionary[replaceChange.FileName] = result = store.AppendValues (DesktopService.GetPixbufForFile (replaceChange.FileName, IconSize.Menu), System.IO.Path.GetFileName (replaceChange.FileName), null, true); return result; }
void FileIconDataFunc(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) { if (TreeIter.Zero.Equals(iter)) { return; } var fileNamePixbufRenderer = (CellRendererPixbuf)cell; var searchResult = (SearchResult)store.GetValue(iter, SearchResultColumn); if (searchResult == null) { return; } fileNamePixbufRenderer.Pixbuf = DesktopService.GetPixbufForFile(searchResult.FileName, IconSize.Menu); }
// FIXME: When the scrollbars of the directory list // are shown, and we perform a new dir action // the column is never edited, but Populate is called private void OnNewDir(object o, EventArgs args) { TreeIter iter; TreePath treepath; TreeViewColumn column; performingtask = PerformingTask.CreatingNew; text_render.Editable = true; iter = store.AppendValues(DesktopService.GetPixbufForFile(CurrentDir, Gtk.IconSize.Menu), "folder name"); treepath = tv.Model.GetPath(iter); column = tv.GetColumn(0); tv.SetCursor(treepath, column, true); }
void UpdateFileList(object sender, EventArgs args) { fileStore.Clear(); string pattern = defaultFilter.Patterns [0]; if (filters != null) { pattern = filters[fileTypeCombo.Active].Patterns [0]; } pattern = Regex.Escape(pattern); pattern = pattern.Replace("\\*", ".*"); pattern = pattern.Replace("\\?", "."); pattern = pattern.Replace("\\|", "$|^"); pattern = "^" + pattern + "$"; var regex = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase); string dir = GetSelectedDirectory().ToString(); foreach (ProjectFile pf in project.Files) { string pathStr = pf.FilePath.ToString(); if (pf.Subtype == Subtype.Directory || !pathStr.StartsWith(dir)) { continue; } int split = pathStr.LastIndexOf(System.IO.Path.DirectorySeparatorChar); if (split != dir.Length) { continue; } if (regex.IsMatch(pf.FilePath.FileName)) { fileStore.AppendValues(pf, DesktopService.GetPixbufForFile(pf.FilePath, Gtk.IconSize.Menu)); } } TreeIter root; if (fileStore.GetIterFirst(out root)) { fileList.Selection.SelectIter(root); } UpdateSensitivity(null, null); }
void TreeSelectionChanged(object o, EventArgs args) { int [] indices; Revision d = GetSelectedRev(out indices); revertButton.Sensitive = (d != null); revertToButton.Sensitive = ((d != null) && (indices.Length == 1) && //no sense to revert to *many* revs (indices [0] != 0)); //no sense to revert to *current* rev changedpathstore.Clear(); foreach (RevisionPath rp in d.ChangedFiles) { 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); changedpathstore.AppendValues(actionIcon, action, fileIcon, rp.Path); } }
TreeIter AppendFileInfo(VersionInfo n) { Gdk.Pixbuf statusicon = VersionControlService.LoadIconForStatus(n.Status); string lstatus = VersionControlService.GetStatusLabel(n.Status); Gdk.Pixbuf rstatusicon = VersionControlService.LoadIconForStatus(n.RemoteStatus); string rstatus = VersionControlService.GetStatusLabel(n.RemoteStatus); string scolor = n.HasLocalChanges && n.HasRemoteChanges ? "red" : null; string localpath = n.LocalPath.ToRelative(filepath); if (localpath.Length > 0 && localpath[0] == Path.DirectorySeparatorChar) { localpath = localpath.Substring(1); } if (localpath == "") { localpath = "."; } // not sure if this happens bool hasComment = GetCommitMessage(n.LocalPath).Length > 0; bool commit = changeSet.ContainsFile(n.LocalPath); Gdk.Pixbuf fileIcon; if (n.IsDirectory) { fileIcon = ImageService.GetPixbuf(MonoDevelop.Ide.Gui.Stock.ClosedFolder, Gtk.IconSize.Menu); } else { fileIcon = DesktopService.GetPixbufForFile(n.LocalPath, Gtk.IconSize.Menu); } TreeIter it = filestore.AppendValues(statusicon, lstatus, GLib.Markup.EscapeText(localpath).Split('\n'), rstatus, commit, false, n.LocalPath.ToString(), true, hasComment, fileIcon, n.HasLocalChanges, rstatusicon, scolor, n.HasRemoteChange(VersionStatus.Modified)); if (!n.IsDirectory) { filestore.AppendValues(it, statusicon, "", new string[0], "", false, true, n.LocalPath.ToString(), false, false, fileIcon, false, null, null, false); } return(it); }
void AddFile(string fileName) { string relativePath = FileService.AbsoluteToRelativePath(project.BaseDirectory, fileName); TreeIter iter = GetPath(System.IO.Path.GetDirectoryName(relativePath)); object[] values = new object[] { DesktopService.GetPixbufForFile(fileName, IconSize.Menu), null, System.IO.Path.GetFileName(fileName), fileName, false }; if (!store.IterIsValid(iter)) { store.AppendValues(values); return; } store.AppendValues(iter, values); }
void AddFile(FilePath filePath) { var relativePath = filePath.ToRelative(baseDirectory); TreeIter iter = GetPath(relativePath.ParentDirectory); object[] values = new object[] { //FIXME: look these pixbufs up lazily in the renderer DesktopService.GetPixbufForFile(filePath, IconSize.Menu), null, filePath.FileName, filePath.ToString(), false }; if (iter.Equals(TreeIter.Zero)) { store.AppendValues(values); return; } store.AppendValues(iter, values); }
public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { SystemFile file = (SystemFile)dataObject; label = file.Name; icon = DesktopService.GetPixbufForFile(file.Path, Gtk.IconSize.Menu); if (file.ShowTransparent) { Gdk.Pixbuf gicon = Context.GetComposedIcon(icon, "fade"); if (gicon == null) { gicon = ImageService.MakeTransparent(icon, 0.5); Context.CacheComposedIcon(icon, "fade", gicon); } icon = gicon; label = "<span foreground='dimgrey'>" + label + "</span>"; } }
protected virtual void OnTitleChanged(EventArgs e) { fileTypeCondition.SetFileName(content.ContentName ?? content.UntitledName); if (show_notification) { tabLabel.Label.Markup = "<span foreground=\"blue\">" + Title + "</span>"; tabLabel.Label.UseMarkup = true; } else { tabLabel.Label.Text = Title; tabLabel.Label.UseMarkup = false; } if (content.ContentName != null && content.ContentName != "") { tabLabel.SetTooltip(content.ContentName, content.ContentName); } try { if (content.StockIconId != null) { tabLabel.Icon = new Gtk.Image((IconId)content.StockIconId, IconSize.Menu); } else if (content.ContentName != null && content.ContentName.IndexOfAny(new char[] { '*', '+' }) == -1) { tabLabel.Icon.Pixbuf = DesktopService.GetPixbufForFile(content.ContentName, Gtk.IconSize.Menu); } } catch (Exception ex) { LoggingService.LogError(ex.ToString()); tabLabel.Icon.Pixbuf = DesktopService.GetPixbufForType("gnome-fs-regular", Gtk.IconSize.Menu); } if (TitleChanged != null) { TitleChanged(this, e); } }
protected override void Update(CommandArrayInfo info) { RecentOpen recentOpen = IdeApp.Workbench.RecentOpen; if (recentOpen.RecentFilesCount > 0) { int i = 0; foreach (RecentItem ri in recentOpen.RecentFiles) { string accelaratorKeyPrefix = i < 10 ? "_" + ((i + 1) % 10).ToString() + " " : ""; string label = ((ri.Private == null || ri.Private.Length < 1) ? Path.GetFileName(ri.ToString()) : ri.Private); CommandInfo cmd = new CommandInfo(accelaratorKeyPrefix + label.Replace("_", "__")); cmd.Description = GettextCatalog.GetString("Open {0}", ri.ToString()); Gdk.Pixbuf icon = DesktopService.GetPixbufForFile(ri.ToString(), IconSize.Menu); if (icon != null) { cmd.Icon = ImageService.GetStockId(icon, IconSize.Menu); } info.Add(cmd, ri); i++; } } }
public ConfirmProjectDeleteDialog(IWorkspaceFileObject item) { this.Build(); this.item = item; store = new TreeStore(typeof(bool), typeof(Gdk.Pixbuf), typeof(string), typeof(string), typeof(string)); fileList.Model = store; TreeViewColumn col = new TreeViewColumn(); CellRendererToggle crt = new CellRendererToggle(); crt.Toggled += CrtToggled; col.PackStart(crt, false); col.AddAttribute(crt, "active", 0); CellRendererPixbuf crp = new CellRendererPixbuf(); col.PackStart(crp, false); col.AddAttribute(crp, "pixbuf", 1); CellRendererText cre = new CellRendererText(); col.PackStart(cre, true); col.AddAttribute(cre, "text", 2); col.AddAttribute(cre, "foreground", 4); fileList.AppendColumn(col); store.SetSortColumnId(2, SortType.Ascending); labelProjectDir.Text = item.BaseDirectory.FullPath; HashSet <string> itemFiles = new HashSet <string> (); HashSet <string> knownPaths = new HashSet <string> (); foreach (FilePath file in item.GetItemFiles(true)) { itemFiles.Add(file.FullPath); knownPaths.Add(file.FullPath + "~"); } foreach (string ext in knownExtensions) { knownPaths.Add(item.FileName.ChangeExtension(ext)); } FillDirRec(TreeIter.Zero, item, itemFiles, knownPaths, item.BaseDirectory, false); if (item.BaseDirectory != item.ItemDirectory) { // If the project has a custom base directory, make sure the project files // from the item directory are shown in the list foreach (FilePath f in item.GetItemFiles(false)) { if (!f.IsChildPathOf(item.BaseDirectory)) { Gdk.Pixbuf pix = DesktopService.GetPixbufForFile(f, IconSize.Menu); paths [f] = store.AppendValues(true, pix, f.FileName, f.ToString()); } } } if (item is SolutionItem) { var sol = ((SolutionItem)item).ParentSolution; var bdir = item.BaseDirectory; if (sol.GetItemFiles(false).Any(f => f.IsChildPathOf(bdir)) || sol.GetAllSolutionItems <SolutionEntityItem> ().Any(it => it != item && it.GetItemFiles(true).Any(f => f.IsChildPathOf(bdir)))) { radioDeleteAll.Sensitive = false; labelProjectDir.Text = GettextCatalog.GetString("Project directory can't be deleted since it contains files from other projects or solutions"); } } if (item.BaseDirectory.FileName == item.Name && radioDeleteAll.Sensitive) { radioDeleteAll.Active = true; fileList.Sensitive = false; } else { radioDeleteSel.Active = true; Focus = radioDeleteSel; } }
ChildInfo FillDirRec(Gtk.TreeIter iter, IWorkspaceFileObject item, HashSet <string> itemFiles, HashSet <string> knownPaths, FilePath dir, bool forceSet) { ChildInfo cinfo = ChildInfo.AllSelected; bool hasChildren = false; foreach (string sd in knownSubdirs) { if (dir == item.BaseDirectory.Combine(sd)) { forceSet = true; break; } } TreeIter dit; if (!iter.Equals(TreeIter.Zero)) { dit = store.AppendValues(iter, false, DesktopService.GetPixbufForFile(dir, IconSize.Menu), dir.FileName.ToString(), dir.ToString()); fileList.ExpandRow(store.GetPath(iter), false); } else { dit = store.AppendValues(false, DesktopService.GetPixbufForFile(dir, IconSize.Menu), dir.FileName.ToString(), dir.ToString()); } paths [dir] = dit; foreach (string file in Directory.GetFiles(dir)) { string path = System.IO.Path.GetFileName(file); Gdk.Pixbuf pix = DesktopService.GetPixbufForFile(file, IconSize.Menu); bool active = itemFiles.Contains(file); string color = null; if (!active) { pix = ImageService.MakeTransparent(pix, 0.5); color = "dimgrey"; } else { cinfo |= ChildInfo.HasProjectFiles; } active = active || forceSet || knownPaths.Contains(file); if (!active) { cinfo &= ~ChildInfo.AllSelected; } else { cinfo |= ChildInfo.SomeSelected; } paths [file] = store.AppendValues(dit, active, pix, path, file, color); if (!hasChildren) { hasChildren = true; fileList.ExpandRow(store.GetPath(dit), false); } } foreach (string cdir in Directory.GetDirectories(dir)) { hasChildren = true; ChildInfo ci = FillDirRec(dit, item, itemFiles, knownPaths, cdir, forceSet); if ((ci & ChildInfo.AllSelected) == 0) { cinfo &= ~ChildInfo.AllSelected; } cinfo |= ci & (ChildInfo.SomeSelected | ChildInfo.HasProjectFiles); } if ((cinfo & ChildInfo.AllSelected) != 0 && hasChildren) { store.SetValue(dit, 0, true); } if ((cinfo & ChildInfo.HasProjectFiles) == 0) { Gdk.Pixbuf pix = DesktopService.GetPixbufForFile(dir, IconSize.Menu); pix = ImageService.MakeTransparent(pix, 0.5); store.SetValue(dit, 1, pix); store.SetValue(dit, 4, "dimgrey"); } if ((cinfo & ChildInfo.SomeSelected) != 0 && (cinfo & ChildInfo.AllSelected) == 0) { fileList.ExpandRow(store.GetPath(dit), false); } else { fileList.CollapseRow(store.GetPath(dit)); } return(cinfo); }
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); } }