1/* Copyright 2016 Software Freedom Conservancy Inc. 2 * 3 * This software is licensed under the GNU Lesser General Public License 4 * (version 2.1 or later). See the COPYING file in this distribution. 5 */ 6 7// A simple grouping Entry that is only expandable 8public class Sidebar.Grouping : Geary.BaseObject, Sidebar.Entry, Sidebar.ExpandableEntry, 9 Sidebar.RenameableEntry { 10 11 private string name; 12 private string? tooltip; 13 private string? icon; 14 15 public Grouping(string name, string? icon, string? tooltip = null) { 16 this.name = name; 17 this.icon = icon; 18 this.tooltip = tooltip; 19 } 20 21 public void rename(string name) { 22 this.name = name; 23 entry_changed(); 24 } 25 26 public bool is_user_renameable() { 27 return false; 28 } 29 30 public string get_sidebar_name() { 31 return name; 32 } 33 34 public string? get_sidebar_tooltip() { 35 return tooltip; 36 } 37 38 public string? get_sidebar_icon() { 39 return icon; 40 } 41 42 public int get_count() { 43 return -1; 44 } 45 46 public string to_string() { 47 return name; 48 } 49 50 public bool expand_on_select() { 51 return true; 52 } 53} 54 55// A simple Sidebar.Branch where the root node is the branch in entirety. 56public class Sidebar.RootOnlyBranch : Sidebar.Branch { 57 public RootOnlyBranch(Sidebar.Entry root) { 58 base (root, Sidebar.Branch.Options.NONE, null_comparator); 59 } 60 61 private static int null_comparator(Sidebar.Entry a, Sidebar.Entry b) { 62 return (a != b) ? -1 : 0; 63 } 64} 65 66/** 67 * A header is an entry that is visually distinguished from its children. Bug 6397 recommends 68 * headers to appear bolded and without any icons. To prevent the icons from rendering, we set the 69 * icons to null in the base class @see Sidebar.Grouping. But we also go a step further by 70 * using a custom cell_data_function (@see Sidebar.Tree::icon_renderer_function) which ensures that 71 * header icons won't be rendered. This approach avoids the blank icon spacing issues. 72 */ 73public class Sidebar.Header : Sidebar.Grouping, Sidebar.EmphasizableEntry { 74 private bool emphasized; 75 76 public Header(string name, bool emphasized = true) { 77 base(name, null); 78 this.emphasized = emphasized; 79 } 80 81 public bool is_emphasized() { 82 return emphasized; 83 } 84} 85 86public interface Sidebar.Contextable : Object { 87 // Return null if the context menu should not be invoked for this event 88 public abstract Gtk.Menu? get_sidebar_context_menu(Gdk.EventButton event); 89} 90 91