~ubuntu-branches/ubuntu/wily/gpaste/wily

« back to all changes in this revision

Viewing changes to src/gnome-shell/searchItem.js

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2015-06-19 11:05:16 UTC
  • mfrom: (6.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20150619110516-h53wz9xi9i4k3smb
Tags: 3.16.2.1-1
* Imported Upstream version 3.16.2.1 (Closes: #789255)
* gpaste-applet does not need a manpage - upstream dropped it
* Build-Depends gtk >= 3.16
* Depends gnome-shell >= 3.16
* Major API changes, bump soname to 3 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 *      This file is part of GPaste.
3
3
 *
4
 
 *      Copyright 2014 Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
 
4
 *      Copyright 2014-2015 Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
5
5
 *
6
6
 *      GPaste is free software: you can redistribute it and/or modify
7
7
 *      it under the terms of the GNU General Public License as published by
30
30
    Extends: PopupMenu.PopupBaseMenuItem,
31
31
 
32
32
    _init: function () {
33
 
        this.parent({activate: false, reactive: true});
 
33
        this.parent({
 
34
            activate: false,
 
35
            reactive: true,
 
36
            can_focus: false
 
37
        });
34
38
 
35
39
        this._entry = new St.Entry({
36
40
            name: 'GPasteSearchEntry',
39
43
            reactive: true,
40
44
            can_focus: true
41
45
        });
42
 
        this.actor.add(new St.Bin({child: this._entry, x_align: St.Align.MIDDLE}), { expand: true });
 
46
        this.actor.add(this._entry, { expand: true });
43
47
 
44
48
        this._entry.set_primary_icon(new St.Icon({
45
49
            style_class:'search-entry-icon',
52
56
            icon_name: 'edit-clear-symbolic'
53
57
        });
54
58
        this._iconClickedId = 0;
55
 
 
56
 
        this.actor.connect('key-focus-in', Lang.bind(this, this._onKeyFocusIn));
57
59
    },
58
60
 
59
61
    get text() {
71
73
        text.set_selection(0, 0);
72
74
    },
73
75
 
 
76
    grabFocus: function() {
 
77
        this._entry.grab_key_focus();
 
78
    },
 
79
 
74
80
    _onTextChanged: function(se, prop) {
75
81
        let dummy = (this.text.length == 0);
76
82
        this._entry.set_secondary_icon((dummy) ? null : this._clearIcon);
78
84
            this._iconClickedId = this._entry.connect('secondary-icon-clicked', Lang.bind(this, this.reset));
79
85
        }
80
86
        this.emit('text-changed');
81
 
    },
82
 
 
83
 
    _onKeyFocusIn: function() {
84
 
        this._entry.grab_key_focus();
85
87
    }
86
88
});