De-C99fied default and scratch plugins.

This commit is contained in:
Tomas Frydrych 2008-10-27 09:33:58 +00:00
parent 07c1003905
commit 310970a91b
3 changed files with 72 additions and 90 deletions

View File

@ -63,35 +63,7 @@ static gboolean reload (const char *params);
* Any dynamically allocated data should be initialized in the * Any dynamically allocated data should be initialized in the
* init () function below. * init () function below.
*/ */
G_MODULE_EXPORT MutterPlugin mutter_plugin = MUTTER_DECLARE_PLUGIN();
{
/*
* These are predefined values; do not modify.
*/
.version_major = METACITY_MAJOR_VERSION,
.version_minor = METACITY_MINOR_VERSION,
.version_micro = METACITY_MICRO_VERSION,
.version_api = METACITY_CLUTTER_PLUGIN_API_VERSION,
/* Human readable name (for use in UI) */
.name = "Default Effects",
/* Plugin load time initialiser */
.do_init = do_init,
/* Effect handlers */
.minimize = minimize,
.destroy = destroy,
.map = map,
.maximize = maximize,
.unmaximize = unmaximize,
.switch_workspace = switch_workspace,
.kill_effect = kill_effect,
/* The reload handler */
.reload = reload
};
/* /*
* Plugin private data that we store in the .plugin_private member. * Plugin private data that we store in the .plugin_private member.
@ -114,6 +86,13 @@ typedef struct _PluginState
gboolean debug_mode : 1; gboolean debug_mode : 1;
} PluginState; } PluginState;
static inline MutterPlugin *
get_plugin ()
{
return &mutter_plugin;
}
/* /*
* Per actor private data we attach to each actor. * Per actor private data we attach to each actor.
*/ */
@ -193,7 +172,7 @@ on_switch_workspace_effect_complete (ClutterActor *group, gpointer data)
state->desktop1 = NULL; state->desktop1 = NULL;
state->desktop2 = NULL; state->desktop2 = NULL;
mutter_plugin_effect_completed (&mutter_plugin, actor_for_cb, mutter_plugin_effect_completed (get_plugin(), actor_for_cb,
MUTTER_PLUGIN_SWITCH_WORKSPACE); MUTTER_PLUGIN_SWITCH_WORKSPACE);
} }
@ -201,7 +180,7 @@ static void
switch_workspace (const GList **actors, gint from, gint to, switch_workspace (const GList **actors, gint from, gint to,
MetaMotionDirection direction) MetaMotionDirection direction)
{ {
MutterPlugin *plugin = &mutter_plugin; MutterPlugin *plugin = get_plugin();
PluginState *state = plugin_state; PluginState *state = plugin_state;
GList *l; GList *l;
gint n_workspaces; gint n_workspaces;
@ -229,7 +208,7 @@ switch_workspace (const GList **actors, gint from, gint to,
if (from == to) if (from == to)
{ {
mutter_plugin_effect_completed (&mutter_plugin, NULL, mutter_plugin_effect_completed (get_plugin(), NULL,
MUTTER_PLUGIN_SWITCH_WORKSPACE); MUTTER_PLUGIN_SWITCH_WORKSPACE);
return; return;
} }
@ -320,7 +299,7 @@ on_minimize_effect_complete (ClutterActor *actor, gpointer data)
CLUTTER_GRAVITY_NORTH_WEST); CLUTTER_GRAVITY_NORTH_WEST);
/* Now notify the manager that we are done with this effect */ /* Now notify the manager that we are done with this effect */
mutter_plugin_effect_completed (&mutter_plugin, mc_window, mutter_plugin_effect_completed (get_plugin(), mc_window,
MUTTER_PLUGIN_MINIMIZE); MUTTER_PLUGIN_MINIMIZE);
} }
@ -355,7 +334,7 @@ minimize (MutterWindow *mc_window)
NULL); NULL);
} }
else else
mutter_plugin_effect_completed (&mutter_plugin, mc_window, mutter_plugin_effect_completed (get_plugin(), mc_window,
MUTTER_PLUGIN_MINIMIZE); MUTTER_PLUGIN_MINIMIZE);
} }
@ -380,7 +359,7 @@ on_maximize_effect_complete (ClutterActor *actor, gpointer data)
CLUTTER_GRAVITY_NORTH_WEST); CLUTTER_GRAVITY_NORTH_WEST);
/* Now notify the manager that we are done with this effect */ /* Now notify the manager that we are done with this effect */
mutter_plugin_effect_completed (&mutter_plugin, mc_window, mutter_plugin_effect_completed (get_plugin(), mc_window,
MUTTER_PLUGIN_MAXIMIZE); MUTTER_PLUGIN_MAXIMIZE);
} }
@ -443,7 +422,7 @@ maximize (MutterWindow *mc_window,
return; return;
} }
mutter_plugin_effect_completed (&mutter_plugin, mc_window, mutter_plugin_effect_completed (get_plugin(), mc_window,
MUTTER_PLUGIN_MAXIMIZE); MUTTER_PLUGIN_MAXIMIZE);
} }
@ -466,7 +445,7 @@ unmaximize (MutterWindow *mc_window,
} }
/* Do this conditionally, if the effect requires completion callback. */ /* Do this conditionally, if the effect requires completion callback. */
mutter_plugin_effect_completed (&mutter_plugin, mc_window, mutter_plugin_effect_completed (get_plugin(), mc_window,
MUTTER_PLUGIN_UNMAXIMIZE); MUTTER_PLUGIN_UNMAXIMIZE);
} }
@ -485,7 +464,7 @@ on_map_effect_complete (ClutterActor *actor, gpointer data)
CLUTTER_GRAVITY_NORTH_WEST); CLUTTER_GRAVITY_NORTH_WEST);
/* Now notify the manager that we are done with this effect */ /* Now notify the manager that we are done with this effect */
mutter_plugin_effect_completed (&mutter_plugin, mc_window, MUTTER_PLUGIN_MAP); mutter_plugin_effect_completed (get_plugin(), mc_window, MUTTER_PLUGIN_MAP);
} }
/* /*
@ -522,7 +501,7 @@ map (MutterWindow *mc_window)
} }
else else
mutter_plugin_effect_completed (&mutter_plugin, mc_window, mutter_plugin_effect_completed (get_plugin(), mc_window,
MUTTER_PLUGIN_MAP); MUTTER_PLUGIN_MAP);
} }
@ -533,7 +512,7 @@ map (MutterWindow *mc_window)
static void static void
on_destroy_effect_complete (ClutterActor *actor, gpointer data) on_destroy_effect_complete (ClutterActor *actor, gpointer data)
{ {
MutterPlugin *plugin = &mutter_plugin; MutterPlugin *plugin = get_plugin();
MutterWindow *mc_window = MUTTER_WINDOW (actor); MutterWindow *mc_window = MUTTER_WINDOW (actor);
ActorPrivate *apriv = get_actor_private (mc_window); ActorPrivate *apriv = get_actor_private (mc_window);
@ -570,14 +549,13 @@ destroy (MutterWindow *mc_window)
NULL); NULL);
} }
else else
mutter_plugin_effect_completed (&mutter_plugin, mc_window, mutter_plugin_effect_completed (get_plugin(), mc_window,
MUTTER_PLUGIN_DESTROY); MUTTER_PLUGIN_DESTROY);
} }
static void static void
kill_effect (MutterWindow *mc_window, gulong event) kill_effect (MutterWindow *mc_window, gulong event)
{ {
MutterPlugin *plugin = &mutter_plugin;
ActorPrivate *apriv; ActorPrivate *apriv;
ClutterActor *actor = CLUTTER_ACTOR (mc_window); ClutterActor *actor = CLUTTER_ACTOR (mc_window);
@ -627,21 +605,32 @@ kill_effect (MutterWindow *mc_window, gulong event)
} }
#if 0
const gchar * g_module_check_init (GModule *module); const gchar * g_module_check_init (GModule *module);
const gchar * const gchar *
g_module_check_init (GModule *module) g_module_check_init (GModule *module)
{ {
/* MutterPlugin *plugin = get_plugin ();
* Unused; left here for documentation purposes.
* /* Human readable name (for use in UI) */
* NB: this function is called *before* the plugin manager does its own plugin->name = "Default Effects";
* initialization of the plugin struct, so you cannot process fields
* like .params in here; use the init function below instead. /* Plugin load time initialiser */
*/ plugin->do_init = do_init;
/* Effect handlers */
plugin->minimize = minimize;
plugin->destroy = destroy;
plugin->map = map;
plugin->maximize = maximize;
plugin->unmaximize = unmaximize;
plugin->switch_workspace = switch_workspace;
plugin->kill_effect = kill_effect;
/* The reload handler */
plugin->reload = reload;
return NULL; return NULL;
} }
#endif
/* /*
* Core of the plugin init function, called for initial initialization and * Core of the plugin init function, called for initial initialization and
@ -662,7 +651,7 @@ do_init (const char *params)
{ {
if (strstr (params, "debug")) if (strstr (params, "debug"))
{ {
g_debug ("%s: Entering debug mode.", mutter_plugin.name); g_debug ("%s: Entering debug mode.", get_plugin()->name);
plugin_state->debug_mode = TRUE; plugin_state->debug_mode = TRUE;

View File

@ -77,35 +77,7 @@ static gboolean reload (const char *params);
* Any dynamically allocated data should be initialized in the * Any dynamically allocated data should be initialized in the
* init () function below. * init () function below.
*/ */
G_MODULE_EXPORT MutterPlugin mutter_plugin = MUTTER_DECLARE_PLUGIN ();
{
/*
* These are predefined values; do not modify.
*/
.version_major = METACITY_MAJOR_VERSION,
.version_minor = METACITY_MINOR_VERSION,
.version_micro = METACITY_MICRO_VERSION,
.version_api = METACITY_CLUTTER_PLUGIN_API_VERSION,
/* Human readable name (for use in UI) */
.name = "Experimental effects",
/* Plugin load time initialiser */
.do_init = do_init,
/* Effect handlers */
.minimize = minimize,
.destroy = destroy,
.map = map,
.maximize = maximize,
.unmaximize = unmaximize,
.switch_workspace = switch_workspace,
.kill_effect = kill_effect,
.xevent_filter = xevent_filter,
/* The reload handler */
.reload = reload
};
/* /*
* Plugin private data that we store in the .plugin_private member. * Plugin private data that we store in the .plugin_private member.
@ -798,21 +770,33 @@ kill_effect (MutterWindow *mcw, gulong event)
} }
#if 0
const gchar * g_module_check_init (GModule *module); const gchar * g_module_check_init (GModule *module);
const gchar * const gchar *
g_module_check_init (GModule *module) g_module_check_init (GModule *module)
{ {
/* MutterPlugin *plugin = get_plugin ();
* Unused; left here for documentation purposes.
* /* Human readable name (for use in UI) */
* NB: this function is called *before* the plugin manager does its own plugin->name = "Experimental effects",
* initialization of the plugin struct, so you cannot process fields
* like .params in here; use the init function below instead. /* Plugin load time initialiser */
*/ plugin->do_init = do_init;
/* Effect handlers */
plugin->minimize = minimize;
plugin->destroy = destroy;
plugin->map = map;
plugin->maximize = maximize;
plugin->unmaximize = unmaximize;
plugin->switch_workspace = switch_workspace;
plugin->kill_effect = kill_effect;
plugin->xevent_filter = xevent_filter;
/* The reload handler */
plugin->reload = reload;
return NULL; return NULL;
} }
#endif
static void switcher_clone_weak_notify (gpointer data, GObject *object); static void switcher_clone_weak_notify (gpointer data, GObject *object);

View File

@ -56,6 +56,15 @@ typedef struct MutterPlugin MutterPlugin;
#define MUTTER_PLUGIN_ALL_EFFECTS (~0) #define MUTTER_PLUGIN_ALL_EFFECTS (~0)
#define MUTTER_DECLARE_PLUGIN() G_MODULE_EXPORT MutterPlugin mutter_plugin = \
{ \
METACITY_MAJOR_VERSION, \
METACITY_MINOR_VERSION, \
METACITY_MICRO_VERSION, \
METACITY_CLUTTER_PLUGIN_API_VERSION \
}
struct MutterPlugin struct MutterPlugin
{ {
/* /*