gedit-view-activatable.c 2.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * gedit-view-activatable.h
 * This file is part of gedit
 *
 * Copyright (C) 2010 Steve Frécinaux
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU Library General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program 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 Library General Public License for more details.
 *
 *  You should have received a copy of the GNU Library General Public License
18
 *  along with this program; if not, see <http://www.gnu.org/licenses/>.
19 20 21 22 23 24 25
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "gedit-view-activatable.h"
26

27
#include "gedit-view.h"
28 29 30

/**
 * SECTION:gedit-view-activatable
31
 * @short_description: Interface for activatable extensions on views
32 33 34
 * @see_also: #PeasExtensionSet
 *
 * #GeditViewActivatable is an interface which should be implemented by
35
 * extensions that should be activated on a gedit view.
36
 **/
37

38 39
G_DEFINE_INTERFACE(GeditViewActivatable, gedit_view_activatable, G_TYPE_OBJECT)

40
static void
41 42
gedit_view_activatable_default_init (GeditViewActivatableInterface *iface)
{
43 44 45 46 47 48 49 50 51 52 53 54 55 56
	/**
	 * GeditViewActivatable:view:
	 *
	 * The window property contains the gedit window for this
	 * #GeditViewActivatable instance.
	 */
	g_object_interface_install_property (iface,
	                                     g_param_spec_object ("view",
	                                                          "view",
	                                                          "A gedit view",
	                                                          GEDIT_TYPE_VIEW,
	                                                          G_PARAM_READWRITE |
	                                                          G_PARAM_CONSTRUCT_ONLY |
	                                                          G_PARAM_STATIC_STRINGS));
57 58 59 60 61 62
}

/**
 * gedit_view_activatable_activate:
 * @activatable: A #GeditViewActivatable.
 *
63
 * Activates the extension on the window property.
64 65
 */
void
66
gedit_view_activatable_activate (GeditViewActivatable *activatable)
67 68 69 70 71 72 73 74
{
	GeditViewActivatableInterface *iface;

	g_return_if_fail (GEDIT_IS_VIEW_ACTIVATABLE (activatable));

	iface = GEDIT_VIEW_ACTIVATABLE_GET_IFACE (activatable);
	if (iface->activate != NULL)
	{
75
		iface->activate (activatable);
76 77 78 79 80 81 82
	}
}

/**
 * gedit_view_activatable_deactivate:
 * @activatable: A #GeditViewActivatable.
 *
83
 * Deactivates the extension on the window property.
84 85
 */
void
86
gedit_view_activatable_deactivate (GeditViewActivatable *activatable)
87 88 89 90 91 92 93 94
{
	GeditViewActivatableInterface *iface;

	g_return_if_fail (GEDIT_IS_VIEW_ACTIVATABLE (activatable));

	iface = GEDIT_VIEW_ACTIVATABLE_GET_IFACE (activatable);
	if (iface->deactivate != NULL)
	{
95
		iface->deactivate (activatable);
96 97
	}
}
98