示例#1
0
        private void PrintButtonClicked(object sender, EventArgs args)
        {
            try {
                page_breaks = new List <PageBreak> ();

                using (Gtk.PrintOperation print_op = new Gtk.PrintOperation()) {
                    print_op.JobName = Note.Title;

                    print_op.BeginPrint += OnBeginPrint;
                    print_op.DrawPage   += OnDrawPage;
                    print_op.EndPrint   += OnEndPrint;

                    print_op.Run(Gtk.PrintOperationAction.PrintDialog, Window);
                }
            } catch (Exception e) {
                Logger.Error("Exception while printing " + Note.Title + ": " + e.ToString());
                HIGMessageDialog dlg = new HIGMessageDialog(Note.Window,
                                                            Gtk.DialogFlags.Modal,
                                                            Gtk.MessageType.Error,
                                                            Gtk.ButtonsType.Ok,
                                                            Catalog.GetString("Error printing note"),
                                                            e.Message);
                dlg.Run();
                dlg.Destroy();
            }
        }
示例#2
0
        protected override bool OnActivate(NoteEditor editor,
                                           Gtk.TextIter start,
                                           Gtk.TextIter end)
        {
            Process p = new Process();

            p.StartInfo.FileName        = "evolution";
            p.StartInfo.Arguments       = EmailUri;
            p.StartInfo.UseShellExecute = false;

            try {
                p.Start();
            } catch (Exception e) {
                string message = String.Format("Error running Evolution: {0}",
                                               e.Message);
                Logger.Error(message);
                HIGMessageDialog dialog =
                    new HIGMessageDialog(editor.Toplevel as Gtk.Window,
                                         Gtk.DialogFlags.DestroyWithParent,
                                         Gtk.MessageType.Info,
                                         Gtk.ButtonsType.Ok,
                                         Catalog.GetString("Cannot open email"),
                                         message);
                dialog.Run();
                dialog.Destroy();
            }

            return(true);
        }
示例#3
0
        /// <summary>
        /// Prompt the user and delete the notebok (if they say so).
        /// </summary>
        /// <param name="parent">
        /// A <see cref="Gtk.Window"/>
        /// </param>
        /// <param name="notebook">
        /// A <see cref="Notebook"/>
        /// </param>
        public static void PromptDeleteNotebook(Gtk.Window parent, Notebook notebook)
        {
            // Confirmation Dialog
            HIGMessageDialog dialog =
                new HIGMessageDialog(parent,
                                     Gtk.DialogFlags.Modal,
                                     Gtk.MessageType.Question,
                                     Gtk.ButtonsType.YesNo,
                                     Catalog.GetString("Really delete this notebook?"),
                                     Catalog.GetString(
                                         "The notes that belong to this notebook will not be " +
                                         "deleted, but they will no longer be associated with " +
                                         "this notebook.  This action cannot be undone."));

            dialog.DefaultResponse = Gtk.ResponseType.No;
            int response = dialog.Run();

            dialog.Destroy();
            if (response != (int)Gtk.ResponseType.Yes)
            {
                return;
            }

            DeleteNotebook(notebook);

            // Delete the template note
            Note templateNote = notebook.GetTemplateNote();

            if (templateNote != null)
            {
                NoteManager noteManager = Tomboy.DefaultNoteManager;
                noteManager.Delete(templateNote);
            }
        }
		private void PrintButtonClicked (object sender, EventArgs args)
		{
			try {
				page_breaks = new List<PageBreak> ();				
				
				using (Gtk.PrintOperation print_op = new Gtk.PrintOperation ()) {
					print_op.JobName = Note.Title;

					print_op.BeginPrint += OnBeginPrint;
					print_op.DrawPage += OnDrawPage;
					print_op.EndPrint += OnEndPrint;

					print_op.Run (Gtk.PrintOperationAction.PrintDialog, Window);
				}
			} catch (Exception e) {
				Logger.Error ("Exception while printing " + Note.Title + ": " + e.ToString ());
				HIGMessageDialog dlg = new HIGMessageDialog (Note.Window,
					Gtk.DialogFlags.Modal,
					Gtk.MessageType.Error,
					Gtk.ButtonsType.Ok,
					Catalog.GetString ("Error printing note"),
					e.Message);
				dlg.Run ();
				dlg.Destroy ();
			}
		}
示例#5
0
        protected override bool OnActivate(NoteEditor editor,
                                           Gtk.TextIter start,
                                           Gtk.TextIter end)
        {
            string     persona = start.GetText(end);
            PersonLink plink   = (PersonLink)galago.Trie.Lookup(persona);

            try {
                plink.SendMessage();
            } catch (Exception e) {
                string title = Catalog.GetString("Cannot contact '{0}'");
                title = String.Format(title, persona);

                string message = Catalog.GetString("Error running gaim-remote: {0}");
                message = String.Format(message, e.Message);

                Logger.Log(message);

                HIGMessageDialog dialog =
                    new HIGMessageDialog(editor.Toplevel as Gtk.Window,
                                         Gtk.DialogFlags.DestroyWithParent,
                                         Gtk.MessageType.Info,
                                         Gtk.ButtonsType.Ok,
                                         title,
                                         message);
                dialog.Run();
                dialog.Destroy();
            }

            return(true);
        }
示例#6
0
        void RemoveClicked(object sender, EventArgs args)
        {
            // Remove the icon file and call UpdateIconStore ().
            Gtk.TreeIter iter;
            if (!icon_tree.Selection.GetSelected(out iter))
            {
                return;
            }

            string icon_path = icon_store.GetValue(iter, 2) as string;

            HIGMessageDialog dialog =
                new HIGMessageDialog(
                    null,
                    Gtk.DialogFlags.DestroyWithParent,
                    Gtk.MessageType.Question,
                    Gtk.ButtonsType.None,
                    Catalog.GetString("Really remove this icon?"),
                    Catalog.GetString("If you remove an icon it is " +
                                      "permanently lost."));

            Gtk.Button button;

            button            = new Gtk.Button(Gtk.Stock.Cancel);
            button.CanDefault = true;
            button.Show();
            dialog.AddActionWidget(button, Gtk.ResponseType.Cancel);
            dialog.DefaultResponse = Gtk.ResponseType.Cancel;

            button            = new Gtk.Button(Gtk.Stock.Delete);
            button.CanDefault = true;
            button.Show();
            dialog.AddActionWidget(button, 666);

            int result = dialog.Run();

            if (result == 666)
            {
                try {
                    File.Delete(icon_path);
                    UpdateIconStore();
                } catch (Exception e) {
                    Logger.Error("Error removing icon {0}: {1}",
                                 icon_path,
                                 e.Message);
                }
            }

            dialog.Destroy();
        }
        void ShowMessageDialog(string title, string message, Gtk.MessageType messageType)
        {
            HIGMessageDialog dialog =
                new HIGMessageDialog(
                    Note.Window,
                    Gtk.DialogFlags.DestroyWithParent,
                    messageType,
                    Gtk.ButtonsType.Ok,
                    title,
                    message);

            dialog.Run();
            dialog.Destroy();
        }
示例#8
0
        void ShowDeletionDialog(List <Task> tasks)
        {
            HIGMessageDialog dialog =
                new HIGMessageDialog(
                    this,
                    Gtk.DialogFlags.DestroyWithParent,
                    Gtk.MessageType.Question,
                    Gtk.ButtonsType.None,
                    tasks.Count > 1 ?
                    Catalog.GetString("Really delete these tasks?") :
                    Catalog.GetString("Really delete this task?"),
                    Catalog.GetString("If you delete a task it is " +
                                      "permanently lost."));

            Gtk.Button button;

            button            = new Gtk.Button(Gtk.Stock.Cancel);
            button.CanDefault = true;
            button.Show();
            dialog.AddActionWidget(button, Gtk.ResponseType.Cancel);
            dialog.DefaultResponse = Gtk.ResponseType.Cancel;

            button            = new Gtk.Button(Gtk.Stock.Delete);
            button.CanDefault = true;
            button.Show();
            dialog.AddActionWidget(button, 666);

            int result = dialog.Run();

            if (result == 666)
            {
                // Disable the selection changed handler while we nuke tasks
                tree.Selection.Changed -= OnSelectionChanged;

                foreach (Task task in tasks)
                {
                    task.Manager.Delete(task);
                }

                tree.Selection.Changed += OnSelectionChanged;
            }

            dialog.Destroy();
        }
		void RemoveClicked (object sender, EventArgs args)
		{
			// Remove the icon file and call UpdateIconStore ().
			Gtk.TreeIter iter;
			if (!icon_tree.Selection.GetSelected (out iter))
				return;

			string icon_path = icon_store.GetValue (iter, 2) as string;

			HIGMessageDialog dialog =
			        new HIGMessageDialog (
			        null,
			        Gtk.DialogFlags.DestroyWithParent,
			        Gtk.MessageType.Question,
			        Gtk.ButtonsType.None,
			        Catalog.GetString ("Really remove this icon?"),
			        Catalog.GetString ("If you remove an icon it is " +
			                           "permanently lost."));

			Gtk.Button button;

			button = new Gtk.Button (Gtk.Stock.Cancel);
			button.CanDefault = true;
			button.Show ();
			dialog.AddActionWidget (button, Gtk.ResponseType.Cancel);
			dialog.DefaultResponse = Gtk.ResponseType.Cancel;

			button = new Gtk.Button (Gtk.Stock.Delete);
			button.CanDefault = true;
			button.Show ();
			dialog.AddActionWidget (button, 666);

			int result = dialog.Run ();
			if (result == 666) {
				try {
					File.Delete (icon_path);
					UpdateIconStore ();
				} catch (Exception e) {
					Logger.Error ("Error removing icon {0}: {1}",
					              icon_path,
					              e.Message);
				}
			}

			dialog.Destroy();
		}
示例#10
0
		void ShowNameClashError (string title)
		{
			// Select text from TitleStart to TitleEnd
			Buffer.MoveMark (Buffer.SelectionBound, TitleStart);
			Buffer.MoveMark (Buffer.InsertMark, TitleEnd);

			string message =
			        String.Format (Catalog.GetString ("A note with the title " +
			                                          "<b>{0}</b> already exists. " +
			                                          "Please choose another name " +
			                                          "for this note before " +
			                                          "continuing."),
			                       title);

			/// Only pop open a warning dialog when one isn't already present
			/// Had to add this check because this method is being called twice.
			if (title_taken_dialog == null) {
				title_taken_dialog =
				        new HIGMessageDialog (Window,
				                              Gtk.DialogFlags.DestroyWithParent,
				                              Gtk.MessageType.Warning,
				                              Gtk.ButtonsType.Ok,
				                              Catalog.GetString ("Note title taken"),
				                              message);
				title_taken_dialog.Modal = true;
				title_taken_dialog.Response +=
				delegate (object sender, Gtk.ResponseArgs args) {
					title_taken_dialog.Destroy ();
					title_taken_dialog = null;
				};
			}

			title_taken_dialog.Present ();
		}
示例#11
0
		/// <summary>
		/// Enable fuse.  This requires root access.
		/// </summary>
		public static bool EnableFuse ()
		{
			if (IsFuseEnabled () == true)
				return true; // nothing to do

			if (string.IsNullOrEmpty (guisuTool) ||
			                string.IsNullOrEmpty (modprobeTool)) {
				Logger.Warn ("Couldn't enable fuse; missing either GUI 'su' tool or modprobe");

				// Let the user know that FUSE could not be enabled
				HIGMessageDialog cannotEnableDlg =
				        new HIGMessageDialog (null,
				                              Gtk.DialogFlags.Modal,
				                              Gtk.MessageType.Error,
				                              Gtk.ButtonsType.Ok,
				                              Catalog.GetString ("Could not enable FUSE"),
				                              Catalog.GetString ("The FUSE module could not be loaded. " +
				                                                 "Please check that it is installed properly " +
				                                                 "and try again."));

				cannotEnableDlg.Run ();
				cannotEnableDlg.Destroy ();
				return false;
			}

			// Prompt the user first about enabling fuse
			HIGMessageDialog dialog =
			        new HIGMessageDialog (null,
			                              Gtk.DialogFlags.Modal,
			                              Gtk.MessageType.Question,
			                              Gtk.ButtonsType.YesNo,
			                              Catalog.GetString ("Enable FUSE?"),
			                              Catalog.GetString (
			                                      // TODO: This message isn't entirely accurate.
			                                      //       We should fix it.
			                                      "The synchronization you've chosen requires the FUSE module to be loaded.\n\n" +
			                                      "To avoid getting this prompt in the future, you should load FUSE at startup.  " +
			                                      "Add \"modprobe fuse\" to /etc/init.d/boot.local or \"fuse\" to /etc/modules."));
			int response = dialog.Run ();
			dialog.Destroy ();
			if (response == (int) Gtk.ResponseType.Yes) {
				// "modprobe fuse"
				Process p = new Process ();
				p.StartInfo.UseShellExecute = false;
				p.StartInfo.FileName = guisuTool;
				p.StartInfo.Arguments = string.Format ("{0} fuse", modprobeTool);
				p.StartInfo.CreateNoWindow = true;
				p.Start ();
				p.WaitForExit ();

				if (p.ExitCode != 0) {
					Logger.Warn ("Couldn't enable fuse");

					// Let the user know that they don't have FUSE installed on their machine
					HIGMessageDialog failedDlg =
					        new HIGMessageDialog (null,
					                              Gtk.DialogFlags.Modal,
					                              Gtk.MessageType.Error,
					                              Gtk.ButtonsType.Ok,
					                              Catalog.GetString ("Could not enable FUSE"),
					                              Catalog.GetString ("The FUSE module could not be loaded. " +
					                                                 "Please check that it is installed properly " +
					                                                 "and try again."));
					failedDlg.Run ();
					failedDlg.Destroy ();
					return false;
				}

				// "echo fuse >> /etc/modules"
				/*
				// Punting for now.  Can't seem to get this to work.
				// When using /etc/init.d/boot.local, you should add "modprobe fuse",
				// and not what has been coded below.
				p = new Process ();
				p.StartInfo.UseShellExecute = false;
				p.StartInfo.FileName = guisuTool;
				p.StartInfo.Arguments = string.Format ("\"{0} fuse >> {1}\"",
				  echoTool, bootLocalFile);
				p.StartInfo.CreateNoWindow = true;
				p.Start ();
				p.WaitForExit ();
				if (p.ExitCode != 0) {
				 Logger.Warn ("Could not enable FUSE persistently.  User will have to be prompted again during their next login session.");
				}
				*/
				return true;
			}

			return false;
		}
示例#12
0
文件: NoteWindow.cs 项目: oluc/tomboy
		//
		// Link menu item activate
		//
		// Create a new note, names according to the buffer's selected
		// text.  Does nothing if there is no active selection.
		//

		void LinkButtonClicked ()
		{
			string select = note.Buffer.Selection;
			if (select == null)
				return;

			string body_unused;
			string title = NoteManager.SplitTitleFromContent (select, out body_unused);
			if (title == null)
				return;

			Note match = note.Manager.Find (title);
			if (match == null) {
				try {
					match = note.Manager.Create (select);
				} catch (Exception e) {
					HIGMessageDialog dialog =
					        new HIGMessageDialog (
					        this,
					        Gtk.DialogFlags.DestroyWithParent,
					        Gtk.MessageType.Error,
					        Gtk.ButtonsType.Ok,
					        Catalog.GetString ("Cannot create note"),
					        e.Message);
					dialog.Run ();
					dialog.Destroy ();
					return;
				}
			}

			match.Window.Present ();
		}
        protected override bool OnActivate(NoteEditor editor,
                                           Gtk.TextIter start,
                                           Gtk.TextIter end)
        {
            Process p = new Process();
            p.StartInfo.FileName = "claws-mail";
            p.StartInfo.Arguments = "--select '" + EmailUri + "'";
            p.StartInfo.UseShellExecute = false;

            try {
                p.Start();
            } catch(Exception ee) {
                string message = String.Format("Error running Claws Mail: {0}", ee.Message);
                Logger.Error(message);
                HIGMessageDialog dialog = new HIGMessageDialog(editor.Toplevel as Gtk.Window,
                                              Gtk.DialogFlags.DestroyWithParent,
                                              Gtk.MessageType.Info,
                                              Gtk.ButtonsType.Ok,
                                              Catalog.GetString("Cannot open email"),
                                              message);
                dialog.Run();
                dialog.Destroy();
            }
            return true;
        }
		/// <summary>
		/// Shows a success dialog when export is complete
		/// </summary>
		/// <param name="detail"> A string with details of the export folder.</param>
		private static void ShowSuccessDialog (string output_folder)
		{
			string detail = String.Format (
			                            Catalog.GetString ("Your notes were exported to \"{0}\"."),
			                            output_folder);

			HIGMessageDialog msg_dialog =
			        new HIGMessageDialog (
			        null,
			        Gtk.DialogFlags.DestroyWithParent,
			        Gtk.MessageType.Info,
			        Gtk.ButtonsType.Ok,
			        Catalog.GetString ("Notes exported successfully"),
			        detail);
			msg_dialog.Run ();
			msg_dialog.Destroy ();
		}
示例#15
0
文件: Tomboy.cs 项目: GNOME/tomboy
		static void OnNewNoteAction (object sender, EventArgs args)
		{
			try {
				Note new_note = manager.Create ();
				new_note.Window.Show ();
			} catch (Exception e) {
				HIGMessageDialog dialog =
				        new HIGMessageDialog (
				        null,
				        0,
				        Gtk.MessageType.Error,
				        Gtk.ButtonsType.Ok,
				        Catalog.GetString ("Cannot create new note"),
				        e.Message);
				dialog.Run ();
				dialog.Destroy ();
			}
		}
示例#16
0
 protected void StatusMsg(string Message)
 {
     HIGMessageDialog hmd = new HIGMessageDialog(Window,
             Gtk.DialogFlags.DestroyWithParent,
             Gtk.MessageType.Error,
             Gtk.ButtonsType.Ok,
             Catalog.GetString ("Error"),
             Catalog.GetString (Message));
     hmd.Run();
     hmd.Destroy();
 }
示例#17
0
        protected override bool OnActivate(NoteEditor editor,
                                           Gtk.TextIter start,
                                           Gtk.TextIter end)
        {
            Process p = new Process();
            p.StartInfo.FileName = "gitg";
            p.StartInfo.Arguments = "--select " + Treeish;
            p.StartInfo.WorkingDirectory = RepositoryPath;
            p.StartInfo.UseShellExecute = false;

            try {
                p.Start();
            } catch(Exception ee) {
                string message = String.Format("Error running Gitg: {0}", ee.Message);
                Logger.Error(message);
                HIGMessageDialog dialog = new HIGMessageDialog(editor.Toplevel as Gtk.Window,
                                              Gtk.DialogFlags.DestroyWithParent,
                                              Gtk.MessageType.Info,
                                              Gtk.ButtonsType.Ok,
                                              Catalog.GetString("Cannot open Git repository browser"),
                                              message);
                dialog.Run();
                dialog.Destroy();
            }
            return true;
        }
示例#18
0
        void ExportButtonClicked(object sender, EventArgs args)
        {
            String             sanitized_title = ExportAllApplicationAddin.SanitizeNoteTitle(Note.Title);
            ExportToHtmlDialog dialog          = new ExportToHtmlDialog(sanitized_title + ".html");
            int    response    = dialog.Run();
            string output_path = dialog.Filename;

            if (response != (int)Gtk.ResponseType.Ok)
            {
                dialog.Destroy();
                return;
            }

            Logger.Debug("Exporting Note '{0}' to '{1}'...", Note.Title, output_path);

            StreamWriter writer        = null;
            string       error_message = null;

            try {
                try {
                    // FIXME: Warn about file existing.  Allow overwrite.
                    File.Delete(output_path);
                } catch {
                }

                writer = new StreamWriter(output_path);
                WriteHTMLForNote(writer, Note, dialog.ExportLinked, dialog.ExportLinkedAll);

                // Save the dialog preferences now that the note has
                // successfully been exported
                dialog.SavePreferences();
                dialog.Destroy();
                dialog = null;

                try {
                    Uri output_uri = new Uri(output_path);
                    Services.NativeApplication.OpenUrl(output_uri.AbsoluteUri,
                                                       Note.Window.Screen);
                } catch (Exception ex) {
                    Logger.Error("Could not open exported note in a web browser: {0}",
                                 ex);

                    string detail = String.Format(
                        Catalog.GetString("Your note was exported to \"{0}\"."),
                        output_path);

                    // Let the user know the note was saved successfully
                    // even though showing the note in a web browser failed.
                    HIGMessageDialog msg_dialog =
                        new HIGMessageDialog(
                            Window,
                            Gtk.DialogFlags.DestroyWithParent,
                            Gtk.MessageType.Info,
                            Gtk.ButtonsType.Ok,
                            Catalog.GetString("Note exported successfully"),
                            detail);
                    msg_dialog.Run();
                    msg_dialog.Destroy();
                }
            } catch (UnauthorizedAccessException) {
                error_message = Catalog.GetString("Access denied.");
            } catch (DirectoryNotFoundException) {
                error_message = Catalog.GetString("Folder does not exist.");
            } catch (Exception e) {
                Logger.Error("Could not export: {0}", e);

                error_message = e.Message;
            } finally {
                if (writer != null)
                {
                    writer.Close();
                }
            }

            if (error_message != null)
            {
                Logger.Error("Could not export: {0}", error_message);

                string msg = String.Format(
                    Catalog.GetString("Could not save the file \"{0}\""),
                    output_path);

                HIGMessageDialog msg_dialog =
                    new HIGMessageDialog(
                        dialog,
                        Gtk.DialogFlags.DestroyWithParent,
                        Gtk.MessageType.Error,
                        Gtk.ButtonsType.Ok,
                        msg,
                        error_message);
                msg_dialog.Run();
                msg_dialog.Destroy();
            }

            if (dialog != null)
            {
                dialog.Destroy();
            }
        }
		void ExportButtonClicked (object sender, EventArgs args)
		{
                        String sanitized_title = ExportAllApplicationAddin.SanitizeNoteTitle (Note.Title);
			ExportToHtmlDialog dialog = new ExportToHtmlDialog (sanitized_title + ".html");
			int response = dialog.Run();
			string output_path = dialog.Filename;

			if (response != (int) Gtk.ResponseType.Ok) {
				dialog.Destroy ();
				return;
			}

			Logger.Debug ("Exporting Note '{0}' to '{1}'...", Note.Title, output_path);

			StreamWriter writer = null;
			string error_message = null;

			try {
				try {
					// FIXME: Warn about file existing.  Allow overwrite.
					File.Delete (output_path);
				} catch {
			}

			writer = new StreamWriter (output_path);
				WriteHTMLForNote (writer, Note, dialog.ExportLinked, dialog.ExportLinkedAll);

				// Save the dialog preferences now that the note has
				// successfully been exported
				dialog.SavePreferences ();
				dialog.Destroy ();
				dialog = null;

				try {
					Uri output_uri = new Uri (output_path);
					Services.NativeApplication.OpenUrl (output_uri.AbsoluteUri,
					                                    Note.Window.Screen);
				} catch (Exception ex) {
					Logger.Error ("Could not open exported note in a web browser: {0}",
					            ex);

					string detail = String.Format (
					                        Catalog.GetString ("Your note was exported to \"{0}\"."),
					                        output_path);

					// Let the user know the note was saved successfully
					// even though showing the note in a web browser failed.
					HIGMessageDialog msg_dialog =
					        new HIGMessageDialog (
					        Window,
					        Gtk.DialogFlags.DestroyWithParent,
					        Gtk.MessageType.Info,
					        Gtk.ButtonsType.Ok,
					        Catalog.GetString ("Note exported successfully"),
					        detail);
					msg_dialog.Run ();
					msg_dialog.Destroy ();
				}
			} catch (UnauthorizedAccessException) {
				error_message = Catalog.GetString ("Access denied.");
			} catch (DirectoryNotFoundException) {
				error_message = Catalog.GetString ("Folder does not exist.");
			} catch (Exception e) {
				Logger.Error ("Could not export: {0}", e);

				error_message = e.Message;
			} finally {
				if (writer != null)
					writer.Close ();
			}

			if (error_message != null)
			{
				Logger.Error ("Could not export: {0}", error_message);

				string msg = String.Format (
				                     Catalog.GetString ("Could not save the file \"{0}\""),
				                     output_path);

				HIGMessageDialog msg_dialog =
				        new HIGMessageDialog (
				        dialog,
				        Gtk.DialogFlags.DestroyWithParent,
				        Gtk.MessageType.Error,
				        Gtk.ButtonsType.Ok,
				        msg,
				        error_message);
				msg_dialog.Run ();
				msg_dialog.Destroy ();
			}

			if (dialog != null)
				dialog.Destroy ();
		}
示例#20
0
文件: Note.cs 项目: oluc/tomboy
		public static void ShowIOErrorDialog (Gtk.Window parent)
		{
			string errorMsg = Catalog.GetString ("An error occurred while saving your notes. " +
			                                     "Please check that you have sufficient disk " +
			                                     "space, and that you have appropriate rights " +
			                                     "on {0}. Error details can be found in " +
			                                     "{1}.");
			string logPath = System.IO.Path.Combine (Services.NativeApplication.LogDirectory,
			                                         "tomboy.log");
			errorMsg = String.Format (errorMsg,
			                          Services.NativeApplication.DataDirectory,
			                          logPath);
			HIGMessageDialog dialog =
				new HIGMessageDialog (
				                      parent,
				                      Gtk.DialogFlags.DestroyWithParent,
				                      Gtk.MessageType.Error,
				                      Gtk.ButtonsType.Ok,
				                      Catalog.GetString ("Error saving note data."),
				                      errorMsg);
			dialog.Run ();
			dialog.Destroy ();
		}
		void AddClicked (object sender, EventArgs args)
		{
			Gtk.FileChooserDialog dialog = new Gtk.FileChooserDialog (
			        Catalog.GetString ("Select an icon..."),
			        null, Gtk.FileChooserAction.Open, new object[] {});
			dialog.AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
			dialog.AddButton (Gtk.Stock.Open, Gtk.ResponseType.Ok);

			dialog.DefaultResponse = Gtk.ResponseType.Ok;
			dialog.LocalOnly = true;
			dialog.SetCurrentFolder (last_opened_dir);

			Gtk.FileFilter filter = new Gtk.FileFilter ();
			filter.AddPixbufFormats ();

			dialog.Filter = filter;

			// Extra Widget
			Gtk.Label l = new Gtk.Label (Catalog.GetString ("_Host name:"));
			Gtk.Entry host_entry = new Gtk.Entry ();
			l.MnemonicWidget = host_entry;
			Gtk.HBox hbox = new Gtk.HBox (false, 6);
			hbox.PackStart (l, false, false, 0);
			hbox.PackStart (host_entry, true, true, 0);
			hbox.ShowAll ();

			dialog.ExtraWidget = hbox;

			int response;
			string icon_file;
			string host;

run_add_dialog:
			response = dialog.Run ();
			icon_file = dialog.Filename;
			host = host_entry.Text.Trim ();

			if (response == (int) Gtk.ResponseType.Ok
			                && host == String.Empty) {
				// Let the user know that they
				// have to specify a host name.
				HIGMessageDialog warn =
				        new HIGMessageDialog (
				        null,
				        Gtk.DialogFlags.DestroyWithParent,
				        Gtk.MessageType.Warning,
				        Gtk.ButtonsType.Ok,
				        Catalog.GetString ("No host name specified"),
				        Catalog.GetString ("You must specify the Bugzilla " +
				                           "host name to use with this icon."));
				warn.Run ();
				warn.Destroy ();

				host_entry.GrabFocus ();
				goto run_add_dialog;
			} else if (response != (int) Gtk.ResponseType.Ok) {
				dialog.Destroy ();
				return;
			}

			// Keep track of the last directory the user had open
			last_opened_dir = dialog.CurrentFolder;

			dialog.Destroy ();

			// Copy the file to the BugzillaIcons directory
			string err_msg;
			if (!CopyToBugizllaIconsDir (icon_file, host, out err_msg)) {
				HIGMessageDialog err =
				        new HIGMessageDialog (
				        null,
				        Gtk.DialogFlags.DestroyWithParent,
				        Gtk.MessageType.Error,
				        Gtk.ButtonsType.Ok,
				        Catalog.GetString ("Error saving icon"),
				        Catalog.GetString ("Could not save the icon file.") +
					                   "  " +
					                   err_msg);
				err.Run ();
				err.Destroy ();
			}

			UpdateIconStore ();
		}
示例#22
0
        void AddClicked(object sender, EventArgs args)
        {
            Gtk.FileChooserDialog dialog = new Gtk.FileChooserDialog(
                Catalog.GetString("Select an icon..."),
                null, Gtk.FileChooserAction.Open, new object[] {});
            dialog.AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
            dialog.AddButton(Gtk.Stock.Open, Gtk.ResponseType.Ok);

            dialog.DefaultResponse = Gtk.ResponseType.Ok;
            dialog.LocalOnly       = true;
            dialog.SetCurrentFolder(last_opened_dir);

            Gtk.FileFilter filter = new Gtk.FileFilter();
            filter.AddPixbufFormats();

            dialog.Filter = filter;

            // Extra Widget
            Gtk.Label l          = new Gtk.Label(Catalog.GetString("_Host name:"));
            Gtk.Entry host_entry = new Gtk.Entry();
            l.MnemonicWidget = host_entry;
            Gtk.HBox hbox = new Gtk.HBox(false, 6);
            hbox.PackStart(l, false, false, 0);
            hbox.PackStart(host_entry, true, true, 0);
            hbox.ShowAll();

            dialog.ExtraWidget = hbox;

            int    response;
            string icon_file;
            string host;

run_add_dialog:
            response  = dialog.Run();
            icon_file = dialog.Filename;
            host      = host_entry.Text.Trim();

            if (response == (int)Gtk.ResponseType.Ok &&
                host == String.Empty)
            {
                // Let the user know that they
                // have to specify a host name.
                HIGMessageDialog warn =
                    new HIGMessageDialog(
                        null,
                        Gtk.DialogFlags.DestroyWithParent,
                        Gtk.MessageType.Warning,
                        Gtk.ButtonsType.Ok,
                        Catalog.GetString("No host name specified"),
                        Catalog.GetString("You must specify the Bugzilla " +
                                          "host name to use with this icon."));
                warn.Run();
                warn.Destroy();

                host_entry.GrabFocus();
                goto run_add_dialog;
            }
            else if (response != (int)Gtk.ResponseType.Ok)
            {
                dialog.Destroy();
                return;
            }

            // Keep track of the last directory the user had open
            last_opened_dir = dialog.CurrentFolder;

            dialog.Destroy();

            // Copy the file to the BugzillaIcons directory
            string err_msg;

            if (!CopyToBugizllaIconsDir(icon_file, host, out err_msg))
            {
                HIGMessageDialog err =
                    new HIGMessageDialog(
                        null,
                        Gtk.DialogFlags.DestroyWithParent,
                        Gtk.MessageType.Error,
                        Gtk.ButtonsType.Ok,
                        Catalog.GetString("Error saving icon"),
                        Catalog.GetString("Could not save the icon file.") +
                        "  " +
                        err_msg);
                err.Run();
                err.Destroy();
            }

            UpdateIconStore();
        }
示例#23
0
		void ShowDeletionDialog (List<Task> tasks)
		{
			HIGMessageDialog dialog =
			        new HIGMessageDialog (
			        this,
			        Gtk.DialogFlags.DestroyWithParent,
			        Gtk.MessageType.Question,
			        Gtk.ButtonsType.None,
			        tasks.Count > 1 ?
			        Catalog.GetString ("Really delete these tasks?") :
			        Catalog.GetString ("Really delete this task?"),
			        Catalog.GetString ("If you delete a task it is " +
			                           "permanently lost."));

			Gtk.Button button;

			button = new Gtk.Button (Gtk.Stock.Cancel);
			button.CanDefault = true;
			button.Show ();
			dialog.AddActionWidget (button, Gtk.ResponseType.Cancel);
			dialog.DefaultResponse = Gtk.ResponseType.Cancel;

			button = new Gtk.Button (Gtk.Stock.Delete);
			button.CanDefault = true;
			button.Show ();
			dialog.AddActionWidget (button, 666);

			int result = dialog.Run ();
			if (result == 666) {
				// Disable the selection changed handler while we nuke tasks
				tree.Selection.Changed -= OnSelectionChanged;

				foreach (Task task in tasks) {
					task.Manager.Delete (task);
				}

				tree.Selection.Changed += OnSelectionChanged;
			}

			dialog.Destroy();
		}
		void ShowMessageDialog (string title, string message, Gtk.MessageType messageType)
		{
			HIGMessageDialog dialog =
			        new HIGMessageDialog (
			        Note.Window,
			        Gtk.DialogFlags.DestroyWithParent,
			        messageType,
			        Gtk.ButtonsType.Ok,
			        title,
			        message);
			dialog.Run ();
			dialog.Destroy ();
		}
示例#25
0
        /// <summary>
        /// Enable fuse.  This requires root access.
        /// </summary>
        public static bool EnableFuse()
        {
            if (IsFuseEnabled() == true)
            {
                return(true);                // nothing to do
            }
            if (string.IsNullOrEmpty(guisuTool) ||
                string.IsNullOrEmpty(modprobeTool))
            {
                Logger.Warn("Couldn't enable fuse; missing either GUI 'su' tool or modprobe");

                // Let the user know that FUSE could not be enabled
                HIGMessageDialog cannotEnableDlg =
                    new HIGMessageDialog(null,
                                         Gtk.DialogFlags.Modal,
                                         Gtk.MessageType.Error,
                                         Gtk.ButtonsType.Ok,
                                         Catalog.GetString("Could not enable FUSE"),
                                         Catalog.GetString("The FUSE module could not be loaded. " +
                                                           "Please check that it is installed properly " +
                                                           "and try again."));

                cannotEnableDlg.Run();
                cannotEnableDlg.Destroy();
                return(false);
            }

            // Prompt the user first about enabling fuse
            HIGMessageDialog dialog =
                new HIGMessageDialog(null,
                                     Gtk.DialogFlags.Modal,
                                     Gtk.MessageType.Question,
                                     Gtk.ButtonsType.YesNo,
                                     Catalog.GetString("Enable FUSE?"),
                                     Catalog.GetString(
                                         // TODO: This message isn't entirely accurate.
                                         //       We should fix it.
                                         "The synchronization you've chosen requires the FUSE module to be loaded.\n\n" +
                                         "To avoid getting this prompt in the future, you should load FUSE at startup.  " +
                                         "Add \"modprobe fuse\" to /etc/init.d/boot.local or \"fuse\" to /etc/modules."));
            int response = dialog.Run();

            dialog.Destroy();
            if (response == (int)Gtk.ResponseType.Yes)
            {
                // "modprobe fuse"
                Process p = new Process();
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.FileName        = guisuTool;
                p.StartInfo.Arguments       = string.Format("{0} fuse", modprobeTool);
                p.StartInfo.CreateNoWindow  = true;
                p.Start();
                p.WaitForExit();

                if (p.ExitCode != 0)
                {
                    Logger.Warn("Couldn't enable fuse");

                    // Let the user know that they don't have FUSE installed on their machine
                    HIGMessageDialog failedDlg =
                        new HIGMessageDialog(null,
                                             Gtk.DialogFlags.Modal,
                                             Gtk.MessageType.Error,
                                             Gtk.ButtonsType.Ok,
                                             Catalog.GetString("Could not enable FUSE"),
                                             Catalog.GetString("The FUSE module could not be loaded. " +
                                                               "Please check that it is installed properly " +
                                                               "and try again."));
                    failedDlg.Run();
                    failedDlg.Destroy();
                    return(false);
                }

                // "echo fuse >> /etc/modules"

                /*
                 * // Punting for now.  Can't seem to get this to work.
                 * // When using /etc/init.d/boot.local, you should add "modprobe fuse",
                 * // and not what has been coded below.
                 * p = new Process ();
                 * p.StartInfo.UseShellExecute = false;
                 * p.StartInfo.FileName = guisuTool;
                 * p.StartInfo.Arguments = string.Format ("\"{0} fuse >> {1}\"",
                 * echoTool, bootLocalFile);
                 * p.StartInfo.CreateNoWindow = true;
                 * p.Start ();
                 * p.WaitForExit ();
                 * if (p.ExitCode != 0) {
                 * Logger.Warn ("Could not enable FUSE persistently.  User will have to be prompted again during their next login session.");
                 * }
                 */
                return(true);
            }

            return(false);
        }
示例#26
0
		void OnResetSyncAddinButton (object sender, EventArgs args)
		{
			if (selectedSyncAddin == null)
				return;

			// User doesn't get a choice if this is invoked by disabling the addin
			// FIXME: null sender check is lame!
			if (sender != null) {
				// Prompt the user about what they're about to do since
				// it's not really recommended to switch back and forth
				// between sync services.
				HIGMessageDialog dialog =
				        new HIGMessageDialog (null,
				                              Gtk.DialogFlags.Modal,
				                              Gtk.MessageType.Question,
				                              Gtk.ButtonsType.YesNo,
				                              Catalog.GetString ("Are you sure?"),
				                              Catalog.GetString (
				                                      "Clearing your synchronization settings is not recommended.  " +
				                                      "You may be forced to synchronize all of your notes again " +
				                                      "when you save new settings."));
				int response = dialog.Run ();
				dialog.Destroy ();
				if (response != (int) Gtk.ResponseType.Yes)
					return;
			} else { // FIXME: Weird place for this to go.  User should be able to cancel disabling of addin, anyway
				HIGMessageDialog dialog =
				        new HIGMessageDialog (null,
				                              Gtk.DialogFlags.Modal,
				                              Gtk.MessageType.Info,
				                              Gtk.ButtonsType.Ok,
				                              Catalog.GetString ("Resetting Synchronization Settings"),
				                              Catalog.GetString (
				                                      "You have disabled the configured synchronization service.  " +
				                                      "Your synchronization settings will now be cleared.  " +
				                                      "You may be forced to synchronize all of your notes again " +
				                                      "when you save new settings."));
				dialog.Run ();
				dialog.Destroy ();
			}

			try {
				selectedSyncAddin.ResetConfiguration ();
			} catch (Exception e) {
				Logger.Debug ("Error calling {0}.ResetConfiguration: {1}\n{2}",
				              selectedSyncAddin.Id, e.Message, e.StackTrace);
			}

			Preferences.Set (
			        Preferences.SYNC_SELECTED_SERVICE_ADDIN,
			        String.Empty);

			// Reset conflict handling behavior
			Preferences.Set (
			        Preferences.SYNC_CONFIGURED_CONFLICT_BEHAVIOR,
			        Preferences.GetDefault (Preferences.SYNC_CONFIGURED_CONFLICT_BEHAVIOR));

			SyncManager.ResetClient ();

			syncAddinCombo.Sensitive = true;
			resetSyncAddinButton.Sensitive = false;
			saveSyncAddinButton.Sensitive = true;
			if (syncAddinPrefsWidget != null)
				syncAddinPrefsWidget.Sensitive = true;
		}
		/// <summary>
		/// Shows an error dialog if things go wrong.
		/// </summary>
		/// <param name="output_folder">
		/// A <see cref="System.String"/> with the name of the folder
		/// that couldn't be exported to.
		/// </param>
		/// <param name="dialog">
		/// The parent <see cref="ExportMultipleDialog"/>.
		/// </param>
		/// <param name="error_message">
		/// A <see cref="System.String"/> with an error description.
		/// </param>
		private static void ShowErrorDialog (string output_folder, ExportMultipleDialog dialog,
		                                     string error_message)
		{
			string msg = String.Format (
			                     Catalog.GetString ("Could not save the files in \"{0}\""),
			                     output_folder);
				HIGMessageDialog msg_dialog =
				        new HIGMessageDialog (
				        dialog,
				        Gtk.DialogFlags.DestroyWithParent,
				        Gtk.MessageType.Error,
				        Gtk.ButtonsType.Ok,
				        msg,
				        error_message);
				msg_dialog.Run ();
				msg_dialog.Destroy ();
			dialog.Destroy ();
			Logger.Error (error_message);
		}
示例#28
0
		/// <summary>
		/// Attempt to save/test the connection to the sync addin.
		/// </summary>
		void OnSaveSyncAddinButton (object sender, EventArgs args)
		{
			if (selectedSyncAddin == null)
				return;

			bool saved = false;
			string errorMsg = null;
			try {
				GdkWindow.Cursor = new Gdk.Cursor (Gdk.CursorType.Watch);
				GdkWindow.Display.Flush ();
				saved = selectedSyncAddin.SaveConfiguration ();
			} catch (TomboySyncException syncEx) {
				errorMsg = syncEx.Message;
			} catch (Exception e) {
				Logger.Debug ("Unexpected error calling {0}.SaveConfiguration: {1}\n{2}",
				              selectedSyncAddin.Id, e.Message, e.StackTrace);
			} finally {
				GdkWindow.Cursor = null;
				GdkWindow.Display.Flush ();
			}

			HIGMessageDialog dialog;
			if (saved) {
				Preferences.Set (
				        Preferences.SYNC_SELECTED_SERVICE_ADDIN,
				        selectedSyncAddin.Id);

				syncAddinCombo.Sensitive = false;
				syncAddinPrefsWidget.Sensitive = false;
				resetSyncAddinButton.Sensitive = true;
				saveSyncAddinButton.Sensitive = false;

				SyncManager.ResetClient ();

				// Give the user a visual letting them know that connecting
				// was successful.
				// TODO: Replace Yes/No with Sync/Close
				dialog =
				        new HIGMessageDialog (this,
				                              Gtk.DialogFlags.Modal,
				                              Gtk.MessageType.Info,
				                              Gtk.ButtonsType.YesNo,
				                              Catalog.GetString ("Connection successful"),
				                              Catalog.GetString (
				                                      "Tomboy is ready to synchronize your notes. Would you like to synchronize them now?"));
				int response = dialog.Run ();
				dialog.Destroy ();

				if (response == (int) Gtk.ResponseType.Yes)
					// TODO: Put this voodoo in a method somewhere
					Tomboy.ActionManager ["NoteSynchronizationAction"].Activate ();
			} else {
				// TODO: Change the SyncServiceAddin API so the call to
				// SaveConfiguration has a way of passing back an exception
				// or other text so it can be displayed to the user.
				Preferences.Set (
				        Preferences.SYNC_SELECTED_SERVICE_ADDIN,
				        String.Empty);

				syncAddinCombo.Sensitive = true;
				syncAddinPrefsWidget.Sensitive = true;
				resetSyncAddinButton.Sensitive = false;
				saveSyncAddinButton.Sensitive = true;

				// Give the user a visual letting them know that connecting
				// was successful.
				if (errorMsg == null) {
					errorMsg = Catalog.GetString ("Please check your information and " +
					                              "try again.  The log file {0} may " +
					                              "contain more information about the error.");
					string logPath = System.IO.Path.Combine (Services.NativeApplication.LogDirectory,
					                                         "tomboy.log");
					errorMsg = String.Format (errorMsg, logPath);
				}
				dialog =
				        new HIGMessageDialog (this,
				                              Gtk.DialogFlags.Modal,
				                              Gtk.MessageType.Warning,
				                              Gtk.ButtonsType.Close,
				                              Catalog.GetString ("Error connecting"),
				                              errorMsg);
				dialog.Run ();
				dialog.Destroy ();
			}
		}
示例#29
0
		/// <summary>
		/// Prompt the user and delete the notebok (if they say so).
		/// </summary>
		/// <param name="parent">
		/// A <see cref="Gtk.Window"/>
		/// </param>
		/// <param name="notebook">
		/// A <see cref="Notebook"/>
		/// </param>
		public static void PromptDeleteNotebook (Gtk.Window parent, Notebook notebook)
		{
			// Confirmation Dialog
			HIGMessageDialog dialog =
				new HIGMessageDialog (parent,
									  Gtk.DialogFlags.Modal,
									  Gtk.MessageType.Question,
									  Gtk.ButtonsType.YesNo,
									  Catalog.GetString ("Really delete this notebook?"),
									  Catalog.GetString (
									  	"The notes that belong to this notebook will not be " +
									  	"deleted, but they will no longer be associated with " +
									  	"this notebook.  This action cannot be undone."));
			dialog.DefaultResponse = Gtk.ResponseType.No;
			int response = dialog.Run ();
			dialog.Destroy ();
			if (response != (int) Gtk.ResponseType.Yes)
				return;
			
			// Grab the template note before removing all the notebook tags
			Note templateNote = notebook.GetTemplateNote ();
			
			DeleteNotebook (notebook);

			// Delete the template note
			if (templateNote != null) {
				NoteManager noteManager = Tomboy.DefaultNoteManager;
				noteManager.Delete (templateNote);
			}
		}
示例#30
0
文件: Note.cs 项目: GNOME/tomboy
		public static void ShowDeletionDialog (List<Note> notes, Gtk.Window parent)
		{
			string message;

			if ((bool) Preferences.Get (Preferences.ENABLE_DELETE_CONFIRM)) {
				// show confirmation dialog
				if (notes.Count == 1) {
					Note note = notes[0];
					message = string.Format (Catalog.GetString ("Really delete \"{0}\"?"), note.Title) ;	
				} else
					message = string.Format (Catalog.GetPluralString (
						"Really delete this {0} note?",
						"Really delete these {0} notes?",
						notes.Count), notes.Count);
			
				HIGMessageDialog dialog =
				        new HIGMessageDialog (
				        parent,
				        Gtk.DialogFlags.DestroyWithParent,
				        Gtk.MessageType.Question,
				        Gtk.ButtonsType.None,
				        message,
				        Catalog.GetString ("If you delete a note it is " +
			                           "permanently lost."));

				Gtk.Button button;

				button = new Gtk.Button (Gtk.Stock.Cancel);
				button.CanDefault = true;
				button.Show ();
				dialog.AddActionWidget (button, Gtk.ResponseType.Cancel);
				dialog.DefaultResponse = Gtk.ResponseType.Cancel;

				button = new Gtk.Button (Gtk.Stock.Delete);
				button.CanDefault = true;
				button.Show ();
				dialog.AddActionWidget (button, 666);

				int result = dialog.Run ();
				if (result == 666) {
					foreach (Note note in notes) {
						note.Manager.Delete (note);
					}
				}

				dialog.Destroy();
			} else {
				// no confirmation dialog, just delete
				foreach (Note note in notes) {
					note.Manager.Delete (note);
				}
			}
		}
示例#31
0
文件: Note.cs 项目: GNOME/tomboy
		public static void ShowIOErrorDialog (Gtk.Window parent)
		{
			// Translators: "note autosaving" is a periodic process we normally run
			// in the background and not an invitation for the user to note something.
			string errorMsg = Catalog.GetString ("An error occurred while saving your notes. " +
			                                     "Please check that you have sufficient disk " +
			                                     "space, and that you have appropriate rights " +
			                                     "on {0}. Error details can be found in " +
			                                     "{1}.\n\n" +
			                                     "Note autosaving is disabled until you close this dialog, " +
			                                     "to allow you to take an appropriate action.");
			string logPath = System.IO.Path.Combine (Services.NativeApplication.LogDirectory,
			                                         "tomboy.log");
			errorMsg = String.Format (errorMsg,
			                          Services.NativeApplication.DataDirectory,
			                          logPath);
			HIGMessageDialog dialog =
				new HIGMessageDialog (
				                      parent,
				                      Gtk.DialogFlags.DestroyWithParent,
				                      Gtk.MessageType.Error,
				                      Gtk.ButtonsType.Ok,
				                      Catalog.GetString ("Error saving note data."),
				                      errorMsg);
			dialog.Run ();
			dialog.Destroy ();
		}
		protected override bool OnActivate (NoteEditor editor,
		                                    Gtk.TextIter start,
		                                    Gtk.TextIter end)
		{
			string persona = start.GetText (end);
			PersonLink plink = (PersonLink) galago.Trie.Lookup (persona);

			try {
				plink.SendMessage ();
			} catch (Exception e) {
				string title = Catalog.GetString ("Cannot contact '{0}'");
				title = String.Format (title, persona);

				string message = Catalog.GetString ("Error running gaim-remote: {0}");
				message = String.Format (message, e.Message);

				Logger.Log (message);

				HIGMessageDialog dialog =
				        new HIGMessageDialog (editor.Toplevel as Gtk.Window,
				                              Gtk.DialogFlags.DestroyWithParent,
				                              Gtk.MessageType.Info,
				                              Gtk.ButtonsType.Ok,
				                              title,
				                              message);
				dialog.Run ();
				dialog.Destroy ();
			}

			return true;
		}