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

gcm-xorg-config.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-xorg-config.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 37 "gcm-xorg-config.gob"

#include <time.h>
#include <unistd.h>

#line 29 "gcm-xorg-config.c"
/* self casting macros */
#define SELF(x) GCM_XORG_CONFIG(x)
#define SELF_CONST(x) GCM_XORG_CONFIG_CONST(x)
#define IS_SELF(x) GCM_IS_XORG_CONFIG(x)
#define TYPE_SELF GCM_TYPE_XORG_CONFIG
#define SELF_CLASS(x) GCM_XORG_CONFIG_CLASS(x)

#define SELF_GET_CLASS(x) GCM_XORG_CONFIG_GET_CLASS(x)

/* self typedefs */
typedef GCMXorgConfig Self;
typedef GCMXorgConfigClass SelfClass;

struct _GCMXorgConfigPrivate {
#line 44 "gcm-xorg-config.gob"
      const gchar * filename;
#line 54 "gcm-xorg-config.gob"
      XF86ConfigPtr config;
#line 48 "gcm-xorg-config.c"
};
/* here are local prototypes */
static void ___object_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
static void gcm_xorg_config_init (GCMXorgConfig * o) G_GNUC_UNUSED;
static void gcm_xorg_config_class_init (GCMXorgConfigClass * c) G_GNUC_UNUSED;

enum {
      PROP_0,
      PROP_FILENAME
};

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

/* Short form macros */
#define self_get_filename gcm_xorg_config_get_filename
#define self_new gcm_xorg_config_new
#define self_write gcm_xorg_config_write
#define self_get_devices gcm_xorg_config_get_devices
#define self_get_screens gcm_xorg_config_get_screens
#define self_get_modules gcm_xorg_config_get_modules
#define self_get_extensions gcm_xorg_config_get_extensions
GType
gcm_xorg_config_get_type (void)
{
      static GType type = 0;

      if ___GOB_UNLIKELY(type == 0) {
            static const GTypeInfo info = {
                  sizeof (GCMXorgConfigClass),
                  (GBaseInitFunc) NULL,
                  (GBaseFinalizeFunc) NULL,
                  (GClassInitFunc) gcm_xorg_config_class_init,
                  (GClassFinalizeFunc) NULL,
                  NULL /* class_data */,
                  sizeof (GCMXorgConfig),
                  0 /* n_preallocs */,
                  (GInstanceInitFunc) gcm_xorg_config_init,
                  NULL
            };

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

      return type;
}

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

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


static void
___finalize(GObject *obj_self)
{
#define __GOB_FUNCTION__ "GCM:Xorg:Config::finalize"
      GCMXorgConfig *self G_GNUC_UNUSED = GCM_XORG_CONFIG (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 55 "gcm-xorg-config.gob"
      if(self->_priv->config) { xf86freeConfig ((gpointer) self->_priv->config); self->_priv->config = NULL; }
#line 124 "gcm-xorg-config.c"
}
#undef __GOB_FUNCTION__

static void 
gcm_xorg_config_init (GCMXorgConfig * o G_GNUC_UNUSED)
{
#define __GOB_FUNCTION__ "GCM:Xorg:Config::init"
      o->_priv = G_TYPE_INSTANCE_GET_PRIVATE(o,GCM_TYPE_XORG_CONFIG,GCMXorgConfigPrivate);
}
#undef __GOB_FUNCTION__
static void 
gcm_xorg_config_class_init (GCMXorgConfigClass * c G_GNUC_UNUSED)
{
#define __GOB_FUNCTION__ "GCM:Xorg:Config::class_init"
      GObjectClass *g_object_class G_GNUC_UNUSED = (GObjectClass*) c;

      g_type_class_add_private(c,sizeof(GCMXorgConfigPrivate));

      parent_class = g_type_class_ref (G_TYPE_OBJECT);

      g_object_class->finalize = ___finalize;
      g_object_class->get_property = ___object_get_property;
    {
      GParamSpec   *param_spec;

      param_spec = g_param_spec_string
            ("filename" /* name */,
             "Filename" /* nick */,
             "Template filename" /* blurb */,
             NULL /* default_value */,
             (GParamFlags)(G_PARAM_READABLE));
      g_object_class_install_property (g_object_class,
            PROP_FILENAME,
            param_spec);
    }
}
#undef __GOB_FUNCTION__

static void
___object_get_property (GObject *object,
      guint property_id,
      GValue *VAL G_GNUC_UNUSED,
      GParamSpec *pspec G_GNUC_UNUSED)
#define __GOB_FUNCTION__ "GCM:Xorg:Config::get_property"
{
      GCMXorgConfig *self G_GNUC_UNUSED;

      self = GCM_XORG_CONFIG (object);

      switch (property_id) {
      case PROP_FILENAME:
            {
#line 51 "gcm-xorg-config.gob"

                  g_value_set_string(VAL, selfp->filename);
            
#line 181 "gcm-xorg-config.c"
            }
            break;
      default:
/* Apparently in g++ this is needed, glib is b0rk */
#ifndef __PRETTY_FUNCTION__
#  undef G_STRLOC
#  define G_STRLOC      __FILE__ ":" G_STRINGIFY (__LINE__)
#endif
            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
            break;
      }
}
#undef __GOB_FUNCTION__



#line 51 "gcm-xorg-config.gob"
gchar * 
gcm_xorg_config_get_filename (GCMXorgConfig * self)
#line 201 "gcm-xorg-config.c"
{
#define __GOB_FUNCTION__ "GCM:Xorg:Config::get_filename"
{
#line 45 "gcm-xorg-config.gob"
            gchar* val; g_object_get (G_OBJECT (self), "filename", &val, NULL); return val;
}}
#line 208 "gcm-xorg-config.c"
#undef __GOB_FUNCTION__

#line 57 "gcm-xorg-config.gob"
GCMXorgConfig * 
gcm_xorg_config_new (void)
#line 214 "gcm-xorg-config.c"
{
#define __GOB_FUNCTION__ "GCM:Xorg:Config::new"
{
#line 59 "gcm-xorg-config.gob"
      
            GCMXorgConfig * self = GET_NEW;
            
            if ((selfp->filename = xf86openConfigFile(NULL, NULL, NULL)) == NULL)
            {
                  g_object_unref(self);
                  return NULL;
            }
            
            if ((selfp->config = xf86readConfigFile()) == NULL)
            {
                  g_object_unref(self);
                  return NULL;
            }

            return self;
      }}
#line 236 "gcm-xorg-config.c"
#undef __GOB_FUNCTION__

#line 77 "gcm-xorg-config.gob"
gboolean 
gcm_xorg_config_write (GCMXorgConfig * self, gchar * filename, gchar ** backup)
#line 242 "gcm-xorg-config.c"
{
#define __GOB_FUNCTION__ "GCM:Xorg:Config::write"
#line 77 "gcm-xorg-config.gob"
      g_return_val_if_fail (self != NULL, (gboolean )0);
#line 77 "gcm-xorg-config.gob"
      g_return_val_if_fail (GCM_IS_XORG_CONFIG (self), (gboolean )0);
#line 249 "gcm-xorg-config.c"
{
#line 79 "gcm-xorg-config.gob"
      
            gchar * file, * save = NULL;
            gboolean result;
            
            file = filename ? filename : (gchar *)selfp->filename;
            
            /* If file exist backup it */
            if (g_file_test(file, G_FILE_TEST_EXISTS))
            {
                  time_t now = time(NULL);
                  struct tm * tm_now = localtime(&now);                 
                  save = g_strdup_printf("%s.gcm.%04i%02i%02i-%02i%02i", file,
                                          tm_now->tm_year + 1900, tm_now->tm_mon + 1,
                                          tm_now->tm_mday, tm_now->tm_hour, tm_now->tm_min);
                  link(file, save);
                  unlink(file);
            }
            result = xf86writeConfigFile(file, selfp->config);
            if (!result && save)
            {
                  /* Restore original file on error */
                  link(save, file);
                  unlink(save);
            }
            if (save) 
            {
                  if (result && backup) *backup = g_strdup(save);
                  g_free(save);
            }
            return result;
      }}
#line 283 "gcm-xorg-config.c"
#undef __GOB_FUNCTION__

#line 111 "gcm-xorg-config.gob"
XF86ConfDevicePtr 
gcm_xorg_config_get_devices (GCMXorgConfig * self)
#line 289 "gcm-xorg-config.c"
{
#define __GOB_FUNCTION__ "GCM:Xorg:Config::get_devices"
#line 111 "gcm-xorg-config.gob"
      g_return_val_if_fail (self != NULL, (XF86ConfDevicePtr )0);
#line 111 "gcm-xorg-config.gob"
      g_return_val_if_fail (GCM_IS_XORG_CONFIG (self), (XF86ConfDevicePtr )0);
#line 296 "gcm-xorg-config.c"
{
#line 113 "gcm-xorg-config.gob"
      
            return selfp->config->conf_device_lst;
      }}
#line 302 "gcm-xorg-config.c"
#undef __GOB_FUNCTION__

#line 117 "gcm-xorg-config.gob"
XF86ConfScreenPtr 
gcm_xorg_config_get_screens (GCMXorgConfig * self)
#line 308 "gcm-xorg-config.c"
{
#define __GOB_FUNCTION__ "GCM:Xorg:Config::get_screens"
#line 117 "gcm-xorg-config.gob"
      g_return_val_if_fail (self != NULL, (XF86ConfScreenPtr )0);
#line 117 "gcm-xorg-config.gob"
      g_return_val_if_fail (GCM_IS_XORG_CONFIG (self), (XF86ConfScreenPtr )0);
#line 315 "gcm-xorg-config.c"
{
#line 119 "gcm-xorg-config.gob"
      
            return selfp->config->conf_screen_lst;
      }}
#line 321 "gcm-xorg-config.c"
#undef __GOB_FUNCTION__

#line 123 "gcm-xorg-config.gob"
XF86ConfModulePtr 
gcm_xorg_config_get_modules (GCMXorgConfig * self)
#line 327 "gcm-xorg-config.c"
{
#define __GOB_FUNCTION__ "GCM:Xorg:Config::get_modules"
#line 123 "gcm-xorg-config.gob"
      g_return_val_if_fail (self != NULL, (XF86ConfModulePtr )0);
#line 123 "gcm-xorg-config.gob"
      g_return_val_if_fail (GCM_IS_XORG_CONFIG (self), (XF86ConfModulePtr )0);
#line 334 "gcm-xorg-config.c"
{
#line 125 "gcm-xorg-config.gob"
      
            return selfp->config->conf_modules;
      }}
#line 340 "gcm-xorg-config.c"
#undef __GOB_FUNCTION__

#line 129 "gcm-xorg-config.gob"
XF86ConfExtensionsPtr 
gcm_xorg_config_get_extensions (GCMXorgConfig * self)
#line 346 "gcm-xorg-config.c"
{
#define __GOB_FUNCTION__ "GCM:Xorg:Config::get_extensions"
#line 129 "gcm-xorg-config.gob"
      g_return_val_if_fail (self != NULL, (XF86ConfExtensionsPtr )0);
#line 129 "gcm-xorg-config.gob"
      g_return_val_if_fail (GCM_IS_XORG_CONFIG (self), (XF86ConfExtensionsPtr )0);
#line 353 "gcm-xorg-config.c"
{
#line 131 "gcm-xorg-config.gob"
      
            if (!selfp->config->conf_extensions)
                  selfp->config->conf_extensions = g_new0(XF86ConfExtensionsRec, 1);
            return selfp->config->conf_extensions;
      }}
#line 361 "gcm-xorg-config.c"
#undef __GOB_FUNCTION__

#line 138 "gcm-xorg-config.gob"

GenericListPtr
xf86RemoveListItem (GenericListPtr head, GenericListPtr item)
{
    GenericListPtr cur = head;
    GenericListPtr prev = NULL;

    while (cur)
    {
        if (cur == item)
        {
            if (prev) prev->next = item->next;
            if (head == item) head = item->next;
            break;
        }
        prev = cur;
        cur  = cur->next;
    }
    
    return head;
}

GenericListPtr
xf86ReOrderItem(GenericListPtr head,
                        GenericListPtr position,
                        GenericListPtr item)
{
      if (item)
      {
            head = xf86RemoveListItem(head, item);
            if (position)
            {
                  item->next = position->next;
                  position->next = item;
            }
            else
            {
                  item->next = head;
                  head = item;
            }
      }
      
      return head;
}

void
VErrorF(const char *f, va_list args)
{
      vfprintf(stderr, f, args);
}

void
ErrorF(const char *f, ...)
{
      va_list args;

      va_start(args, f);
      vfprintf(stderr, f, args);
      va_end(args);
}

#line 426 "gcm-xorg-config.c"

Generated by  Doxygen 1.6.0   Back to index