meta-plugin: Kill off "features"

We already check that the plugin has the appropriate vfunc in the klass
structure, so we shouldn't need to check for the same data again with
a "features" long.

https://bugzilla.gnome.org/show_bug.cgi?id=676855
This commit is contained in:
Jasper St. Pierre 2012-04-05 00:57:28 -04:00
parent 80a70a4ad1
commit 9fa5aa9889
3 changed files with 13 additions and 82 deletions

View File

@ -223,9 +223,7 @@ meta_plugin_manager_kill_switch_workspace (MetaPluginManager *plugin_mgr)
MetaPlugin *plugin = l->data; MetaPlugin *plugin = l->data;
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
if (!meta_plugin_disabled (plugin) if (!meta_plugin_disabled (plugin) && klass->kill_switch_workspace)
&& (meta_plugin_features (plugin) & META_PLUGIN_SWITCH_WORKSPACE)
&& klass->kill_switch_workspace)
klass->kill_switch_workspace (plugin); klass->kill_switch_workspace (plugin);
l = l->next; l = l->next;
@ -258,16 +256,14 @@ meta_plugin_manager_event_simple (MetaPluginManager *plugin_mgr,
MetaPlugin *plugin = l->data; MetaPlugin *plugin = l->data;
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
if (!meta_plugin_disabled (plugin) && if (!meta_plugin_disabled (plugin))
(meta_plugin_features (plugin) & event))
{ {
retval = TRUE;
switch (event) switch (event)
{ {
case META_PLUGIN_MINIMIZE: case META_PLUGIN_MINIMIZE:
if (klass->minimize) if (klass->minimize)
{ {
retval = TRUE;
meta_plugin_manager_kill_window_effects ( meta_plugin_manager_kill_window_effects (
plugin_mgr, plugin_mgr,
actor); actor);
@ -279,6 +275,7 @@ meta_plugin_manager_event_simple (MetaPluginManager *plugin_mgr,
case META_PLUGIN_MAP: case META_PLUGIN_MAP:
if (klass->map) if (klass->map)
{ {
retval = TRUE;
meta_plugin_manager_kill_window_effects ( meta_plugin_manager_kill_window_effects (
plugin_mgr, plugin_mgr,
actor); actor);
@ -290,6 +287,7 @@ meta_plugin_manager_event_simple (MetaPluginManager *plugin_mgr,
case META_PLUGIN_DESTROY: case META_PLUGIN_DESTROY:
if (klass->destroy) if (klass->destroy)
{ {
retval = TRUE;
_meta_plugin_effect_started (plugin); _meta_plugin_effect_started (plugin);
klass->destroy (plugin, actor); klass->destroy (plugin, actor);
} }
@ -335,16 +333,14 @@ meta_plugin_manager_event_maximize (MetaPluginManager *plugin_mgr,
MetaPlugin *plugin = l->data; MetaPlugin *plugin = l->data;
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
if (!meta_plugin_disabled (plugin) && if (!meta_plugin_disabled (plugin))
(meta_plugin_features (plugin) & event))
{ {
retval = TRUE;
switch (event) switch (event)
{ {
case META_PLUGIN_MAXIMIZE: case META_PLUGIN_MAXIMIZE:
if (klass->maximize) if (klass->maximize)
{ {
retval = TRUE;
meta_plugin_manager_kill_window_effects ( meta_plugin_manager_kill_window_effects (
plugin_mgr, plugin_mgr,
actor); actor);
@ -358,6 +354,7 @@ meta_plugin_manager_event_maximize (MetaPluginManager *plugin_mgr,
case META_PLUGIN_UNMAXIMIZE: case META_PLUGIN_UNMAXIMIZE:
if (klass->unmaximize) if (klass->unmaximize)
{ {
retval = TRUE;
meta_plugin_manager_kill_window_effects ( meta_plugin_manager_kill_window_effects (
plugin_mgr, plugin_mgr,
actor); actor);
@ -405,17 +402,13 @@ meta_plugin_manager_switch_workspace (MetaPluginManager *plugin_mgr,
MetaPlugin *plugin = l->data; MetaPlugin *plugin = l->data;
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
if (!meta_plugin_disabled (plugin) && if (!meta_plugin_disabled (plugin) && klass->switch_workspace)
(meta_plugin_features (plugin) & META_PLUGIN_SWITCH_WORKSPACE))
{ {
if (klass->switch_workspace) retval = TRUE;
{ meta_plugin_manager_kill_switch_workspace (plugin_mgr);
retval = TRUE;
meta_plugin_manager_kill_switch_workspace (plugin_mgr);
_meta_plugin_effect_started (plugin); _meta_plugin_effect_started (plugin);
klass->switch_workspace (plugin, from, to, direction); klass->switch_workspace (plugin, from, to, direction);
}
} }
l = l->next; l = l->next;

View File

@ -44,7 +44,6 @@ enum
{ {
PROP_0, PROP_0,
PROP_SCREEN, PROP_SCREEN,
PROP_FEATURES,
PROP_DISABLED, PROP_DISABLED,
PROP_DEBUG_MODE, PROP_DEBUG_MODE,
}; };
@ -52,7 +51,6 @@ enum
struct _MetaPluginPrivate struct _MetaPluginPrivate
{ {
MetaScreen *screen; MetaScreen *screen;
gulong features;
gint running; gint running;
@ -60,45 +58,6 @@ struct _MetaPluginPrivate
gboolean debug : 1; gboolean debug : 1;
}; };
static void
meta_plugin_set_features (MetaPlugin *plugin)
{
MetaPluginPrivate *priv = plugin->priv;
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
priv->features = 0;
/*
* Feature flags: identify events that the plugin can handle; a plugin can
* handle one or more events.
*/
if (klass->minimize)
priv->features |= META_PLUGIN_MINIMIZE;
if (klass->maximize)
priv->features |= META_PLUGIN_MAXIMIZE;
if (klass->unmaximize)
priv->features |= META_PLUGIN_UNMAXIMIZE;
if (klass->map)
priv->features |= META_PLUGIN_MAP;
if (klass->destroy)
priv->features |= META_PLUGIN_DESTROY;
if (klass->switch_workspace)
priv->features |= META_PLUGIN_SWITCH_WORKSPACE;
}
static void
meta_plugin_constructed (GObject *object)
{
meta_plugin_set_features (META_PLUGIN (object));
G_OBJECT_CLASS (meta_plugin_parent_class)->constructed (object);
}
static void static void
meta_plugin_set_property (GObject *object, meta_plugin_set_property (GObject *object,
guint prop_id, guint prop_id,
@ -143,9 +102,6 @@ meta_plugin_get_property (GObject *object,
case PROP_DEBUG_MODE: case PROP_DEBUG_MODE:
g_value_set_boolean (value, priv->debug); g_value_set_boolean (value, priv->debug);
break; break;
case PROP_FEATURES:
g_value_set_ulong (value, priv->features);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -158,7 +114,6 @@ meta_plugin_class_init (MetaPluginClass *klass)
{ {
GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->constructed = meta_plugin_constructed;
gobject_class->set_property = meta_plugin_set_property; gobject_class->set_property = meta_plugin_set_property;
gobject_class->get_property = meta_plugin_get_property; gobject_class->get_property = meta_plugin_get_property;
@ -170,14 +125,6 @@ meta_plugin_class_init (MetaPluginClass *klass)
META_TYPE_SCREEN, META_TYPE_SCREEN,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_FEATURES,
g_param_spec_ulong ("features",
"Features",
"Plugin Features",
0 , G_MAXULONG, 0,
G_PARAM_READABLE));
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_DISABLED, PROP_DISABLED,
g_param_spec_boolean ("disabled", g_param_spec_boolean ("disabled",
@ -205,14 +152,6 @@ meta_plugin_init (MetaPlugin *self)
self->priv = priv = META_PLUGIN_GET_PRIVATE (self); self->priv = priv = META_PLUGIN_GET_PRIVATE (self);
} }
gulong
meta_plugin_features (MetaPlugin *plugin)
{
MetaPluginPrivate *priv = META_PLUGIN (plugin)->priv;
return priv->features;
}
gboolean gboolean
meta_plugin_disabled (MetaPlugin *plugin) meta_plugin_disabled (MetaPlugin *plugin)
{ {

View File

@ -123,7 +123,6 @@ struct _MetaPluginInfo
GType meta_plugin_get_type (void); GType meta_plugin_get_type (void);
gulong meta_plugin_features (MetaPlugin *plugin);
gboolean meta_plugin_disabled (MetaPlugin *plugin); gboolean meta_plugin_disabled (MetaPlugin *plugin);
gboolean meta_plugin_running (MetaPlugin *plugin); gboolean meta_plugin_running (MetaPlugin *plugin);
gboolean meta_plugin_debug_mode (MetaPlugin *plugin); gboolean meta_plugin_debug_mode (MetaPlugin *plugin);