/* $Id: module.h,v 1.5 2007/08/27 06:56:47 mgdepalma Exp $
 *
 * Copyright (C) 2007 Softcraft Impresa, LLC <info@softcraft.org>
 *
 * 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; You may only use version 2 of the License,
 * you have no option to use any other 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
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef MODULE_H
#define MODULE_H

#include <dirent.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <gmodule.h>
#include <gtk/gtk.h>

G_BEGIN_DECLS

/* Module registry bits and mask. */
#define MODULI_SPACE_ALL      0xffff
#define MODULI_SPACE_ADMIN    0x1000
#define MODULI_SPACE_DESKTOP  0x0100
#define MODULI_SPACE_TASKBAR  0x0010
#define MODULI_SPACE_SERVICE  0x0001

/* Data structures */
typedef enum   _modulus_place ModulusPlace;
typedef struct _modulus       Modulus;

enum _modulus_place {
  ADD_TO_CONTAINER,
  PACK_START,
  PACK_END,
  SCREEN,
  NONE
};

struct _modulus
{
  GModule *module;		/* struct _GModule from glib */
  GtkWidget *widget;		/* applet primary widget object */
  ModulusPlace place; 		/* add to container, pack, or none */

  const gchar *name;		/* name by which we are identified */
  const gchar *icon;		/* icon image basename or full path */
  const gchar *description;	/* [optional] narrative description */
  const gchar *release;		/* [optional] version release string */
  guint space;			/* [required]_moduli_space membership */

  void (*module_init) (Modulus *self, gpointer data);  /* [required] */
  void (*module_open) (Modulus *self, gpointer data);  /* [optional] */
  void (*module_close)(Modulus *self, gpointer data);  /* [optional] */
};

/* Methods exported by implementation */
Modulus *module_load(const gchar *file, guint space, gpointer data);
Modulus *module_search(GList *moduli, const gchar *name);

GList *moduli_remove(GList *moduli, Modulus *applet);
GList *moduli_space(GList *moduli,
                    const gchar *path,
                    guint space,
                    gpointer data);

G_END_DECLS

#endif /* </MODULE_H */
