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

View File

@ -44,7 +44,6 @@ enum
{
PROP_0,
PROP_SCREEN,
PROP_FEATURES,
PROP_DISABLED,
PROP_DEBUG_MODE,
};
@ -52,7 +51,6 @@ enum
struct _MetaPluginPrivate
{
MetaScreen *screen;
gulong features;
gint running;
@ -60,45 +58,6 @@ struct _MetaPluginPrivate
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
meta_plugin_set_property (GObject *object,
guint prop_id,
@ -143,9 +102,6 @@ meta_plugin_get_property (GObject *object,
case PROP_DEBUG_MODE:
g_value_set_boolean (value, priv->debug);
break;
case PROP_FEATURES:
g_value_set_ulong (value, priv->features);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -158,7 +114,6 @@ meta_plugin_class_init (MetaPluginClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->constructed = meta_plugin_constructed;
gobject_class->set_property = meta_plugin_set_property;
gobject_class->get_property = meta_plugin_get_property;
@ -170,14 +125,6 @@ meta_plugin_class_init (MetaPluginClass *klass)
META_TYPE_SCREEN,
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,
PROP_DISABLED,
g_param_spec_boolean ("disabled",
@ -205,14 +152,6 @@ meta_plugin_init (MetaPlugin *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
meta_plugin_disabled (MetaPlugin *plugin)
{

View File

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