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);
134 static guint plugin_page_signals[LAST_SIGNAL] = { 0 };
137 static GActionEntry gnc_plugin_page_owner_tree_actions [] =
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 },
147 {
"EditDeleteOwnerAction", gnc_plugin_page_owner_tree_cmd_delete_owner, NULL, NULL, NULL },
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 },
164 static guint gnc_plugin_page_owner_tree_n_actions = G_N_ELEMENTS(gnc_plugin_page_owner_tree_actions);
167 static const gchar *gnc_plugin_load_ui_items [] =
175 "ReportsPlaceholder1",
181 static const gchar *actions_requiring_owner_rw[] =
183 "OTEditVendorAction",
184 "OTEditCustomerAction",
185 "OTEditEmployeeAction",
186 "OTProcessPaymentAction",
193 static const gchar *actions_requiring_owner_always[] =
195 "OTVendorReportAction",
196 "OTCustomerReportAction",
197 "OTEmployeeReportAction",
198 "OTProcessPaymentAction",
203 static const gchar* readonly_inactive_actions[] =
206 "OTNewCustomerAction",
207 "OTNewEmployeeAction",
209 "OTNewInvoiceAction",
210 "OTNewVoucherAction",
211 "OTProcessPaymentAction",
219 {
"OTEditVendorAction", N_(
"Edit") },
220 {
"OTEditCustomerAction", N_(
"Edit") },
221 {
"OTEditEmployeeAction", N_(
"Edit") },
222 {
"OTNewVendorAction", N_(
"New") },
223 {
"OTNewCustomerAction", N_(
"New") },
224 {
"OTNewEmployeeAction", N_(
"New") },
225 {
"OTNewBillAction", N_(
"New Bill") },
226 {
"OTNewInvoiceAction", N_(
"New Invoice") },
227 {
"OTNewVoucherAction", N_(
"New Voucher") },
228 {
"OTVendorListingReportAction", N_(
"Vendor Listing") },
229 {
"OTCustomerListingReportAction", N_(
"Customer Listing") },
230 {
"OTProcessPaymentAction", N_(
"Process Payment") },
253 g_return_val_if_fail( (owner_type != GNC_OWNER_UNDEFINED)
254 && (owner_type != GNC_OWNER_NONE), NULL);
259 for ( ; item; item = g_list_next(item))
262 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
263 if (priv->owner_type == owner_type)
266 return GNC_PLUGIN_PAGE(plugin_page);
270 plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(g_object_new(GNC_TYPE_PLUGIN_PAGE_OWNER_TREE,
nullptr));
272 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
273 priv->owner_type = owner_type;
276 return GNC_PLUGIN_PAGE(plugin_page);
284 gnc_plugin_page_owner_focus_widget (
GncPluginPage *owner_plugin_page)
286 if (GNC_IS_PLUGIN_PAGE_OWNER_TREE(owner_plugin_page))
289 GtkTreeView *tree_view = priv->tree_view;
293 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
296 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
299 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
301 set_menu_and_toolbar_qualifier (owner_plugin_page);
305 gnc_plugin_load_ui_items);
310 if (GTK_IS_TREE_VIEW(tree_view))
312 if (!gtk_widget_is_focus (GTK_WIDGET(tree_view)))
313 gtk_widget_grab_focus (GTK_WIDGET(tree_view));
322 GObjectClass *object_class = G_OBJECT_CLASS (klass);
325 object_class->finalize = gnc_plugin_page_owner_tree_finalize;
327 gnc_plugin_class->
tab_icon = GNC_ICON_ACCOUNT;
328 gnc_plugin_class->
plugin_name = GNC_PLUGIN_PAGE_OWNER_TREE_NAME;
329 gnc_plugin_class->
create_widget = gnc_plugin_page_owner_tree_create_widget;
330 gnc_plugin_class->
destroy_widget = gnc_plugin_page_owner_tree_destroy_widget;
331 gnc_plugin_class->
save_page = gnc_plugin_page_owner_tree_save_page;
332 gnc_plugin_class->
recreate_page = gnc_plugin_page_owner_tree_recreate_page;
335 plugin_page_signals[OWNER_SELECTED] =
336 g_signal_new (
"owner_selected",
337 G_OBJECT_CLASS_TYPE (object_class),
341 g_cclosure_marshal_VOID__POINTER,
349 GSimpleActionGroup *simple_action_group;
353 ENTER(
"page %p", plugin_page);
354 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
357 parent = GNC_PLUGIN_PAGE(plugin_page);
358 g_object_set(G_OBJECT(plugin_page),
359 "page-name", _(
"Owners"),
360 "ui-description",
"gnc-plugin-page-owner-tree.ui",
362 g_signal_connect (G_OBJECT (plugin_page),
"selected",
363 G_CALLBACK (gnc_plugin_page_owner_tree_selected), plugin_page);
370 g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group),
371 gnc_plugin_page_owner_tree_actions,
372 gnc_plugin_page_owner_tree_n_actions,
376 priv->fd.show_inactive = TRUE;
377 priv->fd.show_zero_total = TRUE;
379 LEAVE(
"page %p, priv %p, action group %p",
380 plugin_page, priv, simple_action_group);
384 gnc_plugin_page_owner_tree_finalize (GObject *
object)
389 ENTER(
"object %p",
object);
390 page = GNC_PLUGIN_PAGE_OWNER_TREE (
object);
391 g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE (page));
392 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
393 g_return_if_fail (priv != NULL);
395 G_OBJECT_CLASS (gnc_plugin_page_owner_tree_parent_class)->finalize (
object);
402 GSimpleActionGroup *simple_action_group;
406 g_return_if_fail(plugin_page);
407 g_return_if_fail(GNC_IS_PLUGIN_PAGE(plugin_page));
411 g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group));
424 g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE(page));
426 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
428 if (priv->owner_type == GNC_OWNER_CUSTOMER)
430 else if (priv->owner_type == GNC_OWNER_VENDOR)
432 else if (priv->owner_type == GNC_OWNER_EMPLOYEE)
439 gnc_plugin_page_owner_tree_selected (GObject *
object, gpointer user_data)
442 g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
443 update_inactive_actions(page);
453 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
454 ENTER(
"page %p (tree view %p)", page, priv->tree_view);
462 LEAVE(
"owner %p", owner);
470 gnc_plugin_page_owner_refresh_cb (GHashTable *changes, gpointer user_data)
472 auto page = GNC_PLUGIN_PAGE_OWNER_TREE(user_data);
475 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(page));
481 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
482 gtk_widget_queue_draw(priv->widget);
486 gnc_plugin_page_owner_tree_close_cb (gpointer user_data)
490 plugin_page = GNC_PLUGIN_PAGE(user_data);
495 gnc_plugin_page_owner_tree_create_widget (
GncPluginPage *plugin_page)
499 GtkTreeSelection *selection;
500 GtkTreeView *tree_view;
501 GtkWidget *scrolled_window;
502 GtkTreeViewColumn *col;
503 const gchar *state_section = NULL;
504 const gchar* label =
"";
505 const gchar *style_label = NULL;
507 ENTER(
"page %p", plugin_page);
508 page = GNC_PLUGIN_PAGE_OWNER_TREE (plugin_page);
509 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
510 if (priv->widget != NULL)
512 LEAVE(
"widget = %p", priv->widget);
516 priv->widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
517 gtk_box_set_homogeneous (GTK_BOX (priv->widget), FALSE);
518 gtk_widget_show (priv->widget);
521 gtk_widget_set_name (GTK_WIDGET(priv->widget),
"gnc-id-owner-page");
523 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
524 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
525 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
526 gtk_widget_show (scrolled_window);
527 gtk_box_pack_start (GTK_BOX (priv->widget), scrolled_window,
534 GNC_TREE_VIEW(tree_view), GNC_OWNER_TREE_ID_COL);
535 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
537 GNC_TREE_VIEW(tree_view), GNC_OWNER_TREE_ADDRESS_1_COL);
538 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
540 GNC_TREE_VIEW(tree_view), GNC_OWNER_TREE_ADDRESS_2_COL);
541 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
543 GNC_TREE_VIEW(tree_view), GNC_OWNER_TREE_PHONE_COL);
544 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
547 switch (priv->owner_type)
549 case GNC_OWNER_NONE :
550 case GNC_OWNER_UNDEFINED :
551 PWARN(
"missing owner_type");
552 label = _(
"Unknown");
553 style_label =
"gnc-class-unknown";
555 case GNC_OWNER_CUSTOMER :
556 label = _(
"Customers");
557 state_section =
"Customers Overview";
558 style_label =
"gnc-class-customers";
562 state_section =
"Jobs Overview";
563 style_label =
"gnc-class-jobs";
565 case GNC_OWNER_VENDOR :
566 label = _(
"Vendors");
567 state_section =
"Vendors Overview";
568 style_label =
"gnc-class-vendors";
570 case GNC_OWNER_EMPLOYEE :
571 label = _(
"Employees");
572 state_section =
"Employees Overview";
573 style_label =
"gnc-class-employees";
578 gnc_widget_style_context_add_class (GTK_WIDGET(priv->widget), style_label);
580 g_object_set(G_OBJECT(tree_view),
"state-section", state_section,
581 "show-column-menu", TRUE,
584 g_object_set(G_OBJECT(plugin_page),
"page-name", label, NULL);
586 priv->tree_view = tree_view;
587 selection = gtk_tree_view_get_selection(tree_view);
588 g_signal_connect (G_OBJECT (selection),
"changed",
589 G_CALLBACK (gnc_plugin_page_owner_tree_selection_changed_cb), page);
590 g_signal_connect (G_OBJECT (tree_view),
"button-press-event",
591 G_CALLBACK (gnc_plugin_page_owner_tree_button_press_cb), page);
592 g_signal_connect (G_OBJECT (tree_view),
"row-activated",
593 G_CALLBACK (gnc_plugin_page_owner_tree_double_click_cb), page);
595 gtk_tree_view_set_headers_visible(tree_view, TRUE);
596 gnc_plugin_page_owner_tree_selection_changed_cb (NULL, page);
597 gtk_widget_show (GTK_WIDGET (tree_view));
598 gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET(tree_view));
600 priv->fd.tree_view = GNC_TREE_VIEW_OWNER(priv->tree_view);
602 GNC_TREE_VIEW_OWNER(tree_view),
606 gnc_register_gui_component(PLUGIN_PAGE_ACCT_TREE_CM_CLASS,
607 gnc_plugin_page_owner_refresh_cb,
608 gnc_plugin_page_owner_tree_close_cb,
610 gnc_gui_component_set_session (priv->component_id,
611 gnc_get_current_session());
613 g_signal_connect (G_OBJECT(plugin_page),
"inserted",
617 set_menu_and_toolbar_qualifier (plugin_page);
619 LEAVE(
"widget = %p", priv->widget);
624 gnc_plugin_page_owner_tree_destroy_widget (
GncPluginPage *plugin_page)
629 ENTER(
"page %p", plugin_page);
630 page = GNC_PLUGIN_PAGE_OWNER_TREE (plugin_page);
631 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
637 g_idle_remove_by_data (plugin_page);
641 g_object_unref(G_OBJECT(priv->widget));
645 if (priv->component_id)
647 gnc_unregister_gui_component(priv->component_id);
648 priv->component_id = 0;
651 LEAVE(
"widget destroyed");
654 #define OWNER_TYPE_LABEL "OwnerType" 666 gnc_plugin_page_owner_tree_save_page (
GncPluginPage *plugin_page,
668 const gchar *group_name)
673 g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
674 g_return_if_fail (key_file != NULL);
675 g_return_if_fail (group_name != NULL);
677 ENTER(
"page %p, key_file %p, group_name %s", plugin_page, key_file,
680 owner_page = GNC_PLUGIN_PAGE_OWNER_TREE(plugin_page);
681 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(owner_page);
683 g_key_file_set_integer(key_file, group_name, OWNER_TYPE_LABEL,
686 gnc_tree_view_owner_save(GNC_TREE_VIEW_OWNER(priv->tree_view),
687 &priv->fd, key_file, group_name);
703 gnc_plugin_page_owner_tree_recreate_page (GtkWidget *window,
705 const gchar *group_name)
710 GncOwnerType owner_type;
712 g_return_val_if_fail(key_file, NULL);
713 g_return_val_if_fail(group_name, NULL);
714 ENTER(
"key_file %p, group_name %s", key_file, group_name);
717 owner_type =
static_cast<GncOwnerType
>(g_key_file_get_integer(key_file, group_name, OWNER_TYPE_LABEL, NULL));
719 owner_page = GNC_PLUGIN_PAGE_OWNER_TREE(page);
720 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(owner_page);
725 gnc_tree_view_owner_restore(GNC_TREE_VIEW_OWNER(priv->tree_view),
726 &priv->fd, key_file, group_name, owner_type);
732 static void gnc_ui_owner_edit (GtkWindow *parent,
GncOwner *owner)
734 if (NULL == owner)
return;
738 case GNC_OWNER_NONE :
739 case GNC_OWNER_UNDEFINED :
741 case GNC_OWNER_CUSTOMER :
743 gnc_ui_customer_edit (parent, owner->owner.customer);
748 gnc_ui_job_edit (parent, owner->owner.job);
751 case GNC_OWNER_VENDOR :
753 gnc_ui_vendor_edit (parent, owner->owner.vendor);
756 case GNC_OWNER_EMPLOYEE :
758 gnc_ui_employee_edit (parent, owner->owner.employee);
775 gnc_plugin_page_owner_tree_button_press_cb (GtkWidget *widget,
776 GdkEventButton *event,
779 g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), FALSE);
781 ENTER(
"widget %p, event %p, page %p", widget, event, page);
793 gnc_plugin_page_owner_tree_double_click_cb (GtkTreeView *treeview,
795 GtkTreeViewColumn *col,
798 gnc_plugin_page_owner_tree_cmd_owner_report (NULL, NULL, (gpointer*)page);
802 gnc_plugin_page_owner_tree_selection_changed_cb (GtkTreeSelection *selection,
805 GSimpleActionGroup *simple_action_group;
811 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(page));
819 g_return_if_fail(GTK_IS_TREE_SELECTION(selection));
820 view = gtk_tree_selection_get_tree_view (selection);
822 sensitive = (owner != NULL);
829 sensitive && is_readwrite);
830 g_signal_emit (page, plugin_page_signals[OWNER_SELECTED], 0, owner);
838 build_aging_report (GncOwnerType owner_type)
840 const gchar *report_name = NULL;
841 const gchar *report_title = NULL;
850 case GNC_OWNER_NONE :
851 case GNC_OWNER_UNDEFINED :
852 case GNC_OWNER_EMPLOYEE :
857 case GNC_OWNER_VENDOR :
859 report_name =
"gnc:payables-report-create";
860 report_title = _(
"Vendor Listing");
863 case GNC_OWNER_CUSTOMER :
865 report_name =
"gnc:receivables-report-create";
866 report_title = _(
"Customer Listing");
872 func = scm_c_eval_string (report_name);
873 g_return_val_if_fail (scm_is_procedure (func), -1);
877 args = scm_cons (arg, args);
878 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
881 arg = scm_from_utf8_string (report_title);
882 args = scm_cons (arg, args);
889 args = scm_cons (arg, args);
890 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
894 arg = scm_apply (func, args, SCM_EOL);
895 g_return_val_if_fail (scm_is_exact (arg), -1);
897 return scm_to_int (arg);
906 g_return_val_if_fail (owner, -1);
910 func = scm_c_eval_string (
"gnc:owner-report-create-with-enddate");
911 g_return_val_if_fail (scm_is_procedure (func), -1);
913 args = scm_cons (SCM_BOOL_F, args);
917 swig_type_info * qtype = SWIG_TypeQuery(
"_p_Account");
918 g_return_val_if_fail (qtype, -1);
920 arg = SWIG_NewPointerObj(acc, qtype, 0);
921 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
922 args = scm_cons (arg, args);
926 args = scm_cons (SCM_BOOL_F, args);
929 swig_type_info * qtype = SWIG_TypeQuery(
"_p__gncOwner");
930 g_return_val_if_fail (qtype, -1);
932 arg = SWIG_NewPointerObj(owner, qtype, 0);
934 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
935 args = scm_cons (arg, args);
938 arg = scm_apply (func, args, SCM_EOL);
939 g_return_val_if_fail (scm_is_exact (arg), -1);
940 return scm_to_int (arg);
949 gnc_plugin_page_owner_tree_cmd_new_owner (GSimpleAction *simple,
954 auto page = GNC_PLUGIN_PAGE_OWNER_TREE (user_data);
958 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(page));
960 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE (page);
963 switch (priv->owner_type)
965 case GNC_OWNER_NONE :
966 case GNC_OWNER_UNDEFINED :
968 case GNC_OWNER_CUSTOMER :
970 gnc_ui_customer_new (parent, gnc_get_current_book ());
979 case GNC_OWNER_VENDOR :
981 gnc_ui_vendor_new (parent, gnc_get_current_book ());
984 case GNC_OWNER_EMPLOYEE :
986 gnc_ui_employee_new (parent, gnc_get_current_book ());
993 gnc_plugin_page_owner_tree_cmd_edit_owner (GSimpleAction *simple,
998 auto page = GNC_PLUGIN_PAGE_OWNER_TREE (user_data);
1001 if (NULL == owner)
return;
1003 ENTER(
"action %p, page %p", simple, page);
1006 gnc_ui_owner_edit (parent, owner);
1013 gnc_plugin_page_owner_tree_cmd_delete_owner (GSimpleAction *simple,
1014 GVariant *parameter,
1018 auto page = GNC_PLUGIN_PAGE_OWNER_TREE (user_data);
1022 GtkWidget *dialog = NULL;
1026 if (NULL == owner)
return;
1033 #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" 1035 gnc_ui_object_references_show( _(EXPLANATION), list);
1041 owner_name = g_strdup (gncOwnerGetName(owner));
1044 owner_name = g_strdup (_(
"(no name)"));
1052 char *message = g_strdup_printf(_(
"The owner %s will be deleted.\nAre you sure you want to do this?"), owner_name);
1054 dialog = gtk_message_dialog_new(GTK_WINDOW(window),
1055 GTK_DIALOG_DESTROY_WITH_PARENT,
1056 GTK_MESSAGE_QUESTION,
1060 gtk_dialog_add_buttons(GTK_DIALOG(dialog),
1061 _(
"_Cancel"), GTK_RESPONSE_CANCEL,
1062 _(
"_Delete"), GTK_RESPONSE_ACCEPT,
1064 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
1065 response = gtk_dialog_run(GTK_DIALOG(dialog));
1066 gtk_widget_destroy(dialog);
1068 if (GTK_RESPONSE_ACCEPT == response)
1072 gnc_set_busy_cursor(NULL, TRUE);
1073 gnc_suspend_gui_refresh ();
1075 gncOwnerDestroy (owner);
1076 gnc_resume_gui_refresh ();
1077 gnc_unset_busy_cursor(NULL);
1087 gnc_plugin_page_owner_tree_cmd_view_filter_by (GSimpleAction *simple,
1088 GVariant *parameter,
1092 auto plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(user_data);
1095 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1096 ENTER(
"(action %p, page %p)", simple, plugin_page);
1098 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
1099 owner_filter_dialog_create(&priv->fd, GNC_PLUGIN_PAGE(plugin_page));
1104 gnc_plugin_page_owner_tree_cmd_refresh (GSimpleAction *simple,
1105 GVariant *parameter,
1109 auto plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(user_data);
1112 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1114 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
1115 gtk_widget_queue_draw (priv->widget);
1119 gnc_plugin_page_owner_tree_cmd_edit_tax (GSimpleAction *simple,
1120 GVariant *parameter,
1123 auto plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(user_data);
1126 g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1130 gnc_tax_info_dialog (parent, NULL);
1134 gnc_plugin_page_owner_tree_cmd_new_invoice (GSimpleAction *simple,
1135 GVariant *parameter,
1139 auto plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(user_data);
1144 ENTER(
"action %p, plugin_page %p", simple, plugin_page);
1146 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
1147 switch (priv->owner_type)
1149 case GNC_OWNER_NONE :
1150 case GNC_OWNER_UNDEFINED :
1151 gncOwnerInitUndefined(¤t_owner, NULL);
1153 case GNC_OWNER_CUSTOMER :
1155 gncOwnerInitCustomer(¤t_owner,
1159 case GNC_OWNER_JOB :
1161 gncOwnerInitJob(¤t_owner,
1165 case GNC_OWNER_VENDOR :
1167 gncOwnerInitVendor(¤t_owner,
1171 case GNC_OWNER_EMPLOYEE :
1173 gncOwnerInitEmployee(¤t_owner,
1181 gnc_ui_invoice_new (parent, ¤t_owner, gnc_get_current_book ());
1187 gnc_plugin_page_owner_tree_cmd_owners_report (GSimpleAction *simple,
1188 GVariant *parameter,
1192 auto plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(user_data);
1196 ENTER(
"(action %p, plugin_page %p)", simple, plugin_page);
1198 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1200 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
1201 id = build_aging_report (priv->owner_type);
1205 window = GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window);
1206 gnc_main_window_open_report(
id, window);
1213 gnc_plugin_page_owner_tree_cmd_owner_report (GSimpleAction *simple,
1214 GVariant *parameter,
1218 auto plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(user_data);
1222 ENTER(
"(action %p, plugin_page %p)", simple, plugin_page);
1224 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1227 id = build_owner_report (current_owner, NULL);
1231 window = GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window);
1232 gnc_main_window_open_report(
id, window);
1240 gnc_plugin_page_owner_tree_cmd_process_payment (GSimpleAction *simple,
1241 GVariant *parameter,
1245 auto plugin_page = GNC_PLUGIN_PAGE_OWNER_TREE(user_data);
1246 ENTER(
"(action %p, plugin_page %p)", simple, plugin_page);
1248 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1250 gnc_ui_payment_new (GTK_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window),
1252 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...
The instance data structure for a main window object.
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.