taglist-plugin: Port to WindowActivatable
This commit is contained in:
parent
769f1baaaa
commit
cd3ab1695d
|
@ -5,6 +5,7 @@ DIST_SUBDIRS = \
|
|||
modelines \
|
||||
sort \
|
||||
spell \
|
||||
taglist \
|
||||
time
|
||||
|
||||
SUBDIRS = \
|
||||
|
@ -14,6 +15,7 @@ SUBDIRS = \
|
|||
modelines \
|
||||
sort \
|
||||
spell \
|
||||
taglist \
|
||||
time
|
||||
|
||||
if ENABLE_ENCHANT
|
||||
|
|
|
@ -36,29 +36,28 @@
|
|||
#include "xed-taglist-plugin-parser.h"
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <gmodule.h>
|
||||
#include <libpeas/peas-activatable.h>
|
||||
|
||||
#include <xed/xed-window.h>
|
||||
#include <xed/xed-window-activatable.h>
|
||||
#include <xed/xed-debug.h>
|
||||
|
||||
#define XED_TAGLIST_PLUGIN_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), XED_TYPE_TAGLIST_PLUGIN, XedTaglistPluginPrivate))
|
||||
|
||||
struct _XedTaglistPluginPrivate
|
||||
{
|
||||
GtkWidget *window;
|
||||
XedWindow *window;
|
||||
|
||||
GtkWidget *taglist_panel;
|
||||
};
|
||||
|
||||
static void peas_activatable_iface_init (PeasActivatableInterface *iface);
|
||||
static void xed_window_activatable_iface_init (XedWindowActivatableInterface *iface);
|
||||
|
||||
G_DEFINE_DYNAMIC_TYPE_EXTENDED (XedTaglistPlugin,
|
||||
xed_taglist_plugin,
|
||||
PEAS_TYPE_EXTENSION_BASE,
|
||||
0,
|
||||
G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE,
|
||||
peas_activatable_iface_init) \
|
||||
G_IMPLEMENT_INTERFACE_DYNAMIC (XED_TYPE_WINDOW_ACTIVATABLE,
|
||||
xed_window_activatable_iface_init) \
|
||||
\
|
||||
_xed_taglist_plugin_panel_register_type (type_module); \
|
||||
)
|
||||
|
@ -66,7 +65,7 @@ G_DEFINE_DYNAMIC_TYPE_EXTENDED (XedTaglistPlugin,
|
|||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_OBJECT
|
||||
PROP_WINDOW
|
||||
};
|
||||
|
||||
static void
|
||||
|
@ -84,11 +83,7 @@ xed_taglist_plugin_dispose (GObject *object)
|
|||
|
||||
xed_debug_message (DEBUG_PLUGINS, "XedTaglistPlugin disposing");
|
||||
|
||||
if (plugin->priv->window != NULL)
|
||||
{
|
||||
g_object_unref (plugin->priv->window);
|
||||
plugin->priv->window = NULL;
|
||||
}
|
||||
g_clear_object (&plugin->priv->window);
|
||||
|
||||
G_OBJECT_CLASS (xed_taglist_plugin_parent_class)->dispose (object);
|
||||
}
|
||||
|
@ -104,54 +99,48 @@ xed_taglist_plugin_finalize (GObject *object)
|
|||
}
|
||||
|
||||
static void
|
||||
xed_taglist_plugin_activate (PeasActivatable *activatable)
|
||||
xed_taglist_plugin_activate (XedWindowActivatable *activatable)
|
||||
{
|
||||
XedTaglistPluginPrivate *priv;
|
||||
XedWindow *window;
|
||||
XedPanel *side_panel;
|
||||
gchar *data_dir;
|
||||
|
||||
xed_debug (DEBUG_PLUGINS);
|
||||
|
||||
priv = XED_TAGLIST_PLUGIN (activatable)->priv;
|
||||
window = XED_WINDOW (priv->window);
|
||||
side_panel = xed_window_get_side_panel (window);
|
||||
side_panel = xed_window_get_side_panel (priv->window);
|
||||
|
||||
data_dir = peas_extension_base_get_data_dir (PEAS_EXTENSION_BASE (activatable));
|
||||
priv->taglist_panel = xed_taglist_plugin_panel_new (window, data_dir);
|
||||
priv->taglist_panel = xed_taglist_plugin_panel_new (priv->window, data_dir);
|
||||
g_free (data_dir);
|
||||
|
||||
xed_panel_add_item (side_panel, priv->taglist_panel, _("Tags"), "list-add");
|
||||
}
|
||||
|
||||
static void
|
||||
xed_taglist_plugin_deactivate (PeasActivatable *activatable)
|
||||
xed_taglist_plugin_deactivate (XedWindowActivatable *activatable)
|
||||
{
|
||||
XedTaglistPluginPrivate *priv;
|
||||
XedWindow *window;
|
||||
XedPanel *side_panel;
|
||||
|
||||
xed_debug (DEBUG_PLUGINS);
|
||||
|
||||
priv = XED_TAGLIST_PLUGIN (activatable)->priv;
|
||||
window = XED_WINDOW (priv->window);
|
||||
side_panel = xed_window_get_side_panel (window);
|
||||
side_panel = xed_window_get_side_panel (priv->window);
|
||||
|
||||
xed_panel_remove_item (side_panel, priv->taglist_panel);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_taglist_plugin_update_state (PeasActivatable *activatable)
|
||||
xed_taglist_plugin_update_state (XedWindowActivatable *activatable)
|
||||
{
|
||||
XedTaglistPluginPrivate *priv;
|
||||
XedWindow *window;
|
||||
XedView *view;
|
||||
|
||||
xed_debug (DEBUG_PLUGINS);
|
||||
|
||||
priv = XED_TAGLIST_PLUGIN (activatable)->priv;
|
||||
window = XED_WINDOW (priv->window);
|
||||
view = xed_window_get_active_view (window);
|
||||
view = xed_window_get_active_view (priv->window);
|
||||
|
||||
gtk_widget_set_sensitive (priv->taglist_panel,
|
||||
(view != NULL) &&
|
||||
|
@ -168,8 +157,8 @@ xed_taglist_plugin_set_property (GObject *object,
|
|||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_OBJECT:
|
||||
plugin->priv->window = GTK_WIDGET (g_value_dup_object (value));
|
||||
case PROP_WINDOW:
|
||||
plugin->priv->window = XED_WINDOW (g_value_dup_object (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
@ -187,7 +176,7 @@ xed_taglist_plugin_get_property (GObject *object,
|
|||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_OBJECT:
|
||||
case PROP_WINDOW:
|
||||
g_value_set_object (value, plugin->priv->window);
|
||||
break;
|
||||
default:
|
||||
|
@ -206,7 +195,7 @@ xed_taglist_plugin_class_init (XedTaglistPluginClass *klass)
|
|||
object_class->set_property = xed_taglist_plugin_set_property;
|
||||
object_class->get_property = xed_taglist_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 (XedTaglistPluginPrivate));
|
||||
}
|
||||
|
@ -218,7 +207,7 @@ xed_taglist_plugin_class_finalize (XedTaglistPluginClass *klass)
|
|||
}
|
||||
|
||||
static void
|
||||
peas_activatable_iface_init (PeasActivatableInterface *iface)
|
||||
xed_window_activatable_iface_init (XedWindowActivatableInterface *iface)
|
||||
{
|
||||
iface->activate = xed_taglist_plugin_activate;
|
||||
iface->deactivate = xed_taglist_plugin_deactivate;
|
||||
|
@ -231,6 +220,6 @@ peas_register_types (PeasObjectModule *module)
|
|||
xed_taglist_plugin_register_type (G_TYPE_MODULE (module));
|
||||
|
||||
peas_object_module_register_extension_type (module,
|
||||
PEAS_TYPE_ACTIVATABLE,
|
||||
XED_TYPE_WINDOW_ACTIVATABLE,
|
||||
XED_TYPE_TAGLIST_PLUGIN);
|
||||
}
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
* Modified by the xed Team, 2002-2005. See the AUTHORS file for a
|
||||
* list of people on the xed Team.
|
||||
* See the ChangeLog files for a list of changes.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef __XED_TAGLIST_PLUGIN_H__
|
||||
|
@ -47,13 +45,9 @@ G_BEGIN_DECLS
|
|||
#define XED_IS_TAGLIST_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), XED_TYPE_TAGLIST_PLUGIN))
|
||||
#define XED_TAGLIST_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), XED_TYPE_TAGLIST_PLUGIN, XedTaglistPluginClass))
|
||||
|
||||
/* Private structure type */
|
||||
typedef struct _XedTaglistPluginPrivate XedTaglistPluginPrivate;
|
||||
|
||||
/*
|
||||
* Main object structure
|
||||
*/
|
||||
typedef struct _XedTaglistPlugin XedTaglistPlugin;
|
||||
typedef struct _XedTaglistPluginPrivate XedTaglistPluginPrivate;
|
||||
typedef struct _XedTaglistPluginClass XedTaglistPluginClass;
|
||||
|
||||
struct _XedTaglistPlugin
|
||||
{
|
||||
|
@ -63,22 +57,13 @@ struct _XedTaglistPlugin
|
|||
XedTaglistPluginPrivate *priv;
|
||||
};
|
||||
|
||||
/*
|
||||
* Class definition
|
||||
*/
|
||||
typedef struct _XedTaglistPluginClass XedTaglistPluginClass;
|
||||
|
||||
struct _XedTaglistPluginClass
|
||||
{
|
||||
PeasExtensionBaseClass parent_class;
|
||||
};
|
||||
|
||||
/*
|
||||
* Public methods
|
||||
*/
|
||||
GType xed_taglist_plugin_get_type (void) G_GNUC_CONST;
|
||||
|
||||
/* All the plugins must implement this function */
|
||||
G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
Loading…
Reference in New Issue