Example #1
0
/**
 * eel_show_yes_no_dialog:
 * 
 * Create and show a dialog asking a question with two choices.
 * The caller needs to set up any necessary callbacks 
 * for the buttons. Use eel_create_question_dialog instead
 * if any visual changes need to be made, to avoid flashiness.
 * @question: The text of the question.
 * @yes_label: The label of the "yes" button.
 * @no_label: The label of the "no" button.
 * @parent: The parent window for this dialog.
 */
GtkDialog *
eel_show_yes_no_dialog (const char *primary_text, 
			const char *secondary_text,
			const char *yes_label,
			const char *no_label,
			GtkWindow *parent)
{
	GtkDialog *dialog = NULL;
	dialog = eel_create_question_dialog (primary_text,
					     secondary_text,
					     no_label, GTK_RESPONSE_CANCEL,
					     yes_label, GTK_RESPONSE_YES,
					     GTK_WINDOW (parent));
	gtk_widget_show (GTK_WIDGET (dialog));
	return dialog;
}
static void
forget_history_if_confirmed (NautilusWindow *window)
{
	GtkDialog *dialog;
	char *prompt;
	char *detail;

	/* Confirm before forgetting history because it's a rare operation that
	 * is hard to recover from. We don't want people doing it accidentally
	 * when they intended to choose another Go menu item.
	 */
	if ((rand() % 10) == 0) {
		/* This is a little joke, shows up occasionally. I only
		 * implemented this feature so I could use this joke. 
		 */
		prompt = _("Are you sure you want to forget history?");
		/* Translators: This is part of a joke and is paired with "Are you sure you want to forget history?" */
		detail = _("If you do, you will be doomed to repeat it.");
	} else {
		prompt = _("Are you sure you want to clear the list "
			   "of locations you have visited?");
		detail = _("If you clear the list of locations,"
			   " they will be permanently deleted."); 
	}
					   
	dialog = eel_create_question_dialog (prompt,
					     detail,
					     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
					     GTK_STOCK_CLEAR, RESPONSE_FORGET,
					     GTK_WINDOW (window));

	gtk_widget_show (GTK_WIDGET (dialog));
	
	g_signal_connect (dialog, "response",
			  G_CALLBACK (forget_history_if_yes), NULL);

	gtk_dialog_set_default_response (dialog, GTK_RESPONSE_CANCEL);
}