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



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.

Besides, I need to inform you that recently we changed some APIs in
libfm and libfm-gtk.
To simplify things, some APIs you may use are removed, such as
fm_folder_view_chdir().
Please take a look at libfm/src/demo/main-win.c to see how to use the new APIs.

Now this is the standard way to make a FmFolderView showing a specified folder.
1. Load the folder content with FmFolder, fm_folder_get(path);
2. Create a FmFolderModel for the FmFolder so it can be viewed.
3. Set the FmFolderModel to FmFolderView.

It might takes more lines of code, but things actually became more
flexible and cleaner.
If you want to monitor the changes of the folder, connect to FmFolder
signals directly.
1. "start-loading" signal and "finish-loading" signals tell you when a
folder is being loaded and when it's finished.
  fm_folder_reload() triggers these signals as well.
2. "fs-info" signal is for filesystem information.
3. "unmount" signal tells you that a folder is unmoted.

The new way looks more complicated initially, but soon you'll find it
more reasonable and less error-prone.

Besides, did you write your own libfm.vapi file? We have one in
libfm/src/vapi, too.
The one we have is not completed and it's a good idea for us to use
one single libfm.vap.
Maybe we can merge our vapi files?

On Sun, May 27, 2012 at 7:51 PM, Axel FILMORE <axel filmore gmail com> wrote:
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



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