/gpump/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/gpump/trunk

« back to all changes in this revision

Viewing changes to src/user_button.js

  • Committer: Gustav Hartvigsson
  • Date: 2014-06-13 21:51:09 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20140613215109-1o4421hhbm8ztbei
* Changes a thing in the about dialoug.
* Changed the style of the close button in the prefs dialoug.
* Added, for future use, style.js...

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* This file is part of GPump, a Pump.io client.
2
 
 *
3
 
 * GPump (THE SOFTWARE) is made available under the terms and conditions of the
4
 
 * GNU Lesser General Public Licence 3.0. A copy of the licence can be read
5
 
 * in the file lgpl-3.0.txt in the root of this project.
6
 
 */
7
 
 
8
 
/** @file
9
 
 * UserButton is a custom button that displays the users avatar and name.
10
 
 */
11
 
 
12
 
const GObject = imports.gi.GObject;
13
 
const Gtk = imports.gi.Gtk;
14
 
const Lang = imports.lang;
15
 
 
16
 
const UserButton = Lang.Class ({
17
 
  Name: "UserButton",
18
 
  Extends: Gtk.Button,
19
 
  Properties: {
20
 
    "user_avatar": GObject.param_spec_object ("user_avatar",
21
 
                                     "avatar",
22
 
                                     "A Gtk.Image that is shown in the button",
23
 
                                     GObject.Object,
24
 
                                     GObject.ParamFlags.READABLE |
25
 
                                     GObject.ParamFlags.WRITABLE),
26
 
    
27
 
    "user_name": GObject.param_spec_string ("user_name",
28
 
                                     "name",
29
 
                                     "The text to be shown on the button",
30
 
                                     "user name goes here",
31
 
                                     GObject.ParamFlags.READABLE |
32
 
                                     GObject.ParamFlags.WRITABLE),
33
 
    
34
 
    "show_avatar_only": GObject.param_spec_boolean ("show_avatar_only",
35
 
                                     "show only avatar",
36
 
                                     "When set, only the avatar will be shown" +
37
 
                                     "in the user button",
38
 
                                     false,
39
 
                                     GObject.ParamFlags.READABLE |
40
 
                                     GObject.ParamFlags.WRITABLE)
41
 
  },
42
 
  
43
 
  
44
 
  _init: function (params) {
45
 
    this.parent (params);
46
 
    this.set_property ('always-show-image', true);
47
 
  },
48
 
  
49
 
  get user_avatar () {
50
 
    return this._user_avatar;
51
 
  },
52
 
  
53
 
  set user_avatar (avatar) {
54
 
    if (avatar == null) {
55
 
      this.set_image ();
56
 
    } else {
57
 
      this.set_image (avatar);
58
 
      this._user_avatar = avatar;
59
 
    }
60
 
  },
61
 
  
62
 
  get user_name () {
63
 
    return this._user_name;
64
 
  },
65
 
  
66
 
  set user_name (name) {
67
 
    this._user_name = name;
68
 
    this.parent.set_property ("label", name);
69
 
  },
70
 
  
71
 
  get show_avatar_only () {
72
 
    return _show_avatar_only;
73
 
  },
74
 
  
75
 
  set show_avatar_only (show_avatar) {
76
 
    this._show_avatar_only = show_avatar;
77
 
  }
78
 
  
79
 
});