~elementary-pantheon/pantheon-plugs/plug-template

« back to all changes in this revision

Viewing changes to src/Plug.vala

  • Committer: Corentin Noël
  • Date: 2014-04-15 07:13:05 UTC
  • Revision ID: tintou@mailoo.org-20140415071305-z0r9rb4kbejqzsq5
New Sample Plug version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//
2
 
//  Copyright (C) 2012 Ivo Nunes
3
 
//
4
 
//  This program is free software: you can redistribute it and/or modify
5
 
//  it under the terms of the GNU General Public License as published by
6
 
//  the Free Software Foundation, either version 3 of the License, or
7
 
//  (at your option) any later version.
8
 
//
9
 
//  This program is distributed in the hope that it will be useful,
10
 
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
//  GNU General Public License for more details.
13
 
//
14
 
//  You should have received a copy of the GNU General Public License
15
 
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 
//
17
 
 
18
 
public class Sample.Plug : Switchboard.Plug {
19
 
 
20
 
    private Gtk.Grid main_grid;
21
 
 
22
 
    public Plug () {
23
 
        Object (category: Category.HARDWARE,
24
 
                code_name: "hardware-template-sample",
25
 
                display_name: _("Sample"),
26
 
                description: _("Configure nothing but is a big step"),
27
 
                icon: "go-home");
28
 
    }
29
 
    
30
 
    public override Gtk.Widget get_widget () {
31
 
        if (main_grid == null) {
32
 
            main_grid = new Gtk.Grid ();
33
 
            var label = new Gtk.Label ("Hello World!");
34
 
            main_grid.attach (label, 0, 0, 1, 1);
35
 
        }
36
 
        main_grid.show_all ();
37
 
        return main_grid;
38
 
    }
39
 
    
40
 
    public override void shown () {
41
 
        
42
 
    }
43
 
    
44
 
    public override void hidden () {
45
 
        
46
 
    }
47
 
    
48
 
    public override void search_callback (string location) {
49
 
    
50
 
    }
51
 
    
52
 
    // 'search' returns results like ("Keyboard → Behavior → Duration", "keyboard<sep>behavior")
53
 
    public override async Gee.TreeMap<string, string> search (string search) {
54
 
        return new Gee.TreeMap<string, string> (null, null);
 
1
// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
 
2
/*-
 
3
 * Copyright (c) 2014 YOUR NAME (http://launchpad.net/your-project)
 
4
 *
 
5
 * This library is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU Library General Public
 
7
 * License as published by the Free Software Foundation; either
 
8
 * version 3 of the License, or (at your option) any later version.
 
9
 *
 
10
 * This library is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
 * Library General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU Library General Public
 
16
 * License along with this library; if not, write to the
 
17
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
18
 * Boston, MA 02111-1307, USA.
 
19
 *
 
20
 * Authored by: Corentin Noël <tintou@mailoo.org>
 
21
 */
 
22
namespace Sample {
 
23
 
 
24
    public static Plug plug;
 
25
 
 
26
    public class Plug : Switchboard.Plug {
 
27
        Gtk.Grid main_grid;
 
28
 
 
29
        public Plug () {
 
30
            Object (category: Category.PERSONAL,
 
31
                    code_name: Build.PLUGCODENAME,
 
32
                    display_name: _("Sample Plug"),
 
33
                    description: _("Try to play with it!"),
 
34
                    icon: "applications-development");
 
35
            plug = this;
 
36
        }
 
37
 
 
38
        public override Gtk.Widget get_widget () {
 
39
            if (main_grid == null) {
 
40
                main_grid = new Gtk.Grid ();
 
41
                var hello_label = new Gtk.Label (_("Hello World"));
 
42
                main_grid.attach (hello_label, 0, 0, 1, 1);
 
43
                main_grid.show_all ();
 
44
            }
 
45
 
 
46
            return main_grid;
 
47
        }
 
48
 
 
49
        public override void shown () {
 
50
            
 
51
        }
 
52
 
 
53
        public override void hidden () {
 
54
            
 
55
        }
 
56
 
 
57
        public override void search_callback (string location) {
 
58
            
 
59
        }
 
60
 
 
61
        // 'search' returns results like ("Keyboard → Behavior → Duration", "keyboard<sep>behavior")
 
62
        public override async Gee.TreeMap<string, string> search (string search) {
 
63
            return new Gee.TreeMap<string, string> (null, null);
 
64
        }
55
65
    }
56
66
}
 
67
 
 
68
public Switchboard.Plug get_plug (Module module) {
 
69
    debug ("Activating Sample plug");
 
70
    var plug = new Sample.Plug ();
 
71
    return plug;
 
72
}
 
 
b'\\ No newline at end of file'