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)) 95 static GObjectClass *parent_class = NULL;
103 static void gnc_plugin_page_owner_tree_finalize (GObject *
object);
104 static void gnc_plugin_page_owner_tree_selected (GObject *
object, gpointer user_data);
106 static GtkWidget *gnc_plugin_page_owner_tree_create_widget (
GncPluginPage *plugin_page);
107 static void gnc_plugin_page_owner_tree_destroy_widget (
GncPluginPage *plugin_page);
108 static void gnc_plugin_page_owner_tree_save_page (
GncPluginPage *plugin_page, GKeyFile *file,
const gchar *group);
109 static GncPluginPage *gnc_plugin_page_owner_tree_recreate_page (GtkWidget *window, GKeyFile *file,
const gchar *group);
110 static void set_menu_and_toolbar_qualifier (
GncPluginPage *plugin_page);
113 static gboolean gnc_plugin_page_owner_tree_button_press_cb (GtkWidget *widget,
114 GdkEventButton *event,
116 static void gnc_plugin_page_owner_tree_double_click_cb (GtkTreeView *treeview,
118 GtkTreeViewColumn *col,
121 static void gnc_plugin_page_owner_tree_selection_changed_cb (GtkTreeSelection *selection,
125 static void gnc_plugin_page_owner_tree_cmd_new_owner (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
126 static void gnc_plugin_page_owner_tree_cmd_edit_owner (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
128 static void gnc_plugin_page_owner_tree_cmd_delete_owner (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
130 static void gnc_plugin_page_owner_tree_cmd_view_filter_by (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
131 static void gnc_plugin_page_owner_tree_cmd_refresh (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
132 static void gnc_plugin_page_owner_tree_cmd_new_invoice (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
133 static void gnc_plugin_page_owner_tree_cmd_owners_report (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
134 static void gnc_plugin_page_owner_tree_cmd_owner_report (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
135 static void gnc_plugin_page_owner_tree_cmd_process_payment (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
136 static void gnc_plugin_page_owner_tree_cmd_edit_tax (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
138 static guint plugin_page_signals[LAST_SIGNAL] = { 0 };
141 static GActionEntry gnc_plugin_page_owner_tree_actions [] =
143 {
"OTEditVendorAction", gnc_plugin_page_owner_tree_cmd_edit_owner, NULL, NULL, NULL },
144 {
"OTEditCustomerAction", gnc_plugin_page_owner_tree_cmd_edit_owner, NULL, NULL, NULL },
145 {
"OTEditEmployeeAction", gnc_plugin_page_owner_tree_cmd_edit_owner, NULL, NULL, NULL },
146 {
"OTNewVendorAction", gnc_plugin_page_owner_tree_cmd_new_owner, NULL, NULL, NULL },
147 {
"OTNewCustomerAction", gnc_plugin_page_owner_tree_cmd_new_owner, NULL, NULL, NULL },
148 {
"OTNewEmployeeAction", gnc_plugin_page_owner_tree_cmd_new_owner, NULL, NULL, NULL },
151 {
"EditDeleteOwnerAction", gnc_plugin_page_owner_tree_cmd_delete_owner, NULL, NULL, NULL },
154 {
"ViewFilterByAction", gnc_plugin_page_owner_tree_cmd_view_filter_by, NULL, NULL, NULL },
155 {
"ViewRefreshAction", gnc_plugin_page_owner_tree_cmd_refresh, NULL, NULL, NULL },
156 {
"EditTaxOptionsAction", gnc_plugin_page_owner_tree_cmd_edit_tax, NULL, NULL, NULL },
157 {
"OTNewBillAction", gnc_plugin_page_owner_tree_cmd_new_invoice, NULL, NULL, NULL },
158 {
"OTNewInvoiceAction", gnc_plugin_page_owner_tree_cmd_new_invoice, NULL, NULL, NULL },
159 {
"OTNewVoucherAction", gnc_plugin_page_owner_tree_cmd_new_invoice, NULL, NULL, NULL },
160 {
"OTVendorListingReportAction", gnc_plugin_page_owner_tree_cmd_owners_report, NULL, NULL, NULL },
161 {
"OTCustomerListingReportAction", gnc_plugin_page_owner_tree_cmd_owners_report, NULL, NULL, NULL },
162 {
"OTVendorReportAction", gnc_plugin_page_owner_tree_cmd_owner_report, NULL, NULL, NULL },
163 {
"OTCustomerReportAction", gnc_plugin_page_owner_tree_cmd_owner_report, NULL, NULL, NULL },
164 {
"OTEmployeeReportAction", gnc_plugin_page_owner_tree_cmd_owner_report, NULL, NULL, NULL },
165 {
"OTProcessPaymentAction", gnc_plugin_page_owner_tree_cmd_process_payment, NULL, NULL, NULL },
168 static guint gnc_plugin_page_owner_tree_n_actions = G_N_ELEMENTS(gnc_plugin_page_owner_tree_actions);
171 static const gchar *gnc_plugin_load_ui_items [] =
179 "ReportsPlaceholder1",
185 static const gchar *actions_requiring_owner_rw[] =
187 "OTEditVendorAction",
188 "OTEditCustomerAction",
189 "OTEditEmployeeAction",
190 "OTProcessPaymentAction",
197 static const gchar *actions_requiring_owner_always[] =
199 "OTVendorReportAction",
200 "OTCustomerReportAction",
201 "OTEmployeeReportAction",
202 "OTProcessPaymentAction",
207 static const gchar* readonly_inactive_actions[] =
210 "OTNewCustomerAction",
211 "OTNewEmployeeAction",
213 "OTNewInvoiceAction",
214 "OTNewVoucherAction",
215 "OTProcessPaymentAction",
223 {
"OTEditVendorAction", N_(
"Edit") },
224 {
"OTEditCustomerAction", N_(
"Edit") },
225 {
"OTEditEmployeeAction", N_(
"Edit") },
226 {
"OTNewVendorAction", N_(
"New") },
227 {
"OTNewCustomerAction", N_(
"New") },
228 {
"OTNewEmployeeAction", N_(
"New") },
229 {
"OTNewBillAction", N_(
"New Bill") },
230 {
"OTNewInvoiceAction", N_(
"New Invoice") },
231 {
"OTNewVoucherAction", N_(
"New Voucher") },
232 {
"OTVendorListingReportAction", N_(
"Vendor Listing") },
233 {
"OTCustomerListingReportAction", N_(
"Customer Listing") },
234 {
"OTProcessPaymentAction", N_(
"Process Payment") },
257 g_return_val_if_fail( (owner_type != GNC_OWNER_UNDEFINED)
258 && (owner_type != GNC_OWNER_NONE), NULL);
263 for ( ; item; item = g_list_next(item))
266 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
267 if (priv->owner_type == owner_type)
270 return GNC_PLUGIN_PAGE(plugin_page);
274 plugin_page = g_object_new(GNC_TYPE_PLUGIN_PAGE_OWNER_TREE, NULL);
276 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
277 priv->owner_type = owner_type;
280 return GNC_PLUGIN_PAGE(plugin_page);
288 gnc_plugin_page_owner_focus_widget (
GncPluginPage *owner_plugin_page)
290 if (GNC_IS_PLUGIN_PAGE_OWNER_TREE(owner_plugin_page))
293 GtkTreeView *tree_view = priv->tree_view;
297 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
300 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
303 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
305 set_menu_and_toolbar_qualifier (owner_plugin_page);
309 gnc_plugin_load_ui_items);
314 if (GTK_IS_TREE_VIEW(tree_view))
316 if (!gtk_widget_is_focus (GTK_WIDGET(tree_view)))
317 gtk_widget_grab_focus (GTK_WIDGET(tree_view));
326 GObjectClass *object_class = G_OBJECT_CLASS (klass);
329 parent_class = g_type_class_peek_parent (klass);
331 object_class->finalize = gnc_plugin_page_owner_tree_finalize;
333 gnc_plugin_class->
tab_icon = GNC_ICON_ACCOUNT;
334 gnc_plugin_class->
plugin_name = GNC_PLUGIN_PAGE_OWNER_TREE_NAME;
335 gnc_plugin_class->
create_widget = gnc_plugin_page_owner_tree_create_widget;
336 gnc_plugin_class->
destroy_widget = gnc_plugin_page_owner_tree_destroy_widget;
337 gnc_plugin_class->
save_page = gnc_plugin_page_owner_tree_save_page;
338 gnc_plugin_class->
recreate_page = gnc_plugin_page_owner_tree_recreate_page;
341 plugin_page_signals[OWNER_SELECTED] =
342 g_signal_new (
"owner_selected",
343 G_OBJECT_CLASS_TYPE (object_class),
347 g_cclosure_marshal_VOID__POINTER,
355 GSimpleActionGroup *simple_action_group;
359 ENTER(
"page %p", plugin_page);
360 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
363 parent = GNC_PLUGIN_PAGE(plugin_page);
364 g_object_set(G_OBJECT(plugin_page),
365 "page-name", _(
"Owners"),
366 "ui-description",
"gnc-plugin-page-owner-tree.ui",
368 g_signal_connect (G_OBJECT (plugin_page),
"selected",
369 G_CALLBACK (gnc_plugin_page_owner_tree_selected), plugin_page);
376 g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group),
377 gnc_plugin_page_owner_tree_actions,
378 gnc_plugin_page_owner_tree_n_actions,
382 priv->fd.show_inactive = TRUE;
383 priv->fd.show_zero_total = TRUE;
385 LEAVE(
"page %p, priv %p, action group %p",
386 plugin_page, priv, simple_action_group);
390 gnc_plugin_page_owner_tree_finalize (GObject *
object)
395 ENTER(
"object %p",
object);
396 page = GNC_PLUGIN_PAGE_OWNER_TREE (
object);
397 g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE (page));
398 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
399 g_return_if_fail (priv != NULL);
401 G_OBJECT_CLASS (parent_class)->finalize (
object);
408 GSimpleActionGroup *simple_action_group;
412 g_return_if_fail(plugin_page);
413 g_return_if_fail(GNC_IS_PLUGIN_PAGE(plugin_page));
417 g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group));
430 g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE(page));
432 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
434 if (priv->owner_type == GNC_OWNER_CUSTOMER)
436 else if (priv->owner_type == GNC_OWNER_VENDOR)
438 else if (priv->owner_type == GNC_OWNER_EMPLOYEE)
445 gnc_plugin_page_owner_tree_selected (GObject *
object, gpointer user_data)
448 g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
449 update_inactive_actions(page);
459 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
460 ENTER(
"page %p (tree view %p)", page, priv->tree_view);
468 LEAVE(
"owner %p", owner);
476 gnc_plugin_page_owner_refresh_cb (GHashTable *changes, gpointer user_data)
481 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(page));
487 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
488 gtk_widget_queue_draw(priv->widget);
492 gnc_plugin_page_owner_tree_close_cb (gpointer user_data)
496 plugin_page = GNC_PLUGIN_PAGE(user_data);
501 gnc_plugin_page_owner_tree_create_widget (
GncPluginPage *plugin_page)
505 GtkTreeSelection *selection;
506 GtkTreeView *tree_view;
507 GtkWidget *scrolled_window;
508 GtkTreeViewColumn *col;
509 const gchar *state_section = NULL;
511 const gchar *style_label = NULL;
513 ENTER(
"page %p", plugin_page);
514 page = GNC_PLUGIN_PAGE_OWNER_TREE (plugin_page);
515 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
516 if (priv->widget != NULL)
518 LEAVE(
"widget = %p", priv->widget);
522 priv->widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
523 gtk_box_set_homogeneous (GTK_BOX (priv->widget), FALSE);
524 gtk_widget_show (priv->widget);
527 gtk_widget_set_name (GTK_WIDGET(priv->widget),
"gnc-id-owner-page");
529 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
530 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
531 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
532 gtk_widget_show (scrolled_window);
533 gtk_box_pack_start (GTK_BOX (priv->widget), scrolled_window,
540 GNC_TREE_VIEW(tree_view), GNC_OWNER_TREE_ID_COL);
541 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
543 GNC_TREE_VIEW(tree_view), GNC_OWNER_TREE_ADDRESS_1_COL);
544 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
546 GNC_TREE_VIEW(tree_view), GNC_OWNER_TREE_ADDRESS_2_COL);
547 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
549 GNC_TREE_VIEW(tree_view), GNC_OWNER_TREE_PHONE_COL);
550 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
553 switch (priv->owner_type)
555 case GNC_OWNER_NONE :
556 case GNC_OWNER_UNDEFINED :
557 PWARN(
"missing owner_type");
558 label = _(
"Unknown");
559 style_label =
"gnc-class-unknown";
561 case GNC_OWNER_CUSTOMER :
562 label = _(
"Customers");
563 state_section =
"Customers Overview";
564 style_label =
"gnc-class-customers";
568 state_section =
"Jobs Overview";
569 style_label =
"gnc-class-jobs";
571 case GNC_OWNER_VENDOR :
572 label = _(
"Vendors");
573 state_section =
"Vendors Overview";
574 style_label =
"gnc-class-vendors";
576 case GNC_OWNER_EMPLOYEE :
577 label = _(
"Employees");
578 state_section =
"Employees Overview";
579 style_label =
"gnc-class-employees";
584 gnc_widget_style_context_add_class (GTK_WIDGET(priv->widget), style_label);
586 g_object_set(G_OBJECT(tree_view),
"state-section", state_section,
587 "show-column-menu", TRUE,
590 g_object_set(G_OBJECT(plugin_page),
"page-name", label, NULL);
592 priv->tree_view = tree_view;
593 selection = gtk_tree_view_get_selection(tree_view);
594 g_signal_connect (G_OBJECT (selection),
"changed",
595 G_CALLBACK (gnc_plugin_page_owner_tree_selection_changed_cb), page);
596 g_signal_connect (G_OBJECT (tree_view),
"button-press-event",
597 G_CALLBACK (gnc_plugin_page_owner_tree_button_press_cb), page);
598 g_signal_connect (G_OBJECT (tree_view),
"row-activated",
599 G_CALLBACK (gnc_plugin_page_owner_tree_double_click_cb), page);
601 gtk_tree_view_set_headers_visible(tree_view, TRUE);
602 gnc_plugin_page_owner_tree_selection_changed_cb (NULL, page);
603 gtk_widget_show (GTK_WIDGET (tree_view));
604 gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET(tree_view));
606 priv->fd.tree_view = GNC_TREE_VIEW_OWNER(priv->tree_view);
608 GNC_TREE_VIEW_OWNER(tree_view),
612 gnc_register_gui_component(PLUGIN_PAGE_ACCT_TREE_CM_CLASS,
613 gnc_plugin_page_owner_refresh_cb,
614 gnc_plugin_page_owner_tree_close_cb,
616 gnc_gui_component_set_session (priv->component_id,
617 gnc_get_current_session());
619 g_signal_connect (G_OBJECT(plugin_page),
"inserted",
623 set_menu_and_toolbar_qualifier (plugin_page);
625 LEAVE(
"widget = %p", priv->widget);
630 gnc_plugin_page_owner_tree_destroy_widget (
GncPluginPage *plugin_page)
635 ENTER(
"page %p", plugin_page);
636 page = GNC_PLUGIN_PAGE_OWNER_TREE (plugin_page);
637 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
643 g_idle_remove_by_data (plugin_page);
647 g_object_unref(G_OBJECT(priv->widget));
651 if (priv->component_id)
653 gnc_unregister_gui_component(priv->component_id);
654 priv->component_id = 0;
657 LEAVE(
"widget destroyed");
660 #define OWNER_TYPE_LABEL "OwnerType" 672 gnc_plugin_page_owner_tree_save_page (
GncPluginPage *plugin_page,
674 const gchar *group_name)
679 g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
680 g_return_if_fail (key_file != NULL);
681 g_return_if_fail (group_name != NULL);
683 ENTER(
"page %p, key_file %p, group_name %s", plugin_page, key_file,
686 owner_page = GNC_PLUGIN_PAGE_OWNER_TREE(plugin_page);
687 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(owner_page);
689 g_key_file_set_integer(key_file, group_name, OWNER_TYPE_LABEL,
692 gnc_tree_view_owner_save(GNC_TREE_VIEW_OWNER(priv->tree_view),
693 &priv->fd, key_file, group_name);
709 gnc_plugin_page_owner_tree_recreate_page (GtkWidget *window,
711 const gchar *group_name)
716 GncOwnerType owner_type;
718 g_return_val_if_fail(key_file, NULL);
719 g_return_val_if_fail(group_name, NULL);
720 ENTER(
"key_file %p, group_name %s", key_file, group_name);
723 owner_type = g_key_file_get_integer(key_file, group_name, OWNER_TYPE_LABEL, NULL);
725 owner_page = GNC_PLUGIN_PAGE_OWNER_TREE(page);
726 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(owner_page);
731 gnc_tree_view_owner_restore(GNC_TREE_VIEW_OWNER(priv->tree_view),
732 &priv->fd, key_file, group_name, owner_type);
738 static void gnc_ui_owner_edit (GtkWindow *parent,
GncOwner *owner)
740 if (NULL == owner)
return;
744 case GNC_OWNER_NONE :
745 case GNC_OWNER_UNDEFINED :
747 case GNC_OWNER_CUSTOMER :
749 gnc_ui_customer_edit (parent, owner->owner.customer);
754 gnc_ui_job_edit (parent, owner->owner.job);
757 case GNC_OWNER_VENDOR :
759 gnc_ui_vendor_edit (parent, owner->owner.vendor);
762 case GNC_OWNER_EMPLOYEE :
764 gnc_ui_employee_edit (parent, owner->owner.employee);
781 gnc_plugin_page_owner_tree_button_press_cb (GtkWidget *widget,
782 GdkEventButton *event,
785 g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), FALSE);
787 ENTER(
"widget %p, event %p, page %p", widget, event, page);
799 gnc_plugin_page_owner_tree_double_click_cb (GtkTreeView *treeview,
801 GtkTreeViewColumn *col,
804 gnc_plugin_page_owner_tree_cmd_owner_report (NULL, NULL, (gpointer*)page);
808 gnc_plugin_page_owner_tree_selection_changed_cb (GtkTreeSelection *selection,
811 GSimpleActionGroup *simple_action_group;
817 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(page));
825 g_return_if_fail(GTK_IS_TREE_SELECTION(selection));
826 view = gtk_tree_selection_get_tree_view (selection);
828 sensitive = (owner != NULL);
835 sensitive && is_readwrite);
836 g_signal_emit (page, plugin_page_signals[OWNER_SELECTED], 0, owner);
844 build_aging_report (GncOwnerType owner_type)
846 gchar *report_name = NULL;
847 gchar *report_title = NULL;
856 case GNC_OWNER_NONE :
857 case GNC_OWNER_UNDEFINED :
858 case GNC_OWNER_EMPLOYEE :
863 case GNC_OWNER_VENDOR :
865 report_name =
"gnc:payables-report-create";
866 report_title = _(
"Vendor Listing");
869 case GNC_OWNER_CUSTOMER :
871 report_name =
"gnc:receivables-report-create";
872 report_title = _(
"Customer Listing");
878 func = scm_c_eval_string (report_name);
879 g_return_val_if_fail (scm_is_procedure (func), -1);
883 args = scm_cons (arg, args);
884 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
887 arg = scm_from_utf8_string (report_title);
888 args = scm_cons (arg, args);
895 args = scm_cons (arg, args);
896 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
900 arg = scm_apply (func, args, SCM_EOL);
901 g_return_val_if_fail (scm_is_exact (arg), -1);
903 return scm_to_int (arg);
912 g_return_val_if_fail (owner, -1);
916 func = scm_c_eval_string (
"gnc:owner-report-create-with-enddate");
917 g_return_val_if_fail (scm_is_procedure (func), -1);
919 args = scm_cons (SCM_BOOL_F, args);
923 swig_type_info * qtype = SWIG_TypeQuery(
"_p_Account");
924 g_return_val_if_fail (qtype, -1);
926 arg = SWIG_NewPointerObj(acc, qtype, 0);
927 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
928 args = scm_cons (arg, args);
932 args = scm_cons (SCM_BOOL_F, args);
935 swig_type_info * qtype = SWIG_TypeQuery(
"_p__gncOwner");
936 g_return_val_if_fail (qtype, -1);
938 arg = SWIG_NewPointerObj(owner, qtype, 0);
940 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
941 args = scm_cons (arg, args);
944 arg = scm_apply (func, args, SCM_EOL);
945 g_return_val_if_fail (scm_is_exact (arg), -1);
946 return scm_to_int (arg);
955 gnc_plugin_page_owner_tree_cmd_new_owner (GSimpleAction *simple,
964 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(page));
966 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE (page);
969 switch (priv->owner_type)
971 case GNC_OWNER_NONE :
972 case GNC_OWNER_UNDEFINED :
974 case GNC_OWNER_CUSTOMER :
976 gnc_ui_customer_new (parent, gnc_get_current_book ());
985 case GNC_OWNER_VENDOR :
987 gnc_ui_vendor_new (parent, gnc_get_current_book ());
990 case GNC_OWNER_EMPLOYEE :
992 gnc_ui_employee_new (parent, gnc_get_current_book ());
999 gnc_plugin_page_owner_tree_cmd_edit_owner (GSimpleAction *simple,
1000 GVariant *parameter,
1007 if (NULL == owner)
return;
1009 ENTER(
"action %p, page %p", simple, page);
1012 gnc_ui_owner_edit (parent, owner);
1019 gnc_plugin_page_owner_tree_cmd_delete_owner (GSimpleAction *simple,
1020 GVariant *parameter,
1028 GtkWidget *dialog = NULL;
1032 if (NULL == owner)
return;
1039 #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" 1041 gnc_ui_object_references_show( _(EXPLANATION), list);
1047 owner_name = g_strdup (gncOwnerGetName(owner));
1050 owner_name = g_strdup (_(
"(no name)"));
1058 char *message = g_strdup_printf(_(
"The owner %s will be deleted.\nAre you sure you want to do this?"), owner_name);
1060 dialog = gtk_message_dialog_new(GTK_WINDOW(window),
1061 GTK_DIALOG_DESTROY_WITH_PARENT,
1062 GTK_MESSAGE_QUESTION,
1066 gtk_dialog_add_buttons(GTK_DIALOG(dialog),
1067 _(
"_Cancel"), GTK_RESPONSE_CANCEL,
1068 _(
"_Delete"), GTK_RESPONSE_ACCEPT,
1070 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
1071 response = gtk_dialog_run(GTK_DIALOG(dialog));
1072 gtk_widget_destroy(dialog);
1074 if (GTK_RESPONSE_ACCEPT == response)
1078 gnc_set_busy_cursor(NULL, TRUE);
1079 gnc_suspend_gui_refresh ();
1081 gncOwnerDestroy (owner);
1082 gnc_resume_gui_refresh ();
1083 gnc_unset_busy_cursor(NULL);
1093 gnc_plugin_page_owner_tree_cmd_view_filter_by (GSimpleAction *simple,
1094 GVariant *parameter,
1101 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1102 ENTER(
"(action %p, page %p)", simple, plugin_page);
1104 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
1105 owner_filter_dialog_create(&priv->fd, GNC_PLUGIN_PAGE(plugin_page));
1110 gnc_plugin_page_owner_tree_cmd_refresh (GSimpleAction *simple,
1111 GVariant *parameter,
1118 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1120 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
1121 gtk_widget_queue_draw (priv->widget);
1125 gnc_plugin_page_owner_tree_cmd_edit_tax (GSimpleAction *simple,
1126 GVariant *parameter,
1132 g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1136 gnc_tax_info_dialog (parent, NULL);
1140 gnc_plugin_page_owner_tree_cmd_new_invoice (GSimpleAction *simple,
1141 GVariant *parameter,
1150 ENTER(
"action %p, plugin_page %p", simple, plugin_page);
1152 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
1153 switch (priv->owner_type)
1155 case GNC_OWNER_NONE :
1156 case GNC_OWNER_UNDEFINED :
1157 gncOwnerInitUndefined(¤t_owner, NULL);
1159 case GNC_OWNER_CUSTOMER :
1161 gncOwnerInitCustomer(¤t_owner,
1165 case GNC_OWNER_JOB :
1167 gncOwnerInitJob(¤t_owner,
1171 case GNC_OWNER_VENDOR :
1173 gncOwnerInitVendor(¤t_owner,
1177 case GNC_OWNER_EMPLOYEE :
1179 gncOwnerInitEmployee(¤t_owner,
1187 gnc_ui_invoice_new (parent, ¤t_owner, gnc_get_current_book ());
1193 gnc_plugin_page_owner_tree_cmd_owners_report (GSimpleAction *simple,
1194 GVariant *parameter,
1202 ENTER(
"(action %p, plugin_page %p)", simple, plugin_page);
1204 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1206 priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
1207 id = build_aging_report (priv->owner_type);
1211 window = GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window);
1212 gnc_main_window_open_report(
id, window);
1219 gnc_plugin_page_owner_tree_cmd_owner_report (GSimpleAction *simple,
1220 GVariant *parameter,
1228 ENTER(
"(action %p, plugin_page %p)", simple, plugin_page);
1230 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1233 id = build_owner_report (current_owner, NULL);
1237 window = GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window);
1238 gnc_main_window_open_report(
id, window);
1246 gnc_plugin_page_owner_tree_cmd_process_payment (GSimpleAction *simple,
1247 GVariant *parameter,
1252 ENTER(
"(action %p, plugin_page %p)", simple, plugin_page);
1254 g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page));
1256 gnc_ui_payment_new (GTK_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window),
1258 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.