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"
51 #include "dialog-utils.h"
52 #include "gnc-component-manager.h"
56 #include "gnc-icons.h"
57 #include "gnc-session.h"
61 #include "guile-mappings.h"
62 #include "dialog-lot-viewer.h"
68 #define PLUGIN_PAGE_ACCT_TREE_CM_CLASS "plugin-page-owner-tree"
70 #define DELETE_DIALOG_FILTER "filter"
71 #define DELETE_DIALOG_OWNER "owner"
82 GtkTreeView *tree_view;
84 GncOwnerType owner_type;
88 #define GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(o) \
89 (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN_PAGE_OWNER_TREE, GncPluginPageOwnerTreePrivate))
91 static GObjectClass *parent_class = NULL;
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);
108 static gboolean gnc_plugin_page_owner_tree_button_press_cb (GtkWidget *widget,
109 GdkEventButton *event,
111 static void gnc_plugin_page_owner_tree_double_click_cb (GtkTreeView *treeview,
113 GtkTreeViewColumn *col,
116 static void gnc_plugin_page_owner_tree_selection_changed_cb (GtkTreeSelection *selection,
123 static void gnc_plugin_page_owner_tree_cmd_delete_owner (GtkAction *action,
GncPluginPageOwnerTree *page);
125 static void gnc_plugin_page_owner_tree_cmd_view_filter_by (GtkAction *action,
GncPluginPageOwnerTree *page);
127 static void gnc_plugin_page_owner_tree_cmd_owners_report (GtkAction *action,
GncPluginPageOwnerTree *plugin_page);
128 static void gnc_plugin_page_owner_tree_cmd_owner_report (GtkAction *action,
GncPluginPageOwnerTree *plugin_page);
131 static guint plugin_page_signals[LAST_SIGNAL] = { 0 };
134 static GtkActionEntry gnc_plugin_page_owner_tree_actions [] =
137 {
"FakeToplevel", NULL,
"", NULL, NULL, NULL },
141 "OTEditVendorAction", GNC_STOCK_EDIT_ACCOUNT, N_(
"E_dit Vendor"),
"<control>e",
142 N_(
"Edit the selected vendor"),
143 G_CALLBACK (gnc_plugin_page_owner_tree_cmd_edit_owner)
146 "OTEditCustomerAction", GNC_STOCK_EDIT_ACCOUNT, N_(
"E_dit Customer"),
"<control>e",
147 N_(
"Edit the selected customer"),
148 G_CALLBACK (gnc_plugin_page_owner_tree_cmd_edit_owner)
151 "OTEditEmployeeAction", GNC_STOCK_EDIT_ACCOUNT, N_(
"E_dit Employee"),
"<control>e",
152 N_(
"Edit the selected employee"),
153 G_CALLBACK (gnc_plugin_page_owner_tree_cmd_edit_owner)
156 "OTNewVendorAction", GNC_STOCK_NEW_ACCOUNT, N_(
"_New Vendor..."), NULL,
157 N_(
"Create a new vendor"),
158 G_CALLBACK (gnc_plugin_page_owner_tree_cmd_new_owner)
161 "OTNewCustomerAction", GNC_STOCK_NEW_ACCOUNT, N_(
"_New Customer..."), NULL,
162 N_(
"Create a new customer"),
163 G_CALLBACK (gnc_plugin_page_owner_tree_cmd_new_owner)
166 "OTNewEmployeeAction", GNC_STOCK_NEW_ACCOUNT, N_(
"_New Employee..."), NULL,
167 N_(
"Create a new employee"),
168 G_CALLBACK (gnc_plugin_page_owner_tree_cmd_new_owner)
173 "EditDeleteOwnerAction", GNC_STOCK_DELETE_ACCOUNT, N_(
"_Delete Owner..."),
"Delete",
174 N_(
"Delete selected owner"),
175 G_CALLBACK (gnc_plugin_page_owner_tree_cmd_delete_owner)
181 "ViewFilterByAction", NULL, N_(
"_Filter By..."), NULL, NULL,
182 G_CALLBACK (gnc_plugin_page_owner_tree_cmd_view_filter_by)
187 "OTNewBillAction", GNC_STOCK_INVOICE_NEW, N_(
"New _Bill..."), NULL,
188 N_(
"Create a new bill"),
189 G_CALLBACK (gnc_plugin_page_owner_tree_cmd_new_invoice)
192 "OTNewInvoiceAction", GNC_STOCK_INVOICE_NEW, N_(
"New _Invoice..."), NULL,
193 N_(
"Create a new invoice"),
194 G_CALLBACK (gnc_plugin_page_owner_tree_cmd_new_invoice)
197 "OTNewVoucherAction", GNC_STOCK_INVOICE_NEW, N_(
"New _Voucher..."), NULL,
198 N_(
"Create a new voucher"),
199 G_CALLBACK (gnc_plugin_page_owner_tree_cmd_new_invoice)
202 "OTVendorListingReportAction", GTK_STOCK_PRINT_PREVIEW, N_(
"Vendor Listing"), NULL,
203 N_(
"Show vendor aging overview for all vendors"),
204 G_CALLBACK (gnc_plugin_page_owner_tree_cmd_owners_report)
207 "OTCustomerListingReportAction", GTK_STOCK_PRINT_PREVIEW, N_(
"Customer Listing"), NULL,
208 N_(
"Show customer aging overview for all customers"),
209 G_CALLBACK (gnc_plugin_page_owner_tree_cmd_owners_report)
212 "OTVendorReportAction", NULL, N_(
"Vendor Report"), NULL,
213 N_(
"Show vendor report"),
214 G_CALLBACK (gnc_plugin_page_owner_tree_cmd_owner_report)
217 "OTCustomerReportAction", NULL, N_(
"Customer Report"), NULL,
218 N_(
"Show customer report"),
219 G_CALLBACK (gnc_plugin_page_owner_tree_cmd_owner_report)
222 "OTEmployeeReportAction", NULL, N_(
"Employee Report"), NULL,
223 N_(
"Show employee report"),
224 G_CALLBACK (gnc_plugin_page_owner_tree_cmd_owner_report)
228 static guint gnc_plugin_page_owner_tree_n_actions = G_N_ELEMENTS (gnc_plugin_page_owner_tree_actions);
233 static const gchar *actions_requiring_owner_rw[] =
235 "OTEditVendorAction",
236 "OTEditCustomerAction",
237 "OTEditEmployeeAction",
244 static const gchar *actions_requiring_owner_always[] =
246 "OTVendorReportAction",
247 "OTCustomerReportAction",
248 "OTEmployeeReportAction",
253 static const gchar* readonly_inactive_actions[] =
256 "OTNewCustomerAction",
257 "OTNewEmployeeAction",
259 "OTNewInvoiceAction",
260 "OTNewVoucherAction",
268 {
"OTEditVendorAction", N_(
"Edit") },
269 {
"OTEditCustomerAction", N_(
"Edit") },
270 {
"OTEditEmployeeAction", N_(
"Edit") },
271 {
"OTNewVendorAction", N_(
"New") },
272 {
"OTNewCustomerAction", N_(
"New") },
273 {
"OTNewEmployeeAction", N_(
"New") },
274 {
"OTNewBillAction", N_(
"New Bill") },
275 {
"OTNewInvoiceAction", N_(
"New Invoice") },
276 {
"OTNewVoucherAction", N_(
"New Voucher") },
277 {
"OTVendorListingReportAction", N_(
"Vendor Listing") },
278 {
"OTCustomerListingReportAction", N_(
"Customer Listing") },
296 {
"OTEditVendorAction", GNC_OWNER_VENDOR },
297 {
"OTEditCustomerAction", GNC_OWNER_CUSTOMER },
298 {
"OTEditEmployeeAction", GNC_OWNER_EMPLOYEE },
299 {
"OTNewVendorAction", GNC_OWNER_VENDOR },
300 {
"OTNewCustomerAction", GNC_OWNER_CUSTOMER },
301 {
"OTNewEmployeeAction", GNC_OWNER_EMPLOYEE },
302 {
"OTNewBillAction", GNC_OWNER_VENDOR },
303 {
"OTNewInvoiceAction", GNC_OWNER_CUSTOMER },
304 {
"OTNewVoucherAction", GNC_OWNER_EMPLOYEE },
305 {
"OTVendorListingReportAction", GNC_OWNER_VENDOR },
306 {
"OTCustomerListingReportAction", GNC_OWNER_CUSTOMER },
307 {
"OTVendorReportAction", GNC_OWNER_VENDOR },
308 {
"OTCustomerReportAction", GNC_OWNER_CUSTOMER },
309 {
"OTEmployeeReportAction", GNC_OWNER_EMPLOYEE },
310 { NULL, GNC_OWNER_NONE },
316 static GType gnc_plugin_page_owner_tree_type = 0;
318 if (gnc_plugin_page_owner_tree_type == 0)
320 static const GTypeInfo our_info =
325 (GClassInitFunc) gnc_plugin_page_owner_tree_class_init,
330 (GInstanceInitFunc) gnc_plugin_page_owner_tree_init
333 gnc_plugin_page_owner_tree_type = g_type_register_static (GNC_TYPE_PLUGIN_PAGE,
334 GNC_PLUGIN_PAGE_OWNER_TREE_NAME,
338 return gnc_plugin_page_owner_tree_type;
349 GtkActionGroup *action_group;
351 GValue gvalue = { 0 };
354 g_return_val_if_fail( (owner_type != GNC_OWNER_UNDEFINED)
355 && (owner_type != GNC_OWNER_NONE), NULL);
360 for ( ; item; item = g_list_next(item))
363 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
364 if (priv->owner_type == owner_type)
367 return GNC_PLUGIN_PAGE(plugin_page);
371 plugin_page = g_object_new(GNC_TYPE_PLUGIN_PAGE_OWNER_TREE, NULL);
373 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
374 priv->owner_type = owner_type;
378 g_value_init (&gvalue, G_TYPE_BOOLEAN);
381 action = gtk_action_group_get_action (action_group, action_owners[i].action_name);
382 g_value_set_boolean (&gvalue, (priv->owner_type == action_owners[i].
owner_type) );
383 g_object_set_property (G_OBJECT(action),
"visible", &gvalue);
387 return GNC_PLUGIN_PAGE(plugin_page);
393 GObjectClass *object_class = G_OBJECT_CLASS (klass);
396 parent_class = g_type_class_peek_parent (klass);
398 object_class->finalize = gnc_plugin_page_owner_tree_finalize;
400 gnc_plugin_class->
tab_icon = GNC_STOCK_ACCOUNT;
401 gnc_plugin_class->
plugin_name = GNC_PLUGIN_PAGE_OWNER_TREE_NAME;
402 gnc_plugin_class->
create_widget = gnc_plugin_page_owner_tree_create_widget;
403 gnc_plugin_class->
destroy_widget = gnc_plugin_page_owner_tree_destroy_widget;
404 gnc_plugin_class->
save_page = gnc_plugin_page_owner_tree_save_page;
405 gnc_plugin_class->
recreate_page = gnc_plugin_page_owner_tree_recreate_page;
409 plugin_page_signals[OWNER_SELECTED] =
410 g_signal_new (
"owner_selected",
411 G_OBJECT_CLASS_TYPE (object_class),
415 g_cclosure_marshal_VOID__POINTER,
423 GtkActionGroup *action_group;
427 ENTER(
"page %p", plugin_page);
428 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
431 parent = GNC_PLUGIN_PAGE(plugin_page);
432 g_object_set(G_OBJECT(plugin_page),
433 "page-name", _(
"Owners"),
434 "page-uri",
"default:",
435 "ui-description",
"gnc-plugin-page-owner-tree-ui.xml",
437 g_signal_connect (G_OBJECT (plugin_page),
"selected",
438 G_CALLBACK (gnc_plugin_page_owner_tree_selected), plugin_page);
446 "GncPluginPageOwnerTreeActions");
447 gtk_action_group_add_actions(action_group,
448 gnc_plugin_page_owner_tree_actions,
449 gnc_plugin_page_owner_tree_n_actions,
455 priv->fd.show_inactive = TRUE;
456 priv->fd.show_zero_total = TRUE;
458 LEAVE(
"page %p, priv %p, action group %p",
459 plugin_page, priv, action_group);
463 gnc_plugin_page_owner_tree_finalize (GObject *
object)
468 ENTER(
"object %p",
object);
469 page = GNC_PLUGIN_PAGE_OWNER_TREE (
object);
470 g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE (page));
471 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
472 g_return_if_fail (priv != NULL);
474 G_OBJECT_CLASS (parent_class)->finalize (
object);
478 static void update_inactive_actions(
GncPluginPage *plugin_page)
480 GtkActionGroup *action_group;
484 g_return_if_fail(plugin_page);
485 g_return_if_fail(GNC_IS_PLUGIN_PAGE(plugin_page));
489 g_return_if_fail(GTK_IS_ACTION_GROUP (action_group));
493 "sensitive", is_sensitive);
497 gnc_plugin_page_owner_tree_selected (GObject *
object, gpointer user_data)
500 g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
501 update_inactive_actions(page);
511 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
512 ENTER(
"page %p (tree view %p)", page, priv->tree_view);
520 LEAVE(
"owner %p", owner);
528 gnc_plugin_page_owner_refresh_cb (GHashTable *changes, gpointer user_data)
533 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(page));
539 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
540 gtk_widget_queue_draw(priv->widget);
544 gnc_plugin_page_owner_tree_close_cb (gpointer user_data)
548 plugin_page = GNC_PLUGIN_PAGE(user_data);
553 gnc_plugin_page_owner_tree_create_widget (
GncPluginPage *plugin_page)
557 GtkTreeSelection *selection;
558 GtkTreeView *tree_view;
559 GtkWidget *scrolled_window;
560 GtkTreeViewColumn *col;
561 const gchar *state_section = NULL;
564 ENTER(
"page %p", plugin_page);
565 page = GNC_PLUGIN_PAGE_OWNER_TREE (plugin_page);
566 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
567 if (priv->widget != NULL)
569 LEAVE(
"widget = %p", priv->widget);
573 priv->widget = gtk_vbox_new (FALSE, 0);
574 gtk_widget_show (priv->widget);
576 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
577 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
578 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
579 gtk_widget_show (scrolled_window);
580 gtk_box_pack_start (GTK_BOX (priv->widget), scrolled_window,
587 GNC_TREE_VIEW(tree_view), GNC_OWNER_TREE_ID_COL);
588 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
590 GNC_TREE_VIEW(tree_view), GNC_OWNER_TREE_ADDRESS_1_COL);
591 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
593 GNC_TREE_VIEW(tree_view), GNC_OWNER_TREE_ADDRESS_2_COL);
594 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
596 GNC_TREE_VIEW(tree_view), GNC_OWNER_TREE_PHONE_COL);
597 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
602 switch (priv->owner_type)
604 case GNC_OWNER_NONE :
605 case GNC_OWNER_UNDEFINED :
607 case GNC_OWNER_CUSTOMER :
608 label = N_(
"Customers");
609 state_section =
"Customers Overview";
613 state_section =
"Jobs Overview";
615 case GNC_OWNER_VENDOR :
616 label = N_(
"Vendors");
617 state_section =
"Vendors Overview";
619 case GNC_OWNER_EMPLOYEE :
620 label = N_(
"Employees");
621 state_section =
"Employees Overview";
625 g_object_set(G_OBJECT(tree_view),
"state-section", state_section,
626 "show-column-menu", TRUE,
629 g_object_set(G_OBJECT(plugin_page),
"page-name", label, NULL);
631 priv->tree_view = tree_view;
632 selection = gtk_tree_view_get_selection(tree_view);
633 g_signal_connect (G_OBJECT (selection),
"changed",
634 G_CALLBACK (gnc_plugin_page_owner_tree_selection_changed_cb), page);
635 g_signal_connect (G_OBJECT (tree_view),
"button-press-event",
636 G_CALLBACK (gnc_plugin_page_owner_tree_button_press_cb), page);
637 g_signal_connect (G_OBJECT (tree_view),
"row-activated",
638 G_CALLBACK (gnc_plugin_page_owner_tree_double_click_cb), page);
640 gtk_tree_view_set_headers_visible(tree_view, TRUE);
641 gnc_plugin_page_owner_tree_selection_changed_cb (NULL, page);
642 gtk_widget_show (GTK_WIDGET (tree_view));
643 gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET(tree_view));
645 priv->fd.tree_view = GNC_TREE_VIEW_OWNER(priv->tree_view);
647 GNC_TREE_VIEW_OWNER(tree_view),
651 gnc_register_gui_component(PLUGIN_PAGE_ACCT_TREE_CM_CLASS,
652 gnc_plugin_page_owner_refresh_cb,
653 gnc_plugin_page_owner_tree_close_cb,
655 gnc_gui_component_set_session (priv->component_id,
656 gnc_get_current_session());
658 LEAVE(
"widget = %p", priv->widget);
663 gnc_plugin_page_owner_tree_destroy_widget (
GncPluginPage *plugin_page)
668 ENTER(
"page %p", plugin_page);
669 page = GNC_PLUGIN_PAGE_OWNER_TREE (plugin_page);
670 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
674 g_object_unref(G_OBJECT(priv->widget));
678 if (priv->component_id)
680 gnc_unregister_gui_component(priv->component_id);
681 priv->component_id = 0;
684 LEAVE(
"widget destroyed");
687 #define OWNER_TYPE_LABEL "OwnerType"
699 gnc_plugin_page_owner_tree_save_page (
GncPluginPage *plugin_page,
701 const gchar *group_name)
706 g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
707 g_return_if_fail (key_file != NULL);
708 g_return_if_fail (group_name != NULL);
710 ENTER(
"page %p, key_file %p, group_name %s", plugin_page, key_file,
713 owner_page = GNC_PLUGIN_PAGE_OWNER_TREE(plugin_page);
714 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(owner_page);
716 g_key_file_set_integer(key_file, group_name, OWNER_TYPE_LABEL,
719 gnc_tree_view_owner_save(GNC_TREE_VIEW_OWNER(priv->tree_view),
720 &priv->fd, key_file, group_name);
736 gnc_plugin_page_owner_tree_recreate_page (GtkWidget *window,
738 const gchar *group_name)
743 GncOwnerType owner_type;
745 g_return_val_if_fail(key_file, NULL);
746 g_return_val_if_fail(group_name, NULL);
747 ENTER(
"key_file %p, group_name %s", key_file, group_name);
750 owner_type = g_key_file_get_integer(key_file, group_name, OWNER_TYPE_LABEL, NULL);
752 owner_page = GNC_PLUGIN_PAGE_OWNER_TREE(page);
753 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(owner_page);
758 gnc_tree_view_owner_restore(GNC_TREE_VIEW_OWNER(priv->tree_view),
759 &priv->fd, key_file, group_name, owner_type);
765 static void gnc_ui_owner_edit (
GncOwner *owner)
767 if (NULL == owner)
return;
771 case GNC_OWNER_NONE :
772 case GNC_OWNER_UNDEFINED :
774 case GNC_OWNER_CUSTOMER :
776 gnc_ui_customer_edit (owner->owner.customer);
781 gnc_ui_job_edit (owner->owner.job);
784 case GNC_OWNER_VENDOR :
786 gnc_ui_vendor_edit (owner->owner.vendor);
789 case GNC_OWNER_EMPLOYEE :
791 gnc_ui_employee_edit (owner->owner.employee);
808 gnc_plugin_page_owner_tree_button_press_cb (GtkWidget *widget,
809 GdkEventButton *event,
812 g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), FALSE);
814 ENTER(
"widget %p, event %p, page %p", widget, event, page);
826 gnc_plugin_page_owner_tree_double_click_cb (GtkTreeView *treeview,
828 GtkTreeViewColumn *col,
833 g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE (page));
835 gnc_ui_owner_edit (owner);
839 gnc_plugin_page_owner_tree_selection_changed_cb (GtkTreeSelection *selection,
842 GtkActionGroup *action_group;
848 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(page));
856 g_return_if_fail(GTK_IS_TREE_SELECTION(selection));
857 view = gtk_tree_selection_get_tree_view (selection);
859 sensitive = (owner != NULL);
864 "sensitive", sensitive);
866 "sensitive", sensitive && is_readwrite);
867 g_signal_emit (page, plugin_page_signals[OWNER_SELECTED], 0, owner);
875 build_aging_report (GncOwnerType owner_type)
877 gchar *report_name = NULL;
878 gchar *report_title = NULL;
887 case GNC_OWNER_NONE :
888 case GNC_OWNER_UNDEFINED :
889 case GNC_OWNER_EMPLOYEE :
894 case GNC_OWNER_VENDOR :
896 report_name =
"gnc:payables-report-create";
897 report_title = _(
"Vendor Listing");
900 case GNC_OWNER_CUSTOMER :
902 report_name =
"gnc:receivables-report-create";
903 report_title = _(
"Customer Listing");
909 func = scm_c_eval_string (report_name);
910 g_return_val_if_fail (scm_is_procedure (func), -1);
914 args = scm_cons (arg, args);
915 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
918 arg = scm_from_utf8_string (report_title);
919 args = scm_cons (arg, args);
926 args = scm_cons (arg, args);
927 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
931 arg = scm_apply (func, args, SCM_EOL);
932 g_return_val_if_fail (scm_is_exact (arg), -1);
934 return scm_to_int (arg);
943 g_return_val_if_fail (owner, -1);
947 func = scm_c_eval_string (
"gnc:owner-report-create");
948 g_return_val_if_fail (scm_is_procedure (func), -1);
952 swig_type_info * qtype = SWIG_TypeQuery(
"_p_Account");
953 g_return_val_if_fail (qtype, -1);
955 arg = SWIG_NewPointerObj(acc, qtype, 0);
956 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
957 args = scm_cons (arg, args);
961 args = scm_cons (SCM_BOOL_F, args);
964 arg = SWIG_NewPointerObj(owner, SWIG_TypeQuery(
"_p__gncOwner"), 0);
965 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
966 args = scm_cons (arg, args);
969 arg = scm_apply (func, args, SCM_EOL);
970 g_return_val_if_fail (scm_is_exact (arg), -1);
971 return scm_to_int (arg);
984 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(page));
986 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE (page);
988 switch (priv->owner_type)
990 case GNC_OWNER_NONE :
991 case GNC_OWNER_UNDEFINED :
993 case GNC_OWNER_CUSTOMER :
995 gnc_ui_customer_new (gnc_get_current_book ());
1004 case GNC_OWNER_VENDOR :
1006 gnc_ui_vendor_new (gnc_get_current_book ());
1009 case GNC_OWNER_EMPLOYEE :
1011 gnc_ui_employee_new (gnc_get_current_book ());
1021 if (NULL == owner)
return;
1023 ENTER(
"action %p, page %p", action, page);
1025 gnc_ui_owner_edit (owner);
1037 GtkWidget *dialog = NULL;
1041 if (NULL == owner)
return;
1048 #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"
1050 gnc_ui_object_references_show( _(EXPLANATION), list);
1056 owner_name = g_strdup (gncOwnerGetName(owner));
1059 owner_name = g_strdup (_(
"(no name)"));
1067 char *message = g_strdup_printf(_(
"The owner %s will be deleted.\nAre you sure you want to do this?"), owner_name);
1069 dialog = gtk_message_dialog_new(GTK_WINDOW(window),
1070 GTK_DIALOG_DESTROY_WITH_PARENT,
1071 GTK_MESSAGE_QUESTION,
1075 gtk_dialog_add_buttons(GTK_DIALOG(dialog),
1076 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1077 GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT,
1079 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
1080 response = gtk_dialog_run(GTK_DIALOG(dialog));
1081 gtk_widget_destroy(dialog);
1083 if (GTK_RESPONSE_ACCEPT == response)
1087 gnc_set_busy_cursor(NULL, TRUE);
1088 gnc_suspend_gui_refresh ();
1090 gncOwnerDestroy (owner);
1091 gnc_resume_gui_refresh ();
1092 gnc_unset_busy_cursor(NULL);
1102 gnc_plugin_page_owner_tree_cmd_view_filter_by (GtkAction *action,
1107 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(page));
1108 ENTER(
"(action %p, page %p)", action, page);
1110 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
1111 owner_filter_dialog_create(&priv->fd, GNC_PLUGIN_PAGE(page));
1117 gnc_plugin_page_owner_tree_cmd_new_invoice (GtkAction *action,
1123 ENTER(
"action %p, page %p", action, page);
1125 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
1126 switch (priv->owner_type)
1128 case GNC_OWNER_NONE :
1129 case GNC_OWNER_UNDEFINED :
1130 gncOwnerInitUndefined(¤t_owner, NULL);
1132 case GNC_OWNER_CUSTOMER :
1134 gncOwnerInitCustomer(¤t_owner,
1138 case GNC_OWNER_JOB :
1140 gncOwnerInitJob(¤t_owner,
1144 case GNC_OWNER_VENDOR :
1146 gncOwnerInitVendor(¤t_owner,
1150 case GNC_OWNER_EMPLOYEE :
1152 gncOwnerInitEmployee(¤t_owner,
1159 gnc_ui_invoice_new (¤t_owner, gnc_get_current_book());
1165 gnc_plugin_page_owner_tree_cmd_owners_report (GtkAction *action,
1171 ENTER(
"(action %p, plugin_page %p)", action, plugin_page);
1173 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1175 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
1176 id = build_aging_report (priv->owner_type);
1180 window = GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window);
1181 gnc_main_window_open_report(
id, window);
1188 gnc_plugin_page_owner_tree_cmd_owner_report (GtkAction *action,
1194 ENTER(
"(action %p, plugin_page %p)", action, plugin_page);
1196 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1199 id = build_owner_report (current_owner, NULL);
1203 window = GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window);
1204 gnc_main_window_open_report(
id, window);
GtkWidget * gnc_plugin_page_get_window(GncPluginPage *page)
GtkTreeView * gnc_tree_view_owner_new(GncOwnerType owner_type)
Business Interface: Object OWNERs.
const GList * gnc_gobject_tracking_get_list(const gchar *name)
GncPluginPage *(* recreate_page)(GtkWidget *window, GKeyFile *file, const gchar *group)
gboolean gnc_main_window_button_press_cb(GtkWidget *whatever, GdkEventButton *event, GncPluginPage *page)
void gnc_tree_view_owner_set_filter(GncTreeViewOwner *view, gnc_tree_view_owner_filter_func func, gpointer data, GSourceFunc destroy)
GtkTreeView implementation for gnucash owner tree.
utility functions for the GnuCash UI
GtkActionGroup * gnc_plugin_page_get_action_group(GncPluginPage *page)
GtkTreeViewColumn * gnc_tree_view_find_column_by_name(GncTreeView *view, const gchar *wanted)
#define ENTER(format, args...)
void gncOwnerBeginEdit(GncOwner *owner)
void gnc_main_window_open_page(GncMainWindow *window, GncPluginPage *page)
Functions providing a page which lists owners of one type. This type can be vendors, customers or employees.
void(* destroy_widget)(GncPluginPage *plugin_page)
void gnc_tree_view_configure_columns(GncTreeView *view)
const gchar * plugin_name
GncOwner * gnc_plugin_page_owner_tree_get_current_owner(GncPluginPageOwnerTree *page)
QofIdTypeConst gncOwnerTypeToQofIdType(GncOwnerType t)
gpointer gncOwnerGetUndefined(const GncOwner *owner)
Gnome specific utility functions.
All type declarations for the whole Gnucash engine.
GList * qof_instance_get_referring_object_list(const QofInstance *inst)
GncOwnerType gncOwnerGetType(const GncOwner *owner)
GType gnc_plugin_page_owner_tree_get_type(void)
GncJob * gncOwnerGetJob(const GncOwner *owner)
gboolean qof_book_is_readonly(const QofBook *book)
GtkWidget *(* create_widget)(GncPluginPage *plugin_page)
void gnc_main_window_close_page(GncPluginPage *page)
Functions for adding plugins to a GnuCash window.
#define LEAVE(format, args...)
void(* save_page)(GncPluginPage *page, GKeyFile *file, const gchar *group)
GncVendor * gncOwnerGetVendor(const GncOwner *owner)
GncCustomer * gncOwnerGetCustomer(const GncOwner *owner)
void gnc_plugin_page_add_book(GncPluginPage *page, QofBook *book)
GncOwner * gnc_tree_view_owner_get_selected_owner(GncTreeViewOwner *view)
GtkActionGroup * gnc_plugin_page_create_action_group(GncPluginPage *page, const gchar *group_name)
GncOwner * gnc_tree_view_owner_get_owner_from_path(GncTreeViewOwner *view, GtkTreePath *s_path)
gboolean gnc_plugin_page_owner_tree_filter_owners(GncOwner *owner, gpointer user_data)
GncEmployee * gncOwnerGetEmployee(const GncOwner *owner)
GncPluginPage * gnc_plugin_page_owner_tree_new(GncOwnerType owner_type)
const gchar * QofLogModule