1

I need to edit some code regarding changing desktop wallpaper. Unfortunately I don't know Vala, but I found this piece of code in Wallpaper.vala file of the switchboard-plug-pantheon-shell package:

[DBus (name = "org.freedesktop.Accounts.User")]
interface AccountsServiceUser : Object {
    public abstract void set_background_file (string filename) throws IOError;
}

It looks to me like a definition of some "extern" function for further calls. Am I right? Where can I find the body of this function?

Thank you!

2

What you're looking at here is an interface with an abstract method. Virtually all OOP languages have a similar concept to interfaces, but since you didn't specify which language(s) you do know I can't really draw a parallel to something you're already familiar with. Explaining the concept from scratch is really beyond the scope of a SO answer; you might want to take a look at https://wiki.gnome.org/Projects/Vala/Tutorial#Interfaces-1

The abstract keyword is a bit more interesting; Vala interfaces can be used as mixins. Methods can be implemented either in the interface (in which case they are non-abstract) or left for classes which actually implement that interface to implement (in which case they are abstract). This allows you to share more code than purely abstract interfaces would.

Basically, you can find the implementations of that method in every non-abstract class which implements that interface.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.