[tomboy] Use FileChooserButton in Local Folder sync preferences (bug #592985)



commit 278a85f3a9a35cf7bf3fa19a3d4ee49866319728
Author: Greg Poirier <grep binary-snobbery com>
Date:   Thu Jan 7 00:31:10 2010 -0600

    Use FileChooserButton in Local Folder sync preferences (bug #592985)
    
    Instead of building and packing our own buttons and entry fields, use
    FileChooserButton. Then we don't have to worry about icons.

 .../FileSystemSyncServiceAddin.cs                  |   48 ++++----------------
 1 files changed, 9 insertions(+), 39 deletions(-)
---
diff --git a/Tomboy/Addins/FileSystemSyncService/FileSystemSyncServiceAddin.cs b/Tomboy/Addins/FileSystemSyncService/FileSystemSyncServiceAddin.cs
index 133a608..b29a441 100644
--- a/Tomboy/Addins/FileSystemSyncService/FileSystemSyncServiceAddin.cs
+++ b/Tomboy/Addins/FileSystemSyncService/FileSystemSyncServiceAddin.cs
@@ -14,7 +14,7 @@ namespace Tomboy.Sync
 		// that supports a field, a username, and password.  This could be useful
 		// in quickly building SshSyncServiceAddin, FtpSyncServiceAddin, etc.
 
-		private Entry pathEntry;
+		private FileChooserButton pathButton;
 		private string path;
 		private bool initialized = false;
 
@@ -81,7 +81,7 @@ namespace Tomboy.Sync
 		/// </summary>
 		public override Gtk.Widget CreatePreferencesControl ()
 		{
-			Gtk.Table table = new Gtk.Table (1, 3, false);
+			Gtk.Table table = new Gtk.Table (1, 2, false);
 			table.RowSpacing = 5;
 			table.ColumnSpacing = 10;
 
@@ -97,50 +97,20 @@ namespace Tomboy.Sync
 			              Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill,
 			              0, 0);
 
-			pathEntry = new Entry ();
-			pathEntry.Text = syncPath;
-			table.Attach (pathEntry, 1, 2, 0, 1,
+			pathButton = new FileChooserButton (Catalog.GetString ("Select Synchronization Folder..."),
+			                                    FileChooserAction.SelectFolder);
+			l.MnemonicWidget = pathButton;
+			pathButton.SetFilename (syncPath);
+
+			table.Attach (pathButton, 1, 2, 0, 1,
 			              Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill,
 			              Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill,
 			              0, 0);
-			l.MnemonicWidget = pathEntry;
-
-			Image browseImage = new Image (Stock.Open, IconSize.Button);
-			Label browseLabel = new Label (Catalog.GetString ("_Browse..."));
-
-			HBox browseBox = new HBox (false, 0);
-			browseBox.PackStart (browseImage);
-			browseBox.PackStart (browseLabel);
-
-			Button browseButton = new Button ();
-			browseButton.Add (browseBox);
-			browseLabel.MnemonicWidget = browseButton;
-			browseButton.Clicked += OnBrowseButtonClicked;
-			table.Attach (browseButton, 2, 3, 0, 1, AttachOptions.Shrink, AttachOptions.Expand, 0, 0);
 
 			table.ShowAll ();
 			return table;
 		}
 
-		private void OnBrowseButtonClicked (object sender, EventArgs args)
-		{
-			FileChooserDialog chooserDlg =
-			        new FileChooserDialog (Catalog.GetString ("Select Synchronization Folder..."),
-			                               null,
-			                               FileChooserAction.SelectFolder,
-			                               Stock.Cancel, ResponseType.Cancel,
-			                               Stock.Ok, ResponseType.Ok);
-			chooserDlg.DefaultResponse = ResponseType.Cancel;
-			chooserDlg.SetFilename (pathEntry.Text);
-
-			ResponseType response = (ResponseType) chooserDlg.Run ();
-
-			if (response == ResponseType.Ok)
-				pathEntry.Text = chooserDlg.Filename;
-
-			chooserDlg.Destroy ();
-		}
-
 		/// <summary>
 		/// The Addin should verify and check the connection to the service
 		/// when this is called.  If verification and connection is successful,
@@ -148,7 +118,7 @@ namespace Tomboy.Sync
 		/// </summary>
 		public override bool SaveConfiguration ()
 		{
-			string syncPath = pathEntry.Text.Trim ();
+			string syncPath = pathButton.Filename;
 
 			if (syncPath == string.Empty) {
 				// TODO: Figure out a way to send the error back to the client



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