[f-spot] Fix some minor formatting issues
- From: Stephen Shaw <sshaw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [f-spot] Fix some minor formatting issues
- Date: Thu, 24 Nov 2011 04:47:17 +0000 (UTC)
commit c8338e8c8b8e2684f6cec8088dddfc08838d8e4f
Author: Stephen Shaw <sshaw decriptor com>
Date: Wed Nov 23 21:47:14 2011 -0700
Fix some minor formatting issues
src/Clients/MainApp/FSpot/Literal.cs | 159 ++++++++++++++++++----------------
src/Clients/MainApp/FSpot/Term.cs | 80 ++++++-----------
2 files changed, 111 insertions(+), 128 deletions(-)
---
diff --git a/src/Clients/MainApp/FSpot/Literal.cs b/src/Clients/MainApp/FSpot/Literal.cs
index 662c763..df2a168 100644
--- a/src/Clients/MainApp/FSpot/Literal.cs
+++ b/src/Clients/MainApp/FSpot/Literal.cs
@@ -33,7 +33,6 @@
// This has to do with Finding photos based on tags
// http://mail.gnome.org/archives/f-spot-list/2005-November/msg00053.html
// http://bugzilla-attachments.gnome.org/attachment.cgi?id=54566
-
using System;
using System.Collections;
using System.Collections.Generic;
@@ -48,7 +47,9 @@ namespace FSpot
{
public abstract class AbstractLiteral : Term
{
- public AbstractLiteral(Term parent, Literal after) : base (parent, after) { }
+ public AbstractLiteral (Term parent, Literal after) : base (parent, after)
+ {
+ }
public override Term Invert (bool recurse)
{
@@ -60,9 +61,12 @@ namespace FSpot
// TODO rename to TagLiteral?
public class Literal : AbstractLiteral
{
- public Literal (Tag tag) : this (null, tag, null) { }
+ public Literal (Tag tag) : this (null, tag, null)
+ {
+ }
- public Literal (Term parent, Tag tag, Literal after) : base (parent, after) {
+ public Literal (Term parent, Tag tag, Literal after) : base (parent, after)
+ {
Tag = tag;
}
@@ -96,8 +100,7 @@ namespace FSpot
}
}
- private Pixbuf NegatedIcon
- {
+ private Pixbuf NegatedIcon {
get {
if (negated_icon != null)
return negated_icon;
@@ -136,7 +139,7 @@ namespace FSpot
container.CanFocus = true;
- container.KeyPressEvent += KeyHandler;
+ container.KeyPressEvent += KeyHandler;
container.ButtonPressEvent += HandleButtonPress;
container.ButtonReleaseEvent += HandleButtonRelease;
container.EnterNotifyEvent += HandleMouseIn;
@@ -158,18 +161,17 @@ namespace FSpot
container.DragLeave += HandleDragLeave;
Gtk.Drag.DestSet (container, DestDefaults.All, tag_dest_target_table,
- DragAction.Copy | DragAction.Move );
+ DragAction.Copy | DragAction.Move);
container.TooltipText = Tag.Name;
label.Show ();
image.Show ();
- if (Tag.Icon == null) {
+ if (Tag.Icon == null)
handle_box.Add (label);
- } else {
+else
handle_box.Add (image);
- }
handle_box.Show ();
@@ -184,8 +186,7 @@ namespace FSpot
}
}
- private Pixbuf NormalIcon
- {
+ private Pixbuf NormalIcon {
get {
if (normal_icon != null)
return normal_icon;
@@ -193,8 +194,9 @@ namespace FSpot
Pixbuf scaled = null;
scaled = Tag.Icon;
- for (Category category = Tag.Category; category != null && scaled == null; category = category.Category)
+ for (Category category = Tag.Category; category != null && scaled == null; category = category.Category) {
scaled = category.Icon;
+ }
if (scaled == null)
return null;
@@ -241,7 +243,7 @@ namespace FSpot
}
- if (isHoveredOver && image.Pixbuf != null ) {
+ if (isHoveredOver && image.Pixbuf != null) {
// Brighten the image slightly
Pixbuf brightened = image.Pixbuf.Copy ();
image.Pixbuf.SaturateAndPixelate (brightened, 1.85f, false);
@@ -271,8 +273,9 @@ namespace FSpot
List<Tag> tags = new List<Tag> ();
(Tag as Category).AddDescendentsTo (tags);
- for (int i = 0; i < tags.Count; i++)
+ for (int i = 0; i < tags.Count; i++) {
ids.Append (", " + (tags [i] as Tag).Id.ToString ());
+ }
}
return String.Format (
@@ -285,8 +288,7 @@ namespace FSpot
return new Label ("ERR");
}
- private static Pixbuf NegatedOverlay
- {
+ private static Pixbuf NegatedOverlay {
get {
if (negated_overlay == null) {
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetCallingAssembly ();
@@ -301,8 +303,9 @@ namespace FSpot
public static void RemoveFocusedLiterals ()
{
if (focusedLiterals != null)
- foreach (Literal literal in focusedLiterals)
+ foreach (Literal literal in focusedLiterals) {
literal.RemoveSelf ();
+ }
}
#endregion
@@ -312,10 +315,10 @@ namespace FSpot
args.RetVal = false;
switch (args.Event.Key) {
- case Gdk.Key.Delete:
- RemoveFocusedLiterals ();
- args.RetVal = true;
- return;
+ case Gdk.Key.Delete:
+ RemoveFocusedLiterals ();
+ args.RetVal = true;
+ return;
}
}
@@ -324,33 +327,31 @@ namespace FSpot
args.RetVal = true;
switch (args.Event.Type) {
- case EventType.TwoButtonPress:
- if (args.Event.Button == 1)
- IsNegated = !IsNegated;
- else
- args.RetVal = false;
- return;
+ case EventType.TwoButtonPress:
+ if (args.Event.Button == 1)
+ IsNegated = !IsNegated;
+ else
+ args.RetVal = false;
+ return;
- case EventType.ButtonPress:
- Widget.GrabFocus ();
+ case EventType.ButtonPress:
+ Widget.GrabFocus ();
- if (args.Event.Button == 1) {
- // TODO allow multiple selection of literals so they can be deleted, modified all at once
- //if ((args.Event.State & ModifierType.ControlMask) != 0) {
- //}
+ if (args.Event.Button == 1) {
+ // TODO allow multiple selection of literals so they can be deleted, modified all at once
+ //if ((args.Event.State & ModifierType.ControlMask) != 0) {
+ //}
- }
- else if (args.Event.Button == 3)
- {
- LiteralPopup popup = new LiteralPopup ();
- popup.Activate (args.Event, this);
- }
+ } else if (args.Event.Button == 3) {
+ LiteralPopup popup = new LiteralPopup ();
+ popup.Activate (args.Event, this);
+ }
- return;
+ return;
- default:
- args.RetVal = false;
- return;
+ default:
+ args.RetVal = false;
+ return;
}
}
@@ -359,18 +360,18 @@ namespace FSpot
args.RetVal = true;
switch (args.Event.Type) {
- case EventType.TwoButtonPress:
- args.RetVal = false;
- return;
+ case EventType.TwoButtonPress:
+ args.RetVal = false;
+ return;
- case EventType.ButtonPress:
- if (args.Event.Button == 1) {
- }
- return;
+ case EventType.ButtonPress:
+ if (args.Event.Button == 1) {
+ }
+ return;
- default:
- args.RetVal = false;
- return;
+ default:
+ args.RetVal = false;
+ return;
}
}
@@ -396,7 +397,7 @@ namespace FSpot
Byte [] data = Encoding.UTF8.GetBytes (String.Empty);
Atom [] targets = args.Context.Targets;
- args.SelectionData.Set (targets[0], 8, data, data.Length);
+ args.SelectionData.Set (targets [0], 8, data, data.Length);
return;
}
@@ -404,8 +405,9 @@ namespace FSpot
// Drop cancelled
args.RetVal = false;
- foreach (Widget w in hiddenWidgets)
+ foreach (Widget w in hiddenWidgets) {
w.Visible = true;
+ }
focusedLiterals = null;
}
@@ -449,9 +451,9 @@ namespace FSpot
if (args.Info == DragDropTargets.TagQueryEntry.Info) {
- if (! focusedLiterals.Contains(this))
- if (LiteralsMoved != null)
- LiteralsMoved (focusedLiterals, Parent, this);
+ if (! focusedLiterals.Contains (this))
+ if (LiteralsMoved != null)
+ LiteralsMoved (focusedLiterals, Parent, this);
// Unmark the literals as focused so they don't get nixed
focusedLiterals = null;
@@ -460,6 +462,7 @@ namespace FSpot
private bool preview = false;
private Gtk.Widget preview_widget;
+
private void HandleDragMotion (object o, DragMotionArgs args)
{
if (!preview) {
@@ -507,18 +510,14 @@ namespace FSpot
}
private const int ICON_SIZE = 24;
-
- private const int overlay_size = (int) (.40 * ICON_SIZE);
-
- private static TargetEntry [] tag_target_table =
+ private const int overlay_size = (int)(.40 * ICON_SIZE);
+ private static TargetEntry[] tag_target_table =
new TargetEntry [] { DragDropTargets.TagQueryEntry };
-
- private static TargetEntry [] tag_dest_target_table =
+ private static TargetEntry[] tag_dest_target_table =
new TargetEntry [] {
DragDropTargets.TagListEntry,
DragDropTargets.TagQueryEntry
};
-
private static List<Literal> focusedLiterals = new List<Literal> ();
private static List<Widget> hiddenWidgets = new List<Widget> ();
private Gtk.Container container;
@@ -526,7 +525,6 @@ namespace FSpot
private Gtk.Box box;
private Gtk.Image image;
private Gtk.Label label;
-
private Pixbuf normal_icon;
//private EventBox widget;
private Widget widget;
@@ -535,32 +533,41 @@ namespace FSpot
private bool isHoveredOver = false;
public delegate void NegatedToggleHandler (Literal group);
+
public event NegatedToggleHandler NegatedToggled;
public delegate void RemovingHandler (Literal group);
+
public event RemovingHandler Removing;
public delegate void RemovedHandler (Literal group);
+
public event RemovedHandler Removed;
- public delegate void TagsAddedHandler (Tag[] tags, Term parent, Literal after);
+ public delegate void TagsAddedHandler (Tag[] tags,Term parent,Literal after);
+
public event TagsAddedHandler TagsAdded;
- public delegate void AttachTagHandler (Tag tag, Term parent, Literal after);
+ public delegate void AttachTagHandler (Tag tag,Term parent,Literal after);
+
public event AttachTagHandler AttachTag;
- public delegate void TagRequiredHandler (Tag [] tags);
+ public delegate void TagRequiredHandler (Tag[] tags);
+
public event TagRequiredHandler RequireTag;
- public delegate void TagUnRequiredHandler (Tag [] tags);
+ public delegate void TagUnRequiredHandler (Tag[] tags);
+
public event TagUnRequiredHandler UnRequireTag;
- public delegate void LiteralsMovedHandler (List<Literal> literals, Term parent, Literal after);
+ public delegate void LiteralsMovedHandler (List<Literal> literals,Term parent,Literal after);
+
public event LiteralsMovedHandler LiteralsMoved;
#endregion
}
- public class TextLiteral : AbstractLiteral {
+ public class TextLiteral : AbstractLiteral
+ {
private string text;
public TextLiteral (Term parent, string text) : base (parent, null)
@@ -572,13 +579,13 @@ namespace FSpot
{
return String.Format (
"id {0}IN (SELECT id FROM photos WHERE base_uri LIKE '%{1}%' OR filename LIKE '%{1}%' OR description LIKE '%{1}%')",
- (IsNegated ? "NOT " : ""), EscapeQuotes(text)
+ (IsNegated ? "NOT " : ""), EscapeQuotes (text)
);
}
protected static string EscapeQuotes (string v)
{
- return v == null ? String.Empty : v.Replace("'", "''");
+ return v == null ? String.Empty : v.Replace ("'", "''");
}
}
}
diff --git a/src/Clients/MainApp/FSpot/Term.cs b/src/Clients/MainApp/FSpot/Term.cs
index 4f69113..da2e89a 100644
--- a/src/Clients/MainApp/FSpot/Term.cs
+++ b/src/Clients/MainApp/FSpot/Term.cs
@@ -56,13 +56,12 @@ namespace FSpot
this.parent = parent;
SubTerms = new List<Term> ();
- if (parent != null) {
+ if (parent != null)
if (after == null) {
parent.Add (this);
} else {
parent.SubTerms.Insert (parent.SubTerms.IndexOf (after) + 1, this);
}
- }
}
#region Properties
@@ -82,11 +81,10 @@ namespace FSpot
/// </value>
public Term Last {
get {
- if (SubTerms.Count > 0) {
+ if (SubTerms.Count > 0)
return SubTerms [SubTerms.Count - 1];
- } else {
+else
return null;
- }
}
}
@@ -99,14 +97,12 @@ namespace FSpot
public Term Parent {
get { return parent; }
set {
- if (parent == value) {
+ if (parent == value)
return;
- }
// If our parent was already set, remove ourself from it
- if (parent != null) {
+ if (parent != null)
parent.Remove (this);
- }
// Add ourself to our new parent
parent = value;
@@ -117,9 +113,8 @@ namespace FSpot
public virtual bool IsNegated {
get { return is_negated; }
set {
- if (is_negated != value) {
+ if (is_negated != value)
Invert (false);
- }
is_negated = value;
}
@@ -137,9 +132,8 @@ namespace FSpot
SubTerms.Remove (term);
// Remove ourselves if we're now empty
- if (SubTerms.Count == 0 && Parent != null) {
+ if (SubTerms.Count == 0 && Parent != null)
Parent.Remove (this);
- }
}
public void CopyAndInvertSubTermsFrom (Term term, bool recurse)
@@ -148,11 +142,10 @@ namespace FSpot
List<Term> termsToMove = new List<Term> (term.SubTerms);
foreach (Term subterm in termsToMove) {
- if (recurse) {
+ if (recurse)
subterm.Invert (true).Parent = this;
- } else {
+else
subterm.Parent = this;
- }
}
}
@@ -165,15 +158,14 @@ namespace FSpot
{
List<Term> results = new List<Term> ();
- if (tag != null && tag == t) {
+ if (tag != null && tag == t)
results.Add (this);
- }
- if (recursive) {
+ if (recursive)
foreach (Term term in SubTerms) {
results.AddRange (term.FindByTag (t, true));
}
- } else {
+else
foreach (Term term in SubTerms) {
foreach (Term literal in SubTerms) {
if (literal.tag != null && literal.tag == t) {
@@ -185,7 +177,6 @@ namespace FSpot
results.Add (term);
}
}
- }
return results;
}
@@ -196,16 +187,14 @@ namespace FSpot
bool meme = false;
foreach (Term term in SubTerms) {
- if (term is Literal) {
+ if (term is Literal)
meme = true;
- }
results.AddRange (term.LiteralParents ());
}
- if (meme) {
+ if (meme)
results.Add (this);
- }
return results;
}
@@ -214,27 +203,24 @@ namespace FSpot
{
List<Term> parents = LiteralParents ();
- if (parents.Count == 0) {
+ if (parents.Count == 0)
return false;
- }
foreach (Term term in parents) {
bool termHasTag = false;
bool onlyTerm = true;
foreach (Term literal in term.SubTerms) {
- if (literal.tag != null) {
+ if (literal.tag != null)
if (literal.tag == t) {
termHasTag = true;
} else {
onlyTerm = false;
}
- }
}
- if (termHasTag && onlyTerm) {
+ if (termHasTag && onlyTerm)
return true;
- }
}
return false;
@@ -254,16 +240,15 @@ namespace FSpot
grouped_with = 100;
int min_grouped_with = 100;
- if (parents.Count == 0) {
+ if (parents.Count == 0)
return false;
- }
foreach (Term term in parents) {
bool termHasTag = false;
// Don't count it as required if it's the only subterm..though it is..
// it is more clearly identified as Included at that point.
- if (term.Count > 1) {
+ if (term.Count > 1)
foreach (Term literal in term.SubTerms) {
if (literal.tag != null) {
if (literal.tag == t) {
@@ -274,15 +259,12 @@ namespace FSpot
}
}
}
- }
- if (grouped_with < min_grouped_with) {
+ if (grouped_with < min_grouped_with)
min_grouped_with = grouped_with;
- }
- if (!termHasTag) {
+ if (!termHasTag)
return false;
- }
}
grouped_with = min_grouped_with;
@@ -306,9 +288,8 @@ namespace FSpot
Term term = SubTerms [i] as Term;
condition.Append (term.SqlCondition ());
- if (i != SubTerms.Count - 1) {
+ if (i != SubTerms.Count - 1)
condition.Append (SQLOperator ());
- }
}
condition.Append (")");
@@ -334,13 +315,12 @@ namespace FSpot
//op = op.Trim ();
op = op.ToLower ();
- if (AndTerm.Operators.Contains (op)) {
+ if (AndTerm.Operators.Contains (op))
//Console.WriteLine ("AND!");
return new AndTerm (parent, after);
- } else if (OrTerm.Operators.Contains (op)) {
+else if (OrTerm.Operators.Contains (op))
//Console.WriteLine ("OR!");
return new OrTerm (parent, after);
- }
Log.DebugFormat ("Do not have Term for operator {0}", op);
return null;
@@ -368,9 +348,8 @@ namespace FSpot
{
OrTerm newme = new OrTerm (Parent, null);
newme.CopyAndInvertSubTermsFrom (this, recurse);
- if (Parent != null) {
+ if (Parent != null)
Parent.Remove (this);
- }
return newme;
}
@@ -389,13 +368,12 @@ namespace FSpot
condition.Append (base.SqlCondition ());
Tag hidden = App.Instance.Database.Tags.Hidden;
- if (hidden != null) {
+ if (hidden != null)
if (FindByTag (hidden, true).Count == 0) {
condition.Append (String.Format (
" AND id NOT IN (SELECT photo_id FROM photo_tags WHERE tag_id = {0})", hidden.Id
));
}
- }
condition.Append (")");
@@ -425,9 +403,8 @@ namespace FSpot
public static OrTerm FromTags (Tag [] from_tags)
{
- if (from_tags == null || from_tags.Length == 0) {
+ if (from_tags == null || from_tags.Length == 0)
return null;
- }
OrTerm or = new OrTerm (null, null);
foreach (Tag t in from_tags) {
@@ -443,9 +420,8 @@ namespace FSpot
{
AndTerm newme = new AndTerm (Parent, null);
newme.CopyAndInvertSubTermsFrom (this, recurse);
- if (Parent != null) {
+ if (Parent != null)
Parent.Remove (this);
- }
return newme;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]