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;
|
||||
SplitRegister* reg;
|
||||
GtkAction* action;
|
||||
gboolean expanded, voided, read_only = FALSE;
|
||||
gboolean expanded, voided, read_only = FALSE, read_only_reg = FALSE;
|
||||
Transaction* trans;
|
||||
GList* invoices;
|
||||
CursorClass cursor_class;
|
||||
@ -1106,11 +1106,30 @@ gnc_plugin_page_register_ui_update (gpointer various,
|
||||
g_signal_handlers_unblock_by_func
|
||||
(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 */
|
||||
trans = gnc_split_register_get_current_trans (reg);
|
||||
|
||||
/* If the register is not read only, make any modifying action active
|
||||
* to start with */
|
||||
if (!read_only_reg)
|
||||
{
|
||||
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),
|
||||
@ -1127,7 +1146,7 @@ gnc_plugin_page_register_ui_update (gpointer various,
|
||||
|
||||
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page),
|
||||
"DuplicateTransactionAction");
|
||||
gtk_action_set_sensitive (GTK_ACTION (action), TRUE);
|
||||
gtk_action_set_sensitive (GTK_ACTION (action), !read_only & TRUE);
|
||||
|
||||
if (cursor_class == CURSOR_CLASS_SPLIT)
|
||||
{
|
||||
@ -1154,14 +1173,16 @@ gnc_plugin_page_register_ui_update (gpointer various,
|
||||
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' */
|
||||
uri = xaccTransGetDocLink (trans);
|
||||
|
||||
action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page),
|
||||
"LinkedTransactionOpenAction");
|
||||
if (trans)
|
||||
{
|
||||
uri = xaccTransGetDocLink (trans);
|
||||
gtk_action_set_sensitive (GTK_ACTION(action), (uri ? TRUE:FALSE));
|
||||
|
||||
}
|
||||
/* Set 'ExecAssociatedInvoice'
|
||||
We can determine an invoice from a txn if either
|
||||
- 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),
|
||||
"JumpLinkedInvoiceAction");
|
||||
|
||||
if (trans)
|
||||
{
|
||||
invoices = invoices_from_transaction (trans);
|
||||
gtk_action_set_sensitive (GTK_ACTION (action), (invoices != NULL));
|
||||
g_list_free (invoices);
|
||||
}
|
||||
|
||||
gnc_plugin_business_split_reg_ui_update (GNC_PLUGIN_PAGE (page));
|
||||
|
||||
/* If we are in a readonly book, make any modifying action inactive */
|
||||
if (qof_book_is_readonly (gnc_get_current_book()))
|
||||
/* If we are read only, make any modifying action inactive */
|
||||
if (read_only_reg)
|
||||
{
|
||||
const char** iter;
|
||||
for (iter = readonly_inactive_actions; *iter; ++iter)
|
||||
|
@ -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 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 GNCPlaceholderType gnc_split_reg_get_placeholder( GNCSplitReg *gsr );
|
||||
@ -378,7 +378,7 @@ gnc_split_reg_init2( GNCSplitReg *gsr )
|
||||
{
|
||||
if ( !gsr ) return;
|
||||
|
||||
gnc_split_reg_determine_read_only( gsr );
|
||||
gnc_split_reg_determine_read_only( gsr, TRUE );
|
||||
|
||||
gsr_setup_status_widgets( gsr );
|
||||
/* ordering is important here... setup_status before create_table */
|
||||
@ -2488,7 +2488,7 @@ gtk_callback_bug_workaround (gpointer argp)
|
||||
**/
|
||||
static
|
||||
void
|
||||
gnc_split_reg_determine_read_only( GNCSplitReg *gsr )
|
||||
gnc_split_reg_determine_read_only( GNCSplitReg *gsr, gboolean show_dialog )
|
||||
{
|
||||
SplitRegister *reg;
|
||||
|
||||
@ -2542,6 +2542,7 @@ gnc_split_reg_determine_read_only( GNCSplitReg *gsr )
|
||||
args = g_malloc(sizeof(dialog_args));
|
||||
args->string = string;
|
||||
args->gsr = gsr;
|
||||
if (show_dialog)
|
||||
g_timeout_add (250, gtk_callback_bug_workaround, args); /* 0.25 seconds */
|
||||
}
|
||||
|
||||
@ -2631,7 +2632,16 @@ gnc_split_reg_get_summarybar( GNCSplitReg *gsr )
|
||||
gboolean
|
||||
gnc_split_reg_get_read_only( GNCSplitReg *gsr )
|
||||
{
|
||||
SplitRegister *reg;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ void gnc_split_reg2_raise (GNCSplitReg2 *gsr);
|
||||
static GtkWidget* add_summary_label (GtkWidget *summarybar,
|
||||
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);
|
||||
|
||||
@ -200,7 +200,7 @@ gnc_split_reg2_init2 (GNCSplitReg2 *gsr)
|
||||
{
|
||||
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);
|
||||
|
||||
@ -978,7 +978,7 @@ gtk_callback_bug_workaround (gpointer argp)
|
||||
**/
|
||||
static
|
||||
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()))
|
||||
@ -1018,6 +1018,7 @@ gnc_split_reg2_determine_read_only (GNCSplitReg2 *gsr) //this works
|
||||
gsr->read_only = TRUE;
|
||||
/* Put up a warning dialog */
|
||||
args->gsr = gsr;
|
||||
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)
|
||||
{
|
||||
g_assert (gsr);
|
||||
|
||||
// reset read_only flag
|
||||
gsr->read_only = FALSE;
|
||||
gnc_split_reg2_determine_read_only (gsr, FALSE);
|
||||
return gsr->read_only;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user