1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
/*
* Copyright (C) 2012 Canonical, Ltd.
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* version 3.0 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3.0 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*
* Authored by Michal Hruby <[email protected]>
*
*/
namespace Unity
{
/* Keep in sync with Protocol.CategoryType! */
public enum CategoryType
{
NONE,
APPLICATION,
BOOK,
MUSIC,
MOVIE,
GAMES,
ELECTRONICS,
COMPUTERS,
OFFICE,
HOME,
GARDEN,
PETS,
TOYS,
CHILDREN,
BABY,
CLOTHES,
SHOES,
WATCHES,
SPORTS,
OUTDOORS,
GROCERY,
HEALTH,
BEAUTY,
DIY,
TOOLS,
CAR,
N_CATEGORIES
}
public enum IconSizeHint
{
DEFAULT,
SMALL,
LARGE
}
/*
* AnnotatedIcon can be used to add various icon and text overlays to an icon.
* Add desired overlays using properties of this class and use the to_string()
* method to serialize the icon (for example when appending rows to scope
* results model).
*
* NOTE: We can't make this class implement GIcon, cause GIcon includes
* the type name in the serialized string, and if that didn't match
* the type name from protocol library, the library wouldn't be able
* to deserialize it.
* This does have also a nice side effect though - being unable to construct
* an AnnotatedIcon with another AnnotatedIcon as the base_icon.
*/
public class AnnotatedIcon : Object
{
private Protocol.AnnotatedIcon _pai;
public Icon icon
{
get { return _pai.icon; }
set { _pai.icon = value; }
}
public string ribbon
{
get { return _pai.ribbon; }
set { _pai.ribbon = value; }
}
public CategoryType category
{
get { return (CategoryType) _pai.category; }
set { _pai.category = (Protocol.CategoryType) value; }
}
public IconSizeHint size_hint
{
get
{
return _pai.use_small_icon ? IconSizeHint.SMALL : IconSizeHint.DEFAULT;
}
set { _pai.use_small_icon = value == IconSizeHint.SMALL; }
}
public void set_colorize_rgba (double r, double g, double b, double a)
{
_pai.set_colorize_rgba (r, g, b, a);
}
public AnnotatedIcon (Icon base_icon)
{
Object (icon: base_icon);
}
construct
{
static_assert ((uint) CategoryType.N_CATEGORIES ==
(uint) Protocol.CategoryType.N_CATEGORIES);
_pai = new Protocol.AnnotatedIcon (null);
}
/* GIcon-like to string method */
public string to_string ()
{
return _pai.to_string ();
}
}
} /* namespace */
|