2008-12-17 04:33:56 -05:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2008 Intel Corp.
|
|
|
|
*
|
|
|
|
* Author: Tomas Frydrych <tf@linux.intel.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2014-01-11 20:42:06 -05:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2008-12-17 04:33:56 -05:00
|
|
|
*/
|
|
|
|
|
2011-03-05 19:29:12 -05:00
|
|
|
#include <meta/meta-plugin.h>
|
2010-10-18 13:27:14 -04:00
|
|
|
#include "meta-module.h"
|
2008-12-17 04:33:56 -05:00
|
|
|
|
|
|
|
#include <gmodule.h>
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_PATH,
|
|
|
|
};
|
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
struct _MetaModulePrivate
|
2008-12-17 04:33:56 -05:00
|
|
|
{
|
|
|
|
GModule *lib;
|
|
|
|
gchar *path;
|
|
|
|
GType plugin_type;
|
|
|
|
};
|
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
#define META_MODULE_GET_PRIVATE(obj) \
|
|
|
|
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), META_TYPE_MODULE, MetaModulePrivate))
|
2008-12-17 04:33:56 -05:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
G_DEFINE_TYPE (MetaModule, meta_module, G_TYPE_TYPE_MODULE);
|
2008-12-17 04:33:56 -05:00
|
|
|
|
|
|
|
static gboolean
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_module_load (GTypeModule *gmodule)
|
2008-12-17 04:33:56 -05:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaModulePrivate *priv = META_MODULE (gmodule)->priv;
|
|
|
|
MetaPluginVersion *info = NULL;
|
2008-12-17 04:33:56 -05:00
|
|
|
GType (*register_type) (GTypeModule *) = NULL;
|
|
|
|
|
|
|
|
if (priv->lib && priv->plugin_type)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
g_assert (priv->path);
|
|
|
|
|
|
|
|
if (!priv->lib &&
|
2009-04-07 17:07:32 -04:00
|
|
|
!(priv->lib = g_module_open (priv->path, 0)))
|
2008-12-17 04:33:56 -05:00
|
|
|
{
|
2009-01-06 06:31:45 -05:00
|
|
|
g_warning ("Could not load library [%s (%s)]",
|
|
|
|
priv->path, g_module_error ());
|
2008-12-17 04:33:56 -05:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
if (g_module_symbol (priv->lib, "meta_plugin_version",
|
2009-05-11 16:55:19 -04:00
|
|
|
(gpointer *)(void *)&info) &&
|
2010-10-18 13:27:14 -04:00
|
|
|
g_module_symbol (priv->lib, "meta_plugin_register_type",
|
2009-05-11 16:55:19 -04:00
|
|
|
(gpointer *)(void *)®ister_type) &&
|
2008-12-17 04:33:56 -05:00
|
|
|
info && register_type)
|
|
|
|
{
|
Comprehensively rename to Mutter
Code:
All references in the code not related to themes, keybindings, or
GConf were changed from 'metacity' to 'mutter'. This includes, among other
things, strings, comments, the atoms used in the message protocol, and
the envvars used for debugging. The GConf schema file was reduced to
the 3 settings new to mutter.
The overall version was brought up to 2.27 to match current gnome.
Structure:
All files named '*metacity*' were renamed '*mutter*' with appropriate
changes in the automake system. Files removed are
doc/creating_themes, src/themes, doc/metacity-theme.dtd,
metacity.doap. These files will eventually end up in an external
gnome-wm-data module.
Installation location:
On the filesystem the mutter-plugindir was change from
$(libdir)/metacity/plugins/clutter to just $(libdir)/mutter/plugins.
The mutter-plugins.pc.in reflects these changes.
Note:
mutter.desktop.in and mutter-wm.desktop both continue to have
X-GNOME-WMSettingsModule=metacity set. This allows
gnome-control-center to continue using libmetacity.so for
configuration. This is fine since most the general keybindings and wm
settings are being read from /apps/metacity/* in gconf.
2009-06-10 06:29:20 -04:00
|
|
|
if (info->version_api != MUTTER_PLUGIN_API_VERSION)
|
2008-12-17 04:33:56 -05:00
|
|
|
g_warning ("Plugin API mismatch for [%s]", priv->path);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GType plugin_type;
|
|
|
|
|
|
|
|
if (!(plugin_type = register_type (gmodule)))
|
|
|
|
{
|
|
|
|
g_warning ("Could not register type for plugin %s",
|
|
|
|
priv->path);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
priv->plugin_type = plugin_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
g_warning ("Broken plugin module [%s]", priv->path);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_module_unload (GTypeModule *gmodule)
|
2008-12-17 04:33:56 -05:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaModulePrivate *priv = META_MODULE (gmodule)->priv;
|
2008-12-17 04:33:56 -05:00
|
|
|
|
|
|
|
g_module_close (priv->lib);
|
|
|
|
|
|
|
|
priv->lib = NULL;
|
|
|
|
priv->plugin_type = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_module_dispose (GObject *object)
|
2008-12-17 04:33:56 -05:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
G_OBJECT_CLASS (meta_module_parent_class)->dispose (object);
|
2008-12-17 04:33:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_module_finalize (GObject *object)
|
2008-12-17 04:33:56 -05:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaModulePrivate *priv = META_MODULE (object)->priv;
|
2008-12-17 04:33:56 -05:00
|
|
|
|
|
|
|
g_free (priv->path);
|
|
|
|
priv->path = NULL;
|
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
G_OBJECT_CLASS (meta_module_parent_class)->finalize (object);
|
2008-12-17 04:33:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_module_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2008-12-17 04:33:56 -05:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaModulePrivate *priv = META_MODULE (object)->priv;
|
2008-12-17 04:33:56 -05:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_PATH:
|
|
|
|
g_free (priv->path);
|
|
|
|
priv->path = g_value_dup_string (value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_module_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2008-12-17 04:33:56 -05:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaModulePrivate *priv = META_MODULE (object)->priv;
|
2008-12-17 04:33:56 -05:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_PATH:
|
|
|
|
g_value_set_string (value, priv->path);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_module_class_init (MetaModuleClass *klass)
|
2008-12-17 04:33:56 -05:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
GTypeModuleClass *gmodule_class = G_TYPE_MODULE_CLASS (klass);
|
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
gobject_class->finalize = meta_module_finalize;
|
|
|
|
gobject_class->dispose = meta_module_dispose;
|
|
|
|
gobject_class->set_property = meta_module_set_property;
|
|
|
|
gobject_class->get_property = meta_module_get_property;
|
2008-12-17 04:33:56 -05:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
gmodule_class->load = meta_module_load;
|
|
|
|
gmodule_class->unload = meta_module_unload;
|
2008-12-17 04:33:56 -05:00
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_PATH,
|
|
|
|
g_param_spec_string ("path",
|
|
|
|
"Path",
|
|
|
|
"Load path",
|
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
g_type_class_add_private (gobject_class, sizeof (MetaModulePrivate));
|
2008-12-17 04:33:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_module_init (MetaModule *self)
|
2008-12-17 04:33:56 -05:00
|
|
|
{
|
2013-09-03 16:02:37 -04:00
|
|
|
self->priv = META_MODULE_GET_PRIVATE (self);
|
2008-12-17 04:33:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
GType
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_module_get_plugin_type (MetaModule *module)
|
2008-12-17 04:33:56 -05:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaModulePrivate *priv = META_MODULE (module)->priv;
|
2008-12-17 04:33:56 -05:00
|
|
|
|
|
|
|
return priv->plugin_type;
|
|
|
|
}
|
|
|
|
|