Re: [Vala] Purple.CoreUiOps



I got around it. I had to edit the purple.vapi and change it from a
class to struct. However moving along I had to change more classes to
structs. And now I am stuck with callbacks. I am not strong enough
with VAPI's to even know what they heck I am even doing...

Example, I see:
        [CCode (cheader_filename = "purple.h")]
        [Compact]
        public class EventLoopUiOps {
                public weak GLib.Callback input_add;
                public weak GLib.Callback input_get_error;
                public weak GLib.Callback input_remove;
                public weak GLib.Callback timeout_add;
                public weak GLib.Callback timeout_add_seconds;
                public weak GLib.Callback timeout_remove;
        }

and changed it too:
        [CCode (cheader_filename = "purple.h")]
        [Compact]
        public struct EventLoopUiOps {
                public weak GLib.Callback input_add;
                public weak GLib.Callback input_get_error;
                public weak GLib.Callback input_remove;
                public weak GLib.Callback timeout_add;
                public weak GLib.Callback timeout_add_seconds;
                public weak GLib.Callback timeout_remove;
        }

Then I see:
        [CCode (cheader_filename = "purple.h")]
        public static uint input_add (int fd, Purple.InputCondition cond,
Purple.InputFunction func);

Now when I try to set input_add:
        uint my_input_add(int fd, Purple.InputCondition condition,
Purple.InputFunction func)

        Purple.EventLoopUiOps glib_eventloops = Purple.EventLoopUiOps() {
                input_add = my_input_add,
                input_remove = GLib.Source.remove,
                input_get_error = null,
                timeout_add = GLib.Timeout.add,
                timeout_add_seconds = GLib.Timeout.add_seconds,
                timeout_remove = GLib.Source.remove
        };

I get "Invalid type for member `input_add'". I am going to take a wild
guess and say that in purple.vapi I need to add some [something that
fixed this] to let me add parameters to a callback?

On Fri, Feb 17, 2012 at 9:08 AM, Joseph Montanez
<jmontanez gorilla3d com> wrote:
I tried that one too:

   Purple.CoreUiOps ui_ops = {
       null, null, null, null, null
   };

error: initializer list used for `Purple.CoreUiOps?', which is neither
array nor struct
   Purple.CoreUiOps ui_ops = {

And this one:

   var ui_ops = Purple.CoreUiOps() {
       debug_ui_init = null,
       get_ui_info = null,
       quit = null,
       ui_init = null,
       ui_prefs_init = null
   };

   error: syntax error, use `new' to create new objects


I took a look at the libpurple headers and it is a struct:
typedef struct
{
    void (*ui_prefs_init)(void);
    void (*debug_ui_init)(void);
    void (*ui_init)(void);
    void (*quit)(void);

    GHashTable* (*get_ui_info)(void);

    void (*_purple_reserved1)(void);
    void (*_purple_reserved2)(void);
    void (*_purple_reserved3)(void);
} PurpleCoreUiOps;

Maybe the libpurple vapi that is bundled with vala is wrong?

On Fri, Feb 17, 2012 at 7:16 AM, Luca Bruno <lethalman88 gmail com> wrote:
On Fri, Feb 17, 2012 at 3:38 PM, Joseph Montanez <jmontanez gorilla3d com>
wrote:

My brain is melting trying to figure out how to get Purple.CoreUiOps
to initialize.

Here is the vapi:
       [CCode (cheader_filename = "purple.h")]
       [Compact]
       public class CoreUiOps {
               [CCode (has_construct_function = false)]
               public weak GLib.Callback debug_ui_init;
               public weak GLib.Callback get_ui_info;
               public weak GLib.Callback quit;
               public weak GLib.Callback ui_init;
               public weak GLib.Callback ui_prefs_init;
       }


Try with a struct.

--
www.debian.org - The Universal Operating System



--
Joseph Montanez
Web Developer
Gorilla3D
Design, Develop, Deploy



-- 
Joseph Montanez
Web Developer
Gorilla3D
Design, Develop, Deploy



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