Google recently found
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
static void
activate (GApplication *application)
{
g_application_hold (application);
g_print ("activated\n");
g_application_release (application);
}
static void
activate_action (GAction *action,
GVariant *parameter,
gpointer data)
{
GApplication *application = G_APPLICATION (data);
g_application_hold (application);
This file has been truncated. show original
to help me understanding how toggle_action can be used.
Most seems to make sense, but I still wonder why
g_application_hold (application);
is used there. Can it really happen that
static void activate_toggle_action () is interrupted? Generally GTK main loop is regarded as single-threaded?
May that be only for future GTK version, which may use treads and parallel processing?
Well, I think glib and gio supports threads, so maybe activate_toggle_action () can be indeed called by threads, so I will also use g_application_hold for the Nim example. Works fine already:
proc activateToggleAction(action: SimpleAction; parameter: Variant; app: Application) =
app.hold
block:
echo format("action $1 activated", action.name)
let state: Variant = action.state
let b = state.boolean
action.state = newVariantBoolean(not b)
echo format("state change $1 -> $2", b, not b)
app.release
system
(system)
Closed
July 5, 2019, 8:21am
3
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.