Lumiera  0.pre.03
»edit your freedom«
w-link.hpp File Reference

Go to the source code of this file.

Description

A smart link to an GTK widget with automatic disconnection.

Allows to hold a connection to a trackable without taking ownership. The link is statefull, can be reconnected, and automatically transitions into disconnected state when the target dies. The link state can be tested by bool conversion. WLink objects are fully copyable, and each copy has its own attachment state and can be reconnected independently.

The purpose of WLink is to support collaborations between controllers and widgets or between widgets. Whenever some logic works with or relies on some other UI entity – which it might even _"allocate"_ – without taking ownership, the relation can be implemented with a WLink.

Warning
this class is not threadsafe, because lib SigC++ is not either, and it can only be used reliably from within the GUI thread.
Remarks
the lib SigC++ is used in GTKmm for handling "Signals" and invoking "Slots" (i.e. functors) as result of such a signal. Such is dangerous within the context of an interactive UI, since widgets might go away and be destroyed due to user interaction. To deal with this problem, GTKmm derives all widgets from trackable, which offers an auto deregistration callback, when the object is destroyed, so any remaining signal connections can be dropped to avoid calling a dead functor. We make use of the same mechanism here to install a callback to invalidate this smart-handle.
See also
WLink_test
NotificationHub (usage example)

Definition in file w-link.hpp.

#include "lib/error.hpp"
#include "lib/format-string.hpp"
#include <type_traits>
#include <sigc++/trackable.h>

Classes

class  WLink< TAR >
 Managed link to a sigc::trackable UI widget, without taking ownership. More...
 

Namespaces

 stage
 Lumiera GTK UI implementation root.
 
 stage::model
 The Lumiera GTK-GUI uses a thin proxy layer data model on top of the actual "high-level-model", which lives in the Steam-Layer below.