Possible patch for bug 143171?
- From: Matt Jones <mattharrison sbcglobal net>
- To: f-spot-list gnome org
- Subject: Possible patch for bug 143171?
- Date: Wed, 07 Jul 2004 23:22:31 +0900
Hi -
I've attached a patch (against current anoncvs) that allows categories
to inherit icons from parent categories, which fixes the absence of
icons in photos that exist in sub-categories. I tried to stick to the
style that exists throughout TagStore.cs.
I'm not too sure if this applies to bug 143171 (which is why I'm not
posting this in bugzilla). I have some initial work on an interface to
modify the icons for categories/tags, but nothing that works well, so if
anyones been thinking about this problem and has some suggestions / cool
ideas, I'd love to hear them.
-- Matt Jones
Index: src/TagStore.cs
===================================================================
RCS file: /cvs/gnome/f-spot/src/TagStore.cs,v
retrieving revision 1.7
diff -u -r1.7 TagStore.cs
--- src/TagStore.cs 11 Feb 2004 07:27:33 -0000 1.7
+++ src/TagStore.cs 6 Jul 2004 14:12:54 -0000
@@ -48,6 +48,8 @@
public class Tag : DbItem, IComparable {
+ protected bool leaf_tag;
+
private string name;
public string Name {
set {
@@ -116,6 +118,7 @@
public Tag (Category category, uint id, string name)
: base (id)
{
+ leaf_tag = true;
Category = category;
Name = name;
}
@@ -135,6 +138,24 @@
return Category.CompareTo (tag.Category);
}
}
+
+ public string InheritIcon (Category root)
+ {
+ if (leaf_tag == true) {
+ if (icon != null)
+ return Convert.ToBase64String (PixbufSerializer.Serialize (icon));
+ return stock_icon_name;
+ }
+
+ if ((stock_icon_name == "" || icon == null) && category != root && category != null && category.Name != "root")
+ return category.InheritIcon (root);
+ else if (this == root)
+ return "";
+ else if (icon != null)
+ return Convert.ToBase64String (PixbufSerializer.Serialize (icon));
+ else
+ return stock_icon_name;
+ }
}
@@ -169,6 +190,7 @@
public Category (Category category, uint id, string name)
: base (category, id, name)
{
+ leaf_tag = false;
children = new ArrayList ();
}
}
@@ -188,6 +210,9 @@
private void SetIconFromString (Tag tag, string icon_string)
{
if (icon_string == null || icon_string == "")
+ icon_string = tag.InheritIcon (RootCategory);
+
+ if (icon_string == null || icon_string == "")
tag.Icon = null;
else if (icon_string.StartsWith (STOCK_ICON_DB_PREFIX))
tag.StockIconName = icon_string.Substring (STOCK_ICON_DB_PREFIX.Length);
@@ -249,6 +274,9 @@
Console.WriteLine ("Tag Without category found");
}
+ // Inherit icon (if category)
+ if (tag.Icon == null)
+ SetIconFromString (tag, null);
}
reader.Close ();
command.Dispose ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]