# -*- coding: utf-8 -*-

# extension-py.py.in
# This file is part of libpeas
#
# Copyright (C) 2011-2014 Garrett Regier
#
# libpeas is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# libpeas is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.

import threading

from gi.repository import GObject, Introspection, Peas


__all__ = [ 'ExtensionPythonAbstract', 'ExtensionPythonPlugin' ]


class ExtensionPythonAbstract(Introspection.Abstract):
    pass


class ExtensionPythonPlugin(Introspection.Prerequisite, Peas.Activatable,
                            Introspection.Base, Introspection.Callable,
                            Introspection.HasPrerequisite):

    object = GObject.Property(type=GObject.Object)
    update_count = GObject.Property(type=int, default=0, minimum=0)

    def __init__(self):
        self.__lock = threading.Lock()

    def do_activate(self):
        pass

    def do_deactivate(self):
        pass

    def do_update_state(self):
        with self.__lock:
            self.update_count += 1

    def do_get_plugin_info(self):
        return self.plugin_info

    def do_get_settings(self):
        return self.plugin_info.get_settings(None)

    def do_call_with_return(self):
        return "Hello, World!"

    def do_call_no_args(self):
        pass

    def do_call_single_arg(self):
        return True

    def do_call_multi_args(self, in_, inout):
        return (inout, in_)

# ex:set ts=4 et sw=4 ai:
