33
33
"user_name": GObject.param_spec_string ("user_name",
35
35
"The text to be shown on the button",
36
"user name goes here",
37
37
GObject.ParamFlags.READABLE |
38
38
GObject.ParamFlags.WRITABLE),
53
53
_init: function (params) {
55
this.set_property ('always-show-image', true);
56
this.add (this.layout = new Gtk.Box ({
57
orientation: Gtk.Orientation.HORIZONTAL
61
this._user_avatar = null;
63
if (params["user_avatar"] != undefined) {
64
this.user_avatar = params["user_avatar"];
66
this._user_avatar = Gtk.Image.new_from_icon_name (
67
"avatar-default-symbolic", null);
70
if (params["user_name"] != undefined) {
71
this._user_name = params["user_name"];
73
this._user_name = "Jone Deo";
76
if (params["show_avatar_only"] != undefined) {
77
this._show_avatar_only = params["show_avatar_only"];
79
this._show_avatar_only = false;
86
* Hack to re-build the button, cus we can not use references in JavaScript.
88
_rebuild: function () {
92
this.layout.foreach (function (widget) {
96
this.layout.pack_start (this._user_avatar, false, false, 3);
98
this.user_avatar["icon_size"] = 5;
101
if (this._show_avatar_only == false) {
102
this.layout.pack_start (new Gtk.Separator ({
103
orientation: Gtk.Orientation.VERTICAL
104
}), false, false, 3);
107
this.layout.pack_end (
108
this._user_name_widget = new Gtk.Label ({
109
label: this._user_name
58
116
get user_avatar () {
62
120
set user_avatar (avatar) {
121
if (avatar == undefined) {
123
this._user_avatar = Gtk.Image.new_from_icon_name (
124
"avatar-default-symbolic", null);
66
this.set_image (avatar);
126
print ("Not balls!");
67
127
this._user_avatar = avatar;
75
136
set user_name (name) {
76
137
this._user_name = name;
77
this.parent.set_property ("label", name);
80
141
get show_avatar_only () {
81
142
return _show_avatar_only;
84
set show_avatar_only (show_avatar) {
85
this._show_avatar_only = show_avatar;
145
set show_avatar_only (show_avatar_only) {
146
this._show_avatar_only = show_avatar_only;