[tomboy] Added Enable Startup Notes into Advanced preferences



commit 49ae4a9f1644240f1437469ba9ba0715036c7e94
Author: Alex Tereschenko <frozen and blue gmail com>
Date:   Sun Apr 14 22:09:18 2013 +0200

    Added Enable Startup Notes into Advanced preferences
    
    Signed-off-by: Jared Jennings <jared jaredjennings org>

 .../AdvancedPreferences/AdvancedPreferences.csproj |  1 +
 .../AdvancedPreferencesAddin.cs                    | 22 +++++----
 .../EnableStartupNotesPreference.cs                | 55 ++++++++++++++++++++++
 Tomboy/Addins/AdvancedPreferences/Makefile.am      |  3 +-
 .../MenuMinMaxNoteCountPreference.cs               |  9 +++-
 5 files changed, 78 insertions(+), 12 deletions(-)
---
diff --git a/Tomboy/Addins/AdvancedPreferences/AdvancedPreferences.csproj 
b/Tomboy/Addins/AdvancedPreferences/AdvancedPreferences.csproj
index f78351f..60bc6e9 100644
--- a/Tomboy/Addins/AdvancedPreferences/AdvancedPreferences.csproj
+++ b/Tomboy/Addins/AdvancedPreferences/AdvancedPreferences.csproj
@@ -60,6 +60,7 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="AdvancedPreferencesAddin.cs" />
+    <Compile Include="EnableStartupNotesPreference.cs" />
     <Compile Include="MenuMinMaxNoteCountPreference.cs" />
     <EmbeddedResource Include="AdvancedPreferences.addin.xml" />
     <None Include="Makefile.am" />
diff --git a/Tomboy/Addins/AdvancedPreferences/AdvancedPreferencesAddin.cs 
b/Tomboy/Addins/AdvancedPreferences/AdvancedPreferencesAddin.cs
index 2e1de19..180901c 100644
--- a/Tomboy/Addins/AdvancedPreferences/AdvancedPreferencesAddin.cs
+++ b/Tomboy/Addins/AdvancedPreferences/AdvancedPreferencesAddin.cs
@@ -19,30 +19,34 @@ namespace Tomboy.AdvancedPreferences
                                                                out string tabLabel,
                                                                out Gtk.Widget preferenceWidget)
                {
-                       
-                       Gtk.Alignment align;
 
                        // Addin's tab caption
                        tabLabel = Catalog.GetString ("Advanced");
-                       
+
                        Gtk.VBox opts_list = new Gtk.VBox (false, 12);
                        opts_list.BorderWidth = 12;
                        opts_list.Show ();
-                       
-                       align = new Gtk.Alignment (0.5f, 0.5f, 0.0f, 1.0f);
-                       align.Show ();
-                       opts_list.PackStart (align, false, false, 0);
 
                        /*
                        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;
+                               3) (similar to the below) instantiate object of your class and PackStart its 
widget to opts_list;
+                               It's expected that the returned widget is already within Gtk.Alignment, so no 
further alignment done.
                        */
+
+                       // TODO: More elegant way of implementing this would be to create a collection of 
"prefs" objects
+                       // and iterate over them adding them to opts_list (fewer lines to add upon adding new 
setting).
+
                        // 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);
+                       opts_list.PackStart(menuNoteCountPref.Widget, false, false, 0);
+
+                       //Instantiate class for Enable Startup Notes setting
+                       EnableStartupNotesPreference enableStartupNotesPref = new 
EnableStartupNotesPreference();
+                       // Add the widget to the Advanced tab
+                       opts_list.PackStart (enableStartupNotesPref.Widget, false, false, 0);
 
                        if (opts_list != null) {
                                preferenceWidget = opts_list;
diff --git a/Tomboy/Addins/AdvancedPreferences/EnableStartupNotesPreference.cs 
b/Tomboy/Addins/AdvancedPreferences/EnableStartupNotesPreference.cs
new file mode 100644
index 0000000..55f4afb
--- /dev/null
+++ b/Tomboy/Addins/AdvancedPreferences/EnableStartupNotesPreference.cs
@@ -0,0 +1,55 @@
+// Class for Enable Startup Notes 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 Enable Startup Notes setting for Advanced preferences tab
+       /// </summary>
+       public class EnableStartupNotesPreference
+       {
+               // This will store all widgets
+               private Gtk.Alignment align;
+
+               public EnableStartupNotesPreference ()
+               {
+                       IPropertyEditorBool enableStartupNotes_peditor;
+                       Gtk.CheckButton enableStartupNotesCheckbox;
+                       Gtk.Label enableStartupNotesLabel;
+
+                       // Enable Startup Notes option
+                       enableStartupNotesLabel = new Gtk.Label (Catalog.GetString ("Enable startup notes"));
+                       enableStartupNotesLabel.UseMarkup = true;
+                       enableStartupNotesLabel.Justify = Gtk.Justification.Left;
+                       enableStartupNotesLabel.SetAlignment (0.0f, 0.5f);
+                       enableStartupNotesLabel.Show ();
+
+                       enableStartupNotesCheckbox = new Gtk.CheckButton ();
+                       enableStartupNotesCheckbox.Add (enableStartupNotesLabel);
+                       enableStartupNotesCheckbox.Show ();
+
+                       enableStartupNotes_peditor =
+                               Services.Factory.CreatePropertyEditorToggleButton 
(Preferences.ENABLE_STARTUP_NOTES, enableStartupNotesCheckbox);
+                       Preferences.Get (enableStartupNotes_peditor.Key);
+                       enableStartupNotes_peditor.Setup ();
+
+                       align = new Gtk.Alignment (0.0f, 0.0f, 0.0f, 1.0f);
+                       align.Show ();
+                       align.Add (enableStartupNotesCheckbox);
+               }
+
+               public Gtk.Widget Widget
+               {
+                       get
+                       {
+                               return align;
+                       }
+               }
+       }
+}
\ No newline at end of file
diff --git a/Tomboy/Addins/AdvancedPreferences/Makefile.am b/Tomboy/Addins/AdvancedPreferences/Makefile.am
index 6fc6883..5a0e1a6 100644
--- a/Tomboy/Addins/AdvancedPreferences/Makefile.am
+++ b/Tomboy/Addins/AdvancedPreferences/Makefile.am
@@ -15,7 +15,8 @@ ADDIN_NAME = AdvancedPreferences
 TARGET = $(top_builddir)/bin/addins/$(ADDIN_NAME).dll
 CSFILES = \
        $(srcdir)/AdvancedPreferencesAddin.cs \
-       $(srcdir)/MenuMinMaxNoteCountPreference.cs
+       $(srcdir)/MenuMinMaxNoteCountPreference.cs \
+       $(srcdir)/EnableStartupNotesPreference.cs
        
 RESOURCES = \
        -resource:$(srcdir)/$(ADDIN_NAME).addin.xml
diff --git a/Tomboy/Addins/AdvancedPreferences/MenuMinMaxNoteCountPreference.cs 
b/Tomboy/Addins/AdvancedPreferences/MenuMinMaxNoteCountPreference.cs
index cc9bed8..015c615 100644
--- a/Tomboy/Addins/AdvancedPreferences/MenuMinMaxNoteCountPreference.cs
+++ b/Tomboy/Addins/AdvancedPreferences/MenuMinMaxNoteCountPreference.cs
@@ -22,6 +22,7 @@ namespace Tomboy.AdvancedPreferences
                private int menuMaxNoteCount;
                // This will store both labels and spinbuttons
                private Gtk.Table table;
+               private Gtk.Alignment align;
 
                public MenuMinMaxNoteCountPreference ()
                {
@@ -68,6 +69,10 @@ namespace Tomboy.AdvancedPreferences
                        menuMaxNoteCountSpinner.Show ();
                        table.Attach (menuMaxNoteCountSpinner, 1, 2, 1, 2);
                        menuMaxNoteCountSpinner.ValueChanged += UpdateMenuMaxNoteCountPreference;
+
+                       align = new Gtk.Alignment (0.0f, 0.0f, 0.0f, 1.0f);
+                       align.Show ();
+                       align.Add (table);
                }
 
                // This one is an event handler for a SpinButton, used to set the menu Min note count
@@ -92,11 +97,11 @@ namespace Tomboy.AdvancedPreferences
                        menuMinNoteCountSpinner.SetRange(min, spinner.Value);
                }
 
-               public Gtk.Table Widget
+               public Gtk.Widget Widget
                {
                        get
                        {
-                               return table;
+                               return align;
                        }
                }
        }


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