[f-spot] More small changes but to Extensions
- From: Stephen Shaw <sshaw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [f-spot] More small changes but to Extensions
- Date: Tue, 10 Apr 2012 21:42:43 +0000 (UTC)
commit d6dd9a00ee6d7e32ed2b08f7288f018ddd143029
Author: Stephen Shaw <sshaw decriptor com>
Date: Fri Mar 23 18:56:28 2012 -0600
More small changes but to Extensions
Again thanks to jetbrains for a license
to resharper.
Logic should be the same.
.../FSpot.Exporters.CD/CDExport.cs | 4 +-
.../FSpot.Exporters.CD/CDExportDialog.cs | 2 +-
.../FSpot.Exporters.Facebook/FacebookExport.cs | 86 +++++++---------
.../FacebookExportDialog.cs | 110 +++++++++-----------
.../FSpot.Exporters.Facebook/FacebookTagPopup.cs | 14 +--
.../Mono.Facebook/FacebookException.cs | 21 ++---
.../Mono.Facebook/FacebookParam.cs | 27 ++---
.../Mono.Facebook/FacebookSession.cs | 4 +-
.../Mono.Facebook/SessionInfo.cs | 2 +-
.../FSpot.Exporters.Facebook/Mono.Facebook/Util.cs | 44 +++-----
.../FSpot.Exporters.Flickr/FlickrExport.cs | 20 +---
.../FSpot.Exporters.Flickr/FlickrRemote.cs | 21 ++--
.../FSpot.Exporters.Folder/FolderExport.cs | 2 +-
.../FSpot.Exporters.Folder/FolderGallery.cs | 14 ++--
.../FSpot.Exporters.Gallery/FormClient.cs | 58 ++++++-----
.../FSpot.Exporters.Gallery/Gallery2.cs | 2 +-
.../FSpot.Exporters.Gallery/GalleryAccount.cs | 9 +-
.../FSpot.Exporters.Gallery/GalleryAddAlbum.cs | 4 +-
.../FSpot.Exporters.Gallery/GalleryRemote.cs | 19 ++--
.../FSpot.Exporters.PicasaWeb/GoogleAccount.cs | 55 +++-------
.../GoogleAccountManager.cs | 26 ++---
.../FSpot.Exporters.PicasaWeb/PicasaWebExport.cs | 27 ++----
.../SmugMugAccountDialog.cs | 9 +--
.../SmugMugAccountManager.cs | 11 +--
.../FSpot.Exporters.SmugMug/SmugMugAddAlbum.cs | 24 ++---
.../FSpot.Exporters.SmugMug/SmugMugExport.cs | 20 +---
.../FSpot.Exporters.Tabblo/TabbloExport.cs | 6 +-
.../FSpot.Exporters.Tabblo/TabbloExportModel.cs | 46 +++-----
.../FSpot.Exporters.Zip/ZipExport.cs | 13 ++-
.../ChangePhotoPathController.cs | 13 ++-
.../ChangePhotoPathGui.cs | 13 +--
.../AbstractDevelopInUFRaw.cs | 7 +-
.../GalleryRequestHandler.cs | 77 +++++---------
.../FSpot.Tools.LiveWebGallery/SimpleWebServer.cs | 2 +-
.../FSpot.Tools.MergeDb/MergeDb.cs | 7 +-
.../FSpot.Tools.MergeDb/MergeDbDialog.cs | 6 +-
.../FSpot.Tools.MergeDb/PickFolderDialog.cs | 5 +-
37 files changed, 325 insertions(+), 505 deletions(-)
---
diff --git a/src/Extensions/Exporters/FSpot.Exporters.CD/FSpot.Exporters.CD/CDExport.cs b/src/Extensions/Exporters/FSpot.Exporters.CD/FSpot.Exporters.CD/CDExport.cs
index 8c1557d..7b873c4 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.CD/FSpot.Exporters.CD/CDExport.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.CD/FSpot.Exporters.CD/CDExport.cs
@@ -158,9 +158,7 @@ namespace FSpot.Exporters.CD {
progress_dialog.ProgressText = Catalog.GetString ("Error Transferring");
return;
}
- ThreadAssist.ProxyToMain (() => {
- progress_dialog.Destroy ();
- });
+ ThreadAssist.ProxyToMain (() => progress_dialog.Destroy ());
}
private void Progress (long current_num_bytes, long total_num_bytes)
diff --git a/src/Extensions/Exporters/FSpot.Exporters.CD/FSpot.Exporters.CD/CDExportDialog.cs b/src/Extensions/Exporters/FSpot.Exporters.CD/FSpot.Exporters.CD/CDExportDialog.cs
index bd465a5..c7179c4 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.CD/FSpot.Exporters.CD/CDExportDialog.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.CD/FSpot.Exporters.CD/CDExportDialog.cs
@@ -46,7 +46,7 @@ namespace FSpot.Exporters.CD
Gtk.Window listwindow;
System.Uri dest;
- [GtkBeans.Builder.Object] Button browse_button;
+ [GtkBeans.Builder.Object] Button browse_button;
[GtkBeans.Builder.Object] ScrolledWindow thumb_scrolledwindow;
[GtkBeans.Builder.Object] CheckButton remove_check;
[GtkBeans.Builder.Object] Label size_label;
diff --git a/src/Extensions/Exporters/FSpot.Exporters.Facebook/FSpot.Exporters.Facebook/FacebookExport.cs b/src/Extensions/Exporters/FSpot.Exporters.Facebook/FSpot.Exporters.Facebook/FacebookExport.cs
index 3bf51fc..323f443 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.Facebook/FSpot.Exporters.Facebook/FacebookExport.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.Facebook/FSpot.Exporters.Facebook/FacebookExport.cs
@@ -52,36 +52,35 @@ using Mono.Unix;
namespace FSpot.Exporters.Facebook
{
internal class FacebookAccount
- {
- static string keyring_item_name = "Facebook Account";
-
- static string api_key = "c23d1683e87313fa046954ea253a240e";
-
+ {
+ private const string keyring_item_name = "Facebook Account";
+
+ private const string api_key = "c23d1683e87313fa046954ea253a240e";
+
+ // FIXME:
/* INSECURE! According to:
*
* http://wiki.developers.facebook.com/index.php/Desktop_App_Auth_Process
*
* We should *NOT* put our secret code here, but do an external
* authorization using our own PHP page somewhere.
- */
- static string secret = "743e9a2e6a1c35ce961321bceea7b514";
-
- FacebookSession facebookSession;
- bool connected = false;
-
+ */
+ private const string secret = "743e9a2e6a1c35ce961321bceea7b514";
+
public FacebookAccount ()
- {
+ {
+ Authenticated = false;
SessionInfo info = ReadSessionInfo ();
if (info != null) {
- facebookSession = new FacebookSession (api_key, info);
+ Facebook = new FacebookSession (api_key, info);
try {
/* This basically functions like a ping to ensure the
* session is still valid:
*/
- facebookSession.HasAppPermission("offline_access");
- connected = true;
+ Facebook.HasAppPermission("offline_access");
+ Authenticated = true;
} catch (FacebookException) {
- connected = false;
+ Authenticated = false;
}
}
}
@@ -90,22 +89,22 @@ namespace FSpot.Exporters.Facebook
{
FacebookSession session = new FacebookSession (api_key, secret);
Uri uri = session.CreateToken();
- facebookSession = session;
- connected = false;
+ Facebook = session;
+ Authenticated = false;
return uri;
}
public bool RevokePermission (string permission)
{
- return facebookSession.RevokeAppPermission(permission);
+ return Facebook.RevokeAppPermission(permission);
}
public bool GrantPermission (string permission, Window parent)
{
- if (facebookSession.HasAppPermission(permission))
+ if (Facebook.HasAppPermission(permission))
return true;
- Uri uri = facebookSession.GetGrantUri (permission);
+ Uri uri = Facebook.GetGrantUri (permission);
GtkBeans.Global.ShowUri (parent.Screen, uri.ToString ());
HigMessageDialog mbox = new HigMessageDialog (parent, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal,
@@ -115,24 +114,18 @@ namespace FSpot.Exporters.Facebook
mbox.Run ();
mbox.Destroy ();
- return facebookSession.HasAppPermission(permission);
+ return Facebook.HasAppPermission(permission);
}
public bool HasPermission(string permission)
{
- return facebookSession.HasAppPermission(permission);
- }
-
- public FacebookSession Facebook
- {
- get { return facebookSession; }
- }
-
- public bool Authenticated
- {
- get { return connected; }
- }
-
+ return Facebook.HasAppPermission(permission);
+ }
+
+ public FacebookSession Facebook { get; private set; }
+
+ public bool Authenticated { get; private set; }
+
bool SaveSessionInfo (SessionInfo info)
{
string keyring;
@@ -162,6 +155,7 @@ namespace FSpot.Exporters.Facebook
{
SessionInfo info = null;
+ // FIXME: Should probably convert this to a Dictionary
Hashtable request_attributes = new Hashtable ();
//Dictionary<string, string> request_attributes = new Dictionary<string, string> ();
request_attributes["name"] = keyring_item_name;
@@ -215,28 +209,28 @@ namespace FSpot.Exporters.Facebook
public bool Authenticate ()
{
- if (connected)
+ if (Authenticated)
return true;
try {
- SessionInfo info = facebookSession.GetSession();
- connected = true;
+ SessionInfo info = Facebook.GetSession();
+ Authenticated = true;
if (SaveSessionInfo (info))
Log.Information ("Saved session information to keyring");
else
Log.Warning ("Could not save session information to keyring");
} catch (KeyringException e) {
- connected = false;
+ Authenticated = false;
Log.DebugException (e);
} catch (FacebookException fe) {
- connected = false;
+ Authenticated = false;
Log.DebugException (fe);
}
- return connected;
+ return Authenticated;
}
public void Deauthenticate ()
{
- connected = false;
+ Authenticated = false;
ForgetSessionInfo ();
}
}
@@ -280,12 +274,8 @@ namespace FSpot.Exporters.Facebook
FacebookExportDialog dialog;
ThreadProgressDialog progress_dialog;
System.Threading.Thread command_thread;
- Album album = null;
-
- public FacebookExport ()
- {
- }
-
+ Album album = null;
+
public void Run (IBrowsableCollection selection)
{
diff --git a/src/Extensions/Exporters/FSpot.Exporters.Facebook/FSpot.Exporters.Facebook/FacebookExportDialog.cs b/src/Extensions/Exporters/FSpot.Exporters.Facebook/FSpot.Exporters.Facebook/FacebookExportDialog.cs
index 0a39773..fae250b 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.Facebook/FSpot.Exporters.Facebook/FacebookExportDialog.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.Facebook/FSpot.Exporters.Facebook/FacebookExportDialog.cs
@@ -83,7 +83,7 @@ namespace FSpot.Exporters.Facebook
private class DateComparer : IComparer
{
public int Compare (object left,
- object right)
+ object right)
{
return DateTime.Compare ((left as IPhoto).Time,
(right as IPhoto).Time);
@@ -93,19 +93,19 @@ namespace FSpot.Exporters.Facebook
public FacebookExportDialog (IBrowsableCollection selection) : base (Assembly.GetExecutingAssembly (), "FacebookExport.ui", "facebook_export_dialog")
{
// Sort selection by date ascending
- items = selection.Items;
- Array.Sort (items, new DateComparer ());
+ Items = selection.Items;
+ Array.Sort (Items, new DateComparer ());
current_item = -1;
- captions = new string [selection.Items.Length];
+ Captions = new string [selection.Items.Length];
tags = new List<Mono.Facebook.Tag> [selection.Items.Length];
tray_view = new SelectionCollectionGridView (selection) {
- MaxColumns = 1,
- DisplayDates = false,
- DisplayTags = false,
- DisplayRatings = false
- };
+ MaxColumns = 1,
+ DisplayDates = false,
+ DisplayTags = false,
+ DisplayRatings = false
+ };
tray_view.ButtonPressEvent += HandleThumbnailIconViewButtonPressEvent;
tray_view.KeyPressEvent += delegate (object sender, KeyPressEventArgs e) {(sender as SelectionCollectionGridView).Selection.Clear(); };
thumbnails_scrolled_window.Add (tray_view);
@@ -132,28 +132,19 @@ namespace FSpot.Exporters.Facebook
DoLogout ();
- account = new FacebookAccount();
- if (account.Authenticated)
+ Account = new FacebookAccount();
+ if (Account.Authenticated)
DoLogin ();
- }
-
- FacebookAccount account;
- public FacebookAccount Account {
- get { return account; }
- }
-
- string[] captions;
- public string [] Captions {
- get {return captions; }
- }
-
+ }
+
+ public FacebookAccount Account { get; private set; }
+
+ public string[] Captions { get; private set; }
+
List<Mono.Facebook.Tag>[] tags;
- int current_item;
- IPhoto[] items;
- public IPhoto[] Items {
- get {return items; }
- }
-
+ int current_item;
+ public IPhoto[] Items { get; private set; }
+
public bool CreateAlbum {
get { return create_album_radiobutton.Active; }
}
@@ -181,7 +172,7 @@ namespace FSpot.Exporters.Facebook
return;
// Store the caption
- captions [current_item] = caption_textview.Buffer.Text;
+ Captions [current_item] = caption_textview.Buffer.Text;
}
void HandleThumbnailIconViewButtonPressEvent (object sender, Gtk.ButtonPressEventArgs args)
@@ -192,20 +183,20 @@ namespace FSpot.Exporters.Facebook
int old_item = current_item;
current_item = tray_view.CellAtPosition ((int) args.Event.X, (int) args.Event.Y);
- if (current_item < 0 || current_item >= items.Length) {
+ if (current_item < 0 || current_item >= Items.Length) {
current_item = old_item;
return;
}
- string caption = captions [current_item];
+ string caption = Captions [current_item];
if (caption == null)
- captions [current_item] = caption = "";
+ Captions [current_item] = caption = "";
caption_textview.Buffer.Text = caption;
caption_textview.Sensitive = true;
- tag_treeview.Model = new TagStore (account.Facebook, tags [current_item], friends);
+ tag_treeview.Model = new TagStore (Account.Facebook, tags [current_item], friends);
- IPhoto item = items [current_item];
+ IPhoto item = Items [current_item];
if (tag_image_eventbox.Children.Length > 0) {
tag_image_eventbox.Remove (tag_image);
@@ -223,8 +214,8 @@ namespace FSpot.Exporters.Facebook
public void HandleLoginClicked (object sender, EventArgs args)
{
- if (!account.Authenticated) {
- Uri uri = account.GetLoginUri ();
+ if (!Account.Authenticated) {
+ Uri uri = Account.GetLoginUri ();
GtkBeans.Global.ShowUri (Screen, uri.ToString ());
HigMessageDialog mbox = new HigMessageDialog (this, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal,
@@ -235,14 +226,14 @@ namespace FSpot.Exporters.Facebook
mbox.Destroy ();
LoginProgress (0.0, Catalog.GetString ("Authenticating..."));
- account.Authenticate ();
+ Account.Authenticate ();
}
DoLogin ();
}
void DoLogin ()
{
- if (!account.Authenticated) {
+ if (!Account.Authenticated) {
HigMessageDialog error = new HigMessageDialog (this, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal,
Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString ("Error logging into Facebook"),
Catalog.GetString ("There was a problem logging into Facebook. Check your credentials and try again."));
@@ -257,8 +248,8 @@ namespace FSpot.Exporters.Facebook
LoginProgress (0.0, Catalog.GetString ("Authorizing Session"));
ThreadPool.QueueUserWorkItem (delegate {
try {
- bool perm_offline = account.HasPermission("offline_access");
- bool perm_upload = photo_perm_check.Active = account.HasPermission("photo_upload");
+ bool perm_offline = Account.HasPermission("offline_access");
+ bool perm_upload = photo_perm_check.Active = Account.HasPermission("photo_upload");
ThreadAssist.ProxyToMain (() => {
offline_perm_check.Active = perm_offline;
@@ -266,13 +257,13 @@ namespace FSpot.Exporters.Facebook
LoginProgress (0.2, Catalog.GetString ("Session established, fetching user info..."));
});
- User me = account.Facebook.GetLoggedInUser ().GetUserInfo ();
+ User me = Account.Facebook.GetLoggedInUser ().GetUserInfo ();
ThreadAssist.ProxyToMain (() => {
LoginProgress (0.4, Catalog.GetString ("Session established, fetching friend list..."));
});
- Friend[] friend_list = account.Facebook.GetFriends ();
+ Friend[] friend_list = Account.Facebook.GetFriends ();
long[] uids = new long [friend_list.Length];
for (int i = 0; i < friend_list.Length; i++)
@@ -283,7 +274,7 @@ namespace FSpot.Exporters.Facebook
});
if (uids.Length > 0) {
- User[] infos = account.Facebook.GetUserInfo (uids, new string[] { "first_name", "last_name" });
+ User[] infos = Account.Facebook.GetUserInfo (uids, new string[] { "first_name", "last_name" });
friends = new Dictionary<long, User> ();
foreach (User user in infos)
@@ -293,7 +284,7 @@ namespace FSpot.Exporters.Facebook
ThreadAssist.ProxyToMain (() => {
LoginProgress (0.8, Catalog.GetString ("Session established, fetching photo albums..."));
});
- Album[] albums = account.Facebook.GetAlbums ();
+ Album[] albums = Account.Facebook.GetAlbums ();
ThreadAssist.ProxyToMain (() => {
album_info_vbox.Sensitive = true;
picture_info_vbox.Sensitive = true;
@@ -316,7 +307,7 @@ namespace FSpot.Exporters.Facebook
error.Destroy ();
});
- account.Deauthenticate ();
+ Account.Deauthenticate ();
DoLogout ();
} finally {
ThreadAssist.ProxyToMain (() => {
@@ -330,7 +321,7 @@ namespace FSpot.Exporters.Facebook
void HandleLogoutClicked (object sender, EventArgs args)
{
- account.Deauthenticate ();
+ Account.Deauthenticate ();
DoLogout ();
}
@@ -366,21 +357,21 @@ namespace FSpot.Exporters.Facebook
}
CheckButton origin = (CheckButton)sender;
bool desired = origin.Active;
- bool actual = account.HasPermission (permission);
+ bool actual = Account.HasPermission (permission);
if (desired != actual) {
if (desired) {
Log.DebugFormat ("Granting {0}", permission);
- account.GrantPermission (permission, this);
+ Account.GrantPermission (permission, this);
} else {
Log.DebugFormat ("Revoking {0}", permission);
- account.RevokePermission (permission);
+ Account.RevokePermission (permission);
}
/* Double-check that things work... */
- actual = account.HasPermission (permission);
+ actual = Account.HasPermission (permission);
if (actual != desired) {
Log.Warning("Failed to alter permissions");
}
- origin.Active = account.HasPermission (permission);
+ origin.Active = Account.HasPermission (permission);
}
}
@@ -443,22 +434,17 @@ namespace FSpot.Exporters.Facebook
}
internal class AlbumStore : ListStore
- {
- private Album[] _albums;
-
+ {
public AlbumStore (Album[] albums) : base (typeof (string))
{
- _albums = albums;
+ Albums = albums;
foreach (Album album in Albums) {
AppendValues (album.name);
}
- }
-
- public Album[] Albums
- {
- get { return _albums; }
- }
+ }
+
+ public Album[] Albums { get; private set; }
}
}
diff --git a/src/Extensions/Exporters/FSpot.Exporters.Facebook/FSpot.Exporters.Facebook/FacebookTagPopup.cs b/src/Extensions/Exporters/FSpot.Exporters.Facebook/FSpot.Exporters.Facebook/FacebookTagPopup.cs
index 60adc3e..cf19c7d 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.Facebook/FSpot.Exporters.Facebook/FacebookTagPopup.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.Facebook/FSpot.Exporters.Facebook/FacebookTagPopup.cs
@@ -37,18 +37,12 @@ using Mono.Facebook;
namespace FSpot.Exporters.Facebook
{
internal class FacebookTagPopup : BuilderWindow
- {
- Dictionary<long, User> _friends;
-
+ {
public FacebookTagPopup (Dictionary<long, User> friends) : base (Assembly.GetExecutingAssembly (), "FacebookExport.ui", "facebook_tag_popup")
{
Friends = friends;
- }
-
- public Dictionary<long, User> Friends
- {
- get { return _friends; }
- set { _friends = value; }
- }
+ }
+
+ public Dictionary<long, User> Friends { get; set; }
}
}
diff --git a/src/Extensions/Exporters/FSpot.Exporters.Facebook/Mono.Facebook/FacebookException.cs b/src/Extensions/Exporters/FSpot.Exporters.Facebook/Mono.Facebook/FacebookException.cs
index 15f2cf7..ef4ee6b 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.Facebook/Mono.Facebook/FacebookException.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.Facebook/Mono.Facebook/FacebookException.cs
@@ -30,23 +30,16 @@
using System;
public class FacebookException : Exception
-{
- private int error_code;
- private string error_message;
-
- public int ErrorCode {
- get { return error_code; }
- }
-
- public string ErrorMessage {
- get { return error_message; }
- }
-
+{
+ public int ErrorCode { get; private set; }
+
+ public string ErrorMessage { get; private set; }
+
public FacebookException (int error_code, string error_message)
: base (CreateMessage (error_code, error_message))
{
- this.error_code = error_code;
- this.error_message = error_message;
+ ErrorCode = error_code;
+ ErrorMessage = error_message;
}
private static string CreateMessage (int error_code, string error_message)
diff --git a/src/Extensions/Exporters/FSpot.Exporters.Facebook/Mono.Facebook/FacebookParam.cs b/src/Extensions/Exporters/FSpot.Exporters.Facebook/Mono.Facebook/FacebookParam.cs
index 0d0e525..4169ba3 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.Facebook/Mono.Facebook/FacebookParam.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.Facebook/Mono.Facebook/FacebookParam.cs
@@ -34,26 +34,23 @@ using System.Text;
namespace Mono.Facebook
{
public class FacebookParam : IComparable
- {
- private string name;
- private object value;
-
- public string Name {
- get{ return name; }
- }
-
+ {
+ private object value;
+
+ public string Name { get; private set; }
+
public string Value {
- get {
+ get
+ {
if (value is Array)
- return ConvertArrayToString (value as Array);
- else
- return value.ToString ();
- }
+ return ConvertArrayToString (value as Array);
+ return value.ToString ();
+ }
}
protected FacebookParam (string name, object value)
{
- this.name = name;
+ Name = name;
this.value = value;
}
@@ -72,7 +69,7 @@ namespace Mono.Facebook
if (!(obj is FacebookParam))
return -1;
- return this.name.CompareTo ((obj as FacebookParam).name);
+ return Name.CompareTo ((obj as FacebookParam).Name);
}
private static string ConvertArrayToString (Array a)
diff --git a/src/Extensions/Exporters/FSpot.Exporters.Facebook/Mono.Facebook/FacebookSession.cs b/src/Extensions/Exporters/FSpot.Exporters.Facebook/Mono.Facebook/FacebookSession.cs
index c9fbfcc..a0ca65d 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.Facebook/Mono.Facebook/FacebookSession.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.Facebook/Mono.Facebook/FacebookSession.cs
@@ -138,10 +138,10 @@ namespace Mono.Facebook
param_list.Add (FacebookParam.Create ("call_id", DateTime.Now.Ticks));
param_list.Add (FacebookParam.Create ("name", name));
- if (description != null && description != string.Empty)
+ if (!string.IsNullOrEmpty(description))
param_list.Add (FacebookParam.Create ("description", description));
- if (location != null && location != string.Empty)
+ if (!string.IsNullOrEmpty(location))
param_list.Add (FacebookParam.Create ("location", location));
// create the albums
diff --git a/src/Extensions/Exporters/FSpot.Exporters.Facebook/Mono.Facebook/SessionInfo.cs b/src/Extensions/Exporters/FSpot.Exporters.Facebook/Mono.Facebook/SessionInfo.cs
index 362a325..2a2d5a9 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.Facebook/Mono.Facebook/SessionInfo.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.Facebook/Mono.Facebook/SessionInfo.cs
@@ -34,7 +34,7 @@ namespace Mono.Facebook
[System.Xml.Serialization.XmlRootAttribute("auth_getSession_response", Namespace="http://api.facebook.com/1.0/", IsNullable=false)]
public class SessionInfo : session_info
{
- [XmlIgnore]
+ [XmlIgnore]
public bool IsInfinite
{
get { return expires == 0; }
diff --git a/src/Extensions/Exporters/FSpot.Exporters.Facebook/Mono.Facebook/Util.cs b/src/Extensions/Exporters/FSpot.Exporters.Facebook/Mono.Facebook/Util.cs
index 14ef367..9d4f3a5 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.Facebook/Mono.Facebook/Util.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.Facebook/Mono.Facebook/Util.cs
@@ -44,13 +44,10 @@ namespace Mono.Facebook
private const string BOUNDARY = "SoMeTeXtWeWiLlNeVeRsEe";
private const string LINE = "\r\n";
- private static Dictionary<int, XmlSerializer> serializer_dict = new Dictionary<int, XmlSerializer>();
-
- private FacebookParam VersionParam = FacebookParam.Create ("v", "1.0");
- private string api_key;
- private string secret;
- private bool use_json;
+ private static readonly Dictionary<int, XmlSerializer> serializer_dict = new Dictionary<int, XmlSerializer>();
+ private readonly FacebookParam VersionParam = FacebookParam.Create ("v", "1.0");
+
private static XmlSerializer ErrorSerializer {
get {
return GetSerializer (typeof (Error));
@@ -59,27 +56,16 @@ namespace Mono.Facebook
public Util (string api_key, string secret)
{
- this.api_key = api_key;
- this.secret = secret;
- }
-
- public bool UseJson
- {
- get { return use_json; }
- set { use_json = value; }
- }
-
- internal string SharedSecret
- {
- get { return secret; }
- set { secret = value; }
- }
-
- internal string ApiKey
- {
- get { return api_key; }
- }
-
+ ApiKey = api_key;
+ SharedSecret = secret;
+ }
+
+ public bool UseJson { get; set; }
+
+ internal string SharedSecret { get; set; }
+
+ internal string ApiKey { get; private set; }
+
public T GetResponse<T>(string method_name, params FacebookParam[] parameters)
{
string url = FormatGetUrl (method_name, parameters);
@@ -252,7 +238,7 @@ namespace Mono.Facebook
{
List<FacebookParam> list = new List<FacebookParam> (parameters);
list.Add (FacebookParam.Create ("method", method_name));
- list.Add (FacebookParam.Create ("api_key", api_key));
+ list.Add (FacebookParam.Create ("api_key", ApiKey));
list.Add (VersionParam);
list.Sort ();
@@ -261,7 +247,7 @@ namespace Mono.Facebook
foreach (FacebookParam param in list)
values.Append (param.ToString ());
- values.Append (secret);
+ values.Append (SharedSecret);
byte[] md5_result = MD5.Create ().ComputeHash (Encoding.ASCII.GetBytes (values.ToString ()));
diff --git a/src/Extensions/Exporters/FSpot.Exporters.Flickr/FSpot.Exporters.Flickr/FlickrExport.cs b/src/Extensions/Exporters/FSpot.Exporters.Flickr/FSpot.Exporters.Flickr/FlickrExport.cs
index 2d148ad..9ddd6ae 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.Flickr/FSpot.Exporters.Flickr/FlickrExport.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.Flickr/FSpot.Exporters.Flickr/FlickrExport.cs
@@ -286,23 +286,9 @@ namespace FSpot.Exporters.Flickr {
});
}
- private class AuthorizationEventArgs : System.EventArgs {
- Exception e;
- Auth auth;
-
- public Exception Exception {
- get { return e; }
- set { e = value; }
- }
-
- public Auth Auth {
- get { return auth; }
- set { auth = value; }
- }
-
- public AuthorizationEventArgs ()
- {
- }
+ private class AuthorizationEventArgs : System.EventArgs {
+ public Exception Exception { get; set; }
+ public Auth Auth { get; set; }
}
public void HandleSizeActive (object sender, System.EventArgs args)
diff --git a/src/Extensions/Exporters/FSpot.Exporters.Flickr/FSpot.Exporters.Flickr/FlickrRemote.cs b/src/Extensions/Exporters/FSpot.Exporters.Flickr/FSpot.Exporters.Flickr/FlickrRemote.cs
index 5b88491..3ca01c3 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.Flickr/FSpot.Exporters.Flickr/FlickrRemote.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.Flickr/FSpot.Exporters.Flickr/FlickrRemote.cs
@@ -43,6 +43,7 @@
*/
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Text;
using FSpot.Core;
@@ -69,7 +70,7 @@ public class FlickrRemote {
public FlickrRemote (string token, Service service)
{
- if (token == null || token.Length == 0) {
+ if (string.IsNullOrEmpty(token)) {
this.flickr = new FlickrNet.Flickr (service.ApiKey, service.Secret);
this.token = null;
} else {
@@ -258,15 +259,15 @@ public class FlickrRemote {
PreferencePath = pref;
}
- public static Service FromSupported (SupportedService id)
- {
- foreach (Service s in Supported) {
- if (s.Id == id)
- return s;
- }
-
- throw new System.ArgumentException ("Unknown service type");
- }
+ public static Service FromSupported (SupportedService id)
+ {
+ foreach (Service s in Supported.Where(s => s.Id == id))
+ {
+ return s;
+ }
+
+ throw new System.ArgumentException ("Unknown service type");
+ }
}
}
}
diff --git a/src/Extensions/Exporters/FSpot.Exporters.Folder/FSpot.Exporters.Folder/FolderExport.cs b/src/Extensions/Exporters/FSpot.Exporters.Folder/FSpot.Exporters.Folder/FolderExport.cs
index a837bcb..fcbb047 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.Folder/FSpot.Exporters.Folder/FolderExport.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.Folder/FSpot.Exporters.Folder/FolderExport.cs
@@ -301,7 +301,7 @@ namespace FSpot.Exporters.Folder
if (!dest.IsNative)
System.IO.Directory.Delete (gallery_path, true);
- ThreadAssist.ProxyToMain (() => { Dialog.Destroy(); });
+ ThreadAssist.ProxyToMain (() => Dialog.Destroy());
}
}
diff --git a/src/Extensions/Exporters/FSpot.Exporters.Folder/FSpot.Exporters.Folder/FolderGallery.cs b/src/Extensions/Exporters/FSpot.Exporters.Folder/FSpot.Exporters.Folder/FolderGallery.cs
index 4e22807..bb4b1a3 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.Folder/FSpot.Exporters.Folder/FolderGallery.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.Folder/FSpot.Exporters.Folder/FolderGallery.cs
@@ -75,16 +75,16 @@ namespace FSpot.Exporters.Folder
public ScaleRequest (string name, int width, int height, bool skip, bool exif = false)
{
- this.Name = name != null ? name : String.Empty;
- this.Width = width;
- this.Height = height;
- this.Skip = skip;
- this.CopyExif = exif;
+ Name = name ?? String.Empty;
+ Width = width;
+ Height = height;
+ Skip = skip;
+ CopyExif = exif;
}
public bool AvoidScale (int size)
{
- return (size < this.Width && size < this.Height && this.Skip);
+ return (size < Width && size < Height && Skip);
}
}
@@ -111,7 +111,7 @@ namespace FSpot.Exporters.Folder
Collection = selection;
GalleryName = gallery_name;
GalleryPath = Path.Combine (path, GalleryName);
- this.requests = new ScaleRequest [] { ScaleRequest.Default };
+ requests = new ScaleRequest [] { ScaleRequest.Default };
}
#endregion
diff --git a/src/Extensions/Exporters/FSpot.Exporters.Gallery/FSpot.Exporters.Gallery/FormClient.cs b/src/Extensions/Exporters/FSpot.Exporters.Gallery/FSpot.Exporters.Gallery/FormClient.cs
index 23f16d7..9e9f68f 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.Gallery/FSpot.Exporters.Gallery/FormClient.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.Gallery/FSpot.Exporters.Gallery/FormClient.cs
@@ -60,13 +60,10 @@ namespace FSpot.Exporters.Gallery
private string boundary;
private string start_boundary;
- private string end_boundary;
-
- private bool multipart = false;
- public bool Multipart {
- set { multipart = value; }
- }
-
+ private string end_boundary;
+
+ public bool Multipart { private get; set; }
+
private bool first_item;
public bool Buffer = false;
@@ -80,15 +77,17 @@ namespace FSpot.Exporters.Gallery
public FSpot.ProgressItem Progress;
public FormClient (CookieContainer cookies)
- {
- this.Cookies = cookies;
- this.Items = new List<FormItem> ();
+ {
+ Multipart = false;
+ Cookies = cookies;
+ Items = new List<FormItem> ();
}
public FormClient ()
- {
- this.Items = new List<FormItem> ();
- this.Cookies = new CookieContainer ();
+ {
+ Multipart = false;
+ Items = new List<FormItem> ();
+ Cookies = new CookieContainer ();
}
private void GenerateBoundary ()
@@ -106,7 +105,7 @@ namespace FSpot.Exporters.Gallery
public void Add (string name, FileInfo fileinfo)
{
- multipart = true;
+ Multipart = true;
Items.Add (new FormItem (name, fileinfo));
}
@@ -115,7 +114,7 @@ namespace FSpot.Exporters.Gallery
// types we allow in .Add
if (item.Value == null) {
- Write (item.Name, (string)String.Empty);
+ Write (item.Name, String.Empty);
} else if (item.Value is FileInfo) {
Write (item.Name, (FileInfo)item.Value);
} else if (item.Value is string) {
@@ -125,21 +124,24 @@ namespace FSpot.Exporters.Gallery
}
}
- private long MultipartLength (FormItem item) {
+ private long MultipartLength (FormItem item)
+ {
// The types we check here need to match the
// types we allow in .Add
if (item.Value == null) {
return MultipartLength (item.Name, (string)String.Empty);
- } else if (item.Value is FileInfo) {
+ }
+ if (item.Value is FileInfo) {
return MultipartLength (item.Name, (FileInfo)item.Value);
- } else if (item.Value is string) {
+ }
+ if (item.Value is string) {
return MultipartLength (item.Name, (string)item.Value);
- } else {
- throw new Exception ("Unknown value type");
- }
- }
-
+ }
+
+ throw new Exception ("Unknown value type");
+ }
+
private string MultipartHeader (string name, string value)
{
return string.Format ("{0}\r\n" +
@@ -158,7 +160,7 @@ namespace FSpot.Exporters.Gallery
{
string cmd;
- if (multipart) {
+ if (Multipart) {
cmd = String.Format ("{0}"
+ "{1}\r\n",
MultipartHeader (name, value), value);
@@ -195,7 +197,7 @@ namespace FSpot.Exporters.Gallery
private void Write (string name, FileInfo file)
{
- if (multipart) {
+ if (Multipart) {
stream_writer.Write (MultipartHeader (name, file));
stream_writer.Flush ();
Stream stream = stream_writer.BaseStream;
@@ -224,7 +226,7 @@ namespace FSpot.Exporters.Gallery
public void Clear ()
{
Items.Clear ();
- multipart = false;
+ Multipart = false;
}
public HttpWebResponse Submit (string url, FSpot.ProgressItem progress_item = null)
@@ -262,7 +264,7 @@ namespace FSpot.Exporters.Gallery
Request.Headers["Accept-Charset"] = "utf-8;";
Request.UserAgent = String.Format("F-Spot {0} (http://www.f-spot.org)", Defines.VERSION);
- if (multipart) {
+ if (Multipart) {
GenerateBoundary ();
Request.ContentType = "multipart/form-data; boundary=" + boundary;
Request.Timeout = Request.Timeout * 3;
@@ -293,7 +295,7 @@ namespace FSpot.Exporters.Gallery
Write (item);
}
- if (multipart)
+ if (Multipart)
stream_writer.Write (end_boundary + "\r\n");
stream_writer.Flush ();
diff --git a/src/Extensions/Exporters/FSpot.Exporters.Gallery/FSpot.Exporters.Gallery/Gallery2.cs b/src/Extensions/Exporters/FSpot.Exporters.Gallery/FSpot.Exporters.Gallery/Gallery2.cs
index 02f0edc..bc61456 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.Gallery/FSpot.Exporters.Gallery/Gallery2.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.Gallery/FSpot.Exporters.Gallery/Gallery2.cs
@@ -261,7 +261,7 @@ namespace FSpot.Exporters.Gallery
public override string GetAlbumUrl (Album album)
{
- return Uri.ToString () + "?g2_view=core.ShowItem&g2_itemId=" + album.Name;
+ return Uri + "?g2_view=core.ShowItem&g2_itemId=" + album.Name;
}
}
}
diff --git a/src/Extensions/Exporters/FSpot.Exporters.Gallery/FSpot.Exporters.Gallery/GalleryAccount.cs b/src/Extensions/Exporters/FSpot.Exporters.Gallery/FSpot.Exporters.Gallery/GalleryAccount.cs
index 47ef950..5a8d19d 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.Gallery/FSpot.Exporters.Gallery/GalleryAccount.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.Gallery/FSpot.Exporters.Gallery/GalleryAccount.cs
@@ -37,15 +37,12 @@ namespace FSpot.Exporters.Gallery
public GalleryAccount (string name, string url, string username, string password) : this (name, url, username, password, GalleryVersion.VersionUnknown) {}
public GalleryAccount (string name, string url, string username, string password, GalleryVersion version)
{
- this.Name = name;
+ Name = name;
this.username = username;
this.password = password;
- this.Url = url;
+ Url = url;
- if (version != GalleryVersion.VersionUnknown)
- this.Version = version;
- else
- this.Version = Gallery.DetectGalleryVersion(Url);
+ Version = version != GalleryVersion.VersionUnknown ? version : Gallery.DetectGalleryVersion(Url);
}
public const string EXPORT_SERVICE = "gallery/";
diff --git a/src/Extensions/Exporters/FSpot.Exporters.Gallery/FSpot.Exporters.Gallery/GalleryAddAlbum.cs b/src/Extensions/Exporters/FSpot.Exporters.Gallery/FSpot.Exporters.Gallery/GalleryAddAlbum.cs
index ca095c5..a4a06fe 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.Gallery/FSpot.Exporters.Gallery/GalleryAddAlbum.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.Gallery/FSpot.Exporters.Gallery/GalleryAddAlbum.cs
@@ -105,12 +105,12 @@ namespace FSpot.Exporters.Gallery
if (gallery.Albums.Count == 0 || album_optionmenu.Active <= 0)
parent = String.Empty;
else
- parent = ((Album) gallery.Albums [album_optionmenu.Active-1]).Name;
+ parent = gallery.Albums [album_optionmenu.Active-1].Name;
else
if (gallery.Albums.Count == 0 || album_optionmenu.Active < 0)
parent = String.Empty;
else
- parent = ((Album) gallery.Albums [album_optionmenu.Active]).Name;
+ parent = gallery.Albums [album_optionmenu.Active].Name;
name = name_entry.Text;
description = description_entry.Text;
diff --git a/src/Extensions/Exporters/FSpot.Exporters.Gallery/FSpot.Exporters.Gallery/GalleryRemote.cs b/src/Extensions/Exporters/FSpot.Exporters.Gallery/FSpot.Exporters.Gallery/GalleryRemote.cs
index 8230858..94d6b4d 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.Gallery/FSpot.Exporters.Gallery/GalleryRemote.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.Gallery/FSpot.Exporters.Gallery/GalleryRemote.cs
@@ -131,11 +131,12 @@ namespace FSpot.Exporters.Gallery
return Gallery.GetAlbumUrl(this);
}
- public int CompareTo (Object obj)
+ // FIXME: I switched this to Album obj since its now a List and not an ArrayList
+ public int CompareTo (Album obj)
{
- Album other = obj as Album;
+ Album other = obj;
- int numThis = this.Parents.Count;
+ int numThis = Parents.Count;
int numOther = other.Parents.Count;
int thisVal = -1, otherVal = -1;
@@ -143,8 +144,8 @@ namespace FSpot.Exporters.Gallery
int maxIters = Math.Min (numThis, numOther);
int i = 0;
while (i < maxIters) {
- thisVal = (int)this.Parents[i];
- otherVal = (int)other.Parents[i];
+ thisVal = Parents[i];
+ otherVal = other.Parents[i];
if (thisVal != otherVal) {
break;
}
@@ -158,7 +159,7 @@ namespace FSpot.Exporters.Gallery
} else if (i < numThis) {
//other shorter
- thisVal = (int)this.Parents[i];
+ thisVal = Parents[i];
retVal = thisVal.CompareTo (other.RefNum);
//if equal, we want to make the shorter one come first
@@ -167,8 +168,8 @@ namespace FSpot.Exporters.Gallery
} else if (i < numOther) {
//this shorter
- otherVal = (int)other.Parents[i];
- retVal = this.RefNum.CompareTo (otherVal);
+ otherVal = other.Parents[i];
+ retVal = RefNum.CompareTo (otherVal);
//if equal, we want to make the shorter one come first
if (retVal == 0)
@@ -176,7 +177,7 @@ namespace FSpot.Exporters.Gallery
} else {
//children of the same parent
- retVal = this.RefNum.CompareTo (other.RefNum);
+ retVal = RefNum.CompareTo (other.RefNum);
}
return retVal;
}
diff --git a/src/Extensions/Exporters/FSpot.Exporters.PicasaWeb/FSpot.Exporters.PicasaWeb/GoogleAccount.cs b/src/Extensions/Exporters/FSpot.Exporters.PicasaWeb/FSpot.Exporters.PicasaWeb/GoogleAccount.cs
index 053c38c..8ec593c 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.PicasaWeb/FSpot.Exporters.PicasaWeb/GoogleAccount.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.PicasaWeb/FSpot.Exporters.PicasaWeb/GoogleAccount.cs
@@ -40,12 +40,9 @@ namespace FSpot.Exporters.PicasaWeb
public class GoogleAccount {
private string username;
- private string password;
- private string token;
- private string unlock_captcha;
- private GoogleConnection connection;
- private Mono.Google.Picasa.PicasaWeb picasa;
-
+ private string password;
+ private GoogleConnection connection;
+
public GoogleAccount (string username, string password)
{
this.username = username;
@@ -56,8 +53,8 @@ namespace FSpot.Exporters.PicasaWeb
{
this.username = username;
this.password = password;
- this.token = token;
- this.unlock_captcha = unlock_captcha;
+ Token = token;
+ UnlockCaptcha = unlock_captcha;
}
public Mono.Google.Picasa.PicasaWeb Connect ()
@@ -65,16 +62,16 @@ namespace FSpot.Exporters.PicasaWeb
Log.Debug ("GoogleAccount.Connect()");
GoogleConnection conn = new GoogleConnection (GoogleService.Picasa);
ServicePointManager.CertificatePolicy = new NoCheckCertificatePolicy ();
- if (unlock_captcha == null || token == null)
+ if (UnlockCaptcha == null || Token == null)
conn.Authenticate(username, password);
else {
- conn.Authenticate(username, password, token, unlock_captcha);
- token = null;
- unlock_captcha = null;
+ conn.Authenticate(username, password, Token, UnlockCaptcha);
+ Token = null;
+ UnlockCaptcha = null;
}
connection = conn;
var picasa = new Mono.Google.Picasa.PicasaWeb(conn);
- this.picasa = picasa;
+ Picasa = picasa;
return picasa;
}
@@ -111,30 +108,12 @@ namespace FSpot.Exporters.PicasaWeb
MarkChanged ();
}
}
- }
-
- public string Token {
- get {
- return token;
- }
- set {
- token = value;
- }
- }
-
- public string UnlockCaptcha {
- get {
- return unlock_captcha;
- }
- set {
- unlock_captcha = value;
- }
- }
-
- public Mono.Google.Picasa.PicasaWeb Picasa {
- get {
- return picasa;
- }
- }
+ }
+
+ public string Token { get; set; }
+
+ public string UnlockCaptcha { get; set; }
+
+ public Mono.Google.Picasa.PicasaWeb Picasa { get; private set; }
}
}
diff --git a/src/Extensions/Exporters/FSpot.Exporters.PicasaWeb/FSpot.Exporters.PicasaWeb/GoogleAccountManager.cs b/src/Extensions/Exporters/FSpot.Exporters.PicasaWeb/FSpot.Exporters.PicasaWeb/GoogleAccountManager.cs
index ffe3f0a..4f7e867 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.PicasaWeb/FSpot.Exporters.PicasaWeb/GoogleAccountManager.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.PicasaWeb/FSpot.Exporters.PicasaWeb/GoogleAccountManager.cs
@@ -42,8 +42,8 @@ namespace FSpot.Exporters.PicasaWeb
public class GoogleAccountManager
{
private static GoogleAccountManager instance;
- private const string keyring_item_name = "Google Account";
- List<GoogleAccount> accounts;
+ private const string keyring_item_name = "Google Account";
+ readonly List<GoogleAccount> accounts;
public delegate void AccountListChangedHandler (GoogleAccountManager manager, GoogleAccount changed_account);
public event AccountListChangedHandler AccountListChanged;
@@ -61,14 +61,9 @@ namespace FSpot.Exporters.PicasaWeb
{
accounts = new List<GoogleAccount> ();
ReadAccounts ();
- }
-
- public void MarkChanged ()
- {
- MarkChanged (true, null);
- }
-
- public void MarkChanged (bool write, GoogleAccount changed_account)
+ }
+
+ public void MarkChanged (bool write = true, GoogleAccount changed_account = null)
{
if (write)
WriteAccounts ();
@@ -80,14 +75,9 @@ namespace FSpot.Exporters.PicasaWeb
public List<GoogleAccount> GetAccounts ()
{
return accounts;
- }
-
- public void AddAccount (GoogleAccount account)
- {
- AddAccount (account, true);
- }
-
- public void AddAccount (GoogleAccount account, bool write)
+ }
+
+ public void AddAccount (GoogleAccount account, bool write = true)
{
accounts.Add (account);
MarkChanged (write, account);
diff --git a/src/Extensions/Exporters/FSpot.Exporters.PicasaWeb/FSpot.Exporters.PicasaWeb/PicasaWebExport.cs b/src/Extensions/Exporters/FSpot.Exporters.PicasaWeb/FSpot.Exporters.PicasaWeb/PicasaWebExport.cs
index 0379582..70a1b88 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.PicasaWeb/FSpot.Exporters.PicasaWeb/PicasaWebExport.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.PicasaWeb/FSpot.Exporters.PicasaWeb/PicasaWebExport.cs
@@ -56,11 +56,7 @@ using Mono.Unix;
namespace FSpot.Exporters.PicasaWeb
{
public class GoogleExport : FSpot.Extensions.IExporter
- {
- public GoogleExport ()
- {
- }
-
+ {
public void Run (IBrowsableCollection selection)
{
builder = new GtkBeans.Builder (null, "google_export_dialog.ui", null);
@@ -330,14 +326,9 @@ namespace FSpot.Exporters.PicasaWeb
Log.DebugFormat ("Setting gallery_optionmenu.Active = {0}", pos);
gallery_optionmenu.Active = pos;
- }
-
- private void Connect ()
- {
- Connect (null);
- }
-
- private void Connect (GoogleAccount selected)
+ }
+
+ private void Connect (GoogleAccount selected = null)
{
Connect (selected, null, null);
}
@@ -396,6 +387,7 @@ namespace FSpot.Exporters.PicasaWeb
}
}
+ // FIXME: This is never used
private void HandleAccountSelected (object sender, System.EventArgs args)
{
Connect ();
@@ -409,7 +401,7 @@ namespace FSpot.Exporters.PicasaWeb
// make the newly created album selected
// PicasaAlbumCollection albums = account.Picasa.GetAlbums();
for (int i=0; i < albums.Count; i++) {
- if (((PicasaAlbum)albums [i]).Title == title)
+ if (albums [i].Title == title)
album_optionmenu.Active = i;
}
}
@@ -517,12 +509,7 @@ namespace FSpot.Exporters.PicasaWeb
}
private Gtk.Dialog Dialog {
- get {
- if (dialog == null)
- dialog = new Gtk.Dialog (builder.GetRawObject (dialog_name));
-
- return dialog;
- }
+ get { return dialog ?? (dialog = new Gtk.Dialog(builder.GetRawObject(dialog_name))); }
}
}
}
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
index d0a8ee0..b000f9b 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugAccountDialog.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugAccountDialog.cs
@@ -63,7 +63,7 @@ namespace FSpot.Exporters.SmugMug
if (remove_button != null)
remove_button.Visible = account != null;
- this.Dialog.Show ();
+ Dialog.Show ();
password_entry.Changed += HandleChanged;
username_entry.Changed += HandleChanged;
@@ -102,12 +102,7 @@ namespace FSpot.Exporters.SmugMug
}
private Gtk.Dialog Dialog {
- get {
- if (dialog == null)
- dialog = new Gtk.Dialog (builder.GetRawObject (dialog_name));
-
- return dialog;
- }
+ get { return dialog ?? (dialog = new Gtk.Dialog(builder.GetRawObject(dialog_name))); }
}
private SmugMugAccount account;
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
index 66f3d8a..cb07b50 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugAccountManager.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugAccountManager.cs
@@ -80,14 +80,9 @@ namespace FSpot.Exporters.SmugMug
public List<SmugMugAccount> GetAccounts ()
{
return accounts;
- }
-
- public void AddAccount (SmugMugAccount account)
- {
- AddAccount (account, true);
- }
-
- public void AddAccount (SmugMugAccount account, bool write)
+ }
+
+ public void AddAccount (SmugMugAccount account, bool write = true)
{
accounts.Add (account);
MarkChanged (write, account);
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
index 94cc918..2f1c5dd 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugAddAlbum.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.SmugMug/FSpot.Exporters.SmugMug/SmugMugAddAlbum.cs
@@ -72,16 +72,13 @@ namespace FSpot.Exporters.SmugMug
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;
- }
-
+ private void HandleChanged (object sender, EventArgs args)
+ {
+ title = title_entry.Text;
+
+ add_button.Sensitive = title != String.Empty;
+ }
+
[GLib.ConnectBefore]
protected void HandleAddResponse (object sender, Gtk.ResponseArgs args)
{
@@ -121,12 +118,7 @@ namespace FSpot.Exporters.SmugMug
}
private Gtk.Dialog Dialog {
- get {
- if (dialog == null)
- dialog = new Gtk.Dialog (builder.GetRawObject (dialog_name));
-
- return dialog;
- }
+ get { return dialog ?? (dialog = new Gtk.Dialog(builder.GetRawObject(dialog_name))); }
}
}
}
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 797ac93..0ed5620 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
@@ -163,7 +163,7 @@ namespace FSpot.Exporters.SmugMug {
browser = browser_check.Active;
if (account != null) {
- album = (Album) account.SmugMug.GetAlbums() [Math.Max (0, album_optionmenu.Active)];
+ album = account.SmugMug.GetAlbums() [Math.Max (0, album_optionmenu.Active)];
photo_index = 0;
Dialog.Destroy ();
@@ -286,14 +286,9 @@ namespace FSpot.Exporters.SmugMug {
}
gallery_optionmenu.Active = pos;
- }
-
- private void Connect ()
- {
- Connect (null);
- }
-
- private void Connect (SmugMugAccount selected)
+ }
+
+ private void Connect (SmugMugAccount selected = null)
{
Connect (selected, null);
}
@@ -427,12 +422,7 @@ namespace FSpot.Exporters.SmugMug {
}
private Gtk.Dialog Dialog {
- get {
- if (dialog == null)
- dialog = new Gtk.Dialog (builder.GetRawObject (dialog_name));
-
- return dialog;
- }
+ get { return dialog ?? (dialog = new Gtk.Dialog(builder.GetRawObject(dialog_name))); }
}
}
}
diff --git a/src/Extensions/Exporters/FSpot.Exporters.Tabblo/FSpot.Exporters.Tabblo/TabbloExport.cs b/src/Extensions/Exporters/FSpot.Exporters.Tabblo/FSpot.Exporters.Tabblo/TabbloExport.cs
index 820a5d5..db7536c 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.Tabblo/FSpot.Exporters.Tabblo/TabbloExport.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.Tabblo/FSpot.Exporters.Tabblo/TabbloExport.cs
@@ -373,12 +373,8 @@ namespace FSpot.Exporters.Tabblo {
}
PhotoStore photo_store = FSpot.App.Instance.Database.Photos;
- FSpot.Photo photo = photo_store.GetByUri (
- item.DefaultVersion.Uri);
+ FSpot.Photo photo = photo_store.GetByUri (item.DefaultVersion.Uri);
Debug.Assert (null != photo);
- if (null == photo) {
- return;
- }
if (model.AttachTags) {
photo.AddTag (model.AttachedTags);
diff --git a/src/Extensions/Exporters/FSpot.Exporters.Tabblo/FSpot.Exporters.Tabblo/TabbloExportModel.cs b/src/Extensions/Exporters/FSpot.Exporters.Tabblo/FSpot.Exporters.Tabblo/TabbloExportModel.cs
index d9bc848..ac3bc5d 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.Tabblo/FSpot.Exporters.Tabblo/TabbloExportModel.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.Tabblo/FSpot.Exporters.Tabblo/TabbloExportModel.cs
@@ -39,10 +39,7 @@ using Hyena;
namespace FSpot.Exporters.Tabblo {
- class TabbloExportModel : Mono.Tabblo.IPreferences {
-
- private IBrowsableCollection photo_collection;
-
+ class TabbloExportModel : Mono.Tabblo.IPreferences {
private string username;
private string password;
@@ -74,20 +71,13 @@ namespace FSpot.Exporters.Tabblo {
private const string KeyringItemAppAttr = "application";
- // The photos.
-
- internal IBrowsableCollection PhotoCollection {
- get {
- return photo_collection;
- }
- set {
- photo_collection = value;
- }
- }
-
+ // The photos.
+
+ internal IBrowsableCollection PhotoCollection { get; set; }
+
internal IPhoto [] Photos {
get {
- return photo_collection.Items;
+ return PhotoCollection.Items;
}
}
@@ -97,8 +87,7 @@ namespace FSpot.Exporters.Tabblo {
internal event EventHandler UsernameChanged;
public string Username {
get {
- return null != username
- ? username : string.Empty;
+ return null != username ? username : string.Empty;
}
internal set {
string old_value = username;
@@ -111,8 +100,7 @@ namespace FSpot.Exporters.Tabblo {
internal event EventHandler PasswordChanged;
public string Password {
get {
- return null != password
- ? password : string.Empty;
+ return null != password ? password : string.Empty;
}
internal set {
string old_value = password;
@@ -149,8 +137,7 @@ namespace FSpot.Exporters.Tabblo {
internal event EventHandler AttachedTagsChanged;
internal FSpot.Core.Tag [] AttachedTags {
get {
- return null != attached_tags
- ? attached_tags : no_tags;
+ return null != attached_tags ? attached_tags : no_tags;
}
set {
FSpot.Core.Tag [] old_value = attached_tags;
@@ -176,8 +163,7 @@ namespace FSpot.Exporters.Tabblo {
internal event EventHandler RemovedTagsChanged;
internal FSpot.Core.Tag [] RemovedTags {
get {
- return null != removed_tags
- ? removed_tags : no_tags;
+ return null != removed_tags ? removed_tags : no_tags;
}
set {
FSpot.Core.Tag [] old_value = removed_tags;
@@ -219,6 +205,7 @@ namespace FSpot.Exporters.Tabblo {
string keyring = Gnome.Keyring
.Ring.GetDefaultKeyring ();
+ // FIXME: Change this out for a Dictionary
Hashtable attrs = new Hashtable ();
attrs [KeyringItemNameAttr] = KeyringItemName;
attrs [KeyringItemAppAttr] = KeyringItemApp;
@@ -257,9 +244,10 @@ namespace FSpot.Exporters.Tabblo {
private void ReadAccountData ()
{
string new_username = string.Empty;
- string new_password = string.Empty;
-
- Hashtable attrs = new Hashtable ();
+ string new_password = string.Empty;
+
+ // FIXME: Change this out for a Dictionary
+ Hashtable attrs = new Hashtable();
attrs [KeyringItemNameAttr] = KeyringItemName;
attrs [KeyringItemAppAttr] = KeyringItemApp;
@@ -353,14 +341,14 @@ namespace FSpot.Exporters.Tabblo {
}
- private static FSpot.Core.Tag [] ToTags (int [] ids)
+ private static FSpot.Core.Tag [] ToTags (ICollection<int> ids)
{
if (null == ids) {
return null;
}
List <FSpot.Core.Tag> tags =
- new List <FSpot.Core.Tag> (ids.Length);
+ new List <FSpot.Core.Tag> (ids.Count);
foreach (int id in ids) {
FSpot.Core.Tag tag = FSpot.App.Instance.Database.Tags
.GetTagById (id);
diff --git a/src/Extensions/Exporters/FSpot.Exporters.Zip/FSpot.Exporters.Zip/ZipExport.cs b/src/Extensions/Exporters/FSpot.Exporters.Zip/FSpot.Exporters.Zip/ZipExport.cs
index 2bd4112..fa452e5 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.Zip/FSpot.Exporters.Zip/ZipExport.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.Zip/FSpot.Exporters.Zip/ZipExport.cs
@@ -127,8 +127,9 @@ namespace FSpot.Exporters.Zip {
photos.Length, zipdiag);
//Pack up
- for (int i = 0; i < photos.Length; i ++) {
- if (progress_dialog.Update (String.Format (Catalog.GetString ("Preparing photo \"{0}\""), photos[i].Name))) {
+ foreach (IPhoto photo in photos)
+ {
+ if (progress_dialog.Update (String.Format (Catalog.GetString ("Preparing photo \"{0}\""), photo.Name))) {
progress_dialog.Destroy ();
return;
}
@@ -138,17 +139,17 @@ namespace FSpot.Exporters.Zip {
FilterSet filters = new FilterSet ();
filters.Add (new JpegFilter ());
filters.Add (new ResizeFilter ((uint) scale_size.ValueAsInt));
- FilterRequest freq = new FilterRequest (photos [i].DefaultVersion.Uri);
+ FilterRequest freq = new FilterRequest (photo.DefaultVersion.Uri);
filters.Convert (freq);
f = freq.Current.LocalPath;
} else {
- f = photos [i].DefaultVersion.Uri.LocalPath;
+ f = photo.DefaultVersion.Uri.LocalPath;
}
FileStream fs = File.OpenRead (f);
byte [] buffer = new byte [fs.Length];
fs.Read (buffer, 0, buffer.Length);
- ZipEntry entry = new ZipEntry (System.IO.Path.GetFileName (photos [i].DefaultVersion.Uri.LocalPath));
+ ZipEntry entry = new ZipEntry (System.IO.Path.GetFileName (photo.DefaultVersion.Uri.LocalPath));
entry.DateTime = DateTime.Now;
@@ -162,7 +163,7 @@ namespace FSpot.Exporters.Zip {
s.PutNextEntry (entry);
- s.Write (buffer, 0, buffer.Length);
+ s.Write (buffer, 0, buffer.Length);
}
s.Finish ();
s.Close ();
diff --git a/src/Extensions/Tools/FSpot.Tools.ChangePhotoPath/FSpot.Tools.ChangePhotoPath/ChangePhotoPathController.cs b/src/Extensions/Tools/FSpot.Tools.ChangePhotoPath/FSpot.Tools.ChangePhotoPath/ChangePhotoPathController.cs
index 6c46628..97213f6 100644
--- a/src/Extensions/Tools/FSpot.Tools.ChangePhotoPath/FSpot.Tools.ChangePhotoPath/ChangePhotoPathController.cs
+++ b/src/Extensions/Tools/FSpot.Tools.ChangePhotoPath/FSpot.Tools.ChangePhotoPath/ChangePhotoPathController.cs
@@ -102,7 +102,7 @@ namespace FSpot.Tools.ChangePhotoPath
private string EnsureEndsWithOneDirectorySeparator (string tmp_str)
{
- if ( (tmp_str == null) || (tmp_str.Length == 0) )
+ if ( string.IsNullOrEmpty(tmp_str) )
return String.Format ("{0}", Path.DirectorySeparatorChar);
while (tmp_str.EndsWith(String.Format ("{0}", Path.DirectorySeparatorChar)))
tmp_str = tmp_str.Remove (tmp_str.Length-1, 1);
@@ -176,7 +176,7 @@ namespace FSpot.Tools.ChangePhotoPath
{
foreach (uint version_id in photo.VersionIds) {
- PhotoVersion version = photo.GetVersion (version_id) as PhotoVersion;
+ PhotoVersion version = photo.GetVersion (version_id);
if ( ChangeThisVersionUri (version, old_base, new_base) )
AddVersionToArrays ( photo.Id,
version_id,
@@ -213,11 +213,12 @@ namespace FSpot.Tools.ChangePhotoPath
{
if (photo == null)
photo = photo_store.Get (photo_id_array[index]);
- PhotoVersion version = photo.GetVersion ( (uint) version_id_array[index]) as PhotoVersion;
+
+ PhotoVersion version = photo.GetVersion ( version_id_array[index]);
version.BaseUri = new SafeUri ( path ).GetBaseUri ();
version.Filename = new SafeUri ( path ).GetFilename ();
photo.Changes.UriChanged = true;
- photo.Changes.ChangeVersion ( (uint) version_id_array[index] );
+ photo.Changes.ChangeVersion ( version_id_array[index] );
}
// FIXME: Refactor, try to use one common method....
@@ -282,8 +283,10 @@ namespace FSpot.Tools.ChangePhotoPath
int last_index = 0;
ProcessResult tmp_res;
tmp_res = ChangeAllUris(ref last_index);
- if (!(tmp_res == ProcessResult.Ok))
+
+ if (tmp_res != ProcessResult.Ok)
RevertAllUris(last_index);
+
return tmp_res;
}
diff --git a/src/Extensions/Tools/FSpot.Tools.ChangePhotoPath/FSpot.Tools.ChangePhotoPath/ChangePhotoPathGui.cs b/src/Extensions/Tools/FSpot.Tools.ChangePhotoPath/FSpot.Tools.ChangePhotoPath/ChangePhotoPathGui.cs
index cb20417..7a1f05b 100644
--- a/src/Extensions/Tools/FSpot.Tools.ChangePhotoPath/FSpot.Tools.ChangePhotoPath/ChangePhotoPathGui.cs
+++ b/src/Extensions/Tools/FSpot.Tools.ChangePhotoPath/FSpot.Tools.ChangePhotoPath/ChangePhotoPathGui.cs
@@ -187,8 +187,6 @@ namespace FSpot.Tools.ChangePhotoPath
remove_progress_dialog();
if (destroy_dialog)
Dialog.Destroy();
-
- return;
}
public void DisplayDefaultPaths (string oldpath, string newpath)
@@ -198,11 +196,12 @@ namespace FSpot.Tools.ChangePhotoPath
}
public void remove_progress_dialog ()
- {
- if (progress_dialog != null) {
- progress_dialog.Destroy();
- progress_dialog = null;
- }
+ {
+ if (progress_dialog == null)
+ return;
+
+ progress_dialog.Destroy();
+ progress_dialog = null;
}
public void check_if_remove_progress_dialog (int total)
diff --git a/src/Extensions/Tools/FSpot.Tools.DevelopInUFraw/FSpot.Tools.DevelopInUFraw/AbstractDevelopInUFRaw.cs b/src/Extensions/Tools/FSpot.Tools.DevelopInUFraw/FSpot.Tools.DevelopInUFraw/AbstractDevelopInUFRaw.cs
index d2afe7a..cf4addc 100644
--- a/src/Extensions/Tools/FSpot.Tools.DevelopInUFraw/FSpot.Tools.DevelopInUFraw/AbstractDevelopInUFRaw.cs
+++ b/src/Extensions/Tools/FSpot.Tools.DevelopInUFraw/FSpot.Tools.DevelopInUFraw/AbstractDevelopInUFRaw.cs
@@ -71,7 +71,7 @@ namespace FSpot.Tools.DevelopInUFraw
LoadPreference (UFRAW_ARGUMENTS_KEY);
LoadPreference (UFRAW_BATCH_ARGUMENTS_KEY);
- PhotoVersion raw = p.GetVersion (Photo.OriginalVersionId) as PhotoVersion;
+ PhotoVersion raw = p.GetVersion (Photo.OriginalVersionId);
if (!ImageFile.IsRaw (raw.Uri)) {
Log.Warning ("The original version of this image is not a (supported) RAW file");
return;
@@ -143,9 +143,8 @@ namespace FSpot.Tools.DevelopInUFraw
{
string name = Catalog.GetPluralString ("Developed in UFRaw", "Developed in UFRaw ({0})", i);
name = String.Format (name, i);
- if (p.VersionNameExists (name))
- return GetVersionName (p, i + 1);
- return name;
+
+ return p.VersionNameExists (name) ? GetVersionName (p, i + 1) : name;
}
private System.Uri GetUriForVersionName (Photo p, string version_name)
diff --git a/src/Extensions/Tools/FSpot.Tools.LiveWebGallery/FSpot.Tools.LiveWebGallery/GalleryRequestHandler.cs b/src/Extensions/Tools/FSpot.Tools.LiveWebGallery/FSpot.Tools.LiveWebGallery/GalleryRequestHandler.cs
index ff7b664..fe9c9ce 100644
--- a/src/Extensions/Tools/FSpot.Tools.LiveWebGallery/FSpot.Tools.LiveWebGallery/GalleryRequestHandler.cs
+++ b/src/Extensions/Tools/FSpot.Tools.LiveWebGallery/FSpot.Tools.LiveWebGallery/GalleryRequestHandler.cs
@@ -29,6 +29,7 @@
using System;
using System.IO;
+using System.Linq;
using System.Reflection;
using System.Text;
@@ -42,10 +43,7 @@ namespace FSpot.Tools.LiveWebGallery
{
protected string TagsToString (Photo photo)
{
- string tags = "";
- foreach (Tag tag in photo.Tags) {
- tags += ", " + tag.Name;
- }
+ string tags = photo.Tags.Aggregate("", (current, tag) => current + (", " + tag.Name));
return tags.Length > 1 ? tags.Substring (2) : tags;
}
@@ -82,49 +80,30 @@ namespace FSpot.Tools.LiveWebGallery
}
public class GalleryRequestHandler : TemplateRequestHandler, ILiveWebGalleryOptions
- {
- private QueryType query_type = QueryType.ByTag;
- public QueryType QueryType {
- get { return query_type; }
- set { query_type = value; }
- }
-
- private Tag query_tag;
- public Tag QueryTag {
- get { return query_tag; }
- set { query_tag = value; }
- }
-
- private bool limit_max_photos = true;
- public bool LimitMaxPhotos {
- get { return limit_max_photos; }
- set { limit_max_photos = value; }
- }
-
- private int max_photos = 1000;
- public int MaxPhotos {
- get { return max_photos; }
- set { max_photos = value; }
- }
-
- private bool tagging_allowed = false;
- public bool TaggingAllowed {
- get { return tagging_allowed; }
- set { tagging_allowed = value; }
- }
-
- private Tag editable_tag;
- public Tag EditableTag {
- get { return editable_tag; }
- set { editable_tag = value; }
- }
-
+ {
+ public QueryType QueryType { get; set; }
+
+ public Tag QueryTag { get; set; }
+
+ public bool LimitMaxPhotos { get; set; }
+
+ public int MaxPhotos { get; set; }
+
+ public bool TaggingAllowed { get; set; }
+
+ public Tag EditableTag { get; set; }
+
private LiveWebGalleryStats stats;
public GalleryRequestHandler (LiveWebGalleryStats stats)
: base ("gallery.html")
- {
+ {
+ TaggingAllowed = false;
+ MaxPhotos = 1000;
+ LimitMaxPhotos = true;
+ QueryType = QueryType.ByTag;
this.stats = stats;
+
template = template.Replace ("TITLE", Catalog.GetString("F-Spot Gallery"));
template = template.Replace ("OFFLINE_MESSAGE", Catalog.GetString("The web gallery seems to be offline now"));
template = template.Replace ("SHOW_ALL", Catalog.GetString("Show All"));
@@ -136,10 +115,10 @@ namespace FSpot.Tools.LiveWebGallery
StringBuilder s = new StringBuilder (4096);
s.Append (template);
- int num_photos = limit_max_photos ? Math.Min (photos.Length, max_photos) : photos.Length;
+ int num_photos = LimitMaxPhotos ? Math.Min (photos.Length, MaxPhotos) : photos.Length;
s.Replace ("NUM_PHOTOS", String.Format(Catalog.GetPluralString("{0} photo", "{0} photos", num_photos), num_photos));
s.Replace ("QUERY_TYPE", QueryTypeToString ());
- s.Replace ("EDITABLE_TAG_NAME", tagging_allowed ? Escape (editable_tag.Name) : "");
+ s.Replace ("EDITABLE_TAG_NAME", TaggingAllowed ? Escape (EditableTag.Name) : "");
string photo_template = GetSubTemplate (s, "BEGIN_PHOTO", "END_PHOTO");
StringBuilder photos_s = new StringBuilder (4096);
@@ -148,7 +127,7 @@ namespace FSpot.Tools.LiveWebGallery
foreach (Photo photo in photos) {
photos_s.Append (PreparePhoto (photo_template, photo));
- if (++num_photos >= max_photos && limit_max_photos)
+ if (++num_photos >= MaxPhotos && LimitMaxPhotos)
break;
}
s.Replace ("END_PHOTO", photos_s.ToString ());
@@ -162,9 +141,9 @@ namespace FSpot.Tools.LiveWebGallery
private Photo[] GetChosenPhotos ()
{
- switch (query_type) {
+ switch (QueryType) {
case QueryType.ByTag:
- return App.Instance.Database.Photos.Query (new Tag[] {query_tag});
+ return App.Instance.Database.Photos.Query (new Tag[] {QueryTag});
case QueryType.CurrentView:
return App.Instance.Organizer.Query.Photos;
case QueryType.Selected:
@@ -175,9 +154,9 @@ namespace FSpot.Tools.LiveWebGallery
private string QueryTypeToString ()
{
- switch (query_type) {
+ switch (QueryType) {
case QueryType.ByTag:
- return query_tag.Name;
+ return QueryTag.Name;
case QueryType.CurrentView:
return Catalog.GetString ("Current View");
case QueryType.Selected:
diff --git a/src/Extensions/Tools/FSpot.Tools.LiveWebGallery/FSpot.Tools.LiveWebGallery/SimpleWebServer.cs b/src/Extensions/Tools/FSpot.Tools.LiveWebGallery/FSpot.Tools.LiveWebGallery/SimpleWebServer.cs
index 97964cf..01c8e89 100644
--- a/src/Extensions/Tools/FSpot.Tools.LiveWebGallery/FSpot.Tools.LiveWebGallery/SimpleWebServer.cs
+++ b/src/Extensions/Tools/FSpot.Tools.LiveWebGallery/FSpot.Tools.LiveWebGallery/SimpleWebServer.cs
@@ -45,7 +45,7 @@ namespace FSpot.Tools.LiveWebGallery
{
private Thread server_thread;
private TcpListener listener;
- private Dictionary<string, RequestHandler> handlers = new Dictionary<string, RequestHandler> ();
+ private readonly Dictionary<string, RequestHandler> handlers = new Dictionary<string, RequestHandler> ();
private IWebStats stats;
public IWebStats Stats {
diff --git a/src/Extensions/Tools/FSpot.Tools.MergeDb/FSpot.Tools.MergeDb/MergeDb.cs b/src/Extensions/Tools/FSpot.Tools.MergeDb/FSpot.Tools.MergeDb/MergeDb.cs
index d4bdb1f..35bdcad 100644
--- a/src/Extensions/Tools/FSpot.Tools.MergeDb/FSpot.Tools.MergeDb/MergeDb.cs
+++ b/src/Extensions/Tools/FSpot.Tools.MergeDb/FSpot.Tools.MergeDb/MergeDb.cs
@@ -333,12 +333,13 @@ namespace FSpot.Tools.MergeDb
{
var parts = uri.AbsolutePath.Split('/');
SafeUri current = new SafeUri (uri.Scheme + ":///", true);
- for (int i = 0; i < parts.Length; i++) {
- current = current.Append (parts [i]);
+ foreach (string part in parts)
+ {
+ current = current.Append (part);
var file = GLib.FileFactory.NewForUri (current);
if (!file.Exists) {
file.MakeDirectory (null);
- }
+ }
}
}
}
diff --git a/src/Extensions/Tools/FSpot.Tools.MergeDb/FSpot.Tools.MergeDb/MergeDbDialog.cs b/src/Extensions/Tools/FSpot.Tools.MergeDb/FSpot.Tools.MergeDb/MergeDbDialog.cs
index 25ae378..039a5d8 100644
--- a/src/Extensions/Tools/FSpot.Tools.MergeDb/FSpot.Tools.MergeDb/MergeDbDialog.cs
+++ b/src/Extensions/Tools/FSpot.Tools.MergeDb/FSpot.Tools.MergeDb/MergeDbDialog.cs
@@ -95,10 +95,8 @@ namespace FSpot.Tools.MergeDb
get {
if (allrolls_radio.Active)
return null;
- if (newrolls_radio.Active)
- return rolls;
- else
- return new Roll [] {rolls [rolls_combo.Active]};
+
+ return newrolls_radio.Active ? rolls : new Roll [] {rolls [rolls_combo.Active]};
}
}
diff --git a/src/Extensions/Tools/FSpot.Tools.MergeDb/FSpot.Tools.MergeDb/PickFolderDialog.cs b/src/Extensions/Tools/FSpot.Tools.MergeDb/FSpot.Tools.MergeDb/PickFolderDialog.cs
index 752fbbc..26a7b65 100644
--- a/src/Extensions/Tools/FSpot.Tools.MergeDb/FSpot.Tools.MergeDb/PickFolderDialog.cs
+++ b/src/Extensions/Tools/FSpot.Tools.MergeDb/FSpot.Tools.MergeDb/PickFolderDialog.cs
@@ -61,10 +61,7 @@ namespace FSpot.Tools.MergeDb
public string Run ()
{
pickfolder_dialog.ShowAll ();
- if (pickfolder_dialog.Run () == -6)
- return pickfolder_chooser.Filename;
- else
- return null;
+ return pickfolder_dialog.Run () == -6 ? pickfolder_chooser.Filename : null;
}
public Gtk.Dialog Dialog {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]