public string ChoosePath() { string path = null; CompatFileChooserDialog file_selector = new CompatFileChooserDialog("Import", this.Dialog, CompatFileChooserDialog.Action.SelectFolder); file_selector.SelectMultiple = false; if (ImportPath != null) { file_selector.Filename = ImportPath; } else { file_selector.Filename = FSpot.Global.HomeDirectory; } int response = file_selector.Run(); if ((ResponseType)response == ResponseType.Ok) { path = file_selector.Filename; } file_selector.Destroy(); return(path); }
private void OnSongDirSelected(object o, EventArgs args) { CompatFileChooserDialog fcdlg; fcdlg = new CompatFileChooserDialog("Select Song Folder...", null, CompatFileChooserDialog.Action.SelectFolder); if (fcdlg.Run() == (int)ResponseType.Ok) { songdirentry.Text = fcdlg.Filename; } fcdlg.Destroy(); }
public string ChoosePath () { string path = null; CompatFileChooserDialog file_selector = new CompatFileChooserDialog ("Import", this.Dialog, CompatFileChooserDialog.Action.SelectFolder); file_selector.SelectMultiple = false; if (ImportPath != null) file_selector.Filename = ImportPath; else file_selector.Filename = FSpot.Global.HomeDirectory; int response = file_selector.Run (); if ((ResponseType) response == ResponseType.Ok) { path = file_selector.Filename; } file_selector.Destroy (); return path; }
private void SaveLog() { int rc = 0; bool saveFile = true; string filename = null; string initialPath = Util.LastSavedSyncLogPath; CompatFileChooserDialog cfcd = new CompatFileChooserDialog( Util.GS("Save iFolder Log..."), this, CompatFileChooserDialog.Action.Save); if (initialPath != null) cfcd.CurrentFolder = initialPath; while (saveFile) { rc = cfcd.Run(); cfcd.Hide(); if(rc == -5) { filename = cfcd.Selections[0]; if(File.Exists(filename)) { iFolderMsgDialog dialog = new iFolderMsgDialog( this, iFolderMsgDialog.DialogType.Question, iFolderMsgDialog.ButtonSet.YesNo, "", Util.GS("Overwrite the existing file?"), Util.GS("The file you selected exists. Selecting yes will overwrite the contents of this file.")); rc = dialog.Run(); dialog.Hide(); dialog.Destroy(); if(rc != -8) saveFile = false; } } else break; if(saveFile) { FileStream fs = null; try { fs = File.Create(filename); } catch (System.UnauthorizedAccessException uae) { iFolderMsgDialog dg = new iFolderMsgDialog( this, iFolderMsgDialog.DialogType.Error, iFolderMsgDialog.ButtonSet.Ok, "", Util.GS("Insufficient access"), Util.GS("You do not have access to save the file in the location you specified. Please select a different location.")); dg.Run(); dg.Hide(); dg.Destroy(); continue; } catch (Exception e) { iFolderMsgDialog dg = new iFolderMsgDialog( this, iFolderMsgDialog.DialogType.Error, iFolderMsgDialog.ButtonSet.Ok, "", Util.GS("Error saving the log file"), string.Format(Util.GS("An exception occurred trying to save the log: {0}"), e.Message), e.StackTrace); dg.Run(); dg.Hide(); dg.Destroy(); continue; } if(fs != null) { TreeIter iter; StreamWriter w = new StreamWriter(fs); if(LogTreeStore.GetIterFirst(out iter)) { string logEntry = (string)LogTreeStore.GetValue(iter, 0); w.WriteLine(logEntry); while(LogTreeStore.IterNext(ref iter)) { logEntry = (string)LogTreeStore.GetValue(iter, 0); w.WriteLine(logEntry); } } w.Close(); Util.LastSavedSyncLogPath = filename; break; } else { iFolderMsgDialog dg = new iFolderMsgDialog( this, iFolderMsgDialog.DialogType.Error, iFolderMsgDialog.ButtonSet.Ok, "", Util.GS("Error saving the log file"), Util.GS("The iFolder Client experienced an error trying to save the log. Please report this bug.")); dg.Run(); dg.Hide(); dg.Destroy(); } } } cfcd.Destroy(); }
void on_btn_browse_clicked(object o, EventArgs args) { CompatFileChooserDialog dlg_file_chooser = new CompatFileChooserDialog (Mono.Posix.Catalog.GetString ("Open"), wnd_main, 0); if (dlg_file_chooser.Run () == (int) ResponseType.Ok) entry_application_path_val.Text = dlg_file_chooser.Filename; dlg_file_chooser.Destroy (); }
private void OnAddIncludeClicked (object o, EventArgs args) { CompatFileChooserDialog fs_dialog = new CompatFileChooserDialog (Catalog.GetString ("Select Path"), settings_dialog, CompatFileChooserDialog.Action.SelectFolder); fs_dialog.SelectMultiple = false; ResponseType fs_response = (ResponseType) fs_dialog.Run (); string new_include = fs_dialog.Filename; fs_dialog.Destroy (); if (fs_response == ResponseType.Ok) { string error_message = ""; bool throw_error = false; ArrayList obsolete_includes = new ArrayList (); // Check and see if the current data collides with the new path in any way // FIXME: Do this with System.IO.Path or something foreach (string old_include in include_view.Includes) { if (new_include == old_include) { throw_error = true; error_message = Catalog.GetString ("The selected path is already selected for indexing and wasn't added."); } else if (new_include.StartsWith (old_include + System.IO.Path.PathSeparator)) { throw_error = true; error_message = Catalog.GetString ("The selected path wasn't added. The list contains items that supersedes it and the data is already being indexed."); } else if (old_include.StartsWith (new_include + System.IO.Path.PathSeparator)) { obsolete_includes.Add (old_include); } } if (throw_error) { HigMessageDialog.RunHigMessageDialog (settings_dialog, DialogFlags.Modal, MessageType.Warning, ButtonsType.Ok, Catalog.GetString ("Path not added"), error_message); } else { // Confirm the removal of obsolete includes if (obsolete_includes.Count != 0) { HigMessageDialog dialog = new HigMessageDialog (settings_dialog, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo, Catalog.GetString ("Remove obsolete paths"), Catalog.GetString ("Adding this path will obsolete some of the existing include paths. " + "This will result in the removal of the old obsolete paths. Do you still wish to add it?")); ResponseType confirm_response = (ResponseType) dialog.Run (); if (confirm_response != ResponseType.Yes) return; foreach (string obsolete_include in obsolete_includes) include_view.RemovePath (obsolete_include); dialog.Destroy (); } include_view.AddPath (new_include); } } }
private void OnBrowseButtonClicked (object o, EventArgs args) { switch (Type) { case ExcludeType.Path: CompatFileChooserDialog fs_dialog = new CompatFileChooserDialog (Catalog.GetString ("Select Folder"), add_exclude_dialog, CompatFileChooserDialog.Action.SelectFolder); fs_dialog.SelectMultiple = false; ResponseType response = (ResponseType) fs_dialog.Run (); if (response == ResponseType.Ok) value_entry.Text = fs_dialog.Filename; fs_dialog.Destroy (); break; case ExcludeType.MailFolder: MailFolderDialog mf_dialog = new MailFolderDialog (add_exclude_dialog); mf_dialog.ExcludeItemAddedEvent += new ExcludeItemAddedHandler (OnExcludeItemAdded); break; } }
private void OnSongDirSelected( object o, EventArgs args ) { CompatFileChooserDialog fcdlg; fcdlg = new CompatFileChooserDialog( "Select Song Folder...", null, CompatFileChooserDialog.Action.SelectFolder ); if( fcdlg.Run() == (int)ResponseType.Ok ) { songdirentry.Text = fcdlg.Filename; } fcdlg.Destroy(); }