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



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
#--------------------------------------------#



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