parent
b7ecc43dfc
commit
9b3313efa7
|
@ -22,9 +22,36 @@
|
|||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <libpeas/peas-activatable.h>
|
||||
|
||||
#include <xed/xed-window.h>
|
||||
#include <xed/xed-debug.h>
|
||||
|
||||
#include "xed-trail-save-plugin.h"
|
||||
|
||||
XED_PLUGIN_REGISTER_TYPE(XedTrailSavePlugin, xed_trail_save_plugin)
|
||||
#define XED_TRAIL_SAVE_PLUGIN_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
|
||||
XED_TYPE_TRAIL_SAVE_PLUGIN, \
|
||||
XedTrailSavePluginPrivate))
|
||||
|
||||
static void peas_activatable_iface_init (PeasActivatableInterface *iface);
|
||||
|
||||
G_DEFINE_DYNAMIC_TYPE_EXTENDED (XedTrailSavePlugin,
|
||||
xed_trail_save_plugin,
|
||||
PEAS_TYPE_EXTENSION_BASE,
|
||||
0,
|
||||
G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE,
|
||||
peas_activatable_iface_init))
|
||||
|
||||
struct _XedTrailSavePluginPrivate
|
||||
{
|
||||
GtkWidget *window;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_OBJECT
|
||||
};
|
||||
|
||||
static void
|
||||
strip_trailing_spaces (GtkTextBuffer *text_buffer)
|
||||
|
@ -107,7 +134,7 @@ on_save (XedDocument *document,
|
|||
const gchar *uri,
|
||||
XedEncoding *encoding,
|
||||
XedDocumentSaveFlags save_flags,
|
||||
XedPlugin *plugin)
|
||||
XedTrailSavePlugin *plugin)
|
||||
{
|
||||
GtkTextBuffer *text_buffer = GTK_TEXT_BUFFER (document);
|
||||
|
||||
|
@ -117,7 +144,7 @@ on_save (XedDocument *document,
|
|||
static void
|
||||
on_tab_added (XedWindow *window,
|
||||
XedTab *tab,
|
||||
XedPlugin *plugin)
|
||||
XedTrailSavePlugin *plugin)
|
||||
{
|
||||
XedDocument *document;
|
||||
|
||||
|
@ -128,7 +155,7 @@ on_tab_added (XedWindow *window,
|
|||
static void
|
||||
on_tab_removed (XedWindow *window,
|
||||
XedTab *tab,
|
||||
XedPlugin *plugin)
|
||||
XedTrailSavePlugin *plugin)
|
||||
{
|
||||
XedDocument *document;
|
||||
|
||||
|
@ -137,15 +164,19 @@ on_tab_removed (XedWindow *window,
|
|||
}
|
||||
|
||||
static void
|
||||
impl_activate (XedPlugin *plugin,
|
||||
XedWindow *window)
|
||||
xed_trail_save_plugin_activate (PeasActivatable *activatable)
|
||||
{
|
||||
XedTrailSavePlugin *plugin;
|
||||
XedWindow *window;
|
||||
GList *documents;
|
||||
GList *documents_iter;
|
||||
XedDocument *document;
|
||||
|
||||
xed_debug (DEBUG_PLUGINS);
|
||||
|
||||
plugin = XED_TRAIL_SAVE_PLUGIN (activatable);
|
||||
window = XED_WINDOW (plugin->priv->window);
|
||||
|
||||
g_signal_connect (window, "tab_added", G_CALLBACK (on_tab_added), plugin);
|
||||
g_signal_connect (window, "tab_removed", G_CALLBACK (on_tab_removed), plugin);
|
||||
|
||||
|
@ -163,15 +194,19 @@ impl_activate (XedPlugin *plugin,
|
|||
}
|
||||
|
||||
static void
|
||||
impl_deactivate (XedPlugin *plugin,
|
||||
XedWindow *window)
|
||||
xed_trail_save_plugin_deactivate (PeasActivatable *activatable)
|
||||
{
|
||||
XedTrailSavePlugin *plugin;
|
||||
XedWindow *window;
|
||||
GList *documents;
|
||||
GList *documents_iter;
|
||||
XedDocument *document;
|
||||
|
||||
xed_debug (DEBUG_PLUGINS);
|
||||
|
||||
plugin = XED_TRAIL_SAVE_PLUGIN (activatable);
|
||||
window = XED_WINDOW (plugin->priv->window);
|
||||
|
||||
g_signal_handlers_disconnect_by_data (window, plugin);
|
||||
|
||||
documents = xed_window_get_documents (window);
|
||||
|
@ -191,24 +226,97 @@ static void
|
|||
xed_trail_save_plugin_init (XedTrailSavePlugin *plugin)
|
||||
{
|
||||
xed_debug_message (DEBUG_PLUGINS, "XedTrailSavePlugin initializing");
|
||||
|
||||
plugin->priv = XED_TRAIL_SAVE_PLUGIN_GET_PRIVATE (plugin);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_trail_save_plugin_finalize (GObject *object)
|
||||
xed_trail_save_plugin_dispose (GObject *object)
|
||||
{
|
||||
xed_debug_message (DEBUG_PLUGINS, "XedTrailSavePlugin finalizing");
|
||||
XedTrailSavePlugin *plugin = XED_TRAIL_SAVE_PLUGIN (object);
|
||||
|
||||
G_OBJECT_CLASS (xed_trail_save_plugin_parent_class)->finalize (object);
|
||||
xed_debug_message (DEBUG_PLUGINS, "XedTrailSavePlugin disposing");
|
||||
|
||||
if (plugin->priv->window != NULL)
|
||||
{
|
||||
g_object_unref (plugin->priv->window);
|
||||
plugin->priv->window = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (xed_trail_save_plugin_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_trail_save_plugin_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
XedTrailSavePlugin *plugin = XED_TRAIL_SAVE_PLUGIN (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_OBJECT:
|
||||
plugin->priv->window = GTK_WIDGET (g_value_dup_object (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xed_trail_save_plugin_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
XedTrailSavePlugin *plugin = XED_TRAIL_SAVE_PLUGIN (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_OBJECT:
|
||||
g_value_set_object (value, plugin->priv->window);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xed_trail_save_plugin_class_init (XedTrailSavePluginClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
XedPluginClass *plugin_class = XED_PLUGIN_CLASS (klass);
|
||||
|
||||
object_class->finalize = xed_trail_save_plugin_finalize;
|
||||
object_class->dispose = xed_trail_save_plugin_dispose;
|
||||
object_class->set_property = xed_trail_save_plugin_set_property;
|
||||
object_class->get_property = xed_trail_save_plugin_get_property;
|
||||
|
||||
plugin_class->activate = impl_activate;
|
||||
plugin_class->deactivate = impl_deactivate;
|
||||
g_object_class_override_property (object_class, PROP_OBJECT, "object");
|
||||
|
||||
g_type_class_add_private (object_class, sizeof (XedTrailSavePluginPrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
xed_trail_save_plugin_class_finalize (XedTrailSavePluginClass *klass)
|
||||
{
|
||||
/* dummy function - used by G_DEFINE_DYNAMIC_TYPE_EXTENDED */
|
||||
}
|
||||
|
||||
static void
|
||||
peas_activatable_iface_init (PeasActivatableInterface *iface)
|
||||
{
|
||||
iface->activate = xed_trail_save_plugin_activate;
|
||||
iface->deactivate = xed_trail_save_plugin_deactivate;
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT void
|
||||
peas_register_types (PeasObjectModule *module)
|
||||
{
|
||||
xed_trail_save_plugin_register_type (G_TYPE_MODULE (module));
|
||||
|
||||
peas_object_module_register_extension_type (module,
|
||||
PEAS_TYPE_ACTIVATABLE,
|
||||
XED_TYPE_TRAIL_SAVE_PLUGIN);
|
||||
}
|
||||
|
|
|
@ -23,47 +23,54 @@
|
|||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <xed/xed-plugin.h>
|
||||
#include <libpeas/peas-extension-base.h>
|
||||
#include <libpeas/peas-object-module.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/*
|
||||
* Type checking and casting macros
|
||||
*/
|
||||
#define XED_TYPE_TRAIL_SAVE_PLUGIN (xed_trail_save_plugin_get_type ())
|
||||
#define XED_TRAIL_SAVE_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), XED_TYPE_TRAIL_SAVE_PLUGIN, XedTrailSavePlugin))
|
||||
#define XED_TRAIL_SAVE_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), XED_TYPE_TRAIL_SAVE_PLUGIN, XedTrailSavePluginClass))
|
||||
#define XED_IS_TRAIL_SAVE_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), XED_TYPE_TRAIL_SAVE_PLUGIN))
|
||||
#define XED_IS_TRAIL_SAVE_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), XED_TYPE_TRAIL_SAVE_PLUGIN))
|
||||
#define XED_TRAIL_SAVE_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), XED_TYPE_TRAIL_SAVE_PLUGIN, XedTrailSavePluginClass))
|
||||
#define XED_TYPE_TRAIL_SAVE_PLUGIN (xed_trail_save_plugin_get_type ())
|
||||
#define XED_TRAIL_SAVE_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), XED_TYPE_TRAIL_SAVE_PLUGIN, XedTrailSavePlugin))
|
||||
#define XED_TRAIL_SAVE_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), XED_TYPE_TRAIL_SAVE_PLUGIN, XedTrailSavePluginClass))
|
||||
#define XED_IS_TRAIL_SAVE_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), XED_TYPE_TRAIL_SAVE_PLUGIN))
|
||||
#define XED_IS_TRAIL_SAVE_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), XED_TYPE_TRAIL_SAVE_PLUGIN))
|
||||
#define XED_TRAIL_SAVE_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), XED_TYPE_TRAIL_SAVE_PLUGIN, XedTrailSavePluginClass))
|
||||
|
||||
/* Private structure type */
|
||||
typedef struct _XedTrailSavePluginPrivate XedTrailSavePluginPrivate;
|
||||
|
||||
/*
|
||||
* Main object structure
|
||||
*/
|
||||
typedef struct _XedTrailSavePlugin XedTrailSavePlugin;
|
||||
typedef struct _XedTrailSavePlugin XedTrailSavePlugin;
|
||||
|
||||
struct _XedTrailSavePlugin
|
||||
{
|
||||
XedPlugin parent_instance;
|
||||
PeasExtensionBase parent_instance;
|
||||
|
||||
/*< private >*/
|
||||
XedTrailSavePluginPrivate *priv;
|
||||
};
|
||||
|
||||
/*
|
||||
* Class definition
|
||||
*/
|
||||
typedef struct _XedTrailSavePluginClass XedTrailSavePluginClass;
|
||||
typedef struct _XedTrailSavePluginClass XedTrailSavePluginClass;
|
||||
|
||||
struct _XedTrailSavePluginClass
|
||||
{
|
||||
XedPluginClass parent_class;
|
||||
PeasExtensionBaseClass parent_class;
|
||||
};
|
||||
|
||||
/*
|
||||
* Public methods
|
||||
*/
|
||||
GType xed_trail_save_plugin_get_type (void) G_GNUC_CONST;
|
||||
GType xed_trail_save_plugin_get_type (void) G_GNUC_CONST;
|
||||
|
||||
/* All the plugins must implement this function */
|
||||
G_MODULE_EXPORT GType register_xed_plugin (GTypeModule *module);
|
||||
G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
Loading…
Reference in New Issue