SavePreferences() 공개 메소드

public SavePreferences ( ) : void
리턴 void
예제 #1
0
        /// <summary>
        /// Called when the user chooses "Export All" from the menu, allows user to select destination via GUI.
        /// </summary>
        /// <param name="sender">
        void ExportAllNotesViaGUI()
        {
            Logger.Info("Activated export all to " + export_type_pretty_name);
            exporting_single_notebook = false;

            //Opens the folder selection dialog
            ExportMultipleDialog dialog =
                new ExportMultipleDialog(String.Format(Catalog.GetString("All Notes {0} Export"), export_type_pretty_name), export_type_pretty_name);
            int response = dialog.Run();

            if (response != (int)Gtk.ResponseType.Ok)
            {
                Logger.Debug("User clicked cancel.");
                dialog.Destroy();
                return;
            }
            string output_folder = SanitizePath(dialog.Filename);

            try {
                ExportAllNotes(output_folder);

                //Successful export: clean up and inform.
                dialog.SavePreferences();
                ShowSuccessDialog(output_folder);
            } catch (UnauthorizedAccessException) {
                Logger.Error(Catalog.GetString("Could not export, access denied."));
                ShowErrorDialog(output_folder, dialog,
                                Catalog.GetString("Access denied."));
                return;
            } catch (DirectoryNotFoundException) {
                Logger.Error(Catalog.GetString("Could not export, folder does not exist."));
                ShowErrorDialog(output_folder, dialog,
                                Catalog.GetString("Folder does not exist."));
                return;
            } catch (Exception ex) {
                Logger.Error(Catalog.GetString("Could not export: {0}"), ex);
                ShowErrorDialog(output_folder, dialog,
                                Catalog.GetString("Unknown error."));
                return;
            } finally {
                if (dialog != null)
                {
                    dialog.Destroy();
                    dialog = null;
                }
            }
        }
		/// <summary>
		/// Called when the user chooses "Export All" from the menu, allows user to select destination via GUI.
		/// </summary>
		/// <param name="sender">
		void ExportAllNotesViaGUI ()
		{
			Logger.Info ("Activated export all to " + export_type_pretty_name);
			exporting_single_notebook = false;

			//Opens the folder selection dialog
			ExportMultipleDialog dialog =
			    new ExportMultipleDialog (String.Format (Catalog.GetString ("All Notes {0} Export"), export_type_pretty_name), export_type_pretty_name);
			int response = dialog.Run ();
			if (response != (int) Gtk.ResponseType.Ok) {
				Logger.Debug("User clicked cancel.");
				dialog.Destroy ();
				return;
			}
			string output_folder = SanitizePath (dialog.Filename);

			try {
				ExportAllNotes (output_folder);

				//Successful export: clean up and inform.
				dialog.SavePreferences ();
				ShowSuccessDialog (output_folder);

			} catch (UnauthorizedAccessException) {
				Logger.Error (Catalog.GetString ("Could not export, access denied."));
				ShowErrorDialog (output_folder, dialog,
				                 Catalog.GetString ("Access denied."));
				return;
			} catch (DirectoryNotFoundException) {
				Logger.Error (Catalog.GetString ("Could not export, folder does not exist."));
				ShowErrorDialog (output_folder, dialog,
				                 Catalog.GetString ("Folder does not exist."));
				return;
			} catch (Exception ex) {
				Logger.Error (Catalog.GetString ("Could not export: {0}"), ex);
				ShowErrorDialog (output_folder, dialog,
				                 Catalog.GetString ("Unknown error."));
				return;
			} finally {
				if (dialog != null) {
					dialog.Destroy ();
					dialog = null;
				}
			}
		}
예제 #3
0
		/// <summary>
		/// Called when the user chooses "Export All"
		/// </summary>
		/// <param name="sender">
		void ExportAllNotes ()
		{
			Logger.Info ("Activated export all to " + export_type_pretty_name);
			exporting_single_notebook = false;

			//Opens the folder selection dialog
			ExportMultipleDialog dialog =
			    new ExportMultipleDialog (String.Format (Catalog.GetString ("All Notes {0} Export"), export_type_pretty_name), export_type_pretty_name);
			int response = dialog.Run ();
			if (response != (int) Gtk.ResponseType.Ok) {
				Logger.Debug("User clicked cancel.");
				dialog.Destroy ();
				return;
			}
			string output_folder = SanitizePath (dialog.Filename);

			try {
				Logger.Debug ("Creating an export folder in: " + output_folder);
				System.IO.Directory.CreateDirectory (output_folder);

				//Iterate through notebooks
				Notebooks.Notebook notebook;
				string notebook_folder;

				foreach (Tag tag in TagManager.AllTags) {
					// Skip over tags that aren't notebooks
					notebook = NotebookManager.GetNotebookFromTag (tag);
					if (notebook == null)
						continue;

					Logger.Debug ("Exporting notebook " + notebook.Name);
					notebook_folder = SanitizePath (output_folder + System.IO.Path.DirectorySeparatorChar
					                  + notebook.NormalizedName);
					System.IO.Directory.CreateDirectory (notebook_folder);
					ExportNotesInList (notebook.Tag.Notes, notebook_folder);

				}

				//Finally we have to export all unfiled notes.
				Logger.Debug ("Exporting Unfiled Notes");
				ExportNotesInList (ListUnfiledNotes (), output_folder);

				//Successful export: clean up and inform.
				dialog.SavePreferences ();
				ShowSuccessDialog (output_folder);

			} catch (UnauthorizedAccessException) {
				Logger.Error (Catalog.GetString ("Could not export, access denied."));
				ShowErrorDialog (output_folder, dialog,
				                 Catalog.GetString ("Access denied."));
				return;
			} catch (DirectoryNotFoundException) {
				Logger.Error (Catalog.GetString ("Could not export, folder does not exist."));
				ShowErrorDialog (output_folder, dialog,
				                 Catalog.GetString ("Folder does not exist."));
				return;
			} catch (Exception ex) {
				Logger.Error (Catalog.GetString ("Could not export: {0}"), ex);
				ShowErrorDialog (output_folder, dialog,
				                 Catalog.GetString ("Unknown error."));
				return;
			} finally {
				if (dialog != null) {
					dialog.Destroy ();
					dialog = null;
				}
			}
		}
예제 #4
0
        /// <summary>
        /// Called when the user chooses "Export All"
        /// </summary>
        /// <param name="sender">
        void ExportAllNotes()
        {
            Logger.Info("Activated export all to " + export_type_pretty_name);
            exporting_single_notebook = false;

            //Opens the folder selection dialog
            ExportMultipleDialog dialog =
                new ExportMultipleDialog(String.Format(Catalog.GetString("All Notes {0} Export"), export_type_pretty_name), export_type_pretty_name);
            int response = dialog.Run();

            if (response != (int)Gtk.ResponseType.Ok)
            {
                Logger.Debug("User clicked cancel.");
                dialog.Destroy();
                return;
            }
            string output_folder = SanitizePath(dialog.Filename);

            try {
                Logger.Debug("Creating an export folder in: " + output_folder);
                System.IO.Directory.CreateDirectory(output_folder);

                //Iterate through notebooks
                Notebooks.Notebook notebook;
                string             notebook_folder;

                foreach (Tag tag in TagManager.AllTags)
                {
                    // Skip over tags that aren't notebooks
                    notebook = NotebookManager.GetNotebookFromTag(tag);
                    if (notebook == null)
                    {
                        continue;
                    }

                    Logger.Debug("Exporting notebook " + notebook.Name);
                    notebook_folder = SanitizePath(output_folder + System.IO.Path.DirectorySeparatorChar
                                                   + notebook.NormalizedName);
                    System.IO.Directory.CreateDirectory(notebook_folder);
                    ExportNotesInList(notebook.Tag.Notes, notebook_folder);
                }

                //Finally we have to export all unfiled notes.
                Logger.Debug("Exporting Unfiled Notes");
                ExportNotesInList(ListUnfiledNotes(), output_folder);

                //Successful export: clean up and inform.
                dialog.SavePreferences();
                ShowSuccessDialog(output_folder);
            } catch (UnauthorizedAccessException) {
                Logger.Error(Catalog.GetString("Could not export, access denied."));
                ShowErrorDialog(output_folder, dialog,
                                Catalog.GetString("Access denied."));
                return;
            } catch (DirectoryNotFoundException) {
                Logger.Error(Catalog.GetString("Could not export, folder does not exist."));
                ShowErrorDialog(output_folder, dialog,
                                Catalog.GetString("Folder does not exist."));
                return;
            } catch (Exception ex) {
                Logger.Error(Catalog.GetString("Could not export: {0}"), ex);
                ShowErrorDialog(output_folder, dialog,
                                Catalog.GetString("Unknown error."));
                return;
            } finally {
                if (dialog != null)
                {
                    dialog.Destroy();
                    dialog = null;
                }
            }
        }