| 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 |
|
| 22 |
import gi |
| 23 |
|
| 24 |
gi.require_version('Gtk', '3.0') |
| 25 |
|
| 26 |
from gi.repository import GObject |
| 27 |
from gi.repository import Peas |
| 28 |
from gi.repository import PeasGtk |
| 29 |
from gi.repository import Gtk |
| 30 |
|
| 31 |
LABEL_STRING="Python Says Hello!" |
| 32 |
|
| 33 |
class PythonHelloPlugin(GObject.Object, Peas.Activatable): |
| 34 |
__gtype_name__ = 'PythonHelloPlugin' |
| 35 |
|
| 36 |
object = GObject.Property(type=GObject.Object) |
| 37 |
|
| 38 |
def do_activate(self): |
| 39 |
window = self.object |
| 40 |
print("PythonHelloPlugin.do_activate", repr(window)) |
| 41 |
window._pythonhello_label = Gtk.Label() |
| 42 |
window._pythonhello_label.set_text(LABEL_STRING) |
| 43 |
window._pythonhello_label.show() |
| 44 |
window.get_child().pack_start(window._pythonhello_label, True, True, 0) |
| 45 |
|
| 46 |
def do_deactivate(self): |
| 47 |
window = self.object |
| 48 |
print("PythonHelloPlugin.do_deactivate", repr(window)) |
| 49 |
window.get_child().remove(window._pythonhello_label) |
| 50 |
window._pythonhello_label.destroy() |
| 51 |
|
| 52 |
def do_update_state(self): |
| 53 |
print("PythonHelloPlugin.do_update_state", repr(self.object)) |
| 54 |
|
| 55 |
class PythonHelloConfigurable(GObject.Object, PeasGtk.Configurable): |
| 56 |
__gtype_name__ = 'PythonHelloConfigurable' |
| 57 |
|
| 58 |
def do_create_configure_widget(self): |
| 59 |
return Gtk.Label.new("Python Hello configure widget") |
| 60 |
|
| 61 |
# ex:set ts=4 et sw=4 ai: |