From c180c018c07b0604e4d35d86a8e7071f051d415c Mon Sep 17 00:00:00 2001 From: Dave Peticolas Date: Tue, 25 Apr 2000 10:14:27 +0000 Subject: [PATCH] More work on the budget dialog. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2211 57a11ea4-9604-0410-9ed3-97b8803252fd --- ChangeLog | 4 + src/gnome/.cvsignore | 2 + src/gnome/Makefile.in | 2 +- src/gnome/dialog-budget.c | 202 ++++++++++++ src/gnome/dialog-budget.h | 35 ++ src/gnome/dialog-find-transactions.h | 1 - src/gnome/glade-cb-gnc-dialogs.h | 4 + src/gnome/glade-gnc-dialogs.c | 475 +++++++++++++++++++++++++++ src/gnome/glade-gnc-dialogs.h | 1 + src/gnome/gnc-dialogs.glade | 264 +++++---------- src/scm/extensions.scm | 4 +- src/scm/report/budget-report.scm | 14 + 12 files changed, 831 insertions(+), 177 deletions(-) create mode 100644 src/gnome/dialog-budget.c create mode 100644 src/gnome/dialog-budget.h diff --git a/ChangeLog b/ChangeLog index b4f3738d37..9b56ca7464 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2000-04-24 Dave Peticolas + * src/scm/report/average-balance.scm: the min and max columns + were swapped. Also, the last average balance entry wasn't being + calculated correctly. + * src/gnome/dialog-options.c: modified to use gnc-dateedit. * src/gnome/window-adjust.c: modified to use gnc-dateedit. diff --git a/src/gnome/.cvsignore b/src/gnome/.cvsignore index 10349d9b33..82b51399f0 100644 --- a/src/gnome/.cvsignore +++ b/src/gnome/.cvsignore @@ -3,3 +3,5 @@ tmp obj *.diff backup.glade +glade-cb-gnc-dialogs.c +glade-support-gnc-dialogs.c diff --git a/src/gnome/Makefile.in b/src/gnome/Makefile.in index b700d40de5..a079fc6fd9 100644 --- a/src/gnome/Makefile.in +++ b/src/gnome/Makefile.in @@ -64,7 +64,7 @@ OTHER_OBJS += $(wildcard @top_srcdir@/src/register/gnome/obj/gnome/*.o) ###################################################################### # See Makefile.common for information about these variables. GNOME_SRCS := top-level.c window-main.c window-register.c window-adjust.c \ - window-help.c cursors.c account-tree.c \ + window-help.c cursors.c account-tree.c dialog-budget.c \ window-reconcile.c option-util.c window-html.c \ dialog-options.c dialog-filebox.c dialog-transfer.c \ dialog-add.c dialog-edit.c dialog-utils.c \ diff --git a/src/gnome/dialog-budget.c b/src/gnome/dialog-budget.c new file mode 100644 index 0000000000..26035c5dc6 --- /dev/null +++ b/src/gnome/dialog-budget.c @@ -0,0 +1,202 @@ +/********************************************************************\ + * dialog-budget.c : dialog for entering a budget * + * Copyright (C) 2000 Dave Peticolas * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation; either version 2 of * + * the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License* + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * +\********************************************************************/ + +#include "config.h" + +#include "dialog-budget.h" +#include "glade-gnc-dialogs.h" +#include "guile-util.h" + + +struct _BudgetDialog +{ + GtkWidget *dialog; + + GtkWidget *entry_tree; + + GtkWidget *entry_description_entry; + GtkWidget *entry_type_menu; + + GtkWidget *sub_description_entry; + GtkWidget *sub_amount_entry; + GtkWidget *sub_mechanism_menu; + + SCM apply_func; + SCM apply_func_id; +}; + +typedef struct _BudgetEntry +{ + SCM entry; + SCM entry_id; +} BudgetEntry; + + +static struct +{ + SCM entry_description; +} getters; + +static gboolean getters_initialized = FALSE; + + +static void +initialize_getters() +{ + if (getters_initialized) + return; + + getters.entry_description = gh_eval_str("budget-entry-get-description"); + + getters_initialized = TRUE; +} + + +static void +destroy_entry(gpointer data) +{ + BudgetEntry *be = data; + + if (be == NULL) return; + + gnc_unregister_c_side_scheme_ptr_id(be->entry_id); + + g_free(be); +} + +static void +fill_entry_tree(GtkWidget *entry_tree, SCM budget) +{ + GtkCTreeNode *node; + GtkCTree *ctree; + gchar *text[2]; + BudgetEntry *be; + SCM entry; + SCM value; + + text[1] = NULL; + + ctree = GTK_CTREE(entry_tree); + + gtk_clist_freeze(GTK_CLIST(ctree)); + + while (gh_list_p(budget) && !gh_null_p(budget)) + { + entry = gh_car(budget); + budget = gh_cdr(budget); + + value = gh_call1(getters.entry_description, entry); + text[0] = gh_scm2newstr(value, NULL); + if (text[0] == NULL) + continue; + + node = gtk_ctree_insert_node(ctree, NULL, NULL, text, 0, + NULL, NULL, NULL, NULL, FALSE, FALSE); + + be = g_new0(BudgetEntry, 1); + + be->entry = entry; + be->entry_id = gnc_register_c_side_scheme_ptr(entry); + + gtk_ctree_node_set_row_data_full(ctree, node, be, destroy_entry); + } + + gtk_clist_thaw(GTK_CLIST(ctree)); +} + +BudgetDialog * +gnc_ui_budget_dialog_create(SCM budget, SCM apply_func) +{ + BudgetDialog *bd; + GtkObject *bdo; + GtkWidget *button; + GtkWidget *arrow; + + initialize_getters(); + + bd = g_new0(BudgetDialog, 1); + + bd->dialog = create_Budget_Dialog(); + bdo = GTK_OBJECT(bd->dialog); + + bd->apply_func = apply_func; + bd->apply_func_id = gnc_register_c_side_scheme_ptr(apply_func); + + bd->entry_tree = gtk_object_get_data(bdo, "entry_tree"); + fill_entry_tree(bd->entry_tree, budget); + + bd->entry_description_entry = + gtk_object_get_data(bdo, "entry_description_entry"); + bd->entry_type_menu = + gtk_object_get_data(bdo, "entry_type_menu"); + + bd->sub_description_entry = + gtk_object_get_data(bdo, "sub_description_entry"); + bd->sub_amount_entry = + gtk_object_get_data(bdo, "sub_amount_entry"); + bd->sub_mechanism_menu = + gtk_object_get_data(bdo, "sub_mechanism_menu"); + + button = gtk_object_get_data(bdo, "up_button"); + arrow = gtk_arrow_new(GTK_ARROW_UP, GTK_SHADOW_IN); + gtk_container_remove(GTK_CONTAINER(button), GTK_BIN(button)->child); + gtk_container_add(GTK_CONTAINER(button), arrow); + + button = gtk_object_get_data(bdo, "down_button"); + arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_IN); + gtk_container_remove(GTK_CONTAINER(button), GTK_BIN(button)->child); + gtk_container_add(GTK_CONTAINER(button), arrow); + + gtk_object_set_data(bdo, "budget_dialog_structure", bd); + + gtk_widget_show_all(bd->dialog); + + return bd; +} + +void +gnc_ui_budget_dialog_destroy(BudgetDialog *bd) +{ + if (bd == NULL) + return; + + if (bd->dialog != NULL) + gnome_dialog_close(GNOME_DIALOG(bd->dialog)); + + bd->dialog = NULL; +} + +void +on_Budget_Dialog_destroy(GtkObject *object, + gpointer user_data) +{ + BudgetDialog *bd; + + if (object == NULL) return; + + bd = gtk_object_get_data(object, "budget_dialog_structure"); + if (bd == NULL) + return; + + gnc_unregister_c_side_scheme_ptr_id(bd->apply_func_id); + + g_free(bd); + + gtk_object_set_data(object, "budget_dialog_structure", NULL); +} diff --git a/src/gnome/dialog-budget.h b/src/gnome/dialog-budget.h new file mode 100644 index 0000000000..e35111b35d --- /dev/null +++ b/src/gnome/dialog-budget.h @@ -0,0 +1,35 @@ +/********************************************************************\ + * dialog-budget.h : dialog for entering a budget * + * Copyright (C) 2000 Dave Peticolas * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation; either version 2 of * + * the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License* + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * +\********************************************************************/ + +#ifndef __DIALOG_BUDGET_H_ +#define __DIALOG_BUDGET_H_ + +#include "config.h" + +#include +#include + +#include "glade-gnc-dialogs.h" + +typedef struct _BudgetDialog BudgetDialog; + +BudgetDialog * gnc_ui_budget_dialog_create(SCM budget, SCM apply_func); +void gnc_ui_budget_dialog_destroy(BudgetDialog *bd); + +#endif diff --git a/src/gnome/dialog-find-transactions.h b/src/gnome/dialog-find-transactions.h index 763beab25a..c4894600d3 100644 --- a/src/gnome/dialog-find-transactions.h +++ b/src/gnome/dialog-find-transactions.h @@ -111,5 +111,4 @@ void gnc_ui_select_date_dialog_destroy(SelectDateDialog * sdd); void gnc_ui_select_date_cancel_cb(GtkWidget * w, gpointer user_data); void gnc_ui_select_date_ok_cb(GtkWidget * w, gpointer user_data); -Split ** gnc_make_split_array(int nsplits); #endif diff --git a/src/gnome/glade-cb-gnc-dialogs.h b/src/gnome/glade-cb-gnc-dialogs.h index 49fff42314..6ab12aa947 100644 --- a/src/gnome/glade-cb-gnc-dialogs.h +++ b/src/gnome/glade-cb-gnc-dialogs.h @@ -144,3 +144,7 @@ gnc_ui_select_date_dialog_ok_cb (GtkButton *button, void gnc_ui_select_date_dialog_cancel_cb (GtkButton *button, gpointer user_data); + +void +on_Budget_Dialog_destroy (GtkObject *object, + gpointer user_data); diff --git a/src/gnome/glade-gnc-dialogs.c b/src/gnome/glade-gnc-dialogs.c index f38a6651eb..667178f21f 100644 --- a/src/gnome/glade-gnc-dialogs.c +++ b/src/gnome/glade-gnc-dialogs.c @@ -2663,3 +2663,478 @@ create_Select_Date (void) return Select_Date; } +GtkWidget* +create_Budget_Dialog (void) +{ + GtkWidget *Budget_Dialog; + GtkWidget *dialog_vbox9; + GtkWidget *hbox40; + GtkWidget *frame21; + GtkWidget *vbox58; + GtkWidget *scrolledwindow5; + GtkWidget *viewport2; + GtkWidget *scrolledwindow6; + GtkWidget *entry_tree; + GtkWidget *label773; + GtkWidget *hbox43; + GtkWidget *hbuttonbox2; + GtkWidget *insert_entry_button; + GtkWidget *delete_entry_button; + GtkWidget *hbox44; + GtkWidget *up_button; + GtkWidget *down_button; + GtkWidget *vbox52; + GtkWidget *frame22; + GtkWidget *hbox34; + GtkWidget *vbox54; + GtkWidget *label774; + GtkWidget *label775; + GtkWidget *label776; + GtkWidget *vbox55; + GtkWidget *entry_description_entry; + GtkWidget *entry_type_menu; + GtkWidget *entry_type_menu_menu; + GtkWidget *glade_menuitem; + GtkWidget *match_button; + GtkWidget *frame23; + GtkWidget *hbox35; + GtkWidget *vbox56; + GtkWidget *label777; + GtkWidget *label778; + GtkWidget *label779; + GtkWidget *label780; + GtkWidget *label781; + GtkWidget *label782; + GtkWidget *vbox57; + GtkWidget *sub_description_entry; + GtkWidget *sub_amount_entry; + GtkWidget *period_box; + GtkWidget *hbox37; + GtkWidget *sub_mechanism_menu; + GtkWidget *sub_mechanism_menu_menu; + GtkWidget *label784; + GtkWidget *bill_day_box; + GtkWidget *grace_box; + GtkWidget *dialog_action_area9; + GtkWidget *ok_button; + GtkWidget *apply_button; + GtkWidget *cancel_button; + GtkWidget *help_button; + + Budget_Dialog = gnome_dialog_new (_("Budget"), NULL); + gtk_object_set_data (GTK_OBJECT (Budget_Dialog), "Budget_Dialog", Budget_Dialog); + gtk_window_set_policy (GTK_WINDOW (Budget_Dialog), TRUE, TRUE, FALSE); + + dialog_vbox9 = GNOME_DIALOG (Budget_Dialog)->vbox; + gtk_object_set_data (GTK_OBJECT (Budget_Dialog), "dialog_vbox9", dialog_vbox9); + gtk_widget_show (dialog_vbox9); + + hbox40 = gtk_hbox_new (FALSE, 0); + gtk_widget_ref (hbox40); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "hbox40", hbox40, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (hbox40); + gtk_box_pack_start (GTK_BOX (dialog_vbox9), hbox40, FALSE, FALSE, 0); + + frame21 = gtk_frame_new (_("Budget")); + gtk_widget_ref (frame21); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "frame21", frame21, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (frame21); + gtk_box_pack_start (GTK_BOX (hbox40), frame21, TRUE, TRUE, 0); + gtk_container_set_border_width (GTK_CONTAINER (frame21), 3); + + vbox58 = gtk_vbox_new (FALSE, 0); + gtk_widget_ref (vbox58); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "vbox58", vbox58, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (vbox58); + gtk_container_add (GTK_CONTAINER (frame21), vbox58); + + scrolledwindow5 = gtk_scrolled_window_new (NULL, NULL); + gtk_widget_ref (scrolledwindow5); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "scrolledwindow5", scrolledwindow5, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (scrolledwindow5); + gtk_box_pack_start (GTK_BOX (vbox58), scrolledwindow5, TRUE, TRUE, 0); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow5), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + + viewport2 = gtk_viewport_new (NULL, NULL); + gtk_widget_ref (viewport2); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "viewport2", viewport2, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (viewport2); + gtk_container_add (GTK_CONTAINER (scrolledwindow5), viewport2); + + scrolledwindow6 = gtk_scrolled_window_new (NULL, NULL); + gtk_widget_ref (scrolledwindow6); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "scrolledwindow6", scrolledwindow6, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (scrolledwindow6); + gtk_container_add (GTK_CONTAINER (viewport2), scrolledwindow6); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow6), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + + entry_tree = gtk_ctree_new (1, 0); + gtk_widget_ref (entry_tree); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "entry_tree", entry_tree, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (entry_tree); + gtk_container_add (GTK_CONTAINER (scrolledwindow6), entry_tree); + gtk_clist_set_column_width (GTK_CLIST (entry_tree), 0, 80); + gtk_clist_column_titles_hide (GTK_CLIST (entry_tree)); + + label773 = gtk_label_new (_("label773")); + gtk_widget_ref (label773); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "label773", label773, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label773); + gtk_clist_set_column_widget (GTK_CLIST (entry_tree), 0, label773); + + hbox43 = gtk_hbox_new (FALSE, 0); + gtk_widget_ref (hbox43); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "hbox43", hbox43, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (hbox43); + gtk_box_pack_start (GTK_BOX (vbox58), hbox43, FALSE, FALSE, 1); + + hbuttonbox2 = gtk_hbutton_box_new (); + gtk_widget_ref (hbuttonbox2); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "hbuttonbox2", hbuttonbox2, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (hbuttonbox2); + gtk_box_pack_start (GTK_BOX (hbox43), hbuttonbox2, TRUE, TRUE, 0); + gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox2), GTK_BUTTONBOX_SPREAD); + gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbuttonbox2), 6); + gtk_button_box_set_child_size (GTK_BUTTON_BOX (hbuttonbox2), 75, 0); + + insert_entry_button = gtk_button_new_with_label (_("Insert")); + gtk_widget_ref (insert_entry_button); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "insert_entry_button", insert_entry_button, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (insert_entry_button); + gtk_container_add (GTK_CONTAINER (hbuttonbox2), insert_entry_button); + GTK_WIDGET_SET_FLAGS (insert_entry_button, GTK_CAN_DEFAULT); + + delete_entry_button = gtk_button_new_with_label (_("Delete")); + gtk_widget_ref (delete_entry_button); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "delete_entry_button", delete_entry_button, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (delete_entry_button); + gtk_container_add (GTK_CONTAINER (hbuttonbox2), delete_entry_button); + GTK_WIDGET_SET_FLAGS (delete_entry_button, GTK_CAN_DEFAULT); + + hbox44 = gtk_hbox_new (FALSE, 0); + gtk_widget_ref (hbox44); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "hbox44", hbox44, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (hbox44); + gtk_box_pack_start (GTK_BOX (hbox43), hbox44, FALSE, FALSE, 0); + + up_button = gtk_button_new_with_label (""); + gtk_widget_ref (up_button); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "up_button", up_button, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (up_button); + gtk_box_pack_start (GTK_BOX (hbox44), up_button, FALSE, FALSE, 0); + + down_button = gtk_button_new_with_label (""); + gtk_widget_ref (down_button); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "down_button", down_button, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (down_button); + gtk_box_pack_start (GTK_BOX (hbox44), down_button, FALSE, FALSE, 0); + + vbox52 = gtk_vbox_new (FALSE, 2); + gtk_widget_ref (vbox52); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "vbox52", vbox52, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (vbox52); + gtk_box_pack_start (GTK_BOX (hbox40), vbox52, FALSE, FALSE, 0); + + frame22 = gtk_frame_new (_("Entry")); + gtk_widget_ref (frame22); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "frame22", frame22, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (frame22); + gtk_box_pack_start (GTK_BOX (vbox52), frame22, FALSE, FALSE, 0); + gtk_container_set_border_width (GTK_CONTAINER (frame22), 3); + + hbox34 = gtk_hbox_new (FALSE, 0); + gtk_widget_ref (hbox34); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "hbox34", hbox34, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (hbox34); + gtk_container_add (GTK_CONTAINER (frame22), hbox34); + gtk_container_set_border_width (GTK_CONTAINER (hbox34), 3); + + vbox54 = gtk_vbox_new (TRUE, 0); + gtk_widget_ref (vbox54); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "vbox54", vbox54, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (vbox54); + gtk_box_pack_start (GTK_BOX (hbox34), vbox54, FALSE, FALSE, 0); + gtk_container_set_border_width (GTK_CONTAINER (vbox54), 3); + + label774 = gtk_label_new (_("Description:")); + gtk_widget_ref (label774); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "label774", label774, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label774); + gtk_box_pack_start (GTK_BOX (vbox54), label774, FALSE, FALSE, 0); + gtk_label_set_justify (GTK_LABEL (label774), GTK_JUSTIFY_RIGHT); + gtk_misc_set_alignment (GTK_MISC (label774), 1, 0.5); + + label775 = gtk_label_new (_("Type:")); + gtk_widget_ref (label775); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "label775", label775, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label775); + gtk_box_pack_start (GTK_BOX (vbox54), label775, FALSE, FALSE, 0); + gtk_label_set_justify (GTK_LABEL (label775), GTK_JUSTIFY_RIGHT); + gtk_misc_set_alignment (GTK_MISC (label775), 1, 0.5); + + label776 = gtk_label_new (""); + gtk_widget_ref (label776); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "label776", label776, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label776); + gtk_box_pack_start (GTK_BOX (vbox54), label776, FALSE, FALSE, 0); + gtk_label_set_justify (GTK_LABEL (label776), GTK_JUSTIFY_RIGHT); + gtk_misc_set_alignment (GTK_MISC (label776), 1, 0.5); + + vbox55 = gtk_vbox_new (TRUE, 0); + gtk_widget_ref (vbox55); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "vbox55", vbox55, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (vbox55); + gtk_box_pack_start (GTK_BOX (hbox34), vbox55, TRUE, TRUE, 0); + + entry_description_entry = gtk_entry_new (); + gtk_widget_ref (entry_description_entry); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "entry_description_entry", entry_description_entry, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (entry_description_entry); + gtk_box_pack_start (GTK_BOX (vbox55), entry_description_entry, TRUE, TRUE, 0); + + entry_type_menu = gtk_option_menu_new (); + gtk_widget_ref (entry_type_menu); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "entry_type_menu", entry_type_menu, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (entry_type_menu); + gtk_box_pack_start (GTK_BOX (vbox55), entry_type_menu, TRUE, TRUE, 0); + entry_type_menu_menu = gtk_menu_new (); + glade_menuitem = gtk_menu_item_new_with_label (_("Normal")); + gtk_widget_show (glade_menuitem); + gtk_menu_append (GTK_MENU (entry_type_menu_menu), glade_menuitem); + glade_menuitem = gtk_menu_item_new_with_label (_("No Total")); + gtk_widget_show (glade_menuitem); + gtk_menu_append (GTK_MENU (entry_type_menu_menu), glade_menuitem); + gtk_option_menu_set_menu (GTK_OPTION_MENU (entry_type_menu), entry_type_menu_menu); + + match_button = gtk_button_new_with_label (_("Matching Transactions...")); + gtk_widget_ref (match_button); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "match_button", match_button, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (match_button); + gtk_box_pack_start (GTK_BOX (vbox55), match_button, TRUE, TRUE, 0); + + frame23 = gtk_frame_new (_("Sub-entry")); + gtk_widget_ref (frame23); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "frame23", frame23, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (frame23); + gtk_box_pack_start (GTK_BOX (vbox52), frame23, FALSE, FALSE, 0); + gtk_container_set_border_width (GTK_CONTAINER (frame23), 3); + + hbox35 = gtk_hbox_new (FALSE, 0); + gtk_widget_ref (hbox35); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "hbox35", hbox35, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (hbox35); + gtk_container_add (GTK_CONTAINER (frame23), hbox35); + gtk_container_set_border_width (GTK_CONTAINER (hbox35), 3); + + vbox56 = gtk_vbox_new (TRUE, 0); + gtk_widget_ref (vbox56); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "vbox56", vbox56, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (vbox56); + gtk_box_pack_start (GTK_BOX (hbox35), vbox56, FALSE, FALSE, 0); + gtk_container_set_border_width (GTK_CONTAINER (vbox56), 3); + + label777 = gtk_label_new (_("Description:")); + gtk_widget_ref (label777); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "label777", label777, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label777); + gtk_box_pack_start (GTK_BOX (vbox56), label777, FALSE, FALSE, 0); + gtk_label_set_justify (GTK_LABEL (label777), GTK_JUSTIFY_RIGHT); + gtk_misc_set_alignment (GTK_MISC (label777), 1, 0.5); + + label778 = gtk_label_new (_("Amount:")); + gtk_widget_ref (label778); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "label778", label778, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label778); + gtk_box_pack_start (GTK_BOX (vbox56), label778, FALSE, FALSE, 0); + gtk_label_set_justify (GTK_LABEL (label778), GTK_JUSTIFY_RIGHT); + gtk_misc_set_alignment (GTK_MISC (label778), 1, 0.5); + + label779 = gtk_label_new (_("Period:")); + gtk_widget_ref (label779); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "label779", label779, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label779); + gtk_box_pack_start (GTK_BOX (vbox56), label779, FALSE, FALSE, 0); + gtk_label_set_justify (GTK_LABEL (label779), GTK_JUSTIFY_RIGHT); + gtk_misc_set_alignment (GTK_MISC (label779), 1, 0.5); + + label780 = gtk_label_new (_("Mechanism:")); + gtk_widget_ref (label780); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "label780", label780, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label780); + gtk_box_pack_start (GTK_BOX (vbox56), label780, FALSE, FALSE, 0); + gtk_label_set_justify (GTK_LABEL (label780), GTK_JUSTIFY_RIGHT); + gtk_misc_set_alignment (GTK_MISC (label780), 1, 0.5); + + label781 = gtk_label_new (_("Bill Day:")); + gtk_widget_ref (label781); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "label781", label781, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label781); + gtk_box_pack_start (GTK_BOX (vbox56), label781, FALSE, FALSE, 0); + gtk_label_set_justify (GTK_LABEL (label781), GTK_JUSTIFY_RIGHT); + gtk_misc_set_alignment (GTK_MISC (label781), 1, 0.5); + + label782 = gtk_label_new (_("Grace Period:")); + gtk_widget_ref (label782); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "label782", label782, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label782); + gtk_box_pack_start (GTK_BOX (vbox56), label782, FALSE, FALSE, 0); + gtk_label_set_justify (GTK_LABEL (label782), GTK_JUSTIFY_RIGHT); + gtk_misc_set_alignment (GTK_MISC (label782), 1, 0.5); + + vbox57 = gtk_vbox_new (TRUE, 0); + gtk_widget_ref (vbox57); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "vbox57", vbox57, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (vbox57); + gtk_box_pack_start (GTK_BOX (hbox35), vbox57, TRUE, TRUE, 0); + + sub_description_entry = gtk_entry_new (); + gtk_widget_ref (sub_description_entry); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "sub_description_entry", sub_description_entry, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (sub_description_entry); + gtk_box_pack_start (GTK_BOX (vbox57), sub_description_entry, FALSE, FALSE, 0); + + sub_amount_entry = gtk_entry_new (); + gtk_widget_ref (sub_amount_entry); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "sub_amount_entry", sub_amount_entry, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (sub_amount_entry); + gtk_box_pack_start (GTK_BOX (vbox57), sub_amount_entry, TRUE, TRUE, 0); + + period_box = gtk_hbox_new (FALSE, 0); + gtk_widget_ref (period_box); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "period_box", period_box, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (period_box); + gtk_box_pack_start (GTK_BOX (vbox57), period_box, TRUE, TRUE, 0); + + hbox37 = gtk_hbox_new (FALSE, 0); + gtk_widget_ref (hbox37); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "hbox37", hbox37, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (hbox37); + gtk_box_pack_start (GTK_BOX (vbox57), hbox37, FALSE, FALSE, 0); + + sub_mechanism_menu = gtk_option_menu_new (); + gtk_widget_ref (sub_mechanism_menu); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "sub_mechanism_menu", sub_mechanism_menu, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (sub_mechanism_menu); + gtk_box_pack_start (GTK_BOX (hbox37), sub_mechanism_menu, FALSE, FALSE, 0); + sub_mechanism_menu_menu = gtk_menu_new (); + glade_menuitem = gtk_menu_item_new_with_label (_("Nominal")); + gtk_widget_show (glade_menuitem); + gtk_menu_append (GTK_MENU (sub_mechanism_menu_menu), glade_menuitem); + glade_menuitem = gtk_menu_item_new_with_label (_("Bill")); + gtk_widget_show (glade_menuitem); + gtk_menu_append (GTK_MENU (sub_mechanism_menu_menu), glade_menuitem); + glade_menuitem = gtk_menu_item_new_with_label (_("Recurring")); + gtk_widget_show (glade_menuitem); + gtk_menu_append (GTK_MENU (sub_mechanism_menu_menu), glade_menuitem); + glade_menuitem = gtk_menu_item_new_with_label (_("Contingency")); + gtk_widget_show (glade_menuitem); + gtk_menu_append (GTK_MENU (sub_mechanism_menu_menu), glade_menuitem); + gtk_option_menu_set_menu (GTK_OPTION_MENU (sub_mechanism_menu), sub_mechanism_menu_menu); + + label784 = gtk_label_new (""); + gtk_widget_ref (label784); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "label784", label784, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label784); + gtk_box_pack_start (GTK_BOX (hbox37), label784, TRUE, TRUE, 0); + + bill_day_box = gtk_hbox_new (FALSE, 0); + gtk_widget_ref (bill_day_box); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "bill_day_box", bill_day_box, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (bill_day_box); + gtk_box_pack_start (GTK_BOX (vbox57), bill_day_box, FALSE, FALSE, 0); + + grace_box = gtk_hbox_new (FALSE, 0); + gtk_widget_ref (grace_box); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "grace_box", grace_box, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (grace_box); + gtk_box_pack_start (GTK_BOX (vbox57), grace_box, FALSE, FALSE, 0); + + dialog_action_area9 = GNOME_DIALOG (Budget_Dialog)->action_area; + gtk_object_set_data (GTK_OBJECT (Budget_Dialog), "dialog_action_area9", dialog_action_area9); + gtk_widget_show (dialog_action_area9); + gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area9), GTK_BUTTONBOX_END); + gtk_button_box_set_spacing (GTK_BUTTON_BOX (dialog_action_area9), 8); + + gnome_dialog_append_button (GNOME_DIALOG (Budget_Dialog), GNOME_STOCK_BUTTON_OK); + ok_button = g_list_last (GNOME_DIALOG (Budget_Dialog)->buttons)->data; + gtk_widget_ref (ok_button); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "ok_button", ok_button, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (ok_button); + GTK_WIDGET_SET_FLAGS (ok_button, GTK_CAN_DEFAULT); + + gnome_dialog_append_button (GNOME_DIALOG (Budget_Dialog), GNOME_STOCK_BUTTON_APPLY); + apply_button = g_list_last (GNOME_DIALOG (Budget_Dialog)->buttons)->data; + gtk_widget_ref (apply_button); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "apply_button", apply_button, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (apply_button); + GTK_WIDGET_SET_FLAGS (apply_button, GTK_CAN_DEFAULT); + + gnome_dialog_append_button (GNOME_DIALOG (Budget_Dialog), GNOME_STOCK_BUTTON_CANCEL); + cancel_button = g_list_last (GNOME_DIALOG (Budget_Dialog)->buttons)->data; + gtk_widget_ref (cancel_button); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "cancel_button", cancel_button, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (cancel_button); + GTK_WIDGET_SET_FLAGS (cancel_button, GTK_CAN_DEFAULT); + + gnome_dialog_append_button (GNOME_DIALOG (Budget_Dialog), GNOME_STOCK_BUTTON_HELP); + help_button = g_list_last (GNOME_DIALOG (Budget_Dialog)->buttons)->data; + gtk_widget_ref (help_button); + gtk_object_set_data_full (GTK_OBJECT (Budget_Dialog), "help_button", help_button, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (help_button); + GTK_WIDGET_SET_FLAGS (help_button, GTK_CAN_DEFAULT); + + gtk_signal_connect (GTK_OBJECT (Budget_Dialog), "destroy", + GTK_SIGNAL_FUNC (on_Budget_Dialog_destroy), + Budget_Dialog); + + return Budget_Dialog; +} + diff --git a/src/gnome/glade-gnc-dialogs.h b/src/gnome/glade-gnc-dialogs.h index 1913790454..e8fa8ab9c7 100644 --- a/src/gnome/glade-gnc-dialogs.h +++ b/src/gnome/glade-gnc-dialogs.h @@ -10,3 +10,4 @@ GtkWidget* create_Paper_Size_Selector_Dialog (void); GtkWidget* create_Print_Check_Dialog (void); GtkWidget* create_Find_Transactions (void); GtkWidget* create_Select_Date (void); +GtkWidget* create_Budget_Dialog (void); diff --git a/src/gnome/gnc-dialogs.glade b/src/gnome/gnc-dialogs.glade index d081e71c16..29d1f0eaae 100644 --- a/src/gnome/gnc-dialogs.glade +++ b/src/gnome/gnc-dialogs.glade @@ -19,6 +19,7 @@ glade-cb-gnc-dialogs.h glade-support-gnc-dialogs.c glade-support-gnc-dialogs.h + glade_strings.txt @@ -4004,6 +4005,12 @@ Exactly GnomeDialog Budget Dialog + + destroy + on_Budget Dialog_destroy + Budget_Dialog + Tue, 25 Apr 2000 06:44:25 GMT + Budget GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE @@ -4053,7 +4060,7 @@ Exactly GtkButton - report_button + apply_button True True GNOME_STOCK_BUTTON_APPLY @@ -4092,7 +4099,7 @@ Exactly GnomeDock:contents frame21 3 - + 0 GTK_SHADOW_ETCHED_IN @@ -4161,14 +4168,10 @@ Exactly - GtkHButtonBox - hbuttonbox2 - GTK_BUTTONBOX_SPREAD - 6 - 75 - 0 - 7 - 0 + GtkHBox + hbox43 + False + 0 1 False @@ -4176,19 +4179,71 @@ Exactly - GtkButton - insert_entry_button - True - True - + GtkHButtonBox + hbuttonbox2 + GTK_BUTTONBOX_SPREAD + 6 + 75 + 0 + 7 + 0 + + 0 + True + True + + + + GtkButton + insert_entry_button + True + True + + + + + GtkButton + delete_entry_button + True + True + + - GtkButton - delete_entry_button - True - True - + GtkHBox + hbox44 + False + 0 + + 0 + False + False + + + + GtkButton + up_button + True + + + 0 + False + False + + + + + GtkButton + down_button + True + + + 0 + False + False + + @@ -4303,7 +4358,7 @@ Exactly GtkEntry - entry5 + entry_description_entry True True True @@ -4318,7 +4373,7 @@ Exactly GtkOptionMenu - optionmenu1 + entry_type_menu True Normal No Total @@ -4333,7 +4388,7 @@ No Total GtkButton - button45 + match_button True @@ -4494,7 +4549,7 @@ No Total GtkEntry - entry6 + sub_description_entry True True True @@ -4502,14 +4557,14 @@ No Total 0 - True - True + False + False GtkEntry - entry7 + sub_amount_entry True True True @@ -4524,53 +4579,17 @@ No Total GtkHBox - hbox36 + period_box False 0 0 - False - False + True + True - GtkSpinButton - spinbutton1 - True - 1 - 0 - True - GTK_UPDATE_ALWAYS - False - False - 1 - 1 - 1000 - 1 - 10 - 10 - - 0 - False - False - - - - - GtkOptionMenu - optionmenu4 - True - Days -Weeks -Months -Years - - 0 - - 0 - False - False - + Placeholder @@ -4587,7 +4606,7 @@ Years GtkOptionMenu - optionmenu3 + sub_mechanism_menu True Nominal Bill @@ -4622,7 +4641,7 @@ Contingency GtkHBox - hbox38 + bill_day_box False 0 @@ -4632,49 +4651,13 @@ Contingency - GtkSpinButton - spinbutton2 - True - 1 - 0 - True - GTK_UPDATE_ALWAYS - False - False - 1 - -365 - 365 - 1 - 10 - 10 - - 0 - False - False - - - - - GtkLabel - label783 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - True - True - + Placeholder GtkHBox - hbox39 + grace_box False 0 @@ -4684,72 +4667,7 @@ Contingency - GtkHBox - hbox41 - False - 0 - - 0 - False - False - - - - GtkSpinButton - spinbutton3 - True - 1 - 0 - True - GTK_UPDATE_ALWAYS - False - False - 1 - -365 - 365 - 1 - 10 - 10 - - 0 - True - True - - - - - GtkOptionMenu - optionmenu2 - True - Days -Weeks -Months -Years - - 0 - - 0 - False - False - - - - - - GtkLabel - label785 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - True - True - + Placeholder diff --git a/src/scm/extensions.scm b/src/scm/extensions.scm index a6e272cdc9..145e3ac091 100644 --- a/src/scm/extensions.scm +++ b/src/scm/extensions.scm @@ -46,13 +46,13 @@ (define (gnc:extensions-menu-setup win) (define menu (gnc:make-menu "Extensions" (list "_Settings"))) - + (define export-item (gnc:make-menu-item "Export data as text (Danger: Unfinished)" "Export data as text." (list "Extensions" "") (lambda () (gnc:main-win-export-data-as-text win)))) - + (define qif-item (gnc:make-menu-item "QIF File Import (Danger: Unfinished)" "Import QIF File - Scripted in Guile." diff --git a/src/scm/report/budget-report.scm b/src/scm/report/budget-report.scm index 5def552531..7f714ec0dd 100644 --- a/src/scm/report/budget-report.scm +++ b/src/scm/report/budget-report.scm @@ -1230,3 +1230,17 @@ 'options-generator budget-report-options-generator 'renderer gnc:budget-renderer) +(if (gnc:debugging?) + (let () + (define budget-item + (gnc:make-menu-item + "Budget Dialog (Testing)" + "Test the budget dialog." + (list "Extensions" "") + (lambda () + (gnc:budget-dialog-create + gnc:budget-entries + (lambda () (display "Applied the budget.\n")))))) + + (gnc:hook-add-dangler gnc:*main-window-opened-hook* + (lambda (win) (gnc:add-extension budget-item)))))