Logo Search packages:      
Sourcecode: gnome-compiz-manager version File versions

gcm-plugin-loader.c

/* Generated by GOB (v2.0.14)   (do not edit directly) */

/* End world hunger, donate to the World Food Programme, http://www.wfp.org */

#define GOB_VERSION_MAJOR 2
#define GOB_VERSION_MINOR 0
#define GOB_VERSION_PATCHLEVEL 14

#define selfp (self->_priv)

#include <string.h> /* memset() */

#include "gcm-plugin-loader.h"

#ifdef G_LIKELY
#define ___GOB_LIKELY(expr) G_LIKELY(expr)
#define ___GOB_UNLIKELY(expr) G_UNLIKELY(expr)
#else /* ! G_LIKELY */
#define ___GOB_LIKELY(expr) (expr)
#define ___GOB_UNLIKELY(expr) (expr)
#endif /* G_LIKELY */

#line 25 "gcm-plugin-loader.gob"

#include "gcm-plugin.h"

#line 28 "gcm-plugin-loader.c"
/* self casting macros */
#define SELF(x) GCM_PLUGIN_LOADER(x)
#define SELF_CONST(x) GCM_PLUGIN_LOADER_CONST(x)
#define IS_SELF(x) GCM_IS_PLUGIN_LOADER(x)
#define TYPE_SELF GCM_TYPE_PLUGIN_LOADER
#define SELF_CLASS(x) GCM_PLUGIN_LOADER_CLASS(x)

#define SELF_GET_CLASS(x) GCM_PLUGIN_LOADER_GET_CLASS(x)

/* self typedefs */
typedef GCMPluginLoader Self;
typedef GCMPluginLoaderClass SelfClass;

struct _GCMPluginLoaderPrivate {
#line 31 "gcm-plugin-loader.gob"
      gchar ** pluginspath;
#line 45 "gcm-plugin-loader.c"
};
/* here are local prototypes */
static void gcm_plugin_loader_init (GCMPluginLoader * o) G_GNUC_UNUSED;
static void gcm_plugin_loader_class_init (GCMPluginLoaderClass * c) G_GNUC_UNUSED;

/* pointer to the class of our parent */
static GObjectClass *parent_class = NULL;

/* Short form macros */
#define self_parse_path gcm_plugin_loader_parse_path
#define self_get_type_plugin gcm_plugin_loader_get_type_plugin
GType
gcm_plugin_loader_get_type (void)
{
      static GType type = 0;

      if ___GOB_UNLIKELY(type == 0) {
            static const GTypeInfo info = {
                  sizeof (GCMPluginLoaderClass),
                  (GBaseInitFunc) NULL,
                  (GBaseFinalizeFunc) NULL,
                  (GClassInitFunc) gcm_plugin_loader_class_init,
                  (GClassFinalizeFunc) NULL,
                  NULL /* class_data */,
                  sizeof (GCMPluginLoader),
                  0 /* n_preallocs */,
                  (GInstanceInitFunc) gcm_plugin_loader_init,
                  NULL
            };

            type = g_type_register_static (G_TYPE_OBJECT, "GCMPluginLoader", &info, (GTypeFlags)0);
      }

      return type;
}

/* a macro for creating a new object of our type */
#define GET_NEW ((GCMPluginLoader *)g_object_new(gcm_plugin_loader_get_type(), NULL))

/* a function for creating a new object of our type */
#include <stdarg.h>
static GCMPluginLoader * GET_NEW_VARG (const char *first, ...) G_GNUC_UNUSED;
static GCMPluginLoader *
GET_NEW_VARG (const char *first, ...)
{
      GCMPluginLoader *ret;
      va_list ap;
      va_start (ap, first);
      ret = (GCMPluginLoader *)g_object_new_valist (gcm_plugin_loader_get_type (), first, ap);
      va_end (ap);
      return ret;
}


static void
___finalize(GObject *obj_self)
{
#define __GOB_FUNCTION__ "GCM:Plugin:Loader::finalize"
      GCMPluginLoader *self G_GNUC_UNUSED = GCM_PLUGIN_LOADER (obj_self);
      gpointer priv G_GNUC_UNUSED = self->_priv;
      if(G_OBJECT_CLASS(parent_class)->finalize) \
            (* G_OBJECT_CLASS(parent_class)->finalize)(obj_self);
#line 32 "gcm-plugin-loader.gob"
      if(self->_priv->pluginspath) { g_strfreev ((gpointer) self->_priv->pluginspath); self->_priv->pluginspath = NULL; }
#line 110 "gcm-plugin-loader.c"
#line 34 "gcm-plugin-loader.gob"
      if(self->plugins) { g_hash_table_destroy ((gpointer) self->plugins); self->plugins = NULL; }
#line 113 "gcm-plugin-loader.c"
}
#undef __GOB_FUNCTION__

static void 
gcm_plugin_loader_init (GCMPluginLoader * o G_GNUC_UNUSED)
{
#define __GOB_FUNCTION__ "GCM:Plugin:Loader::init"
      o->_priv = G_TYPE_INSTANCE_GET_PRIVATE(o,GCM_TYPE_PLUGIN_LOADER,GCMPluginLoaderPrivate);
#line 25 "gcm-plugin-loader.gob"
      o->_priv->pluginspath = NULL;
#line 124 "gcm-plugin-loader.c"
}
#undef __GOB_FUNCTION__
static void 
gcm_plugin_loader_class_init (GCMPluginLoaderClass * c G_GNUC_UNUSED)
{
#define __GOB_FUNCTION__ "GCM:Plugin:Loader::class_init"
      GObjectClass *g_object_class G_GNUC_UNUSED = (GObjectClass*) c;

      g_type_class_add_private(c,sizeof(GCMPluginLoaderPrivate));

      parent_class = g_type_class_ref (G_TYPE_OBJECT);

      g_object_class->finalize = ___finalize;
}
#undef __GOB_FUNCTION__



#line 36 "gcm-plugin-loader.gob"
gboolean 
gcm_plugin_loader_parse_path (GCMPluginLoader * self, gchar * path)
#line 146 "gcm-plugin-loader.c"
{
#define __GOB_FUNCTION__ "GCM:Plugin:Loader::parse_path"
#line 36 "gcm-plugin-loader.gob"
      g_return_val_if_fail (self != NULL, (gboolean )FALSE);
#line 36 "gcm-plugin-loader.gob"
      g_return_val_if_fail (GCM_IS_PLUGIN_LOADER (self), (gboolean )FALSE);
#line 36 "gcm-plugin-loader.gob"
      g_return_val_if_fail (path != NULL, (gboolean )FALSE);
#line 155 "gcm-plugin-loader.c"
{
#line 38 "gcm-plugin-loader.gob"
      
            GDir * plugins_dir;
            gchar * filename;
            gint cpt;
            
            if (!selfp->pluginspath)
            {
                  selfp->pluginspath = g_strsplit(path, ";", -1);
                  for (cpt = 0; selfp->pluginspath[cpt] != NULL; cpt++)
                  {
                        if ((plugins_dir = g_dir_open(selfp->pluginspath[cpt], 0, NULL)) == NULL)
                        {
                              return FALSE;
                        }
                        while ((filename = (gchar *)g_dir_read_name(plugins_dir)) != NULL)
                        {
                              if (g_pattern_match_simple("*.plugin", filename))
                              {
                                    GCMPlugin * plugin;
                                    gchar * file = g_build_filename(selfp->pluginspath[cpt], 
                                                                                    filename, NULL);
                                    
                                    if ((plugin = gcm_plugin_new(file)) != NULL)
                                    {
                                          if (!self->plugins) 
                                                self->plugins = g_hash_table_new_full(g_str_hash, 
                                                                                                        g_str_equal, 
                                                                                                        g_free, 
                                                                                                        g_object_unref);
                                          g_hash_table_insert(self->plugins, plugin->name, 
                                                                        plugin);
                                    }
                                    g_free(file);
                              }
                        }
                        g_dir_close(plugins_dir);
                  }
            }
            return TRUE;
      }}
#line 198 "gcm-plugin-loader.c"
#undef __GOB_FUNCTION__

#line 79 "gcm-plugin-loader.gob"
GType 
gcm_plugin_loader_get_type_plugin (GCMPluginLoader * self, gchar * plugin_name)
#line 204 "gcm-plugin-loader.c"
{
#define __GOB_FUNCTION__ "GCM:Plugin:Loader::get_type_plugin"
#line 79 "gcm-plugin-loader.gob"
      g_return_val_if_fail (self != NULL, (GType )0);
#line 79 "gcm-plugin-loader.gob"
      g_return_val_if_fail (GCM_IS_PLUGIN_LOADER (self), (GType )0);
#line 79 "gcm-plugin-loader.gob"
      g_return_val_if_fail (plugin_name != NULL, (GType )0);
#line 213 "gcm-plugin-loader.c"
{
#line 81 "gcm-plugin-loader.gob"
      
            GCMPlugin * plugin;
            
            if ((plugin = g_hash_table_lookup(self->plugins, plugin_name)) == NULL)
            {
                  return 0;
            }
            
            return gcm_plugin_get_type_object(plugin);
      }}
#line 226 "gcm-plugin-loader.c"
#undef __GOB_FUNCTION__

Generated by  Doxygen 1.6.0   Back to index