Esempio n. 1
0
USER_OBJECT_
R_internal_getGTypeHierarchy(GType type)
{
  USER_OBJECT_ ans;
  int n = 0;
  GType orig = type;

  while(type != 0 && type != G_TYPE_INVALID) {
     type = g_type_parent(type);
     n++;
  }

  PROTECT(ans = NEW_CHARACTER(n));
  n = 0;
  type = orig;
  while(type != G_TYPE_INVALID) {
     const char *val;
     val = g_type_name(type);
     SET_STRING_ELT(ans, n, COPY_TO_USER_STRING(val));
     n++;
     type =  g_type_parent(type);
  }
  UNPROTECT(1);

  return(ans);
}
Esempio n. 2
0
static GValueTransform
transform_func_lookup (GType src_type,
                       GType dest_type)
{
    TransformEntry entry;

    entry.src_type = src_type;
    do
    {
        entry.dest_type = dest_type;
        do
        {
            TransformEntry *e;

            e = g_bsearch_array_lookup (transform_array, &transform_bconfig, &entry);
            if (e)
            {
                /* need to check that there hasn't been a change in value handling */
                if (g_type_value_table_peek (entry.dest_type) == g_type_value_table_peek (dest_type) &&
                        g_type_value_table_peek (entry.src_type) == g_type_value_table_peek (src_type))
                    return e->func;
            }
            entry.dest_type = g_type_parent (entry.dest_type);
        }
        while (entry.dest_type);

        entry.src_type = g_type_parent (entry.src_type);
    }
    while (entry.src_type);

    return NULL;
}
Esempio n. 3
0
static gboolean __type_is_valid(GType type)
{
	GType _type = type;
	if(!_type)
		return FALSE;

	if(type == MIDGARD_TYPE_DBOBJECT 
			|| type == MIDGARD_TYPE_OBJECT)
		return TRUE;

	/* check MIDGARD_TYPE_OBJECT */
	if(g_type_parent(_type) != MIDGARD_TYPE_DBOBJECT) {
		
		/* if fails, try MIDGARD_TYPE_DBOBJECT */
		if(g_type_parent(_type) == MIDGARD_TYPE_OBJECT
				|| g_type_parent(_type) == MIDGARD_TYPE_VIEW) {
			
			return TRUE;
		
		} else {

			return FALSE;
		}
	}

	return TRUE;
}
Esempio n. 4
0
static void
test_widget_type (gpointer  data)
{
  GType  type = GPOINTER_TO_SIZE (data);

  if (!g_type_is_a (type, GTK_TYPE_WIDGET))
    {
      GString* chain = g_string_new (g_type_name (type));
      if (type != G_TYPE_OBJECT)
        {
          GType parent = g_type_parent (type);
          g_string_append_printf (chain, " is a %s", g_type_name (parent));

          for (; g_type_name (parent) ; parent = g_type_parent (parent))
            {
              g_print ("%d (%s)\n", parent, g_type_name (parent));
              g_string_append_printf (chain, ", which is a %s", g_type_name (parent));
            }
          g_print ("%d (%s)\n", parent, g_type_name (parent));
        }

      g_warning ("The type %s doesn't derive from %s (%s)",
                 g_type_name (type),
                 g_type_name (GTK_TYPE_WIDGET),
                 chain->str);

      g_string_free (chain, TRUE);
    }
}
/* Find the type that implemented the GESExtractable interface */
static inline const gchar *
_extractable_type_name (GType type)
{
  while (1) {
    if (g_type_is_a (g_type_parent (type), GES_TYPE_EXTRACTABLE))
      type = g_type_parent (type);
    else
      return g_type_name (type);
  }
}
Esempio n. 6
0
/**
 * atk_registry_get_factory_type:
 * @registry: an #AtkRegistry
 * @type: a #GType with which to look up the associated #AtkObjectFactory
 * subclass
 *
 * Provides a #GType indicating the #AtkObjectFactory subclass
 * associated with @type.
 *
 * Returns: a #GType associated with type @type
 **/
GType
atk_registry_get_factory_type (AtkRegistry *registry,
                               GType type)
{
  GType factory_type;
  gpointer value;

  /*
   * look up factory type in first hash;
   * if there isn't an explicitly registered factory type,
   * try inheriting one...
   */
  do {
    value =
        g_hash_table_lookup (registry->factory_type_registry, 
                             (gpointer) type);
    type = g_type_parent (type);
    if (type == G_TYPE_INVALID)
      {
        break;
      }
  } while (value == NULL);

  factory_type = (GType) value;
  return factory_type;
}
void
mcd_dbus_get_interfaces (TpSvcDBusProperties *self, const gchar *name,
			 GValue *value)
{
    McdInterfaceData *iface_data, *id;
    GPtrArray *a_ifaces;
    GType type;

    DEBUG ("called");

    a_ifaces = g_ptr_array_new ();

    for (type = G_OBJECT_TYPE (self); type != 0; type = g_type_parent (type))
    {
	iface_data = g_type_get_qdata (type, MCD_INTERFACES_QUARK);
	if (!iface_data) continue;

	for (id = iface_data; id->get_type; id++)
        {
            if (id->optional &&
                !mcd_dbus_is_active_optional_interface (self,
                                                        id->get_type ()))
            {
                DEBUG ("skipping inactive optional iface %s", id->interface);
                continue;
            }

	    g_ptr_array_add (a_ifaces, g_strdup (id->interface));
        }
    }
    g_ptr_array_add (a_ifaces, NULL);

    g_value_init (value, G_TYPE_STRV);
    g_value_take_boxed (value, g_ptr_array_free (a_ifaces, FALSE));
}
Esempio n. 8
0
void
gom_resource_build_save_cmd (GomResource *resource,
                             GomAdapter  *adapter)
{
   GomCommandBuilder *builder;
   gboolean has_pkey, is_insert;
   GSList *types = NULL;
   GSList *iter;
   GType resource_type;
   GList *cmds = NULL;

   resource_type = G_TYPE_FROM_INSTANCE(resource);
   g_assert(g_type_is_a(resource_type, GOM_TYPE_RESOURCE));

   builder = g_object_new(GOM_TYPE_COMMAND_BUILDER,
                          "adapter", adapter,
                          NULL);

   has_pkey = has_primary_key(resource);
   if (has_pkey) {
     /* Could be an insert for a non-automatic primary key,
      * or an update */
     is_insert = !resource->priv->is_from_table;
   } else {
     is_insert = TRUE;
   }

   g_object_set_data (G_OBJECT (resource), "is-insert", GINT_TO_POINTER (is_insert));

   do {
      types = g_slist_prepend(types, GINT_TO_POINTER(resource_type));
   } while ((resource_type = g_type_parent(resource_type)) != GOM_TYPE_RESOURCE);

   for (iter = types; iter; iter = iter->next) {
      GomCommand *command;

      resource_type = GPOINTER_TO_INT(iter->data);

      g_object_set(builder,
                   "resource-type", resource_type,
                   NULL);

      if (is_insert) {
         command = gom_command_builder_build_insert(builder, resource);
      } else {
         command = gom_command_builder_build_update(builder, resource);
      }

      if (is_insert && gom_resource_has_dynamic_pkey(resource_type))
        is_insert = FALSE;

      cmds = g_list_prepend (cmds, command);
   }

   cmds = g_list_reverse (cmds);
   g_object_set_data_full (G_OBJECT(resource), "save-commands", cmds, free_save_cmds);

   g_slist_free(types);
   g_object_unref (builder);
}
Esempio n. 9
0
File: gtkswitch.c Progetto: BYC/gtk
static AtkObject *
gtk_switch_get_accessible (GtkWidget *widget)
{
  static gboolean first_time = TRUE;

  if (G_UNLIKELY (first_time))
    {
      AtkObjectFactory *factory;
      AtkRegistry *registry;
      GType derived_type;
      GType derived_atk_type;

      /* Figure out whether accessibility is enabled by looking at the
       * type of the accessible object which would be created for the
       * parent type of GtkSwitch
       */
      derived_type = g_type_parent (GTK_TYPE_SWITCH);

      registry = atk_get_default_registry ();
      factory = atk_registry_get_factory (registry, derived_type);
      derived_atk_type = atk_object_factory_get_accessible_type (factory);
      if (g_type_is_a (derived_atk_type, GTK_TYPE_ACCESSIBLE))
        atk_registry_set_factory_type (registry,
                                       GTK_TYPE_SWITCH,
                                       gtk_switch_accessible_factory_get_type ());

      first_time = FALSE;
    }

  return GTK_WIDGET_CLASS (gtk_switch_parent_class)->get_accessible (widget);
}
Esempio n. 10
0
static gboolean
gtk_real_model_types_iter_parent (GtkTreeModel *tree_model,
                                  GtkTreeIter  *iter,
                                  GtkTreeIter  *child)
{
  GType type;
  GType parent;
  
  type = GPOINTER_TO_INT (child->user_data);
  
  parent = g_type_parent (type);
  
  if (parent == G_TYPE_INVALID)
    {
      if (type > G_TYPE_FUNDAMENTAL_MAX)
        g_warning ("no parent for %ld %s\n",
                   (long int) type,
                   g_type_name (type));
      return FALSE;
    }
  else
    {
      iter->user_data = GINT_TO_POINTER (parent);
      
      return TRUE;
    }
}
Esempio n. 11
0
static gboolean unserialize (QCADDesignObject *obj, FILE *fp)
  {
  char *pszLine = NULL, *pszValue = NULL ;
  gboolean bStopReading = FALSE, bParentInit = FALSE ;

  if (!SkipPast (fp, '\0', "[TYPE:" QCAD_TYPE_STRING_RULER "]", NULL)) return FALSE ;

  while (TRUE)
    {
    if (NULL == (pszLine = ReadLine (fp, '\0', TRUE)))
      break ;

    if (!strcmp (pszLine, "[#TYPE:" QCAD_TYPE_STRING_RULER "]"))
      {
      g_free (pszLine) ;
      break ;
      }

    if (!bStopReading)
      {
      tokenize_line (pszLine, strlen (pszLine), &pszValue, '=') ;

      if (!strncmp (pszLine, "[TYPE:", 6))
        {
        if (!(bParentInit = QCAD_DESIGN_OBJECT_CLASS (g_type_class_peek (g_type_parent (QCAD_TYPE_STRETCHY_OBJECT)))->unserialize (obj, fp)))
          bStopReading = TRUE ;
        }
      }
    g_free (pszLine) ;
    g_free (ReadLine (fp, '\0', FALSE)) ;
    }

  return bParentInit ;
  }
Esempio n. 12
0
static void qcad_layer_instance_finalize (GObject *object)
  {
  GList *llItr = NULL, *llNext = NULL ;
  QCADLayer *layer = QCAD_LAYER (object) ;
  void (*parent_finalize) (GObject *object) ;

/*  DBG_OO (fprintf (stderr, "QCADLayer::instance_finalize:Layer %s:destroying lstObjs\n", layer->pszDescription)) ;*/

  for (llItr = layer->lstObjs ; llItr != NULL ; )
    {
    llNext = llItr->next ;
    if (NULL != llItr->data)
      {
/*      DBG_REFS (fprintf (stderr, "QCADLayer::instance_finalize:unref-ing object 0x%08X\n", (int)(llItr->data))) ;*/
      g_object_unref (G_OBJECT (llItr->data)) ;
      }
    llItr = llNext ;
    }

  g_free (layer->pszDescription) ;

  g_list_free (layer->lstObjs) ;
  g_list_free (layer->lstSelObjs) ;

/*  DBG_OO (fprintf (stderr, "QCADLayer::instance_finalize: Calling parent\n")) ;*/
  if (NULL != (parent_finalize = G_OBJECT_CLASS (g_type_class_peek (g_type_parent (QCAD_TYPE_LAYER)))->finalize))
    (*parent_finalize) (object) ;
  }
Esempio n. 13
0
/**
 * panel_a11y_query_accessible_parent_type
 * @type: widget type
 * @type_info: accessible object type info to complete
 *
 * Standard hack which figures out the #GType of the accessible
 * object for @type's parent type. Also, fills out the class_size
 * and instance_size of @type_info to match the size of the parent
 * type.
 *
 * Basically, this is the hack to use if you want to derive from
 * an accessible object implementation in gail.
 *
 * Returns: the #GType of @type's parent's accessible peer
 */
GType
panel_a11y_query_accessible_parent_type (GType      type,
					 GTypeInfo *type_info)
{
	AtkObjectFactory *factory;
	GType             parent_type;
	GType             accessible_parent_type;

	g_return_val_if_fail (G_TYPE_IS_OBJECT (type), G_TYPE_INVALID);

	parent_type = g_type_parent (type);

	factory = atk_registry_get_factory (atk_get_default_registry (), parent_type);

	accessible_parent_type = atk_object_factory_get_accessible_type (factory);

	if (type_info) {
		GTypeQuery query;

		g_type_query (accessible_parent_type, &query);

		type_info->class_size    = query.class_size;
		type_info->instance_size = query.instance_size;
	}

	return atk_object_factory_get_accessible_type (factory);
}
Esempio n. 14
0
static void
each_cinfo(gpointer instance, ClassInfoCallbackFunc func, gpointer user_data)
{
    const GType gtype = G_TYPE_FROM_INSTANCE(instance);
    GType* interfaces;
    guint n_interfaces = 0;

    interfaces = g_type_interfaces(gtype, &n_interfaces);
    {
        guint i;
        for (i = 0; i < n_interfaces; i++) {
	    const RGObjClassInfo *info;

	    info = GTYPE2CINFO_NO_CREATE(interfaces[i]);
	    if (info)
		func(instance, info, user_data);
	}
    }
    g_free(interfaces);

    {
        GType type;
        for (type = gtype; type != G_TYPE_INVALID; type = g_type_parent(type)) {
	    const RGObjClassInfo *info;

	    info = GTYPE2CINFO_NO_CREATE(type);
	    if (info)
		func(instance, info, user_data);
	}
    }
}
Esempio n. 15
0
static void
ada_class_record_init (GObjectClass* klass, gpointer class_data)
{
   GType type = G_TYPE_FROM_CLASS (klass);
   GType parent = g_type_parent (type);
   GTypeQuery query;
   GTypeQuery parent_query;
   const AdaGObjectClass ada_klass = (AdaGObjectClass)class_data;

   g_type_query (type, &query);
   g_type_query (parent, &parent_query);

   /* Initialize the function pointers for the new signals to NULL */

   memset ((char*)(klass) + parent_query.class_size, 0,
           query.class_size - parent_query.class_size);

   /* Set a pointer to the AdaGObjectClass, so that we can retrieve it
    * later from a type.
    */
   SET_ADA_CLASS_FROM_C_CLASS(klass, ada_klass);

   if (ada_klass->class_init) {
      ada_klass->class_init (klass);
   }
}
Esempio n. 16
0
static AtkObject *
mate_druid_get_accessible (GtkWidget *widget)
{
	static gboolean first_time = TRUE;

	if (first_time) {
		AtkObjectFactory *factory;
		AtkRegistry *registry;
 		GType derived_type; 
		GType derived_atk_type; 

		/*
		 * Figure out whether accessibility is enabled by looking at the
		 * type of the accessible object which would be created for
		 * the parent type of MateDruid.
		 */
		derived_type = g_type_parent (MATE_TYPE_DRUID);

		registry = atk_get_default_registry ();
		factory = atk_registry_get_factory (registry,
						    derived_type);
		derived_atk_type = atk_object_factory_get_accessible_type (factory);
		if (g_type_is_a (derived_atk_type, GTK_TYPE_ACCESSIBLE))  {
			atk_registry_set_factory_type (registry, 
						       MATE_TYPE_DRUID,
						       mate_druid_accessible_factory_get_type ());
		}
		first_time = FALSE;
	} 
	return GTK_WIDGET_CLASS (parent_class)->get_accessible (widget);
}
Esempio n. 17
0
GskXmlNode    *gsk_xml_context_serialize_value   (GskXmlContext         *context,
                                                  GValue                *value,
                                                  GError               **error)
{
  GType type;
  for (type = G_VALUE_TYPE (value); type != 0; type = g_type_parent (type))
    {
      TypeInfo *type_info = try_type_info (context, type);
      if (type_info != NULL && type_info->to_xml != NULL)
        {
          GError *e = NULL;
          GskXmlNode *node = type_info->to_xml (context, value, type_info->data, &e);

          /* success */
          if (node != NULL)
            return node;


          /* real error */
          if (e)
            {
              g_propagate_error (error, e);
              return NULL;
            }

          /* continue trying */
        }
    }
  g_set_error (error, GSK_G_ERROR_DOMAIN, GSK_ERROR_BAD_FORMAT,
               "no working serializer registered for type %s", G_VALUE_TYPE_NAME (value));
  return NULL;
}
Esempio n. 18
0
static void
print_hierarchy (GType type, gint level, gint * maxlevel)
{
  GType parent;
  gint i;

  parent = g_type_parent (type);

  *maxlevel = *maxlevel + 1;
  level++;

  if (parent)
    print_hierarchy (parent, level, maxlevel);

  if (_name)
    g_print ("%s", _name);

  for (i = 1; i < *maxlevel - level; i++)
    g_print ("      ");
  if (*maxlevel - level)
    g_print (" +----");

  g_print ("%s\n", g_type_name (type));

  if (level == 1)
    n_print ("\n");
}
Esempio n. 19
0
gboolean       gsk_xml_context_deserialize_value (GskXmlContext         *context,
                                                  GskXmlNode            *node,
                                                  GValue                *out,
						  GError               **error)
{
  GType type;
  for (type = G_VALUE_TYPE (out); type != 0; type = g_type_parent (type))
    {
      TypeInfo *type_info = try_type_info (context, type);
      if (type_info != NULL && type_info->func != NULL)
        {
          GError *e = NULL;
          if (type_info->func (context, node, out, type_info->data, &e))
            return TRUE;

          /* real error */
          if (e)
            {
              g_propagate_error (error, e);
              return FALSE;
            }

          /* continue trying */
        }
    }
  g_set_error (error, GSK_G_ERROR_DOMAIN, GSK_ERROR_BAD_FORMAT,
               "no working serializer registered for type %s",
               G_VALUE_TYPE_NAME (out));
  return FALSE;
}
Esempio n. 20
0
static void
build_map (GHashTable  *table_map,
           GType        type,
           const gchar *m2m_table)
{
   GomResourceClass *klass;
   const gchar *prefix;
   gchar *key;
   gchar *value;

   g_assert(table_map);
   g_assert(g_type_is_a(type, GOM_TYPE_RESOURCE));
   g_assert(!m2m_table || type != GOM_TYPE_RESOURCE);

   if (!m2m_table) {
      return;
   }

   prefix = g_type_name(type);

   do {
      klass = g_type_class_ref(type);
      key = g_strdup_printf("%s.%s", prefix, klass->table);
      value = g_strdup_printf("%s_%s", m2m_table, klass->table);
      g_hash_table_replace(table_map, key, value);
      g_type_class_unref(klass);
   } while ((type = g_type_parent(type)) != GOM_TYPE_RESOURCE);
}
Esempio n. 21
0
static void stretch_draw_state_change (QCADStretchyObject *obj, int x, int y, int xRef, int yRef)
  {
  int Nix ;
  QCADRuler *ruler = QCAD_RULER (obj) ;
  int xMIN = MIN (x, xRef), xMAX = MAX (x, xRef), yMIN = MIN (y, yRef), yMAX = MAX (y, yRef) ;
  QCADStretchyObjectClass *klass = QCAD_STRETCHY_OBJECT_CLASS (g_type_class_peek (g_type_parent (QCAD_TYPE_RULER))) ;

  if (NULL != klass->stretch_draw_state_change)
    klass->stretch_draw_state_change (obj, x, y, xRef, yRef) ;

  ruler->ruler_bounding_box.xWorld = real_to_world_x (xMIN) ;
  ruler->ruler_bounding_box.yWorld = real_to_world_y (yMIN) ;
  ruler->ruler_bounding_box.cxWorld = real_to_world_cx (xMAX - xMIN) ;
  ruler->ruler_bounding_box.cyWorld = real_to_world_cy (yMAX - yMIN) ;

  memcpy (&(QCAD_DESIGN_OBJECT (obj)->bounding_box), &(ruler->ruler_bounding_box), sizeof (WorldRectangle)) ;

  for (Nix = 0 ; Nix < ruler->icLabelsVisible ; Nix++)
    world_rect_union (&(QCAD_DESIGN_OBJECT (obj)->bounding_box), &(QCAD_DESIGN_OBJECT (exp_array_index_1d (ruler->labels, GRADUATION, Nix).lbl)->bounding_box), &(QCAD_DESIGN_OBJECT (obj)->bounding_box)) ;

  QCAD_RULER (obj)->orientation =
    QCAD_RULER_CALCULATE_ORIENTATION (
      ruler->ruler_bounding_box.cxWorld,
      ruler->ruler_bounding_box.cyWorld, x, y, xRef, yRef) ;
  }
AtkObject *
gal_a11y_e_cell_registry_get_object     (GalA11yECellRegistry     *registry,
					 ETableItem               *item,
					 ECellView                *cell_view,
					 AtkObject                *parent,
					 int                       model_col,
					 int                       view_col,
					 int                       row)
{
	GalA11yECellRegistryFunc func = NULL;
	GType type;

	if (registry == NULL) {
		init_default_registry ();
		registry = default_registry;
	}

	type = GTK_OBJECT_TYPE (cell_view->ecell);
	while (func == NULL && type != 0) {
		func = g_hash_table_lookup (registry->priv->table, GINT_TO_POINTER (type));
		type = g_type_parent (type);
	}

	if (func)
		return func (item, cell_view, parent, model_col, view_col, row);
	else
		return gal_a11y_e_cell_new (item, cell_view, parent, model_col, view_col, row);
}
Esempio n. 23
0
static gboolean
gom_resource_do_delete (GomResource  *resource,
                        GomAdapter   *adapter,
                        GError      **error)
{
   GomCommandBuilder *builder;
   GType resource_type;

   g_return_val_if_fail(GOM_IS_RESOURCE(resource), FALSE);
   g_return_val_if_fail(GOM_IS_ADAPTER(adapter), FALSE);

   resource_type = G_TYPE_FROM_INSTANCE(resource);
   builder = g_object_new(GOM_TYPE_COMMAND_BUILDER,
                          "adapter", adapter,
                          NULL);

   do {
      GomResourceClass *klass;
      GParamSpec *pspec;
      GomCommand *command;
      GomFilter *filter;
      GArray *values;
      GValue value = { 0 };
      gchar *sql;

      klass = g_type_class_peek(resource_type);
      g_assert(GOM_IS_RESOURCE_CLASS(klass));

      pspec = g_object_class_find_property(G_OBJECT_CLASS(klass),
                                           klass->primary_key);
      g_assert(pspec);

      g_value_init(&value, pspec->value_type);
      g_object_get_property(G_OBJECT(resource), klass->primary_key, &value);
      sql = g_strdup_printf("'%s'.'%s' = ?", klass->table, klass->primary_key);
      values = g_array_sized_new(FALSE, FALSE, sizeof(GValue), 1);
      g_array_append_val(values, value);
      filter = gom_filter_new_sql(sql, values);
      g_free(sql);
      memset(&value, 0, sizeof value);
      g_array_unref(values);
      g_object_set(builder,
                   "filter", filter,
                   "resource-type", resource_type,
                   NULL);
      g_object_unref(filter);

      command = gom_command_builder_build_delete(builder);
      if (!gom_command_execute(command, NULL, error)) {
         g_object_unref(command);
         g_object_unref(builder);
         return FALSE;
      }
      g_object_unref(command);
   } while ((resource_type = g_type_parent(resource_type)) != GOM_TYPE_RESOURCE);

   g_object_unref(builder);

   return TRUE;
}
Esempio n. 24
0
void
rbgobj_initialize_object(VALUE obj, gpointer cobj)
{
    GType type;
    GType parent_type;

    if (!cobj)
        rb_raise(rb_eRuntimeError, "failed to initialize");

    type = RVAL2GTYPE(obj);

    for (parent_type = type;
         parent_type != G_TYPE_INVALID;
         parent_type = g_type_parent(parent_type)) {

         if (rbgobj_convert_initialize(parent_type, obj, cobj))
             return;
    }

    type = G_TYPE_FUNDAMENTAL(type);
    switch (type){
    case G_TYPE_OBJECT:
        rbgobj_gobject_initialize(obj, cobj);
        break;
    case G_TYPE_PARAM:
        rbgobj_param_spec_initialize(obj, cobj);
        break;
    case G_TYPE_BOXED:
        rbgobj_boxed_initialize(obj, cobj);
        break;
    default:
        rbgobj_convert_initialize(type, obj, cobj);
    }
}
Esempio n. 25
0
VALUE
rbgobj_ruby_object_from_instance2(gpointer instance, gboolean alloc)
{
    VALUE object;
    GType type;

    if (!instance)
    	return Qnil;

    type = G_TYPE_FROM_INSTANCE(instance);
    if (alloc) {
        GType parent_type;
        for (parent_type = type;
             parent_type != G_TYPE_INVALID;
             parent_type = g_type_parent(parent_type)) {
            if (rbgobj_convert_instance2robj(parent_type, instance, &object))
                return object;
        }
    }

    switch (G_TYPE_FUNDAMENTAL(type)) {
    case G_TYPE_OBJECT:
        return rbgobj_get_ruby_object_from_gobject(instance, alloc);
    case G_TYPE_PARAM:
        return rbgobj_get_ruby_object_from_param_spec(instance, alloc);
    default:
        if (alloc) {
            rb_raise(rb_eTypeError, "%s isn't supported", g_type_name(type));
        } else {
            return Qnil;
        }
    }
}
Esempio n. 26
0
GType ev_view_accessible_get_type (void)
{
	static GType type = 0;

	if (G_UNLIKELY (type == 0)) {
		GTypeInfo tinfo = {
			0,	/* class size */
			(GBaseInitFunc) NULL,	/* base init */
			(GBaseFinalizeFunc) NULL,	/* base finalize */
			(GClassInitFunc) ev_view_accessible_class_init,	/* class init */
			(GClassFinalizeFunc) NULL,	/* class finalize */
			NULL,	/* class data */
			0,	/* instance size */
			0,	/* nb preallocs */
			(GInstanceInitFunc) NULL,	/* instance init */
			NULL	/* value table */
		};

		const GInterfaceInfo atk_text_info = {
			(GInterfaceInitFunc)
			ev_view_accessible_text_iface_init,
			(GInterfaceFinalizeFunc) NULL,
			NULL
		};

		const GInterfaceInfo atk_action_info = {
			(GInterfaceInitFunc)
			ev_view_accessible_action_iface_init,
			(GInterfaceFinalizeFunc) NULL,
			NULL
		};
		/*
		 * Figure out the size of the class and instance
		 * we are deriving from
		 */
		AtkObjectFactory *factory;
		GType derived_type;
		GTypeQuery query;
		GType derived_atk_type;

		derived_type = g_type_parent (EV_TYPE_VIEW);
		factory = atk_registry_get_factory (atk_get_default_registry (),
		                                    derived_type);
		derived_atk_type = atk_object_factory_get_accessible_type (factory);

		g_type_query (derived_atk_type, &query);
		tinfo.class_size = query.class_size;
		tinfo.instance_size = query.instance_size;

		type = g_type_register_static (derived_atk_type, "EvViewAccessible",
		                               &tinfo, 0);
		g_type_add_interface_static (type, ATK_TYPE_TEXT,
		                             &atk_text_info);
		g_type_add_interface_static (type, ATK_TYPE_ACTION,
		                             &atk_action_info);
	}

	return type;
}
Esempio n. 27
0
/**
 * A meta table for a class has been created on the stack.  Now
 * try to find the base class and call _get_object_meta for it, too.
 *
 * @param L  Lua State
 * @param type_nr  The GType of the class to find the parent for
 *
 * Input stack: metaclass
 * Output stack: metaclass
 *
 * @return 1 on success, 0 otherwise
 */
static int _get_object_meta_parent(lua_State *L, GType type_nr)
{
    const char *parent_name;
    GType parent_type_nr;
    GTypeQuery query;
    query.type_name = NULL;
    int rc;
    typespec_t ts;

    /* determine the name of the parent class, if any */
    parent_type_nr = g_type_parent(type_nr);
    if (!parent_type_nr) {
	/* printf("%s no parent for type 0x%x\n", msgprefix, type_nr); */
	return 1;
    }

    parent_name = g_type_name(parent_type_nr);
    /*
    printf("%s parent 0x%x -> 0x%x %s\n", msgprefix, type_nr, parent_type_nr,
	parent_name);
    */
    if (!parent_name) {
	fprintf(stderr, "%s Unknown GType 0x%x, supposed parent of %s\n",
	    msgprefix, (unsigned int) parent_type_nr, g_type_name(type_nr));
	return 1;
    }

    /* Get LuaGnome description of this structure.  It might not exist, as
     * abstract, empty base classes like GInitiallyUnowned or GBoxed are
     * not known to LuaGnome.  Also, when a base class should be handled by
     * another module, which doesn't have it or isn't loaded, this fails
     * in the same way. */
    ts = lg_find_struct(L, parent_name, 0);

    if (!ts.value) {
	/* Might be a non-native type of this module; it could be looked
	 * for by the hash value; on the other hand, non-native types are
	 * not registered anywhere, so a linear search would be required
	 * on the type list.  If found, indicates a problem; the non-native
	 * type should exist in another module. */
	if (!strcmp(parent_name, "GBoxed"))
	    return 1;
	printf("%s warning: type not found: %s\n", msgprefix, parent_name);
	return 1;
    }

    /* the parent class might actually be handled by another module. */
    ts = lg_type_normalize(L, ts);

    rc = _get_object_meta(L, ts);
    if (rc == 1) {
	/* add _parent -- used by _fe_recurse to climb up the hierarchy */
	lua_pushliteral(L, "_parent");	    // meta parentmeta name
	lua_insert(L, -2);		    // meta name parentmeta
	lua_rawset(L, -3);		    // meta
    }

    return 1;
}
static void qcad_undo_entry_instance_finalize (GObject *object)
  {
  void (*parent_finalize) (GObject *obj) =
    G_OBJECT_CLASS (g_type_class_peek (g_type_parent (QCAD_TYPE_UNDO_ENTRY)))->finalize ;

  if (NULL != parent_finalize)
    (*parent_finalize) (object) ;
  DBG_OO (fprintf (stderr, QCAD_TYPE_STRING_UNDO_ENTRY "::instance_finalize:Leaving\n")) ;
  }
static GObjectClass *
get_threshold_class (GObject *obj)
{
	GType gtype = G_TYPE_FROM_INSTANCE (obj);
	while (HAS_PREFIX (g_type_name (gtype)))
		gtype = g_type_parent (gtype);
	GObjectClass *klass = g_type_class_peek (gtype);
	if (klass == NULL) klass = g_type_class_ref (gtype);
	return klass;
}
Esempio n. 30
0
static void qcad_label_instance_finalize (GObject *object)
  {
  DBG_OO (fprintf (stderr, "QCADLabel::instance_finalize:Entering\n")) ;
  g_free (QCAD_LABEL (object)->psz) ;
#ifdef GTK_GUI
  exp_pixmap_free (QCAD_LABEL (object)->epm) ;
#endif /* def GTK_GUI */
  G_OBJECT_CLASS (g_type_class_peek (g_type_parent (QCAD_TYPE_LABEL)))->finalize (object) ;
  DBG_OO (fprintf (stderr, "QCADLabel::instance_finalize:Leaving\n")) ;
  }