public void Populate (Category cat, Gtk.Menu parent) { Widget [] dead_pool = parent.Children; for (int i = 0; i < dead_pool.Length; i++) dead_pool [i].Destroy (); foreach (Tag t in cat.Children) { TagMenuItem item = new TagMenuItem (t); parent.Append (item); item.ShowAll (); Category subcat = t as Category; if (subcat != null && subcat.Children.Count != 0) { Gtk.Menu submenu = new Menu (); Populate (t as Category, submenu); Gtk.SeparatorMenuItem sep = new Gtk.SeparatorMenuItem (); submenu.Prepend (sep); sep.ShowAll (); TagMenuItem subitem = new TagMenuItem (t); subitem.Activated += HandleActivate; submenu.Prepend (subitem); subitem.ShowAll (); item.Submenu = submenu; } else { item.Activated += HandleActivate; } } }
public void Populate (Photo [] photos) { Hashtable hash = new Hashtable (); if (photos != null) { foreach (Photo p in photos) { foreach (Tag t in p.Tags) { if (!hash.Contains (t.Id)) { hash.Add (t.Id, t); } } } } foreach (Widget w in this.Children) { w.Destroy (); } if (hash.Count == 0) { /* Fixme this should really set parent menu items insensitve */ MenuItem item = new MenuItem (Mono.Unix.Catalog.GetString ("(No Tags)")); this.Append (item); item.Sensitive = false; item.ShowAll (); return; } foreach (Tag t in hash.Values) { TagMenuItem item = new TagMenuItem (t); this.Append (item); item.ShowAll (); item.Activated += HandleActivate; } }
public void PopulateFlat (Category cat, Gtk.Menu parent) { foreach (Tag t in cat.Children) { TagMenuItem item = TagMenuItem.IndentedItem (t); parent.Append (item); item.ShowAll (); Category subcat = t as Category; if (subcat != null && subcat.Children.Count != 0) { PopulateFlat (t as Category, parent); } else { item.Activated += HandleActivate; } } }
public void Populate(Photo [] photos) { Hashtable hash = new Hashtable(); if (photos != null) { foreach (Photo p in photos) { foreach (Tag t in p.Tags) { if (!hash.Contains(t.Id)) { hash.Add(t.Id, t); } } } } foreach (Widget w in this.Children) { w.Destroy(); } if (hash.Count == 0) { /* Fixme this should really set parent menu * items insensitve */ MenuItem item = new MenuItem(Mono.Unix.Catalog.GetString("(No Tags)")); this.Append(item); item.Sensitive = false; item.ShowAll(); return; } foreach (Tag t in hash.Values) { TagMenuItem item = new TagMenuItem(t); this.Append(item); item.ShowAll(); item.Activated += HandleActivate; } }
public void Populate (Category cat, Gtk.Menu parent) { Widget [] dead_pool = parent.Children; for (int i = 0; i < dead_pool.Length; i++) dead_pool [i].Destroy (); foreach (Tag t in cat.Children) { TagMenuItem item = new TagMenuItem (t); parent.Append (item); item.ShowAll (); Category subcat = t as Category; if (subcat != null && subcat.Children.Length != 0) { Gtk.Menu submenu = new Menu (); Populate (t as Category, submenu); Gtk.SeparatorMenuItem sep = new Gtk.SeparatorMenuItem (); submenu.Prepend (sep); sep.ShowAll (); TagMenuItem subitem = new TagMenuItem (t); subitem.Activated += HandleActivate; submenu.Prepend (subitem); subitem.ShowAll (); item.Submenu = submenu; } else { item.Activated += HandleActivate; } } }