// Adds the CmisSync folder to the user's // list of bookmarked places public override void AddToBookmarks() { string bookmarks_file_path = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.Personal), ".gtk-bookmarks"); // newer nautilus version using a different path then older ones string bookmarks_file_path_gtk3 = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.Personal), ".config", "gtk-3.0", "bookmarks"); // if the new path is found, take the new one, otherwise the old one if (File.Exists(bookmarks_file_path_gtk3)) { bookmarks_file_path = bookmarks_file_path_gtk3; } string cmissync_bookmark = "file://" + FoldersPath.Replace(" ", "%20"); if (File.Exists(bookmarks_file_path)) { string bookmarks = File.ReadAllText(bookmarks_file_path); if (!bookmarks.Contains(cmissync_bookmark)) { File.AppendAllText(bookmarks_file_path, cmissync_bookmark); } } else { File.WriteAllText(bookmarks_file_path, cmissync_bookmark); } }
private async void RemoveFiles() { var dialog = new MetroDialogSettings { AffirmativeButtonText = "OK" }; var result = await _mainWindow.ShowMessageAsync("Please confirm", "Are you sure you want to remove this files?", MessageDialogStyle.AffirmativeAndNegative, dialog); if (result == MessageDialogResult.Affirmative) { var selectedLocations = MultiTermLocationCollection.Where(s => s.IsSelected).ToList(); var controller = await _mainWindow.ShowProgressAsync("Please wait...", "We are removing selected files"); controller.SetIndeterminate(); var locationsToClear = new List <string>(); controller.SetIndeterminate(); var selectedMultiTermVersions = MultiTermVersionsCollection.Where(s => s.IsSelected).ToList(); var selectedMultiTermLocations = MultiTermLocationCollection.Where(f => f.IsSelected).ToList(); if (selectedMultiTermVersions.Any()) { var documentsFolderLocation = await FoldersPath.GetMultiTermFoldersPath(_userName, selectedMultiTermVersions, selectedMultiTermLocations); locationsToClear.AddRange(documentsFolderLocation); } //to close the message //await controller.CloseAsync(); } }
private async void RemoveFiles() { var dialog = new MetroDialogSettings { AffirmativeButtonText = "OK" }; var result = await _mainWindow.ShowMessageAsync("Please confirm", "Are you sure you want to remove this files?", MessageDialogStyle.AffirmativeAndNegative, dialog); if (result == MessageDialogResult.Affirmative) { if (!MultiTermIsRunning()) { var controller = await _mainWindow.ShowProgressAsync("Please wait...", "We are removing selected files"); controller.SetIndeterminate(); var foldersToClearOrRestore = new List <LocationDetails>(); controller.SetIndeterminate(); var selectedMultiTermVersions = MultiTermVersionsCollection.Where(s => s.IsSelected).ToList(); var selectedMultiTermLocations = MultiTermLocationCollection.Where(f => f.IsSelected).ToList(); if (selectedMultiTermVersions.Any()) { var documentsFolderLocation = await FoldersPath.GetMultiTermFoldersPath(_userName, selectedMultiTermVersions, selectedMultiTermLocations); foldersToClearOrRestore.AddRange(documentsFolderLocation); } //save settings _persistence.SaveSettings(foldersToClearOrRestore, false); await Remove.BackupFiles(foldersToClearOrRestore); await Remove.FromSelectedLocations(foldersToClearOrRestore); //to close the message await controller.CloseAsync(); } else { await _mainWindow.ShowMessageAsync("MultiTerm is running", "Please close MultiTerm in order to remove selected folders.", MessageDialogStyle.Affirmative, dialog); } } }
// Creates the CmisSync folder in the user's home folder public override bool CreateCmisSyncFolder() { if (!Directory.Exists(FoldersPath)) { Directory.CreateDirectory(FoldersPath); Logger.Info("Created '" + FoldersPath + "'"); string iconName = "folder-cmissync.png"; string iconSrc = Path.Combine(Defines.ASSETS_DIR, "icons", "hicolor", "256x256", "places", iconName); string iconDst = Path.Combine(FoldersPath, iconName); if (File.Exists(iconSrc)) { File.Copy(iconSrc, iconDst); } string gvfs_command_path = Path.Combine( Path.VolumeSeparatorChar.ToString(), "usr", "bin", "gvfs-set-attribute"); // Add a special icon to the CmisSync folder if (File.Exists(gvfs_command_path)) { Process process = new Process(); process.StartInfo.UseShellExecute = false; process.StartInfo.FileName = "gvfs-set-attribute"; // Clear the custom (legacy) icon path process.StartInfo.Arguments = "-t unset \"" + FoldersPath.Replace(" ", "\\ ") + "\" metadata::custom-icon"; process.Start(); process.WaitForExit(); // Give the CmisSync folder an icon name, so that it scales process.StartInfo.Arguments = FoldersPath.Replace(" ", "\\ ") + " metadata::custom-icon-name 'folder-cmissync'"; process.Start(); process.WaitForExit(); if (File.Exists(iconDst)) { process.StartInfo.Arguments = FoldersPath.Replace(" ", "\\ ") + " metadata::custom-icon 'folder-cmissync.png'"; process.Start(); process.WaitForExit(); } } string kde_directory_path = Path.Combine(FoldersPath, ".directory"); string kde_directory_content = "[Desktop Entry]\nIcon=folder-cmissync\n"; try { File.WriteAllText(kde_directory_path, kde_directory_content); } catch (IOException e) { Logger.Info("Config | Failed setting kde icon for '" + FoldersPath + "': " + e.Message); } return(true); } return(false); }