1
/* Copyright 2016 Software Freedom Conservancy Inc.
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.
7
public class ConversationListCellRenderer : Gtk.CellRenderer {
8
private static FormattedConversationData? example_data = null;
9
private static bool hover_selected = false;
12
public FormattedConversationData data { get; set; }
14
public ConversationListCellRenderer() {
17
~ConversationListCellRenderer() {
21
public override void get_preferred_height(Gtk.Widget widget,
23
out int natural_size) {
24
if (example_data == null)
25
style_changed(widget);
27
minimum_size = natural_size = example_data.get_height();
30
public override void get_preferred_width(Gtk.Widget widget,
32
out int natural_size) {
33
// Set width to 1 (rather than 0) to work around certain
34
// themes that cause the conversation list to be shown as
36
// https://bugzilla.gnome.org/show_bug.cgi?id=713954
37
minimum_size = natural_size = 1;
40
public override void render(Cairo.Context ctx, Gtk.Widget widget, Gdk.Rectangle background_area,
41
Gdk.Rectangle cell_area, Gtk.CellRendererState flags) {
43
data.render(ctx, widget, background_area, cell_area, flags, hover_selected);
46
// Recalculates size when the style changed.
47
// Note: this must be called by the parent TreeView.
48
public static void style_changed(Gtk.Widget widget) {
49
if (example_data == null) {
50
example_data = new FormattedConversationData.create_example();
53
example_data.calculate_sizes(widget);
56
// Shows hover effect on all selected cells.
57
public static void set_hover_selected(bool hover) {
58
hover_selected = hover;
61
// This is implemented because it's required; ignore it and look at get_preferred_height() instead.
62
public override void get_size(Gtk.Widget widget, Gdk.Rectangle? cell_area, out int x_offset,
63
out int y_offset, out int width, out int height) {
64
// Set values to avoid compiler warning.