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; } }
void HandleActivate (object obj, EventArgs args) { if (TagSelected != null) { TagMenuItem t = obj as TagMenuItem; if (t != null) TagSelected (t.Value); else Log.Debug ("TagMenu.HandleActivate: Item was not a TagMenuItem"); } }
public void PopulateFlat(Category cat, Gtk.Menu parent) { foreach (var t in cat.Children) { var item = TagMenuItem.IndentedItem(t); parent.Append(item); item.ShowAll(); if (t is Category subcat && subcat.Children.Count != 0) { PopulateFlat(t as Category, parent); }
void HandleActivate(object obj, EventArgs args) { if (TagSelected != null) { TagMenuItem t = obj as TagMenuItem; if (t != null) { TagSelected(t.Value); } else { Console.WriteLine("Item was not a TagMenuItem"); } } }
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 int GetPosition (Tag t) { // FIXME right now this only works on flat menus int i = 0; foreach (Widget w in this.Children) { TagMenuItem item = w as TagMenuItem; if (item != null) { if (t == item.Value) return i; } i++; } return -1; }
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; } } }