diff --git a/po/POTFILES.in b/po/POTFILES.in index 9c25fea263..8411eb71da 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -207,7 +207,6 @@ src/gnome/dialog-sx-editor.c src/gnome/dialog-sx-from-trans.c src/gnome/dialog-sx-since-last-run.c src/gnome/dialog-tax-info.c -src/gnome/glade/budget.glade src/gnome/glade/newuser.glade src/gnome/glade/progress.glade src/gnome/glade/reconcile.glade @@ -229,12 +228,12 @@ src/gnome/gtkbuilder/assistant-acct-period.glade src/gnome/gtkbuilder/assistant-hierarchy.glade src/gnome/gtkbuilder/assistant-loan.glade src/gnome/gtkbuilder/assistant-stock-split.glade -src/gnome/gtkbuilder/budget.glade src/gnome/gtkbuilder/dialog-commodities.glade src/gnome/gtkbuilder/dialog-fincalc.glade src/gnome/gtkbuilder/dialog-lot-viewer.glade src/gnome/gtkbuilder/dialog-price.glade src/gnome/gtkbuilder/dialog-print-check.glade +src/gnome/gtkbuilder/gnc-plugin-page-budget.glade src/gnome/gtkbuilder/newuser.glade src/gnome/gtkbuilder/owner.glade src/gnome/gtkbuilder/progress.glade @@ -359,6 +358,7 @@ src/gnome-utils/gnc-window.c src/gnome-utils/gtkbuilder/dialog-commodity.glade src/gnome-utils/gtkbuilder/dialog-transfer.glade src/gnome-utils/gtkbuilder/gnc-date-format.glade +src/gnome-utils/gtkbuilder/gnc-recurrence.glade src/gnome-utils/misc-gnome-utils.c src/gnome-utils/print-session.c src/gnome-utils/schemas/apps_gnucash_history.schemas.in diff --git a/src/gnome-utils/gnc-recurrence.c b/src/gnome-utils/gnc-recurrence.c index a3ddad09d6..06f9fd56c1 100644 --- a/src/gnome-utils/gnc-recurrence.c +++ b/src/gnome-utils/gnc-recurrence.c @@ -1,34 +1,34 @@ -/* gnc-recurrence.c: - * - */ - -/* Copyright (C) 2005, Chris Shoemaker - * - * 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, contact: - * - * Free Software Foundation Voice: +1-617-542-5942 - * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 - * Boston, MA 02110-1301, USA gnu@gnu.org - */ +/******************************************************************** + * gnc-recurrence.c -- GncRecurrence is a minimal GUI for * + * specifying a Recurrence. * + * * + * You see, small is _nice_. :) * + * Copyright (C) 2005, Chris Shoemaker * + * Copyright (C) 2011, Robert Fewell * + * * + * 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, contact: * + * * + * Free Software Foundation Voice: +1-617-542-5942 * + * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 * + * Boston, MA 02110-1301, USA gnu@gnu.org * + *******************************************************************/ +#include #include "config.h" - -#include -#include - #include "dialog-utils.h" #include "gnc-recurrence.h" +#include "gnc-date-edit.h" #include "Recurrence.h" #include "gnc-engine.h" #include "gnc-gdate-utils.h" @@ -39,12 +39,11 @@ struct _GncRecurrence { GtkVBox widget; - GnomeDateEdit *gde_start; + GtkWidget *gde_start; GtkComboBox *gcb_period; GtkCheckButton *gcb_eom; GtkSpinButton *gsb_mult; GtkCheckButton *nth_weekday; - GladeXML *xml; Recurrence recurrence; }; @@ -71,11 +70,13 @@ typedef enum static GObjectClass *parent_class = NULL; + static UIPeriodType get_pt_ui(GncRecurrence *gr) { return (gtk_combo_box_get_active(gr->gcb_period)); } + static void set_pt_ui(GncRecurrence *gr, PeriodType pt) { UIPeriodType idx; @@ -110,6 +111,7 @@ static void set_pt_ui(GncRecurrence *gr, PeriodType pt) (pt == PERIOD_END_OF_MONTH || pt == PERIOD_LAST_WEEKDAY)); } + static gboolean is_ambiguous_relative(const GDate *date) { @@ -122,6 +124,7 @@ is_ambiguous_relative(const GDate *date) return ((d - 1) / 7 == 3) && (dim - d < 7); } + static gboolean is_ambiguous_absolute(const GDate *date) { @@ -129,6 +132,7 @@ is_ambiguous_absolute(const GDate *date) (g_date_get_day(date) < 31)); } + static void something_changed( GtkWidget *wid, gpointer d ) { @@ -140,7 +144,7 @@ something_changed( GtkWidget *wid, gpointer d ) pt = get_pt_ui(gr); - t = gnome_date_edit_get_time(gr->gde_start); + t = gnc_date_edit_get_date(GNC_DATE_EDIT(gr->gde_start)); g_date_set_time_t(&start, t); if (pt == GNCR_MONTH) @@ -174,35 +178,44 @@ something_changed( GtkWidget *wid, gpointer d ) g_signal_emit_by_name(d, "changed"); } + static void gnc_recurrence_init( GncRecurrence *gr ) { GtkVBox *vb; + GtkHBox *hb; + GtkWidget *w; + GtkBuilder *builder; recurrenceSet(&gr->recurrence, 1, PERIOD_MONTH, NULL, WEEKEND_ADJ_NONE); - gr->xml = gnc_glade_xml_new("budget.glade", "RecurrenceEntryVBox"); - vb = GTK_VBOX(glade_xml_get_widget(gr->xml, "RecurrenceEntryVBox")); - gr->gde_start = GNOME_DATE_EDIT(glade_xml_get_widget(gr->xml, - "GDE_StartDate")); + /* Open up the builder file */ + builder = gtk_builder_new(); + gnc_builder_add_from_file (builder,"gnc-recurrence.glade", "GCB_PeriodType_liststore"); + gnc_builder_add_from_file (builder,"gnc-recurrence.glade", "GSB_Mult_Adj"); + gnc_builder_add_from_file (builder,"gnc-recurrence.glade", "RecurrenceEntryVBox"); + + vb = GTK_VBOX(gtk_builder_get_object (builder, "RecurrenceEntryVBox")); + hb = GTK_HBOX(gtk_builder_get_object (builder, "Startdate_hbox")); + w = gnc_date_edit_new (time (NULL), FALSE, FALSE); + gr->gde_start = w; + gtk_box_pack_start (GTK_BOX (hb), w, TRUE, TRUE, 0); + gtk_widget_show (w); + gtk_widget_set_no_show_all(GTK_WIDGET(gr->gde_start), TRUE); - gr->gcb_period = GTK_COMBO_BOX(glade_xml_get_widget(gr->xml, - "GCB_PeriodType")); - gr->gsb_mult = GTK_SPIN_BUTTON(glade_xml_get_widget(gr->xml, "GSB_Mult")); - gr->gcb_eom = GTK_CHECK_BUTTON(glade_xml_get_widget(gr->xml, - "GCB_EndOfMonth")); - gr->nth_weekday = GTK_CHECK_BUTTON(glade_xml_get_widget(gr->xml, - "GCB_NthWeekday")); + gr->gcb_period = GTK_COMBO_BOX(gtk_builder_get_object (builder, "GCB_PeriodType")); + gr->gsb_mult = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, "GSB_Mult")); + gr->gcb_eom = GTK_CHECK_BUTTON(gtk_builder_get_object (builder, "GCB_EndOfMonth")); + gr->nth_weekday = GTK_CHECK_BUTTON(gtk_builder_get_object (builder, "GCB_NthWeekday")); gtk_widget_set_no_show_all(GTK_WIDGET(gr->gcb_eom), TRUE); gtk_widget_set_no_show_all(GTK_WIDGET(gr->nth_weekday), TRUE); - gtk_container_add( GTK_CONTAINER(&gr->widget), GTK_WIDGET(vb) ); gnc_recurrence_set(gr, &gr->recurrence); something_changed( GTK_WIDGET(gr), gr); - /* respond to changes */ + /* Setup the signals */ g_signal_connect( G_OBJECT(gr->gde_start), "date_changed", G_CALLBACK(something_changed), gr ); g_signal_connect( G_OBJECT(gr->gcb_period), "changed", @@ -215,8 +228,12 @@ gnc_recurrence_init( GncRecurrence *gr ) G_CALLBACK(something_changed), gr ); gtk_widget_show_all( GTK_WIDGET(&gr->widget) ); + + gtk_builder_connect_signals(builder, gr); + g_object_unref(G_OBJECT(builder)); } + void gnc_recurrence_set(GncRecurrence *gr, const Recurrence *r) { @@ -235,12 +252,13 @@ gnc_recurrence_set(GncRecurrence *gr, const Recurrence *r) { time_t t; t = gnc_timet_get_day_start_gdate (&start); - gnome_date_edit_set_time(gr->gde_start, t); + gnc_date_edit_set_time(GNC_DATE_EDIT(gr->gde_start), t); } set_pt_ui(gr, pt); } + const Recurrence * gnc_recurrence_get(GncRecurrence *gr) { @@ -252,7 +270,7 @@ gnc_recurrence_get(GncRecurrence *gr) gboolean use_eom = FALSE, rel; mult = (guint) gtk_spin_button_get_value_as_int(gr->gsb_mult); - t = gnome_date_edit_get_time(gr->gde_start); + t = gnc_date_edit_get_date(GNC_DATE_EDIT(gr->gde_start)); g_date_set_time_t(&start, t); period = get_pt_ui(gr); @@ -311,11 +329,11 @@ gnc_recurrence_get(GncRecurrence *gr) pt = PERIOD_INVALID; } - recurrenceSet(&gr->recurrence, mult, pt, &start, WEEKEND_ADJ_NONE); return &gr->recurrence; - } + + static void gnc_recurrence_finalize(GObject *o) { @@ -325,6 +343,7 @@ gnc_recurrence_finalize(GObject *o) G_OBJECT_CLASS (parent_class)->finalize (o); } + static void gnc_recurrence_class_init( GncRecurrenceClass *klass ) { @@ -347,6 +366,7 @@ gnc_recurrence_class_init( GncRecurrenceClass *klass ) object_class->finalize = gnc_recurrence_finalize; } + GType gnc_recurrence_get_type() { @@ -370,6 +390,7 @@ gnc_recurrence_get_type() return type; } + GtkWidget * gnc_recurrence_new() { @@ -381,10 +402,10 @@ gnc_recurrence_new() return GTK_WIDGET(gr); } + /* TODO: Maybe this stuff should go into another file. * */ - struct _GncRecurrenceComp { GtkScrolledWindow widget; @@ -399,22 +420,27 @@ struct _GncRecurrenceComp GList *rlist; }; + typedef struct { GtkScrolledWindowClass parent_class; void (*changed) (GncRecurrenceComp *gr); } GncRecurrenceCompClass; + typedef enum { GNCRECURRENCECOMP_CHANGED, GNCRC_LAST_SIGNAL } GNCRC_Signals; + static void grc_changed(GtkWidget *w, gpointer data) { g_signal_emit_by_name(data, "changed"); } + + static void addRecurrence(GncRecurrenceComp *grc, GncRecurrence *gr) { @@ -429,6 +455,8 @@ static void addRecurrence(GncRecurrenceComp *grc, GncRecurrence *gr) } + + static void removeRecurrence(GncRecurrenceComp *grc) { GList *children, *last; @@ -446,6 +474,7 @@ static void removeRecurrence(GncRecurrenceComp *grc) } + static void addClicked(GtkButton *b, gpointer data) { GncRecurrenceComp *grc = data; @@ -455,6 +484,7 @@ static void addClicked(GtkButton *b, gpointer data) addRecurrence(grc, gr); } + static void removeClicked(GtkButton *b, gpointer data) { GncRecurrenceComp *grc = data; @@ -463,6 +493,7 @@ static void removeClicked(GtkButton *b, gpointer data) removeRecurrence(grc); } + void gnc_recurrence_comp_set_list(GncRecurrenceComp *grc, const GList *rlist) { @@ -482,6 +513,7 @@ gnc_recurrence_comp_set_list(GncRecurrenceComp *grc, const GList *rlist) } } + GList * gnc_recurrence_comp_get_list(GncRecurrenceComp *grc) { @@ -540,6 +572,7 @@ gnc_recurrence_comp_init(GncRecurrenceComp *grc) addClicked(NULL, grc); } + static void gnc_recurrence_comp_class_init( GncRecurrenceCompClass *klass ) { @@ -562,6 +595,7 @@ gnc_recurrence_comp_class_init( GncRecurrenceCompClass *klass ) //object_class->finalize = gnc_recurrence_finalize; } + GType gnc_recurrence_comp_get_type() { @@ -585,6 +619,7 @@ gnc_recurrence_comp_get_type() return type; } + GtkWidget * gnc_recurrence_comp_new() { diff --git a/src/gnome-utils/gtkbuilder/Makefile.am b/src/gnome-utils/gtkbuilder/Makefile.am index ef3da2fa48..cc7336f538 100644 --- a/src/gnome-utils/gtkbuilder/Makefile.am +++ b/src/gnome-utils/gtkbuilder/Makefile.am @@ -2,6 +2,7 @@ gtkbuilderdir = $(GNC_GTKBUILDER_DIR) gtkbuilder_DATA = \ dialog-commodity.glade \ dialog-transfer.glade \ - gnc-date-format.glade + gnc-date-format.glade \ + gnc-recurrence.glade EXTRA_DIST = $(gtkbuilder_DATA) diff --git a/src/gnome-utils/gtkbuilder/gnc-recurrence.glade b/src/gnome-utils/gtkbuilder/gnc-recurrence.glade new file mode 100644 index 0000000000..2f6bfdb35f --- /dev/null +++ b/src/gnome-utils/gtkbuilder/gnc-recurrence.glade @@ -0,0 +1,185 @@ + + + + + + + + + + + + day(s) + + + week(s) + + + month(s) + + + year(s) + + + + + 1 + 250 + 1 + 1 + 10 + + + True + False + + + True + False + + + True + False + + + True + False + Every + + + False + False + 0 + + + + + True + True + Number of calendar units in the recurrence: E.g. Biweekly = every 2 weeks; Quarterly = every 3 months + False + False + True + True + GSB_Mult_Adj + 1 + True + + + False + True + 1 + + + + + True + False + GCB_PeriodType_liststore + + + + 0 + + + + + True + True + 2 + + + + + True + True + 0 + + + + + True + False + + + True + False + 0 + beginning on: + + + False + False + 0 + + + + + True + False + + + + + + True + True + 1 + + + + + True + True + 1 + + + + + True + False + + + last of month + True + True + False + Always use the last day (or day of week) in the month? + False + True + True + + + False + False + 0 + + + + + same week & day + True + True + False + Match the "day of week" and "week of month"? (for example, the "second Tuesday" of every month) + False + True + True + + + False + False + 1 + + + + + True + True + 2 + + + + + + diff --git a/src/gnome/glade/Makefile.am b/src/gnome/glade/Makefile.am index 084ad4580b..ea4e7c12ae 100644 --- a/src/gnome/glade/Makefile.am +++ b/src/gnome/glade/Makefile.am @@ -1,6 +1,5 @@ gladedir = $(GNC_GLADE_DIR) glade_DATA = \ - budget.glade \ newuser.glade \ progress.glade \ reconcile.glade \ diff --git a/src/gnome/glade/budget.glade b/src/gnome/glade/budget.glade deleted file mode 100644 index 8da7fe7c26..0000000000 --- a/src/gnome/glade/budget.glade +++ /dev/null @@ -1,628 +0,0 @@ - - - - - - - - True - 6 - Budget List - dialog - - - True - vertical - 6 - - - True - - - True - True - 5 - in - - - 250 - 200 - True - True - 10 - - - - - 0 - - - - - True - 5 - vertical - spread - - - gtk-new - True - True - True - False - Create a New Budget - True - - - False - False - 0 - - - - - gtk-open - True - True - True - False - Open the Selected Budget - True - - - False - False - 1 - - - - - gtk-delete - True - True - True - False - Delete the Selected Budget - True - - - False - False - 2 - - - - - False - 1 - - - - - 2 - - - - - True - end - - - gtk-close - -7 - True - True - True - False - Close the Budget List - True - - - False - False - 0 - - - - - False - end - 0 - - - - - - - True - Options - True - dialog - - - True - vertical - - - True - True - - - True - 5 - 3 - 3 - 3 - - - True - 0 - 0 - Budget Name: - - - GTK_FILL - - - - - - True - True - - - 1 - 2 - - - - - - True - 0 - Notes: - - - 1 - 2 - GTK_FILL - - - - - - True - True - - - True - True - - - - - 1 - 2 - 1 - 2 - GTK_FILL - GTK_FILL - - - - - True - - - True - gnc_recurrence_new - - - 0 - - - - - 1 - 2 - 3 - 4 - GTK_FILL - GTK_FILL - - - - - True - 0 - Number of Periods: - - - 4 - 5 - GTK_FILL - - - - - - True - True - 1 1 60 1 12 0 - 1 - True - - - 1 - 2 - 4 - 5 - - - - - - True - 0 - Budget Period: - - - 3 - 4 - GTK_FILL - - - - - - True - - - 1 - 2 - 2 - 3 - GTK_FILL - - - - - True - - - 2 - 3 - GTK_FILL - GTK_FILL - - - - - - - - - - - - - - - - - - - - - - True - Budget Options - - - False - tab - - - - - 2 - - - - - True - end - - - False - end - 0 - - - - - - - True - - - True - vertical - - - True - - - True - Every - - - False - False - 0 - - - - - True - True - Number of calendar units in the recurrence: E.g. Biweekly = every 2 weeks; Quarterly = every 3 months - 1 1 250 1 10 0 - 1 - True - - - False - 1 - - - - - True - day(s) -week(s) -month(s) -year(s) - - - 2 - - - - - 0 - - - - - True - - - True - 0 - beginning on: - - - False - False - 0 - - - - - True - GNOME_DATE_EDIT_24_HR - - - 1 - - - - - 1 - - - - - True - - - last of month - True - True - False - Always use the last day (or day of week) in the month? - True - True - - - False - False - 0 - - - - - same week & day - True - True - False - Match the "day of week" and "week of month"? (for example, the "second Tuesday" of every month) - True - True - - - False - False - 1 - - - - - 2 - - - - - - - True - Estimate Budget Values - True - dialog - - - True - vertical - - - True - vertical - - - True - GnuCash will estimate budget values for the selected accounts from past transactions. - True - - - False - False - 0 - - - - - - - - - - - 2 - - - - - True - 3 - 3 - - - True - 0 - Start Date: - - - GTK_FILL - - - - - - True - 0 - Significant Digits: - - - 1 - 2 - GTK_FILL - - - - - - True - True - The number of leading digits to keep when rounding - 1 1 12 1 1 0 - 1 - True - - - 1 - 2 - 1 - 2 - - - - - - True - gnc_date_edit_new_glade - - - 1 - 2 - GTK_FILL - GTK_FILL - - - - - - - - - - - - - - - - - - - - 3 - - - - - True - end - - - gtk-cancel - -6 - True - True - True - False - True - - - False - False - 0 - - - - - gtk-ok - -5 - True - True - True - False - True - - - False - False - 1 - - - - - False - end - 0 - - - - - - diff --git a/src/gnome/gnc-plugin-budget.h b/src/gnome/gnc-plugin-budget.h index f32501980f..5a1f6c2951 100644 --- a/src/gnome/gnc-plugin-budget.h +++ b/src/gnome/gnc-plugin-budget.h @@ -42,7 +42,6 @@ G_BEGIN_DECLS #define GNC_PLUGIN_BUDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_PLUGIN_BUDGET, GncPluginBudgetClass)) #define GNC_PLUGIN_BUDGET_NAME "gnc-plugin-budget" -#define GNC_BUDGET_GUI_FILE "budget.glade" /* typedefs & structures */ typedef struct diff --git a/src/gnome/gnc-plugin-page-budget.c b/src/gnome/gnc-plugin-page-budget.c index 37577ddcf7..01166b6a6c 100644 --- a/src/gnome/gnc-plugin-page-budget.c +++ b/src/gnome/gnc-plugin-page-budget.c @@ -1,27 +1,27 @@ -/* - * gnc-plugin-page-budget.c -- - * - * Copyright (C) 2005-2006 Chris Shoemaker - * (based on gnc-plugin-page-account-tree.c) - * - * 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, contact: - * - * Free Software Foundation Voice: +1-617-542-5942 - * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 - * Boston, MA 02110-1301, USA gnu@gnu.org - */ - +/******************************************************************** + * gnc-plugin-page-budget.c -- Budget plugin based on * + * gnc-plugin-page-account-tree.c * + * * + * Copyright (C) 2005, Chris Shoemaker * + * Copyright (C) 2011, Robert Fewell * + * * + * 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, contact: * + * * + * Free Software Foundation Voice: +1-617-542-5942 * + * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 * + * Boston, MA 02110-1301, USA gnu@gnu.org * + *******************************************************************/ /* * TODO: @@ -118,8 +118,6 @@ static void gnc_plugin_page_budget_cmd_view_options( static void gnc_plugin_page_budget_cmd_estimate_budget( GtkAction *action, GncPluginPageBudget *page); - - static GtkActionEntry gnc_plugin_page_budget_actions [] = { /* Toplevel */ @@ -197,7 +195,7 @@ typedef struct GncPluginPageBudgetPrivate GncBudget* budget; GncGUID key; - GncDialog* d; + GtkWidget *dialog; /* To distinguish between closing a tab and deleting a budget */ gboolean delete_budget; @@ -214,6 +212,7 @@ typedef struct GncPluginPageBudgetPrivate static GObjectClass *parent_class = NULL; + GType gnc_plugin_page_budget_get_type (void) { @@ -242,6 +241,7 @@ gnc_plugin_page_budget_get_type (void) return gnc_plugin_page_budget_type; } + GncPluginPage * gnc_plugin_page_budget_new (GncBudget *budget) { @@ -279,6 +279,7 @@ gnc_plugin_page_budget_new (GncBudget *budget) return GNC_PLUGIN_PAGE(plugin_page); } + static void gnc_plugin_page_budget_class_init (GncPluginPageBudgetClass *klass) { @@ -299,6 +300,7 @@ gnc_plugin_page_budget_class_init (GncPluginPageBudgetClass *klass) g_type_class_add_private(klass, sizeof(GncPluginPageBudgetPrivate)); } + static void gnc_plugin_page_budget_init (GncPluginPageBudget *plugin_page) { @@ -342,6 +344,7 @@ gnc_plugin_page_budget_init (GncPluginPageBudget *plugin_page) plugin_page, priv, action_group); } + static void gnc_plugin_page_budget_finalize (GObject *object) { @@ -368,6 +371,7 @@ gnc_plugin_page_budget_close_cb (gpointer user_data) gnc_main_window_close_page (page); } + static void gnc_plugin_page_budget_refresh_cb(GHashTable *changes, gpointer user_data) { @@ -397,9 +401,9 @@ gnc_plugin_page_budget_refresh_cb(GHashTable *changes, gpointer user_data) } -/* - * GncPluginPage Functions - */ +/**************************** + * GncPluginPage Functions * + ***************************/ static GtkWidget * gnc_plugin_page_budget_create_widget (GncPluginPage *plugin_page) { @@ -483,6 +487,7 @@ gnc_plugin_page_budget_create_widget (GncPluginPage *plugin_page) return priv->widget; } + static void gnc_plugin_page_budget_destroy_widget (GncPluginPage *plugin_page) { @@ -521,17 +526,20 @@ gnc_plugin_page_budget_destroy_widget (GncPluginPage *plugin_page) LEAVE("widget destroyed"); } + #define BUDGET_GUID "Budget GncGUID" -/** Save enough information about this plugin page that it can - * be recreated next time the user starts gnucash. - * - * @param page The page to save. - * - * @param key_file A pointer to the GKeyFile data structure where the - * page information should be written. - * - * @param group_name The group name to use when saving data. */ +/*********************************************************************** + * Save enough information about this plugin page that it can * + * be recreated next time the user starts gnucash. * + * * + * @param page The page to save. * + * * + * @param key_file A pointer to the GKeyFile data structure where the * + * page information should be written. * + * * + * @param group_name The group name to use when saving data. * + **********************************************************************/ static void gnc_plugin_page_budget_save_page (GncPluginPage *plugin_page, GKeyFile *key_file, const gchar *group_name) @@ -560,8 +568,8 @@ gnc_plugin_page_budget_save_page (GncPluginPage *plugin_page, } - -/** Create a new plugin page based on the information saved +/*********************************************************************** + * Create a new plugin page based on the information saved * during a previous instantiation of gnucash. * * @param window The window where this page should be installed. @@ -569,7 +577,8 @@ gnc_plugin_page_budget_save_page (GncPluginPage *plugin_page, * @param key_file A pointer to the GKeyFile data structure where the * page information should be read. * - * @param group_name The group name to use when restoring data. */ + * @param group_name The group name to use when restoring data. + **********************************************************************/ static GncPluginPage * gnc_plugin_page_budget_recreate_page (GtkWidget *window, GKeyFile *key_file, const gchar *group_name) @@ -620,13 +629,16 @@ gnc_plugin_page_budget_recreate_page (GtkWidget *window, GKeyFile *key_file, return page; } -/** This button press handler calls the common button press handler + +/*********************************************************************** + * This button press handler calls the common button press handler * for all pages. The GtkTreeView eats all button presses and * doesn't pass them up the widget tree, even when it doesn't do * anything with them. The only way to get access to the button * presses in an account tree page is here on the tree view widget. * Button presses on all other pages are caught by the signal - * registered in gnc-main-window.c. */ + * registered in gnc-main-window.c. + **********************************************************************/ static gboolean gppb_button_press_cb(GtkWidget *widget, GdkEventButton *event, GncPluginPage *page) @@ -641,6 +653,7 @@ gppb_button_press_cb(GtkWidget *widget, GdkEventButton *event, return result; } + static gboolean gppb_key_press_cb(GtkWidget *treeview, GdkEventKey *event, gpointer userdata) { @@ -671,6 +684,7 @@ gppb_key_press_cb(GtkWidget *treeview, GdkEventKey *event, gpointer userdata) return TRUE; } + static void gppb_double_click_cb(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *col, GncPluginPageBudget *page) @@ -690,6 +704,7 @@ gppb_double_click_cb(GtkTreeView *treeview, GtkTreePath *path, gnc_main_window_open_page(GNC_MAIN_WINDOW(window), new_page); } + static void gppb_selection_changed_cb(GtkTreeSelection *selection, GncPluginPageBudget *page) @@ -722,8 +737,10 @@ gppb_selection_changed_cb(GtkTreeSelection *selection, "sensitive", sensitive); } -/* Command callbacks */ +/********************* + * Command callbacks * + ********************/ static void gnc_plugin_page_budget_cmd_open_account (GtkAction *action, GncPluginPageBudget *page) @@ -749,6 +766,7 @@ gnc_plugin_page_budget_cmd_open_account (GtkAction *action, g_list_free(acct_list); } + static void gnc_plugin_page_budget_cmd_open_subaccounts (GtkAction *action, GncPluginPageBudget *page) @@ -774,6 +792,7 @@ gnc_plugin_page_budget_cmd_open_subaccounts (GtkAction *action, g_list_free(acct_list); } + static void gnc_plugin_page_budget_cmd_delete_budget (GtkAction *action, GncPluginPageBudget *page) @@ -789,134 +808,96 @@ gnc_plugin_page_budget_cmd_delete_budget (GtkAction *action, } + /******************************/ /* Options Dialog */ /******************************/ - -static gboolean -gnc_plugin_page_budget_options_apply_cb (GncDialog * d, - gpointer user_data) -{ - GncPluginPageBudget *page = user_data; - GncPluginPageBudgetPrivate *priv; - gchar *name; - gchar *desc; - gint num_periods; - GncRecurrence *gr; - const Recurrence *r; - - if (!page) - return TRUE; - - ENTER(" "); - priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(page); - name = gnc_dialog_get_string(d, "BudgetName"); - if (name) - { - gchar* label; - - gnc_budget_set_name(priv->budget, name); - label = g_strdup_printf("%s: %s", _("Budget"), name); - main_window_update_page_name(GNC_PLUGIN_PAGE(page), label); - g_free(label); - DEBUG("%s", name); - g_free(name); - } - - desc = (gchar *) gnc_dialog_get_string(d, "BudgetDescription"); - gnc_budget_set_description(priv->budget, desc); - g_free(desc); - - num_periods = gnc_dialog_get_int(d, "BudgetNumPeriods"); - gnc_budget_set_num_periods(priv->budget, num_periods); - - gr = GNC_RECURRENCE(gnc_dialog_get_widget(d, "BudgetRecurrenceEntry")); - r = gnc_recurrence_get(gr); - gnc_budget_set_recurrence(priv->budget, r); - - LEAVE(" "); - return TRUE; -} - -static gboolean -gnc_plugin_page_budget_options_help_cb (GncDialog *d, - gpointer user_data) -{ - GtkWidget *dialog; - - dialog = gtk_message_dialog_new (NULL, - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - "%s", - _("Set the budget options using this dialog.")); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - return TRUE; -} - -static gboolean -gnc_plugin_page_budget_options_close_cb (GncDialog *d, - gpointer user_data) -{ - GncPluginPageBudget *page = user_data; - GncPluginPageBudgetPrivate *priv; - - g_return_val_if_fail(page, TRUE); - - priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(page); - gtk_widget_destroy(GTK_WIDGET(d)); - priv->d = NULL; - return TRUE; -} - - -static void -gnc_budget_gui_show_options(GncDialog *pw, GncBudget *budget, - GncPluginPageBudget *page) -{ - GncRecurrence *gr; - GncPluginPageBudgetPrivate *priv; - - - g_return_if_fail (GNC_IS_PLUGIN_PAGE_BUDGET (page)); - priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(page); - - gnc_dialog_set_string(pw, "BudgetName", - gnc_budget_get_name(budget)); - gnc_dialog_set_string(pw, "BudgetDescription", - gnc_budget_get_description(budget)); - gnc_dialog_set_int(pw, "BudgetNumPeriods", - gnc_budget_get_num_periods(budget)); - gr = GNC_RECURRENCE(gnc_dialog_get_widget( - pw, "BudgetRecurrenceEntry")); - gnc_recurrence_set(gr, gnc_budget_get_recurrence(budget)); -} - - static void gnc_plugin_page_budget_cmd_view_options (GtkAction *action, GncPluginPageBudget *page) { GncPluginPageBudgetPrivate *priv; + GncRecurrence *gr; + GtkBuilder *builder; + gint result; + gchar *name; + gchar *desc; + gint num_periods; + GtkWidget *gbname, *gbtreeview, *gbnumperiods, *gbhb; + const Recurrence *r; + + GtkTextBuffer *buffer; + GtkTextIter start, end; g_return_if_fail (GNC_IS_PLUGIN_PAGE_BUDGET (page)); priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(page); - if (!priv->d) + if (!priv->dialog) { - priv->d = gnc_dialog_new(GNC_BUDGET_GUI_FILE, "BudgetOptions"); - gtk_window_set_title(GTK_WINDOW(priv->d), _("Budget Options")); - gnc_dialog_set_cb(priv->d, - gnc_plugin_page_budget_options_apply_cb, - gnc_plugin_page_budget_options_close_cb, - gnc_plugin_page_budget_options_help_cb, - page); - } + builder = gtk_builder_new(); + gnc_builder_add_from_file (builder, "gnc-plugin-page-budget.glade", "NumPeriods_Adj"); + gnc_builder_add_from_file (builder, "gnc-plugin-page-budget.glade", "OptionsContainer"); - gnc_budget_gui_show_options(priv->d, priv->budget, page); - gtk_widget_show_all(GTK_WIDGET(priv->d)); + priv->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "OptionsContainer")); + + gtk_window_set_transient_for( + GTK_WINDOW(priv->dialog), + GTK_WINDOW(gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(page)))); + + gbname = GTK_WIDGET(gtk_builder_get_object (builder, "BudgetName")); + gtk_entry_set_text(GTK_ENTRY(gbname), gnc_budget_get_name(priv->budget)); + + gbtreeview = GTK_WIDGET(gtk_builder_get_object (builder, "BudgetDescription")); + buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gbtreeview)); + gtk_text_buffer_set_text (buffer, gnc_budget_get_description(priv->budget), -1); + + gbhb = GTK_WIDGET(gtk_builder_get_object (builder, "BudgetPeriod")); + gr = GNC_RECURRENCE(gnc_recurrence_new()); + gnc_recurrence_set(gr, gnc_budget_get_recurrence(priv->budget)); + gtk_box_pack_start (GTK_BOX (gbhb), GTK_WIDGET(gr), TRUE, TRUE, 0); + gtk_widget_show (GTK_WIDGET(gr)); + + gbnumperiods = GTK_WIDGET(gtk_builder_get_object (builder, "BudgetNumPeriods")); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(gbnumperiods), gnc_budget_get_num_periods(priv->budget)); + + gtk_widget_show_all (priv->dialog); + result = gtk_dialog_run(GTK_DIALOG(priv->dialog)); + + switch (result) + { + case GTK_RESPONSE_OK: + name = (gchar *) gtk_entry_get_text(GTK_ENTRY(gbname)); + DEBUG("%s", name); + if (name) + { + gchar* label; + gnc_budget_set_name(priv->budget, name); + label = g_strdup_printf("%s: %s", _("Budget"), name); + main_window_update_page_name(GNC_PLUGIN_PAGE(page), label); + g_free(label); + } + + gtk_text_buffer_get_bounds (gtk_text_view_get_buffer(GTK_TEXT_VIEW (gbtreeview)), &start, &end); + desc = gtk_text_buffer_get_text (gtk_text_view_get_buffer(GTK_TEXT_VIEW (gbtreeview)), &start, &end, TRUE); + + gnc_budget_set_description(priv->budget, desc); + g_free(desc); + + num_periods = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(gbnumperiods)); + gnc_budget_set_num_periods(priv->budget, num_periods); + + r = gnc_recurrence_get(gr); + gnc_budget_set_recurrence(priv->budget, r); + break; + case GTK_RESPONSE_CANCEL: + break; + default: + break; + } + g_object_unref(G_OBJECT(builder)); + gtk_widget_destroy(priv->dialog); + } + priv->dialog = NULL; } @@ -930,7 +911,6 @@ gnc_budget_gui_delete_budget(GncBudget *budget) if (!name) name = _("Unnamed Budget"); - if (gnc_verify_dialog (NULL, FALSE, _("Delete %s?"), name)) { gnc_suspend_gui_refresh (); @@ -938,9 +918,9 @@ gnc_budget_gui_delete_budget(GncBudget *budget) // Views should close themselves because the CM will notify them. gnc_resume_gui_refresh (); } - } + static void estimate_budget_helper(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) @@ -976,17 +956,21 @@ estimate_budget_helper(GtkTreeModel *model, GtkTreePath *path, } } + +/*******************************/ +/* Estimate Dialog */ +/*******************************/ static void gnc_plugin_page_budget_cmd_estimate_budget(GtkAction *action, GncPluginPageBudget *page) { GncPluginPageBudgetPrivate *priv; GtkTreeSelection *sel; - GtkWidget *dialog, *gde, *dtr; + GtkWidget *dialog, *gde, *dtr, *hb; gint result; GDate date; const Recurrence *r; - GladeXML *xml; + GtkBuilder *builder; g_return_if_fail (GNC_IS_PLUGIN_PAGE_BUDGET(page)); priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(page); @@ -1005,15 +989,25 @@ gnc_plugin_page_budget_cmd_estimate_budget(GtkAction *action, return; } - xml = gnc_glade_xml_new ("budget.glade", "BudgetEstimate"); - dialog = glade_xml_get_widget (xml, "BudgetEstimate"); + builder = gtk_builder_new(); + gnc_builder_add_from_file (builder, "gnc-plugin-page-budget.glade", "DigitsToRound_Adj"); + gnc_builder_add_from_file (builder, "gnc-plugin-page-budget.glade", "BudgetEstimate"); + + dialog = GTK_WIDGET(gtk_builder_get_object (builder, "BudgetEstimate")); + gtk_window_set_transient_for( GTK_WINDOW(dialog), GTK_WINDOW(gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(page)))); - gde = glade_xml_get_widget(xml, "StartDate"); + + hb = GTK_WIDGET(gtk_builder_get_object (builder, "StartDate_hbox")); + gde = gnc_date_edit_new (time (NULL), FALSE, FALSE); + gtk_box_pack_start (GTK_BOX (hb), gde, TRUE, TRUE, 0); + gtk_widget_show (gde); + date = recurrenceGetDate(&priv->r); gnc_date_edit_set_gdate(GNC_DATE_EDIT(gde), &date); - dtr = glade_xml_get_widget(xml, "DigitsToRound"); + + dtr = GTK_WIDGET(gtk_builder_get_object (builder, "DigitsToRound")); gtk_spin_button_set_value(GTK_SPIN_BUTTON(dtr), (gdouble)priv->sigFigs); @@ -1037,8 +1031,10 @@ gnc_plugin_page_budget_cmd_estimate_budget(GtkAction *action, break; } gtk_widget_destroy(dialog); + g_object_unref(G_OBJECT(builder)); } + static gchar * budget_col_source(Account *account, GtkTreeViewColumn *col, GtkCellRenderer *cell) @@ -1070,10 +1066,10 @@ budget_col_source(Account *account, GtkTreeViewColumn *col, gnc_account_print_info(account, FALSE)); } } - return g_strdup(amtbuff); } + static void budget_col_edited(Account *account, GtkTreeViewColumn *col, const gchar *new_text) @@ -1098,6 +1094,7 @@ budget_col_edited(Account *account, GtkTreeViewColumn *col, numeric); } + static void gnc_plugin_page_budget_refresh_col_titles(GncPluginPageBudget *page) { @@ -1132,6 +1129,7 @@ gnc_plugin_page_budget_refresh_col_titles(GncPluginPageBudget *page) } + static void gnc_plugin_page_budget_view_refresh (GncPluginPageBudget *page) { @@ -1175,6 +1173,7 @@ gnc_plugin_page_budget_view_refresh (GncPluginPageBudget *page) gnc_plugin_page_budget_refresh_col_titles(page); } + static void gnc_plugin_page_budget_cmd_view_filter_by (GtkAction *action, GncPluginPageBudget *page) diff --git a/src/gnome/gtkbuilder/Makefile.am b/src/gnome/gtkbuilder/Makefile.am index bac8774705..022b7e98e2 100644 --- a/src/gnome/gtkbuilder/Makefile.am +++ b/src/gnome/gtkbuilder/Makefile.am @@ -5,12 +5,12 @@ gtkbuilder_DATA = \ assistant-hierarchy.glade \ assistant-loan.glade \ assistant-stock-split.glade \ - budget.glade \ dialog-commodities.glade \ dialog-lot-viewer.glade \ dialog-fincalc.glade \ dialog-price.glade \ dialog-print-check.glade \ + gnc-plugin-page-budget.glade \ newuser.glade \ owner.glade \ progress.glade \ diff --git a/src/gnome/gtkbuilder/budget.glade b/src/gnome/gtkbuilder/gnc-plugin-page-budget.glade similarity index 78% rename from src/gnome/gtkbuilder/budget.glade rename to src/gnome/gtkbuilder/gnc-plugin-page-budget.glade index 5d08d438ab..18f72ea563 100644 --- a/src/gnome/gtkbuilder/budget.glade +++ b/src/gnome/gtkbuilder/gnc-plugin-page-budget.glade @@ -2,39 +2,51 @@ - - - - - - - - day(s) - - - week(s) - - - month(s) - - - year(s) - - - - + True + False 6 Budget List dialog True - vertical + False 6 + + + True + False + end + + + gtk-close + True + True + True + False + Close the Budget List + False + True + + + False + False + 0 + + + + + False + True + end + 0 + + True + False True @@ -52,14 +64,16 @@ + True + True 0 True + False 5 - vertical spread @@ -69,6 +83,7 @@ True False Create a New Budget + False True @@ -85,6 +100,7 @@ True False Open the Selected Budget + False True @@ -101,6 +117,7 @@ True False Delete the Selected Budget + False True @@ -112,26 +129,47 @@ False + True 1 + True + True 2 + + + + close_button + + + + True + False + 5 + Estimate Budget Values + True + dialog + + + True + False - + True + False end - - gtk-close + + gtk-cancel True True True False - Close the Budget List + False True @@ -140,35 +178,171 @@ 0 + + + gtk-ok + True + True + True + False + False + True + + + False + False + 1 + + + + + False + True + end + 0 + + + + + True + False + + + True + False + GnuCash will estimate budget values for the selected accounts from past transactions. + True + + + False + False + 0 + + - False - end - 0 + True + False + 2 + + + + + True + False + 2 + 3 + + + True + False + 0 + Start Date: + + + GTK_FILL + + + + + + True + False + 0 + Significant Digits: + + + 1 + 2 + GTK_FILL + + + + + + True + True + The number of leading digits to keep when rounding + False + False + True + True + DigitsToRound_Adj + 1 + True + + + 1 + 2 + 1 + 2 + + + + + + True + False + + + + + + 1 + 3 + GTK_FILL + + + + + + + + True + False + 3 - close_button + cancelbutton1 + okbutton1 + + 1 + 12 + 1 + 1 + 1 + + + 1 + 60 + 1 + 1 + 12 + True - Options + False + Budget Options True dialog True - vertical + False True True + 5 True + False 5 3 3 @@ -176,6 +350,7 @@ True + False 0 0 Budget Name: @@ -183,12 +358,17 @@ GTK_FILL + 3 True True + False + False + True + True 1 @@ -199,6 +379,7 @@ True + False 0 Notes: @@ -207,6 +388,7 @@ 2 GTK_FILL + 3 @@ -230,8 +412,9 @@ - + True + False @@ -248,6 +431,7 @@ True + False 0 Number of Periods: @@ -256,13 +440,18 @@ 5 GTK_FILL + 3 True True - adjustment3 + False + False + True + True + NumPeriods_Adj 1 True @@ -277,6 +466,7 @@ True + False 0 Budget Period: @@ -285,11 +475,13 @@ 4 GTK_FILL + 3 True + False 1 @@ -302,6 +494,7 @@ True + False 2 @@ -330,6 +523,7 @@ True + False Budget Options @@ -338,315 +532,71 @@ - 2 + True + True + 0 + + + True - end - - - False - end - 0 - - - - - - - True - - - True - vertical - - - True - - - True - Every - - - False - False - 0 - - - - - True - True - Number of calendar units in the recurrence: E.g. Biweekly = every 2 weeks; Quarterly = every 3 months - adjustment2 - 1 - True - - - False - 1 - - - - - True - liststore1 - - - - 0 - - - - - 2 - - - - - 0 - - - - - True - - - True - 0 - beginning on: - - - False - False - 0 - - - - - - - - 1 - - - - - True - - - last of month - True - True - False - Always use the last day (or day of week) in the month? - True - True - - - False - False - 0 - - - - - same week & day - True - True - False - Match the "day of week" and "week of month"? (for example, the "second Tuesday" of every month) - True - True - - - False - False - 1 - - - - - 2 - - - - - - - True - Estimate Budget Values - True - dialog - - - True - vertical - - - True - vertical - - - True - GnuCash will estimate budget values for the selected accounts from past transactions. - True - - - False - False - 0 - - - - - - - - - - - 2 - - - - - True - 3 - 3 - - - True - 0 - Start Date: - - - GTK_FILL - - - - - - True - 0 - Significant Digits: - - - 1 - 2 - GTK_FILL - - - - - - True - True - The number of leading digits to keep when rounding - adjustment1 - 1 - True - - - 1 - 2 - 1 - 2 - - - - - - - - - - - - - - - - - - - - - - - - 3 - - - - - True + False end - + + + + + + + gtk-cancel True True - True - False + True + False True False False - 0 + 2 - + gtk-ok True True - True - False + True + False True False False - 1 + 3 False + True end - 0 + 2 + + + - cancelbutton1 - okbutton1 + cancelbutton2 + okbutton2 - - 1 - 1 - 12 - 1 - 1 - - - 1 - 1 - 250 - 1 - 10 - - - 1 - 1 - 60 - 1 - 12 -