[pdfmod] Save/Load the Gtk.AccelMap



commit 68080291aa7dcaf41224832fca9aa68550df1bc6
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Wed Aug 12 16:08:34 2009 -0700

    Save/Load the Gtk.AccelMap

 src/PdfMod/Core/Client.cs |    6 +++++-
 src/PdfMod/Gui/Client.cs  |   18 ++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/src/PdfMod/Core/Client.cs b/src/PdfMod/Core/Client.cs
index 6b5b667..d05d29b 100644
--- a/src/PdfMod/Core/Client.cs
+++ b/src/PdfMod/Core/Client.cs
@@ -59,7 +59,11 @@ namespace PdfMod.Core
             // Remove the old "cache" dir that really ended up being ~/.config/
             if (Directory.Exists (old_cache_dir)) {
                 try {
-                    Directory.Delete (old_cache_dir);
+                    foreach (string file in Directory.GetFiles (CacheDir)) {
+                        if (file.Contains ("tmpfile-")) {
+                            File.Delete (file);
+                        }
+                    }
                 } catch {}
             }
 
diff --git a/src/PdfMod/Gui/Client.cs b/src/PdfMod/Gui/Client.cs
index 675bee9..d2078a2 100644
--- a/src/PdfMod/Gui/Client.cs
+++ b/src/PdfMod/Gui/Client.cs
@@ -19,6 +19,8 @@ namespace PdfMod.Gui
     public class Client : Core.Client
     {
         private static int app_count = 0;
+        private static string accel_map_file = Path.Combine (Path.Combine (
+            XdgBaseDirectorySpec.GetUserDirectory ("XDG_CONFIG_HOME", ".config"), "pdfmod"), "gtk_accel_map");
 
         private Gtk.MenuBar menu_bar;
         private Gtk.Label status_label;
@@ -39,6 +41,15 @@ namespace PdfMod.Gui
             ThreadAssist.ProxyToMainHandler = RunIdle;
             Hyena.Log.Notify += OnLogNotify;
             Gtk.Window.DefaultIconName = "pdfmod";
+
+            try {
+                if (System.IO.File.Exists (accel_map_file)) {
+                    Gtk.AccelMap.Load (accel_map_file);
+                    Hyena.Log.DebugFormat ("Loaded custom AccelMap from {0}", accel_map_file);
+                }
+            } catch (Exception e) {
+                Hyena.Log.Exception ("Failed to load custom AccelMap", e);
+            }
         }
 
         public Client () : this (false)
@@ -141,6 +152,13 @@ namespace PdfMod.Gui
             Window = null;
 
             if (--app_count == 0) {
+                try {
+                    Directory.CreateDirectory (Path.GetDirectoryName (accel_map_file));
+                    Gtk.AccelMap.Save (accel_map_file);
+                } catch (Exception e) {
+                    Hyena.Log.Exception ("Failed to save custom AccelMap", e);
+                }
+
                 Application.Quit ();
             }
         }



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