Example #1
0
static void default_hash_funcs(void)
{
	// Some funcs could already be enabled by cmdline arg
	if (hash_funcs_count_enabled())
		return;

	bool has_enabled = false;

	// Try to enable default functions
	for (int i = 0; i < HASH_FUNCS_N; i++) {
		if (HASH_FUNC_IS_DEFAULT(i) && hash.funcs[i].supported) {
			gtk_toggle_button_set_active(gui.hash_widgets[i].button, true);
			has_enabled = true;
		}
	}

	if (has_enabled)
		return;

	// Try to enable any supported function
	for (int i = 0; i < HASH_FUNCS_N; i++) {
		if (hash.funcs[i].supported) {
			gtk_toggle_button_set_active(gui.hash_widgets[i].button, true);
			return;
		}
	}

	gui_error(_("Failed to enable any supported hash functions."));
	exit(EXIT_FAILURE);
}
Example #2
0
static void default_hash_funcs(void)
{
	bool has_enabled = false;

	// Try to enable default functions
	for (int i = 0; i < HASH_FUNCS_N; i++)
		if (HASH_FUNC_IS_DEFAULT(i) && hash.funcs[i].supported) {
			gtk_toggle_button_set_active(gui.hash_widgets[i].button, true);
			has_enabled = true;
		}

	if (has_enabled)
		return;

	// Try to enable any supported function
	for (int i = 0; i < HASH_FUNCS_N; i++)
		if (hash.funcs[i].supported) {
			gtk_toggle_button_set_active(gui.hash_widgets[i].button, true);
			return;
		}

	GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
		GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
		_("Failed to enable any supported hash functions."));
	gtk_window_set_title(GTK_WINDOW(dialog), PACKAGE_NAME);
	gtk_dialog_run(GTK_DIALOG(dialog));
	gtk_widget_destroy(dialog);
	exit(EXIT_FAILURE);
}