~diodon-team/diodon/plugin-sample

« back to all changes in this revision

Viewing changes to sample-plugin.vala

  • Committer: Oliver Sauder
  • Date: 2011-10-12 14:15:03 UTC
  • Revision ID: os@esite.ch-20111012141503-mr927svd5n3z2b1r
Adding plugin sample

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Diodon - GTK+ clipboard manager.
 
3
 * Copyright (C) 2011 Diodon Team <diodon-team@lists.launchpad.net>
 
4
 *
 
5
 * This program is free software: you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License as published
 
7
 * by the Free Software Foundation, either version 2 of the License, or (at
 
8
 * your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful, but
 
11
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 
12
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
 
13
 * License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
 
 
19
namespace Diodon.Plugins.Sample
 
20
{
 
21
    /**
 
22
     * Sample plugin to be used as template to implement plugins for Diodon
 
23
     */
 
24
    public class SamplePlugin : Peas.ExtensionBase, Peas.Activatable
 
25
    {
 
26
        public Object object { get; construct; }
 
27
 
 
28
        public SamplePlugin()
 
29
        {
 
30
            Object();
 
31
        }
 
32
 
 
33
        public void activate()
 
34
        {
 
35
            Controller controller = object as Controller;
 
36
            controller.add_as_text_item(ClipboardType.PRIMARY, "SamplePlugin activated");
 
37
        }
 
38
 
 
39
        public void deactivate()
 
40
        {
 
41
        }
 
42
 
 
43
        public void update_state()
 
44
        {
 
45
        }
 
46
    }
 
47
}
 
48
 
 
49
[ModuleInit]
 
50
public void peas_register_types (GLib.TypeModule module)
 
51
{
 
52
  Peas.ObjectModule objmodule = module as Peas.ObjectModule;
 
53
  objmodule.register_extension_type (typeof (Peas.Activatable),
 
54
                                     typeof (Diodon.Plugins.Sample.SamplePlugin));
 
55
}
 
56