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
147 { "EditDeleteOwnerAction", gnc_plugin_page_owner_tree_cmd_delete_owner, NULL, NULL, NULL },
148#endif
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
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
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
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
233 { NULL, NULL },
234};
235
239typedef struct
240{
242 const char *action_name;
244 GncOwnerType owner_type;
246
249{
252 const GList *item;
253
254 g_return_val_if_fail( (owner_type != GNC_OWNER_UNDEFINED)
255 && (owner_type != GNC_OWNER_NONE), NULL);
257
258
260 for ( ; item; item = g_list_next(item))
261 {
263 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
264 if (priv->owner_type == owner_type)
265 {
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
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 {
290 GtkTreeView *tree_view = priv->tree_view;
291
292
294 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
295
297 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
298
300 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
301
302 set_menu_and_toolbar_qualifier (owner_plugin_page);
303
305 owner_plugin_page,
306 gnc_plugin_load_ui_items);
307
308
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
322{
323 GObjectClass *object_class = G_OBJECT_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;
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,
341 NULL, NULL,
342 g_cclosure_marshal_VOID__POINTER,
343 G_TYPE_NONE, 1,
344 G_TYPE_POINTER);
345}
346
347static void
349{
350 GSimpleActionGroup *simple_action_group;
353
354 ENTER(
"page %p", plugin_page);
355 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
356
357
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
368
369
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
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);
398}
399
400static void
402{
403 GSimpleActionGroup *simple_action_group;
405
406
407 g_return_if_fail(plugin_page);
408 g_return_if_fail(GNC_IS_PLUGIN_PAGE(plugin_page));
409
410
412 g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group));
413
414
416 is_sensitive);
417}
418
419static void
421{
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)
431 else if (priv->owner_type == GNC_OWNER_VENDOR)
433 else if (priv->owner_type == GNC_OWNER_EMPLOYEE)
435 else
437}
438
439static void
440gnc_plugin_page_owner_tree_selected (GObject *object, gpointer user_data)
441{
443 g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
444 update_inactive_actions(page);
445}
446
447
450{
453
454 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
455 ENTER(
"page %p (tree view %p)", page, priv->tree_view);
457 if (owner == NULL)
458 {
460 return NULL;
461 }
462
463 LEAVE(
"owner %p", owner);
464 return owner;
465}
466
467
468
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
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{
490
491 plugin_page = GNC_PLUGIN_PAGE(user_data);
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
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
532
533
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));
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 :
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
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",
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
636
637
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{
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);
690}
691
692
693
704gnc_plugin_page_owner_tree_recreate_page (GtkWidget *window,
705 GKeyFile *key_file,
706 const gchar *group_name)
707{
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
718 owner_type = static_cast<GncOwnerType>(g_key_file_get_integer(key_file, group_name, OWNER_TYPE_LABEL, NULL));
720 owner_page = GNC_PLUGIN_PAGE_OWNER_TREE(page);
721 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(owner_page);
722
723
725
726 gnc_tree_view_owner_restore(GNC_TREE_VIEW_OWNER(priv->tree_view),
727 &priv->fd, key_file, group_name, owner_type);
729 return page;
730}
731
732
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
767
775static gboolean
776gnc_plugin_page_owner_tree_button_press_cb (GtkWidget *widget,
777 GdkEventButton *event,
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);
785
786
787
788
789
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;
809 gboolean sensitive;
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);
823 sensitive = (owner != NULL);
824 }
825
828 sensitive);
830 sensitive && is_readwrite);
831 g_signal_emit (page, plugin_page_signals[OWNER_SELECTED], 0, owner);
832}
833
834
835
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
873 func = scm_c_eval_string (report_name);
874 g_return_val_if_fail (scm_is_procedure (func), -1);
875
876
877 arg = SCM_BOOL_T;
878 args = scm_cons (arg, args);
879 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
880
881
882 arg = scm_from_utf8_string (report_title);
883 args = scm_cons (arg, args);
884
885
886
887
888
889 arg = SCM_BOOL_F;
890 args = scm_cons (arg, args);
891 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
892
893
894
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
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);
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
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
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);
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
977
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
1007 gnc_ui_owner_edit (parent, owner);
1008
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
1026
1027 gnc_invoice_search (parent, NULL, owner, gnc_get_current_book ());
1028
1030}
1031
1032
1033#if 0
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
1051
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
1063 owner_name = g_strdup (gncOwnerGetName(owner));
1064 if (!owner_name)
1065 {
1066 owner_name = g_strdup (
_(
"(no name)"));
1067 }
1068
1069
1070
1071
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
1093
1094 gnc_set_busy_cursor(NULL, TRUE);
1095 gnc_suspend_gui_refresh ();
1097 gncOwnerDestroy (owner);
1098 gnc_resume_gui_refresh ();
1099 gnc_unset_busy_cursor(NULL);
1100 }
1101 }
1102 g_free(owner_name);
1103}
1104#endif
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));
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
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);
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(¤t_owner, NULL);
1174 break;
1175 case GNC_OWNER_CUSTOMER :
1176 {
1177 gncOwnerInitCustomer(¤t_owner,
1179 break;
1180 }
1181 case GNC_OWNER_JOB :
1182 {
1183 gncOwnerInitJob(¤t_owner,
1185 break;
1186 }
1187 case GNC_OWNER_VENDOR :
1188 {
1189 gncOwnerInitVendor(¤t_owner,
1191 break;
1192 }
1193 case GNC_OWNER_EMPLOYEE :
1194 {
1195 gncOwnerInitEmployee(¤t_owner,
1197 break;
1198 }
1199 }
1200
1203 gnc_ui_invoice_new (parent, ¤t_owner, gnc_get_current_book ());
1204
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
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);
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
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
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
1277}
gboolean qof_book_is_readonly(const QofBook *book)
Return whether the book is read only.
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.
#define PWARN(format, args...)
Log a warning.
#define ENTER(format, args...)
Print a function entry debugging message.
GncCustomer * gncOwnerGetCustomer(const GncOwner *owner)
If the given owner is of type GNC_OWNER_CUSTOMER, returns the pointer to the customer object.
void gncOwnerBeginEdit(GncOwner *owner)
These are convenience wrappers around gnc{Vendor,Customer,Job,Employee}* functions.
GncEmployee * gncOwnerGetEmployee(const GncOwner *owner)
If the given owner is of type GNC_OWNER_EMPLOYEE, returns the pointer to the employee object.
GncJob * gncOwnerGetJob(const GncOwner *owner)
If the given owner is of type GNC_OWNER_JOB, returns the pointer to the job object.
GncVendor * gncOwnerGetVendor(const GncOwner *owner)
If the given owner is of type GNC_OWNER_VENDOR, returns the pointer to the vendor object.
gpointer gncOwnerGetUndefined(const GncOwner *owner)
If the given owner is of type GNC_OWNER_UNDEFINED, returns the undefined pointer, which is usually NU...
GncOwnerType gncOwnerGetType(const GncOwner *owner)
Returns the GncOwnerType of this owner.
QofIdTypeConst gncOwnerTypeToQofIdType(GncOwnerType t)
Returns the QofIdType of the given GncOwnerType, or NULL if no suitable one exists.
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.