[pdfmod] Remember show_toolbar and last_open folder in gconf
- From: Gabriel Burt <gburt src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [pdfmod] Remember show_toolbar and last_open folder in gconf
- Date: Mon, 10 Aug 2009 19:26:39 +0000 (UTC)
commit 3647e8bd20533f317c8fa0deac29e89fec0512f2
Author: Gabriel Burt <gabriel burt gmail com>
Date: Mon Aug 10 12:23:32 2009 -0700
Remember show_toolbar and last_open folder in gconf
configure.ac | 1 +
src/PdfMod/Makefile.am | 2 +
src/PdfMod/PdfMod.mdp | 3 ++
src/PdfMod/PdfMod/Configuration.cs | 39 ++++++++++++++++++++++++++++++++++++
src/PdfMod/PdfMod/GlobalActions.cs | 11 ++++++++-
src/PdfMod/PdfMod/PdfMod.cs | 5 ++++
6 files changed, 59 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index a657e11..4bbe7ca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -109,6 +109,7 @@ dnl package checks, common for all configs
PKG_CHECK_MODULES([GTK_SHARP_20], [gtk-sharp-2.0])
PKG_CHECK_MODULES([GLIB_SHARP_20], [glib-sharp-2.0])
PKG_CHECK_MODULES([GNOME_SHARP_20], [gnome-sharp-2.0])
+PKG_CHECK_MODULES([GCONF_SHARP_20], [gconf-sharp-2.0])
dnl package checks, per config
diff --git a/src/PdfMod/Makefile.am b/src/PdfMod/Makefile.am
index be072f1..827e964 100644
--- a/src/PdfMod/Makefile.am
+++ b/src/PdfMod/Makefile.am
@@ -86,6 +86,7 @@ FILES = \
PdfMod/AssemblyInfo.cs \
PdfMod/CellRendererCairo.cs \
PdfMod/CellRendererPage.cs \
+ PdfMod/Configuration.cs \
PdfMod/Defines.cs \
PdfMod/Document.cs \
PdfMod/GlobalActions.cs \
@@ -108,6 +109,7 @@ EXTRAS = \
REFERENCES = \
Mono.Cairo \
Mono.Posix \
+ -pkg:gconf-sharp-2.0 \
-pkg:glade-sharp-2.0 \
-pkg:glib-sharp-2.0 \
-pkg:gnome-sharp-2.0 \
diff --git a/src/PdfMod/PdfMod.mdp b/src/PdfMod/PdfMod.mdp
index f418978..908bae8 100644
--- a/src/PdfMod/PdfMod.mdp
+++ b/src/PdfMod/PdfMod.mdp
@@ -39,6 +39,8 @@
<File name="PdfMod/PageThumbnail.cs" subtype="Code" buildaction="Compile" />
<File name="PdfMod/PageLabels.cs" subtype="Code" buildaction="Compile" />
<File name="PdfMod/Defines.cs.in" subtype="Code" buildaction="Nothing" />
+ <File name="PdfMod/Defines.cs" subtype="Code" buildaction="Compile" />
+ <File name="PdfMod/Configuration.cs" subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
@@ -58,6 +60,7 @@
<ProjectReference type="Assembly" localcopy="True" specificVersion="False" refto="../../lib/Hyena.Gui.dll" />
<ProjectReference type="Assembly" localcopy="True" specificVersion="False" refto="../../lib/poppler-sharp.dll" />
<ProjectReference type="Gac" localcopy="True" refto="gnome-sharp, Version=2.24.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+ <ProjectReference type="Gac" localcopy="True" refto="gconf-sharp, Version=2.24.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
</References>
<GtkDesignInfo gettextClass="Mono.Posix.Catalog" />
<MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="Makefile.am" BuildTargetName="" CleanTargetName="" SyncReferences="True" IsAutotoolsProject="True" RelativeConfigureInPath="../..">
diff --git a/src/PdfMod/PdfMod/Configuration.cs b/src/PdfMod/PdfMod/Configuration.cs
new file mode 100644
index 0000000..a41116e
--- /dev/null
+++ b/src/PdfMod/PdfMod/Configuration.cs
@@ -0,0 +1,39 @@
+
+using System;
+
+namespace PdfMod
+{
+ public class Configuration
+ {
+ private GConf.Client client = new GConf.Client ();
+ private string ns = "/apps/pdfmod/";
+
+ public Configuration()
+ {
+ }
+
+ private T Get<T> (string key, T fallback)
+ {
+ try {
+ return (T) client.Get (ns + key);
+ } catch {
+ return fallback;
+ }
+ }
+
+ private void Set<T> (string key, T val)
+ {
+ client.Set (ns + key, val);
+ }
+
+ public bool ShowToolbar {
+ get { return Get<bool> ("show_toolbar", true); }
+ set { Set<bool> ("show_toolbar", value); }
+ }
+
+ public string LastOpenFolder {
+ get { return Get<string> ("last_folder", System.Environment.GetFolderPath (System.Environment.SpecialFolder.Desktop)); }
+ set { Set<string> ("last_folder", value); }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/PdfMod/PdfMod/GlobalActions.cs b/src/PdfMod/PdfMod/GlobalActions.cs
index 0dbc2af..b33a5ed 100644
--- a/src/PdfMod/PdfMod/GlobalActions.cs
+++ b/src/PdfMod/PdfMod/GlobalActions.cs
@@ -80,7 +80,7 @@ namespace PdfMod
AddImportant (
new ToggleActionEntry ("Properties", Stock.Properties, null, "<alt>Return", Catalog.GetString ("View and edit the title, keywords, and more for this document"), OnProperties, false),
new ToggleActionEntry ("ZoomFit", Stock.ZoomFit, null, "<control>0", null, OnZoomFit, true),
- new ToggleActionEntry ("ViewToolbar", null, Catalog.GetString ("Toolbar"), null, null, OnViewToolbar, true)
+ new ToggleActionEntry ("ViewToolbar", null, Catalog.GetString ("Toolbar"), null, null, OnViewToolbar, PdfMod.Configuration.ShowToolbar)
);
this["RotateRight"].IconName = "object-rotate-right";
@@ -189,6 +189,11 @@ namespace PdfMod
chooser.AddButton (Stock.Cancel, ResponseType.Cancel);
chooser.AddButton (Stock.Open, ResponseType.Ok);
chooser.DefaultResponse = ResponseType.Ok;
+ if (app.Document != null) {
+ chooser.SetCurrentFolder (System.IO.Path.GetDirectoryName (app.Document.SuggestedSavePath));
+ } else {
+ chooser.SetCurrentFolder (PdfMod.Configuration.LastOpenFolder);
+ }
var response = chooser.Run ();
string filename = chooser.Filename;
@@ -210,6 +215,7 @@ namespace PdfMod
chooser.AddFilter (GtkUtilities.GetFileFilter ("PDF Documents", new string [] {"pdf"}));
chooser.AddFilter (GtkUtilities.GetFileFilter (Catalog.GetString ("All Files"), new string [] {"*"}));
chooser.SelectMultiple = false;
+ chooser.SetCurrentFolder (System.IO.Path.GetDirectoryName (app.Document.SuggestedSavePath));
chooser.AddButton (Stock.Cancel, ResponseType.Cancel);
chooser.AddButton (Stock.Open, ResponseType.Ok);
chooser.DefaultResponse = ResponseType.Ok;
@@ -500,7 +506,8 @@ namespace PdfMod
private void OnViewToolbar (object o, EventArgs args)
{
- app.HeaderToolbar.Visible = (this["ViewToolbar"] as ToggleAction).Active;
+ bool show = (this["ViewToolbar"] as ToggleAction).Active;
+ PdfMod.Configuration.ShowToolbar = app.HeaderToolbar.Visible = show;
}
private void OnRotateRight (object o, EventArgs args)
diff --git a/src/PdfMod/PdfMod/PdfMod.cs b/src/PdfMod/PdfMod/PdfMod.cs
index 21b79b0..0347867 100644
--- a/src/PdfMod/PdfMod/PdfMod.cs
+++ b/src/PdfMod/PdfMod/PdfMod.cs
@@ -27,6 +27,7 @@ namespace PdfMod
Gtk.Application.Init (null, ref args);
Gdk.Global.ProgramClass = "pdfmod";
+ Configuration = new Configuration ();
ThreadAssist.InitializeMainThread ();
ThreadAssist.ProxyToMainHandler = RunIdle;
@@ -55,6 +56,7 @@ namespace PdfMod
public PdfIconView IconView { get; private set; }
public Document Document { get; private set; }
public MetadataEditorBox EditorBox { get; private set; }
+ public static Configuration Configuration { get; private set; }
public event EventHandler DocumentLoaded;
@@ -102,6 +104,8 @@ namespace PdfMod
HeaderToolbar.ShowArrow = false;
HeaderToolbar.ToolbarStyle = ToolbarStyle.Icons;
HeaderToolbar.Tooltips = true;
+ HeaderToolbar.NoShowAll = true;
+ HeaderToolbar.Visible = Configuration.ShowToolbar;
var vbox = new VBox ();
vbox.PackStart (menu_bar, false, false, 0);
@@ -231,6 +235,7 @@ namespace PdfMod
loading = true;
}
+ Configuration.LastOpenFolder = System.IO.Path.GetDirectoryName (suggestedFilename ?? path);
status_label.Text = Catalog.GetString ("Loading document...");
ThreadAssist.SpawnFromMain (delegate {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]