GnuCash c935c2f+
Loading...
Searching...
No Matches
Files | Data Structures | Macros | Enumerations | Functions
An Owner Tree Plugin

Files

file  gnc-plugin-page-owner-tree.h
 Functions providing a page which lists owners of one type.
 

Data Structures

struct  GncPluginPageOwnerTreePrivate
 
struct  action_owners_struct
 Map actions to owners. More...
 
struct  GncPluginPageOwnerTree
 
struct  GncPluginPageOwnerTreeClass
 

Macros

#define PLUGIN_PAGE_ACCT_TREE_CM_CLASS   "plugin-page-owner-tree"
 
#define DELETE_DIALOG_FILTER   "filter"
 
#define DELETE_DIALOG_OWNER   "owner"
 
#define GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(o)    ((GncPluginPageOwnerTreePrivate*)gnc_plugin_page_owner_tree_get_instance_private((GncPluginPageOwnerTree*)o))
 
#define OWNER_TYPE_LABEL   "OwnerType"
 
#define GNC_TYPE_PLUGIN_PAGE_OWNER_TREE   (gnc_plugin_page_owner_tree_get_type ())
 
#define GNC_PLUGIN_PAGE_OWNER_TREE(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_PLUGIN_PAGE_OWNER_TREE, GncPluginPageOwnerTree))
 
#define GNC_PLUGIN_PAGE_OWNER_TREE_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN_PAGE_OWNER_TREE, GncPluginPageOwnerTreeClass))
 
#define GNC_IS_PLUGIN_PAGE_OWNER_TREE(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_PLUGIN_PAGE_OWNER_TREE))
 
#define GNC_IS_PLUGIN_PAGE_OWNER_TREE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN_PAGE_OWNER_TREE))
 
#define GNC_PLUGIN_PAGE_OWNER_TREE_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_PLUGIN_PAGE_OWNER_TREE, GncPluginPageOwnerTreeClass))
 
#define GNC_PLUGIN_PAGE_OWNER_TREE_NAME   "GncPluginPageOwnerTree"
 

Enumerations

enum  { OWNER_SELECTED , LAST_SIGNAL }
 

Functions

GncPluginPagegnc_plugin_page_owner_tree_new (GncOwnerType owner_type)
 Create a new "owner tree" plugin page.
 
GncOwnergnc_plugin_page_owner_tree_get_current_owner (GncPluginPageOwnerTree *page)
 Given a pointer to an owner tree plugin page, return the selected owner (if any).
 
GType gnc_plugin_page_owner_tree_get_type (void)
 Retrieve the type number for an "owner tree" plugin page.
 

Detailed Description

Macro Definition Documentation

◆ DELETE_DIALOG_FILTER

#define DELETE_DIALOG_FILTER   "filter"

Definition at line 72 of file gnc-plugin-page-owner-tree.cpp.

◆ DELETE_DIALOG_OWNER

#define DELETE_DIALOG_OWNER   "owner"

Definition at line 73 of file gnc-plugin-page-owner-tree.cpp.

◆ GNC_IS_PLUGIN_PAGE_OWNER_TREE

#define GNC_IS_PLUGIN_PAGE_OWNER_TREE (   obj)    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_PLUGIN_PAGE_OWNER_TREE))

Definition at line 48 of file gnc-plugin-page-owner-tree.h.

◆ GNC_IS_PLUGIN_PAGE_OWNER_TREE_CLASS

#define GNC_IS_PLUGIN_PAGE_OWNER_TREE_CLASS (   klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN_PAGE_OWNER_TREE))

Definition at line 49 of file gnc-plugin-page-owner-tree.h.

◆ GNC_PLUGIN_PAGE_OWNER_TREE

#define GNC_PLUGIN_PAGE_OWNER_TREE (   obj)    (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_PLUGIN_PAGE_OWNER_TREE, GncPluginPageOwnerTree))

Definition at line 46 of file gnc-plugin-page-owner-tree.h.

◆ GNC_PLUGIN_PAGE_OWNER_TREE_CLASS

#define GNC_PLUGIN_PAGE_OWNER_TREE_CLASS (   klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN_PAGE_OWNER_TREE, GncPluginPageOwnerTreeClass))

Definition at line 47 of file gnc-plugin-page-owner-tree.h.

◆ GNC_PLUGIN_PAGE_OWNER_TREE_GET_CLASS

#define GNC_PLUGIN_PAGE_OWNER_TREE_GET_CLASS (   obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_PLUGIN_PAGE_OWNER_TREE, GncPluginPageOwnerTreeClass))

Definition at line 50 of file gnc-plugin-page-owner-tree.h.

◆ GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE

#define GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE (   o)     ((GncPluginPageOwnerTreePrivate*)gnc_plugin_page_owner_tree_get_instance_private((GncPluginPageOwnerTree*)o))

Definition at line 92 of file gnc-plugin-page-owner-tree.cpp.

134 { 0 };
135
136
137static GActionEntry gnc_plugin_page_owner_tree_actions [] =
138{
139 { "OTEditVendorAction", gnc_plugin_page_owner_tree_cmd_edit_owner, NULL, NULL, NULL },
140 { "OTEditCustomerAction", gnc_plugin_page_owner_tree_cmd_edit_owner, NULL, NULL, NULL },
141 { "OTEditEmployeeAction", gnc_plugin_page_owner_tree_cmd_edit_owner, NULL, NULL, NULL },
142 { "OTNewVendorAction", gnc_plugin_page_owner_tree_cmd_new_owner, NULL, NULL, NULL },
143 { "OTNewCustomerAction", gnc_plugin_page_owner_tree_cmd_new_owner, NULL, NULL, NULL },
144 { "OTNewEmployeeAction", gnc_plugin_page_owner_tree_cmd_new_owner, NULL, NULL, NULL },
145
146#if 0 /* Disabled due to crash */
147 { "EditDeleteOwnerAction", gnc_plugin_page_owner_tree_cmd_delete_owner, NULL, NULL, NULL },
148#endif /* Disabled due to crash */
149
150 { "ViewFilterByAction", gnc_plugin_page_owner_tree_cmd_view_filter_by, NULL, NULL, NULL },
151 { "ViewRefreshAction", gnc_plugin_page_owner_tree_cmd_refresh, NULL, NULL, NULL },
152 { "EditTaxOptionsAction", gnc_plugin_page_owner_tree_cmd_edit_tax, NULL, NULL, NULL },
153 { "OTNewBillAction", gnc_plugin_page_owner_tree_cmd_new_invoice, NULL, NULL, NULL },
154 { "OTNewInvoiceAction", gnc_plugin_page_owner_tree_cmd_new_invoice, NULL, NULL, NULL },
155 { "OTNewVoucherAction", gnc_plugin_page_owner_tree_cmd_new_invoice, NULL, NULL, NULL },
156 { "OTVendorListingReportAction", gnc_plugin_page_owner_tree_cmd_owners_report, NULL, NULL, NULL },
157 { "OTCustomerListingReportAction", gnc_plugin_page_owner_tree_cmd_owners_report, NULL, NULL, NULL },
158 { "OTVendorReportAction", gnc_plugin_page_owner_tree_cmd_owner_report, NULL, NULL, NULL },
159 { "OTCustomerReportAction", gnc_plugin_page_owner_tree_cmd_owner_report, NULL, NULL, NULL },
160 { "OTEmployeeReportAction", gnc_plugin_page_owner_tree_cmd_owner_report, NULL, NULL, NULL },
161 { "OTProcessPaymentAction", gnc_plugin_page_owner_tree_cmd_process_payment, NULL, NULL, NULL },
162 { "OTSearchInvoicesAction", gnc_plugin_page_owner_tree_cmd_search_invoices, NULL, NULL, NULL },
163};
165static guint gnc_plugin_page_owner_tree_n_actions = G_N_ELEMENTS(gnc_plugin_page_owner_tree_actions);
166
168static const gchar *gnc_plugin_load_ui_items [] =
169{
170 "FilePlaceholder3",
171 "EditPlaceholder2",
172 "EditPlaceholder3",
173 "EditPlaceholder5",
174 "ViewPlaceholder1",
175 "ViewPlaceholder4",
176 "ReportsPlaceholder1",
177 NULL,
178};
179
182static const gchar *actions_requiring_owner_rw[] =
183{
184 "OTEditVendorAction",
185 "OTEditCustomerAction",
186 "OTEditEmployeeAction",
187 "OTProcessPaymentAction",
188/* FIXME disabled due to crash "EditDeleteOwnerAction", */
189 NULL
190};
191
194static const gchar *actions_requiring_owner_always[] =
195{
196 "OTVendorReportAction",
197 "OTCustomerReportAction",
198 "OTEmployeeReportAction",
199 "OTProcessPaymentAction",
200 NULL
201};
202
203/* This is the list of actions which are switched inactive in a read-only book. */
204static const gchar* readonly_inactive_actions[] =
205{
206 "OTNewVendorAction",
207 "OTNewCustomerAction",
208 "OTNewEmployeeAction",
209 "OTNewBillAction",
210 "OTNewInvoiceAction",
211 "OTNewVoucherAction",
212 "OTProcessPaymentAction",
213 NULL
214};
215
216
218static GncToolBarShortNames toolbar_labels[] =
219{
220 { "OTEditVendorAction", N_("Edit") },
221 { "OTEditCustomerAction", N_("Edit") },
222 { "OTEditEmployeeAction", N_("Edit") },
223 { "OTNewVendorAction", N_("New") },
224 { "OTNewCustomerAction", N_("New") },
225 { "OTNewEmployeeAction", N_("New") },
226 { "OTNewBillAction", N_("New Bill") },
227 { "OTNewInvoiceAction", N_("New Invoice") },
228 { "OTNewVoucherAction", N_("New Voucher") },
229 { "OTVendorListingReportAction", N_("Vendor Listing") },
230 { "OTCustomerListingReportAction", N_("Customer Listing") },
231 { "OTProcessPaymentAction", N_("Process Payment") },
232/* FIXME disable due to crash { "EditDeleteOwnerAction", N_("Delete") },*/
233 { NULL, NULL },
234};
235
239typedef struct
240{
242 const char *action_name;
244 GncOwnerType owner_type;
246
248gnc_plugin_page_owner_tree_new (GncOwnerType owner_type)
249{
250 GncPluginPageOwnerTree *plugin_page;
252 const GList *item;
253
254 g_return_val_if_fail( (owner_type != GNC_OWNER_UNDEFINED)
255 && (owner_type != GNC_OWNER_NONE), NULL);
256 ENTER(" ");
257
258 /* Is there an existing page? */
259 item = gnc_gobject_tracking_get_list(GNC_PLUGIN_PAGE_OWNER_TREE_NAME);
260 for ( ; item; item = g_list_next(item))
261 {
262 plugin_page = (GncPluginPageOwnerTree *)item->data;
263 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
264 if (priv->owner_type == owner_type)
265 {
266 LEAVE("existing %s tree page %p", gncOwnerTypeToQofIdType(owner_type), plugin_page);
267 return GNC_PLUGIN_PAGE(plugin_page);
268 }
269 }
270
271 plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(g_object_new(GNC_TYPE_PLUGIN_PAGE_OWNER_TREE, nullptr));
272
273 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
274 priv->owner_type = owner_type;
275
276 LEAVE("new %s tree page %p", gncOwnerTypeToQofIdType(owner_type), plugin_page);
277 return GNC_PLUGIN_PAGE(plugin_page);
278}
279
284static gboolean
285gnc_plugin_page_owner_focus_widget (GncPluginPage *owner_plugin_page)
286{
287 if (GNC_IS_PLUGIN_PAGE_OWNER_TREE(owner_plugin_page))
288 {
289 GncPluginPageOwnerTreePrivate *priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(owner_plugin_page);
290 GtkTreeView *tree_view = priv->tree_view;
291
292 /* Disable the Transaction Menu */
293 GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(owner_plugin_page->window), "TransactionAction");
294 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
295 /* Disable the Schedule menu */
296 action = gnc_main_window_find_action (GNC_MAIN_WINDOW(owner_plugin_page->window), "ScheduledAction");
297 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
298 /* Disable the FilePrintAction */
299 action = gnc_main_window_find_action (GNC_MAIN_WINDOW(owner_plugin_page->window), "FilePrintAction");
300 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
301
302 set_menu_and_toolbar_qualifier (owner_plugin_page);
303
304 gnc_main_window_update_menu_and_toolbar (GNC_MAIN_WINDOW(owner_plugin_page->window),
305 owner_plugin_page,
306 gnc_plugin_load_ui_items);
307
308 // setup any short toolbar names
309 gnc_main_window_init_short_names (GNC_MAIN_WINDOW(owner_plugin_page->window), toolbar_labels);
310
311 if (GTK_IS_TREE_VIEW(tree_view))
312 {
313 if (!gtk_widget_is_focus (GTK_WIDGET(tree_view)))
314 gtk_widget_grab_focus (GTK_WIDGET(tree_view));
315 }
316 }
317 return FALSE;
318}
319
320static void
321gnc_plugin_page_owner_tree_class_init (GncPluginPageOwnerTreeClass *klass)
322{
323 GObjectClass *object_class = G_OBJECT_CLASS (klass);
324 GncPluginPageClass *gnc_plugin_class = GNC_PLUGIN_PAGE_CLASS(klass);
325
326 object_class->finalize = gnc_plugin_page_owner_tree_finalize;
327
328 gnc_plugin_class->tab_icon = GNC_ICON_ACCOUNT;
329 gnc_plugin_class->plugin_name = GNC_PLUGIN_PAGE_OWNER_TREE_NAME;
330 gnc_plugin_class->create_widget = gnc_plugin_page_owner_tree_create_widget;
331 gnc_plugin_class->destroy_widget = gnc_plugin_page_owner_tree_destroy_widget;
332 gnc_plugin_class->save_page = gnc_plugin_page_owner_tree_save_page;
333 gnc_plugin_class->recreate_page = gnc_plugin_page_owner_tree_recreate_page;
334 gnc_plugin_class->focus_page_function = gnc_plugin_page_owner_focus_widget;
335
336 plugin_page_signals[OWNER_SELECTED] =
337 g_signal_new ("owner_selected",
338 G_OBJECT_CLASS_TYPE (object_class),
339 G_SIGNAL_RUN_FIRST,
340 G_STRUCT_OFFSET (GncPluginPageOwnerTreeClass, owner_selected),
341 NULL, NULL,
342 g_cclosure_marshal_VOID__POINTER,
343 G_TYPE_NONE, 1,
344 G_TYPE_POINTER);
345}
346
347static void
348gnc_plugin_page_owner_tree_init (GncPluginPageOwnerTree *plugin_page)
349{
350 GSimpleActionGroup *simple_action_group;
352 GncPluginPage *parent;
353
354 ENTER("page %p", plugin_page);
355 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
356
357 /* Init parent declared variables */
358 parent = GNC_PLUGIN_PAGE(plugin_page);
359 g_object_set(G_OBJECT(plugin_page),
360 "page-name", _("Owners"),
361 "ui-description", "gnc-plugin-page-owner-tree.ui",
362 NULL);
363 g_signal_connect (G_OBJECT (plugin_page), "selected",
364 G_CALLBACK (gnc_plugin_page_owner_tree_selected), plugin_page);
365
366 /* change me when the system supports multiple books */
367 gnc_plugin_page_add_book (parent, gnc_get_current_book());
368
369 /* Create menu and toolbar information */
370 simple_action_group = gnc_plugin_page_create_action_group (parent, "GncPluginPageOwnerTreeActions");
371 g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group),
372 gnc_plugin_page_owner_tree_actions,
373 gnc_plugin_page_owner_tree_n_actions,
374 plugin_page);
375
376 /* Init filter */
377 priv->fd.show_inactive = TRUE;
378 priv->fd.show_zero_total = TRUE;
379
380 LEAVE("page %p, priv %p, action group %p",
381 plugin_page, priv, simple_action_group);
382}
383
384static void
385gnc_plugin_page_owner_tree_finalize (GObject *object)
386{
389
390 ENTER("object %p", object);
391 page = GNC_PLUGIN_PAGE_OWNER_TREE (object);
392 g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE (page));
393 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
394 g_return_if_fail (priv != NULL);
395
396 G_OBJECT_CLASS (gnc_plugin_page_owner_tree_parent_class)->finalize (object);
397 LEAVE(" ");
398}
399
400static void
401update_inactive_actions(GncPluginPage *plugin_page)
402{
403 GSimpleActionGroup *simple_action_group;
404 gboolean is_sensitive = !qof_book_is_readonly(gnc_get_current_book());
405
406 // We are readonly - so we have to switch particular actions to inactive.
407 g_return_if_fail(plugin_page);
408 g_return_if_fail(GNC_IS_PLUGIN_PAGE(plugin_page));
409
410 /* Get the action group */
411 simple_action_group = gnc_plugin_page_get_action_group (plugin_page);
412 g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group));
413
414 /* Set the action's sensitivity */
415 gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), readonly_inactive_actions,
416 is_sensitive);
417}
418
419static void
420set_menu_and_toolbar_qualifier (GncPluginPage *plugin_page)
421{
422 GncPluginPageOwnerTree *page = GNC_PLUGIN_PAGE_OWNER_TREE(plugin_page);
424
425 g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE(page));
426
427 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
428
429 if (priv->owner_type == GNC_OWNER_CUSTOMER)
430 gnc_plugin_page_set_menu_qualifier (plugin_page, "c");
431 else if (priv->owner_type == GNC_OWNER_VENDOR)
432 gnc_plugin_page_set_menu_qualifier (plugin_page, "v");
433 else if (priv->owner_type == GNC_OWNER_EMPLOYEE)
434 gnc_plugin_page_set_menu_qualifier (plugin_page, "e");
435 else
436 gnc_plugin_page_set_menu_qualifier (plugin_page, NULL);
437}
438
439static void
440gnc_plugin_page_owner_tree_selected (GObject *object, gpointer user_data)
441{
442 GncPluginPage *page = GNC_PLUGIN_PAGE (object);
443 g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
444 update_inactive_actions(page);
445}
446
447
448GncOwner *
450{
452 GncOwner *owner;
453
454 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
455 ENTER("page %p (tree view %p)", page, priv->tree_view);
456 owner = gnc_tree_view_owner_get_selected_owner (GNC_TREE_VIEW_OWNER(priv->tree_view));
457 if (owner == NULL)
458 {
459 LEAVE("no owner");
460 return NULL;
461 }
462
463 LEAVE("owner %p", owner);
464 return owner;
465}
466
467
468/* Virtual Functions */
469
470static void
471gnc_plugin_page_owner_refresh_cb (GHashTable *changes, gpointer user_data)
472{
473 auto page = GNC_PLUGIN_PAGE_OWNER_TREE(user_data);
475
476 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(page));
477
478 /* We're only looking for forced updates here. */
479 if (changes)
480 return;
481
482 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
483 gtk_widget_queue_draw(priv->widget);
484}
485
486static void
487gnc_plugin_page_owner_tree_close_cb (gpointer user_data)
488{
489 GncPluginPage *plugin_page;
490
491 plugin_page = GNC_PLUGIN_PAGE(user_data);
492 gnc_main_window_close_page(plugin_page);
493}
494
495static GtkWidget *
496gnc_plugin_page_owner_tree_create_widget (GncPluginPage *plugin_page)
497{
500 GtkTreeSelection *selection;
501 GtkTreeView *tree_view;
502 GtkWidget *scrolled_window;
503 GtkTreeViewColumn *col;
504 const gchar *state_section = NULL;
505 const gchar* label = "";
506 const gchar *style_label = NULL;
507
508 ENTER("page %p", plugin_page);
509 page = GNC_PLUGIN_PAGE_OWNER_TREE (plugin_page);
510 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
511 if (priv->widget != NULL)
512 {
513 LEAVE("widget = %p", priv->widget);
514 return priv->widget;
515 }
516
517 priv->widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
518 gtk_box_set_homogeneous (GTK_BOX (priv->widget), FALSE);
519 gtk_widget_show (priv->widget);
520
521 // Set the name for this widget so it can be easily manipulated with css
522 gtk_widget_set_name (GTK_WIDGET(priv->widget), "gnc-id-owner-page");
523
524 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
525 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
526 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
527 gtk_widget_show (scrolled_window);
528 gtk_box_pack_start (GTK_BOX (priv->widget), scrolled_window,
529 TRUE, TRUE, 0);
530
531 tree_view = gnc_tree_view_owner_new(priv->owner_type);
532
533 /* Show default columns */
535 GNC_TREE_VIEW(tree_view), GNC_OWNER_TREE_ID_COL);
536 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
538 GNC_TREE_VIEW(tree_view), GNC_OWNER_TREE_ADDRESS_1_COL);
539 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
541 GNC_TREE_VIEW(tree_view), GNC_OWNER_TREE_ADDRESS_2_COL);
542 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
544 GNC_TREE_VIEW(tree_view), GNC_OWNER_TREE_PHONE_COL);
545 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
546 gnc_tree_view_configure_columns(GNC_TREE_VIEW(tree_view));
547
548 switch (priv->owner_type)
549 {
550 case GNC_OWNER_NONE :
551 case GNC_OWNER_UNDEFINED :
552 PWARN("missing owner_type");
553 label = _("Unknown");
554 style_label = "gnc-class-unknown";
555 break;
556 case GNC_OWNER_CUSTOMER :
557 label = _("Customers");
558 state_section = "Customers Overview";
559 style_label = "gnc-class-customers";
560 break;
561 case GNC_OWNER_JOB :
562 label = _("Jobs");
563 state_section = "Jobs Overview";
564 style_label = "gnc-class-jobs";
565 break;
566 case GNC_OWNER_VENDOR :
567 label = _("Vendors");
568 state_section = "Vendors Overview";
569 style_label = "gnc-class-vendors";
570 break;
571 case GNC_OWNER_EMPLOYEE :
572 label = _("Employees");
573 state_section = "Employees Overview";
574 style_label = "gnc-class-employees";
575 break;
576 }
577
578 // Set a secondary style context for this page so it can be easily manipulated with css
579 gnc_widget_style_context_add_class (GTK_WIDGET(priv->widget), style_label);
580
581 g_object_set(G_OBJECT(tree_view), "state-section", state_section,
582 "show-column-menu", TRUE,
583 NULL);
584
585 g_object_set(G_OBJECT(plugin_page), "page-name", label, NULL);
586
587 priv->tree_view = tree_view;
588 selection = gtk_tree_view_get_selection(tree_view);
589 g_signal_connect (G_OBJECT (selection), "changed",
590 G_CALLBACK (gnc_plugin_page_owner_tree_selection_changed_cb), page);
591 g_signal_connect (G_OBJECT (tree_view), "button-press-event",
592 G_CALLBACK (gnc_plugin_page_owner_tree_button_press_cb), page);
593 g_signal_connect (G_OBJECT (tree_view), "row-activated",
594 G_CALLBACK (gnc_plugin_page_owner_tree_double_click_cb), page);
595
596 gtk_tree_view_set_headers_visible(tree_view, TRUE);
597 gnc_plugin_page_owner_tree_selection_changed_cb (NULL, page);
598 gtk_widget_show (GTK_WIDGET (tree_view));
599 gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET(tree_view));
600
601 priv->fd.tree_view = GNC_TREE_VIEW_OWNER(priv->tree_view);
603 GNC_TREE_VIEW_OWNER(tree_view),
605
606 priv->component_id =
607 gnc_register_gui_component(PLUGIN_PAGE_ACCT_TREE_CM_CLASS,
608 gnc_plugin_page_owner_refresh_cb,
609 gnc_plugin_page_owner_tree_close_cb,
610 page);
611 gnc_gui_component_set_session (priv->component_id,
612 gnc_get_current_session());
613
614 g_signal_connect (G_OBJECT(plugin_page), "inserted",
615 G_CALLBACK(gnc_plugin_page_inserted_cb),
616 NULL);
617
618 set_menu_and_toolbar_qualifier (plugin_page);
619
620 LEAVE("widget = %p", priv->widget);
621 return priv->widget;
622}
623
624static void
625gnc_plugin_page_owner_tree_destroy_widget (GncPluginPage *plugin_page)
626{
629
630 ENTER("page %p", plugin_page);
631 page = GNC_PLUGIN_PAGE_OWNER_TREE (plugin_page);
632 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
633
634 // Remove the page_changed signal callback
635 gnc_plugin_page_disconnect_page_changed (GNC_PLUGIN_PAGE(plugin_page));
636
637 // Remove the page focus idle function if present
638 g_idle_remove_by_data (plugin_page);
639
640 if (priv->widget)
641 {
642 g_object_unref(G_OBJECT(priv->widget));
643 priv->widget = NULL;
644 }
645
646 if (priv->component_id)
647 {
648 gnc_unregister_gui_component(priv->component_id);
649 priv->component_id = 0;
650 }
651
652 LEAVE("widget destroyed");
653}
654
655#define OWNER_TYPE_LABEL "OwnerType"
656
666static void
667gnc_plugin_page_owner_tree_save_page (GncPluginPage *plugin_page,
668 GKeyFile *key_file,
669 const gchar *group_name)
670{
671 GncPluginPageOwnerTree *owner_page;
673
674 g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
675 g_return_if_fail (key_file != NULL);
676 g_return_if_fail (group_name != NULL);
677
678 ENTER("page %p, key_file %p, group_name %s", plugin_page, key_file,
679 group_name);
680
681 owner_page = GNC_PLUGIN_PAGE_OWNER_TREE(plugin_page);
682 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(owner_page);
683
684 g_key_file_set_integer(key_file, group_name, OWNER_TYPE_LABEL,
685 priv->owner_type);
686
687 gnc_tree_view_owner_save(GNC_TREE_VIEW_OWNER(priv->tree_view),
688 &priv->fd, key_file, group_name);
689 LEAVE(" ");
690}
691
692
693
703static GncPluginPage *
704gnc_plugin_page_owner_tree_recreate_page (GtkWidget *window,
705 GKeyFile *key_file,
706 const gchar *group_name)
707{
708 GncPluginPageOwnerTree *owner_page;
710 GncPluginPage *page;
711 GncOwnerType owner_type;
712
713 g_return_val_if_fail(key_file, NULL);
714 g_return_val_if_fail(group_name, NULL);
715 ENTER("key_file %p, group_name %s", key_file, group_name);
716
717 /* Create the new page. */
718 owner_type = static_cast<GncOwnerType>(g_key_file_get_integer(key_file, group_name, OWNER_TYPE_LABEL, NULL));
719 page = gnc_plugin_page_owner_tree_new(owner_type);
720 owner_page = GNC_PLUGIN_PAGE_OWNER_TREE(page);
721 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(owner_page);
722
723 /* Install it now so we can then manipulate the created widget */
724 gnc_main_window_open_page(GNC_MAIN_WINDOW(window), page);
725
726 gnc_tree_view_owner_restore(GNC_TREE_VIEW_OWNER(priv->tree_view),
727 &priv->fd, key_file, group_name, owner_type);
728 LEAVE(" ");
729 return page;
730}
731
732/* Wrapper function to open the proper edit dialog, depending on the owner type */
733static void gnc_ui_owner_edit (GtkWindow *parent, GncOwner *owner)
734{
735 if (NULL == owner) return;
736
737 switch (owner->type)
738 {
739 case GNC_OWNER_NONE :
740 case GNC_OWNER_UNDEFINED :
741 break;
742 case GNC_OWNER_CUSTOMER :
743 {
744 gnc_ui_customer_edit (parent, owner->owner.customer);
745 break;
746 }
747 case GNC_OWNER_JOB :
748 {
749 gnc_ui_job_edit (parent, owner->owner.job);
750 break;
751 }
752 case GNC_OWNER_VENDOR :
753 {
754 gnc_ui_vendor_edit (parent, owner->owner.vendor);
755 break;
756 }
757 case GNC_OWNER_EMPLOYEE :
758 {
759 gnc_ui_employee_edit (parent, owner->owner.employee);
760 break;
761 }
762 }
763}
764
765
766/* Callbacks */
767
775static gboolean
776gnc_plugin_page_owner_tree_button_press_cb (GtkWidget *widget,
777 GdkEventButton *event,
778 GncPluginPage *page)
779{
780 g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), FALSE);
781
782 ENTER("widget %p, event %p, page %p", widget, event, page);
783 gnc_main_window_button_press_cb(widget, event, page);
784 LEAVE(" ");
785
786 /* Always return FALSE. This will let the tree view callback run as
787 * well which will select the item under the cursor. By the time
788 * the user sees the menu both callbacks will have run and the menu
789 * actions will operate on the just-selected owner. */
790 return FALSE;
791}
792
793static void
794gnc_plugin_page_owner_tree_double_click_cb (GtkTreeView *treeview,
795 GtkTreePath *path,
796 GtkTreeViewColumn *col,
798{
799 gnc_plugin_page_owner_tree_cmd_owner_report (NULL, NULL, (gpointer*)page);
800}
801
802static void
803gnc_plugin_page_owner_tree_selection_changed_cb (GtkTreeSelection *selection,
805{
806 GSimpleActionGroup *simple_action_group;
807 GtkTreeView *view;
808 GncOwner *owner = NULL;
809 gboolean sensitive;
810 gboolean is_readwrite = !qof_book_is_readonly(gnc_get_current_book());
811
812 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(page));
813
814 if (!selection)
815 {
816 sensitive = FALSE;
817 }
818 else
819 {
820 g_return_if_fail(GTK_IS_TREE_SELECTION(selection));
821 view = gtk_tree_selection_get_tree_view (selection);
822 owner = gnc_tree_view_owner_get_selected_owner (GNC_TREE_VIEW_OWNER(view));
823 sensitive = (owner != NULL);
824 }
825
826 simple_action_group = gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page));
827 gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), actions_requiring_owner_always,
828 sensitive);
829 gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), actions_requiring_owner_rw,
830 sensitive && is_readwrite);
831 g_signal_emit (page, plugin_page_signals[OWNER_SELECTED], 0, owner);
832}
833
834/******************************************************************/
835/* Report helper functions */
836/******************************************************************/
837
838static int
839build_aging_report (GncOwnerType owner_type)
840{
841 const gchar *report_name = NULL;
842 const gchar *report_title = NULL;
843 SCM args;
844 SCM func;
845 SCM arg;
846
847 args = SCM_EOL;
848
849 switch (owner_type)
850 {
851 case GNC_OWNER_NONE :
852 case GNC_OWNER_UNDEFINED :
853 case GNC_OWNER_EMPLOYEE :
854 case GNC_OWNER_JOB :
855 {
856 return -1;
857 }
858 case GNC_OWNER_VENDOR :
859 {
860 report_name = "gnc:payables-report-create";
861 report_title = _("Vendor Listing");
862 break;
863 }
864 case GNC_OWNER_CUSTOMER :
865 {
866 report_name = "gnc:receivables-report-create";
867 report_title = _("Customer Listing");
868 break;
869 }
870 }
871
872 /* Find report generator function in guile */
873 func = scm_c_eval_string (report_name);
874 g_return_val_if_fail (scm_is_procedure (func), -1);
875
876 /* Option Show zero's ? - Yes for the listing report */
877 arg = SCM_BOOL_T;
878 args = scm_cons (arg, args);
879 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
880
881 /* Option Report title */
882 arg = scm_from_utf8_string (report_title);
883 args = scm_cons (arg, args);
884
885 /* Option Account - Using False to select default account
886 *
887 * XXX I'm not sure if it would make sense to use another
888 * account than default */
889 arg = SCM_BOOL_F;
890 args = scm_cons (arg, args);
891 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
892
893
894 /* Apply the function to the args */
895 arg = scm_apply (func, args, SCM_EOL);
896 g_return_val_if_fail (scm_is_exact (arg), -1);
897
898 return scm_to_int (arg);
899}
900
901static int build_owner_report (GncOwner *owner, Account *acc)
902{
903 SCM args;
904 SCM func;
905 SCM arg;
906
907 g_return_val_if_fail (owner, -1);
908
909 args = SCM_EOL;
910
911 func = scm_c_eval_string ("gnc:owner-report-create-with-enddate");
912 g_return_val_if_fail (scm_is_procedure (func), -1);
913
914 args = scm_cons (SCM_BOOL_F, args); /* enddate is #f */
915
916 if (acc)
917 {
918 swig_type_info * qtype = SWIG_TypeQuery("_p_Account");
919 g_return_val_if_fail (qtype, -1);
920
921 arg = SWIG_NewPointerObj(acc, qtype, 0);
922 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
923 args = scm_cons (arg, args);
924 }
925 else
926 {
927 args = scm_cons (SCM_BOOL_F, args);
928 }
929
930 swig_type_info * qtype = SWIG_TypeQuery("_p__gncOwner");
931 g_return_val_if_fail (qtype, -1);
932
933 arg = SWIG_NewPointerObj(owner, qtype, 0);
934
935 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
936 args = scm_cons (arg, args);
937
938 /* Apply the function to the args */
939 arg = scm_apply (func, args, SCM_EOL);
940 g_return_val_if_fail (scm_is_exact (arg), -1);
941 return scm_to_int (arg);
942}
943
944
945/************************************************************/
946/* Command callbacks */
947/************************************************************/
948
949static void
950gnc_plugin_page_owner_tree_cmd_new_owner (GSimpleAction *simple,
951 GVariant *parameter,
952 gpointer user_data)
953
954{
955 auto page = GNC_PLUGIN_PAGE_OWNER_TREE (user_data);
957 GtkWindow *parent;
958
959 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(page));
960
961 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE (page);
962 parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page)));
963
964 switch (priv->owner_type)
965 {
966 case GNC_OWNER_NONE :
967 case GNC_OWNER_UNDEFINED :
968 break;
969 case GNC_OWNER_CUSTOMER :
970 {
971 gnc_ui_customer_new (parent, gnc_get_current_book ());
972 break;
973 }
974 case GNC_OWNER_JOB :
975 {
976 /* XXX currently not properly implemented, so disabled for now
977 gnc_ui_job_new (owner, gnc_get_current_book ()); */
978 break;
979 }
980 case GNC_OWNER_VENDOR :
981 {
982 gnc_ui_vendor_new (parent, gnc_get_current_book ());
983 break;
984 }
985 case GNC_OWNER_EMPLOYEE :
986 {
987 gnc_ui_employee_new (parent, gnc_get_current_book ());
988 break;
989 }
990 }
991}
992
993static void
994gnc_plugin_page_owner_tree_cmd_edit_owner (GSimpleAction *simple,
995 GVariant *parameter,
996 gpointer user_data)
997
998{
999 auto page = GNC_PLUGIN_PAGE_OWNER_TREE (user_data);
1000 GtkWindow *parent;
1002 if (NULL == owner) return;
1003
1004 ENTER("action %p, page %p", simple, page);
1005
1006 parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page)));
1007 gnc_ui_owner_edit (parent, owner);
1008
1009 LEAVE(" ");
1010}
1011
1012static void
1013gnc_plugin_page_owner_tree_cmd_search_invoices (GSimpleAction *simple,
1014 GVariant *parameter,
1015 gpointer user_data)
1016
1017{
1018 auto page = GNC_PLUGIN_PAGE_OWNER_TREE (user_data);
1019 GtkWindow *parent;
1021 if (NULL == owner) return;
1022
1023 ENTER("action %p, page %p", simple, page);
1024
1025 parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page)));
1026
1027 gnc_invoice_search (parent, NULL, owner, gnc_get_current_book ());
1028
1029 LEAVE(" ");
1030}
1031
1032
1033#if 0 /* Disabled due to crash */
1034static void
1035gnc_plugin_page_owner_tree_cmd_delete_owner (GSimpleAction *simple,
1036 GVariant *parameter,
1037 gpointer user_data)
1038
1039{
1040 auto page = GNC_PLUGIN_PAGE_OWNER_TREE (user_data);
1042 gchar *owner_name;
1043 GtkWidget *window;
1044 GtkWidget *dialog = NULL;
1045 gint response;
1046 GList* list;
1047
1048 if (NULL == owner) return;
1049
1050 /* If the owner has objects referring to it, show the list - the owner can't be deleted until these
1051 references are dealt with. */
1053 if (list != NULL)
1054 {
1055#define EXPLANATION "The list below shows objects which make use of the owner which you want to delete.\nBefore you can delete it, you must either delete those objects or else modify them so they make use\nof another owner"
1056
1057 gnc_ui_object_references_show( _(EXPLANATION), list);
1058 g_list_free(list);
1059 return;
1060 }
1061
1062 window = gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(page));
1063 owner_name = g_strdup (gncOwnerGetName(owner));
1064 if (!owner_name)
1065 {
1066 owner_name = g_strdup (_("(no name)"));
1067 }
1068
1069 /*
1070 * Present a message to the user which specifies what will be
1071 * deleted, then ask for verification.
1072 */
1073 {
1074 char *message = g_strdup_printf(_("The owner %s will be deleted.\nAre you sure you want to do this?"), owner_name);
1075
1076 dialog = gtk_message_dialog_new(GTK_WINDOW(window),
1077 GTK_DIALOG_DESTROY_WITH_PARENT,
1078 GTK_MESSAGE_QUESTION,
1079 GTK_BUTTONS_NONE,
1080 "%s", message);
1081 g_free(message);
1082 gtk_dialog_add_buttons(GTK_DIALOG(dialog),
1083 _("_Cancel"), GTK_RESPONSE_CANCEL,
1084 _("_Delete"), GTK_RESPONSE_ACCEPT,
1085 (gchar *)NULL);
1086 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
1087 response = gtk_dialog_run(GTK_DIALOG(dialog));
1088 gtk_widget_destroy(dialog);
1089
1090 if (GTK_RESPONSE_ACCEPT == response)
1091 {
1092 /* FIXME The code below results in a crash.
1093 * The corresponding menu item/toolbar button is disabled until this is fixed. */
1094 gnc_set_busy_cursor(NULL, TRUE);
1095 gnc_suspend_gui_refresh ();
1096 gncOwnerBeginEdit (owner);
1097 gncOwnerDestroy (owner);
1098 gnc_resume_gui_refresh ();
1099 gnc_unset_busy_cursor(NULL);
1100 }
1101 }
1102 g_free(owner_name);
1103}
1104#endif /* Disabled due to crash */
1105
1106/*********************/
1107
1108static void
1109gnc_plugin_page_owner_tree_cmd_view_filter_by (GSimpleAction *simple,
1110 GVariant *parameter,
1111 gpointer user_data)
1112
1113{
1114 auto plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(user_data);
1116
1117 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1118 ENTER("(action %p, page %p)", simple, plugin_page);
1119
1120 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
1121 owner_filter_dialog_create(&priv->fd, GNC_PLUGIN_PAGE(plugin_page));
1122 LEAVE(" ");
1123}
1124
1125static void
1126gnc_plugin_page_owner_tree_cmd_refresh (GSimpleAction *simple,
1127 GVariant *parameter,
1128 gpointer user_data)
1129
1130{
1131 auto plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(user_data);
1133
1134 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1135
1136 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
1137 gtk_widget_queue_draw (priv->widget);
1138}
1139
1140static void
1141gnc_plugin_page_owner_tree_cmd_edit_tax (GSimpleAction *simple,
1142 GVariant *parameter,
1143 gpointer user_data)
1144{
1145 auto plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(user_data);
1146 GtkWidget *parent;
1147
1148 g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1149
1150 parent = GTK_WIDGET(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page)));
1151
1152 gnc_tax_info_dialog (parent, NULL);
1153}
1154
1155static void
1156gnc_plugin_page_owner_tree_cmd_new_invoice (GSimpleAction *simple,
1157 GVariant *parameter,
1158 gpointer user_data)
1159
1160{
1161 auto plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(user_data);
1163 GncOwner current_owner;
1164 GtkWindow *parent;
1165
1166 ENTER("action %p, plugin_page %p", simple, plugin_page);
1167
1168 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
1169 switch (priv->owner_type)
1170 {
1171 case GNC_OWNER_NONE :
1172 case GNC_OWNER_UNDEFINED :
1173 gncOwnerInitUndefined(&current_owner, NULL);
1174 break;
1175 case GNC_OWNER_CUSTOMER :
1176 {
1177 gncOwnerInitCustomer(&current_owner,
1179 break;
1180 }
1181 case GNC_OWNER_JOB :
1182 {
1183 gncOwnerInitJob(&current_owner,
1185 break;
1186 }
1187 case GNC_OWNER_VENDOR :
1188 {
1189 gncOwnerInitVendor(&current_owner,
1191 break;
1192 }
1193 case GNC_OWNER_EMPLOYEE :
1194 {
1195 gncOwnerInitEmployee(&current_owner,
1197 break;
1198 }
1199 }
1200
1201 parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page)));
1202 if (gncOwnerGetType(&current_owner) != GNC_OWNER_UNDEFINED)
1203 gnc_ui_invoice_new (parent, &current_owner, gnc_get_current_book ());
1204
1205 LEAVE(" ");
1206}
1207
1208static void
1209gnc_plugin_page_owner_tree_cmd_owners_report (GSimpleAction *simple,
1210 GVariant *parameter,
1211 gpointer user_data)
1212
1213{
1214 auto plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(user_data);
1216 int id;
1217
1218 ENTER("(action %p, plugin_page %p)", simple, plugin_page);
1219
1220 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1221
1222 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
1223 id = build_aging_report (priv->owner_type);
1224 if (id >= 0)
1225 {
1226 GncMainWindow *window;
1227 window = GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window);
1228 gnc_main_window_open_report(id, window);
1229 }
1230
1231 LEAVE(" ");
1232}
1233
1234static void
1235gnc_plugin_page_owner_tree_cmd_owner_report (GSimpleAction *simple,
1236 GVariant *parameter,
1237 gpointer user_data)
1238
1239{
1240 auto plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(user_data);
1241 GncOwner *current_owner;
1242 int id;
1243
1244 ENTER("(action %p, plugin_page %p)", simple, plugin_page);
1245
1246 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1247
1248 current_owner = gnc_plugin_page_owner_tree_get_current_owner (plugin_page);
1249 id = build_owner_report (current_owner, NULL);
1250 if (id >= 0)
1251 {
1252 GncMainWindow *window;
1253 window = GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window);
1254 gnc_main_window_open_report(id, window);
1255 }
1256
1257 LEAVE(" ");
1258}
1259
1260
1261static void
1262gnc_plugin_page_owner_tree_cmd_process_payment (GSimpleAction *simple,
1263 GVariant *parameter,
1264 gpointer user_data)
1265
1266{
1267 auto plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(user_data);
1268 ENTER("(action %p, plugin_page %p)", simple, plugin_page);
1269
1270 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1271
1272 gnc_ui_payment_new (GTK_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window),
1274 gnc_get_current_book ());
1275
1276 LEAVE(" ");
1277}
gboolean qof_book_is_readonly(const QofBook *book)
Return whether the book is read only.
Definition qofbook.cpp:497
GSimpleActionGroup * gnc_plugin_page_create_action_group(GncPluginPage *page, const gchar *group_name)
Create the GSimpleActionGroup object associated with this page.
GtkWidget * gnc_plugin_page_get_window(GncPluginPage *page)
Retrieve a pointer to the GncMainWindow (GtkWindow) containing this page.
void gnc_plugin_page_disconnect_page_changed(GncPluginPage *page)
Disconnect the page_changed_id signal callback.
void gnc_plugin_page_add_book(GncPluginPage *page, QofBook *book)
Add a book reference to the specified page.
void gnc_plugin_page_inserted_cb(GncPluginPage *page, gpointer user_data)
Set up the page_changed callback for when the current page is changed.
GSimpleActionGroup * gnc_plugin_page_get_action_group(GncPluginPage *page)
Retrieve the GSimpleActionGroup object associated with this page.
void gnc_plugin_page_set_menu_qualifier(GncPluginPage *page, const char *menu_qualifier)
Set a qualifier string for this page.
gboolean gnc_main_window_button_press_cb(GtkWidget *whatever, GdkEventButton *event, GncPluginPage *page)
Callback function invoked when the user clicks in the content of any Gnucash window.
GAction * gnc_main_window_find_action(GncMainWindow *window, const gchar *action_name)
Find the GAction in the main window.
void gnc_main_window_init_short_names(GncMainWindow *window, GncToolBarShortNames *toolbar_labels)
Update the labels of the toolbar items with short names.
void gnc_main_window_open_page(GncMainWindow *window, GncPluginPage *page)
Display a data plugin page in a window.
void gnc_main_window_update_menu_and_toolbar(GncMainWindow *window, GncPluginPage *page, const gchar **ui_updates)
Update the main window menu with the placeholders listed in ui_updates and load the page specific too...
void gnc_main_window_close_page(GncPluginPage *page)
Remove a data plugin page from a window and display the previous page.
GncPluginPage * gnc_plugin_page_owner_tree_new(GncOwnerType owner_type)
Create a new "owner tree" plugin page.
GncOwner * gnc_plugin_page_owner_tree_get_current_owner(GncPluginPageOwnerTree *page)
Given a pointer to an owner tree plugin page, return the selected owner (if any).
void gnc_tree_view_configure_columns(GncTreeView *view)
Make all the correct columns visible, respecting their default visibility setting,...
GtkTreeViewColumn * gnc_tree_view_find_column_by_name(GncTreeView *view, const gchar *wanted)
Find a tree column given the "pref name" used with saved state.
const GList * gnc_gobject_tracking_get_list(const gchar *name)
Get a list of all known objects of a specified type.
void gnc_tree_view_owner_set_filter(GncTreeViewOwner *view, gnc_tree_view_owner_filter_func func, gpointer data, GSourceFunc destroy)
This function attaches a filter function to the given owner tree.
GtkTreeView * gnc_tree_view_owner_new(GncOwnerType owner_type)
Create a new owner tree view for one type of owners.
GncOwner * gnc_tree_view_owner_get_selected_owner(GncTreeViewOwner *view)
This function returns the owner associated with the selected item in the owner tree view.
gboolean gnc_plugin_page_owner_tree_filter_owners(GncOwner *owner, gpointer user_data)
This function tells the owner tree view whether or not to filter out a particular owner.
GList * qof_instance_get_referring_object_list(const QofInstance *inst)
Returns a list of objects which refer to a specific object.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition qoflog.h:282
#define PWARN(format, args...)
Log a warning.
Definition qoflog.h:250
#define ENTER(format, args...)
Print a function entry debugging message.
Definition qoflog.h:272
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
GncCustomer * gncOwnerGetCustomer(const GncOwner *owner)
If the given owner is of type GNC_OWNER_CUSTOMER, returns the pointer to the customer object.
Definition gncOwner.c:369
void gncOwnerBeginEdit(GncOwner *owner)
These are convenience wrappers around gnc{Vendor,Customer,Job,Employee}* functions.
Definition gncOwner.c:72
GncEmployee * gncOwnerGetEmployee(const GncOwner *owner)
If the given owner is of type GNC_OWNER_EMPLOYEE, returns the pointer to the employee object.
Definition gncOwner.c:390
GncJob * gncOwnerGetJob(const GncOwner *owner)
If the given owner is of type GNC_OWNER_JOB, returns the pointer to the job object.
Definition gncOwner.c:376
GncVendor * gncOwnerGetVendor(const GncOwner *owner)
If the given owner is of type GNC_OWNER_VENDOR, returns the pointer to the vendor object.
Definition gncOwner.c:383
gpointer gncOwnerGetUndefined(const GncOwner *owner)
If the given owner is of type GNC_OWNER_UNDEFINED, returns the undefined pointer, which is usually NU...
Definition gncOwner.c:362
GncOwnerType gncOwnerGetType(const GncOwner *owner)
Returns the GncOwnerType of this owner.
Definition gncOwner.c:200
QofIdTypeConst gncOwnerTypeToQofIdType(GncOwnerType t)
Returns the QofIdType of the given GncOwnerType, or NULL if no suitable one exists.
Definition gncOwner.c:235
STRUCTS.
The class data structure for a content plugin.
void(* save_page)(GncPluginPage *page, GKeyFile *file, const gchar *group)
Save enough information about this page so that it can be recreated next time the user starts gnucash...
const gchar * tab_icon
The relative name of the icon that should be shown on the tab for this page.
const gchar * plugin_name
The textual name of this plugin.
void(* destroy_widget)(GncPluginPage *plugin_page)
Function called to destroy the display widget for a particular type of plugin.
GncPluginPage *(* recreate_page)(GtkWidget *window, GKeyFile *file, const gchar *group)
Create a new page based on the information saved during a previous instantiation of gnucash.
GtkWidget *(* create_widget)(GncPluginPage *plugin_page)
Function called to create the display widget for a particular type of plugin.
gboolean(* focus_page_function)(GncPluginPage *plugin_page)
This function performs specific actions to set the focus on a specific widget.
The instance data structure for a content plugin.
GtkWidget * window
The window that contains the display widget for this plugin.
A structure for defining alternate action names for use in the toolbar.

◆ GNC_PLUGIN_PAGE_OWNER_TREE_NAME

#define GNC_PLUGIN_PAGE_OWNER_TREE_NAME   "GncPluginPageOwnerTree"

Definition at line 52 of file gnc-plugin-page-owner-tree.h.

◆ GNC_TYPE_PLUGIN_PAGE_OWNER_TREE

#define GNC_TYPE_PLUGIN_PAGE_OWNER_TREE   (gnc_plugin_page_owner_tree_get_type ())

Definition at line 45 of file gnc-plugin-page-owner-tree.h.

◆ OWNER_TYPE_LABEL

#define OWNER_TYPE_LABEL   "OwnerType"

Definition at line 656 of file gnc-plugin-page-owner-tree.cpp.

◆ PLUGIN_PAGE_ACCT_TREE_CM_CLASS

#define PLUGIN_PAGE_ACCT_TREE_CM_CLASS   "plugin-page-owner-tree"

Definition at line 70 of file gnc-plugin-page-owner-tree.cpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Definition at line 75 of file gnc-plugin-page-owner-tree.cpp.

76{
77 OWNER_SELECTED,
78 LAST_SIGNAL
79};

Function Documentation

◆ gnc_plugin_page_owner_tree_get_current_owner()

GncOwner * gnc_plugin_page_owner_tree_get_current_owner ( GncPluginPageOwnerTree page)

Given a pointer to an owner tree plugin page, return the selected owner (if any).

Parameters
pageThe "owner tree" page.
Returns
The currently selected owner. NULL if no owner is selected.

Definition at line 450 of file gnc-plugin-page-owner-tree.cpp.

451{
453 GncOwner *owner;
454
455 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
456 ENTER("page %p (tree view %p)", page, priv->tree_view);
457 owner = gnc_tree_view_owner_get_selected_owner (GNC_TREE_VIEW_OWNER(priv->tree_view));
458 if (owner == NULL)
459 {
460 LEAVE("no owner");
461 return NULL;
462 }
463
464 LEAVE("owner %p", owner);
465 return owner;
466}

◆ gnc_plugin_page_owner_tree_get_type()

GType gnc_plugin_page_owner_tree_get_type ( void  )

Retrieve the type number for an "owner tree" plugin page.

Returns
The type number.

◆ gnc_plugin_page_owner_tree_new()

GncPluginPage * gnc_plugin_page_owner_tree_new ( GncOwnerType  owner_type)

Create a new "owner tree" plugin page.

Parameters
owner_typeThe owner type to create a page for. Can be any of the owner types defined in GnuCash, like vendor, customer,...
Returns
The newly created plugin page.

Definition at line 249 of file gnc-plugin-page-owner-tree.cpp.

250{
251 GncPluginPageOwnerTree *plugin_page;
253 const GList *item;
254
255 g_return_val_if_fail( (owner_type != GNC_OWNER_UNDEFINED)
256 && (owner_type != GNC_OWNER_NONE), NULL);
257 ENTER(" ");
258
259 /* Is there an existing page? */
260 item = gnc_gobject_tracking_get_list(GNC_PLUGIN_PAGE_OWNER_TREE_NAME);
261 for ( ; item; item = g_list_next(item))
262 {
263 plugin_page = (GncPluginPageOwnerTree *)item->data;
264 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
265 if (priv->owner_type == owner_type)
266 {
267 LEAVE("existing %s tree page %p", gncOwnerTypeToQofIdType(owner_type), plugin_page);
268 return GNC_PLUGIN_PAGE(plugin_page);
269 }
270 }
271
272 plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(g_object_new(GNC_TYPE_PLUGIN_PAGE_OWNER_TREE, nullptr));
273
274 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
275 priv->owner_type = owner_type;
276
277 LEAVE("new %s tree page %p", gncOwnerTypeToQofIdType(owner_type), plugin_page);
278 return GNC_PLUGIN_PAGE(plugin_page);
279}