static void on_button_hash_clicked(void) { if (gui_get_view() == GUI_VIEW_FILE) { // XXX: Workaround for when user clicks Cancel in FileChooserDialog and // XXX: uri is changed without emitting the "selection-changed" signal on_filechooserbutton_selection_changed(); if (!gtk_widget_get_sensitive(GTK_WIDGET(gui.button_hash))) return; } switch (gui_get_view()) { case GUI_VIEW_FILE: { gui_clear_digests(); gui_set_state(GUI_STATE_BUSY); char *uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER( gui.filechooserbutton)); hash_file_start(uri); break; } case GUI_VIEW_TEXT: hash_string(); break; case GUI_VIEW_FILE_LIST: gui_clear_digests(); gui_set_state(GUI_STATE_BUSY); hash_file_list_start(); break; default: g_assert_not_reached(); } }
static void gui_level(int id, int i) { struct level *l = get_level(i); const GLubyte *fore = 0; const GLubyte *back = 0; int jd; if (!l) { gui_label(id, " ", GUI_SML, gui_blk, gui_blk); return; } if (level_opened(l)) { fore = level_bonus(l) ? gui_grn : gui_wht; back = level_completed(l) ? fore : gui_yel; } jd = gui_label(id, level_name(l), GUI_SML, back, fore); if (level_opened(l) || config_cheat()) gui_set_state(jd, START_LEVEL, i); }
void gtkhash_hash_file_stop_cb(G_GNUC_UNUSED void *data) { gdk_threads_enter(); if (hash_priv.uris) { g_slist_free_full(hash_priv.uris, g_free); hash_priv.uris = NULL; } gui_set_state(GUI_STATE_IDLE); gdk_threads_leave(); }
static int gui_demo_thumbs(int id) { int w = video.device_w; int h = video.device_h; int jd, kd, ld; int i, j; int row = w < h ? DEMO_LINEP : DEMO_LINEL; int iw = (w - 160) / row; int ih = iw * 3 / 4; struct thumb *thumb; if ((jd = gui_varray(id))) for (i = first; i < first + DEMO_STEP; i += row) if ((kd = gui_harray(jd))) { for (j = i + row - 1; j >= i; j--) { thumb = &thumbs[j % DEMO_STEP]; thumb->item = j; if (j < total) { if ((ld = gui_vstack(kd))) { gui_space(ld); thumb->shot = gui_image(ld, " ", iw, ih); thumb->name = gui_label(ld, " ", GUI_SML, gui_wht, gui_wht); gui_set_trunc(thumb->name, TRUNC_TAIL); gui_set_state(ld, DEMO_SELECT, j); } } else { gui_space(kd); thumb->shot = 0; thumb->name = 0; } } } return jd; }
static int gui_demo_thumbs(int id) { int w = config_get_d(CONFIG_WIDTH); int h = config_get_d(CONFIG_HEIGHT); int jd, kd, ld; int i, j; struct thumb *thumb; if ((jd = gui_varray(id))) for (i = first; i < first + DEMO_STEP; i += DEMO_LINE) if ((kd = gui_harray(jd))) { for (j = i + DEMO_LINE - 1; j >= i; j--) { thumb = &thumbs[j % DEMO_STEP]; thumb->item = j; if (j < total) { if ((ld = gui_vstack(kd))) { gui_space(ld); thumb->shot = gui_image(ld, " ", w / 6, h / 6); thumb->name = gui_label(ld, " ", GUI_SML, gui_wht, gui_wht); gui_set_trunc(thumb->name, TRUNC_TAIL); gui_set_state(ld, DEMO_SELECT, j); } } else { gui_space(kd); thumb->shot = 0; thumb->name = 0; } } } return jd; }
void gtkhash_hash_file_finish_cb(G_GNUC_UNUSED void *data) { const bool stop = gtkhash_hash_file_get_stop(&hash_priv.file_data); switch (gui_get_view()) { case GUI_VIEW_FILE: { if (stop) break; for (int i = 0; i < HASH_FUNCS_N; i++) { const char *digest = gtkhash_hash_func_get_digest(&hash.funcs[i], gui_get_digest_format()); gtk_entry_set_text(gui.hash_widgets[i].entry_file, digest); } break; } case GUI_VIEW_FILE_LIST: { g_assert(hash_priv.uris); g_assert(hash_priv.uris->data); if (stop) break; for (int i = 0; i < HASH_FUNCS_N; i++) { const char *digest = gtkhash_hash_func_get_digest(&hash.funcs[i], gui_get_digest_format()); list_set_digest(hash_priv.uris->data, i, digest); } g_free(hash_priv.uris->data); hash_priv.uris = g_slist_delete_link(hash_priv.uris, hash_priv.uris); if (hash_priv.uris) { hash_file_start(hash_priv.uris->data); return; } break; } default: g_assert_not_reached(); } gui_set_state(GUI_STATE_IDLE); }
void gui_init(const char *datadir) { gtk_init(NULL, NULL); GtkBuilder *builder = gtk_builder_new(); gtk_builder_set_translation_domain(builder, GETTEXT_PACKAGE); char *filename = g_build_filename(datadir, PACKAGE ".xml", NULL); GError *error = NULL; gtk_builder_add_from_file(builder, filename, &error); g_free(filename); if (error) { GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", error->message); gtk_window_set_title(GTK_WINDOW(dialog), PACKAGE_NAME); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); g_error_free(error); g_object_unref(builder); exit(EXIT_FAILURE); } gui_get_objects(builder); g_object_ref(gui.menu_treeview); g_object_unref(builder); gui_init_hash_funcs(); gtk_window_set_transient_for(GTK_WINDOW(gui.dialog), gui.window); gui_set_state(GUI_STATE_IDLE); callbacks_init(); }
static int video_gui(void) { static const struct conf_option multisample_opts[] = { { N_("Off"), 0 }, { N_("2x"), 2 }, { N_("4x"), 4 }, { N_("8x"), 8 }, }; int id, jd; if ((id = gui_vstack(0))) { char resolution[sizeof ("12345678 x 12345678")]; const char *display; int dpy = config_get_d(CONFIG_DISPLAY); sprintf(resolution, "%d x %d", config_get_d(CONFIG_WIDTH), config_get_d(CONFIG_HEIGHT)); if (!(display = SDL_GetDisplayName(dpy))) display = _("Unknown Display"); conf_header(id, _("Graphics"), GUI_BACK); if ((jd = conf_state(id, _("Display"), "Longest Name", VIDEO_DISPLAY))) { gui_set_trunc(jd, TRUNC_TAIL); gui_set_label(jd, display); } conf_toggle(id, _("Fullscreen"), VIDEO_FULLSCREEN, config_get_d(CONFIG_FULLSCREEN), _("On"), 1, _("Off"), 0); if ((jd = conf_state (id, _("Resolution"), resolution, VIDEO_RESOLUTION))) { /* * Because we always use the desktop display mode, disable * display mode switching in fullscreen. */ if (config_get_d(CONFIG_FULLSCREEN)) { gui_set_state(jd, GUI_NONE, 0); gui_set_color(jd, gui_gry, gui_gry); } } #if ENABLE_HMD conf_toggle(id, _("HMD"), VIDEO_HMD, config_get_d(CONFIG_HMD), _("On"), 1, _("Off"), 0); #endif gui_space(id); conf_toggle(id, _("V-Sync"), VIDEO_VSYNC, config_get_d(CONFIG_VSYNC), _("On"), 1, _("Off"), 0); conf_select(id, _("Antialiasing"), VIDEO_MULTISAMPLE, config_get_d(CONFIG_MULTISAMPLE), multisample_opts, ARRAYSIZE(multisample_opts)); gui_space(id); conf_toggle(id, _("Reflection"), VIDEO_REFLECTION, config_get_d(CONFIG_REFLECTION), _("On"), 1, _("Off"), 0); conf_toggle(id, _("Background"), VIDEO_BACKGROUND, config_get_d(CONFIG_BACKGROUND), _("On"), 1, _("Off"), 0); conf_toggle(id, _("Shadow"), VIDEO_SHADOW, config_get_d(CONFIG_SHADOW), _("On"), 1, _("Off"), 0); gui_layout(id, 0, 0); } return id; }
static int course_enter(struct state *st, struct state *prev) { int w = config_get_d(CONFIG_WIDTH); int h = config_get_d(CONFIG_HEIGHT); int id, jd, kd, ld, md; int i, j, r, c, n; n = course_count(); r = comp_rows(n); c = comp_cols(n); if ((id = gui_vstack(0))) { gui_label(id, _("Select Course"), GUI_MED, 0, 0); gui_space(id); if ((jd = gui_hstack(id))) { shot_id = gui_image(jd, course_shot(0), w / 3, h / 3); gui_filler(jd); if ((kd = gui_varray(jd))) { for(i = 0; i < r; i++) { if ((ld = gui_harray(kd))) { for (j = c - 1; j >= 0; j--) { int k = i * c + j; if (k < n) { md = gui_image(ld, course_shot(k), w / 3 / c, h / 3 / r); gui_set_state(md, k, 0); if (k == 0) gui_focus(md); } else gui_space(ld); } } } } } gui_space(id); desc_id = gui_multi(id, _(course_desc(0)), GUI_SML, gui_yel, gui_wht); gui_space(id); if ((jd = gui_hstack(id))) { gui_filler(jd); gui_state(jd, _("Back"), GUI_SML, COURSE_BACK, 0); } gui_layout(id, 0, 0); } audio_music_fade_to(0.5f, "bgm/inter.ogg"); return id; }