Change the GeditViewActivatable to take the view as a construct property.

parent 4180a7bb
......@@ -24,67 +24,82 @@
#endif
#include "gedit-view-activatable.h"
#include "gedit-view.h"
/**
* SECTION:gedit-view-activatable
* @short_description: Interface for extensions activatable on views
* @short_description: Interface for activatable extensions on views
* @see_also: #PeasExtensionSet
*
* #GeditViewActivatable is an interface which should be implemented by
* extensions that should be activated on a gedit view (or the document it
* contains).
* extensions that should be activated on a gedit view.
**/
G_DEFINE_INTERFACE(GeditViewActivatable, gedit_view_activatable, G_TYPE_OBJECT)
void
gedit_view_activatable_default_init (GeditViewActivatableInterface *iface)
{
static gboolean initialized = FALSE;
if (!initialized)
{
/**
* 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));
initialized = TRUE;
}
}
/**
* gedit_view_activatable_activate:
* @activatable: A #GeditViewActivatable.
* @view: The #GeditView on which the plugin should be activated.
*
* Activates the extension on the given view.
* Activates the extension on the window property.
*/
void
gedit_view_activatable_activate (GeditViewActivatable *activatable,
GeditView *view)
gedit_view_activatable_activate (GeditViewActivatable *activatable)
{
GeditViewActivatableInterface *iface;
g_return_if_fail (GEDIT_IS_VIEW_ACTIVATABLE (activatable));
g_return_if_fail (GEDIT_IS_VIEW (view));
iface = GEDIT_VIEW_ACTIVATABLE_GET_IFACE (activatable);
if (iface->activate != NULL)
{
iface->activate (activatable, view);
iface->activate (activatable);
}
}
/**
* gedit_view_activatable_deactivate:
* @activatable: A #GeditViewActivatable.
* @view: A #GeditView.
*
* Deactivates the plugin on the given view.
* Deactivates the extension on the window property.
*/
void
gedit_view_activatable_deactivate (GeditViewActivatable *activatable,
GeditView *view)
gedit_view_activatable_deactivate (GeditViewActivatable *activatable)
{
GeditViewActivatableInterface *iface;
g_return_if_fail (GEDIT_IS_VIEW_ACTIVATABLE (activatable));
g_return_if_fail (GEDIT_IS_VIEW (view));
iface = GEDIT_VIEW_ACTIVATABLE_GET_IFACE (activatable);
if (iface->deactivate != NULL)
{
iface->deactivate (activatable, view);
iface->deactivate (activatable);
}
}
......@@ -24,8 +24,6 @@
#include <glib-object.h>
#include "gedit-view.h"
G_BEGIN_DECLS
/*
......@@ -45,10 +43,8 @@ struct _GeditViewActivatableInterface
GTypeInterface g_iface;
/* Virtual public methods */
void (*activate) (GeditViewActivatable *activatable,
GeditView *view);
void (*deactivate) (GeditViewActivatable *activatable,
GeditView *view);
void (*activate) (GeditViewActivatable *activatable);
void (*deactivate) (GeditViewActivatable *activatable);
};
/*
......@@ -56,10 +52,8 @@ struct _GeditViewActivatableInterface
*/
GType gedit_view_activatable_get_type (void) G_GNUC_CONST;
void gedit_view_activatable_activate (GeditViewActivatable *activatable,
GeditView *view);
void gedit_view_activatable_deactivate (GeditViewActivatable *activatable,
GeditView *view);
void gedit_view_activatable_activate (GeditViewActivatable *activatable);
void gedit_view_activatable_deactivate (GeditViewActivatable *activatable);
G_END_DECLS
......
......@@ -315,7 +315,7 @@ extension_added (PeasExtensionSet *extensions,
PeasExtension *exten,
GeditView *view)
{
peas_extension_call (exten, "activate", view);
peas_extension_call (exten, "activate");
}
static void
......@@ -324,7 +324,7 @@ extension_removed (PeasExtensionSet *extensions,
PeasExtension *exten,
GeditView *view)
{
peas_extension_call (exten, "deactivate", view);
peas_extension_call (exten, "deactivate");
}
static void
......@@ -357,7 +357,7 @@ on_notify_buffer_cb (GeditView *view,
/* We only activate the extensions when the right buffer is set,
* because most plugins will expect this behaviour, and we won't
* change the buffer later anyway. */
peas_extension_set_call (view->priv->extensions, "activate", view);
peas_extension_set_call (view->priv->extensions, "activate");
}
static void
......@@ -451,7 +451,9 @@ gedit_view_init (GeditView *view)
gtk_target_list_add_uri_targets (tl, TARGET_URI_LIST);
view->priv->extensions = peas_extension_set_new (PEAS_ENGINE (gedit_plugins_engine_get_default ()),
GEDIT_TYPE_VIEW_ACTIVATABLE);
GEDIT_TYPE_VIEW_ACTIVATABLE,
"view", view,
NULL);
g_signal_connect (view->priv->extensions,
"extension-added",
G_CALLBACK (extension_added),
......@@ -479,8 +481,7 @@ gedit_view_destroy (GtkObject *object)
if (view->priv->extensions != NULL)
{
peas_extension_set_call (view->priv->extensions,
"deactivate",
view);
"deactivate");
g_object_unref (view->priv->extensions);
view->priv->extensions = NULL;
}
......
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