From d245d4607b380ce0d834063f226a54e1a6b38eb9 Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Mon, 28 Oct 2002 01:44:18 +0000 Subject: [PATCH] * gncInvoice.[ch]: create gncInvoiceGetTotal(), which currently does nothing but will eventually return the actual invoice total. * dialog-invoice.c: add a summary bar with the invoice total * invoice.glade: add a summary bar dock at the bottom of the page. Partial fix for bug #96833 git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7410 57a11ea4-9604-0410-9ed3-97b8803252fd --- ChangeLog | 7 ++ src/business/business-core/gncInvoice.c | 7 ++ src/business/business-core/gncInvoice.h | 3 + src/business/business-gnome/dialog-invoice.c | 81 ++++++++++++++++++- .../business-gnome/glade/invoice.glade | 19 +++++ 5 files changed, 116 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index dc38463bd4..e292a3200c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2002-10-27 Derek Atkins + * gncInvoice.[ch]: create gncInvoiceGetTotal(), which currently does + nothing but will eventually return the actual invoice total. + * dialog-invoice.c: add a summary bar with the invoice total + * invoice.glade: add a summary bar dock at the bottom of the page. + Partial fix for bug #96833 + 2002-10-27 Christian Stimming * src/import-export/hbci/*.c: add #include config.h for correct diff --git a/src/business/business-core/gncInvoice.c b/src/business/business-core/gncInvoice.c index b7e8488e54..b1594154de 100644 --- a/src/business/business-core/gncInvoice.c +++ b/src/business/business-core/gncInvoice.c @@ -373,6 +373,13 @@ const char * gncInvoiceGetNotes (GncInvoice *invoice) return invoice->notes; } +gnc_numeric gncInvoiceGetTotal (GncInvoice *invoice) +{ + gnc_numeric total = { 200, 100 }; + if (!invoice) return gnc_numeric_zero(); + return total; +} + static GncOwnerType gncInvoiceGetOwnerType (GncInvoice *invoice) { GncOwner *owner; diff --git a/src/business/business-core/gncInvoice.h b/src/business/business-core/gncInvoice.h index 2dbaeb6411..3a89ff415a 100644 --- a/src/business/business-core/gncInvoice.h +++ b/src/business/business-core/gncInvoice.h @@ -63,6 +63,9 @@ GNCLot * gncInvoiceGetPostedLot (GncInvoice *invoice); Transaction * gncInvoiceGetPostedTxn (GncInvoice *invoice); Account * gncInvoiceGetPostedAcc (GncInvoice *invoice); +/* return the "total" amount of the invoice */ +gnc_numeric gncInvoiceGetTotal (GncInvoice *invoice); + GList * gncInvoiceGetEntries (GncInvoice *invoice); /* Post this invoice to an account. Returns the new Transaction diff --git a/src/business/business-gnome/dialog-invoice.c b/src/business/business-gnome/dialog-invoice.c index 6bafe87ec9..89bc237a7a 100644 --- a/src/business/business-gnome/dialog-invoice.c +++ b/src/business/business-gnome/dialog-invoice.c @@ -90,6 +90,10 @@ struct _invoice_window { GtkWidget * print_button; GtkWidget * post_button; + /* Summary Bar Widgets */ + GtkWidget * summarybar_dock; + GtkWidget * total_label; + /* Menu Widgets */ GtkWidget * menu_print; GtkWidget * menu_cut; @@ -171,6 +175,7 @@ void gnc_invoice_window_sort_price_cb (GtkWidget *widget, gpointer data); void gnc_invoice_window_toolbar_cb (GtkWidget *widget, gpointer data); void gnc_invoice_window_statusbar_cb (GtkWidget *widget, gpointer data); +void gnc_invoice_window_summarybar_cb (GtkWidget *widget, gpointer data); #define INV_WIDTH_PREFIX "invoice_reg" #define BILL_WIDTH_PREFIX "bill_reg" @@ -787,6 +792,54 @@ void gnc_invoice_window_statusbar_cb (GtkWidget *widget, gpointer data) } } +void +gnc_invoice_window_summarybar_cb (GtkWidget *widget, gpointer data) +{ + InvoiceWindow *iw = data; + GtkCheckMenuItem *checkmenu = GTK_CHECK_MENU_ITEM(widget); + + if (checkmenu->active) { + gtk_widget_show(iw->summarybar_dock); + } else { + gtk_widget_hide(iw->summarybar_dock); + gtk_widget_queue_resize(iw->summarybar_dock); + } +} + +static GtkWidget * +add_summary_label (GtkWidget *summarybar, const char *label_str) +{ + GtkWidget *hbox; + GtkWidget *label; + + hbox = gtk_hbox_new(FALSE, 2); + gtk_box_pack_start (GTK_BOX(summarybar), hbox, FALSE, FALSE, 5); + + label = gtk_label_new (label_str); + gtk_misc_set_alignment (GTK_MISC(label), 1.0, 0.5); + gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0); + + label = gtk_label_new (""); + gtk_misc_set_alignment (GTK_MISC(label), 1.0, 0.5); + gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0); + + return label; +} + +static GtkWidget * +gnc_invoice_window_create_summary_bar (InvoiceWindow *iw) +{ + GtkWidget *summarybar; + + iw->total_label = NULL; + + summarybar = gtk_hbox_new (FALSE, 4); + + iw->total_label = add_summary_label (summarybar, _("Total:")); + + return summarybar; +} + static GtkWidget * gnc_invoice_window_create_popup_menu (InvoiceWindow *iw) { @@ -1148,10 +1201,26 @@ gnc_invoice_window_close_handler (gpointer user_data) static void gnc_invoice_redraw_all_cb (GnucashRegister *g_reg, gpointer data) { - // InvoiceWindow *iw = data; + InvoiceWindow *iw = data; + GncInvoice * invoice; + gnc_numeric amount; + char string[256]; + + if (!iw) + return; // if (iw) // gnc_invoice_update_window (iw); + + invoice = iw_get_invoice (iw); + if (!invoice) + return; + + if (iw->total_label) { + amount = gncInvoiceGetTotal(invoice); + xaccSPrintAmount (string, amount, gnc_default_print_info (TRUE)); + gtk_label_set_text (GTK_LABEL (iw->total_label), string); + } } static void @@ -1577,6 +1646,16 @@ gnc_invoice_new_window (GNCBook *bookp, InvoiceDialogType type, /* grab the statusbar */ iw->statusbar = glade_xml_get_widget (xml, "status_bar"); + /* grab/build the summarybar */ + { + GtkWidget * summarybar = gnc_invoice_window_create_summary_bar (iw); + iw->summarybar_dock = glade_xml_get_widget (xml, "summarybar_dock"); + if (summarybar) { + gtk_widget_show_all (summarybar); + gtk_container_add (GTK_CONTAINER (iw->summarybar_dock), summarybar); + } + } + hbox = glade_xml_get_widget (xml, "date_opened_hbox"); iw->opened_date = gnc_date_edit_new (time(NULL), FALSE, FALSE); gtk_box_pack_start (GTK_BOX(hbox), iw->opened_date, TRUE, TRUE, 0); diff --git a/src/business/business-gnome/glade/invoice.glade b/src/business/business-gnome/glade/invoice.glade index 58aecbc956..ea3adaef18 100644 --- a/src/business/business-gnome/glade/invoice.glade +++ b/src/business/business-gnome/glade/invoice.glade @@ -1360,6 +1360,25 @@ + + GnomeDockItem + summarybar_dock + GNOME_DOCK_BOTTOM + 0 + 0 + 0 + False + False + False + False + False + GTK_SHADOW_OUT + + + Placeholder + + + GtkVBox GnomeDock:contents