4
namespace Lsc.Widgets {
5
public class CategoryButton : Button {
6
public CategoryButton (string icon, string name, bool fill = false) {
7
get_style_context ().add_provider (CategoriesView.style_provider, -1);
10
if (icon != "" && ! fill) {
11
Box container = new Box(Orientation.HORIZONTAL, 3);
12
Box label_box = new Box(Orientation.VERTICAL, 0);
13
label_box.valign = Align.CENTER;
14
Image image_widget = new Image.from_icon_name(icon, IconSize.LARGE_TOOLBAR);
16
Label title = new Label("<b>"+name+"</b>");
17
title.ellipsize = Pango.EllipsizeMode.END;
18
title.halign = Align.START;
19
title.valign = Align.END;
20
title.use_markup = true;
22
Label description = new Label("<i>Comment</i>");
23
description.ellipsize = Pango.EllipsizeMode.END;
24
description.halign = Align.START;
25
description.valign = Align.START;
26
description.use_markup = true;
28
label_box.pack_start(title, false, false, 0);
29
label_box.pack_start(description, false, false, 0);
31
container.pack_start(image_widget, false, false, 0);
32
container.pack_start(label_box, false, false, 0);
38
public class CategoriesView : Box {
40
private string CSS_STYLE = """
41
.CategoriesView *:first-child .button:first-child {
42
border-width: 1 0 0 1;
43
border-radius: 4 0 0 0;
44
-unico-outer-stroke-width: 1 0 0 1;
47
.CategoriesView *:first-child .button {
48
border-width: 1 0 0 1;
49
border-radius: 0 0 0 0;
50
-unico-outer-stroke-width: 1 0 0 0;
53
.CategoriesView *:first-child .button:last-child {
54
border-width: 1 1 0 1;
55
border-radius: 0 4 0 0;
56
-unico-outer-stroke-width: 1 1 0 0;
59
.CategoriesView *.button:first-child {
62
border-width: 1 0 0 1;
63
border-radius: 0 0 0 0;
64
-unico-outer-stroke-width: 0 0 0 1;
67
.CategoriesView *.button {
70
border-width: 1 0 0 1;
71
border-radius: 0 0 0 0;
72
-unico-outer-stroke-width: 0 0 0 0;
75
.CategoriesView *.button:last-child {
78
border-width: 1 1 0 1;
79
border-radius: 0 0 0 0;
80
-unico-outer-stroke-width: 0 1 0 0;
83
.CategoriesView *:last-child .button:first-child {
84
border-width: 1 0 1 1;
85
border-radius: 0 0 0 4;
86
-unico-outer-stroke-width: 0 0 1 1;
89
.CategoriesView *:last-child .button {
90
border-width: 1 0 1 1;
91
border-radius: 0 0 0 0;
92
-unico-outer-stroke-width: 0 0 1 0;
95
.CategoriesView *:last-child .button:last-child {
96
border-width: 1 1 1 1;
97
border-radius: 0 0 4 0;
98
-unico-outer-stroke-width: 0 1 1 0;
101
internal static CssProvider style_provider;
103
public signal void category_choosed ();
106
public Box box_child;
107
private CategoryButton button_child;
109
private int actual_col;
111
public void add_category (string image, string name) {
112
if (actual_col == columns) {
113
box_child = new Box(Orientation.HORIZONTAL, 0);
114
box_child.homogeneous = true;
116
pack_start(box_child, true, true, 0);
120
button_child = new CategoryButton(image, name);
121
button_child.clicked.connect(() => { category_choosed(); });
122
button_child.show_all();
124
box_child.pack_start(button_child, true, true, 0);
128
public void fill_space () {
129
while (actual_col != columns) {
130
button_child = new CategoryButton("", "", true);
131
button_child.clicked.connect(() => { category_choosed(); });
132
button_child.show_all();
133
box_child.pack_start(button_child, true, true, 0);
138
public CategoriesView (int cols) {
142
if (style_provider == null) {
143
style_provider = new CssProvider();
145
style_provider.load_from_data (CSS_STYLE, -1);
147
warning ("CategoryView: %s. The widget will not look as intended", e.message);
151
orientation = Orientation.VERTICAL;
153
get_style_context().add_class("CategoriesView");
155
box_child = new Box(Orientation.HORIZONTAL, 0);
156
box_child.homogeneous = true;
157
pack_start(box_child, true, true, 0);