Example #1
0
		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");
			
			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);

			Gtk.Table table = new Gtk.Table (1, 2, false);
			table.ColumnSpacing = 6;
			table.RowSpacing = 6;
			table.Show ();
			align.Add (table);


			// 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;
			} else {
				preferenceWidget = null;
				return false;
			}
		}
		public override bool GetPreferenceTabWidget (	PreferencesDialog parent,
								out string tabLabel,
								out Gtk.Widget preferenceWidget)
		{

			// Addin's tab caption
			tabLabel = Catalog.GetString ("Advanced");

			Gtk.VBox opts_list = new Gtk.VBox (false, 12);
			opts_list.BorderWidth = 12;
			opts_list.Show ();

			/*
			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 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
			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;
				return true;
			} else {
				preferenceWidget = null;
				return false;
			}
		}
		/// <summary>
		/// Returns a Gtk.Widget to place in a new tab in Tomboy's
		/// preferences dialog.
		/// <param name="parent">The preferences dialog.  Add-ins should
		/// use this for connecting to Hidden or other events as needed.
		/// Another use would be to pop open dialogs, so they can properly
		/// set their parent.
		/// </param>
		/// <param name="tabLabel">The string to be used in the tab's
		/// label.</param>
		/// <param name="preferenceWidget">The Gtk.Widget to use as the
		/// content of the tab page.</param>
		/// <returns>Returns <value>true</value> if the widget is
		/// valid/created or <value>false</value> otherwise.</returns>
		/// </summary>
		public abstract bool GetPreferenceTabWidget (
									PreferencesDialog parent,
									out string tabLabel,
									out Gtk.Widget preferenceWidget);
Example #4
0
		static void OnPreferencesResponse (object sender, Gtk.ResponseArgs args)
		{
			((Gtk.Widget) sender).Destroy ();
			prefs_dlg = null;
		}
Example #5
0
		static void OnShowPreferencesAction (object sender, EventArgs args)
		{
			prefs_dlg = new PreferencesDialog (manager);
			prefs_dlg.ShowAll ();
		}
Example #6
0
		static void OnShowPreferencesAction (object sender, EventArgs args)
		{
			if (prefs_dlg == null) {
				prefs_dlg = new PreferencesDialog (manager.AddinManager);
				prefs_dlg.Response += OnPreferencesResponse;
			}
			prefs_dlg.Present ();
		}