Update the menu items associated with this invoice page.
This function should be called whenever the posted state of an invoice is changed.
478{
479 GncMainWindow *window;
480 GSimpleActionGroup *simple_action_group;
481 GAction *action;
483 GncInvoiceType invoice_type;
484 GncInvoice *invoice;
487 gboolean has_uri = FALSE;
488
490
491 g_return_if_fail (GNC_IS_PLUGIN_PAGE_INVOICE(page));
492
493 priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(page);
494
495
496 priv->is_posted = is_posted;
497 priv->can_unpost = can_unpost;
498
501 return;
502
503 invoice_type = gnc_invoice_get_type_from_window(priv->iw);
504
505 switch (invoice_type) {
506 case GNC_INVOICE_CUST_INVOICE:
507 label_list = invoice_action_labels;
508 break;
509 case GNC_INVOICE_VEND_INVOICE:
510 label_list = bill_action_labels;
511 break;
512 case GNC_INVOICE_EMPL_INVOICE:
513 label_list = voucher_action_labels;
514 break;
515 case GNC_INVOICE_CUST_CREDIT_NOTE:
516 case GNC_INVOICE_VEND_CREDIT_NOTE:
517 case GNC_INVOICE_EMPL_CREDIT_NOTE:
518 label_list = creditnote_action_labels;
519 break;
520 default:
521 label_list = invoice_action_labels;
522 }
523
524
525 switch (invoice_type) {
526 case GNC_INVOICE_CUST_INVOICE:
527 case GNC_INVOICE_CUST_CREDIT_NOTE:
528 label_layout_list = invoice_action_layout_labels;
529 break;
530 case GNC_INVOICE_VEND_INVOICE:
531 case GNC_INVOICE_VEND_CREDIT_NOTE:
532 label_layout_list = bill_action_layout_labels;
533 break;
534 case GNC_INVOICE_EMPL_INVOICE:
535 case GNC_INVOICE_EMPL_CREDIT_NOTE:
536 label_layout_list = voucher_action_layout_labels;
537 break;
538 default:
539 label_layout_list = invoice_action_layout_labels;
540 }
541
542 if (is_readonly)
543 {
544
545 is_posted = TRUE;
546 can_unpost = FALSE;
547 }
548
549
551 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE);
552
555 is_posted);
557 !is_posted);
559 can_unpost);
561 !is_readonly);
562
563
564 gnc_plugin_page_invoice_action_update (page, label_list);
565
566
567 gnc_plugin_page_update_reset_layout_action (page);
568
569
570 gnc_plugin_page_invoice_action_update (page, label_layout_list);
571
572
573 invoice = gnc_invoice_window_get_invoice (priv->iw);
574 if (gncInvoiceGetDocLink (invoice))
575 has_uri = TRUE;
576
577 update_doclink_actions (page, has_uri);
578}
gboolean qof_book_is_readonly(const QofBook *book)
Return whether the book is read only.
GtkWidget * gnc_plugin_page_get_window(GncPluginPage *page)
Retrieve a pointer to the GncMainWindow (GtkWindow) containing this page.
GSimpleActionGroup * gnc_plugin_page_get_action_group(GncPluginPage *page)
Retrieve the GSimpleActionGroup object associated with this page.
GncPluginPage * gnc_main_window_get_current_page(GncMainWindow *window)
Retrieve a pointer to the page that is currently at the front of the specified window.
GAction * gnc_main_window_find_action(GncMainWindow *window, const gchar *action_name)
Find the GAction in the main window.