Re: [Vala] Generated vapi file for a library not compilable.

2012-11-28 Thread Axel FILMORE
On Thu, 29 Nov 2012 13:09:53 +0800
PCMan  wrote:

> Thanks for sharing.
> Manually editing the vapi file works for me too, but this is only a
> workaround.
> After regeneration of vapi files, the changes are gone and need to be
> done again.
> There must be something wrong in valac or my compiler settings.
> We need a way to generate correct vapi files from vala code directly.
> So, it seems that it's a bug in valac?

I done like this in the library :
http://bazaar.launchpad.net/~axel-filmore/valadesktop/spanel-lib/view/head:/src/PanelApplet.vala
http://bazaar.launchpad.net/~axel-filmore/valadesktop/spanel-lib/view/head:/vapi/libspanel.vapi

And like this in the application :
http://bazaar.launchpad.net/~axel-filmore/valadesktop/spanel/view/head:/src/Applets/Weather/WeatherApplet.vala

I don't use any namespace for Applets :)

I don't have the technical explanation however.

:P
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Generated vapi file for a library not compilable.

2012-11-28 Thread Axel FILMORE
On Thu, 29 Nov 2012 10:13:40 +0800
PCMan  wrote:

> Hello,
> I got another issue with vala.
> I moved the core part of my program to a separate library, and let
> the main program call that library.
> The library itself compiles correctly.
> However, the genrated vapi file is not usable by the main program.
> Both parts are written in vala.
> The generated vapi file looks like this.
> 
> When compiling the main program with --pkg , I got
> errors. The generated vapi file seems to have duplicated nested
> namespace for static methods like this.

I had a similar problem doing this :

namespace Panel {
public class MenuApplet {
}
}

public static AppletType register () {

applet_type.id = typeof (MenuApplet); // < it's "PanelMenuApplet"
return applet_type;
}

I found that the type *is not* "MenuApplet" but "PanelMenuApplet",
I just removed the namespaces for Panel Applet that fixed the problem :

public class MenuApplet {
}


public static AppletType register () {

applet_type.id = typeof (MenuApplet);
return applet_type;
}

:)

___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] GTK+ Tutorial

2012-08-30 Thread Axel FILMORE
On 29/08/2012 22:39, Horace Abenga wrote:
> Hi all,
> 
> I'm planning on writing a comprehensive GTK+ programming using Vala tutorial
> that will loosely follow the classic GTK+ tutorial
> (http://developer.gnome.org/gtk-tutorial/2.90/).
> 
> I've done the first four chapters, which can be found (in docbook xml) on
> https://github.com/abenga/valagtktutorial .
> 
> I'm requesting for comments, especially on coding conventions, best
> practice coding
> techniques, and any other suggestions of things I should include or
> remove, before I
> go too far.

Great idea :-P

I agree with David about adding a space before parenthesis, much better
even in C.

My personal rules with Vala are :

- No "using". (something I learned from Elementary Developer Guide :-P)

- No "var", only explicit variable declarations for code clarity.


That's personal taste, now if you adopt the same rules, maybe you can
use "using" and "var" in the first chapter to explain things and not
using it in other chapters to force newcomers to good practices. :-P

:)




-- 
Axel FILMORE
##
  - Vala Desktop -
A New Desktop Written In Vala
  https://launchpad.net/valadesktop
##
  - Vala Compiler -
A Compiler For The GObject Type System
 https://live.gnome.org/Vala
##
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] sqlite3_finalize() ??

2012-06-27 Thread Axel FILMORE

Le 27/06/2012 22:04, Steven Oliver a écrit :


Would you mind enlightening those less endowed with what you see in the
VAPI that answers his question?


As I understand it, it's not needed to call finalize since Vala knows 
the name of the finalize function :


free_function = "sqlite3_finalize"

It will insert the code automagically for you.

There is no finalize function anyway in the Vala object :
http://unstable.valadoc.org/#!api=sqlite3/Sqlite.Statement

:)

--
Axel FILMORE
##
https://github.com/afilmore
##
 Vala - Compiler For The GObject Type System
https://live.gnome.org/Vala
##


___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Chain up base constructor troubles with C code...

2012-05-28 Thread Axel FILMORE

On 28/05/2012 06:52, PCMan wrote:

It looks like you're using libfm/libfmgtk from pcmanfm project. :-)
For performance reasons, in libfm we did not utilize gobject
properties most of the time since we do not need this feature.
So g_object_new with constructor properties won't work.
Just replicating what are done by the C constructor works in this case.


It works, that's fabulous, I'm still missing a few things about
GObject in general, I started GTK+ and Vala in January, I'm a bit new.

I really like Vala, to create some GUI that's fabulous.

On other points, I'm sending you a more detailed reply, I've done a lot 
of experiments indeed.


:)


--
Axel FILMORE
##
https://github.com/afilmore
##
 Vala - Compiler For The GObject Type System
https://live.gnome.org/Vala
##
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Chain up base constructor troubles with C code...

2012-05-27 Thread Axel FILMORE

On 27/05/2012 17:54, Kerrick Staley wrote:

Axel,
I believe that when you're inheriting from a C class in Vala code,
calling the base class's constructor is not supported [1]. Instead, just
replicate the original constructor's functionality at the beginning of
your derived class's constructor:

public class FolderView : Fm.FolderView, BaseView
{
 public FolderView()
 {
 // initialize Fm.FolderView's properties
fmFoldViewProp1 = "foo";
...
 // do FolderView-specific initialization
foldViewProp1 = "bar";
 }
}


It works just great, this is what I have :

public class FolderView : Fm.FolderView, BaseView {

public FolderView (Gtk.Notebook parent, string directory) {

// Object (); // not needed :)
base.set_mode (Fm.FolderViewMode.LIST_VIEW);
base.small_icon_size =  16;
base.big_icon_size =36;
base.single_click = false;
}
}

I first tried to call Object () but you are absolutely correct,
just setting the properties works as expected. Marvelous. :-P

So, here's the result.

The Folder View :
http://pix.toile-libre.org/upload/original/1338136960.png

The Terminal :
http://pix.toile-libre.org/upload/original/1338137023.png

Great information, thanks a lot, I'm not very familiar with GObject yet 
and I often have that kind of troubles with derived classes.


Thank you, best regards.

:)



--
Axel FILMORE
##
https://github.com/afilmore
##
 Vala - Compiler For The GObject Type System
https://live.gnome.org/Vala
##
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


[Vala] Chain up base constructor troubles with C code...

2012-05-27 Thread Axel FILMORE

Hi there,

to avoid some nasty duplicated code I try to use inheritance with a base 
abstract class and derived views.


I need to create a terminal view and a folder view, while it works fine 
with my terminal view which is written in Vala, I've some troubles with 
the folder view which is C code. :(


I have the following :

namespace Manager {

public class FolderView : Fm.FolderView, BaseView {

construct {
base.new (Fm.FolderViewMode.LIST_VIEW);
//Object ();
//base (Fm.FolderViewMode.LIST_VIEW);
}

public FolderView () {
//Object (mode: Fm.FolderViewMode.LIST_VIEW);
//base (Fm.FolderViewMode.LIST_VIEW);

base.new (Fm.FolderViewMode.LIST_VIEW);
}
}
}

I tried a few things without much success, the problem is that the base 
object doesn't seem to be created.


BaseView is an abstract class in Vala and Fm.FolderView is my base 
object in C, the one that gives my some troubles. :-P


In my Vapi file for the base object, I have :

[CCode (cheader_filename = "gtk/fm-folder-view.h")]
public class FolderView : Gtk.ScrolledWindow,
  Atk.Implementor,
  Gtk.Buildable {

public Fm.FolderViewMode   mode;

[CCode (has_construct_function = false,
cname = "fm_folder_view_new",
type = "GtkWidget*")]

public FolderView (int mode);

}


The problem is that the new function (fm_folder_view_new) is not called 
from Vala code.


I tried to use "Object (mode: Fm.FolderViewMode.LIST_VIEW);"
but "mode" is not a property and it fails.

Is there a way so that when doing var = new Manager.FolderView ();
the base function "fm_folder_view_new" is called ?

Thanks. :)


--
Axel FILMORE
##
https://github.com/afilmore
##
 Vala - Compiler For The GObject Type System
https://live.gnome.org/Vala
##
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Passing a callback function as an argument and connect to activate signal, cannot convert error....

2012-04-27 Thread Axel FILMORE

Thanks Luca, it works great.

Marvelous.

:)

On 27/04/2012 20:36, Luca Bruno wrote:
On Fri, Apr 27, 2012 at 7:15 PM, Axel FILMORE <mailto:axel.film...@gmail.com>> wrote:


But I try to add some actions dynamically so I'd like to pass the
callback as an argument.

What I'm doing wrong ?


Nothing, Vala still does not support passing delegates to signal 
handlers. You have to use a lambda instead, something like: 
signal.connect ((foo, bar) => delegate(foo, bar););


--
www.debian.org <http://www.debian.org> - The Universal Operating System



--
Axel FILMORE

___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] Passing a callback function as an argument and connect to activate signal, cannot convert error....

2012-04-27 Thread Axel FILMORE

Hi there,

I try to do the following in Vala without much success :

namespace Test {

public class Popup {

public void create (Callback action_callback) {

Gtk.Action action = new Gtk.Action ("", "", "", null);

action.activate.connect (action_callback);

}
}
}


Then :

Test.Popup test = new Test.Popup ();
test.create ((Callback) _test_template);

I get "Cannot convert from GLib.Callback to Gtk.Action.activate", I 
tried also with (void *), or Gtk.ActionCallback

but I also get compilation errors.

Any idea ?

If I'm doing this, of course it works :

namespace Test {

public class Popup {

public void create (Callback action_callback) {

Gtk.Action action = new Gtk.Action ("", "", "", null);

action.activate.connect (_test_template);

}
private void _test_template (Gtk.Action action) {
}
}
}

But I try to add some actions dynamically so I'd like to pass the 
callback as an argument.


What I'm doing wrong ?

:)

--
Axel FILMORE

___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] cannot convert to a pointer type error when passing Gdk.MotionEvent

2012-03-28 Thread Axel FILMORE

Thanks a lot, it works just fine :-)

private bool on_motion_notify (Gdk.EventMotion evt) {

Gdk.Event* real_e = (Gdk.Event*)(&evt);

Gtk.drag_begin (this,
target_list,
Gdk.DragAction.COPY
| Gdk.DragAction.MOVE
| Gdk.DragAction.LINK,
1,
(Gdk.Event) evt);
}

I tried all sort of things, like Gdk.Event? event = (Gdk.Event*) evt;
but none worked.

Thanks again. :-)



On 28/03/2012 23:51, Eric Gregory wrote:

On Wed, Mar 28, 2012 at 2:38 PM, Axel FILMORE <mailto:axel.film...@gmail.com>> wrote:


Hi there,

I can't get the following code to compile with Vala :

private bool on_motion_notify (Gdk.EventMotion evt) {
   Gtk.drag_begin (this,
   target_list,
   Gdk.DragAction.COPY
   | Gdk.DragAction.MOVE
   | Gdk.DragAction.LINK,
   1,
   (Gdk.Event) evt);
}


Unlike in C, in Vala Gdk.Event is a class and Gdk.EventMotion is a struct.

You might check this thread for a user who had a similar issue:
http://www.mail-archive.com/vala-list@gnome.org/msg08105.html

 - Eric



--
Axel FILMORE

___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] cannot convert to a pointer type error when passing Gdk.MotionEvent

2012-03-28 Thread Axel FILMORE

Hi there,

I can't get the following code to compile with Vala :

private bool on_motion_notify (Gdk.EventMotion evt) {
Gtk.drag_begin (this,
target_list,
Gdk.DragAction.COPY
| Gdk.DragAction.MOVE
| Gdk.DragAction.LINK,
1,
(Gdk.Event) evt);
}

I get the error "cannot convert to a pointer type"

Here's the generated code :

static gboolean desktop_window_on_motion_notify (DesktopWindow* self, 
GdkEventMotion* evt) {

GdkEventMotion _tmp19_;
_tmp19_ = *evt;
gtk_drag_begin ((GtkWidget*) self, _tmp18_, 
(GDK_ACTION_COPY | GDK_ACTION_MOVE) | GDK_ACTION_LINK, 1, (GdkEvent*) 
_tmp19_);

}

I should get something like this :
static gboolean desktop_window_on_motion_notify (DesktopWindow* self, 
GdkEventMotion* evt) {

GdkEventMotion* _tmp19_;
_tmp19_ = evt;
gtk_drag_begin ((GtkWidget*) self, _tmp18_, 
(GDK_ACTION_COPY | GDK_ACTION_MOVE) | GDK_ACTION_LINK, 1, (GdkEvent*) 
_tmp19_);

}

That seems to be the same issue than reported here :
https://mail.gnome.org/archives/vala-list/2009-August/msg7.html

Is it something wrong I'm doing ?
Does anybody know a workaround ?

Regards.


--
Axel FILMORE

___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Compilation error using XClientMessageEvent

2012-01-13 Thread Axel FILMORE

Well, no, currently I can't get it to compile, this sample code is from an
implementation of the system tray specification :
http://standards.freedesktop.org/systemtray-spec/systemtray-spec-latest.html

There's other implementations in plain C but I'd prefer to have it in Vala,
that's cleaner that mixing C and Vala.

I think that code worked before maybe with another version of the compiler
or with a modified vapi file, I don't know.

:)


On 13/01/2012 19:54, Timo Kluck wrote:

Hi Axel,


I'm missing something, any help would be appreciated.

Thanks.


I tried modifying x11.vala like this, which almost makes your code work:

[CCode (cname = "union { char b[20]; short s[10]; long l[5]; }")]
public struct ClientMessageEventData {

which gives the following error:

incompatible types when assigning to type ‘union’ from
type ‘union’

So it turns out that you cannot make your own variable of the same
type as the anonymous union and have C consider them as the same type.
I don't think there's an easy way out of this. The fact that the union
is anonymous is beyond vala's control.

Does copying the entire ClientMessageEvent work for you?

Timo Kluck




--
Axel FILMORE

___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] X11 and pointers help

2012-01-13 Thread Axel FILMORE
gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list




--
Axel FILMORE

___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] Compilation error using XClientMessageEvent

2012-01-13 Thread Axel FILMORE

Hi,

then I try to compile the following code with vala 0.14, I get a 
compilation error from gcc :


using Gtk;
using Gdk;
using X;


public class Test : Object {

enum Message {
REQUEST_DOCK,
BEGIN,
CANCEL
}

private void add_client (long xid) {
}

private void event_filter (Gdk.XEvent xev) {
void* pointer = &xev;
X.Event* xevent = (X.Event*) pointer;

if (xevent->xclient.data.l [1] == Message.REQUEST_DOCK)
add_client (xevent->xclient.data.l [2]);
return;
}

static int main (string[] args) {
Gtk.init (ref args);
Gtk.main ();
return 0;
}
}


valac --pkg x11 --pkg gtk+-3.0 --pkg gdk-x11-3.0 xlib.vala
xlib.vala:17.5-17.29: warning: method `Test.event_filter' never used
private void event_filter (Gdk.XEvent xev) {
^
/home/hotnuma/Bureau/Projets/samples/x11/xlib.vala.c: In function 
'test_event_filter':
/home/hotnuma/Bureau/Projets/samples/x11/xlib.vala.c:83:2: erreur: 
unknown type name 'ClientMessageEventData'
/home/hotnuma/Bureau/Projets/samples/x11/xlib.vala.c:94:9: erreur: 
incompatible types when assigning to type 'int' from type 'union 
'
/home/hotnuma/Bureau/Projets/samples/x11/xlib.vala.c:95:17: erreur: 
request for member 'l' in something not a structure or union
/home/hotnuma/Bureau/Projets/samples/x11/xlib.vala.c:96:25: erreur: 
request for member 'l_length1' in something not a structure or union
/home/hotnuma/Bureau/Projets/samples/x11/xlib.vala.c:101:3: erreur: 
unknown type name 'ClientMessageEventData'
/home/hotnuma/Bureau/Projets/samples/x11/xlib.vala.c:107:10: erreur: 
incompatible types when assigning to type 'int' from type 'union 
'
/home/hotnuma/Bureau/Projets/samples/x11/xlib.vala.c:108:18: erreur: 
request for member 'l' in something not a structure or union
/home/hotnuma/Bureau/Projets/samples/x11/xlib.vala.c:109:26: erreur: 
request for member 'l_length1' in something not a structure or union

error: cc exited with status 256
Compilation failed: 1 error(s), 1 warning(s)

ClientMessageEventData is an union to ClientMessageEvent (x11.vapi)  :

public struct ClientMessageEvent {
public int type;
public ulong serial;/* # of last request processed by server */
public bool send_event;/* true if this came from a 
SendEvent request */
public unowned Display display;/* Display the event was 
read from */

public Window window;
public Atom message_type;
public int format;
    public ClientMessageEventData data;
}


I'm missing something, any help would be appreciated.

Thanks.





-- Axel FILMORE
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Vapi help

2012-01-11 Thread Axel FILMORE
Attached files are an example I have done, I use the vala-gen-introspect 
method :

https://live.gnome.org/Vala/Bindings/GI

Then I modifed the generated file, I had to tweak the "cname" and 
"cprefix" values

in order that it works.

Well I'm not an expert I don't know if it's really correct, but it works 
fine, it seems

that you have the same troubles.

Regards.

On 10/01/2012 23:52, Denis Kuzmenok wrote:

Hi.
I  need  some  help  with  vapi  file.  I'm making vapi for C non-Glib
library. There are structs, i write them into vapi, as
  namespace AC ->  struct AC_Automata

And i'm getting errors:
undefined reference to `ac_ac_automata_destroy'

But  there  is no destroy calls in .c files (except one free call from
the  function),  so  i  suppose it's some vapi magic that inserts that
calls.
Is  there any docs describing possible variables for CCode? There is a
link to image on live.gnome.org, but it's broken..

Thanks.

___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list




--
Axel FILMORE

/* libmenu-cache.vapi generated by vapigen, do not modify. */

namespace Mc {
	[CCode (cname = "MenuCache", cprefix="menu_cache_", cheader_filename = "menu-cache.h", ref_function = "menu_cache_ref", unref_function = "menu_cache_unref")]
	[Compact]
	public class Cache {
		public void* add_reload_notify (GLib.Func func);
		public uint32 get_desktop_env_flag (string desktop_env);
		public unowned CacheDir get_dir_from_path (string path);
		public unowned CacheDir get_root_dir ();
		public static void init (int flags);
		public unowned GLib.SList list_all_apps ();
		public static unowned Cache lookup (string menu_name);
		public static unowned Cache lookup_sync (string menu_name);
		public bool reload ();
		public void remove_reload_notify (void* notify_id);
	}
	[CCode (cname = "MenuCacheApp", cprefix="menu_cache_app_", cheader_filename = "menu-cache.h")]
	[Compact]
	public class CacheApp {
		public unowned string get_exec ();
		public bool get_is_visible (uint32 de_flags);
		public uint32 get_show_flags ();
		public bool get_use_sn ();
		public bool get_use_terminal ();
		public unowned string get_working_dir ();
	}
	[CCode (cname = "MenuCacheDir", cprefix="menu_cache_dir_", cheader_filename = "menu-cache.h")]
	[Compact]
	public class CacheDir {
		public unowned GLib.SList get_children ();
		public unowned string make_path ();
	}
	[CCode (cname = "MenuCacheItem", cprefix="menu_cache_item_", cheader_filename = "menu-cache.h", ref_function = "menu_cache_item_ref", unref_function = "menu_cache_item_unref")]
	[Compact]
	public class CacheItem {
		public unowned Type get_type ();
		public unowned string get_comment ();
		public unowned string get_file_basename ();
		public unowned string get_file_dirname ();
		public unowned string get_file_path ();
		public unowned string get_icon ();
		public unowned string get_id ();
		public unowned string get_name ();
		public unowned CacheDir get_parent ();
	}
	[CCode (cname="MenuCacheItemFlag", cheader_filename = "menu-cache.h", cprefix = "FLAG_", has_type_id = false)]
	public enum Item {
		USE_TERMINAL,
		USE_SN
	}
	[CCode (cname="MenuCacheShowFlag", cheader_filename = "menu-cache.h", cprefix = "SHOW_", has_type_id = false)]
	public enum Show {
		IN_LXDE,
		IN_GNOME,
		IN_KDE,
		IN_XFCE,
		IN_ROX,
		N_KNOWN_DESKTOPS
	}
	[CCode (cname="MenuCacheType", cheader_filename = "menu-cache.h", cprefix = "MENU_CACHE_TYPE_", has_type_id = false)]
	public enum Type {
		NONE,
		DIR,
		APP,
		SEP
	}
}
/* libmenu-cache.vapi generated by vapigen, do not modify. */

namespace Menu {
[CCode (cheader_filename = "libmenu-cache.h", ref_function = 
"menu_cache_ref", unref_function = "menu_cache_unref")]
[Compact]
public class Cache {
public void* add_reload_notify (GLib.Func func);
public uint32 get_desktop_env_flag (string desktop_env);
public unowned Menu.CacheDir get_dir_from_path (string path);
public unowned Menu.CacheDir get_root_dir ();
public static void init (int flags);
public unowned GLib.SList list_all_apps ();
public static unowned Menu.Cache lookup (string menu_name);
public static unowned Menu.Cache lookup_sync (string menu_name);
public bool reload ();
public void remove_reload_notify (void* notify_id);
}
[CCode (cheader_filename = "libmenu-cache.h")]
[Compact]
public class CacheApp {
public unowned string get_exec ();