[Vala] some libeflvala patches; was: Re: Compact classes in HashTable



Hello

Here are my two patches from my ongoing rewrite of ffalarms in Vala.
(Is there a better place/method you would want to accept libeflvala
patches?)

libeflvala-lupan-ecore-signals.patch ::

    vapi/Makefile.am: add edje.vapi and edje.deps to dist_vapi_DATA (or is
    there a reason not to install them?)

    vapi/ecore.vapi: add support for signal events (EventHandler modeled
    after FdHandler) -- now creating new events

    NOTE: Attached usage example: signals.vala

libeflvala-lupan-elm.patch ::

    Layout.edje_get is better to return weak pointer otherwise one has
    to keep it forever (or put it in HashTable black hole)

    NOTE: I have not changed Layout.edje_get type to Edje.Object which
    should be best to do.

    vapi/elm.vapi:
     - ListItem append, prepend, insert_before, insert_after: icon, end, and
       func may be null
     - add ListItem: selected_item_get and selected_items_get

    NOTE: ListItem append etc could also return weak but for now I use
    HashTable black hole to have the effect of weak (which was the
    problem of this thread).

And a question:

Would you apply a patch to make most sth_set(value) methods also
accessable as properties (I can prepear it) such as:

     public void title_set( string title );
+    public string title { [CCode (cname = "elm_win_title_set")] set; }

so then one can write

-    win.title_set( "Elementary meets Vala" );
+    win.title = "Elementary meets Vala";


Best regards,
Łukasz


diff --git a/vapi/Makefile.am b/vapi/Makefile.am
index 8bf1f01..9233a5e 100644
--- a/vapi/Makefile.am
+++ b/vapi/Makefile.am
@@ -11,6 +11,8 @@ dist_vapi_DATA = \
   evas.deps \
   ecore.vapi \
   ecore.deps \
+  edje.vapi \
+  edje.deps \
   elm.vapi \
   elm.deps \
   $(NULL)
diff --git a/vapi/ecore.vapi b/vapi/ecore.vapi
index 7511878..05c0ca9 100644
--- a/vapi/ecore.vapi
+++ b/vapi/ecore.vapi
@@ -28,12 +28,56 @@ namespace Ecore
 
     //=======================================================================
     [CCode (instance_pos = 0)]
+    public delegate bool EventHandlerFunc( int type, void *event );
+
+    //=======================================================================
+    [CCode (instance_pos = 0)]
     public delegate bool FdHandlerFunc( FdHandler fdhandler );
 
     //=======================================================================
     [CCode (instance_pos = 0)]
     public delegate bool BufHandlerFunc( void* data );
 
+    [CCode (cname="Ecore_Event_Signal_User")]
+    public struct EventSignalUser
+    {
+       public int number;
+    }
+
+    [CCode (cname="Ecore_Event_Signal_Exit")]
+    public struct EventSignalExit
+    {
+       public uint interrupt;
+       public uint quit;
+       public uint terminate;
+    }
+
+    [CCode (cname="Ecore_Event_Signal_Realtime")]
+    public struct EventSignalRealtime
+    {
+       public int num;
+    }
+
+    [CCode (cprefix = "ECORE_EVENT_")]
+    public enum EventType
+    {
+       NONE,
+       SIGNAL_USER,
+       SIGNAL_HUP,
+       SIGNAL_EXIT,
+       SIGNAL_POWER,
+       SIGNAL_REALTIME,
+    }
+
+    //=======================================================================
+    [Compact]
+    [CCode (cname = "Ecore_Event_Handler", free_function = "ecore_event_handler_del")]
+    public class EventHandler
+    {
+        [CCode (cname = "ecore_event_handler_add")]
+        EventHandler( int type, EventHandlerFunc event_func );
+    }
+
     //=======================================================================
     namespace MainLoop
     {
diff --git a/vapi/elm.vapi b/vapi/elm.vapi
index 14196b8..e94f9a8 100644
--- a/vapi/elm.vapi
+++ b/vapi/elm.vapi
@@ -250,7 +251,7 @@ public class Layout : Elm.Object
 
     public void file_set( string file, string group );
     public void content_set( string swallow, Elm.Object content );
-    public Elm.Object edje_get();
+    public weak Elm.Object edje_get();
 }
 
 
@@ -390,15 +391,21 @@ public class List : Elm.Object
 {
     [CCode (cname = "elm_list_add")]
     public List( Elm.Object? parent );
-    public ListItem append( string label, Elm.Object icon, Elm.Object end, Evas.SmartCallback func );
-    public ListItem prepend( string label, Elm.Object icon, Elm.Object end, Evas.SmartCallback func );
-    public ListItem insert_before( ListItem before, string label, Elm.Object icon, Elm.Object end, 
Evas.SmartCallback func );
-    public ListItem insert_after( ListItem after, string label, Elm.Object icon, Elm.Object end, 
Evas.SmartCallback func );
+    [CCode (cname = "elm_list_item_append")]
+    public ListItem append( string label, Elm.Object? icon, Elm.Object? end, Evas.SmartCallback? func);
+    [CCode (cname = "elm_list_item_prepend")]
+    public ListItem prepend( string label, Elm.Object? icon, Elm.Object? end, Evas.SmartCallback? func );
+    public ListItem insert_before( ListItem before, string label, Elm.Object? icon, Elm.Object? end, 
Evas.SmartCallback? func );
+    public ListItem insert_after( ListItem after, string label, Elm.Object? icon, Elm.Object? end, 
Evas.SmartCallback? func );
 
     public void go();
     public void multi_select_set( bool multi );
     public void horizontal_mode_set( ListMode mode );
     public void always_select_mode_set( bool always_select );
+
+    public weak ListItem selected_item_get();
+    public weak Eina.List<ListItem> selected_items_get();
+       
 }
 
 
using Ecore;


bool sig_user(int type, void *event)
{
    stdout.printf("USR%d\n", ((EventSignalUser *) event)->number);
    return false;
}

bool sig_realtime(int type, void *event)
{
    stdout.printf("num: %d\n", ((EventSignalRealtime *) event)->num);
    return true;
}

bool sig_exit(int type, void *event)
{
    var ev = (EventSignalExit *) event;
    stdout.printf("[i: %u, q: %u, t: %u]\n",
                  ev->interrupt, ev->quit, ev->terminate);
    if (ev->terminate != 0)
        Ecore.MainLoop.quit();
    return false;
}

void main()
{
    Ecore.init();
    var x = new EventHandler(EventType.SIGNAL_USER, sig_user);
    var y = new EventHandler(EventType.SIGNAL_REALTIME, sig_realtime);
    var z = new EventHandler(EventType.SIGNAL_EXIT, sig_exit);
    Ecore.MainLoop.begin();
    x = null; y = null; z = null; // required to avoid double free of the event
    Ecore.shutdown();
}


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