summaryrefslogtreecommitdiff
path: root/src/sidebar/common.vala
diff options
context:
space:
mode:
Diffstat (limited to 'src/sidebar/common.vala')
-rw-r--r--src/sidebar/common.vala59
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);