GnuCash  4.11-627-g58c1a51897
Files | Data Structures | Macros | Functions
Business Invoice Page

Files

file  gnc-plugin-page-invoice.h
 utility functions for the GnuCash UI
 

Data Structures

struct  GncPluginPageInvoice
 
struct  GncPluginPageInvoiceClass
 

Macros

#define GNC_TYPE_PLUGIN_PAGE_INVOICE   (gnc_plugin_page_invoice_get_type ())
 
#define GNC_PLUGIN_PAGE_INVOICE(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_PLUGIN_PAGE_INVOICE, GncPluginPageInvoice))
 
#define GNC_PLUGIN_PAGE_INVOICE_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN_PAGE_INVOICE, GncPluginPageInvoiceClass))
 
#define GNC_IS_PLUGIN_PAGE_INVOICE(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_PLUGIN_PAGE_INVOICE))
 
#define GNC_IS_PLUGIN_PAGE_INVOICE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN_PAGE_INVOICE))
 
#define GNC_PLUGIN_PAGE_INVOICE_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_PLUGIN_PAGE_INVOICE, GncPluginPageInvoiceClass))
 
#define GNC_PLUGIN_PAGE_INVOICE_NAME   "GncPluginPageInvoice"
 

Functions

GType gnc_plugin_page_invoice_get_type (void)
 Retrieve the type number for an "invoice" plugin page. More...
 
GncPluginPagegnc_plugin_page_invoice_new (InvoiceWindow *iw)
 Create a new "invoice" plugin page, given a pointer to an InvoiceWindow data structure. More...
 
void gnc_plugin_page_invoice_update_menus (GncPluginPage *page, gboolean is_posted, gboolean can_unpost)
 Update the menu items associated with this invoice page. More...
 
void gnc_plugin_page_invoice_update_title (GncPluginPage *page)
 Update the title associated with this invoice page. More...
 
InvoiceWindow * gnc_plugin_page_invoice_get_window (GncInvoice *invoice)
 Find the Invoice Window amongst the plugin pages for an Invoice, if not present return NULL. More...
 

Detailed Description

Function Documentation

◆ gnc_plugin_page_invoice_get_type()

GType gnc_plugin_page_invoice_get_type ( void  )

Retrieve the type number for an "invoice" plugin page.

Returns
The type number.

◆ gnc_plugin_page_invoice_get_window()

InvoiceWindow* gnc_plugin_page_invoice_get_window ( GncInvoice *  invoice)

Find the Invoice Window amongst the plugin pages for an Invoice, if not present return NULL.

Parameters
pageA pointer to an invoice.
Returns
The invoice or NULL.

Definition at line 490 of file gnc-plugin-page-invoice.c.

491 {
493  GncPluginPageInvoice *invoice_page;
494  const GList *item;
495 
496  /* Is there an existing page? */
497  item = gnc_gobject_tracking_get_list (GNC_PLUGIN_PAGE_INVOICE_NAME);
498  for ( ; item; item = g_list_next(item))
499  {
500  invoice_page = (GncPluginPageInvoice *)item->data;
501  priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(invoice_page);
502 
503  if (gnc_invoice_window_get_invoice (priv->iw) == invoice)
504  return priv->iw;
505  }
506  return NULL;
507 }
const GList * gnc_gobject_tracking_get_list(const gchar *name)
Get a list of all known objects of a specified type.

◆ gnc_plugin_page_invoice_new()

GncPluginPage* gnc_plugin_page_invoice_new ( InvoiceWindow *  iw)

Create a new "invoice" plugin page, given a pointer to an InvoiceWindow data structure.

This structure is used to describe both the "invoice entry" page in a window, and also to describe the New Invoice dialog.

Parameters
iwA pointer to the invoice to be embedded into a main window.
Returns
The newly created plugin page.

Definition at line 510 of file gnc-plugin-page-invoice.c.

511 {
513  GncPluginPageInvoice *invoice_page;
514  GncPluginPage *plugin_page;
515  const GList *item;
516 
517  /* Is there an existing page? */
518  item = gnc_gobject_tracking_get_list(GNC_PLUGIN_PAGE_INVOICE_NAME);
519  for ( ; item; item = g_list_next(item))
520  {
521  invoice_page = (GncPluginPageInvoice *)item->data;
522  priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(invoice_page);
523  if (priv->iw == iw)
524  return GNC_PLUGIN_PAGE(invoice_page);
525  }
526 
527  invoice_page = g_object_new (GNC_TYPE_PLUGIN_PAGE_INVOICE, (char *)NULL);
528  priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(invoice_page);
529  priv->iw = iw;
530 
531  plugin_page = GNC_PLUGIN_PAGE(invoice_page);
533  gnc_plugin_page_set_uri(plugin_page, "default:");
534 
535  priv->component_manager_id = 0;
536  return plugin_page;
537 }
The instance data structure for a content plugin.
const GList * gnc_gobject_tracking_get_list(const gchar *name)
Get a list of all known objects of a specified type.
void gnc_plugin_page_set_uri(GncPluginPage *page, const char *name)
Set the Uniform Resource Identifier for this page.
void gnc_plugin_page_invoice_update_title(GncPluginPage *plugin_page)
Update the title associated with this invoice page.

◆ gnc_plugin_page_invoice_update_menus()

void gnc_plugin_page_invoice_update_menus ( GncPluginPage page,
gboolean  is_posted,
gboolean  can_unpost 
)

Update the menu items associated with this invoice page.

This function should be called whenever the posted state of an invoice is changed.

Parameters
pageA pointer invoice page.
is_postedSet this to TRUE if the invoice has been posted.
can_unpostSet this to TRUE if the invoice can be un-posted.

Definition at line 648 of file gnc-plugin-page-invoice.c.

649 {
650  GtkActionGroup *action_group;
652  GncInvoiceType invoice_type;
653  GncInvoice *invoice;
654  gint i, j;
655  action_toolbar_labels *label_list;
656  action_toolbar_labels *tooltip_list;
657  action_toolbar_labels *label_layout_list;
658  action_toolbar_labels *tooltip_layout_list;
659  gboolean has_uri = FALSE;
660 
661  gboolean is_readonly = qof_book_is_readonly(gnc_get_current_book());
662 
663  g_return_if_fail (GNC_IS_PLUGIN_PAGE_INVOICE(page));
664 
665  priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(page);
666  invoice_type = gnc_invoice_get_type_from_window(priv->iw);
667 
668  switch (invoice_type) {
669  case GNC_INVOICE_CUST_INVOICE:
670  label_list = invoice_action_labels;
671  tooltip_list = invoice_action_tooltips;
672  break;
673  case GNC_INVOICE_VEND_INVOICE:
674  label_list = bill_action_labels;
675  tooltip_list = bill_action_tooltips;
676  break;
677  case GNC_INVOICE_EMPL_INVOICE:
678  label_list = voucher_action_labels;
679  tooltip_list = voucher_action_tooltips;
680  break;
681  case GNC_INVOICE_CUST_CREDIT_NOTE: // fallthrough
682  case GNC_INVOICE_VEND_CREDIT_NOTE: // fallthrough
683  case GNC_INVOICE_EMPL_CREDIT_NOTE: // fallthrough
684  label_list = creditnote_action_labels;
685  tooltip_list = creditnote_action_tooltips;
686  break;
687  default: // catches GNC_INVOICE_UNDEFINED, use invoice by default
688  label_list = invoice_action_labels;
689  tooltip_list = invoice_action_tooltips;
690  }
691 
692  // layout actions
693  switch (invoice_type) {
694  case GNC_INVOICE_CUST_INVOICE:
695  case GNC_INVOICE_CUST_CREDIT_NOTE:
696  label_layout_list = invoice_action_layout_labels;
697  tooltip_layout_list = invoice_action_layout_tooltips;
698  break;
699  case GNC_INVOICE_VEND_INVOICE:
700  case GNC_INVOICE_VEND_CREDIT_NOTE:
701  label_layout_list = bill_action_layout_labels;
702  tooltip_layout_list = bill_action_layout_tooltips;
703  break;
704  case GNC_INVOICE_EMPL_INVOICE:
705  case GNC_INVOICE_EMPL_CREDIT_NOTE:
706  label_layout_list = voucher_action_layout_labels;
707  tooltip_layout_list = voucher_action_layout_tooltips;
708  break;
709  default: // catches GNC_INVOICE_UNDEFINED, use invoice by default
710  label_layout_list = invoice_action_layout_labels;
711  tooltip_layout_list = invoice_action_layout_tooltips;
712  }
713 
714  if (is_readonly)
715  {
716  // Are we readonly? Then don't allow any actions.
717  is_posted = TRUE;
718  can_unpost = FALSE;
719  }
720 
721  action_group = gnc_plugin_page_get_action_group(page);
722  gnc_plugin_update_actions (action_group, posted_actions,
723  "sensitive", is_posted);
724  gnc_plugin_update_actions (action_group, unposted_actions,
725  "sensitive", !is_posted);
726  gnc_plugin_update_actions (action_group, can_unpost_actions,
727  "sensitive", can_unpost);
728  gnc_plugin_update_actions (action_group, invoice_book_readwrite_actions,
729  "sensitive", !is_readonly);
730 
731  /* update the action labels */
732  gnc_plugin_page_invoice_action_update (action_group, label_list, (void*)gtk_action_set_label);
733  /* update the action tooltips */
734  gnc_plugin_page_invoice_action_update (action_group, tooltip_list, (void*)gtk_action_set_tooltip);
735 
736  // if there is no default layout do not enable reset action
737  gnc_plugin_page_update_reset_layout_action (page);
738 
739  /* update the layout action labels */
740  gnc_plugin_page_invoice_action_update (action_group, label_layout_list, (void*)gtk_action_set_label);
741  /* update the layout action tooltips */
742  gnc_plugin_page_invoice_action_update (action_group, tooltip_layout_list, (void*)gtk_action_set_tooltip);
743 
744  // update doclink buttons
745  invoice = gnc_invoice_window_get_invoice (priv->iw);
746  if (gncInvoiceGetDocLink (invoice))
747  has_uri = TRUE;
748 
749  update_doclink_actions (page, has_uri);
750 }
A structure for defining alternate action names for use in the toolbar.
Definition: gnc-plugin.h:228
GtkActionGroup * gnc_plugin_page_get_action_group(GncPluginPage *page)
Retrieve the GtkActionGroup object associated with this page.
gboolean qof_book_is_readonly(const QofBook *book)
Return whether the book is read only.
Definition: qofbook.cpp:506
void gnc_plugin_update_actions(GtkActionGroup *action_group, const gchar **action_names, const gchar *property_name, gboolean value)
Update a property on a set of existing GtkActions.
Definition: gnc-plugin.c:280

◆ gnc_plugin_page_invoice_update_title()

void gnc_plugin_page_invoice_update_title ( GncPluginPage page)

Update the title associated with this invoice page.

This function should be called whenever the name on an invoice is changed.

Parameters
pageA pointer invoice page.

Definition at line 1493 of file gnc-plugin-page-invoice.c.

1494 {
1495  GncPluginPageInvoice *page;
1497  gchar *title;
1498 
1499  g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page));
1500 
1501  page = GNC_PLUGIN_PAGE_INVOICE(plugin_page);
1502  priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(page);
1503  title = gnc_invoice_get_title(priv->iw);
1504  main_window_update_page_name(plugin_page, title);
1505  g_free(title);
1506 }
void main_window_update_page_name(GncPluginPage *page, const gchar *name_in)
Update the name of the page in the main window.