vapi: genlist item class functions have no target; hence only static delegates work
[libeflvala.git] / examples / elementary / genlist.vala
blob8f0a1722b6922dd2da5bb6df55a750f06ca15aaf
1 /**
2 * Copyright (C) 2009 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 public class T.Genlist : T.Abstract
22 Elm.Genlist list;
23 Elm.GenlistItemClass itc;
25 public Genlist()
27 itc.item_style = "default";
28 itc.func.label_get = getLabel;
29 itc.func.icon_get = getIcon;
30 itc.func.state_get = getState;
31 itc.func.del = delItem;
34 public override void run( Evas.Object obj, void* event_info )
36 open();
37 list = new Elm.Genlist( win );
38 debug( "created genlist %p", list );
39 for ( int i = 1; i <= 1000; ++i )
41 list.item_append( itc, (void*)i, null, Elm.GenlistItemFlags.NONE, onSelectedItem );
43 list.show();
44 list.size_hint_weight_set( 1.0, 1.0 );
45 win.resize_object_add( list );
48 public override string name()
50 return "Generic List Example";
53 public static string getLabel( Elm.Object obj, string part )
55 int number = (int)obj;
56 debug( "label_get: %p", obj );
57 return "This is list item #%d".printf( number );
59 public static Elm.Object? getIcon( Elm.Object obj, string part )
61 return null;
62 /* This leads to a SIGSEGV, something's still wrong wrt. those delegates */
64 int number = (int)obj;
65 debug( "icon_get for item %d", number );
66 var icon = new Elm.Icon( list );
67 icon.file_set( "/usr/share/icons/oxygen/128x128/apps/tux.png", null );
68 return icon;
71 public static bool getState( Elm.Object obj, string part )
73 int number = (int)obj;
74 debug( "state_get for item %d", number );
75 return false;
77 public static void delItem( Elm.Object obj )
79 int number = (int)obj;
80 debug( "del for item %d", number );
82 public void onSelectedItem( Evas.Object obj, void* event_info)
84 debug( "item selected on list %p, item %p", obj, event_info );