trailsave-plugin: Port to WindowActivatable
This commit is contained in:
parent
cd3ab1695d
commit
77ae5a4048
|
@ -6,7 +6,8 @@ DIST_SUBDIRS = \
|
||||||
sort \
|
sort \
|
||||||
spell \
|
spell \
|
||||||
taglist \
|
taglist \
|
||||||
time
|
time \
|
||||||
|
trailsave
|
||||||
|
|
||||||
SUBDIRS = \
|
SUBDIRS = \
|
||||||
changecase \
|
changecase \
|
||||||
|
@ -16,7 +17,8 @@ SUBDIRS = \
|
||||||
sort \
|
sort \
|
||||||
spell \
|
spell \
|
||||||
taglist \
|
taglist \
|
||||||
time
|
time \
|
||||||
|
trailsave
|
||||||
|
|
||||||
if ENABLE_ENCHANT
|
if ENABLE_ENCHANT
|
||||||
SUBDIRS += spell
|
SUBDIRS += spell
|
||||||
|
|
|
@ -14,43 +14,40 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <libpeas/peas-activatable.h>
|
#include "xed-trail-save-plugin.h"
|
||||||
|
|
||||||
#include <xed/xed-window.h>
|
#include <xed/xed-window.h>
|
||||||
|
#include <xed/xed-window-activatable.h>
|
||||||
#include <xed/xed-debug.h>
|
#include <xed/xed-debug.h>
|
||||||
|
|
||||||
#include "xed-trail-save-plugin.h"
|
|
||||||
|
|
||||||
#define XED_TRAIL_SAVE_PLUGIN_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
|
#define XED_TRAIL_SAVE_PLUGIN_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
|
||||||
XED_TYPE_TRAIL_SAVE_PLUGIN, \
|
XED_TYPE_TRAIL_SAVE_PLUGIN, \
|
||||||
XedTrailSavePluginPrivate))
|
XedTrailSavePluginPrivate))
|
||||||
|
|
||||||
static void peas_activatable_iface_init (PeasActivatableInterface *iface);
|
static void xed_window_activatable_iface_init (XedWindowActivatableInterface *iface);
|
||||||
|
|
||||||
G_DEFINE_DYNAMIC_TYPE_EXTENDED (XedTrailSavePlugin,
|
G_DEFINE_DYNAMIC_TYPE_EXTENDED (XedTrailSavePlugin,
|
||||||
xed_trail_save_plugin,
|
xed_trail_save_plugin,
|
||||||
PEAS_TYPE_EXTENSION_BASE,
|
PEAS_TYPE_EXTENSION_BASE,
|
||||||
0,
|
0,
|
||||||
G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE,
|
G_IMPLEMENT_INTERFACE_DYNAMIC (XED_TYPE_WINDOW_ACTIVATABLE,
|
||||||
peas_activatable_iface_init))
|
xed_window_activatable_iface_init))
|
||||||
|
|
||||||
struct _XedTrailSavePluginPrivate
|
struct _XedTrailSavePluginPrivate
|
||||||
{
|
{
|
||||||
GtkWidget *window;
|
XedWindow *window;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_OBJECT
|
PROP_WINDOW
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -149,7 +146,8 @@ on_tab_added (XedWindow *window,
|
||||||
XedDocument *document;
|
XedDocument *document;
|
||||||
|
|
||||||
document = xed_tab_get_document (tab);
|
document = xed_tab_get_document (tab);
|
||||||
g_signal_connect (document, "save", G_CALLBACK (on_save), plugin);
|
g_signal_connect (document, "save",
|
||||||
|
G_CALLBACK (on_save), plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -164,59 +162,58 @@ on_tab_removed (XedWindow *window,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_trail_save_plugin_activate (PeasActivatable *activatable)
|
xed_trail_save_plugin_activate (XedWindowActivatable *activatable)
|
||||||
{
|
{
|
||||||
XedTrailSavePlugin *plugin;
|
XedTrailSavePluginPrivate *priv;
|
||||||
XedWindow *window;
|
|
||||||
GList *documents;
|
GList *documents;
|
||||||
GList *documents_iter;
|
GList *documents_iter;
|
||||||
XedDocument *document;
|
XedDocument *document;
|
||||||
|
|
||||||
xed_debug (DEBUG_PLUGINS);
|
xed_debug (DEBUG_PLUGINS);
|
||||||
|
|
||||||
plugin = XED_TRAIL_SAVE_PLUGIN (activatable);
|
priv = XED_TRAIL_SAVE_PLUGIN (activatable)->priv;
|
||||||
window = XED_WINDOW (plugin->priv->window);
|
|
||||||
|
|
||||||
g_signal_connect (window, "tab_added", G_CALLBACK (on_tab_added), plugin);
|
g_signal_connect (priv->window, "tab_added",
|
||||||
g_signal_connect (window, "tab_removed", G_CALLBACK (on_tab_removed), plugin);
|
G_CALLBACK (on_tab_added), XED_TRAIL_SAVE_PLUGIN (activatable));
|
||||||
|
g_signal_connect (priv->window, "tab_removed",
|
||||||
|
G_CALLBACK (on_tab_removed), XED_TRAIL_SAVE_PLUGIN (activatable));
|
||||||
|
|
||||||
documents = xed_window_get_documents (window);
|
documents = xed_window_get_documents (priv->window);
|
||||||
|
|
||||||
for (documents_iter = documents;
|
for (documents_iter = documents;
|
||||||
documents_iter && documents_iter->data;
|
documents_iter && documents_iter->data;
|
||||||
documents_iter = documents_iter->next)
|
documents_iter = documents_iter->next)
|
||||||
{
|
{
|
||||||
document = (XedDocument *) documents_iter->data;
|
document = (XedDocument *) documents_iter->data;
|
||||||
g_signal_connect (document, "save", G_CALLBACK (on_save), plugin);
|
g_signal_connect (document, "save",
|
||||||
|
G_CALLBACK (on_save), XED_TRAIL_SAVE_PLUGIN (activatable));
|
||||||
}
|
}
|
||||||
|
|
||||||
g_list_free (documents);
|
g_list_free (documents);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_trail_save_plugin_deactivate (PeasActivatable *activatable)
|
xed_trail_save_plugin_deactivate (XedWindowActivatable *activatable)
|
||||||
{
|
{
|
||||||
XedTrailSavePlugin *plugin;
|
XedTrailSavePluginPrivate *priv;
|
||||||
XedWindow *window;
|
|
||||||
GList *documents;
|
GList *documents;
|
||||||
GList *documents_iter;
|
GList *documents_iter;
|
||||||
XedDocument *document;
|
XedDocument *document;
|
||||||
|
|
||||||
xed_debug (DEBUG_PLUGINS);
|
xed_debug (DEBUG_PLUGINS);
|
||||||
|
|
||||||
plugin = XED_TRAIL_SAVE_PLUGIN (activatable);
|
priv = XED_TRAIL_SAVE_PLUGIN (activatable)->priv;
|
||||||
window = XED_WINDOW (plugin->priv->window);
|
|
||||||
|
|
||||||
g_signal_handlers_disconnect_by_data (window, plugin);
|
g_signal_handlers_disconnect_by_data (priv->window, XED_TRAIL_SAVE_PLUGIN (activatable));
|
||||||
|
|
||||||
documents = xed_window_get_documents (window);
|
documents = xed_window_get_documents (priv->window);
|
||||||
|
|
||||||
for (documents_iter = documents;
|
for (documents_iter = documents;
|
||||||
documents_iter && documents_iter->data;
|
documents_iter && documents_iter->data;
|
||||||
documents_iter = documents_iter->next)
|
documents_iter = documents_iter->next)
|
||||||
{
|
{
|
||||||
document = (XedDocument *) documents_iter->data;
|
document = (XedDocument *) documents_iter->data;
|
||||||
g_signal_handlers_disconnect_by_data (document, plugin);
|
g_signal_handlers_disconnect_by_data (document, XED_TRAIL_SAVE_PLUGIN (activatable));
|
||||||
}
|
}
|
||||||
|
|
||||||
g_list_free (documents);
|
g_list_free (documents);
|
||||||
|
@ -227,7 +224,7 @@ xed_trail_save_plugin_init (XedTrailSavePlugin *plugin)
|
||||||
{
|
{
|
||||||
xed_debug_message (DEBUG_PLUGINS, "XedTrailSavePlugin initializing");
|
xed_debug_message (DEBUG_PLUGINS, "XedTrailSavePlugin initializing");
|
||||||
|
|
||||||
plugin->priv = XED_TRAIL_SAVE_PLUGIN_GET_PRIVATE (plugin);
|
plugin->priv = G_TYPE_INSTANCE_GET_PRIVATE (plugin, XED_TYPE_TRAIL_SAVE_PLUGIN, XedTrailSavePluginPrivate);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -237,11 +234,7 @@ xed_trail_save_plugin_dispose (GObject *object)
|
||||||
|
|
||||||
xed_debug_message (DEBUG_PLUGINS, "XedTrailSavePlugin disposing");
|
xed_debug_message (DEBUG_PLUGINS, "XedTrailSavePlugin disposing");
|
||||||
|
|
||||||
if (plugin->priv->window != NULL)
|
g_clear_object (&plugin->priv->window);
|
||||||
{
|
|
||||||
g_object_unref (plugin->priv->window);
|
|
||||||
plugin->priv->window = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (xed_trail_save_plugin_parent_class)->dispose (object);
|
G_OBJECT_CLASS (xed_trail_save_plugin_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
@ -256,8 +249,8 @@ xed_trail_save_plugin_set_property (GObject *object,
|
||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_OBJECT:
|
case PROP_WINDOW:
|
||||||
plugin->priv->window = GTK_WIDGET (g_value_dup_object (value));
|
plugin->priv->window = XED_WINDOW (g_value_dup_object (value));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
@ -275,7 +268,7 @@ xed_trail_save_plugin_get_property (GObject *object,
|
||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_OBJECT:
|
case PROP_WINDOW:
|
||||||
g_value_set_object (value, plugin->priv->window);
|
g_value_set_object (value, plugin->priv->window);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -293,7 +286,7 @@ xed_trail_save_plugin_class_init (XedTrailSavePluginClass *klass)
|
||||||
object_class->set_property = xed_trail_save_plugin_set_property;
|
object_class->set_property = xed_trail_save_plugin_set_property;
|
||||||
object_class->get_property = xed_trail_save_plugin_get_property;
|
object_class->get_property = xed_trail_save_plugin_get_property;
|
||||||
|
|
||||||
g_object_class_override_property (object_class, PROP_OBJECT, "object");
|
g_object_class_override_property (object_class, PROP_WINDOW, "window");
|
||||||
|
|
||||||
g_type_class_add_private (object_class, sizeof (XedTrailSavePluginPrivate));
|
g_type_class_add_private (object_class, sizeof (XedTrailSavePluginPrivate));
|
||||||
}
|
}
|
||||||
|
@ -305,7 +298,7 @@ xed_trail_save_plugin_class_finalize (XedTrailSavePluginClass *klass)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
peas_activatable_iface_init (PeasActivatableInterface *iface)
|
xed_window_activatable_iface_init (XedWindowActivatableInterface *iface)
|
||||||
{
|
{
|
||||||
iface->activate = xed_trail_save_plugin_activate;
|
iface->activate = xed_trail_save_plugin_activate;
|
||||||
iface->deactivate = xed_trail_save_plugin_deactivate;
|
iface->deactivate = xed_trail_save_plugin_deactivate;
|
||||||
|
@ -317,6 +310,6 @@ peas_register_types (PeasObjectModule *module)
|
||||||
xed_trail_save_plugin_register_type (G_TYPE_MODULE (module));
|
xed_trail_save_plugin_register_type (G_TYPE_MODULE (module));
|
||||||
|
|
||||||
peas_object_module_register_extension_type (module,
|
peas_object_module_register_extension_type (module,
|
||||||
PEAS_TYPE_ACTIVATABLE,
|
XED_TYPE_WINDOW_ACTIVATABLE,
|
||||||
XED_TYPE_TRAIL_SAVE_PLUGIN);
|
XED_TYPE_TRAIL_SAVE_PLUGIN);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,6 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
/*
|
|
||||||
* Type checking and casting macros
|
|
||||||
*/
|
|
||||||
#define XED_TYPE_TRAIL_SAVE_PLUGIN (xed_trail_save_plugin_get_type ())
|
#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(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_TRAIL_SAVE_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), XED_TYPE_TRAIL_SAVE_PLUGIN, XedTrailSavePluginClass))
|
||||||
|
@ -38,13 +35,9 @@ G_BEGIN_DECLS
|
||||||
#define XED_IS_TRAIL_SAVE_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), 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_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;
|
||||||
|
typedef struct _XedTrailSavePluginPrivate XedTrailSavePluginPrivate;
|
||||||
|
typedef struct _XedTrailSavePluginClass XedTrailSavePluginClass;
|
||||||
|
|
||||||
struct _XedTrailSavePlugin
|
struct _XedTrailSavePlugin
|
||||||
{
|
{
|
||||||
|
@ -54,22 +47,13 @@ struct _XedTrailSavePlugin
|
||||||
XedTrailSavePluginPrivate *priv;
|
XedTrailSavePluginPrivate *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Class definition
|
|
||||||
*/
|
|
||||||
typedef struct _XedTrailSavePluginClass XedTrailSavePluginClass;
|
|
||||||
|
|
||||||
struct _XedTrailSavePluginClass
|
struct _XedTrailSavePluginClass
|
||||||
{
|
{
|
||||||
PeasExtensionBaseClass 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 void peas_register_types (PeasObjectModule *module);
|
G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
Loading…
Reference in New Issue