[f-spot/icon-view-cleanup: 21/24] Create a file for each SmugMug exporter class



commit 012ea505a1b61b471b5c85ceadac5d88a49d3d79
Author: Paul Lange <palango gmx de>
Date:   Tue Aug 17 15:52:59 2010 +0200

    Create a file for each SmugMug exporter class
    
    https://bugzilla.gnome.org/show_bug.cgi?id=627154

 po/POTFILES.in                                     |    4 +
 .../FSpot.Exporters.SmugMug.csproj                 |    5 +-
 .../FSpot.Exporters.SmugMug/SmugMugAccount.cs      |   85 +++++
 .../SmugMugAccountDialog.cs                        |  113 ++++++
 .../SmugMugAccountManager.cs                       |  134 +++++++
 .../FSpot.Exporters.SmugMug/SmugMugAddAlbum.cs     |  117 ++++++
 .../FSpot.Exporters.SmugMug/SmugMugExport.cs       |  375 +-------------------
 .../Exporters/FSpot.Exporters.SmugMug/Makefile.am  |    7 +-
 8 files changed, 464 insertions(+), 376 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index b85d917..27958cd 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -118,6 +118,10 @@ src/Extensions/Exporters/FSpot.Exporters.PicasaWeb/FSpot.Exporters.PicasaWeb/Goo
 src/Extensions/Exporters/FSpot.Exporters.PicasaWeb/FSpot.Exporters.PicasaWeb/GoogleAddAlbum.cs
 src/Extensions/Exporters/FSpot.Exporters.PicasaWeb/FSpot.Exporters.PicasaWeb/PicasaWebExport.cs
 [type: gettext/glade]src/Extensions/Exporters/FSpot.Exporters.PicasaWeb/Resources/PicasaWebExport.glade
+src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugAccount.cs
+src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugAccountDialog.cs
+src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugAccountManager.cs
+src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugAddAlbum.cs
 src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugExport.cs
 [type: gettext/glade]src/Extensions/Exporters/FSpot.Exporters.SmugMug/Resources/SmugMugExport.glade
 src/Extensions/Exporters/FSpot.Exporters.Tabblo/FSpot.Exporters.Tabblo/TabbloExport.cs
diff --git a/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug.csproj b/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug.csproj
index 1ba769a..ada3919 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug.csproj
+++ b/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug.csproj
@@ -33,6 +33,10 @@
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <ItemGroup>
     <Compile Include="FSpot.Exporters.SmugMug\SmugMugExport.cs" />
+    <Compile Include="FSpot.Exporters.SmugMug\SmugMugAccount.cs" />
+    <Compile Include="FSpot.Exporters.SmugMug\SmugMugAccountManager.cs" />
+    <Compile Include="FSpot.Exporters.SmugMug\SmugMugAccountDialog.cs" />
+    <Compile Include="FSpot.Exporters.SmugMug\SmugMugAddAlbum.cs" />
   </ItemGroup>
   <ItemGroup>
     <EmbeddedResource Include="Resources\SmugMugExport.addin.xml">
@@ -77,7 +81,6 @@
   </ItemGroup>
   <ItemGroup>
     <Reference Include="Gnome.Keyring, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1a73e1bde00c9b66">
-      <Package>gnome-keyring-sharp-1.0</Package>
     </Reference>
     <Reference Include="System" />
     <Reference Include="Mono.Posix" />
diff --git a/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugAccount.cs b/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugAccount.cs
new file mode 100644
index 0000000..927a94b
--- /dev/null
+++ b/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugAccount.cs
@@ -0,0 +1,85 @@
+using System;
+using System.Net;
+using System.IO;
+using System.Text;
+using System.Threading;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Web;
+using Mono.Unix;
+using Gtk;
+using FSpot;
+using FSpot.Core;
+using FSpot.Filters;
+using FSpot.Widgets;
+using Hyena;
+using FSpot.UI.Dialog;
+using Gnome.Keyring;
+using SmugMugNet;
+
+namespace FSpot.Exporters.SmugMug
+{
+	public class SmugMugAccount {
+		private string username;
+		private string password;
+		private SmugMugApi smugmug_proxy;
+
+		public SmugMugAccount (string username, string password)
+		{
+			this.username = username;
+			this.password = password;
+		}
+
+		public SmugMugApi Connect ()
+		{
+			Log.Debug ("SmugMug.Connect() " + username);
+			SmugMugApi proxy = new SmugMugApi (username, password);
+			ServicePointManager.CertificatePolicy = new NoCheckCertificatePolicy ();
+			proxy.Login ();
+
+			this.smugmug_proxy = proxy;
+			return proxy;
+		}
+
+		private void MarkChanged()
+		{
+			smugmug_proxy = null;
+		}
+
+		public bool Connected {
+			get {
+				return (smugmug_proxy != null && smugmug_proxy.Connected);
+			}
+		}
+
+		public string Username {
+			get {
+				return username;
+			}
+			set {
+				if (username != value) {
+					username = value;
+					MarkChanged ();
+				}
+			}
+		}
+
+		public string Password {
+			get {
+				return password;
+			}
+			set {
+				if (password != value) {
+					password = value;
+					MarkChanged ();
+				}
+			}
+		}
+
+		public SmugMugApi SmugMug {
+			get {
+				return smugmug_proxy;
+			}
+		}
+	}
+}
diff --git a/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugAccountDialog.cs b/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugAccountDialog.cs
new file mode 100644
index 0000000..8d7daf8
--- /dev/null
+++ b/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugAccountDialog.cs
@@ -0,0 +1,113 @@
+using System;
+using System.Net;
+using System.IO;
+using System.Text;
+using System.Threading;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Web;
+using Mono.Unix;
+using Gtk;
+using FSpot;
+using FSpot.Core;
+using FSpot.Filters;
+using FSpot.Widgets;
+using Hyena;
+using FSpot.UI.Dialog;
+using Gnome.Keyring;
+using SmugMugNet;
+
+namespace FSpot.Exporters.SmugMug
+{
+	public class SmugMugAccountDialog {
+		public SmugMugAccountDialog (Gtk.Window parent) : this (parent, null) {
+			Dialog.Response += HandleAddResponse;
+			add_button.Sensitive = false;
+		}
+
+		public SmugMugAccountDialog (Gtk.Window parent, SmugMugAccount account)
+		{
+			xml = new Glade.XML (null, "SmugMugExport.glade", dialog_name, "f-spot");
+			xml.Autoconnect (this);
+
+			Dialog.Modal = false;
+			Dialog.TransientFor = parent;
+			Dialog.DefaultResponse = Gtk.ResponseType.Ok;
+
+			this.account = account;
+
+			password_entry.ActivatesDefault = true;
+			username_entry.ActivatesDefault = true;
+
+			if (account != null) {
+				password_entry.Text = account.Password;
+				username_entry.Text = account.Username;
+				add_button.Label = Gtk.Stock.Ok;
+				Dialog.Response += HandleEditResponse;
+			}
+
+			if (remove_button != null)
+				remove_button.Visible = account != null;
+
+			this.Dialog.Show ();
+
+			password_entry.Changed += HandleChanged;
+			username_entry.Changed += HandleChanged;
+			HandleChanged (null, null);
+		}
+
+		private void HandleChanged (object sender, System.EventArgs args)
+		{
+			password = password_entry.Text;
+			username = username_entry.Text;
+
+			add_button.Sensitive = !(password == String.Empty || username == String.Empty);
+		}
+
+		[GLib.ConnectBefore]
+		protected void HandleAddResponse (object sender, Gtk.ResponseArgs args)
+		{
+			if (args.ResponseId == Gtk.ResponseType.Ok) {
+				SmugMugAccount account = new SmugMugAccount (username, password);
+				SmugMugAccountManager.GetInstance ().AddAccount (account);
+			}
+			Dialog.Destroy ();
+		}
+
+		protected void HandleEditResponse (object sender, Gtk.ResponseArgs args)
+		{
+			if (args.ResponseId == Gtk.ResponseType.Ok) {
+				account.Username = username;
+				account.Password = password;
+				SmugMugAccountManager.GetInstance ().MarkChanged (true, account);
+			} else if (args.ResponseId == Gtk.ResponseType.Reject) {
+				// NOTE we are using Reject to signal the remove action.
+				SmugMugAccountManager.GetInstance ().RemoveAccount (account);
+			}
+			Dialog.Destroy ();
+		}
+
+		private Gtk.Dialog Dialog {
+			get {
+				if (dialog == null)
+					dialog = (Gtk.Dialog) xml.GetWidget (dialog_name);
+
+				return dialog;
+			}
+		}
+
+		private SmugMugAccount account;
+		private string password;
+		private string username;
+		private string dialog_name = "smugmug_add_dialog";
+		private Glade.XML xml;
+
+		// widgets
+		[Glade.Widget] Gtk.Dialog dialog;
+		[Glade.Widget] Gtk.Entry password_entry;
+		[Glade.Widget] Gtk.Entry username_entry;
+
+		[Glade.Widget] Gtk.Button add_button;
+		[Glade.Widget] Gtk.Button remove_button;
+	}
+}
diff --git a/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugAccountManager.cs b/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugAccountManager.cs
new file mode 100644
index 0000000..c4f340f
--- /dev/null
+++ b/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugAccountManager.cs
@@ -0,0 +1,134 @@
+using System;
+using System.Net;
+using System.IO;
+using System.Text;
+using System.Threading;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Web;
+using Mono.Unix;
+using Gtk;
+using FSpot;
+using FSpot.Core;
+using FSpot.Filters;
+using FSpot.Widgets;
+using Hyena;
+using FSpot.UI.Dialog;
+using Gnome.Keyring;
+using SmugMugNet;
+
+namespace FSpot.Exporters.SmugMug
+{
+	public class SmugMugAccountManager
+	{
+		private static SmugMugAccountManager instance;
+		private const string keyring_item_name = "SmugMug Account";
+		ArrayList accounts;
+
+		public delegate void AccountListChangedHandler (SmugMugAccountManager manager, SmugMugAccount changed_account);
+		public event AccountListChangedHandler AccountListChanged;
+
+		public static SmugMugAccountManager GetInstance ()
+		{
+			if (instance == null) {
+				instance = new SmugMugAccountManager ();
+			}
+
+			return instance;
+		}
+
+		private SmugMugAccountManager ()
+		{
+			accounts = new ArrayList ();
+			ReadAccounts ();
+		}
+
+		public void MarkChanged ()
+		{
+			MarkChanged (true, null);
+		}
+
+		public void MarkChanged (bool write, SmugMugAccount changed_account)
+		{
+			if (write)
+				WriteAccounts ();
+
+			if (AccountListChanged != null)
+				AccountListChanged (this, changed_account);
+		}
+
+		public ArrayList GetAccounts ()
+		{
+			return accounts;
+		}
+
+		public void AddAccount (SmugMugAccount account)
+		{
+			AddAccount (account, true);
+		}
+
+		public void AddAccount (SmugMugAccount account, bool write)
+		{
+			accounts.Add (account);
+			MarkChanged (write, account);
+		}
+
+		public void RemoveAccount (SmugMugAccount account)
+		{
+			string keyring = Ring.GetDefaultKeyring();
+			Hashtable request_attributes = new Hashtable();
+			request_attributes["name"] = keyring_item_name;
+			request_attributes["username"] = account.Username;
+			try {
+				foreach(ItemData result in Ring.Find(ItemType.GenericSecret, request_attributes)) {
+					Ring.DeleteItem(keyring, result.ItemID);
+				}
+			} catch (Exception e) {
+				Log.Exception (e);
+			}
+			accounts.Remove (account);
+			MarkChanged ();
+		}
+
+		public void WriteAccounts ()
+		{
+			string keyring = Ring.GetDefaultKeyring();
+			foreach (SmugMugAccount account in accounts) {
+				Hashtable update_request_attributes = new Hashtable();
+				update_request_attributes["name"] = keyring_item_name;
+				update_request_attributes["username"] = account.Username;
+
+				Ring.CreateItem(keyring, ItemType.GenericSecret, keyring_item_name, update_request_attributes, account.Password, true);
+			}
+		}
+
+		private void ReadAccounts ()
+		{
+
+			Hashtable request_attributes = new Hashtable();
+			request_attributes["name"] = keyring_item_name;
+			try {
+				foreach(ItemData result in Ring.Find(ItemType.GenericSecret, request_attributes)) {
+					if(!result.Attributes.ContainsKey("name") || !result.Attributes.ContainsKey("username") ||
+						(result.Attributes["name"] as string) != keyring_item_name)
+						continue;
+
+					string username = (string)result.Attributes["username"];
+					string password = result.Secret;
+
+					if (username == null || username == String.Empty || password == null || password == String.Empty)
+						throw new ApplicationException ("Invalid username/password in keyring");
+
+					SmugMugAccount account = new SmugMugAccount(username, password);
+					if (account != null)
+						AddAccount (account, false);
+
+				}
+			} catch (Exception e) {
+				Log.Exception (e);
+			}
+
+			MarkChanged ();
+		}
+	}
+}
diff --git a/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugAddAlbum.cs b/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugAddAlbum.cs
new file mode 100644
index 0000000..e1f181e
--- /dev/null
+++ b/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugAddAlbum.cs
@@ -0,0 +1,117 @@
+using System;
+using System.Net;
+using System.IO;
+using System.Text;
+using System.Threading;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Web;
+using Mono.Unix;
+using Gtk;
+using FSpot;
+using FSpot.Core;
+using FSpot.Filters;
+using FSpot.Widgets;
+using Hyena;
+using FSpot.UI.Dialog;
+using Gnome.Keyring;
+using SmugMugNet;
+
+namespace FSpot.Exporters.SmugMug
+{
+	public class SmugMugAddAlbum {
+		//[Glade.Widget] Gtk.OptionMenu album_optionmenu;
+
+		[Glade.Widget] Gtk.Dialog dialog;
+		[Glade.Widget] Gtk.Entry title_entry;
+		[Glade.Widget] Gtk.CheckButton public_check;
+		[Glade.Widget] Gtk.ComboBox category_combo;
+
+		[Glade.Widget] Gtk.Button add_button;
+
+		private string dialog_name = "smugmug_add_album_dialog";
+		private Glade.XML xml;
+		private SmugMugExport export;
+		private SmugMugApi smugmug;
+		private string title;
+		private ListStore category_store;
+
+		public SmugMugAddAlbum (SmugMugExport export, SmugMugApi smugmug)
+		{
+			xml = new Glade.XML (null, "SmugMugExport.glade", dialog_name, "f-spot");
+			xml.Autoconnect (this);
+
+			this.export = export;
+			this.smugmug = smugmug;
+
+			this.category_store = new ListStore (typeof(int), typeof(string));
+			CellRendererText display_cell = new CellRendererText();
+			category_combo.PackStart (display_cell, true);
+			category_combo.SetCellDataFunc (display_cell, new CellLayoutDataFunc (CategoryDataFunc));
+			this.category_combo.Model = category_store;
+			PopulateCategoryCombo ();
+
+			Dialog.Response += HandleAddResponse;
+
+			title_entry.Changed += HandleChanged;
+			HandleChanged (null, null);
+		}
+
+		private void HandleChanged (object sender, EventArgs args)
+		{
+			title = title_entry.Text;
+
+			if (title == String.Empty)
+				add_button.Sensitive = false;
+			else
+				add_button.Sensitive = true;
+		}
+
+		[GLib.ConnectBefore]
+		protected void HandleAddResponse (object sender, Gtk.ResponseArgs args)
+		{
+			if (args.ResponseId == Gtk.ResponseType.Ok) {
+				smugmug.CreateAlbum (title, CurrentCategoryId, public_check.Active);
+				export.HandleAlbumAdded (title);
+			}
+			Dialog.Destroy ();
+		}
+
+		void CategoryDataFunc (CellLayout layout, CellRenderer renderer, TreeModel model, TreeIter iter)
+		{
+			string name = (string)model.GetValue (iter, 1);
+			(renderer as CellRendererText).Text = name;
+		}
+
+		protected void PopulateCategoryCombo ()
+		{
+			SmugMugNet.Category[] categories = smugmug.GetCategories ();
+
+			foreach (SmugMugNet.Category category in categories) {
+				category_store.AppendValues (category.CategoryID, category.Title);
+			}
+
+			category_combo.Active = 0;
+
+			category_combo.ShowAll ();
+		}
+
+		protected int CurrentCategoryId
+		{
+			get {
+				TreeIter current;
+				category_combo.GetActiveIter (out current);
+				return (int)category_combo.Model.GetValue (current, 0);
+			}
+		}
+
+		private Gtk.Dialog Dialog {
+			get {
+				if (dialog == null)
+					dialog = (Gtk.Dialog) xml.GetWidget (dialog_name);
+
+				return dialog;
+			}
+		}
+	}
+}
diff --git a/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugExport.cs b/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugExport.cs
index 0cb5f24..6bd5f74 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugExport.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugExport.cs
@@ -31,377 +31,8 @@ using Gnome.Keyring;
 using SmugMugNet;
 
 namespace FSpot.Exporters.SmugMug {
-	public class SmugMugAccount {
-		private string username;
-		private string password;
-		private SmugMugApi smugmug_proxy;
-
-		public SmugMugAccount (string username, string password)
-		{
-			this.username = username;
-			this.password = password;
-		}
-
-		public SmugMugApi Connect ()
-		{
-			Log.Debug ("SmugMug.Connect() " + username);
-			SmugMugApi proxy = new SmugMugApi (username, password);
-			ServicePointManager.CertificatePolicy = new NoCheckCertificatePolicy ();
-			proxy.Login ();
-
-			this.smugmug_proxy = proxy;
-			return proxy;
-		}
-
-		private void MarkChanged()
-		{
-			smugmug_proxy = null;
-		}
-
-		public bool Connected {
-			get {
-				return (smugmug_proxy != null && smugmug_proxy.Connected);
-			}
-		}
-
-		public string Username {
-			get {
-				return username;
-			}
-			set {
-				if (username != value) {
-					username = value;
-					MarkChanged ();
-				}
-			}
-		}
-
-		public string Password {
-			get {
-				return password;
-			}
-			set {
-				if (password != value) {
-					password = value;
-					MarkChanged ();
-				}
-			}
-		}
-
-		public SmugMugApi SmugMug {
-			get {
-				return smugmug_proxy;
-			}
-		}
-	}
-
-
-	public class SmugMugAccountManager
-	{
-		private static SmugMugAccountManager instance;
-		private const string keyring_item_name = "SmugMug Account";
-		ArrayList accounts;
-
-		public delegate void AccountListChangedHandler (SmugMugAccountManager manager, SmugMugAccount changed_account);
-		public event AccountListChangedHandler AccountListChanged;
-
-		public static SmugMugAccountManager GetInstance ()
-		{
-			if (instance == null) {
-				instance = new SmugMugAccountManager ();
-			}
-
-			return instance;
-		}
-
-		private SmugMugAccountManager ()
-		{
-			accounts = new ArrayList ();
-			ReadAccounts ();
-		}
-
-		public void MarkChanged ()
-		{
-			MarkChanged (true, null);
-		}
-
-		public void MarkChanged (bool write, SmugMugAccount changed_account)
-		{
-			if (write)
-				WriteAccounts ();
-
-			if (AccountListChanged != null)
-				AccountListChanged (this, changed_account);
-		}
-
-		public ArrayList GetAccounts ()
-		{
-			return accounts;
-		}
-
-		public void AddAccount (SmugMugAccount account)
-		{
-			AddAccount (account, true);
-		}
-
-		public void AddAccount (SmugMugAccount account, bool write)
-		{
-			accounts.Add (account);
-			MarkChanged (write, account);
-		}
-
-		public void RemoveAccount (SmugMugAccount account)
-		{
-			string keyring = Ring.GetDefaultKeyring();
-			Hashtable request_attributes = new Hashtable();
-			request_attributes["name"] = keyring_item_name;
-			request_attributes["username"] = account.Username;
-			try {
-				foreach(ItemData result in Ring.Find(ItemType.GenericSecret, request_attributes)) {
-					Ring.DeleteItem(keyring, result.ItemID);
-				}
-			} catch (Exception e) {
-				Log.Exception (e);
-			}
-			accounts.Remove (account);
-			MarkChanged ();
-		}
-
-		public void WriteAccounts ()
-		{
-			string keyring = Ring.GetDefaultKeyring();
-			foreach (SmugMugAccount account in accounts) {
-				Hashtable update_request_attributes = new Hashtable();
-				update_request_attributes["name"] = keyring_item_name;
-				update_request_attributes["username"] = account.Username;
-
-				Ring.CreateItem(keyring, ItemType.GenericSecret, keyring_item_name, update_request_attributes, account.Password, true);
-			}
-		}
-
-		private void ReadAccounts ()
-		{
-
-			Hashtable request_attributes = new Hashtable();
-			request_attributes["name"] = keyring_item_name;
-			try {
-				foreach(ItemData result in Ring.Find(ItemType.GenericSecret, request_attributes)) {
-					if(!result.Attributes.ContainsKey("name") || !result.Attributes.ContainsKey("username") ||
-						(result.Attributes["name"] as string) != keyring_item_name)
-						continue;
-
-					string username = (string)result.Attributes["username"];
-					string password = result.Secret;
-
-					if (username == null || username == String.Empty || password == null || password == String.Empty)
-						throw new ApplicationException ("Invalid username/password in keyring");
-
-					SmugMugAccount account = new SmugMugAccount(username, password);
-					if (account != null)
-						AddAccount (account, false);
-
-				}
-			} catch (Exception e) {
-				Log.Exception (e);
-			}
-
-			MarkChanged ();
-		}
-	}
-
-	public class SmugMugAccountDialog {
-		public SmugMugAccountDialog (Gtk.Window parent) : this (parent, null) {
-			Dialog.Response += HandleAddResponse;
-			add_button.Sensitive = false;
-		}
-
-		public SmugMugAccountDialog (Gtk.Window parent, SmugMugAccount account)
-		{
-			xml = new Glade.XML (null, "SmugMugExport.glade", dialog_name, "f-spot");
-			xml.Autoconnect (this);
-
-			Dialog.Modal = false;
-			Dialog.TransientFor = parent;
-			Dialog.DefaultResponse = Gtk.ResponseType.Ok;
-
-			this.account = account;
-
-			password_entry.ActivatesDefault = true;
-			username_entry.ActivatesDefault = true;
-
-			if (account != null) {
-				password_entry.Text = account.Password;
-				username_entry.Text = account.Username;
-				add_button.Label = Gtk.Stock.Ok;
-				Dialog.Response += HandleEditResponse;
-			}
-
-			if (remove_button != null)
-				remove_button.Visible = account != null;
-
-			this.Dialog.Show ();
-
-			password_entry.Changed += HandleChanged;
-			username_entry.Changed += HandleChanged;
-			HandleChanged (null, null);
-		}
-
-		private void HandleChanged (object sender, System.EventArgs args)
-		{
-			password = password_entry.Text;
-			username = username_entry.Text;
-
-			add_button.Sensitive = !(password == String.Empty || username == String.Empty);
-		}
-
-		[GLib.ConnectBefore]
-		protected void HandleAddResponse (object sender, Gtk.ResponseArgs args)
-		{
-			if (args.ResponseId == Gtk.ResponseType.Ok) {
-				SmugMugAccount account = new SmugMugAccount (username, password);
-				SmugMugAccountManager.GetInstance ().AddAccount (account);
-			}
-			Dialog.Destroy ();
-		}
-
-		protected void HandleEditResponse (object sender, Gtk.ResponseArgs args)
-		{
-			if (args.ResponseId == Gtk.ResponseType.Ok) {
-				account.Username = username;
-				account.Password = password;
-				SmugMugAccountManager.GetInstance ().MarkChanged (true, account);
-			} else if (args.ResponseId == Gtk.ResponseType.Reject) {
-				// NOTE we are using Reject to signal the remove action.
-				SmugMugAccountManager.GetInstance ().RemoveAccount (account);
-			}
-			Dialog.Destroy ();
-		}
-
-		private Gtk.Dialog Dialog {
-			get {
-				if (dialog == null)
-					dialog = (Gtk.Dialog) xml.GetWidget (dialog_name);
-
-				return dialog;
-			}
-		}
-
-		private SmugMugAccount account;
-		private string password;
-		private string username;
-		private string dialog_name = "smugmug_add_dialog";
-		private Glade.XML xml;
-
-		// widgets
-		[Glade.Widget] Gtk.Dialog dialog;
-		[Glade.Widget] Gtk.Entry password_entry;
-		[Glade.Widget] Gtk.Entry username_entry;
-
-		[Glade.Widget] Gtk.Button add_button;
-		[Glade.Widget] Gtk.Button remove_button;
-	}
-
-	public class SmugMugAddAlbum {
-		//[Glade.Widget] Gtk.OptionMenu album_optionmenu;
-
-		[Glade.Widget] Gtk.Dialog dialog;
-		[Glade.Widget] Gtk.Entry title_entry;
-		[Glade.Widget] Gtk.CheckButton public_check;
-		[Glade.Widget] Gtk.ComboBox category_combo;
-
-		[Glade.Widget] Gtk.Button add_button;
-
-		private string dialog_name = "smugmug_add_album_dialog";
-		private Glade.XML xml;
-		private SmugMugExport export;
-		private SmugMugApi smugmug;
-		private string title;
-		private ListStore category_store;
-
-		public SmugMugAddAlbum (SmugMugExport export, SmugMugApi smugmug)
-		{
-			xml = new Glade.XML (null, "SmugMugExport.glade", dialog_name, "f-spot");
-			xml.Autoconnect (this);
-
-			this.export = export;
-			this.smugmug = smugmug;
-
-			this.category_store = new ListStore (typeof(int), typeof(string));
-			CellRendererText display_cell = new CellRendererText();
-			category_combo.PackStart (display_cell, true);
-			category_combo.SetCellDataFunc (display_cell, new CellLayoutDataFunc (CategoryDataFunc));
-			this.category_combo.Model = category_store;
-			PopulateCategoryCombo ();
-
-			Dialog.Response += HandleAddResponse;
-
-			title_entry.Changed += HandleChanged;
-			HandleChanged (null, null);
-		}
-
-		private void HandleChanged (object sender, EventArgs args)
-		{
-			title = title_entry.Text;
-
-			if (title == String.Empty)
-				add_button.Sensitive = false;
-			else
-				add_button.Sensitive = true;
-		}
-
-		[GLib.ConnectBefore]
-		protected void HandleAddResponse (object sender, Gtk.ResponseArgs args)
-		{
-			if (args.ResponseId == Gtk.ResponseType.Ok) {
-				smugmug.CreateAlbum (title, CurrentCategoryId, public_check.Active);
-				export.HandleAlbumAdded (title);
-			}
-			Dialog.Destroy ();
-		}
-
-		void CategoryDataFunc (CellLayout layout, CellRenderer renderer, TreeModel model, TreeIter iter)
-		{
-			string name = (string)model.GetValue (iter, 1);
-			(renderer as CellRendererText).Text = name;
-		}
-
-		protected void PopulateCategoryCombo ()
-		{
-			SmugMugNet.Category[] categories = smugmug.GetCategories ();
-
-			foreach (SmugMugNet.Category category in categories) {
-				category_store.AppendValues (category.CategoryID, category.Title);
-			}
-
-			category_combo.Active = 0;
-
-			category_combo.ShowAll ();
-		}
-
-		protected int CurrentCategoryId
-		{
-			get {
-				TreeIter current;
-				category_combo.GetActiveIter (out current);
-				return (int)category_combo.Model.GetValue (current, 0);
-			}
-		}
-
-		private Gtk.Dialog Dialog {
-			get {
-				if (dialog == null)
-					dialog = (Gtk.Dialog) xml.GetWidget (dialog_name);
-
-				return dialog;
-			}
-		}
-	}
-
-
 	public class SmugMugExport : FSpot.Extensions.IExporter {
-		public SmugMugExport ()
-		{
-		}
+		public SmugMugExport () {}
 		public void Run (IBrowsableCollection selection)
 		{
 			xml = new Glade.XML (null, "SmugMugExport.glade", dialog_name, "f-spot");
@@ -444,7 +75,6 @@ namespace FSpot.Exporters.SmugMug {
 		private bool scale;
 		private int size;
 		private bool browser;
-//		private bool meta;
 		private bool connect = false;
 
 		private long approx_size = 0;
@@ -503,10 +133,8 @@ namespace FSpot.Exporters.SmugMug {
 				scale = false;
 
 			browser = browser_check.Active;
-//			meta = meta_check.Active;
 
 			if (account != null) {
-				//System.Console.WriteLine ("history = {0}", album_optionmenu.History);
 				album = (Album) account.SmugMug.GetAlbums() [Math.Max (0, album_optionmenu.History)];
 				photo_index = 0;
 
@@ -661,7 +289,6 @@ namespace FSpot.Exporters.SmugMug {
 				}
 			} catch (System.Exception) {
 				Log.Warning ("Can not connect to SmugMug. Bad username? Password? Network connection?");
-				//System.Console.WriteLine ("{0}",ex);
 				if (selected != null)
 					account = selected;
 
diff --git a/src/Extensions/Exporters/FSpot.Exporters.SmugMug/Makefile.am b/src/Extensions/Exporters/FSpot.Exporters.SmugMug/Makefile.am
index 1b0ddb5..ccebce7 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.SmugMug/Makefile.am
+++ b/src/Extensions/Exporters/FSpot.Exporters.SmugMug/Makefile.am
@@ -3,7 +3,12 @@ TARGET = library
 LINK = $(REF_FSPOT_EXTENSION_SMUGMUGEXPORT)
 INSTALL_DIR = $(EXTENSIONS_INSTALL_DIR)
 
-SOURCES = FSpot.Exporters.SmugMug/SmugMugExport.cs
+SOURCES =  \
+	FSpot.Exporters.SmugMug/SmugMugAccount.cs \
+	FSpot.Exporters.SmugMug/SmugMugAccountDialog.cs \
+	FSpot.Exporters.SmugMug/SmugMugAccountManager.cs \
+	FSpot.Exporters.SmugMug/SmugMugAddAlbum.cs \
+	FSpot.Exporters.SmugMug/SmugMugExport.cs
 
 RESOURCES =  \
 	Resources/SmugMugExport.addin.xml \



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