Update dialogs to give them a Gtk2 HIG look and feel.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@12003 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
David Hampton 2005-11-21 04:43:41 +00:00
parent 5340707a9a
commit 0d2191dad7
2 changed files with 113 additions and 60 deletions

View File

@ -1,5 +1,8 @@
2005-11-20 David Hampton <hampton@employees.org> 2005-11-20 David Hampton <hampton@employees.org>
* src/gnome/gnc-split-reg.c: Update dialogs to give them a Gtk2
HIG look and feel.
*src/gnome-utils/dialog-reset-warnings.c: Make a function *src/gnome-utils/dialog-reset-warnings.c: Make a function
static. Remove extraneous printf. static. Remove extraneous printf.

View File

@ -1111,18 +1111,13 @@ gsr_default_reinit_handler( GNCSplitReg *gsr, gpointer data )
SplitRegister *reg; SplitRegister *reg;
Transaction *trans; Transaction *trans;
Split *split; Split *split;
char *buf = NULL; GtkWidget *dialog;
gint result; gint result;
const char *two_choices[] = { N_(GTK_STOCK_CANCEL),
N_("Remove Transaction Splits"),
NULL };
const char *message = _("Are you sure you want to remove the "
"Splits of this transaction?");
const char *recn_warn = _("You would be modifying a " const char *message = _("Remove the splits from this transaction?");
"transaction with reconciled splits!\n" const char *recn_warn = _("This transaction contains reconciled splits. "
"This is not a good idea as it will cause your " "Modifying it is not a good idea because that will "
"reconciled balance to be off."); "cause your reconciled balance to be off.");
reg = gnc_ledger_display_get_split_register( gsr->ledger ); reg = gnc_ledger_display_get_split_register( gsr->ledger );
@ -1130,16 +1125,31 @@ gsr_default_reinit_handler( GNCSplitReg *gsr, gpointer data )
if (xaccTransWarnReadOnly(trans)) if (xaccTransWarnReadOnly(trans))
return; return;
if (xaccTransHasReconciledSplits (trans)) { if (xaccTransHasReconciledSplits (trans)) {
buf = g_strconcat (message, "\n\n", recn_warn, NULL); dialog =
result = gtk_message_dialog_new_with_markup(GTK_WINDOW(gsr->window),
gnc_generic_warning_dialog(gsr->window, two_choices, buf); GTK_DIALOG_MODAL
| GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_NONE,
"<b>%s</b>\n\n%s",
message, recn_warn);
} else { } else {
buf = g_strdup (message); dialog =
result = gtk_message_dialog_new_with_markup(GTK_WINDOW(gsr->window),
gnc_generic_question_dialog(gsr->window, two_choices,buf); GTK_DIALOG_MODAL
| GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE,
"<b>%s</b>", message);
} }
g_free(buf);
if (!result) gtk_dialog_add_button(GTK_DIALOG(dialog),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
gnc_gtk_dialog_add_button(dialog, N_("_Remove Splits"),
GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT);
result = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy (dialog);
if (result != GTK_RESPONSE_ACCEPT)
return; return;
/* /*
@ -1171,12 +1181,9 @@ gsr_default_delete_handler( GNCSplitReg *gsr, gpointer data )
CursorClass cursor_class; CursorClass cursor_class;
SplitRegister *reg; SplitRegister *reg;
Transaction *trans; Transaction *trans;
char *buf = NULL;
Split *split; Split *split;
GtkWidget *dialog;
gint result; gint result;
const char *two_choices[] = { N_(GTK_STOCK_DELETE),
N_(GTK_STOCK_CANCEL),
NULL };
reg = gnc_ledger_display_get_split_register( gsr->ledger ); reg = gnc_ledger_display_get_split_register( gsr->ledger );
@ -1212,20 +1219,33 @@ gsr_default_delete_handler( GNCSplitReg *gsr, gpointer data )
/* On a split cursor, just delete the one split. */ /* On a split cursor, just delete the one split. */
if (cursor_class == CURSOR_CLASS_SPLIT) if (cursor_class == CURSOR_CLASS_SPLIT)
{ {
const char *format = _("Are you sure you want to delete\n %s\n" const char *format = _("Delete the split '%s' from the transaction '%s'?");
"from the transaction\n %s ?"); const char *recn_warn = _("You would be deleting a reconciled split! "
const char *recn_warn = _("You would be deleting a reconciled split!\n"
"This is not a good idea as it will cause your " "This is not a good idea as it will cause your "
"reconciled balance to be off."); "reconciled balance to be off.");
const char *anchor_error = _("You cannot delete this split.");
const char *anchor_split = _("This is the split anchoring this transaction " const char *anchor_split = _("This is the split anchoring this transaction "
"to the register. You may not delete it from " "to the register. You may not delete it from "
"this register window."); "this register window. You may delete the "
"entire transaction from this window, or you "
"may navigate to a register that shows "
"another side of this same transaction and "
"delete the split from that register.");
char *buf = NULL;
const char *memo; const char *memo;
const char *desc; const char *desc;
char recn; char recn;
if (split == gnc_split_register_get_current_trans_split (reg, NULL)) { if (split == gnc_split_register_get_current_trans_split (reg, NULL)) {
gnc_error_dialog(gsr->window, anchor_split); dialog =
gtk_message_dialog_new_with_markup(GTK_WINDOW(gsr->window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
"<b>%s</b>\n\n%s",
anchor_error, anchor_split);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy (dialog);
return; return;
} }
@ -1241,20 +1261,31 @@ gsr_default_delete_handler( GNCSplitReg *gsr, gpointer data )
recn = xaccSplitGetReconcile (split); recn = xaccSplitGetReconcile (split);
if (recn == YREC || recn == FREC) if (recn == YREC || recn == FREC)
{ {
char *new_buf; dialog =
gtk_message_dialog_new_with_markup(GTK_WINDOW(gsr->window),
new_buf = g_strconcat (buf, "\n\n", recn_warn, NULL); GTK_DIALOG_MODAL
g_free (buf); | GTK_DIALOG_DESTROY_WITH_PARENT,
buf = new_buf; GTK_MESSAGE_WARNING,
result = GTK_BUTTONS_NONE,
gnc_generic_warning_dialog(gsr->window, two_choices, "%s", buf); "<b>%s</b>\n\n%s", buf, recn_warn);
} else { } else {
result = dialog =
gnc_generic_question_dialog(gsr->window, two_choices, "%s", buf); gtk_message_dialog_new_with_markup(GTK_WINDOW(gsr->window),
GTK_DIALOG_MODAL
| GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE,
"<b>%s</b>", buf);
} }
g_free(buf); g_free(buf);
if (result != 0) gtk_dialog_add_button(GTK_DIALOG(dialog),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
gnc_gtk_dialog_add_button(dialog, N_("_Delete Split"),
GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT);
result = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy (dialog);
if (result != GTK_RESPONSE_ACCEPT)
return; return;
gnc_split_register_delete_current_split (reg); gnc_split_register_delete_current_split (reg);
@ -1266,27 +1297,36 @@ gsr_default_delete_handler( GNCSplitReg *gsr, gpointer data )
/* On a transaction cursor with 2 or fewer splits in single or double /* On a transaction cursor with 2 or fewer splits in single or double
* mode, we just delete the whole transaction, kerblooie */ * mode, we just delete the whole transaction, kerblooie */
{ {
const char *message = _("Are you sure you want to delete the current " const char *message = _("Delete the current transaction?");
"transaction?");
const char *recn_warn = _("You would be deleting a transaction " const char *recn_warn = _("You would be deleting a transaction "
"with reconciled splits!\n" "with reconciled splits! "
"This is not a good idea as it will cause your " "This is not a good idea as it will cause your "
"reconciled balance to be off."); "reconciled balance to be off.");
char *buf;
if (xaccTransHasReconciledSplits (trans)) { if (xaccTransHasReconciledSplits (trans)) {
buf = g_strconcat (message, "\n\n", recn_warn, NULL); dialog =
result = gtk_message_dialog_new_with_markup(GTK_WINDOW(gsr->window),
gnc_generic_warning_dialog(gsr->window, two_choices, buf); GTK_DIALOG_MODAL |
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_NONE,
"<b>%s</b>\n\n%s", message, recn_warn);
} else { } else {
buf = g_strdup (message); dialog =
result = gtk_message_dialog_new_with_markup(GTK_WINDOW(gsr->window),
gnc_generic_question_dialog(gsr->window, two_choices, buf); GTK_DIALOG_MODAL
| GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE,
"<b>%s</b>", message);
} }
gtk_dialog_add_button(GTK_DIALOG(dialog),
g_free (buf); GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
gnc_gtk_dialog_add_button(dialog, N_("_Delete Transaction"),
if (result != 0) GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT);
result = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy (dialog);
if (result != GTK_RESPONSE_ACCEPT)
return; return;
gnc_split_register_delete_current_trans (reg); gnc_split_register_delete_current_trans (reg);
@ -2144,8 +2184,18 @@ gint
gtk_callback_bug_workaround (gpointer argp) gtk_callback_bug_workaround (gpointer argp)
{ {
dialog_args *args = argp; dialog_args *args = argp;
const gchar *read_only = "This account register is read-only.";
GtkWidget *dialog;
gnc_warning_dialog(args->gsr->window, "%s", args->string); dialog = gtk_message_dialog_new_with_markup(GTK_WINDOW(args->gsr->window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_CLOSE,
"<b>%s</b>\n\n%s",
read_only,
args->string);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
g_free(args); g_free(args);
return FALSE; return FALSE;
} }
@ -2176,18 +2226,18 @@ gnc_split_reg_determine_read_only( GNCSplitReg *gsr )
return; return;
case PLACEHOLDER_THIS: case PLACEHOLDER_THIS:
args->string = _("This account may not be edited. If you want\n" args->string = _("This account may not be edited. If you want "
"to edit transactions in this register, please\n" "to edit transactions in this register, please "
"open the account options and turn off the\n" "open the account options and turn off the "
"placeholder checkbox."); "placeholder checkbox.");
break; break;
default: default:
args->string = _("One of the sub-accounts selected may not be\n" args->string = _("One of the sub-accounts selected may not be "
"edited. If you want to edit transactions in\n" "edited. If you want to edit transactions in "
"this register, please open the sub-account\n" "this register, please open the sub-account "
"options and turn off the placeholder checkbox.\n" "options and turn off the placeholder checkbox. "
"You may also open an individual account instead\n" "You may also open an individual account instead "
"of a set of accounts."); "of a set of accounts.");
break; break;
} }