[pdfmod] Handle Hyena.Log msgs meant to be shown to the user



commit f514497a54956d218794c2fc9063961ab86abe2e
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Wed Jul 29 21:20:49 2009 -0700

    Handle Hyena.Log msgs meant to be shown to the user

 src/PdfMod/PdfMod/PdfMod.cs |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/src/PdfMod/PdfMod/PdfMod.cs b/src/PdfMod/PdfMod/PdfMod.cs
index d1ec35a..9b93015 100644
--- a/src/PdfMod/PdfMod/PdfMod.cs
+++ b/src/PdfMod/PdfMod/PdfMod.cs
@@ -23,6 +23,7 @@ namespace PdfMod
             ThreadAssist.ProxyToMainHandler = RunIdle;
 
             Hyena.Log.Debugging = true;
+            Hyena.Log.Notify += OnLogNotify;
             Hyena.Log.DebugFormat ("Starting PdfMod");
 
             Gtk.Application.Init ();
@@ -275,6 +276,33 @@ namespace PdfMod
             Window.Title = title == null ? filename : String.Format ("{0} ({1})", title, filename);
         }
 
+        private static void OnLogNotify (LogNotifyArgs args)
+        {
+            Gtk.Window window = null;
+            Gtk.MessageType mtype;
+            var entry = args.Entry;
+
+            switch (entry.Type) {
+                case LogEntryType.Warning:
+                    mtype = Gtk.MessageType.Warning;
+                    break;
+                case LogEntryType.Information:
+                    mtype = Gtk.MessageType.Info;
+                    break;
+                case LogEntryType.Error:
+                default:
+                    mtype = Gtk.MessageType.Error;
+                    break;
+            }
+
+            Hyena.Widgets.HigMessageDialog dialog = new Hyena.Widgets.HigMessageDialog (
+                null, Gtk.DialogFlags.Modal, mtype, Gtk.ButtonsType.Close, entry.Message, entry.Details);
+
+            dialog.Title = String.Empty;
+            dialog.Run ();
+            dialog.Destroy ();
+        }
+
         private static void InitCatalog (params string [] dirs)
         {
             foreach (var dir in dirs) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]