37 #include <glib/gi18n.h> 38 #include "swig-runtime.h" 44 #include "dialog-vendor.h" 45 #include "dialog-customer.h" 46 #include "dialog-employee.h" 47 #include "dialog-invoice.h" 48 #include "dialog-job.h" 49 #include "dialog-payment.h" 52 #include "dialog-utils.h" 53 #include "gnc-component-manager.h" 57 #include "gnc-icons.h" 58 #include "gnc-session.h" 63 #include "guile-mappings.h" 64 #include "dialog-lot-viewer.h" 68 static QofLogModule log_module = GNC_MOD_GUI;
70 #define PLUGIN_PAGE_ACCT_TREE_CM_CLASS "plugin-page-owner-tree" 72 #define DELETE_DIALOG_FILTER "filter" 73 #define DELETE_DIALOG_OWNER "owner" 84 GtkTreeView *tree_view;
86 GncOwnerType owner_type;
92 #define GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(o) \ 93 ((GncPluginPageOwnerTreePrivate*)gnc_plugin_page_owner_tree_get_instance_private((GncPluginPageOwnerTree*)o)) 99 static void gnc_plugin_page_owner_tree_finalize (GObject *
object);
100 static void gnc_plugin_page_owner_tree_selected (GObject *
object, gpointer user_data);
102 static GtkWidget *gnc_plugin_page_owner_tree_create_widget (
GncPluginPage *plugin_page);
103 static void gnc_plugin_page_owner_tree_destroy_widget (
GncPluginPage *plugin_page);
104 static void gnc_plugin_page_owner_tree_save_page (
GncPluginPage *plugin_page, GKeyFile *file,
const gchar *group);
105 static GncPluginPage *gnc_plugin_page_owner_tree_recreate_page (GtkWidget *window, GKeyFile *file,
const gchar *group);
106 static void set_menu_and_toolbar_qualifier (
GncPluginPage *plugin_page);
109 static gboolean gnc_plugin_page_owner_tree_button_press_cb (GtkWidget *widget,
110 GdkEventButton *event,
112 static void gnc_plugin_page_owner_tree_double_click_cb (GtkTreeView *treeview,
114 GtkTreeViewColumn *col,
117 static void gnc_plugin_page_owner_tree_selection_changed_cb (GtkTreeSelection *selection,
121 static void gnc_plugin_page_owner_tree_cmd_new_owner (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
122 static void gnc_plugin_page_owner_tree_cmd_edit_owner (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
124 static void gnc_plugin_page_owner_tree_cmd_delete_owner (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
126 static void gnc_plugin_page_owner_tree_cmd_view_filter_by (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
127 static void gnc_plugin_page_owner_tree_cmd_refresh (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
128 static void gnc_plugin_page_owner_tree_cmd_new_invoice (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
129 static void gnc_plugin_page_owner_tree_cmd_owners_report (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
130 static void gnc_plugin_page_owner_tree_cmd_owner_report (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
131 static void gnc_plugin_page_owner_tree_cmd_process_payment (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
132 static void gnc_plugin_page_owner_tree_cmd_edit_tax (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
133 static void gnc_plugin_page_owner_tree_cmd_search_invoices (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
135 static guint plugin_page_signals[LAST_SIGNAL] = { 0 };
138 static GActionEntry gnc_plugin_page_owner_tree_actions [] =
140 {
"OTEditVendorAction", gnc_plugin_page_owner_tree_cmd_edit_owner, NULL, NULL, NULL },
141 {
"OTEditCustomerAction", gnc_plugin_page_owner_tree_cmd_edit_owner, NULL, NULL, NULL },
142 {
"OTEditEmployeeAction", gnc_plugin_page_owner_tree_cmd_edit_owner, NULL, NULL, NULL },
143 {
"OTNewVendorAction", gnc_plugin_page_owner_tree_cmd_new_owner, NULL, NULL, NULL },
144 {
"OTNewCustomerAction", gnc_plugin_page_owner_tree_cmd_new_owner, NULL, NULL, NULL },
145 {
"OTNewEmployeeAction", gnc_plugin_page_owner_tree_cmd_new_owner, NULL, NULL, NULL },
148 {
"EditDeleteOwnerAction", gnc_plugin_page_owner_tree_cmd_delete_owner, NULL, NULL, NULL },
151 {
"ViewFilterByAction", gnc_plugin_page_owner_tree_cmd_view_filter_by, NULL, NULL, NULL },
152 {
"ViewRefreshAction", gnc_plugin_page_owner_tree_cmd_refresh, NULL, NULL, NULL },
153 {
"EditTaxOptionsAction", gnc_plugin_page_owner_tree_cmd_edit_tax, NULL, NULL, NULL },
154 {
"OTNewBillAction", gnc_plugin_page_owner_tree_cmd_new_invoice, NULL, NULL, NULL },
155 {
"OTNewInvoiceAction", gnc_plugin_page_owner_tree_cmd_new_invoice, NULL, NULL, NULL },
156 {
"OTNewVoucherAction", gnc_plugin_page_owner_tree_cmd_new_invoice, NULL, NULL, NULL },
157 {
"OTVendorListingReportAction", gnc_plugin_page_owner_tree_cmd_owners_report, NULL, NULL, NULL },
158 {
"OTCustomerListingReportAction", gnc_plugin_page_owner_tree_cmd_owners_report, NULL, NULL, NULL },
159 {
"OTVendorReportAction", gnc_plugin_page_owner_tree_cmd_owner_report, NULL, NULL, NULL },
160 {
"OTCustomerReportAction", gnc_plugin_page_owner_tree_cmd_owner_report, NULL, NULL, NULL },
161 {
"OTEmployeeReportAction", gnc_plugin_page_owner_tree_cmd_owner_report, NULL, NULL, NULL },
162 {
"OTProcessPaymentAction", gnc_plugin_page_owner_tree_cmd_process_payment, NULL, NULL, NULL },
163 {
"OTSearchInvoicesAction", gnc_plugin_page_owner_tree_cmd_search_invoices, NULL, NULL, NULL },
166 static guint gnc_plugin_page_owner_tree_n_actions = G_N_ELEMENTS(gnc_plugin_page_owner_tree_actions);
169 static const gchar *gnc_plugin_load_ui_items [] =
177 "ReportsPlaceholder1",
183 static const gchar *actions_requiring_owner_rw[] =
185 "OTEditVendorAction",
186 "OTEditCustomerAction",
187 "OTEditEmployeeAction",
188 "OTProcessPaymentAction",
195 static const gchar *actions_requiring_owner_always[] =
197 "OTVendorReportAction",
198 "OTCustomerReportAction",
199 "OTEmployeeReportAction",
200 "OTProcessPaymentAction",
205 static const gchar* readonly_inactive_actions[] =
208 "OTNewCustomerAction",
209 "OTNewEmployeeAction",
211 "OTNewInvoiceAction",
212 "OTNewVoucherAction",
213 "OTProcessPaymentAction",
221 {
"OTEditVendorAction", N_(
"Edit") },
222 {
"OTEditCustomerAction", N_(
"Edit") },
223 {
"OTEditEmployeeAction", N_(
"Edit") },
224 {
"OTNewVendorAction", N_(
"New") },
225 {
"OTNewCustomerAction", N_(
"New") },
226 {
"OTNewEmployeeAction", N_(
"New") },
227 {
"OTNewBillAction", N_(
"New Bill") },
228 {
"OTNewInvoiceAction", N_(
"New Invoice") },
229 {
"OTNewVoucherAction", N_(
"New Voucher") },
230 {
"OTVendorListingReportAction", N_(
"Vendor Listing") },
231 {
"OTCustomerListingReportAction", N_(
"Customer Listing") },
232 {
"OTProcessPaymentAction", N_(
"Process Payment") },
255 g_return_val_if_fail( (owner_type != GNC_OWNER_UNDEFINED)
256 && (owner_type != GNC_OWNER_NONE), NULL);
261 for ( ; item; item = g_list_next(item))
264 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
265 if (priv->owner_type == owner_type)
268 return GNC_PLUGIN_PAGE(plugin_page);
272 plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(g_object_new(GNC_TYPE_PLUGIN_PAGE_OWNER_TREE,
nullptr));
274 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
275 priv->owner_type = owner_type;
278 return GNC_PLUGIN_PAGE(plugin_page);
286 gnc_plugin_page_owner_focus_widget (
GncPluginPage *owner_plugin_page)
288 if (GNC_IS_PLUGIN_PAGE_OWNER_TREE(owner_plugin_page))
291 GtkTreeView *tree_view = priv->tree_view;
295 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
298 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
301 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
303 set_menu_and_toolbar_qualifier (owner_plugin_page);
307 gnc_plugin_load_ui_items);
312 if (GTK_IS_TREE_VIEW(tree_view))
314 if (!gtk_widget_is_focus (GTK_WIDGET(tree_view)))
315 gtk_widget_grab_focus (GTK_WIDGET(tree_view));
324 GObjectClass *object_class = G_OBJECT_CLASS (klass);
327 object_class->finalize = gnc_plugin_page_owner_tree_finalize;
329 gnc_plugin_class->
tab_icon = GNC_ICON_ACCOUNT;
330 gnc_plugin_class->
plugin_name = GNC_PLUGIN_PAGE_OWNER_TREE_NAME;
331 gnc_plugin_class->
create_widget = gnc_plugin_page_owner_tree_create_widget;
332 gnc_plugin_class->
destroy_widget = gnc_plugin_page_owner_tree_destroy_widget;
333 gnc_plugin_class->
save_page = gnc_plugin_page_owner_tree_save_page;
334 gnc_plugin_class->
recreate_page = gnc_plugin_page_owner_tree_recreate_page;
337 plugin_page_signals[OWNER_SELECTED] =
338 g_signal_new (
"owner_selected",
339 G_OBJECT_CLASS_TYPE (object_class),
343 g_cclosure_marshal_VOID__POINTER,
351 GSimpleActionGroup *simple_action_group;
355 ENTER(
"page %p", plugin_page);
356 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
359 parent = GNC_PLUGIN_PAGE(plugin_page);
360 g_object_set(G_OBJECT(plugin_page),
361 "page-name", _(
"Owners"),
362 "ui-description",
"gnc-plugin-page-owner-tree.ui",
364 g_signal_connect (G_OBJECT (plugin_page),
"selected",
365 G_CALLBACK (gnc_plugin_page_owner_tree_selected), plugin_page);
372 g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group),
373 gnc_plugin_page_owner_tree_actions,
374 gnc_plugin_page_owner_tree_n_actions,
378 priv->fd.show_inactive = TRUE;
379 priv->fd.show_zero_total = TRUE;
381 LEAVE(
"page %p, priv %p, action group %p",
382 plugin_page, priv, simple_action_group);
386 gnc_plugin_page_owner_tree_finalize (GObject *
object)
391 ENTER(
"object %p",
object);
392 page = GNC_PLUGIN_PAGE_OWNER_TREE (
object);
393 g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE (page));
394 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
395 g_return_if_fail (priv != NULL);
397 G_OBJECT_CLASS (gnc_plugin_page_owner_tree_parent_class)->finalize (
object);
404 GSimpleActionGroup *simple_action_group;
408 g_return_if_fail(plugin_page);
409 g_return_if_fail(GNC_IS_PLUGIN_PAGE(plugin_page));
413 g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group));
426 g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE(page));
428 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
430 if (priv->owner_type == GNC_OWNER_CUSTOMER)
432 else if (priv->owner_type == GNC_OWNER_VENDOR)
434 else if (priv->owner_type == GNC_OWNER_EMPLOYEE)
441 gnc_plugin_page_owner_tree_selected (GObject *
object, gpointer user_data)
444 g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
445 update_inactive_actions(page);
455 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
456 ENTER(
"page %p (tree view %p)", page, priv->tree_view);
464 LEAVE(
"owner %p", owner);
472 gnc_plugin_page_owner_refresh_cb (GHashTable *changes, gpointer user_data)
474 auto page = GNC_PLUGIN_PAGE_OWNER_TREE(user_data);
477 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(page));
483 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
484 gtk_widget_queue_draw(priv->widget);
488 gnc_plugin_page_owner_tree_close_cb (gpointer user_data)
492 plugin_page = GNC_PLUGIN_PAGE(user_data);
497 gnc_plugin_page_owner_tree_create_widget (
GncPluginPage *plugin_page)
501 GtkTreeSelection *selection;
502 GtkTreeView *tree_view;
503 GtkWidget *scrolled_window;
504 GtkTreeViewColumn *col;
505 const gchar *state_section = NULL;
506 const gchar* label =
"";
507 const gchar *style_label = NULL;
509 ENTER(
"page %p", plugin_page);
510 page = GNC_PLUGIN_PAGE_OWNER_TREE (plugin_page);
511 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
512 if (priv->widget != NULL)
514 LEAVE(
"widget = %p", priv->widget);
518 priv->widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
519 gtk_box_set_homogeneous (GTK_BOX (priv->widget), FALSE);
520 gtk_widget_show (priv->widget);
523 gtk_widget_set_name (GTK_WIDGET(priv->widget),
"gnc-id-owner-page");
525 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
526 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
527 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
528 gtk_widget_show (scrolled_window);
529 gtk_box_pack_start (GTK_BOX (priv->widget), scrolled_window,
536 GNC_TREE_VIEW(tree_view), GNC_OWNER_TREE_ID_COL);
537 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
539 GNC_TREE_VIEW(tree_view), GNC_OWNER_TREE_ADDRESS_1_COL);
540 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
542 GNC_TREE_VIEW(tree_view), GNC_OWNER_TREE_ADDRESS_2_COL);
543 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
545 GNC_TREE_VIEW(tree_view), GNC_OWNER_TREE_PHONE_COL);
546 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
549 switch (priv->owner_type)
551 case GNC_OWNER_NONE :
552 case GNC_OWNER_UNDEFINED :
553 PWARN(
"missing owner_type");
554 label = _(
"Unknown");
555 style_label =
"gnc-class-unknown";
557 case GNC_OWNER_CUSTOMER :
558 label = _(
"Customers");
559 state_section =
"Customers Overview";
560 style_label =
"gnc-class-customers";
564 state_section =
"Jobs Overview";
565 style_label =
"gnc-class-jobs";
567 case GNC_OWNER_VENDOR :
568 label = _(
"Vendors");
569 state_section =
"Vendors Overview";
570 style_label =
"gnc-class-vendors";
572 case GNC_OWNER_EMPLOYEE :
573 label = _(
"Employees");
574 state_section =
"Employees Overview";
575 style_label =
"gnc-class-employees";
580 gnc_widget_style_context_add_class (GTK_WIDGET(priv->widget), style_label);
582 g_object_set(G_OBJECT(tree_view),
"state-section", state_section,
583 "show-column-menu", TRUE,
586 g_object_set(G_OBJECT(plugin_page),
"page-name", label, NULL);
588 priv->tree_view = tree_view;
589 selection = gtk_tree_view_get_selection(tree_view);
590 g_signal_connect (G_OBJECT (selection),
"changed",
591 G_CALLBACK (gnc_plugin_page_owner_tree_selection_changed_cb), page);
592 g_signal_connect (G_OBJECT (tree_view),
"button-press-event",
593 G_CALLBACK (gnc_plugin_page_owner_tree_button_press_cb), page);
594 g_signal_connect (G_OBJECT (tree_view),
"row-activated",
595 G_CALLBACK (gnc_plugin_page_owner_tree_double_click_cb), page);
597 gtk_tree_view_set_headers_visible(tree_view, TRUE);
598 gnc_plugin_page_owner_tree_selection_changed_cb (NULL, page);
599 gtk_widget_show (GTK_WIDGET (tree_view));
600 gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET(tree_view));
602 priv->fd.tree_view = GNC_TREE_VIEW_OWNER(priv->tree_view);
604 GNC_TREE_VIEW_OWNER(tree_view),
608 gnc_register_gui_component(PLUGIN_PAGE_ACCT_TREE_CM_CLASS,
609 gnc_plugin_page_owner_refresh_cb,
610 gnc_plugin_page_owner_tree_close_cb,
612 gnc_gui_component_set_session (priv->component_id,
613 gnc_get_current_session());
615 g_signal_connect (G_OBJECT(plugin_page),
"inserted",
619 set_menu_and_toolbar_qualifier (plugin_page);
621 LEAVE(
"widget = %p", priv->widget);
626 gnc_plugin_page_owner_tree_destroy_widget (
GncPluginPage *plugin_page)
631 ENTER(
"page %p", plugin_page);
632 page = GNC_PLUGIN_PAGE_OWNER_TREE (plugin_page);
633 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
639 g_idle_remove_by_data (plugin_page);
643 g_object_unref(G_OBJECT(priv->widget));
647 if (priv->component_id)
649 gnc_unregister_gui_component(priv->component_id);
650 priv->component_id = 0;
653 LEAVE(
"widget destroyed");
656 #define OWNER_TYPE_LABEL "OwnerType" 668 gnc_plugin_page_owner_tree_save_page (
GncPluginPage *plugin_page,
670 const gchar *group_name)
675 g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
676 g_return_if_fail (key_file != NULL);
677 g_return_if_fail (group_name != NULL);
679 ENTER(
"page %p, key_file %p, group_name %s", plugin_page, key_file,
682 owner_page = GNC_PLUGIN_PAGE_OWNER_TREE(plugin_page);
683 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(owner_page);
685 g_key_file_set_integer(key_file, group_name, OWNER_TYPE_LABEL,
688 gnc_tree_view_owner_save(GNC_TREE_VIEW_OWNER(priv->tree_view),
689 &priv->fd, key_file, group_name);
705 gnc_plugin_page_owner_tree_recreate_page (GtkWidget *window,
707 const gchar *group_name)
712 GncOwnerType owner_type;
714 g_return_val_if_fail(key_file, NULL);
715 g_return_val_if_fail(group_name, NULL);
716 ENTER(
"key_file %p, group_name %s", key_file, group_name);
719 owner_type =
static_cast<GncOwnerType
>(g_key_file_get_integer(key_file, group_name, OWNER_TYPE_LABEL, NULL));
721 owner_page = GNC_PLUGIN_PAGE_OWNER_TREE(page);
722 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(owner_page);
727 gnc_tree_view_owner_restore(GNC_TREE_VIEW_OWNER(priv->tree_view),
728 &priv->fd, key_file, group_name, owner_type);
734 static void gnc_ui_owner_edit (GtkWindow *parent,
GncOwner *owner)
736 if (NULL == owner)
return;
740 case GNC_OWNER_NONE :
741 case GNC_OWNER_UNDEFINED :
743 case GNC_OWNER_CUSTOMER :
745 gnc_ui_customer_edit (parent, owner->owner.customer);
750 gnc_ui_job_edit (parent, owner->owner.job);
753 case GNC_OWNER_VENDOR :
755 gnc_ui_vendor_edit (parent, owner->owner.vendor);
758 case GNC_OWNER_EMPLOYEE :
760 gnc_ui_employee_edit (parent, owner->owner.employee);
777 gnc_plugin_page_owner_tree_button_press_cb (GtkWidget *widget,
778 GdkEventButton *event,
781 g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), FALSE);
783 ENTER(
"widget %p, event %p, page %p", widget, event, page);
795 gnc_plugin_page_owner_tree_double_click_cb (GtkTreeView *treeview,
797 GtkTreeViewColumn *col,
800 gnc_plugin_page_owner_tree_cmd_owner_report (NULL, NULL, (gpointer*)page);
804 gnc_plugin_page_owner_tree_selection_changed_cb (GtkTreeSelection *selection,
807 GSimpleActionGroup *simple_action_group;
813 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(page));
821 g_return_if_fail(GTK_IS_TREE_SELECTION(selection));
822 view = gtk_tree_selection_get_tree_view (selection);
824 sensitive = (owner != NULL);
831 sensitive && is_readwrite);
832 g_signal_emit (page, plugin_page_signals[OWNER_SELECTED], 0, owner);
840 build_aging_report (GncOwnerType owner_type)
842 const gchar *report_name = NULL;
843 const gchar *report_title = NULL;
852 case GNC_OWNER_NONE :
853 case GNC_OWNER_UNDEFINED :
854 case GNC_OWNER_EMPLOYEE :
859 case GNC_OWNER_VENDOR :
861 report_name =
"gnc:payables-report-create";
862 report_title = _(
"Vendor Listing");
865 case GNC_OWNER_CUSTOMER :
867 report_name =
"gnc:receivables-report-create";
868 report_title = _(
"Customer Listing");
874 func = scm_c_eval_string (report_name);
875 g_return_val_if_fail (scm_is_procedure (func), -1);
879 args = scm_cons (arg, args);
880 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
883 arg = scm_from_utf8_string (report_title);
884 args = scm_cons (arg, args);
891 args = scm_cons (arg, args);
892 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
896 arg = scm_apply (func, args, SCM_EOL);
897 g_return_val_if_fail (scm_is_exact (arg), -1);
899 return scm_to_int (arg);
908 g_return_val_if_fail (owner, -1);
912 func = scm_c_eval_string (
"gnc:owner-report-create-with-enddate");
913 g_return_val_if_fail (scm_is_procedure (func), -1);
915 args = scm_cons (SCM_BOOL_F, args);
919 swig_type_info * qtype = SWIG_TypeQuery(
"_p_Account");
920 g_return_val_if_fail (qtype, -1);
922 arg = SWIG_NewPointerObj(acc, qtype, 0);
923 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
924 args = scm_cons (arg, args);
928 args = scm_cons (SCM_BOOL_F, args);
931 swig_type_info * qtype = SWIG_TypeQuery(
"_p__gncOwner");
932 g_return_val_if_fail (qtype, -1);
934 arg = SWIG_NewPointerObj(owner, qtype, 0);
936 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
937 args = scm_cons (arg, args);
940 arg = scm_apply (func, args, SCM_EOL);
941 g_return_val_if_fail (scm_is_exact (arg), -1);
942 return scm_to_int (arg);
951 gnc_plugin_page_owner_tree_cmd_new_owner (GSimpleAction *simple,
956 auto page = GNC_PLUGIN_PAGE_OWNER_TREE (user_data);
960 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(page));
962 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE (page);
965 switch (priv->owner_type)
967 case GNC_OWNER_NONE :
968 case GNC_OWNER_UNDEFINED :
970 case GNC_OWNER_CUSTOMER :
972 gnc_ui_customer_new (parent, gnc_get_current_book ());
981 case GNC_OWNER_VENDOR :
983 gnc_ui_vendor_new (parent, gnc_get_current_book ());
986 case GNC_OWNER_EMPLOYEE :
988 gnc_ui_employee_new (parent, gnc_get_current_book ());
995 gnc_plugin_page_owner_tree_cmd_edit_owner (GSimpleAction *simple,
1000 auto page = GNC_PLUGIN_PAGE_OWNER_TREE (user_data);
1003 if (NULL == owner)
return;
1005 ENTER(
"action %p, page %p", simple, page);
1008 gnc_ui_owner_edit (parent, owner);
1014 gnc_plugin_page_owner_tree_cmd_search_invoices (GSimpleAction *simple,
1015 GVariant *parameter,
1019 auto page = GNC_PLUGIN_PAGE_OWNER_TREE (user_data);
1022 if (NULL == owner)
return;
1024 ENTER(
"action %p, page %p", simple, page);
1028 gnc_invoice_search (parent, NULL, owner, gnc_get_current_book ());
1036 gnc_plugin_page_owner_tree_cmd_delete_owner (GSimpleAction *simple,
1037 GVariant *parameter,
1041 auto page = GNC_PLUGIN_PAGE_OWNER_TREE (user_data);
1045 GtkWidget *dialog = NULL;
1049 if (NULL == owner)
return;
1056 #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" 1058 gnc_ui_object_references_show( _(EXPLANATION), list);
1064 owner_name = g_strdup (gncOwnerGetName(owner));
1067 owner_name = g_strdup (_(
"(no name)"));
1075 char *message = g_strdup_printf(_(
"The owner %s will be deleted.\nAre you sure you want to do this?"), owner_name);
1077 dialog = gtk_message_dialog_new(GTK_WINDOW(window),
1078 GTK_DIALOG_DESTROY_WITH_PARENT,
1079 GTK_MESSAGE_QUESTION,
1083 gtk_dialog_add_buttons(GTK_DIALOG(dialog),
1084 _(
"_Cancel"), GTK_RESPONSE_CANCEL,
1085 _(
"_Delete"), GTK_RESPONSE_ACCEPT,
1087 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
1088 response = gtk_dialog_run(GTK_DIALOG(dialog));
1089 gtk_widget_destroy(dialog);
1091 if (GTK_RESPONSE_ACCEPT == response)
1095 gnc_set_busy_cursor(NULL, TRUE);
1096 gnc_suspend_gui_refresh ();
1098 gncOwnerDestroy (owner);
1099 gnc_resume_gui_refresh ();
1100 gnc_unset_busy_cursor(NULL);
1110 gnc_plugin_page_owner_tree_cmd_view_filter_by (GSimpleAction *simple,
1111 GVariant *parameter,
1115 auto plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(user_data);
1118 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1119 ENTER(
"(action %p, page %p)", simple, plugin_page);
1121 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
1122 owner_filter_dialog_create(&priv->fd, GNC_PLUGIN_PAGE(plugin_page));
1127 gnc_plugin_page_owner_tree_cmd_refresh (GSimpleAction *simple,
1128 GVariant *parameter,
1132 auto plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(user_data);
1135 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1137 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
1138 gtk_widget_queue_draw (priv->widget);
1142 gnc_plugin_page_owner_tree_cmd_edit_tax (GSimpleAction *simple,
1143 GVariant *parameter,
1146 auto plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(user_data);
1149 g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1153 gnc_tax_info_dialog (parent, NULL);
1157 gnc_plugin_page_owner_tree_cmd_new_invoice (GSimpleAction *simple,
1158 GVariant *parameter,
1162 auto plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(user_data);
1167 ENTER(
"action %p, plugin_page %p", simple, plugin_page);
1169 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
1170 switch (priv->owner_type)
1172 case GNC_OWNER_NONE :
1173 case GNC_OWNER_UNDEFINED :
1174 gncOwnerInitUndefined(¤t_owner, NULL);
1176 case GNC_OWNER_CUSTOMER :
1178 gncOwnerInitCustomer(¤t_owner,
1182 case GNC_OWNER_JOB :
1184 gncOwnerInitJob(¤t_owner,
1188 case GNC_OWNER_VENDOR :
1190 gncOwnerInitVendor(¤t_owner,
1194 case GNC_OWNER_EMPLOYEE :
1196 gncOwnerInitEmployee(¤t_owner,
1204 gnc_ui_invoice_new (parent, ¤t_owner, gnc_get_current_book ());
1210 gnc_plugin_page_owner_tree_cmd_owners_report (GSimpleAction *simple,
1211 GVariant *parameter,
1215 auto plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(user_data);
1219 ENTER(
"(action %p, plugin_page %p)", simple, plugin_page);
1221 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1223 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
1224 id = build_aging_report (priv->owner_type);
1227 GncMainWindow *window;
1228 window = GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window);
1229 gnc_main_window_open_report(
id, window);
1236 gnc_plugin_page_owner_tree_cmd_owner_report (GSimpleAction *simple,
1237 GVariant *parameter,
1241 auto plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(user_data);
1245 ENTER(
"(action %p, plugin_page %p)", simple, plugin_page);
1247 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1250 id = build_owner_report (current_owner, NULL);
1253 GncMainWindow *window;
1254 window = GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window);
1255 gnc_main_window_open_report(
id, window);
1263 gnc_plugin_page_owner_tree_cmd_process_payment (GSimpleAction *simple,
1264 GVariant *parameter,
1268 auto plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(user_data);
1269 ENTER(
"(action %p, plugin_page %p)", simple, plugin_page);
1271 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1273 gnc_ui_payment_new (GTK_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window),
1275 gnc_get_current_book ());
GtkWidget * gnc_plugin_page_get_window(GncPluginPage *page)
Retrieve a pointer to the GncMainWindow (GtkWindow) containing this page.
const gchar * tab_icon
The relative name of the icon that should be shown on the tab for this page.
void gnc_plugin_page_set_menu_qualifier(GncPluginPage *page, const char *menu_qualifier)
Set a qualifier string for this page.
GtkTreeView * gnc_tree_view_owner_new(GncOwnerType owner_type)
Create a new owner tree view for one type of owners.
gboolean(* focus_page_function)(GncPluginPage *plugin_page)
This function performs specific actions to set the focus on a specific widget.
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...
Business Interface: Object OWNERs.
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.
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.
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 implementation for gnucash owner tree.
utility functions for the GnuCash UI
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...
void gnc_main_window_init_short_names(GncMainWindow *window, GncToolBarShortNames *toolbar_labels)
Update the labels of the toolbar items with short names.
Functions that are supported by all types of windows.
GSimpleActionGroup * gnc_plugin_page_get_action_group(GncPluginPage *page)
Retrieve the GSimpleActionGroup object associated with this page.
GtkWidget * window
The window that contains the display widget for this plugin.
GncOwnerType owner_type
The owner type to show this action for.
GSimpleActionGroup * gnc_plugin_page_create_action_group(GncPluginPage *page, const gchar *group_name)
Create the GSimpleActionGroup object associated with this page.
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.
#define ENTER(format, args...)
Print a function entry debugging message.
This file contains the functions to present a dialog box with a list of object references and an expl...
void gncOwnerBeginEdit(GncOwner *owner)
These are convenience wrappers around gnc{Vendor,Customer,Job,Employee}* functions.
void gnc_main_window_open_page(GncMainWindow *window, GncPluginPage *page)
Display a data plugin page in a window.
void(* destroy_widget)(GncPluginPage *plugin_page)
Function called to destroy the display widget for a particular type of plugin.
#define PWARN(format, args...)
Log a warning.
The class data structure for a content plugin.
Functions providing a page which lists owners of one type.
GAction * gnc_main_window_find_action(GncMainWindow *window, const gchar *action_name)
Find the GAction in the main window.
void gnc_plugin_page_disconnect_page_changed(GncPluginPage *page)
Disconnect the page_changed_id signal callback.
const char * action_name
The name of the action.
void gnc_tree_view_configure_columns(GncTreeView *view)
Make all the correct columns visible, respecting their default visibility setting, their "always" visibility setting, and the last saved state if available.
const gchar * plugin_name
The textual name of this plugin.
GtkWidget *(* create_widget)(GncPluginPage *plugin_page)
Function called to create the display widget for a particular type of plugin.
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). ...
QofIdTypeConst gncOwnerTypeToQofIdType(GncOwnerType t)
Returns the QofIdType of the given GncOwnerType, or NULL if no suitable one exists.
gpointer gncOwnerGetUndefined(const GncOwner *owner)
If the given owner is of type GNC_OWNER_UNDEFINED, returns the undefined pointer, which is usually NU...
Gnome specific utility functions.
All type declarations for the whole Gnucash engine.
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...
GList * qof_instance_get_referring_object_list(const QofInstance *inst)
Returns a list of objects which refer to a specific object.
GncOwnerType gncOwnerGetType(const GncOwner *owner)
Returns the GncOwnerType of this owner.
GncJob * gncOwnerGetJob(const GncOwner *owner)
If the given owner is of type GNC_OWNER_JOB, returns the pointer to the job object.
gboolean qof_book_is_readonly(const QofBook *book)
Return whether the book is read only.
void gnc_plugin_page_inserted_cb(GncPluginPage *page, gpointer user_data)
Set up the page_changed callback for when the current page is changed.
void gnc_main_window_close_page(GncPluginPage *page)
Remove a data plugin page from a window and display the previous page.
Functions for adding plugins to a GnuCash window.
#define LEAVE(format, args...)
Print a function exit debugging message.
GncVendor * gncOwnerGetVendor(const GncOwner *owner)
If the given owner is of type GNC_OWNER_VENDOR, returns the pointer to the vendor object...
GncCustomer * gncOwnerGetCustomer(const GncOwner *owner)
If the given owner is of type GNC_OWNER_CUSTOMER, returns the pointer to the customer object...
void gnc_plugin_page_add_book(GncPluginPage *page, QofBook *book)
Add a book reference to the specified page.
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...
GncEmployee * gncOwnerGetEmployee(const GncOwner *owner)
If the given owner is of type GNC_OWNER_EMPLOYEE, returns the pointer to the employee object...
GncPluginPage * gnc_plugin_page_owner_tree_new(GncOwnerType owner_type)
Create a new "owner tree" plugin page.