solus-project / budgie-desktop-examples

Examples on how to create trivial Budgie Desktop Applets
MIT License
19 stars 11 forks source link

add get_applet_settings to C example #3

Open fossfreedom opened 7 years ago

fossfreedom commented 7 years ago

in the vala example there is example code for using the applet settings functions e.g. member function "get_applet_settings" - var settings = this.get_applet_settings(uuid);

Any chance of an equivalent example code for the C example please? ... having difficulty trying to translate the Vala example to C ...

ikeydoherty commented 7 years ago

Yeah the C example is actually pretty crap, and I can't remember if it handles the dispose chain properly. I'll redo it to be nice and include all the typical Budgie bits one needs

ikeydoherty commented 7 years ago

FWIW in the mean time..:

https://github.com/solus-project/budgie-desktop-examples/blob/master/c_project/NativeApplet.c#L78

static void native_applet_init(__budgie_unused__ NativeApplet *self)
{
}

This is where you do basic initialisation, before you have access to any gobject properties. The constructor will need modifying to pass the uuid. Now, in GObject C you're only guaranteed to have these constructor-time properties set in the construct function, so we need to override the GObjectClassvtable to have a ->construct method, which can then set to do something like:

self->settings = budgie_applet_get_applet_settings(BUDGIE_APPLET(self), ourUUID);

I'll flesh out the example. I suspect a slight API change in 11 to make this less derpy. It catered to Valaisms unfortunately.

ikeydoherty commented 7 years ago

Moved this under the new org, slipped my mind

fossfreedom commented 7 years ago

Hi Ikey - noticed you have updated the example! cheers.

I compiled and installed the example - saw the "I am groot" by adding the new applet.

When removing the applet via raven - the panel crashed. (Ubuntu 16.04)

backtrace enc - thoughts on what the issue is?

http://paste.ubuntu.com/23482435/

ikeydoherty commented 7 years ago

Yeah seeing it here too, haven't yet tracked it down fully. I know that its happening in the library itself (Dereferencing ->priv which SHOULD be initialised..)

fossfreedom commented 7 years ago

k - sorry Ikey - just got back to looking at this.

so we think this is a budgie-panel issue itself or something wrong with the example itself?

If the former - should this be tracked on the budgie-desktop tracker?