GnuCash  5.6-133-gc519490283+
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 319 of file gnc-plugin-page-invoice.cpp.

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

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

477 {
478  GncMainWindow *window;
479  GSimpleActionGroup *simple_action_group;
480  GAction *action;
482  GncInvoiceType invoice_type;
483  GncInvoice *invoice;
484  action_toolbar_labels *label_list;
485  action_toolbar_labels *label_layout_list;
486  gboolean has_uri = FALSE;
487 
488  gboolean is_readonly = qof_book_is_readonly(gnc_get_current_book());
489 
490  g_return_if_fail (GNC_IS_PLUGIN_PAGE_INVOICE(page));
491 
492  priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(page);
493 
494  // lets remember these settings
495  priv->is_posted = is_posted;
496  priv->can_unpost = can_unpost;
497 
498  window = (GncMainWindow*)gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(page));
499  if (gnc_main_window_get_current_page (window) != page)
500  return;
501 
502  invoice_type = gnc_invoice_get_type_from_window(priv->iw);
503 
504  switch (invoice_type) {
505  case GNC_INVOICE_CUST_INVOICE:
506  label_list = invoice_action_labels;
507  break;
508  case GNC_INVOICE_VEND_INVOICE:
509  label_list = bill_action_labels;
510  break;
511  case GNC_INVOICE_EMPL_INVOICE:
512  label_list = voucher_action_labels;
513  break;
514  case GNC_INVOICE_CUST_CREDIT_NOTE: // fallthrough
515  case GNC_INVOICE_VEND_CREDIT_NOTE: // fallthrough
516  case GNC_INVOICE_EMPL_CREDIT_NOTE: // fallthrough
517  label_list = creditnote_action_labels;
518  break;
519  default: // catches GNC_INVOICE_UNDEFINED, use invoice by default
520  label_list = invoice_action_labels;
521  }
522 
523  // layout actions
524  switch (invoice_type) {
525  case GNC_INVOICE_CUST_INVOICE:
526  case GNC_INVOICE_CUST_CREDIT_NOTE:
527  label_layout_list = invoice_action_layout_labels;
528  break;
529  case GNC_INVOICE_VEND_INVOICE:
530  case GNC_INVOICE_VEND_CREDIT_NOTE:
531  label_layout_list = bill_action_layout_labels;
532  break;
533  case GNC_INVOICE_EMPL_INVOICE:
534  case GNC_INVOICE_EMPL_CREDIT_NOTE:
535  label_layout_list = voucher_action_layout_labels;
536  break;
537  default: // catches GNC_INVOICE_UNDEFINED, use invoice by default
538  label_layout_list = invoice_action_layout_labels;
539  }
540 
541  if (is_readonly)
542  {
543  // Are we readonly? Then don't allow any actions.
544  is_posted = TRUE;
545  can_unpost = FALSE;
546  }
547 
548  /* Enable the FilePrintAction */
549  action = gnc_main_window_find_action (window, "FilePrintAction");
550  g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE);
551 
552  simple_action_group = gnc_plugin_page_get_action_group (page);
553  gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), posted_actions,
554  is_posted);
555  gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), unposted_actions,
556  !is_posted);
557  gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), can_unpost_actions,
558  can_unpost);
559  gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), invoice_book_readwrite_actions,
560  !is_readonly);
561 
562  /* update the action labels and tooltips */
563  gnc_plugin_page_invoice_action_update (page, label_list);
564 
565  // if there is no default layout do not enable reset action
566  gnc_plugin_page_update_reset_layout_action (page);
567 
568  /* update the layout action labels and tooltips */
569  gnc_plugin_page_invoice_action_update (page, label_layout_list);
570 
571  // update doclink buttons
572  invoice = gnc_invoice_window_get_invoice (priv->iw);
573  if (gncInvoiceGetDocLink (invoice))
574  has_uri = TRUE;
575 
576  update_doclink_actions (page, has_uri);
577 }
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 1368 of file gnc-plugin-page-invoice.cpp.

1369 {
1370  GncPluginPageInvoice *page;
1372  gchar *title;
1373 
1374  g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page));
1375 
1376  page = GNC_PLUGIN_PAGE_INVOICE(plugin_page);
1377  priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(page);
1378  title = gnc_invoice_get_title(priv->iw);
1379  main_window_update_page_name(plugin_page, title);
1380  g_free(title);
1381 }
void main_window_update_page_name(GncPluginPage *page, const gchar *name_in)
Update the name of the page in the main window.