[SOLVED]: nemo_window_slot_init?

About programming and getting involved with Linux Mint development
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
Mike888
Level 2
Level 2
Posts: 85
Joined: Fri Apr 17, 2020 3:09 pm

[SOLVED]: nemo_window_slot_init?

Post by Mike888 »

Hello,

I am trundling through the Nemo code and am seeing the "nemo_window_slot_init" function; but, I cannot find where that function is called.

The call to this function has to come from within Nemo doesn't it?
Last edited by LockBot on Tue Jan 30, 2024 11:00 pm, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Mike888
Level 2
Level 2
Posts: 85
Joined: Fri Apr 17, 2020 3:09 pm

Re: nemo_window_slot_init?

Post by Mike888 »

To understand how the nemo_window_slot_init() function is called, it is first necessary to understand how GTK works.

GTK provides an object-oriented library based on GObject, methods and properties.

In a C++ object-oriented framework you have a constructor & a destructor. The code within the constructor is automatically run when the associated object is created (instantiated).

In GTK, there are two constructors and they are called base_init & class_init (Actually they are called 'gtk_init()" and gtk_class_init()' in the GTK library).

The GTK documentation also states that after these init methods (functions) are executed that an activate or an open method is executed.

In 'nemo-window-slot.c' there is this DEFINE statement:

Code: Select all

G_DEFINE_TYPE (NemoWindowSlot, [b]nemo_window_slot[/b], GTK_TYPE_BOX);
This essentially overrides (supersedes) the builtin init() function of GTK: gtk_init(). The overridden method is called nemo_window_slot_init(). You can see how the G_DEFINE_TYPE causes the gtk part (of gtk_init) to be replaced with nemo_window_slot redirecting it to an app that is defined in the Nemo code.

The definition of the nemo_window_slot_init function appears in 'nemo-window-slot.c'.

So, once the Nemo Window Slot object is instantiated, the nemo_window_slot_init function is automatically run.

The instantiation of the Nemo Window Slot object is as follows:

Code: Select all

slot = g_object_new (NEMO_TYPE_WINDOW_SLOT, NULL);
You can find this line of code in nemo-window-slot.c within the function NemoWindowSlot *nemo_window_slot_new (NemoWindowPane *pane) function.

Also, interestingly, this nemo_window_slot_new function is overridden from the GTK library as well. It is called gtk_new() within the GTK library.
Locked

Return to “Programming & Development”