Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8049471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:47:43+00:00 2026-06-05T06:47:43+00:00

I did a class whoss parent class is gtk.box in vala. linking to box

  • 0

I did a class whoss parent class is gtk.box in vala. linking to box constructor is not supported, so, how can I set the Orientation of the box in the constructor??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:47:45+00:00Added an answer on June 5, 2026 at 6:47 am

    While calling this.set_orientation (Gtk.Orientation.VERTICAL) might work, the more correct way to do this would be to set the orientation property at construct time, just like the Gtk.Box default constructor does. In Vala, you would do something like this:

    public class MyBox : Gtk.Box {
      public MyBox () {
        GLib.Object (orientation: Gtk.Orientation.VERTICAL);
      }
    }
    

    At the C level, this is a bit different than just calling set_orientation… it will generate something a bit like this (simplified for clarity):

    MyBox* my_box_new () {
      return g_object_new (GTK_TYPE_BOX, "orientation", GTK_ORIENTATION_VERTICAL, NULL);
    }
    

    Calling set_orientation (or setting the orientation property), on the other hand, would generate something like this:

    MyBox* my_box_new () {
      MyBox* self = g_object_new (GTK_TYPE_BOX, NULL);
      gtk_box_set_orientation (GTK_BOX(self), GTK_ORIENTATION_VERTICAL);
      return self;
    }
    

    The difference is that for the first version the orientation will be set correctly during instantiation (in other words, during the construct block of each of the ancestor classes), whereas for the second version the object will first be created with the wrong orientation, then the orientation will be changed. I’m not sure whether or not this difference is significant for Gtk.Box, but in some cases it is very important so it’s probably a good idea to get in the habit of doing it the right way.

    If you’re not sure what I mean by “construct block”, take a look a the section in the Vala Tutorial on GObject-Style Construction.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Earlier I had a problem when an inner anonymous class did not see a
The story: I had class User and class Organization: User. I did not use
I am writing a daemon in PHP. I did not take a OS class
I did my own Socket class, to be able to send and receive HTTP
I did create a XDateTime class that is able to handle inaccurate date and
My coworker did this experiment: public class DoubleDemo { public static void main(String[] args)
I was writing a metaclass and accidentally did it like this: class MetaCls(type): def
What is special about addid a parameterless constructor to a non serializable, extendable class.
I have a custom class loader so that a desktop application can dynamically start
Got some error in codeigniter when trying to call parent class. This is what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.