More checking of the read-only flag of the book.

- GncEntryLedger switches to read-only
- Toolbar actions of several plugin pages switch to insensitive
  (invoice, normal register)

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21585 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming 2011-11-19 11:49:00 +00:00
parent 21216a137a
commit b379a2fd18
3 changed files with 17 additions and 3 deletions

View File

@ -423,6 +423,13 @@ gnc_plugin_page_invoice_update_menus (GncPluginPage *page, gboolean is_posted, g
g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(page));
if (qof_book_is_readonly(gnc_get_current_book()))
{
// Are we readonly? Then don't allow any actions.
is_posted = TRUE;
can_unpost = FALSE;
}
action_group = gnc_plugin_page_get_action_group(page);
gnc_plugin_update_actions (action_group, posted_actions,
"sensitive", is_posted);

View File

@ -378,6 +378,10 @@ GncEntryLedger * gnc_entry_ledger_new (QofBook *book, GncEntryLedgerType type)
/* Initialize Display */
gnc_entry_ledger_display_init (ledger);
if (qof_book_is_readonly(ledger->book))
{
gnc_entry_ledger_set_readonly(ledger, TRUE);
}
return ledger;
}
@ -603,6 +607,7 @@ gboolean gnc_entry_ledger_find_entry (GncEntryLedger *ledger, GncEntry *entry,
void gnc_entry_ledger_set_readonly (GncEntryLedger *ledger, gboolean readonly)
{
if (!ledger) return;
if (!readonly && qof_book_is_readonly(ledger->book)) return;
/* reset the ledger type appropriately */
if (readonly)

View File

@ -827,12 +827,13 @@ gnc_plugin_page_register_ui_initial_state (GncPluginPageRegister *page)
SplitRegister *reg;
GNCLedgerDisplayType ledger_type;
int i;
gboolean is_readwrite = !qof_book_is_readonly(gnc_get_current_book());
priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(page);
account = gnc_plugin_page_register_get_account (page);
action_group = gnc_plugin_page_get_action_group(GNC_PLUGIN_PAGE(page));
gnc_plugin_update_actions(action_group, actions_requiring_account,
"sensitive", account != NULL);
"sensitive", is_readwrite && account != NULL);
/* Set "style" radio button */
ledger_type = gnc_ledger_display_type(priv->ledger);
@ -1300,14 +1301,15 @@ gnc_plugin_page_register_update_edit_menu (GncPluginPage *page, gboolean hide)
GtkAction *action;
gboolean can_copy = FALSE, can_cut = FALSE, can_paste = FALSE;
gboolean has_selection;
gboolean is_readwrite = !qof_book_is_readonly(gnc_get_current_book());
reg_page = GNC_PLUGIN_PAGE_REGISTER(page);
priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(reg_page);
has_selection = gnucash_register_has_selection (priv->gsr->reg);
can_copy = has_selection;
can_cut = has_selection;
can_paste = TRUE;
can_cut = is_readwrite && has_selection;
can_paste = is_readwrite;
action = gnc_plugin_page_get_action (page, "EditCopyAction");
gtk_action_set_sensitive (action, can_copy);