Scroom 0.14-48-ga0fee447
Loading...
Searching...
No Matches
Scroom::GtkHelpers Namespace Reference

Namespaces

namespace  Detail
 

Functions

template<typename T >
std::pair< GSourceFunc, gpointer > wrap (T f)
 
bool on_ui_thread ()
 
template<typename T >
void async_on_ui_thread (T f)
 
template<typename T >
void async_on_ui_thread_and_wait (T f)
 
template<typename T >
void sync_on_ui_thread (T f)
 
cairo_rectangle_int_t createCairoIntRectangle (int x, int y, int width, int height)
 
GtkWindow * get_parent_window (GtkWidget *widget)
 

Function Documentation

◆ async_on_ui_thread()

template<typename T >
void Scroom::GtkHelpers::async_on_ui_thread ( f)
43 {
44 const auto [function, data] = wrap(std::move(f));
45 gdk_threads_add_idle(function, data);
46 }
uint8_t data
Definition blob-tests.cc:36
f
Definition gtkhelper-tests.cc:43
std::pair< GSourceFunc, gpointer > wrap(T f)
Definition gtk-helpers.hh:34

Referenced by async_on_ui_thread_and_wait(), TiledBitmapViewData::tileLoaded(), and Scroom::GtkTestHelpers::GtkMainLoop::~GtkMainLoop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ async_on_ui_thread_and_wait()

template<typename T >
void Scroom::GtkHelpers::async_on_ui_thread_and_wait ( f)
50 {
52 std::packaged_task<void(void)> t(std::move(f));
53 std::future<void> const future = t.get_future();
54 async_on_ui_thread(std::move(t));
55 future.wait();
56 }
#define require(expr)
Definition assertions.hh:30
() void(clear(nullptr)+(5 *clear(nullptr)) *5)
bool on_ui_thread()
Definition gtk-helpers.cc:15
void async_on_ui_thread(T f)
Definition gtk-helpers.hh:42
ThreadPool t(0)

Referenced by sync_on_ui_thread().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createCairoIntRectangle()

cairo_rectangle_int_t Scroom::GtkHelpers::createCairoIntRectangle ( int  x,
int  y,
int  width,
int  height 
)
inline
72 {
73 cairo_rectangle_int_t rect;
74 rect.x = x;
75 rect.y = y;
76 rect.width = width;
77 rect.height = height;
78 return rect;
79 }
const auto rect
Definition rectangletests.cc:335

Referenced by createCairoIntRectangle(), and Scroom::Utils::Rectangle< T >::toGdkRectangle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_parent_window()

GtkWindow * Scroom::GtkHelpers::get_parent_window ( GtkWidget *  widget)
18 {
19 auto* topLevel = gtk_widget_get_toplevel(widget);
20 if(GTK_IS_WINDOW(topLevel))
21 {
22 return GTK_WINDOW(topLevel);
23 }
24
25 return nullptr;
26 }

Referenced by on_image_properties_activate().

Here is the caller graph for this function:

◆ on_ui_thread()

bool Scroom::GtkHelpers::on_ui_thread ( )
15{ return g_main_context_is_owner(g_main_context_default()); }

Referenced by async_on_ui_thread_and_wait(), sync_on_ui_thread(), and sync_on_ui_thread().

Here is the caller graph for this function:

◆ sync_on_ui_thread()

template<typename T >
void Scroom::GtkHelpers::sync_on_ui_thread ( f)
60 {
61 if(on_ui_thread())
62 {
63 f();
64 }
65 else
66 {
67 async_on_ui_thread_and_wait(std::move(f));
68 }
69 }

Referenced by View::addToolButton(), PipetteHandler::computeValues(), PipetteHandler::displayValues(), invalidate_view(), Scroom::TiledBitmap::scheduleLoadingBitmap(), ProgressBarManager::setWorking(), TiledBitmap::tileFinished(), and Metadata::viewAdded().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wrap()

template<typename T >
std::pair< GSourceFunc, gpointer > Scroom::GtkHelpers::wrap ( f)
35 {
36 return std::make_pair<GSourceFunc, gpointer>(Detail::gtkWrapper<T>, new T(std::move(f)));
37 }

Referenced by async_on_ui_thread().

Here is the caller graph for this function: