Change the GeditWindowActivatable to take the window as a construct property.

parent 3972b9d4
......@@ -24,91 +24,103 @@
#endif
#include "gedit-window-activatable.h"
#include "gedit-window.h"
/**
* SECTION:gedit-window-activatable
* @short_description: Interface for extensions activatable on windows
* @short_description: Interface for activatable extensions on windows
* @see_also: #PeasExtensionSet
*
* #GeditWindowActivatable is an interface which should be implemented by
* extensions that should be activated on a gedit main window.
**/
G_DEFINE_INTERFACE(GeditWindowActivatable, gedit_window_activatable, G_TYPE_OBJECT)
void
gedit_window_activatable_default_init (GeditWindowActivatableInterface *iface)
{
static gboolean initialized = FALSE;
if (!initialized)
{
/**
* 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));
initialized = TRUE;
}
}
/**
* gedit_window_activatable_activate:
* @activatable: A #GeditWindowActivatable.
* @window: The #GeditWindow on which the plugin should be activated.
*
* Activates the extension on the given window.
* Activates the extension on the window property.
*/
void
gedit_window_activatable_activate (GeditWindowActivatable *activatable,
GeditWindow *window)
gedit_window_activatable_activate (GeditWindowActivatable *activatable)
{
GeditWindowActivatableInterface *iface;
g_return_if_fail (GEDIT_IS_WINDOW_ACTIVATABLE (activatable));
g_return_if_fail (GEDIT_IS_WINDOW (window));
iface = GEDIT_WINDOW_ACTIVATABLE_GET_IFACE (activatable);
if (iface->activate != NULL)
{
iface->activate (activatable, window);
iface->activate (activatable);
}
}
/**
* gedit_window_activatable_deactivate:
* @activatable: A #GeditWindowActivatable.
* @window: A #GeditWindow.
*
* Deactivates the plugin on the given window.
* Deactivates the extension on the window property.
*/
void
gedit_window_activatable_deactivate (GeditWindowActivatable *activatable,
GeditWindow *window)
gedit_window_activatable_deactivate (GeditWindowActivatable *activatable)
{
GeditWindowActivatableInterface *iface;
g_return_if_fail (GEDIT_IS_WINDOW_ACTIVATABLE (activatable));
g_return_if_fail (GEDIT_IS_WINDOW (window));
iface = GEDIT_WINDOW_ACTIVATABLE_GET_IFACE (activatable);
if (iface->deactivate != NULL)
{
iface->deactivate (activatable, window);
iface->deactivate (activatable);
}
}
/**
* gedit_window_activatable_update_state:
* @activatable: A #GeditWindowActivatable.
* @window: A #GeditWindow.
*
* Triggers an update of the plugin insternal state to take into account
* state changes in the window state, due to a plugin or an user action.
* Triggers an update of the extension internal state to take into account
* state changes in the window, due to some event or user action.
*/
void
gedit_window_activatable_update_state (GeditWindowActivatable *activatable,
GeditWindow *window)
gedit_window_activatable_update_state (GeditWindowActivatable *activatable)
{
GeditWindowActivatableInterface *iface;
g_return_if_fail (GEDIT_IS_WINDOW_ACTIVATABLE (activatable));
g_return_if_fail (GEDIT_IS_WINDOW (window));
iface = GEDIT_WINDOW_ACTIVATABLE_GET_IFACE (activatable);
if (iface->update_state != NULL)
{
iface->update_state (activatable, window);
iface->update_state (activatable);
}
}
......@@ -24,8 +24,6 @@
#include <glib-object.h>
#include "gedit-window.h"
G_BEGIN_DECLS
/*
......@@ -45,12 +43,9 @@ struct _GeditWindowActivatableInterface
GTypeInterface g_iface;
/* Virtual public methods */
void (*activate) (GeditWindowActivatable *activatable,
GeditWindow *window);
void (*deactivate) (GeditWindowActivatable *activatable,
GeditWindow *window);
void (*update_state) (GeditWindowActivatable *activatable,
GeditWindow *window);
void (*activate) (GeditWindowActivatable *activatable);
void (*deactivate) (GeditWindowActivatable *activatable);
void (*update_state) (GeditWindowActivatable *activatable);
};
/*
......@@ -58,12 +53,9 @@ struct _GeditWindowActivatableInterface
*/
GType gedit_window_activatable_get_type (void) G_GNUC_CONST;
void gedit_window_activatable_activate (GeditWindowActivatable *activatable,
GeditWindow *window);
void gedit_window_activatable_deactivate (GeditWindowActivatable *activatable,
GeditWindow *window);
void gedit_window_activatable_update_state (GeditWindowActivatable *activatable,
GeditWindow *window);
void gedit_window_activatable_activate (GeditWindowActivatable *activatable);
void gedit_window_activatable_deactivate (GeditWindowActivatable *activatable);
void gedit_window_activatable_update_state (GeditWindowActivatable *activatable);
G_END_DECLS
......
......@@ -3032,7 +3032,7 @@ sync_name (GeditTab *tab,
g_free (escaped_name);
g_free (tip);
peas_extension_set_call (window->priv->extensions, "update_state", window);
peas_extension_set_call (window->priv->extensions, "update_state");
}
static GeditWindow *
......@@ -3428,7 +3428,7 @@ selection_changed (GeditDocument *doc,
editable &&
gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (doc)));
peas_extension_set_call (window->priv->extensions, "update_state", window);
peas_extension_set_call (window->priv->extensions, "update_state");
}
static void
......@@ -3437,7 +3437,7 @@ sync_languages_menu (GeditDocument *doc,
GeditWindow *window)
{
update_languages_menu (window);
peas_extension_set_call (window->priv->extensions, "update_state", window);
peas_extension_set_call (window->priv->extensions, "update_state");
}
static void
......@@ -3450,7 +3450,7 @@ readonly_changed (GeditDocument *doc,
sync_name (gedit_window_get_active_tab (window), NULL, window);
peas_extension_set_call (window->priv->extensions, "update_state", window);
peas_extension_set_call (window->priv->extensions, "update_state");
}
static void
......@@ -3458,7 +3458,7 @@ editable_changed (GeditView *view,
GParamSpec *arg1,
GeditWindow *window)
{
peas_extension_set_call (window->priv->extensions, "update_state", window);
peas_extension_set_call (window->priv->extensions, "update_state");
}
static void
......@@ -3689,7 +3689,7 @@ on_tab_removed (GeditMultiNotebook *multi,
if (num_tabs == 0)
{
peas_extension_set_call (window->priv->extensions, "update_state", window);
peas_extension_set_call (window->priv->extensions, "update_state");
}
}
......@@ -4122,7 +4122,7 @@ extension_added (PeasExtensionSet *extensions,
PeasExtension *exten,
GeditWindow *window)
{
peas_extension_call (exten, "activate", window);
peas_extension_call (exten, "activate");
}
static void
......@@ -4131,7 +4131,7 @@ extension_removed (PeasExtensionSet *extensions,
PeasExtension *exten,
GeditWindow *window)
{
peas_extension_call (exten, "deactivate", window);
peas_extension_call (exten, "deactivate");
/* Ensure update of ui manager, because we suspect it does something
* with expected static strings in the type module (when unloaded the
......@@ -4312,7 +4312,9 @@ gedit_window_init (GeditWindow *window)
gedit_debug_message (DEBUG_WINDOW, "Update plugins ui");
window->priv->extensions = peas_extension_set_new (PEAS_ENGINE (gedit_plugins_engine_get_default ()),
GEDIT_TYPE_WINDOW_ACTIVATABLE);
GEDIT_TYPE_WINDOW_ACTIVATABLE,
"window", window,
NULL);
g_signal_connect (window->priv->extensions,
"extension-added",
G_CALLBACK (extension_added),
......@@ -4321,7 +4323,7 @@ gedit_window_init (GeditWindow *window)
"extension-removed",
G_CALLBACK (extension_removed),
window);
peas_extension_set_call (window->priv->extensions, "activate", window);
peas_extension_set_call (window->priv->extensions, "activate");
/* set visibility of panels.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment