Created
March 12, 2021 05:17
-
-
Save lidaobing/78feffc2b937f4fbe1f91b5b1e7da7e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Result: | |
// signal does not depends on main loop | |
// GSimpleAction is a very useful tool for DocView model | |
#include <gio/gio.h> | |
namespace { | |
bool c1 = false; | |
bool c2 = false; | |
void callback1() { | |
c1 = true; | |
} | |
void callback2() { | |
c2 = true; | |
} | |
} | |
int main() { | |
auto a = g_simple_action_new("a", nullptr); | |
g_signal_connect(a, "activate", callback1, nullptr); | |
g_signal_connect(a, "activate", callback2, nullptr); | |
g_action_activate(G_ACTION(a), nullptr); | |
g_assert(c1); | |
g_assert(c2); | |
} | |
// compile command: | |
// g++ -std=c++11 `pkg-config --cflags --libs gio-2.0` GioTest.cpp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment