gedit-window-activatable.c 3.57 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * gedit-window-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-window-activatable.h"
26

27
#include <string.h>
28

29 30
#include "gedit-window.h"

31 32
/**
 * SECTION:gedit-window-activatable
33
 * @short_description: Interface for activatable extensions on windows
34 35 36 37 38
 * @see_also: #PeasExtensionSet
 *
 * #GeditWindowActivatable is an interface which should be implemented by
 * extensions that should be activated on a gedit main window.
 **/
39

40 41
G_DEFINE_INTERFACE(GeditWindowActivatable, gedit_window_activatable, G_TYPE_OBJECT)

42
static void
43 44
gedit_window_activatable_default_init (GeditWindowActivatableInterface *iface)
{
45 46 47 48 49 50 51 52 53 54 55 56 57 58
	/**
	 * GeditWindowActivatable:window:
	 *
	 * The window property contains the gedit window for this
	 * #GeditWindowActivatable instance.
	 */
	g_object_interface_install_property (iface,
	                                     g_param_spec_object ("window",
	                                                          "Window",
	                                                          "The gedit window",
	                                                          GEDIT_TYPE_WINDOW,
	                                                          G_PARAM_READWRITE |
	                                                          G_PARAM_CONSTRUCT_ONLY |
	                                                          G_PARAM_STATIC_STRINGS));
59 60 61 62 63 64
}

/**
 * gedit_window_activatable_activate:
 * @activatable: A #GeditWindowActivatable.
 *
65
 * Activates the extension on the window property.
66 67
 */
void
68
gedit_window_activatable_activate (GeditWindowActivatable *activatable)
69 70 71 72 73 74 75 76
{
	GeditWindowActivatableInterface *iface;

	g_return_if_fail (GEDIT_IS_WINDOW_ACTIVATABLE (activatable));

	iface = GEDIT_WINDOW_ACTIVATABLE_GET_IFACE (activatable);
	if (iface->activate != NULL)
	{
77
		iface->activate (activatable);
78 79 80 81 82 83 84
	}
}

/**
 * gedit_window_activatable_deactivate:
 * @activatable: A #GeditWindowActivatable.
 *
85
 * Deactivates the extension on the window property.
86 87
 */
void
88
gedit_window_activatable_deactivate (GeditWindowActivatable *activatable)
89 90 91 92 93 94 95 96
{
	GeditWindowActivatableInterface *iface;

	g_return_if_fail (GEDIT_IS_WINDOW_ACTIVATABLE (activatable));

	iface = GEDIT_WINDOW_ACTIVATABLE_GET_IFACE (activatable);
	if (iface->deactivate != NULL)
	{
97
		iface->deactivate (activatable);
98 99 100 101 102 103 104
	}
}

/**
 * gedit_window_activatable_update_state:
 * @activatable: A #GeditWindowActivatable.
 *
105 106
 * Triggers an update of the extension internal state to take into account
 * state changes in the window, due to some event or user action.
107 108
 */
void
109
gedit_window_activatable_update_state (GeditWindowActivatable *activatable)
110 111 112 113 114 115 116 117
{
	GeditWindowActivatableInterface *iface;

	g_return_if_fail (GEDIT_IS_WINDOW_ACTIVATABLE (activatable));

	iface = GEDIT_WINDOW_ACTIVATABLE_GET_IFACE (activatable);
	if (iface->update_state != NULL)
	{
118
		iface->update_state (activatable);
119 120
	}
}
121

122
/* ex:set ts=8 noet: */