GnuCash  5.6-150-g038405b370+
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 320 of file gnc-plugin-page-invoice.cpp.

321 {
323  GncPluginPageInvoice *invoice_page;
324  const GList *item;
325 
326  /* Is there an existing page? */
327  item = gnc_gobject_tracking_get_list (GNC_PLUGIN_PAGE_INVOICE_NAME);
328  for ( ; item; item = g_list_next(item))
329  {
330  invoice_page = (GncPluginPageInvoice *)item->data;
331  priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(invoice_page);
332 
333  if (gnc_invoice_window_get_invoice (priv->iw) == invoice)
334  return priv->iw;
335  }
336  return NULL;
337 }
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 340 of file gnc-plugin-page-invoice.cpp.

341 {
343  GncPluginPageInvoice *invoice_page;
344  GncPluginPage *plugin_page;
345  const GList *item;
346 
347  /* Is there an existing page? */
348  item = gnc_gobject_tracking_get_list(GNC_PLUGIN_PAGE_INVOICE_NAME);
349  for ( ; item; item = g_list_next(item))
350  {
351  invoice_page = (GncPluginPageInvoice *)item->data;
352  priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(invoice_page);
353  if (priv->iw == iw)
354  return GNC_PLUGIN_PAGE(invoice_page);
355  }
356 
357  invoice_page = GNC_PLUGIN_PAGE_INVOICE (g_object_new (GNC_TYPE_PLUGIN_PAGE_INVOICE, nullptr));
358  priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(invoice_page);
359  priv->iw = iw;
360 
361  plugin_page = GNC_PLUGIN_PAGE(invoice_page);
363 
364  priv->component_manager_id = 0;
365  return plugin_page;
366 }
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_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 477 of file gnc-plugin-page-invoice.cpp.

478 {
479  GncMainWindow *window;
480  GSimpleActionGroup *simple_action_group;
481  GAction *action;
483  GncInvoiceType invoice_type;
484  GncInvoice *invoice;
485  action_toolbar_labels *label_list;
486  action_toolbar_labels *label_layout_list;
487  gboolean has_uri = FALSE;
488 
489  gboolean is_readonly = qof_book_is_readonly(gnc_get_current_book());
490 
491  g_return_if_fail (GNC_IS_PLUGIN_PAGE_INVOICE(page));
492 
493  priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(page);
494 
495  // lets remember these settings
496  priv->is_posted = is_posted;
497  priv->can_unpost = can_unpost;
498 
499  window = (GncMainWindow*)gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(page));
500  if (gnc_main_window_get_current_page (window) != page)
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: // fallthrough
516  case GNC_INVOICE_VEND_CREDIT_NOTE: // fallthrough
517  case GNC_INVOICE_EMPL_CREDIT_NOTE: // fallthrough
518  label_list = creditnote_action_labels;
519  break;
520  default: // catches GNC_INVOICE_UNDEFINED, use invoice by default
521  label_list = invoice_action_labels;
522  }
523 
524  // layout actions
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: // catches GNC_INVOICE_UNDEFINED, use invoice by default
539  label_layout_list = invoice_action_layout_labels;
540  }
541 
542  if (is_readonly)
543  {
544  // Are we readonly? Then don't allow any actions.
545  is_posted = TRUE;
546  can_unpost = FALSE;
547  }
548 
549  /* Enable the FilePrintAction */
550  action = gnc_main_window_find_action (window, "FilePrintAction");
551  g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE);
552 
553  simple_action_group = gnc_plugin_page_get_action_group (page);
554  gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), posted_actions,
555  is_posted);
556  gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), unposted_actions,
557  !is_posted);
558  gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), can_unpost_actions,
559  can_unpost);
560  gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), invoice_book_readwrite_actions,
561  !is_readonly);
562 
563  /* update the action labels and tooltips */
564  gnc_plugin_page_invoice_action_update (page, label_list);
565 
566  // if there is no default layout do not enable reset action
567  gnc_plugin_page_update_reset_layout_action (page);
568 
569  /* update the layout action labels and tooltips */
570  gnc_plugin_page_invoice_action_update (page, label_layout_list);
571 
572  // update doclink buttons
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 }
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.
A structure for defining alternate action names for use in the toolbar.
Definition: gnc-plugin.h:204
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.
void gnc_plugin_set_actions_enabled(GActionMap *action_map, const gchar **action_names, gboolean enable)
This function sets the sensitivity of a GAction in a specific group.
Definition: gnc-plugin.c:250
gboolean qof_book_is_readonly(const QofBook *book)
Return whether the book is read only.
Definition: qofbook.cpp:497
The instance data structure for a main window object.

◆ 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 1391 of file gnc-plugin-page-invoice.cpp.

1392 {
1393  GncPluginPageInvoice *page;
1395  gchar *title;
1396 
1397  g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page));
1398 
1399  page = GNC_PLUGIN_PAGE_INVOICE(plugin_page);
1400  priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(page);
1401  title = gnc_invoice_get_title(priv->iw);
1402  main_window_update_page_name(plugin_page, title);
1403  g_free(title);
1404 }
void main_window_update_page_name(GncPluginPage *page, const gchar *name_in)
Update the name of the page in the main window.