mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug 355496 - Indication of Read Only Register
Currently a read only register allows you to do a lot of actions like duplicate transaction, delete transactions, schedule transactions and more. This commit adds a check for the register being read only and disable all the actions that would be for a read only book.
This commit is contained in:
parent
f0fc1e537d
commit
f3eae750ed
@ -1086,7 +1086,7 @@ gnc_plugin_page_register_ui_update (gpointer various,
|
|||||||
GncPluginPageRegisterPrivate* priv;
|
GncPluginPageRegisterPrivate* priv;
|
||||||
SplitRegister* reg;
|
SplitRegister* reg;
|
||||||
GtkAction* action;
|
GtkAction* action;
|
||||||
gboolean expanded, voided, read_only = FALSE;
|
gboolean expanded, voided, read_only = FALSE, read_only_reg = FALSE;
|
||||||
Transaction* trans;
|
Transaction* trans;
|
||||||
GList* invoices;
|
GList* invoices;
|
||||||
CursorClass cursor_class;
|
CursorClass cursor_class;
|
||||||
@ -1106,62 +1106,83 @@ gnc_plugin_page_register_ui_update (gpointer various,
|
|||||||
g_signal_handlers_unblock_by_func
|
g_signal_handlers_unblock_by_func
|
||||||
(action, gnc_plugin_page_register_cmd_expand_transaction, page);
|
(action, gnc_plugin_page_register_cmd_expand_transaction, page);
|
||||||
|
|
||||||
|
/* If we are in a readonly book, or possibly a place holder
|
||||||
|
* account register make any modifying action inactive */
|
||||||
|
if (qof_book_is_readonly (gnc_get_current_book()) ||
|
||||||
|
gnc_split_reg_get_read_only (priv->gsr))
|
||||||
|
read_only_reg = TRUE;
|
||||||
|
|
||||||
/* Set available actions based on read only */
|
/* Set available actions based on read only */
|
||||||
trans = gnc_split_register_get_current_trans (reg);
|
trans = gnc_split_register_get_current_trans (reg);
|
||||||
|
|
||||||
if (trans)
|
/* If the register is not read only, make any modifying action active
|
||||||
read_only = xaccTransIsReadonlyByPostedDate (trans);
|
* to start with */
|
||||||
voided = xaccTransHasSplitsInState (trans, VREC);
|
if (!read_only_reg)
|
||||||
|
|
||||||
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page),
|
|
||||||
"CutTransactionAction");
|
|
||||||
gtk_action_set_sensitive (GTK_ACTION (action), !read_only & !voided);
|
|
||||||
|
|
||||||
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page),
|
|
||||||
"PasteTransactionAction");
|
|
||||||
gtk_action_set_sensitive (GTK_ACTION (action), !read_only & !voided);
|
|
||||||
|
|
||||||
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page),
|
|
||||||
"DeleteTransactionAction");
|
|
||||||
gtk_action_set_sensitive (GTK_ACTION (action), !read_only & !voided);
|
|
||||||
|
|
||||||
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page),
|
|
||||||
"DuplicateTransactionAction");
|
|
||||||
gtk_action_set_sensitive (GTK_ACTION (action), TRUE);
|
|
||||||
|
|
||||||
if (cursor_class == CURSOR_CLASS_SPLIT)
|
|
||||||
{
|
{
|
||||||
|
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, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trans)
|
||||||
|
read_only = xaccTransIsReadonlyByPostedDate (trans);
|
||||||
|
|
||||||
|
voided = xaccTransHasSplitsInState (trans, VREC);
|
||||||
|
|
||||||
|
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page),
|
||||||
|
"CutTransactionAction");
|
||||||
|
gtk_action_set_sensitive (GTK_ACTION (action), !read_only & !voided);
|
||||||
|
|
||||||
|
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page),
|
||||||
|
"PasteTransactionAction");
|
||||||
|
gtk_action_set_sensitive (GTK_ACTION (action), !read_only & !voided);
|
||||||
|
|
||||||
|
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page),
|
||||||
|
"DeleteTransactionAction");
|
||||||
|
gtk_action_set_sensitive (GTK_ACTION (action), !read_only & !voided);
|
||||||
|
|
||||||
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page),
|
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page),
|
||||||
"DuplicateTransactionAction");
|
"DuplicateTransactionAction");
|
||||||
|
gtk_action_set_sensitive (GTK_ACTION (action), !read_only & TRUE);
|
||||||
|
|
||||||
|
if (cursor_class == CURSOR_CLASS_SPLIT)
|
||||||
|
{
|
||||||
|
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page),
|
||||||
|
"DuplicateTransactionAction");
|
||||||
|
gtk_action_set_sensitive (GTK_ACTION (action), !read_only & !voided);
|
||||||
|
}
|
||||||
|
|
||||||
|
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page),
|
||||||
|
"RemoveTransactionSplitsAction");
|
||||||
gtk_action_set_sensitive (GTK_ACTION (action), !read_only & !voided);
|
gtk_action_set_sensitive (GTK_ACTION (action), !read_only & !voided);
|
||||||
|
|
||||||
|
/* Set 'Void' and 'Unvoid' */
|
||||||
|
if (read_only)
|
||||||
|
voided = TRUE;
|
||||||
|
|
||||||
|
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page),
|
||||||
|
"VoidTransactionAction");
|
||||||
|
gtk_action_set_sensitive (GTK_ACTION (action), !voided);
|
||||||
|
|
||||||
|
if (read_only)
|
||||||
|
voided = FALSE;
|
||||||
|
|
||||||
|
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page),
|
||||||
|
"UnvoidTransactionAction");
|
||||||
|
gtk_action_set_sensitive (GTK_ACTION (action), voided);
|
||||||
}
|
}
|
||||||
|
|
||||||
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page),
|
|
||||||
"RemoveTransactionSplitsAction");
|
|
||||||
gtk_action_set_sensitive (GTK_ACTION (action), !read_only & !voided);
|
|
||||||
|
|
||||||
/* Set 'Void' and 'Unvoid' */
|
|
||||||
if (read_only)
|
|
||||||
voided = TRUE;
|
|
||||||
|
|
||||||
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page),
|
|
||||||
"VoidTransactionAction");
|
|
||||||
gtk_action_set_sensitive (GTK_ACTION (action), !voided);
|
|
||||||
|
|
||||||
if (read_only)
|
|
||||||
voided = FALSE;
|
|
||||||
|
|
||||||
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page),
|
|
||||||
"UnvoidTransactionAction");
|
|
||||||
gtk_action_set_sensitive (GTK_ACTION (action), voided);
|
|
||||||
|
|
||||||
/* Set 'Open and Remove Linked Documents' */
|
/* Set 'Open and Remove Linked Documents' */
|
||||||
uri = xaccTransGetDocLink (trans);
|
|
||||||
|
|
||||||
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page),
|
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page),
|
||||||
"LinkedTransactionOpenAction");
|
"LinkedTransactionOpenAction");
|
||||||
gtk_action_set_sensitive (GTK_ACTION(action), (uri ? TRUE:FALSE));
|
if (trans)
|
||||||
|
{
|
||||||
|
uri = xaccTransGetDocLink (trans);
|
||||||
|
gtk_action_set_sensitive (GTK_ACTION(action), (uri ? TRUE:FALSE));
|
||||||
|
}
|
||||||
/* Set 'ExecAssociatedInvoice'
|
/* Set 'ExecAssociatedInvoice'
|
||||||
We can determine an invoice from a txn if either
|
We can determine an invoice from a txn if either
|
||||||
- it is an invoice transaction
|
- it is an invoice transaction
|
||||||
@ -1169,15 +1190,17 @@ gnc_plugin_page_register_ui_update (gpointer various,
|
|||||||
*/
|
*/
|
||||||
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page),
|
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page),
|
||||||
"JumpLinkedInvoiceAction");
|
"JumpLinkedInvoiceAction");
|
||||||
|
if (trans)
|
||||||
invoices = invoices_from_transaction (trans);
|
{
|
||||||
gtk_action_set_sensitive (GTK_ACTION (action), (invoices != NULL));
|
invoices = invoices_from_transaction (trans);
|
||||||
g_list_free (invoices);
|
gtk_action_set_sensitive (GTK_ACTION (action), (invoices != NULL));
|
||||||
|
g_list_free (invoices);
|
||||||
|
}
|
||||||
|
|
||||||
gnc_plugin_business_split_reg_ui_update (GNC_PLUGIN_PAGE (page));
|
gnc_plugin_business_split_reg_ui_update (GNC_PLUGIN_PAGE (page));
|
||||||
|
|
||||||
/* If we are in a readonly book, make any modifying action inactive */
|
/* If we are read only, make any modifying action inactive */
|
||||||
if (qof_book_is_readonly (gnc_get_current_book()))
|
if (read_only_reg)
|
||||||
{
|
{
|
||||||
const char** iter;
|
const char** iter;
|
||||||
for (iter = readonly_inactive_actions; *iter; ++iter)
|
for (iter = readonly_inactive_actions; *iter; ++iter)
|
||||||
@ -1937,7 +1960,7 @@ finish_scrub (GncPluginPage* page)
|
|||||||
(GNC_PLUGIN_PAGE(page))),
|
(GNC_PLUGIN_PAGE(page))),
|
||||||
FALSE,
|
FALSE,
|
||||||
_("'Check & Repair' is currently running, do you want to abort it?"));
|
_("'Check & Repair' is currently running, do you want to abort it?"));
|
||||||
|
|
||||||
show_abort_verify = FALSE;
|
show_abort_verify = FALSE;
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -5020,10 +5043,10 @@ scrub_kp_handler (GtkWidget *widget, GdkEventKey *event, gpointer data)
|
|||||||
{
|
{
|
||||||
gboolean abort_scrub = gnc_verify_dialog (GTK_WINDOW(widget), FALSE,
|
gboolean abort_scrub = gnc_verify_dialog (GTK_WINDOW(widget), FALSE,
|
||||||
_("'Check & Repair' is currently running, do you want to abort it?"));
|
_("'Check & Repair' is currently running, do you want to abort it?"));
|
||||||
|
|
||||||
if (abort_scrub)
|
if (abort_scrub)
|
||||||
gnc_set_abort_scrub (TRUE);
|
gnc_set_abort_scrub (TRUE);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -73,7 +73,7 @@ static GtkWidget* add_summary_label( GtkWidget *summarybar, gboolean pack_start,
|
|||||||
|
|
||||||
static void gsr_summarybar_set_arrow_draw (GNCSplitReg *gsr);
|
static void gsr_summarybar_set_arrow_draw (GNCSplitReg *gsr);
|
||||||
|
|
||||||
static void gnc_split_reg_determine_read_only( GNCSplitReg *gsr );
|
static void gnc_split_reg_determine_read_only( GNCSplitReg *gsr, gboolean show_dialog );
|
||||||
static gboolean is_trans_readonly_and_warn (GtkWindow *parent, Transaction *trans);
|
static gboolean is_trans_readonly_and_warn (GtkWindow *parent, Transaction *trans);
|
||||||
|
|
||||||
static GNCPlaceholderType gnc_split_reg_get_placeholder( GNCSplitReg *gsr );
|
static GNCPlaceholderType gnc_split_reg_get_placeholder( GNCSplitReg *gsr );
|
||||||
@ -378,7 +378,7 @@ gnc_split_reg_init2( GNCSplitReg *gsr )
|
|||||||
{
|
{
|
||||||
if ( !gsr ) return;
|
if ( !gsr ) return;
|
||||||
|
|
||||||
gnc_split_reg_determine_read_only( gsr );
|
gnc_split_reg_determine_read_only( gsr, TRUE );
|
||||||
|
|
||||||
gsr_setup_status_widgets( gsr );
|
gsr_setup_status_widgets( gsr );
|
||||||
/* ordering is important here... setup_status before create_table */
|
/* ordering is important here... setup_status before create_table */
|
||||||
@ -2488,7 +2488,7 @@ gtk_callback_bug_workaround (gpointer argp)
|
|||||||
**/
|
**/
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
gnc_split_reg_determine_read_only( GNCSplitReg *gsr )
|
gnc_split_reg_determine_read_only( GNCSplitReg *gsr, gboolean show_dialog )
|
||||||
{
|
{
|
||||||
SplitRegister *reg;
|
SplitRegister *reg;
|
||||||
|
|
||||||
@ -2542,7 +2542,8 @@ gnc_split_reg_determine_read_only( GNCSplitReg *gsr )
|
|||||||
args = g_malloc(sizeof(dialog_args));
|
args = g_malloc(sizeof(dialog_args));
|
||||||
args->string = string;
|
args->string = string;
|
||||||
args->gsr = gsr;
|
args->gsr = gsr;
|
||||||
g_timeout_add (250, gtk_callback_bug_workaround, args); /* 0.25 seconds */
|
if (show_dialog)
|
||||||
|
g_timeout_add (250, gtk_callback_bug_workaround, args); /* 0.25 seconds */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make the contents immutable */
|
/* Make the contents immutable */
|
||||||
@ -2631,7 +2632,16 @@ gnc_split_reg_get_summarybar( GNCSplitReg *gsr )
|
|||||||
gboolean
|
gboolean
|
||||||
gnc_split_reg_get_read_only( GNCSplitReg *gsr )
|
gnc_split_reg_get_read_only( GNCSplitReg *gsr )
|
||||||
{
|
{
|
||||||
|
SplitRegister *reg;
|
||||||
|
|
||||||
g_assert( gsr );
|
g_assert( gsr );
|
||||||
|
|
||||||
|
// reset read_only flag
|
||||||
|
gsr->read_only = FALSE;
|
||||||
|
gnc_split_reg_determine_read_only (gsr, FALSE);
|
||||||
|
|
||||||
|
reg = gnc_ledger_display_get_split_register( gsr->ledger );
|
||||||
|
gnc_split_register_set_read_only( reg, gsr->read_only );
|
||||||
return gsr->read_only;
|
return gsr->read_only;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ void gnc_split_reg2_raise (GNCSplitReg2 *gsr);
|
|||||||
static GtkWidget* add_summary_label (GtkWidget *summarybar,
|
static GtkWidget* add_summary_label (GtkWidget *summarybar,
|
||||||
const char *label_str);
|
const char *label_str);
|
||||||
|
|
||||||
static void gnc_split_reg2_determine_read_only (GNCSplitReg2 *gsr);
|
static void gnc_split_reg2_determine_read_only (GNCSplitReg2 *gsr, gboolean show_dialog);
|
||||||
|
|
||||||
static void gnc_split_reg2_determine_account_pr (GNCSplitReg2 *gsr);
|
static void gnc_split_reg2_determine_account_pr (GNCSplitReg2 *gsr);
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ gnc_split_reg2_init2 (GNCSplitReg2 *gsr)
|
|||||||
{
|
{
|
||||||
if (!gsr) return;
|
if (!gsr) return;
|
||||||
|
|
||||||
gnc_split_reg2_determine_read_only (gsr);
|
gnc_split_reg2_determine_read_only (gsr, TRUE);
|
||||||
|
|
||||||
gnc_split_reg2_determine_account_pr (gsr);
|
gnc_split_reg2_determine_account_pr (gsr);
|
||||||
|
|
||||||
@ -978,7 +978,7 @@ gtk_callback_bug_workaround (gpointer argp)
|
|||||||
**/
|
**/
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
gnc_split_reg2_determine_read_only (GNCSplitReg2 *gsr) //this works
|
gnc_split_reg2_determine_read_only (GNCSplitReg2 *gsr, gboolean show_dialog)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (qof_book_is_readonly (gnc_get_current_book()))
|
if (qof_book_is_readonly (gnc_get_current_book()))
|
||||||
@ -1018,7 +1018,8 @@ gnc_split_reg2_determine_read_only (GNCSplitReg2 *gsr) //this works
|
|||||||
gsr->read_only = TRUE;
|
gsr->read_only = TRUE;
|
||||||
/* Put up a warning dialog */
|
/* Put up a warning dialog */
|
||||||
args->gsr = gsr;
|
args->gsr = gsr;
|
||||||
g_timeout_add (250, gtk_callback_bug_workaround, args); /* 0.25 seconds */
|
if (show_dialog)
|
||||||
|
g_timeout_add (250, gtk_callback_bug_workaround, args); /* 0.25 seconds */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1125,6 +1126,10 @@ gboolean
|
|||||||
gnc_split_reg2_get_read_only (GNCSplitReg2 *gsr)
|
gnc_split_reg2_get_read_only (GNCSplitReg2 *gsr)
|
||||||
{
|
{
|
||||||
g_assert (gsr);
|
g_assert (gsr);
|
||||||
|
|
||||||
|
// reset read_only flag
|
||||||
|
gsr->read_only = FALSE;
|
||||||
|
gnc_split_reg2_determine_read_only (gsr, FALSE);
|
||||||
return gsr->read_only;
|
return gsr->read_only;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user