[tomboy] Max number of notes in tray menu is now configurable
- From: Jared L Jennings <jjennings src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tomboy] Max number of notes in tray menu is now configurable
- Date: Sat, 19 Jan 2013 21:17:35 +0000 (UTC)
commit 9a19da74d9c260a7f65d26acea529258c625eade
Author: Alex Tereschenko <frozen and blue gmail com>
Date: Sun Jan 13 14:04:35 2013 +0100
Max number of notes in tray menu is now configurable
Signed-off-by: Jared Jennings <jared jaredjennings org>
.../AdvancedPreferences.addin.xml | 2 +-
.../AdvancedPreferences/AdvancedPreferences.csproj | 1 +
.../AdvancedPreferencesAddin.cs | 52 +++--------
Tomboy/Addins/AdvancedPreferences/Makefile.am | 3 +-
.../MenuMinMaxNoteCountPreference.cs | 103 ++++++++++++++++++++
Tomboy/Preferences.cs | 4 +
Tomboy/Tray.cs | 4 +-
data/tomboy.schemas.in | 15 +++
8 files changed, 141 insertions(+), 43 deletions(-)
---
diff --git a/Tomboy/Addins/AdvancedPreferences/AdvancedPreferences.addin.xml b/Tomboy/Addins/AdvancedPreferences/AdvancedPreferences.addin.xml
index 2f1c056..de20e5c 100644
--- a/Tomboy/Addins/AdvancedPreferences/AdvancedPreferences.addin.xml
+++ b/Tomboy/Addins/AdvancedPreferences/AdvancedPreferences.addin.xml
@@ -5,7 +5,7 @@
description="Adds Advanced tab to preferences dialog"
category="Preferences"
defaultEnabled="false"
- version="1.1">
+ version="2.0">
<Runtime>
<Import assembly="AdvancedPreferences.dll" />
diff --git a/Tomboy/Addins/AdvancedPreferences/AdvancedPreferences.csproj b/Tomboy/Addins/AdvancedPreferences/AdvancedPreferences.csproj
index 9c3b3ff..e42e608 100644
--- a/Tomboy/Addins/AdvancedPreferences/AdvancedPreferences.csproj
+++ b/Tomboy/Addins/AdvancedPreferences/AdvancedPreferences.csproj
@@ -59,6 +59,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AdvancedPreferencesAddin.cs" />
+ <Compile Include="MenuMinMaxNoteCountPreference.cs" />
<EmbeddedResource Include="AdvancedPreferences.addin.xml" />
<None Include="Makefile.am" />
</ItemGroup>
diff --git a/Tomboy/Addins/AdvancedPreferences/AdvancedPreferencesAddin.cs b/Tomboy/Addins/AdvancedPreferences/AdvancedPreferencesAddin.cs
index f56d03c..2e1de19 100644
--- a/Tomboy/Addins/AdvancedPreferences/AdvancedPreferencesAddin.cs
+++ b/Tomboy/Addins/AdvancedPreferences/AdvancedPreferencesAddin.cs
@@ -1,5 +1,5 @@
ï// Plugin for Tomboy Advanced preferences tab
-// (c) 2011 Alex Tereschenko <frozenblue zoho com>
+// (c) 2011-2013 Alex Tereschenko <frozen and blue gmail com>
// LGPL 2.1 or later
using System;
@@ -14,25 +14,13 @@ namespace Tomboy.AdvancedPreferences
/// </summary>
public class AdvancedPreferencesAddin : PreferenceTabAddin
{
-
- // This one is an event handler for a SpinButton, used to set the menu note count
- private void UpdateMenuNoteCountPreference (object source, EventArgs args)
- {
- Gtk.SpinButton spinner = source as SpinButton;
- Preferences.Set (Preferences.MENU_NOTE_COUNT, spinner.ValueAsInt);
-
- }
-
-
+
public override bool GetPreferenceTabWidget ( PreferencesDialog parent,
out string tabLabel,
out Gtk.Widget preferenceWidget)
{
- Gtk.Label label;
- Gtk.SpinButton menuNoteCountSpinner;
Gtk.Alignment align;
- int menuNoteCount;
// Addin's tab caption
tabLabel = Catalog.GetString ("Advanced");
@@ -45,33 +33,17 @@ namespace Tomboy.AdvancedPreferences
align.Show ();
opts_list.PackStart (align, false, false, 0);
- Gtk.Table table = new Gtk.Table (1, 2, false);
- table.ColumnSpacing = 6;
- table.RowSpacing = 6;
- table.Show ();
- align.Add (table);
-
+ /*
+ If you want to add new settings to the Advanced tab - follow the steps below:
+ 1) define a class which implements the functionality (see e.g. MenuMinMaxNoteCountPreference.cs);
+ 2) define property/method for that class that returns the widget you want to place onto the tab;
+ 3) (similar to the below) instantiate object of your class and add its widget to the "align" widget;
+ */
+ // Instantiate class for Menu Min/Max Note Count setting
+ MenuMinMaxNoteCountPreference menuNoteCountPref = new MenuMinMaxNoteCountPreference();
+ // Add the widget for this setting to the Advanced tab
+ align.Add (menuNoteCountPref.Widget);
- // Menu Note Count option
- label = new Gtk.Label (Catalog.GetString ("Minimum number of notes to show in Recent list (maximum 18)"));
-
- label.UseMarkup = true;
- label.Justify = Gtk.Justification.Left;
- label.SetAlignment (0.0f, 0.5f);
- label.Show ();
-
- table.Attach (label, 0, 1, 0, 1);
-
- menuNoteCount = (int) Preferences.Get (Preferences.MENU_NOTE_COUNT);
- // we have a hard limit of 18 set, thus not allowing anything bigger than 18
- menuNoteCountSpinner = new Gtk.SpinButton (1, 18, 1);
- menuNoteCountSpinner.Value = menuNoteCount <= 18 ? menuNoteCount : 18;
-
- menuNoteCountSpinner.Show ();
- table.Attach (menuNoteCountSpinner, 1, 2, 0, 1);
-
- menuNoteCountSpinner.ValueChanged += UpdateMenuNoteCountPreference;
-
if (opts_list != null) {
preferenceWidget = opts_list;
return true;
diff --git a/Tomboy/Addins/AdvancedPreferences/Makefile.am b/Tomboy/Addins/AdvancedPreferences/Makefile.am
index 5e0c38d..6fc6883 100644
--- a/Tomboy/Addins/AdvancedPreferences/Makefile.am
+++ b/Tomboy/Addins/AdvancedPreferences/Makefile.am
@@ -14,7 +14,8 @@ ASSEMBLIES = \
ADDIN_NAME = AdvancedPreferences
TARGET = $(top_builddir)/bin/addins/$(ADDIN_NAME).dll
CSFILES = \
- $(srcdir)/AdvancedPreferencesAddin.cs
+ $(srcdir)/AdvancedPreferencesAddin.cs \
+ $(srcdir)/MenuMinMaxNoteCountPreference.cs
RESOURCES = \
-resource:$(srcdir)/$(ADDIN_NAME).addin.xml
diff --git a/Tomboy/Addins/AdvancedPreferences/MenuMinMaxNoteCountPreference.cs b/Tomboy/Addins/AdvancedPreferences/MenuMinMaxNoteCountPreference.cs
new file mode 100644
index 0000000..cc9bed8
--- /dev/null
+++ b/Tomboy/Addins/AdvancedPreferences/MenuMinMaxNoteCountPreference.cs
@@ -0,0 +1,103 @@
+ï// Class for Menu Min/Max Note Count setting of Tomboy Advanced preferences tab
+// (c) 2013 Alex Tereschenko <frozen and blue gmail com>
+// LGPL 2.1 or later
+
+using System;
+using Gtk;
+using Mono.Unix;
+using Tomboy;
+
+namespace Tomboy.AdvancedPreferences
+{
+ /// <summary>
+ /// Contains a class for Menu Min/Max Note Count setting for Advanced preferences tab
+ /// </summary>
+ public class MenuMinMaxNoteCountPreference
+ {
+ private Gtk.Label menuMinNoteCountLabel;
+ private Gtk.SpinButton menuMinNoteCountSpinner;
+ private int menuMinNoteCount;
+ private Gtk.Label menuMaxNoteCountLabel;
+ private Gtk.SpinButton menuMaxNoteCountSpinner;
+ private int menuMaxNoteCount;
+ // This will store both labels and spinbuttons
+ private Gtk.Table table;
+
+ public MenuMinMaxNoteCountPreference ()
+ {
+ table = new Gtk.Table (2, 2, false);
+ table.ColumnSpacing = 6;
+ table.RowSpacing = 6;
+ table.Show ();
+
+ // Menu Min Note Count option
+ menuMinNoteCountLabel = new Gtk.Label (Catalog.GetString ("Minimum number of notes to show in Recent list"));
+
+ menuMinNoteCountLabel.UseMarkup = true;
+ menuMinNoteCountLabel.Justify = Gtk.Justification.Left;
+ menuMinNoteCountLabel.SetAlignment (0.0f, 0.5f);
+ menuMinNoteCountLabel.Show ();
+ table.Attach (menuMinNoteCountLabel, 0, 1, 0, 1);
+
+ menuMinNoteCount = (int) Preferences.Get (Preferences.MENU_NOTE_COUNT);
+ menuMaxNoteCount = (int) Preferences.Get (Preferences.MENU_MAX_NOTE_COUNT);
+ // This is to avoid having Max bigger than absolute maximum if someone changed the setting
+ // outside of the Tomboy using e.g. gconf
+ menuMaxNoteCount = (menuMaxNoteCount <= int.MaxValue ? menuMaxNoteCount : int.MaxValue);
+ // This is to avoid having Min bigger than Max if someone changed the setting
+ // outside of the Tomboy using e.g. gconf
+ menuMinNoteCount = (menuMinNoteCount <= menuMaxNoteCount ? menuMinNoteCount : menuMaxNoteCount);
+
+ menuMinNoteCountSpinner = new Gtk.SpinButton (1, menuMaxNoteCount, 1);
+ menuMinNoteCountSpinner.Value = menuMinNoteCount;
+ menuMinNoteCountSpinner.Show ();
+ table.Attach (menuMinNoteCountSpinner, 1, 2, 0, 1);
+ menuMinNoteCountSpinner.ValueChanged += UpdateMenuMinNoteCountPreference;
+
+ // Menu Max Note Count option
+ menuMaxNoteCountLabel = new Gtk.Label (Catalog.GetString ("Maximum number of notes to show in Recent list"));
+
+ menuMaxNoteCountLabel.UseMarkup = true;
+ menuMaxNoteCountLabel.Justify = Gtk.Justification.Left;
+ menuMaxNoteCountLabel.SetAlignment (0.0f, 0.5f);
+ menuMaxNoteCountLabel.Show ();
+ table.Attach (menuMaxNoteCountLabel, 0, 1, 1, 2);
+
+ menuMaxNoteCountSpinner = new Gtk.SpinButton (menuMinNoteCount, int.MaxValue, 1);
+ menuMaxNoteCountSpinner.Value = menuMaxNoteCount;
+ menuMaxNoteCountSpinner.Show ();
+ table.Attach (menuMaxNoteCountSpinner, 1, 2, 1, 2);
+ menuMaxNoteCountSpinner.ValueChanged += UpdateMenuMaxNoteCountPreference;
+ }
+
+ // This one is an event handler for a SpinButton, used to set the menu Min note count
+ private void UpdateMenuMinNoteCountPreference (object source, EventArgs args)
+ {
+ Gtk.SpinButton spinner = source as SpinButton;
+ Preferences.Set (Preferences.MENU_NOTE_COUNT, spinner.ValueAsInt);
+ // We need to update lower limit for menuMaxNoteCountSpinner in view of this change
+ double min, max;
+ menuMaxNoteCountSpinner.GetRange(out min, out max);
+ menuMaxNoteCountSpinner.SetRange(spinner.Value, max);
+ }
+
+ // This one is an event handler for a SpinButton, used to set the menu Max note count
+ private void UpdateMenuMaxNoteCountPreference (object source, EventArgs args)
+ {
+ Gtk.SpinButton spinner = source as SpinButton;
+ Preferences.Set (Preferences.MENU_MAX_NOTE_COUNT, spinner.ValueAsInt);
+ // We need to update upper limit for menuMinNoteCountSpinner in view of this change
+ double min, max;
+ menuMinNoteCountSpinner.GetRange(out min, out max);
+ menuMinNoteCountSpinner.SetRange(min, spinner.Value);
+ }
+
+ public Gtk.Table Widget
+ {
+ get
+ {
+ return table;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Tomboy/Preferences.cs b/Tomboy/Preferences.cs
index ba09d1a..801583c 100644
--- a/Tomboy/Preferences.cs
+++ b/Tomboy/Preferences.cs
@@ -21,6 +21,7 @@ namespace Tomboy
public const string START_NOTE_URI = "/apps/tomboy/start_note";
public const string CUSTOM_FONT_FACE = "/apps/tomboy/custom_font_face";
public const string MENU_NOTE_COUNT = "/apps/tomboy/menu_note_count";
+ public const string MENU_MAX_NOTE_COUNT = "/apps/tomboy/menu_max_note_count";
public const string MENU_PINNED_NOTES = "/apps/tomboy/menu_pinned_notes";
public const string MENU_ITEM_MAX_LENGTH = "/apps/tomboy/tray_menu_item_max_length";
@@ -104,6 +105,9 @@ namespace Tomboy
case MENU_NOTE_COUNT:
return 10;
+ case MENU_MAX_NOTE_COUNT:
+ return 18;
+
case MENU_PINNED_NOTES:
return string.Empty;
diff --git a/Tomboy/Tray.cs b/Tomboy/Tray.cs
index 46a3c26..1e36fb0 100644
--- a/Tomboy/Tray.cs
+++ b/Tomboy/Tray.cs
@@ -439,7 +439,9 @@ namespace Tomboy
public void AddRecentlyChangedNotes ()
{
int min_size = (int) Preferences.Get (Preferences.MENU_NOTE_COUNT);
- int max_size = 18;
+ int max_size = (int) Preferences.Get (Preferences.MENU_MAX_NOTE_COUNT);
+ if (max_size < min_size)
+ max_size = min_size;
int list_size = 0;
bool menuOpensUpward = tray.MenuOpensUpward ();
NoteMenuItem item;
diff --git a/data/tomboy.schemas.in b/data/tomboy.schemas.in
index b031397..d859124 100644
--- a/data/tomboy.schemas.in
+++ b/data/tomboy.schemas.in
@@ -168,6 +168,21 @@
</schema>
<schema>
+ <key>/schemas/apps/tomboy/menu_max_note_count</key>
+ <applyto>/apps/tomboy/menu_max_note_count</applyto>
+ <owner>tomboy</owner>
+ <type>int</type>
+ <default>18</default>
+ <locale name="C">
+ <short>Maximum number of notes to show in menu</short>
+ <long>
+ Integer determining the maximum number of notes to show in the Tomboy
+ note menu.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
<key>/schemas/apps/tomboy/menu_pinned_notes</key>
<applyto>/apps/tomboy/menu_pinned_notes</applyto>
<owner>tomboy</owner>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]