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
|
/* This file is part of GPump, a Pump.io client.
*
* GPump (THE SOFTWARE) is made available under the terms and conditions of the
* GNU Lesser General Public Licence 3.0. A copy of the licence can be read
* in the file lgpl-3.0.txt in the root of this project.
*/
/** @file
* UserButton is a custom button that displays the users avatar and name.
*/
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
const UserButton = Lang.Class ({
Name: "UserButton",
Extends: Gtk.Button,
Properties: {
"user_avatar": GObject.param_spec_object ("user_avatar",
"avatar",
"A Gtk.Image that is shown in the button",
GObject.Object,
GObject.ParamFlags.READABLE |
GObject.ParamFlags.WRITABLE),
"user_name": GObject.param_spec_string ("user_name",
"name",
"The text to be shown on the button",
"user name goes here",
GObject.ParamFlags.READABLE |
GObject.ParamFlags.WRITABLE),
"show_avatar_only": GObject.param_spec_boolean ("show_avatar_only",
"show only avatar",
"When set, only the avatar will be shown" +
"in the user button",
false,
GObject.ParamFlags.READABLE |
GObject.ParamFlags.WRITABLE)
},
_init: function (params) {
this.parent (params);
this.set_property ('always-show-image', true);
},
get user_avatar () {
return this._user_avatar;
},
set user_avatar (avatar) {
if (avatar == null) {
this.set_image ();
} else {
this.set_image (avatar);
this._user_avatar = avatar;
}
},
get user_name () {
return this._user_name;
},
set user_name (name) {
this._user_name = name;
this.parent.set_property ("label", name);
},
get show_avatar_only () {
return _show_avatar_only;
},
set show_avatar_only (show_avatar) {
this._show_avatar_only = show_avatar;
}
});
|