diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-04-03 13:14:53 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-04-03 13:14:53 +0200 |
commit | c43dfb815a4951b8248f4f0e98babe4f80204f03 (patch) | |
tree | 82745ed2353757c41ea1865bad9ac7a1b0a8a366 /src/sidebar/common.vala | |
parent | 2785a691b958a79a1dd606c445188c71c3f58b3c (diff) |
Imported Upstream version 0.22.0upstream/0.22.0
Diffstat (limited to 'src/sidebar/common.vala')
-rw-r--r-- | src/sidebar/common.vala | 59 |
1 files changed, 41 insertions, 18 deletions
diff --git a/src/sidebar/common.vala b/src/sidebar/common.vala index 36adfff..0f1bc05 100644 --- a/src/sidebar/common.vala +++ b/src/sidebar/common.vala @@ -1,39 +1,42 @@ -/* Copyright 2011-2014 Yorba Foundation +/* Copyright 2011-2015 Yorba Foundation * * This software is licensed under the GNU Lesser General Public License * (version 2.1 or later). See the COPYING file in this distribution. */ // A simple grouping Entry that is only expandable -public class Sidebar.Grouping : Object, Sidebar.Entry, Sidebar.ExpandableEntry { +public class Sidebar.Grouping : Object, Sidebar.Entry, Sidebar.ExpandableEntry, + Sidebar.RenameableEntry { + private string name; - private Icon? open_icon; - private Icon? closed_icon; + private string? tooltip; + private string? icon; - public Grouping(string name, Icon? open_icon, Icon? closed_icon = null) { + public Grouping(string name, string? icon, string? tooltip = null) { this.name = name; - this.open_icon = open_icon; - this.closed_icon = closed_icon ?? open_icon; + this.icon = icon; + this.tooltip = tooltip; } - public string get_sidebar_name() { - return name; + public void rename(string name) { + this.name = name; + sidebar_name_changed(name); } - public string? get_sidebar_tooltip() { - return name; + public bool is_user_renameable() { + return false; } - public Icon? get_sidebar_icon() { - return null; + public string get_sidebar_name() { + return name; } - public Icon? get_sidebar_open_icon() { - return open_icon; + public string? get_sidebar_tooltip() { + return tooltip; } - public Icon? get_sidebar_closed_icon() { - return closed_icon; + public string? get_sidebar_icon() { + return icon; } public string to_string() { @@ -61,7 +64,7 @@ public abstract class Sidebar.SimplePageEntry : Object, Sidebar.Entry, Sidebar.S return get_sidebar_name(); } - public abstract Icon? get_sidebar_icon(); + public abstract string? get_sidebar_icon(); public virtual string to_string() { return get_sidebar_name(); @@ -107,6 +110,26 @@ public class Sidebar.RootOnlyBranch : Sidebar.Branch { } } +/** + * A header is an entry that is visually distinguished from its children. Bug 6397 recommends + * headers to appear bolded and without any icons. To prevent the icons from rendering, we set the + * icons to null in the base class @see Sidebar.Grouping. But we also go a step further by + * using a custom cell_data_function (@see Sidebar.Tree::icon_renderer_function) which ensures that + * header icons won't be rendered. This approach avoids the blank icon spacing issues. + */ +public class Sidebar.Header : Sidebar.Grouping, Sidebar.EmphasizableEntry { + private bool emphasized; + + public Header(string name, bool emphasized = true) { + base(name, null); + this.emphasized = emphasized; + } + + public bool is_emphasized() { + return emphasized; + } +} + public interface Sidebar.Contextable : Object { // Return null if the context menu should not be invoked for this event public abstract Gtk.Menu? get_sidebar_context_menu(Gdk.EventButton? event); |