Logo Search packages:      
Sourcecode: caribou version File versions  Download package

key-model.c

/* key-model.c generated by valac 0.13.3, the Vala compiler
 * generated from key-model.vala, do not modify */


#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <gdk/gdk.h>
#include <gee.h>


#define CARIBOU_TYPE_ISCANNABLE_ITEM (caribou_iscannable_item_get_type ())
#define CARIBOU_ISCANNABLE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_ISCANNABLE_ITEM, CaribouIScannableItem))
#define CARIBOU_IS_ISCANNABLE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_ISCANNABLE_ITEM))
#define CARIBOU_ISCANNABLE_ITEM_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), CARIBOU_TYPE_ISCANNABLE_ITEM, CaribouIScannableItemIface))

typedef struct _CaribouIScannableItem CaribouIScannableItem;
typedef struct _CaribouIScannableItemIface CaribouIScannableItemIface;

#define CARIBOU_TYPE_IKEYBOARD_OBJECT (caribou_ikeyboard_object_get_type ())
#define CARIBOU_IKEYBOARD_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_IKEYBOARD_OBJECT, CaribouIKeyboardObject))
#define CARIBOU_IS_IKEYBOARD_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_IKEYBOARD_OBJECT))
#define CARIBOU_IKEYBOARD_OBJECT_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), CARIBOU_TYPE_IKEYBOARD_OBJECT, CaribouIKeyboardObjectIface))

typedef struct _CaribouIKeyboardObject CaribouIKeyboardObject;
typedef struct _CaribouIKeyboardObjectIface CaribouIKeyboardObjectIface;

#define CARIBOU_TYPE_KEY_MODEL (caribou_key_model_get_type ())
#define CARIBOU_KEY_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_KEY_MODEL, CaribouKeyModel))
#define CARIBOU_KEY_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_KEY_MODEL, CaribouKeyModelClass))
#define CARIBOU_IS_KEY_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_KEY_MODEL))
#define CARIBOU_IS_KEY_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_KEY_MODEL))
#define CARIBOU_KEY_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_KEY_MODEL, CaribouKeyModelClass))

typedef struct _CaribouKeyModel CaribouKeyModel;
typedef struct _CaribouKeyModelClass CaribouKeyModelClass;
typedef struct _CaribouKeyModelPrivate CaribouKeyModelPrivate;

#define CARIBOU_TYPE_MODIFIER_STATE (caribou_modifier_state_get_type ())

#define CARIBOU_TYPE_XADAPTER (caribou_xadapter_get_type ())
#define CARIBOU_XADAPTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_XADAPTER, CaribouXAdapter))
#define CARIBOU_XADAPTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_XADAPTER, CaribouXAdapterClass))
#define CARIBOU_IS_XADAPTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_XADAPTER))
#define CARIBOU_IS_XADAPTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_XADAPTER))
#define CARIBOU_XADAPTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_XADAPTER, CaribouXAdapterClass))

typedef struct _CaribouXAdapter CaribouXAdapter;
typedef struct _CaribouXAdapterClass CaribouXAdapterClass;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define CARIBOU_TYPE_MODIFIER_MAP_ENTRY (caribou_modifier_map_entry_get_type ())
typedef struct _CaribouModifierMapEntry CaribouModifierMapEntry;

struct _CaribouIScannableItemIface {
      GTypeInterface parent_iface;
      gboolean (*get_scan_stepping) (CaribouIScannableItem* self);
      void (*set_scan_stepping) (CaribouIScannableItem* self, gboolean value);
      gboolean (*get_scan_selected) (CaribouIScannableItem* self);
      void (*set_scan_selected) (CaribouIScannableItem* self, gboolean value);
};

struct _CaribouIKeyboardObjectIface {
      GTypeInterface parent_iface;
      CaribouIKeyboardObject** (*get_children) (CaribouIKeyboardObject* self, int* result_length1);
      CaribouKeyModel** (*get_keys) (CaribouIKeyboardObject* self, int* result_length1);
};

typedef enum  {
      CARIBOU_MODIFIER_STATE_NONE,
      CARIBOU_MODIFIER_STATE_LATCHED,
      CARIBOU_MODIFIER_STATE_LOCKED
} CaribouModifierState;

struct _CaribouKeyModel {
      GObject parent_instance;
      CaribouKeyModelPrivate * priv;
      CaribouModifierState modifier_state;
};

struct _CaribouKeyModelClass {
      GObjectClass parent_class;
};

00089 struct _CaribouKeyModelPrivate {
      gchar* _align;
      gdouble _width;
      gchar* _toggle;
      GdkModifierType mod_mask;
      gboolean _show_subkeys;
      gchar* _name;
      guint _keyval;
      gboolean _scan_stepping;
      gboolean _scan_selected;
      guint hold_tid;
      CaribouXAdapter* xadapter;
      GeeArrayList* extended_keys;
};

struct _CaribouModifierMapEntry {
      gchar* name;
      GdkModifierType mask;
};


static gpointer caribou_key_model_parent_class = NULL;
static CaribouIScannableItemIface* caribou_key_model_caribou_iscannable_item_parent_iface = NULL;
static CaribouIKeyboardObjectIface* caribou_key_model_caribou_ikeyboard_object_parent_iface = NULL;

GType caribou_iscannable_item_get_type (void) G_GNUC_CONST;
GType caribou_key_model_get_type (void) G_GNUC_CONST;
GType caribou_ikeyboard_object_get_type (void) G_GNUC_CONST;
GType caribou_modifier_state_get_type (void) G_GNUC_CONST;
GType caribou_xadapter_get_type (void) G_GNUC_CONST;
#define CARIBOU_KEY_MODEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CARIBOU_TYPE_KEY_MODEL, CaribouKeyModelPrivate))
enum  {
      CARIBOU_KEY_MODEL_DUMMY_PROPERTY,
      CARIBOU_KEY_MODEL_ALIGN,
      CARIBOU_KEY_MODEL_WIDTH,
      CARIBOU_KEY_MODEL_TOGGLE,
      CARIBOU_KEY_MODEL_IS_MODIFIER,
      CARIBOU_KEY_MODEL_SHOW_SUBKEYS,
      CARIBOU_KEY_MODEL_NAME,
      CARIBOU_KEY_MODEL_KEYVAL,
      CARIBOU_KEY_MODEL_SCAN_STEPPING,
      CARIBOU_KEY_MODEL_SCAN_SELECTED
};
GType caribou_modifier_map_entry_get_type (void) G_GNUC_CONST;
CaribouModifierMapEntry* caribou_modifier_map_entry_dup (const CaribouModifierMapEntry* self);
void caribou_modifier_map_entry_free (CaribouModifierMapEntry* self);
void caribou_modifier_map_entry_copy (const CaribouModifierMapEntry* self, CaribouModifierMapEntry* dest);
void caribou_modifier_map_entry_destroy (CaribouModifierMapEntry* self);
CaribouKeyModel* caribou_key_model_new (const gchar* name);
CaribouKeyModel* caribou_key_model_construct (GType object_type, const gchar* name);
static void caribou_key_model_set_name (CaribouKeyModel* self, const gchar* value);
static void caribou_key_model_set_keyval (CaribouKeyModel* self, guint value);
CaribouXAdapter* caribou_xadapter_get_default (void);
void caribou_key_model_add_subkey (CaribouKeyModel* self, CaribouKeyModel* key);
static void caribou_key_model_on_subkey_clicked (CaribouKeyModel* self, CaribouKeyModel* key);
static void _caribou_key_model_on_subkey_clicked_caribou_ikeyboard_object_key_clicked (CaribouIKeyboardObject* _sender, CaribouKeyModel* key, gpointer self);
static void caribou_key_model_set_show_subkeys (CaribouKeyModel* self, gboolean value);
void caribou_key_model_press (CaribouKeyModel* self);
gboolean caribou_key_model_get_is_modifier (CaribouKeyModel* self);
void caribou_xadapter_mod_lock (CaribouXAdapter* self, guint mask);
static gboolean caribou_key_model_on_key_held (CaribouKeyModel* self);
static gboolean _caribou_key_model_on_key_held_gsource_func (gpointer self);
void caribou_key_model_release (CaribouKeyModel* self);
void caribou_xadapter_mod_unlock (CaribouXAdapter* self, guint mask);
guint caribou_key_model_get_keyval (CaribouKeyModel* self);
void caribou_xadapter_keyval_press (CaribouXAdapter* self, guint keyval);
void caribou_xadapter_keyval_release (CaribouXAdapter* self, guint keyval);
CaribouKeyModel** caribou_key_model_get_extended_keys (CaribouKeyModel* self, int* result_length1);
static CaribouKeyModel** caribou_key_model_real_get_keys (CaribouIKeyboardObject* base, int* result_length1);
static CaribouIKeyboardObject** caribou_key_model_real_get_children (CaribouIKeyboardObject* base, int* result_length1);
void caribou_key_model_activate (CaribouKeyModel* self);
static gboolean __lambda0_ (CaribouKeyModel* self);
static gboolean ___lambda0__gsource_func (gpointer self);
const gchar* caribou_key_model_get_align (CaribouKeyModel* self);
void caribou_key_model_set_align (CaribouKeyModel* self, const gchar* value);
gdouble caribou_key_model_get_width (CaribouKeyModel* self);
void caribou_key_model_set_width (CaribouKeyModel* self, gdouble value);
const gchar* caribou_key_model_get_toggle (CaribouKeyModel* self);
void caribou_key_model_set_toggle (CaribouKeyModel* self, const gchar* value);
void caribou_key_model_set_is_modifier (CaribouKeyModel* self, gboolean value);
gboolean caribou_key_model_get_show_subkeys (CaribouKeyModel* self);
const gchar* caribou_key_model_get_name (CaribouKeyModel* self);
static void caribou_key_model_finalize (GObject* obj);
gboolean caribou_iscannable_item_get_scan_stepping (CaribouIScannableItem* self);
gboolean caribou_iscannable_item_get_scan_selected (CaribouIScannableItem* self);
static void _vala_caribou_key_model_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
void caribou_iscannable_item_set_scan_stepping (CaribouIScannableItem* self, gboolean value);
void caribou_iscannable_item_set_scan_selected (CaribouIScannableItem* self, gboolean value);
static void _vala_caribou_key_model_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);

static const CaribouModifierMapEntry CARIBOU_KEY_MODEL_mod_map[3] = {{"Control_L", GDK_CONTROL_MASK}, {"Alt_L", GDK_MOD1_MASK}, {NULL, 0}};

CaribouKeyModel* caribou_key_model_construct (GType object_type, const gchar* name) {
      CaribouKeyModel * self = NULL;
      const gchar* _tmp0_;
      gint i;
      GdkModifierType _tmp17_;
      CaribouXAdapter* _tmp20_ = NULL;
      GeeArrayList* _tmp21_;
      g_return_val_if_fail (name != NULL, NULL);
      self = (CaribouKeyModel*) g_object_new (object_type, NULL);
      _tmp0_ = name;
      caribou_key_model_set_name (self, _tmp0_);
      self->priv->mod_mask = (GdkModifierType) 0;
      i = 0;
      {
            gint _tmp1_;
            CaribouModifierMapEntry _tmp2_;
            CaribouModifierMapEntry _tmp3_ = {0};
            CaribouModifierMapEntry entry;
            _tmp1_ = i;
            _tmp2_ = CARIBOU_KEY_MODEL_mod_map[_tmp1_];
            caribou_modifier_map_entry_copy (&_tmp2_, &_tmp3_);
            entry = _tmp3_;
            {
                  gboolean _tmp4_;
                  _tmp4_ = TRUE;
                  while (TRUE) {
                        gboolean _tmp5_;
                        CaribouModifierMapEntry _tmp10_;
                        const gchar* _tmp11_;
                        const gchar* _tmp12_;
                        CaribouModifierMapEntry _tmp13_;
                        const gchar* _tmp14_;
                        _tmp5_ = _tmp4_;
                        if (!_tmp5_) {
                              gint _tmp6_;
                              gint _tmp7_;
                              CaribouModifierMapEntry _tmp8_;
                              CaribouModifierMapEntry _tmp9_ = {0};
                              _tmp6_ = i;
                              i = _tmp6_ + 1;
                              _tmp7_ = i;
                              _tmp8_ = CARIBOU_KEY_MODEL_mod_map[_tmp7_];
                              caribou_modifier_map_entry_copy (&_tmp8_, &_tmp9_);
                              caribou_modifier_map_entry_destroy (&entry);
                              entry = _tmp9_;
                        }
                        _tmp4_ = FALSE;
                        _tmp10_ = entry;
                        _tmp11_ = _tmp10_.name;
                        if (!(_tmp11_ != NULL)) {
                              break;
                        }
                        _tmp12_ = name;
                        _tmp13_ = entry;
                        _tmp14_ = _tmp13_.name;
                        if (g_strcmp0 (_tmp12_, _tmp14_) == 0) {
                              CaribouModifierMapEntry _tmp15_;
                              GdkModifierType _tmp16_;
                              _tmp15_ = entry;
                              _tmp16_ = _tmp15_.mask;
                              self->priv->mod_mask = _tmp16_;
                        }
                  }
            }
            caribou_modifier_map_entry_destroy (&entry);
      }
      _tmp17_ = self->priv->mod_mask;
      if (_tmp17_ == 0) {
            const gchar* _tmp18_;
            guint _tmp19_ = 0U;
            _tmp18_ = name;
            _tmp19_ = gdk_keyval_from_name (_tmp18_);
            caribou_key_model_set_keyval (self, _tmp19_);
      }
      _tmp20_ = caribou_xadapter_get_default ();
      _g_object_unref0 (self->priv->xadapter);
      self->priv->xadapter = _tmp20_;
      _tmp21_ = gee_array_list_new (CARIBOU_TYPE_KEY_MODEL, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL);
      _g_object_unref0 (self->priv->extended_keys);
      self->priv->extended_keys = _tmp21_;
      return self;
}


CaribouKeyModel* caribou_key_model_new (const gchar* name) {
      return caribou_key_model_construct (CARIBOU_TYPE_KEY_MODEL, name);
}


static void _caribou_key_model_on_subkey_clicked_caribou_ikeyboard_object_key_clicked (CaribouIKeyboardObject* _sender, CaribouKeyModel* key, gpointer self) {
      caribou_key_model_on_subkey_clicked (self, key);
}


void caribou_key_model_add_subkey (CaribouKeyModel* self, CaribouKeyModel* key) {
      CaribouKeyModel* _tmp0_;
      GeeArrayList* _tmp1_;
      CaribouKeyModel* _tmp2_;
      g_return_if_fail (self != NULL);
      g_return_if_fail (key != NULL);
      _tmp0_ = key;
      g_signal_connect_object ((CaribouIKeyboardObject*) _tmp0_, "key-clicked", (GCallback) _caribou_key_model_on_subkey_clicked_caribou_ikeyboard_object_key_clicked, self, 0);
      _tmp1_ = self->priv->extended_keys;
      _tmp2_ = key;
      gee_abstract_collection_add ((GeeAbstractCollection*) _tmp1_, _tmp2_);
}


static void caribou_key_model_on_subkey_clicked (CaribouKeyModel* self, CaribouKeyModel* key) {
      CaribouKeyModel* _tmp0_;
      g_return_if_fail (self != NULL);
      g_return_if_fail (key != NULL);
      _tmp0_ = key;
      g_signal_emit_by_name ((CaribouIKeyboardObject*) self, "key-clicked", _tmp0_);
      caribou_key_model_set_show_subkeys (self, FALSE);
}


static gboolean _caribou_key_model_on_key_held_gsource_func (gpointer self) {
      gboolean result;
      result = caribou_key_model_on_key_held (self);
      return result;
}


void caribou_key_model_press (CaribouKeyModel* self) {
      gboolean _tmp0_;
      gboolean _tmp1_;
      guint _tmp5_ = 0U;
      g_return_if_fail (self != NULL);
      _tmp0_ = caribou_key_model_get_is_modifier (self);
      _tmp1_ = _tmp0_;
      if (_tmp1_) {
            CaribouModifierState _tmp2_;
            _tmp2_ = self->modifier_state;
            if (_tmp2_ == CARIBOU_MODIFIER_STATE_NONE) {
                  CaribouXAdapter* _tmp3_;
                  GdkModifierType _tmp4_;
                  self->modifier_state = CARIBOU_MODIFIER_STATE_LATCHED;
                  _tmp3_ = self->priv->xadapter;
                  _tmp4_ = self->priv->mod_mask;
                  caribou_xadapter_mod_lock (_tmp3_, (guint) _tmp4_);
            } else {
                  self->modifier_state = CARIBOU_MODIFIER_STATE_NONE;
            }
      }
      _tmp5_ = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 1000, _caribou_key_model_on_key_held_gsource_func, g_object_ref (self), g_object_unref);
      self->priv->hold_tid = _tmp5_;
      g_signal_emit_by_name ((CaribouIKeyboardObject*) self, "key-pressed", self);
}


void caribou_key_model_release (CaribouKeyModel* self) {
      guint _tmp0_;
      gboolean _tmp2_;
      gboolean _tmp3_;
      guint _tmp7_;
      guint _tmp12_;
      g_return_if_fail (self != NULL);
      _tmp0_ = self->priv->hold_tid;
      if (_tmp0_ != ((guint) 0)) {
            guint _tmp1_;
            _tmp1_ = self->priv->hold_tid;
            g_source_remove (_tmp1_);
      }
      _tmp2_ = caribou_key_model_get_is_modifier (self);
      _tmp3_ = _tmp2_;
      if (_tmp3_) {
            CaribouModifierState _tmp4_;
            _tmp4_ = self->modifier_state;
            if (_tmp4_ == CARIBOU_MODIFIER_STATE_NONE) {
                  CaribouXAdapter* _tmp5_;
                  GdkModifierType _tmp6_;
                  _tmp5_ = self->priv->xadapter;
                  _tmp6_ = self->priv->mod_mask;
                  caribou_xadapter_mod_unlock (_tmp5_, (guint) _tmp6_);
            } else {
                  return;
            }
      }
      _tmp7_ = self->priv->_keyval;
      if (_tmp7_ != ((guint) 0)) {
            CaribouXAdapter* _tmp8_;
            guint _tmp9_;
            CaribouXAdapter* _tmp10_;
            guint _tmp11_;
            _tmp8_ = self->priv->xadapter;
            _tmp9_ = self->priv->_keyval;
            caribou_xadapter_keyval_press (_tmp8_, _tmp9_);
            _tmp10_ = self->priv->xadapter;
            _tmp11_ = self->priv->_keyval;
            caribou_xadapter_keyval_release (_tmp10_, _tmp11_);
      }
      g_signal_emit_by_name ((CaribouIKeyboardObject*) self, "key-released", self);
      _tmp12_ = self->priv->hold_tid;
      if (_tmp12_ != ((guint) 0)) {
            g_signal_emit_by_name ((CaribouIKeyboardObject*) self, "key-clicked", self);
            self->priv->hold_tid = (guint) 0;
      } else {
            g_signal_emit_by_name (self, "key-hold-end");
      }
}


static gboolean caribou_key_model_on_key_held (CaribouKeyModel* self) {
      gboolean result = FALSE;
      GeeArrayList* _tmp0_;
      gint _tmp1_;
      gint _tmp2_;
      gboolean _tmp3_ = FALSE;
      gboolean _tmp4_;
      gboolean _tmp5_;
      gboolean _tmp7_;
      g_return_val_if_fail (self != NULL, FALSE);
      self->priv->hold_tid = (guint) 0;
      _tmp0_ = self->priv->extended_keys;
      _tmp1_ = gee_collection_get_size ((GeeCollection*) _tmp0_);
      _tmp2_ = _tmp1_;
      if (_tmp2_ != 0) {
            caribou_key_model_set_show_subkeys (self, TRUE);
      }
      _tmp4_ = caribou_key_model_get_is_modifier (self);
      _tmp5_ = _tmp4_;
      if (_tmp5_) {
            CaribouModifierState _tmp6_;
            _tmp6_ = self->modifier_state;
            _tmp3_ = _tmp6_ == CARIBOU_MODIFIER_STATE_LATCHED;
      } else {
            _tmp3_ = FALSE;
      }
      _tmp7_ = _tmp3_;
      if (_tmp7_) {
            self->modifier_state = CARIBOU_MODIFIER_STATE_LOCKED;
      }
      g_signal_emit_by_name (self, "key-hold");
      result = FALSE;
      return result;
}


CaribouKeyModel** caribou_key_model_get_extended_keys (CaribouKeyModel* self, int* result_length1) {
      CaribouKeyModel** result = NULL;
      GeeArrayList* _tmp0_;
      gint _tmp1_ = 0;
      gpointer* _tmp2_ = NULL;
      CaribouKeyModel** _tmp3_;
      gint _tmp3__length1;
      g_return_val_if_fail (self != NULL, NULL);
      _tmp0_ = self->priv->extended_keys;
      _tmp2_ = gee_abstract_collection_to_array ((GeeAbstractCollection*) _tmp0_, &_tmp1_);
      _tmp3_ = (CaribouKeyModel**) _tmp2_;
      _tmp3__length1 = _tmp1_;
      if (result_length1) {
            *result_length1 = _tmp3__length1;
      }
      result = _tmp3_;
      return result;
}


static CaribouKeyModel** caribou_key_model_real_get_keys (CaribouIKeyboardObject* base, int* result_length1) {
      CaribouKeyModel * self;
      CaribouKeyModel** result = NULL;
      GeeArrayList* _tmp0_;
      GeeArrayList* all_keys;
      GeeArrayList* _tmp1_;
      gint _tmp2_ = 0;
      gpointer* _tmp3_ = NULL;
      CaribouKeyModel** _tmp4_;
      gint _tmp4__length1;
      self = (CaribouKeyModel*) base;
      _tmp0_ = gee_array_list_new (CARIBOU_TYPE_KEY_MODEL, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL);
      all_keys = _tmp0_;
      gee_abstract_collection_add ((GeeAbstractCollection*) all_keys, self);
      _tmp1_ = self->priv->extended_keys;
      gee_abstract_collection_add_all ((GeeAbstractCollection*) all_keys, (GeeCollection*) _tmp1_);
      _tmp3_ = gee_abstract_collection_to_array ((GeeAbstractCollection*) all_keys, &_tmp2_);
      _tmp4_ = (CaribouKeyModel**) _tmp3_;
      _tmp4__length1 = _tmp2_;
      if (result_length1) {
            *result_length1 = _tmp4__length1;
      }
      result = _tmp4_;
      _g_object_unref0 (all_keys);
      return result;
}


static CaribouIKeyboardObject** caribou_key_model_real_get_children (CaribouIKeyboardObject* base, int* result_length1) {
      CaribouKeyModel * self;
      CaribouIKeyboardObject** result = NULL;
      GeeArrayList* _tmp0_;
      gint _tmp1_ = 0;
      gpointer* _tmp2_ = NULL;
      CaribouIKeyboardObject** _tmp3_;
      gint _tmp3__length1;
      self = (CaribouKeyModel*) base;
      _tmp0_ = self->priv->extended_keys;
      _tmp2_ = gee_abstract_collection_to_array ((GeeAbstractCollection*) _tmp0_, &_tmp1_);
      _tmp3_ = (CaribouIKeyboardObject**) _tmp2_;
      _tmp3__length1 = _tmp1_;
      if (result_length1) {
            *result_length1 = _tmp3__length1;
      }
      result = _tmp3_;
      return result;
}


static gboolean __lambda0_ (CaribouKeyModel* self) {
      gboolean result = FALSE;
      caribou_key_model_release (self);
      result = FALSE;
      return result;
}


static gboolean ___lambda0__gsource_func (gpointer self) {
      gboolean result;
      result = __lambda0_ (self);
      return result;
}


void caribou_key_model_activate (CaribouKeyModel* self) {
      g_return_if_fail (self != NULL);
      caribou_key_model_press (self);
      g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 200, ___lambda0__gsource_func, g_object_ref (self), g_object_unref);
}


const gchar* caribou_key_model_get_align (CaribouKeyModel* self) {
      const gchar* result;
      const gchar* _tmp0_;
      g_return_val_if_fail (self != NULL, NULL);
      _tmp0_ = self->priv->_align;
      result = _tmp0_;
      return result;
}


void caribou_key_model_set_align (CaribouKeyModel* self, const gchar* value) {
      const gchar* _tmp0_;
      gchar* _tmp1_;
      g_return_if_fail (self != NULL);
      _tmp0_ = value;
      _tmp1_ = g_strdup (_tmp0_);
      _g_free0 (self->priv->_align);
      self->priv->_align = _tmp1_;
      g_object_notify ((GObject *) self, "align");
}


gdouble caribou_key_model_get_width (CaribouKeyModel* self) {
      gdouble result;
      gdouble _tmp0_;
      g_return_val_if_fail (self != NULL, 0.0);
      _tmp0_ = self->priv->_width;
      result = _tmp0_;
      return result;
}


void caribou_key_model_set_width (CaribouKeyModel* self, gdouble value) {
      gdouble _tmp0_;
      g_return_if_fail (self != NULL);
      _tmp0_ = value;
      self->priv->_width = _tmp0_;
      g_object_notify ((GObject *) self, "width");
}


const gchar* caribou_key_model_get_toggle (CaribouKeyModel* self) {
      const gchar* result;
      const gchar* _tmp0_;
      g_return_val_if_fail (self != NULL, NULL);
      _tmp0_ = self->priv->_toggle;
      result = _tmp0_;
      return result;
}


void caribou_key_model_set_toggle (CaribouKeyModel* self, const gchar* value) {
      const gchar* _tmp0_;
      gchar* _tmp1_;
      g_return_if_fail (self != NULL);
      _tmp0_ = value;
      _tmp1_ = g_strdup (_tmp0_);
      _g_free0 (self->priv->_toggle);
      self->priv->_toggle = _tmp1_;
      g_object_notify ((GObject *) self, "toggle");
}


gboolean caribou_key_model_get_is_modifier (CaribouKeyModel* self) {
      gboolean result;
      GdkModifierType _tmp0_;
      g_return_val_if_fail (self != NULL, FALSE);
      _tmp0_ = self->priv->mod_mask;
      result = _tmp0_ != 0;
      return result;
}


void caribou_key_model_set_is_modifier (CaribouKeyModel* self, gboolean value) {
      g_return_if_fail (self != NULL);
      g_object_notify ((GObject *) self, "is-modifier");
}


gboolean caribou_key_model_get_show_subkeys (CaribouKeyModel* self) {
      gboolean result;
      gboolean _tmp0_;
      g_return_val_if_fail (self != NULL, FALSE);
      _tmp0_ = self->priv->_show_subkeys;
      result = _tmp0_;
      return result;
}


static void caribou_key_model_set_show_subkeys (CaribouKeyModel* self, gboolean value) {
      gboolean _tmp0_;
      g_return_if_fail (self != NULL);
      _tmp0_ = value;
      self->priv->_show_subkeys = _tmp0_;
      g_object_notify ((GObject *) self, "show-subkeys");
}


const gchar* caribou_key_model_get_name (CaribouKeyModel* self) {
      const gchar* result;
      const gchar* _tmp0_;
      g_return_val_if_fail (self != NULL, NULL);
      _tmp0_ = self->priv->_name;
      result = _tmp0_;
      return result;
}


static void caribou_key_model_set_name (CaribouKeyModel* self, const gchar* value) {
      const gchar* _tmp0_;
      gchar* _tmp1_;
      g_return_if_fail (self != NULL);
      _tmp0_ = value;
      _tmp1_ = g_strdup (_tmp0_);
      _g_free0 (self->priv->_name);
      self->priv->_name = _tmp1_;
      g_object_notify ((GObject *) self, "name");
}


guint caribou_key_model_get_keyval (CaribouKeyModel* self) {
      guint result;
      guint _tmp0_;
      g_return_val_if_fail (self != NULL, 0U);
      _tmp0_ = self->priv->_keyval;
      result = _tmp0_;
      return result;
}


static void caribou_key_model_set_keyval (CaribouKeyModel* self, guint value) {
      guint _tmp0_;
      g_return_if_fail (self != NULL);
      _tmp0_ = value;
      self->priv->_keyval = _tmp0_;
      g_object_notify ((GObject *) self, "keyval");
}


static gboolean caribou_key_model_real_get_scan_stepping (CaribouIScannableItem* base) {
      gboolean result;
      CaribouKeyModel* self;
      gboolean _tmp0_;
      self = (CaribouKeyModel*) base;
      _tmp0_ = self->priv->_scan_stepping;
      result = _tmp0_;
      return result;
}


static void caribou_key_model_real_set_scan_stepping (CaribouIScannableItem* base, gboolean value) {
      CaribouKeyModel* self;
      gboolean _tmp0_;
      self = (CaribouKeyModel*) base;
      _tmp0_ = value;
      self->priv->_scan_stepping = _tmp0_;
      g_object_notify ((GObject *) self, "scan-stepping");
}


static gboolean caribou_key_model_real_get_scan_selected (CaribouIScannableItem* base) {
      gboolean result;
      CaribouKeyModel* self;
      gboolean _tmp0_;
      self = (CaribouKeyModel*) base;
      _tmp0_ = self->priv->_scan_selected;
      result = _tmp0_;
      return result;
}


static void caribou_key_model_real_set_scan_selected (CaribouIScannableItem* base, gboolean value) {
      CaribouKeyModel* self;
      gboolean _tmp0_;
      gboolean _tmp1_;
      self = (CaribouKeyModel*) base;
      _tmp0_ = value;
      self->priv->_scan_selected = _tmp0_;
      _tmp1_ = self->priv->_scan_selected;
      if (_tmp1_) {
            caribou_key_model_activate (self);
      }
      g_object_notify ((GObject *) self, "scan-selected");
}


static void caribou_key_model_class_init (CaribouKeyModelClass * klass) {
      caribou_key_model_parent_class = g_type_class_peek_parent (klass);
      g_type_class_add_private (klass, sizeof (CaribouKeyModelPrivate));
      G_OBJECT_CLASS (klass)->get_property = _vala_caribou_key_model_get_property;
      G_OBJECT_CLASS (klass)->set_property = _vala_caribou_key_model_set_property;
      G_OBJECT_CLASS (klass)->finalize = caribou_key_model_finalize;
      g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_KEY_MODEL_ALIGN, g_param_spec_string ("align", "align", "align", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
      g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_KEY_MODEL_WIDTH, g_param_spec_double ("width", "width", "width", -G_MAXDOUBLE, G_MAXDOUBLE, 1.0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
      g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_KEY_MODEL_TOGGLE, g_param_spec_string ("toggle", "toggle", "toggle", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
      g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_KEY_MODEL_IS_MODIFIER, g_param_spec_boolean ("is-modifier", "is-modifier", "is-modifier", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
      g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_KEY_MODEL_SHOW_SUBKEYS, g_param_spec_boolean ("show-subkeys", "show-subkeys", "show-subkeys", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
      g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_KEY_MODEL_NAME, g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
      g_object_class_install_property (G_OBJECT_CLASS (klass), CARIBOU_KEY_MODEL_KEYVAL, g_param_spec_uint ("keyval", "keyval", "keyval", 0, G_MAXUINT, 0U, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
      g_object_class_override_property (G_OBJECT_CLASS (klass), CARIBOU_KEY_MODEL_SCAN_STEPPING, "scan-stepping");
      g_object_class_override_property (G_OBJECT_CLASS (klass), CARIBOU_KEY_MODEL_SCAN_SELECTED, "scan-selected");
      g_signal_new ("key_hold_end", CARIBOU_TYPE_KEY_MODEL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
      g_signal_new ("key_hold", CARIBOU_TYPE_KEY_MODEL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}


static void caribou_key_model_caribou_iscannable_item_interface_init (CaribouIScannableItemIface * iface) {
      caribou_key_model_caribou_iscannable_item_parent_iface = g_type_interface_peek_parent (iface);
      iface->get_scan_stepping = caribou_key_model_real_get_scan_stepping;
      iface->set_scan_stepping = caribou_key_model_real_set_scan_stepping;
      iface->get_scan_selected = caribou_key_model_real_get_scan_selected;
      iface->set_scan_selected = caribou_key_model_real_set_scan_selected;
}


static void caribou_key_model_caribou_ikeyboard_object_interface_init (CaribouIKeyboardObjectIface * iface) {
      caribou_key_model_caribou_ikeyboard_object_parent_iface = g_type_interface_peek_parent (iface);
      iface->get_keys = (CaribouKeyModel** (*)(CaribouIKeyboardObject*, int*)) caribou_key_model_real_get_keys;
      iface->get_children = (CaribouIKeyboardObject** (*)(CaribouIKeyboardObject*, int*)) caribou_key_model_real_get_children;
}


static void caribou_key_model_instance_init (CaribouKeyModel * self) {
      gchar* _tmp0_;
      gchar* _tmp1_;
      self->priv = CARIBOU_KEY_MODEL_GET_PRIVATE (self);
      _tmp0_ = g_strdup ("center");
      self->priv->_align = _tmp0_;
      self->priv->_width = 1.0;
      _tmp1_ = g_strdup ("");
      self->priv->_toggle = _tmp1_;
      self->priv->_show_subkeys = FALSE;
}


static void caribou_key_model_finalize (GObject* obj) {
      CaribouKeyModel * self;
      self = CARIBOU_KEY_MODEL (obj);
      _g_free0 (self->priv->_align);
      _g_free0 (self->priv->_toggle);
      _g_free0 (self->priv->_name);
      _g_object_unref0 (self->priv->xadapter);
      _g_object_unref0 (self->priv->extended_keys);
      G_OBJECT_CLASS (caribou_key_model_parent_class)->finalize (obj);
}


GType caribou_key_model_get_type (void) {
      static volatile gsize caribou_key_model_type_id__volatile = 0;
      if (g_once_init_enter (&caribou_key_model_type_id__volatile)) {
            static const GTypeInfo g_define_type_info = { sizeof (CaribouKeyModelClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) caribou_key_model_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CaribouKeyModel), 0, (GInstanceInitFunc) caribou_key_model_instance_init, NULL };
            static const GInterfaceInfo caribou_iscannable_item_info = { (GInterfaceInitFunc) caribou_key_model_caribou_iscannable_item_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
            static const GInterfaceInfo caribou_ikeyboard_object_info = { (GInterfaceInitFunc) caribou_key_model_caribou_ikeyboard_object_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
            GType caribou_key_model_type_id;
            caribou_key_model_type_id = g_type_register_static (G_TYPE_OBJECT, "CaribouKeyModel", &g_define_type_info, 0);
            g_type_add_interface_static (caribou_key_model_type_id, CARIBOU_TYPE_ISCANNABLE_ITEM, &caribou_iscannable_item_info);
            g_type_add_interface_static (caribou_key_model_type_id, CARIBOU_TYPE_IKEYBOARD_OBJECT, &caribou_ikeyboard_object_info);
            g_once_init_leave (&caribou_key_model_type_id__volatile, caribou_key_model_type_id);
      }
      return caribou_key_model_type_id__volatile;
}


static void _vala_caribou_key_model_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
      CaribouKeyModel * self;
      self = CARIBOU_KEY_MODEL (object);
      switch (property_id) {
            case CARIBOU_KEY_MODEL_ALIGN:
            g_value_set_string (value, caribou_key_model_get_align (self));
            break;
            case CARIBOU_KEY_MODEL_WIDTH:
            g_value_set_double (value, caribou_key_model_get_width (self));
            break;
            case CARIBOU_KEY_MODEL_TOGGLE:
            g_value_set_string (value, caribou_key_model_get_toggle (self));
            break;
            case CARIBOU_KEY_MODEL_IS_MODIFIER:
            g_value_set_boolean (value, caribou_key_model_get_is_modifier (self));
            break;
            case CARIBOU_KEY_MODEL_SHOW_SUBKEYS:
            g_value_set_boolean (value, caribou_key_model_get_show_subkeys (self));
            break;
            case CARIBOU_KEY_MODEL_NAME:
            g_value_set_string (value, caribou_key_model_get_name (self));
            break;
            case CARIBOU_KEY_MODEL_KEYVAL:
            g_value_set_uint (value, caribou_key_model_get_keyval (self));
            break;
            case CARIBOU_KEY_MODEL_SCAN_STEPPING:
            g_value_set_boolean (value, caribou_iscannable_item_get_scan_stepping ((CaribouIScannableItem*) self));
            break;
            case CARIBOU_KEY_MODEL_SCAN_SELECTED:
            g_value_set_boolean (value, caribou_iscannable_item_get_scan_selected ((CaribouIScannableItem*) self));
            break;
            default:
            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
            break;
      }
}


static void _vala_caribou_key_model_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
      CaribouKeyModel * self;
      self = CARIBOU_KEY_MODEL (object);
      switch (property_id) {
            case CARIBOU_KEY_MODEL_ALIGN:
            caribou_key_model_set_align (self, g_value_get_string (value));
            break;
            case CARIBOU_KEY_MODEL_WIDTH:
            caribou_key_model_set_width (self, g_value_get_double (value));
            break;
            case CARIBOU_KEY_MODEL_TOGGLE:
            caribou_key_model_set_toggle (self, g_value_get_string (value));
            break;
            case CARIBOU_KEY_MODEL_IS_MODIFIER:
            caribou_key_model_set_is_modifier (self, g_value_get_boolean (value));
            break;
            case CARIBOU_KEY_MODEL_SHOW_SUBKEYS:
            caribou_key_model_set_show_subkeys (self, g_value_get_boolean (value));
            break;
            case CARIBOU_KEY_MODEL_NAME:
            caribou_key_model_set_name (self, g_value_get_string (value));
            break;
            case CARIBOU_KEY_MODEL_KEYVAL:
            caribou_key_model_set_keyval (self, g_value_get_uint (value));
            break;
            case CARIBOU_KEY_MODEL_SCAN_STEPPING:
            caribou_iscannable_item_set_scan_stepping ((CaribouIScannableItem*) self, g_value_get_boolean (value));
            break;
            case CARIBOU_KEY_MODEL_SCAN_SELECTED:
            caribou_iscannable_item_set_scan_selected ((CaribouIScannableItem*) self, g_value_get_boolean (value));
            break;
            default:
            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
            break;
      }
}


GType caribou_modifier_state_get_type (void) {
      static volatile gsize caribou_modifier_state_type_id__volatile = 0;
      if (g_once_init_enter (&caribou_modifier_state_type_id__volatile)) {
            static const GEnumValue values[] = {{CARIBOU_MODIFIER_STATE_NONE, "CARIBOU_MODIFIER_STATE_NONE", "none"}, {CARIBOU_MODIFIER_STATE_LATCHED, "CARIBOU_MODIFIER_STATE_LATCHED", "latched"}, {CARIBOU_MODIFIER_STATE_LOCKED, "CARIBOU_MODIFIER_STATE_LOCKED", "locked"}, {0, NULL, NULL}};
            GType caribou_modifier_state_type_id;
            caribou_modifier_state_type_id = g_enum_register_static ("CaribouModifierState", values);
            g_once_init_leave (&caribou_modifier_state_type_id__volatile, caribou_modifier_state_type_id);
      }
      return caribou_modifier_state_type_id__volatile;
}


void caribou_modifier_map_entry_copy (const CaribouModifierMapEntry* self, CaribouModifierMapEntry* dest) {
      const gchar* _tmp0_;
      const gchar* _tmp1_;
      GdkModifierType _tmp2_;
      _tmp0_ = (*self).name;
      _tmp1_ = g_strdup (_tmp0_);
      _g_free0 ((*dest).name);
      (*dest).name = _tmp1_;
      _tmp2_ = (*self).mask;
      (*dest).mask = _tmp2_;
}


void caribou_modifier_map_entry_destroy (CaribouModifierMapEntry* self) {
      _g_free0 ((*self).name);
}


CaribouModifierMapEntry* caribou_modifier_map_entry_dup (const CaribouModifierMapEntry* self) {
      CaribouModifierMapEntry* dup;
      dup = g_new0 (CaribouModifierMapEntry, 1);
      caribou_modifier_map_entry_copy (self, dup);
      return dup;
}


void caribou_modifier_map_entry_free (CaribouModifierMapEntry* self) {
      caribou_modifier_map_entry_destroy (self);
      g_free (self);
}


GType caribou_modifier_map_entry_get_type (void) {
      static volatile gsize caribou_modifier_map_entry_type_id__volatile = 0;
      if (g_once_init_enter (&caribou_modifier_map_entry_type_id__volatile)) {
            GType caribou_modifier_map_entry_type_id;
            caribou_modifier_map_entry_type_id = g_boxed_type_register_static ("CaribouModifierMapEntry", (GBoxedCopyFunc) caribou_modifier_map_entry_dup, (GBoxedFreeFunc) caribou_modifier_map_entry_free);
            g_once_init_leave (&caribou_modifier_map_entry_type_id__volatile, caribou_modifier_map_entry_type_id);
      }
      return caribou_modifier_map_entry_type_id__volatile;
}




Generated by  Doxygen 1.6.0   Back to index