1 #include "where_people_look/gui_cb.h"
7 #include "where_people_look/experiment.h"
14 bool cb_finish_assistant(
const GtkWidget*,
15 const GtkWidget* window) {
16 gtk_window_present(GTK_WINDOW(window));
17 gtk_window_fullscreen(GTK_WINDOW(window));
21 bool cb_key_press(
const GtkWidget*,
22 const GdkEventKey* event_key) {
23 switch (event_key->keyval) {
25 if (event_key->state & GDK_MOD1_MASK) {
29 case GDK_KEY_q:
case GDK_KEY_W:
30 if (event_key->state & GDK_META_MASK) {
38 bool cb_update_config(GtkWidget*
const widget,
39 Experiment*
const experiment) {
41 if (!widget_name.
compare(
"subject_id")) {
42 experiment->get_config()->set_subject_id(
43 std::string(gtk_entry_get_text(GTK_ENTRY(widget))));
44 }
else if (!widget_name.
compare(
"stimuli_dir_path")) {
45 experiment->get_config()->set_stimuli_dir_path(
46 std::string(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget))));
49 if (experiment->get_config()->assistant_data_complete()) {
50 GtkWidget* grid = gtk_widget_get_parent(widget);
51 GtkWidget* assistant = gtk_widget_get_ancestor(grid, GTK_TYPE_ASSISTANT);
52 gtk_assistant_set_page_complete(GTK_ASSISTANT(assistant),
58 void register_and_connect_callbacks(GtkBuilder*
const builder,
59 Experiment*
const experiment) {
60 gtk_builder_add_callback_symbols(builder,
61 "cb_finish_assistant", G_CALLBACK(cb_finish_assistant),
62 "cb_key_press", G_CALLBACK(cb_key_press),
65 "cb_update_config", G_CALLBACK(cb_update_config),
66 static_cast<void*>(0));
68 gtk_builder_connect_signals(builder, experiment);
71 void set_css_style(GtkWidget*
const window,
72 const char*
const css_resource) {
73 GtkStyleContext* style_context = gtk_widget_get_style_context(window);
74 GtkCssProvider* style_provider = gtk_css_provider_new();
75 gtk_css_provider_load_from_resource(style_provider, css_resource);
76 gtk_style_context_add_provider(style_context,
77 GTK_STYLE_PROVIDER(style_provider),
78 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
static bool experiment_prepare(const GtkWidget *const assistant, Experiment *const experiment)
static bool experiment_start(const GtkWidget *const window, const GdkEventKey *const event_key, Experiment *const experiment)
int compare(const basic_string &__str) const
basic_string< char > string