1# -*- coding: utf-8 -*-
2
3# pythonhello.py
4# This file is part of libpeas
5#
6# Copyright (C) 2009-2010 Steve Frécinaux
7#
8# libpeas is free software; you can redistribute it and/or
9# modify it under the terms of the GNU Lesser General Public
10# License as published by the Free Software Foundation; either
11# version 2.1 of the License, or (at your option) any later version.
12#
13# libpeas is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16# Lesser General Public License for more details.
17#
18# You should have received a copy of the GNU Lesser General Public
19# License along with this library; if not, write to the Free Software
20# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
21
22from gi.repository import GObject
23from gi.repository import Peas
24from gi.repository import PeasGtk
25from gi.repository import Gtk
26
27LABEL_STRING="Python Says Hello!"
28
29class PythonHelloPlugin(GObject.Object, Peas.Activatable):
30    __gtype_name__ = 'PythonHelloPlugin'
31
32    object = GObject.Property(type=GObject.Object)
33
34    def do_activate(self):
35        window = self.object
36        print("PythonHelloPlugin.do_activate", repr(window))
37        window._pythonhello_label = Gtk.Label()
38        window._pythonhello_label.set_text(LABEL_STRING)
39        window._pythonhello_label.show()
40        window.get_child().pack_start(window._pythonhello_label, True, True, 0)
41
42    def do_deactivate(self):
43        window = self.object
44        print("PythonHelloPlugin.do_deactivate", repr(window))
45        window.get_child().remove(window._pythonhello_label)
46        window._pythonhello_label.destroy()
47
48    def do_update_state(self):
49        print("PythonHelloPlugin.do_update_state", repr(self.object))
50
51class PythonHelloConfigurable(GObject.Object, PeasGtk.Configurable):
52    __gtype_name__ = 'PythonHelloConfigurable'
53
54    def do_create_configure_widget(self):
55        return Gtk.Label.new("Python Hello configure widget")
56
57# ex:set ts=4 et sw=4 ai:
58