Re: introspection



1. Could you share your Gir file?
2. Is a good idea to add a namespace. Like your main project prefix. This avoids introspection function and objects name collisions.

El 19/11/2014 05:13, "Andrea Zagli" <azagli libero it> escribió:
i made a very little library

===============================================================================================
#ifndef __LIBCONFI_H__
#define __LIBCONFI_H__

#include <glib.h>
#include <glib-object.h>

#include <libgdaex/libgdaex.h>

G_BEGIN_DECLS


#define TYPE_CONFI                 (confi_get_type ())
#define CONFI(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CONFI, Confi))
#define CONFI_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CONFI, ConfiClass))
#define IS_CONFI(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CONFI))
#define IS_CONFI_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CONFI))
#define CONFI_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CONFI, ConfiClass))


typedef struct _Confi Confi;
typedef struct _ConfiClass ConfiClass;

struct _Confi
        {
                GObject parent;
        };

struct _ConfiClass
        {
                GObjectClass parent_class;
        };

GType confi_get_type (void) G_GNUC_CONST;

Confi *confi_new (const gchar *cnc_string,
                  const gchar *name,
                  const gchar *root,
                  gboolean create);
===============================================================================================


now i want to add introspection; i follow https://wiki.gnome.org/Projects/GObjectIntrospection/AutotoolsIntegration and i can build the library and gir file

but if i try to use it from python i get errors

===============================================================================================
#!/usr/bin/env python

from gi.repository import Confi

# Create a new object
confi = Confi.Confi()
===============================================================================================

===============================================================================================
Traceback (most recent call last):
  File "./gir.py", line 6, in <module>
    confi = Confi.Confi()
  File "C:/msys32/mingw32/lib/python2.7/site-packages/gi/module.py", line 320, in __getattr__
    return getattr(self._introspection_module, name)
  File "C:/msys32/mingw32/lib/python2.7/site-packages/gi/module.py", line 139, in __getattr__
    self.__name__, name))
AttributeError: 'gi.repository.Confi' object has no attribute 'Confi'
===============================================================================================


the problem could it be that the library hasn't "submodules" inside the Confi namespace? (i saw maman_bar example, where Maman is the namespace and Bar is the "real" name of the object)


thanks in advance
_______________________________________________
gtk-list mailing list
gtk-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-list


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]