f-spot r3563 - in trunk: . src



Author: sdelcroix
Date: Thu Jan 17 13:22:19 2008
New Revision: 3563
URL: http://svn.gnome.org/viewvc/f-spot?rev=3563&view=rev

Log:
2008-01-17  Stephane Delcroix  <sdelcroix novell com>

	* src/Category.cs:
	* src/Tag.cs: moved from TagStore.cs in their own files and
	in the FSpot namespace.

	* src/TagStore.cs:
	* src/FotkiRemote.cs:
	* src/TagCommands.cs:
	* src/Makefile.am:
	* src/ImportCommand.cs:
	* src/FlickrRemote.cs:
	* src/PhotoTagMenu.cs:
	* src/TagSelectionWidget.cs:
	* src/TagPopup.cs:
	* src/TagMenu.cs: required namespace adaptations


Added:
   trunk/src/Category.cs
   trunk/src/Tag.cs
Modified:
   trunk/ChangeLog
   trunk/src/FlickrRemote.cs
   trunk/src/FotkiRemote.cs
   trunk/src/ImportCommand.cs
   trunk/src/Makefile.am
   trunk/src/PhotoTagMenu.cs
   trunk/src/TagCommands.cs
   trunk/src/TagMenu.cs
   trunk/src/TagPopup.cs
   trunk/src/TagSelectionWidget.cs
   trunk/src/TagStore.cs

Added: trunk/src/Category.cs
==============================================================================
--- (empty file)
+++ trunk/src/Category.cs	Thu Jan 17 13:22:19 2008
@@ -0,0 +1,64 @@
+/*
+ * FSpot.Tag
+ * 
+ * Author(s):
+ *	Larry Ewing  <lewing novell com>
+ *	Stephane Delcroix  <stephane delcroix org>
+ *
+ * This is free software. See COPYING for details.
+ */
+
+using System.Collections;
+
+namespace FSpot
+{
+	public class Category : Tag {
+		ArrayList children;
+		bool children_need_sort;
+		public Tag [] Children {
+			get {
+				if (children_need_sort)
+					children.Sort ();
+				return (Tag []) children.ToArray (typeof (Tag));
+			}
+			set {
+				children = new ArrayList (value);
+				children_need_sort = true;
+			}
+		}
+	
+		// Appends all of this categories descendents to the list
+		public void AddDescendentsTo (ArrayList list)
+		{
+			foreach (Tag tag in children) {
+				if (! list.Contains (tag))
+					list.Add (tag);
+	
+				if (! (tag is Category))
+					continue;
+	
+				Category cat = tag as Category;
+	
+				cat.AddDescendentsTo (list);
+			}
+		}
+	
+		public void AddChild (Tag child)
+		{
+			children.Add (child);
+			children_need_sort = true;
+		}
+	
+		public void RemoveChild (Tag child)
+		{
+			children.Remove (child);
+			children_need_sort = true;
+		}
+	
+		public Category (Category category, uint id, string name)
+			: base (category, id, name)
+		{
+			children = new ArrayList ();
+		}
+	}
+}

Modified: trunk/src/FlickrRemote.cs
==============================================================================
--- trunk/src/FlickrRemote.cs	(original)
+++ trunk/src/FlickrRemote.cs	Thu Jan 17 13:22:19 2008
@@ -141,7 +141,7 @@
 				
 				if (ExportTags && photo.Tags != null) {
 					StringBuilder taglist = new StringBuilder ();
-					Tag [] t = photo.Tags;
+					FSpot.Tag [] t = photo.Tags;
 					
 					for (int i = 0; i < t.Length; i++) {
 						if (i > 0)

Modified: trunk/src/FotkiRemote.cs
==============================================================================
--- trunk/src/FotkiRemote.cs	(original)
+++ trunk/src/FotkiRemote.cs	Thu Jan 17 13:22:19 2008
@@ -8,6 +8,7 @@
 using System.Collections;
 using System.Collections.Specialized;
 using System.Net;
+using FSpot;
 
 public class FotkiRemote {
 	// This is the up

Modified: trunk/src/ImportCommand.cs
==============================================================================
--- trunk/src/ImportCommand.cs	(original)
+++ trunk/src/ImportCommand.cs	Thu Jan 17 13:22:19 2008
@@ -21,6 +21,7 @@
 using System;
 using Mono.Unix;
 using FSpot.Widgets;
+using FSpot;
 
 public class ImportCommand : FSpot.GladeDialog
 {

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Thu Jan 17 13:22:19 2008
@@ -53,6 +53,7 @@
 	$(srcdir)/BlockProcessor.cs		\
 	$(srcdir)/BitConverter.cs		\
 	$(srcdir)/PhotoArray.cs 		\
+	$(srcdir)/Category.cs			\
 	$(srcdir)/CDExport.cs			\
 	$(srcdir)/ColorDialog.cs		\
 	$(srcdir)/ColorAdjustment.cs		\
@@ -192,6 +193,7 @@
 	$(srcdir)/SingleView.cs			\
 	$(srcdir)/SimpleCalendar.cs		\
 	$(srcdir)/SmugMugExport.cs		\
+	$(srcdir)/Tag.cs			\
 	$(srcdir)/TagCommands.cs		\
 	$(srcdir)/TagMenu.cs			\
 	$(srcdir)/TagPopup.cs			\

Modified: trunk/src/PhotoTagMenu.cs
==============================================================================
--- trunk/src/PhotoTagMenu.cs	(original)
+++ trunk/src/PhotoTagMenu.cs	Thu Jan 17 13:22:19 2008
@@ -28,6 +28,8 @@
 using System.Collections;
 using Gtk;
 
+using FSpot;
+
 public class PhotoTagMenu : Menu {
 	public delegate void TagSelectedHandler (Tag t);
 	public event TagSelectedHandler TagSelected;

Added: trunk/src/Tag.cs
==============================================================================
--- (empty file)
+++ trunk/src/Tag.cs	Thu Jan 17 13:22:19 2008
@@ -0,0 +1,156 @@
+/*
+ * FSpot.Tag
+ * 
+ * Author(s):
+ *	Larry Ewing  <lewing novell com>
+ *	Stephane Delcroix  <stephane delcroix org>
+ *
+ * This is free software. See COPYING for details.
+ */
+
+using System;
+
+using Gdk;
+
+namespace FSpot
+{
+	public class Tag : DbItem, IComparable {
+		private string name;
+		public string Name {
+			set {
+				name = value;
+			}
+			get {
+				return name;
+			}
+		}
+	
+		private Category category;
+		public Category Category {
+			set {
+				if (Category != null)
+					Category.RemoveChild (this);
+	
+				category = value;
+				if (category != null)
+					category.AddChild (this);
+			}
+			get {
+				return category;
+			}
+		}
+	
+		private int sort_priority;
+		public int SortPriority {
+			set {
+				sort_priority = value;
+			}
+			get {
+				return sort_priority;
+			}
+		}
+	
+		// Icon.  If theme_icon_name is not null, then we save the name of the icon instead
+		// of the actual icon data.
+	
+		private string theme_icon_name;
+		public string ThemeIconName {
+			set {
+				theme_icon_name = value;
+				cached_icon_size = IconSize.Hidden;
+				icon = GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, theme_icon_name, 48, (Gtk.IconLookupFlags)0);
+			}
+			get { return theme_icon_name; }
+		}
+	
+		private Pixbuf icon;
+		public Pixbuf Icon {
+			set {
+				theme_icon_name = null;
+				if (icon != null)
+					icon.Dispose ();
+				icon = value;
+				cached_icon_size = IconSize.Hidden;
+			}
+			get { return icon; }
+		}
+	
+		public enum IconSize {
+			Hidden = 0,
+			Small = 16,
+			Medium = 24,
+			Large = 48
+		};
+	
+		private static IconSize tag_icon_size = IconSize.Large;
+		public static IconSize TagIconSize {
+			get { return tag_icon_size; }
+			set { tag_icon_size = value; }
+		}
+	
+		private Pixbuf cached_icon;
+		private IconSize cached_icon_size = IconSize.Hidden;
+	
+		// We can use a SizedIcon everywhere we were using an Icon
+		public Pixbuf SizedIcon {
+			get {
+				if (tag_icon_size == IconSize.Hidden) //Hidden
+					return null;
+				if (tag_icon_size == cached_icon_size)
+					return cached_icon;
+				if (theme_icon_name != null) { //Theme icon
+					if (cached_icon != null)
+						cached_icon.Dispose ();
+					cached_icon = GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, theme_icon_name, (int) tag_icon_size, (Gtk.IconLookupFlags)0);
+	
+					if (Math.Max (cached_icon.Width, cached_icon.Height) <= (int) tag_icon_size) 
+						return cached_icon;
+				}
+				if (Math.Max (icon.Width, icon.Height) >= (int) tag_icon_size) { //Don't upscale
+					if (cached_icon != null)
+						cached_icon.Dispose ();
+					cached_icon = icon.ScaleSimple ((int) tag_icon_size, (int) tag_icon_size, InterpType.Bilinear);
+					cached_icon_size = tag_icon_size;
+					return cached_icon;
+				}
+				else
+					return icon;
+			}	
+		}
+	
+	
+		// You are not supposed to invoke these constructors outside of the TagStore class.
+		public Tag (Category category, uint id, string name)
+			: base (id)
+		{
+			Category = category;
+			Name = name;
+		}
+	
+	
+		// IComparer.
+		public int CompareTo (object obj)
+		{
+			Tag tag = obj as Tag;
+	
+			if (Category == tag.Category) {
+				if (SortPriority == tag.SortPriority)
+					return Name.CompareTo (tag.Name);
+				else
+					return SortPriority - tag.SortPriority;
+			} else {
+				return Category.CompareTo (tag.Category);
+			}
+		}
+		
+		public bool IsAncestorOf (Tag tag)
+		{
+			for (Category parent = tag.Category; parent != null; parent = parent.Category) {
+				if (parent == this)
+					return true;
+			}
+	
+			return false;
+		}
+	}
+}

Modified: trunk/src/TagCommands.cs
==============================================================================
--- trunk/src/TagCommands.cs	(original)
+++ trunk/src/TagCommands.cs	Thu Jan 17 13:22:19 2008
@@ -15,6 +15,7 @@
 using System.Collections;
 
 using Mono.Unix;
+using FSpot;
 
 public class TagCommands {
 

Modified: trunk/src/TagMenu.cs
==============================================================================
--- trunk/src/TagMenu.cs	(original)
+++ trunk/src/TagMenu.cs	Thu Jan 17 13:22:19 2008
@@ -1,5 +1,6 @@
 using Gtk;
 using System;
+using FSpot;
 
 public class TagMenu : Menu {
 	private TagStore tag_store;

Modified: trunk/src/TagPopup.cs
==============================================================================
--- trunk/src/TagPopup.cs	(original)
+++ trunk/src/TagPopup.cs	Thu Jan 17 13:22:19 2008
@@ -11,6 +11,7 @@
 
 using System;
 using Mono.Unix;
+using FSpot;
 
 public class TagPopup {
 	public void Activate (Gdk.EventButton eb, Tag tag, Tag [] tags)

Modified: trunk/src/TagSelectionWidget.cs
==============================================================================
--- trunk/src/TagSelectionWidget.cs	(original)
+++ trunk/src/TagSelectionWidget.cs	Thu Jan 17 13:22:19 2008
@@ -33,6 +33,7 @@
 using System;
 
 using Mono.Unix;
+using FSpot;
 
 public class TagSelectionWidget : FSpot.Widgets.SaneTreeView {
 	TagSelectionWidget widget;

Modified: trunk/src/TagStore.cs
==============================================================================
--- trunk/src/TagStore.cs	(original)
+++ trunk/src/TagStore.cs	Thu Jan 17 13:22:19 2008
@@ -47,199 +47,6 @@
 	}
 }
 
-
-public class Tag : DbItem, IComparable {
-	private string name;
-	public string Name {
-		set {
-			name = value;
-		}
-		get {
-			return name;
-		}
-	}
-
-	private Category category;
-	public Category Category {
-		set {
-			if (Category != null)
-				Category.RemoveChild (this);
-
-			category = value;
-			if (category != null)
-				category.AddChild (this);
-		}
-		get {
-			return category;
-		}
-	}
-
-	private int sort_priority;
-	public int SortPriority {
-		set {
-			sort_priority = value;
-		}
-		get {
-			return sort_priority;
-		}
-	}
-
-	// Icon.  If theme_icon_name is not null, then we save the name of the icon instead
-	// of the actual icon data.
-
-	private string theme_icon_name;
-	public string ThemeIconName {
-		set {
-			theme_icon_name = value;
-			cached_icon_size = IconSize.Hidden;
-			icon = GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, theme_icon_name, 48, (Gtk.IconLookupFlags)0);
-		}
-		get { return theme_icon_name; }
-	}
-
-	private Pixbuf icon;
-	public Pixbuf Icon {
-		set {
-			theme_icon_name = null;
-			if (icon != null)
-				icon.Dispose ();
-			icon = value;
-			cached_icon_size = IconSize.Hidden;
-		}
-		get { return icon; }
-	}
-
-	public enum IconSize {
-		Hidden = 0,
-		Small = 16,
-		Medium = 24,
-		Large = 48
-	};
-
-	private static IconSize tag_icon_size = IconSize.Large;
-	public static IconSize TagIconSize {
-		get { return tag_icon_size; }
-		set { tag_icon_size = value; }
-	}
-
-	private Pixbuf cached_icon;
-	private IconSize cached_icon_size = IconSize.Hidden;
-
-	// We can use a SizedIcon everywhere we were using an Icon
-	public Pixbuf SizedIcon {
-		get {
-			if (tag_icon_size == IconSize.Hidden) //Hidden
-				return null;
-			if (tag_icon_size == cached_icon_size)
-				return cached_icon;
-			if (theme_icon_name != null) { //Theme icon
-				if (cached_icon != null)
-					cached_icon.Dispose ();
-				cached_icon = GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, theme_icon_name, (int) tag_icon_size, (Gtk.IconLookupFlags)0);
-
-				if (Math.Max (cached_icon.Width, cached_icon.Height) <= (int) tag_icon_size) 
-					return cached_icon;
-			}
-			if (Math.Max (icon.Width, icon.Height) >= (int) tag_icon_size) { //Don't upscale
-				if (cached_icon != null)
-					cached_icon.Dispose ();
-				cached_icon = icon.ScaleSimple ((int) tag_icon_size, (int) tag_icon_size, InterpType.Bilinear);
-				cached_icon_size = tag_icon_size;
-				return cached_icon;
-			}
-			else
-				return icon;
-		}	
-	}
-
-
-	// You are not supposed to invoke these constructors outside of the TagStore class.
-	public Tag (Category category, uint id, string name)
-		: base (id)
-	{
-		Category = category;
-		Name = name;
-	}
-
-
-	// IComparer.
-	public int CompareTo (object obj)
-	{
-		Tag tag = obj as Tag;
-
-		if (Category == tag.Category) {
-			if (SortPriority == tag.SortPriority)
-				return Name.CompareTo (tag.Name);
-			else
-				return SortPriority - tag.SortPriority;
-		} else {
-			return Category.CompareTo (tag.Category);
-		}
-	}
-	
-	public bool IsAncestorOf (Tag tag)
-	{
-		for (Category parent = tag.Category; parent != null; parent = parent.Category) {
-			if (parent == this)
-				return true;
-		}
-
-		return false;
-	}
-}
-
-
-// A Category is a Tag which has contains sub-Tags (we use the same terminology as Photoshop Album).
-public class Category : Tag {
-	ArrayList children;
-	bool children_need_sort;
-	public Tag [] Children {
-		get {
-			if (children_need_sort)
-				children.Sort ();
-			return (Tag []) children.ToArray (typeof (Tag));
-		}
-		set {
-			children = new ArrayList (value);
-			children_need_sort = true;
-		}
-	}
-
-	// Appends all of this categories descendents to the list
-	public void AddDescendentsTo (ArrayList list)
-	{
-		foreach (Tag tag in children) {
-			if (! list.Contains (tag))
-				list.Add (tag);
-
-			if (! (tag is Category))
-				continue;
-
-			Category cat = tag as Category;
-
-			cat.AddDescendentsTo (list);
-		}
-	}
-
-	public void AddChild (Tag child)
-	{
-		children.Add (child);
-		children_need_sort = true;
-	}
-
-	public void RemoveChild (Tag child)
-	{
-		children.Remove (child);
-		children_need_sort = true;
-	}
-
-	public Category (Category category, uint id, string name)
-		: base (category, id, name)
-	{
-		children = new ArrayList ();
-	}
-}
-
 public class InvalidTagOperationException : InvalidOperationException {
 	public Tag tag;
 	



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