mirror of
https://github.com/Gnucash/gnucash.git
synced 2026-09-03 20:53:02 -05:00
Take into account the read-only flag of the book to update the buttons in the register accordingly.
Also, the register itself must be read-only. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21569 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -1121,8 +1121,11 @@ xaccTransBeginEdit (Transaction *trans)
|
||||
|
||||
if (qof_book_shutting_down(qof_instance_get_book(trans))) return;
|
||||
|
||||
xaccOpenLog ();
|
||||
xaccTransWriteLog (trans, 'B');
|
||||
if (!qof_book_is_readonly(qof_instance_get_book(trans)))
|
||||
{
|
||||
xaccOpenLog ();
|
||||
xaccTransWriteLog (trans, 'B');
|
||||
}
|
||||
|
||||
/* Make a clone of the transaction; we will use this
|
||||
* in case we need to roll-back the edit. */
|
||||
@@ -1179,7 +1182,7 @@ do_destroy (Transaction *trans)
|
||||
destroy_gains (trans);
|
||||
|
||||
/* Make a log in the journal before destruction. */
|
||||
if (!shutting_down)
|
||||
if (!shutting_down && !qof_book_is_readonly(qof_instance_get_book(trans)))
|
||||
xaccTransWriteLog (trans, 'D');
|
||||
|
||||
qof_event_gen (&trans->inst, QOF_EVENT_DESTROY, NULL);
|
||||
@@ -1288,7 +1291,8 @@ static void trans_cleanup_commit(Transaction *trans)
|
||||
}
|
||||
g_list_free(slist);
|
||||
|
||||
xaccTransWriteLog (trans, 'C');
|
||||
if (!qof_book_is_readonly(qof_instance_get_book(trans)))
|
||||
xaccTransWriteLog (trans, 'C');
|
||||
|
||||
/* Get rid of the copy we made. We won't be rolling back,
|
||||
* so we don't need it any more. */
|
||||
@@ -1512,7 +1516,8 @@ xaccTransRollbackEdit (Transaction *trans)
|
||||
}
|
||||
}
|
||||
|
||||
xaccTransWriteLog (trans, 'R');
|
||||
if (!qof_book_is_readonly(qof_instance_get_book(trans)))
|
||||
xaccTransWriteLog (trans, 'R');
|
||||
|
||||
xaccFreeTransaction (trans->orig);
|
||||
|
||||
|
||||
@@ -745,6 +745,31 @@ gnc_plugin_page_register_get_account (GncPluginPageRegister *page)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* This is the list of actions which are switched inactive in a read-only book. */
|
||||
static const char* readonly_inactive_actions[] =
|
||||
{
|
||||
"EditCutAction",
|
||||
"EditPasteAction",
|
||||
"CutTransactionAction",
|
||||
"PasteTransactionAction",
|
||||
"DuplicateTransactionAction",
|
||||
"DeleteTransactionAction",
|
||||
"RemoveTransactionSplitsAction",
|
||||
"RecordTransactionAction",
|
||||
"CancelTransactionAction",
|
||||
"UnvoidTransactionAction",
|
||||
"VoidTransactionAction",
|
||||
"ReverseTransactionAction",
|
||||
"ShiftTransactionForwardAction",
|
||||
"ActionsTransferAction",
|
||||
"ActionsReconcileAction",
|
||||
"ActionsStockSplitAction",
|
||||
"ScheduleTransactionAction",
|
||||
"ScrubAllAction",
|
||||
"ScrubCurrentAction",
|
||||
NULL
|
||||
};
|
||||
|
||||
static void
|
||||
gnc_plugin_page_register_ui_update (gpointer various, GncPluginPageRegister *page)
|
||||
{
|
||||
@@ -777,6 +802,19 @@ gnc_plugin_page_register_ui_update (gpointer various, GncPluginPageRegister *pag
|
||||
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page),
|
||||
"UnvoidTransactionAction");
|
||||
gtk_action_set_sensitive (GTK_ACTION(action), voided);
|
||||
|
||||
/* If we are in a readonly book, make any modifying action inactive */
|
||||
if (qof_book_is_readonly(gnc_get_current_book()))
|
||||
{
|
||||
const char **iter;
|
||||
for (iter = readonly_inactive_actions; *iter; ++iter)
|
||||
{
|
||||
/* Set the action's sensitivity */
|
||||
GtkAction *action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), *iter);
|
||||
gtk_action_set_sensitive(action, FALSE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -1975,6 +1975,13 @@ gnc_split_reg_determine_read_only( GNCSplitReg *gsr )
|
||||
dialog_args *args = g_malloc(sizeof(dialog_args));
|
||||
SplitRegister *reg;
|
||||
|
||||
if (qof_book_is_readonly(gnc_get_current_book()))
|
||||
{
|
||||
/* Is the book read-only? Then for sure also make this register
|
||||
read-only. */
|
||||
gsr->read_only = TRUE;
|
||||
}
|
||||
|
||||
if ( !gsr->read_only )
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user