r21148 - gnucash/trunk - Rename lot viewer related files to be more in line with other dialogs
Geert Janssens
gjanssens at code.gnucash.org
Wed Aug 10 17:10:42 EDT 2011
Author: gjanssens
Date: 2011-08-10 17:10:42 -0400 (Wed, 10 Aug 2011)
New Revision: 21148
Trac: http://svn.gnucash.org/trac/changeset/21148
Added:
gnucash/trunk/src/gnome/dialog-lot-viewer.c
gnucash/trunk/src/gnome/dialog-lot-viewer.h
gnucash/trunk/src/gnome/gtkbuilder/dialog-lot-viewer.glade
Removed:
gnucash/trunk/src/gnome/gtkbuilder/lots.glade
gnucash/trunk/src/gnome/lot-viewer.c
gnucash/trunk/src/gnome/lot-viewer.h
Modified:
gnucash/trunk/po/POTFILES.in
gnucash/trunk/src/business/business-gnome/gnc-plugin-page-owner-tree.c
gnucash/trunk/src/engine/gnc-lot.c
gnucash/trunk/src/gnome/Makefile.am
gnucash/trunk/src/gnome/gnc-plugin-page-account-tree.c
gnucash/trunk/src/gnome/gnc-plugin-page-register.c
gnucash/trunk/src/gnome/gtkbuilder/Makefile.am
Log:
Rename lot viewer related files to be more in line with other dialogs
Modified: gnucash/trunk/po/POTFILES.in
===================================================================
--- gnucash/trunk/po/POTFILES.in 2011-08-10 21:10:29 UTC (rev 21147)
+++ gnucash/trunk/po/POTFILES.in 2011-08-10 21:10:42 UTC (rev 21148)
@@ -198,6 +198,7 @@
src/gnome/dialog-commodities.c
src/gnome/dialog-fincalc.c
src/gnome/dialog-find-transactions.c
+src/gnome/dialog-lot-viewer.c
src/gnome/dialog-new-user.c
src/gnome/dialog-price-edit-db.c
src/gnome/dialog-price-editor.c
@@ -233,8 +234,8 @@
src/gnome/gtkbuilder/autoclear.glade
src/gnome/gtkbuilder/budget.glade
src/gnome/gtkbuilder/commodities.glade
+src/gnome/gtkbuilder/dialog-lot-viewer.glade
src/gnome/gtkbuilder/fincalc.glade
-src/gnome/gtkbuilder/lots.glade
src/gnome/gtkbuilder/newuser.glade
src/gnome/gtkbuilder/owner.glade
src/gnome/gtkbuilder/price.glade
@@ -245,7 +246,6 @@
src/gnome/gtkbuilder/sched-xact.glade
src/gnome/gtkbuilder/tax.glade
src/gnome/gtkbuilder/userpass.glade
-src/gnome/lot-viewer.c
src/gnome/reconcile-list.c
src/gnome/schemas/apps_gnucash_dialog_commodities.schemas.in
src/gnome/schemas/apps_gnucash_dialog_common.schemas.in
Modified: gnucash/trunk/src/business/business-gnome/gnc-plugin-page-owner-tree.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/gnc-plugin-page-owner-tree.c 2011-08-10 21:10:29 UTC (rev 21147)
+++ gnucash/trunk/src/business/business-gnome/gnc-plugin-page-owner-tree.c 2011-08-10 21:10:42 UTC (rev 21148)
@@ -60,7 +60,7 @@
#include "gnc-ui.h"
#include "gnc-ui-util.h"
#include "guile-mappings.h"
-#include "lot-viewer.h"
+#include "dialog-lot-viewer.h"
#include "dialog-object-references.h"
/* This static indicates the debugging module that this .o belongs to. */
Modified: gnucash/trunk/src/engine/gnc-lot.c
===================================================================
--- gnucash/trunk/src/engine/gnc-lot.c 2011-08-10 21:10:29 UTC (rev 21147)
+++ gnucash/trunk/src/engine/gnc-lot.c 2011-08-10 21:10:42 UTC (rev 21148)
@@ -26,13 +26,13 @@
* FUNCTION:
* Lots implement the fundamental conceptual idea behind invoices,
* inventory lots, and stock market investment lots. See the file
- * src/doc/lots.txt for implmentation overview.
+ * src/doc/lots.txt for implementation overview.
*
* XXX Lots are not currently treated in a correct transactional
* manner. There's now a per-Lot dirty flag in the QofInstance, but
* this code still needs to emit the correct signals when a lot has
* changed. This is true both in the Scrub2.c and in
- * src/gnome/lot-viewer.c
+ * src/gnome/dialog-lot-viewer.c
*
* HISTORY:
* Created by Linas Vepstas May 2002
Modified: gnucash/trunk/src/gnome/Makefile.am
===================================================================
--- gnucash/trunk/src/gnome/Makefile.am 2011-08-10 21:10:29 UTC (rev 21147)
+++ gnucash/trunk/src/gnome/Makefile.am 2011-08-10 21:10:42 UTC (rev 21148)
@@ -31,6 +31,7 @@
dialog-commodities.c \
dialog-fincalc.c \
dialog-find-transactions.c \
+ dialog-lot-viewer.c \
dialog-new-user.c \
dialog-price-editor.c \
dialog-price-edit-db.c \
@@ -49,7 +50,6 @@
gnc-plugin-page-sx-list.c \
gnc-plugin-page-register.c \
gnc-split-reg.c \
- lot-viewer.c \
reconcile-list.c \
top-level.c \
window-reconcile.c \
@@ -70,6 +70,7 @@
assistant-stock-split.h \
dialog-fincalc.h \
dialog-find-transactions.h \
+ dialog-lot-viewer.h \
dialog-new-user.h \
dialog-print-check.h \
dialog-progress.h \
@@ -85,7 +86,6 @@
gnc-plugin-page-sx-list.h \
gnc-plugin-page-register.h \
gnc-split-reg.h \
- lot-viewer.h \
reconcile-list.h \
top-level.h \
window-reconcile.h \
Copied: gnucash/trunk/src/gnome/dialog-lot-viewer.c (from rev 21147, gnucash/trunk/src/gnome/lot-viewer.c)
===================================================================
--- gnucash/trunk/src/gnome/dialog-lot-viewer.c (rev 0)
+++ gnucash/trunk/src/gnome/dialog-lot-viewer.c 2011-08-10 21:10:42 UTC (rev 21148)
@@ -0,0 +1,820 @@
+/*******************************************************************\
+ * dialog-lot-viewer.c -- a basic lot viewer for GnuCash *
+ * Copyright (C) 2003 Linas Vepstas <linas at linas.org> *
+ * Copyright (C) 2011 Geert Janssens <geert at kobaltwit.be> *
+ * *
+ * 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 at gnu.org *
+ * *
+\********************************************************************/
+
+/* XXX todo: The button "view lot in register" is not implemented.
+ * it needs to open register window showing only the splits in the
+ * given lot ...
+ */
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+
+#include "Account.h"
+#include "cap-gains.h"
+#include "gnc-commodity.h"
+#include "qof.h"
+#include "gnc-lot.h"
+#include "Scrub3.h"
+#include "Transaction.h"
+
+#include "dialog-utils.h"
+#include "dialog-lot-viewer.h"
+#include "gnc-component-manager.h"
+#include "gnc-ui-util.h"
+#include "gnc-gconf-utils.h"
+#include "misc-gnome-utils.h"
+
+#define LOT_VIEWER_CM_CLASS "dialog-lot-viewer"
+
+enum lot_cols
+{
+ LOT_COL_OPEN = 0,
+ LOT_COL_CLOSE,
+ LOT_COL_TITLE,
+ LOT_COL_BALN,
+ LOT_COL_GAINS,
+ LOT_COL_PNTR,
+ NUM_LOT_COLS
+};
+
+enum split_cols
+{
+ SPLIT_COL_DATE = 0,
+ SPLIT_COL_NUM,
+ SPLIT_COL_DESCRIPTION,
+ SPLIT_COL_AMOUNT,
+ SPLIT_COL_VALUE,
+ SPLIT_COL_GAIN_LOSS,
+ SPLIT_COL_BALANCE,
+ SPLIT_COL_PNTR,
+ NUM_SPLIT_COLS
+};
+
+#define RESPONSE_VIEW 1
+#define RESPONSE_DELETE 2
+#define RESPONSE_SCRUB_LOT 3
+#define RESPONSE_SCRUB_ACCOUNT 4
+#define RESPONSE_NEW_LOT 5
+
+#define GCONF_SECTION "dialogs/lot_viewer"
+#define GCONF_KEY_HPOSITION "hpane_position"
+#define GCONF_KEY_VPOSITION "vpane_position"
+
+struct _GNCLotViewer
+{
+ GtkWidget * window;
+#ifdef LOTS_READY_FOR_SHOWTIME
+ GtkButton * regview_button;
+#endif
+ GtkButton * delete_button;
+ GtkButton * scrub_lot_button;
+ GtkButton * new_lot_button;
+ GtkPaned * lot_hpaned;
+ GtkPaned * lot_vpaned;
+ GtkTreeView * lot_view;
+ GtkListStore * lot_store;
+ GtkTextView * lot_notes;
+ GtkEntry * title_entry;
+ GtkTreeView * split_view;
+ GtkListStore * split_store;
+
+ Account * account;
+ GNCLot * selected_lot;
+};
+
+static void gnc_lot_viewer_fill (GNCLotViewer *lv);
+
+/* ======================================================================== */
+/* Callback prototypes */
+
+void lv_title_entry_changed_cb (GtkEntry *ent, gpointer user_data);
+void lv_response_cb (GtkDialog *dialog, gint response, gpointer data);
+void lv_window_destroy_cb (GtkObject *object, gpointer user_data);
+void lv_paned_notify_cb (GObject *gobject,
+ GParamSpec *pspec,
+ gpointer user_data);
+
+/* ======================================================================== */
+/* Put the splits into the split list */
+
+static void
+lv_show_splits (GNCLotViewer *lv)
+{
+ GNCLot *lot = lv->selected_lot;
+ SplitList *split_list, *node;
+ gnc_numeric baln = gnc_numeric_zero();
+ GtkListStore *store;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkTreeSelection *selection;
+
+ if (NULL == lot) return;
+
+ gtk_list_store_clear (lv->split_store);
+ split_list = gnc_lot_get_split_list (lot);
+ for (node = split_list; node; node = node->next)
+ {
+ Split *split = node->data;
+ char dbuff[MAX_DATE_LENGTH];
+ char amtbuff[200];
+ char valbuff[200];
+ char gainbuff[200];
+ char balnbuff[200];
+ gnc_commodity *currency;
+ Transaction *trans = xaccSplitGetParent (split);
+ time_t date = xaccTransGetDate (trans);
+ gnc_numeric amnt, valu, gains;
+ int row;
+
+ /* Do not show gains splits */
+ if (gnc_numeric_zero_p (xaccSplitGetAmount(split))) continue;
+
+ store = lv->split_store;
+ gtk_list_store_append(store, &iter);
+
+ /* Date */
+ qof_print_date_buff (dbuff, MAX_DATE_LENGTH, date);
+ gtk_list_store_set (store, &iter, SPLIT_COL_DATE, dbuff, -1);
+
+ /* Num */
+ gtk_list_store_set (store, &iter, SPLIT_COL_NUM, xaccTransGetNum (trans), -1);
+
+ /* Description */
+ gtk_list_store_set (store, &iter, SPLIT_COL_DESCRIPTION, xaccTransGetDescription (trans), -1);
+
+ /* Amount */
+ amnt = xaccSplitGetAmount (split);
+ xaccSPrintAmount (amtbuff, amnt,
+ gnc_account_print_info (lv->account, TRUE));
+ gtk_list_store_set (store, &iter, SPLIT_COL_AMOUNT, amtbuff, -1);
+
+ /* Value. Invert the sign on the first, opening entry. */
+ currency = xaccTransGetCurrency (trans);
+ valu = xaccSplitGetValue (split);
+ if (node != split_list)
+ {
+ valu = gnc_numeric_neg (valu);
+ }
+ xaccSPrintAmount (valbuff, valu,
+ gnc_commodity_print_info (currency, TRUE));
+ gtk_list_store_set (store, &iter, SPLIT_COL_VALUE, valbuff, -1);
+
+ /* Gains. Blank if none. */
+ gains = xaccSplitGetCapGains (split);
+ if (gnc_numeric_zero_p(gains))
+ {
+ gainbuff[0] = 0;
+ }
+ else
+ {
+ xaccSPrintAmount (gainbuff, gains,
+ gnc_commodity_print_info (currency, TRUE));
+ }
+ gtk_list_store_set (store, &iter, SPLIT_COL_GAIN_LOSS, gainbuff, -1);
+
+ /* Balance of Gains */
+ baln = gnc_numeric_add_fixed (baln, amnt);
+ if (gnc_numeric_zero_p(baln))
+ {
+ balnbuff[0] = 0;
+ }
+ else
+ {
+ xaccSPrintAmount (balnbuff, baln,
+ gnc_account_print_info (lv->account, TRUE));
+ }
+ gtk_list_store_set (store, &iter, SPLIT_COL_BALANCE, balnbuff, -1);
+
+ /* Self-reference */
+ gtk_list_store_set(store, &iter, SPLIT_COL_PNTR, split, -1);
+ }
+}
+
+/* ======================================================================== */
+/* Remove all splits from the split list */
+
+static void
+lv_clear_splits (GNCLotViewer *lv)
+{
+ gtk_list_store_clear (lv->split_store);
+}
+
+/* ======================================================================== */
+/* Save potential changes to the currently selected lot */
+static void
+lv_save_current_row (GNCLotViewer *lv)
+{
+ GNCLot *lot = lv->selected_lot;
+ const char * str;
+ char * notes;
+
+ if (lot)
+ {
+ gnc_lot_begin_edit(lot);
+
+ /* Get the title, save_the_title */
+ str = gtk_entry_get_text (lv->title_entry);
+ gnc_lot_set_title (lot, str);
+
+ /* Get the notes, save the notes */
+ notes = xxxgtk_textview_get_text (lv->lot_notes);
+ gnc_lot_set_notes (lot, notes);
+ g_free(notes);
+
+ gnc_lot_commit_edit(lot);
+ }
+}
+
+/* ======================================================================== */
+/* Select a row in the lot list */
+
+static void
+lv_select_row (GNCLotViewer *lv,
+ GNCLot *lot)
+{
+ const char * str;
+
+ lv_save_current_row (lv);
+
+ str = gnc_lot_get_title (lot);
+ if (!str) str = "";
+ gtk_entry_set_text (lv->title_entry, str);
+ gtk_editable_set_editable (GTK_EDITABLE(lv->title_entry), TRUE);
+
+ /* Set the notes field */
+ str = gnc_lot_get_notes (lot);
+ if (!str) str = "";
+ xxxgtk_textview_set_text (lv->lot_notes, str);
+ gtk_text_view_set_editable (lv->lot_notes, TRUE);
+
+ /* Don't set until end, to avoid recursion in gtkentry "changed" cb. */
+ lv->selected_lot = lot;
+ lv_show_splits (lv);
+
+#ifdef LOTS_READY_FOR_SHOWTIME
+ gtk_widget_set_sensitive(GTK_WIDGET(lv->regview_button), TRUE);
+#endif
+ gtk_widget_set_sensitive(GTK_WIDGET(lv->delete_button), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(lv->scrub_lot_button), TRUE);
+}
+
+/* ======================================================================== */
+
+static void
+lv_unset_lot (GNCLotViewer *lv)
+{
+ /* Set immediately, to avoid recursion in gtkentry "changed" cb. */
+ lv->selected_lot = NULL;
+
+ /* Blank the title widget */
+ gtk_entry_set_text (lv->title_entry, "");
+ gtk_editable_set_editable (GTK_EDITABLE(lv->title_entry), FALSE);
+
+ /* Blank the notes area */
+ xxxgtk_textview_set_text (lv->lot_notes, "");
+ gtk_text_view_set_editable (lv->lot_notes, FALSE);
+
+ /* Erase the mini-view area */
+ lv_clear_splits (lv);
+
+#ifdef LOTS_READY_FOR_SHOWTIME
+ gtk_widget_set_sensitive(GTK_WIDGET(lv->regview_button), FALSE);
+#endif
+ gtk_widget_set_sensitive(GTK_WIDGET(lv->delete_button), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(lv->scrub_lot_button), FALSE);
+}
+
+/* ======================================================================== */
+/* De-select a row the the lot list */
+
+static void
+lv_unselect_row (GNCLotViewer *lv)
+{
+ lv_save_current_row (lv);
+ lv_unset_lot (lv);
+}
+
+/* ======================================================================== */
+/* Callback triggered when the user changes the selected line in the lot list */
+
+static void
+lv_selection_changed_cb (GtkTreeSelection *selection,
+ GNCLotViewer *lv)
+{
+ GNCLot *lot;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ {
+ gtk_tree_model_get(model, &iter, LOT_COL_PNTR, &lot, -1);
+ lv_select_row(lv, lot);
+ }
+ else
+ {
+ lv_unselect_row(lv);
+ }
+}
+
+
+/* ======================================================================== */
+/* Callback triggered when user types a new lot title into the entry widget */
+
+void
+lv_title_entry_changed_cb (GtkEntry *ent, gpointer user_data)
+{
+ GNCLotViewer *lv = user_data;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkTreeSelection *selection;
+ const char * title;
+ title = gtk_entry_get_text (lv->title_entry);
+
+ selection = gtk_tree_view_get_selection(lv->lot_view);
+ if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ {
+ gtk_list_store_set(GTK_LIST_STORE(model), &iter, LOT_COL_TITLE, title, -1);
+ }
+}
+
+/* ======================================================================== */
+/* Get the realized gains for this lot. This routine or a variant of it
+ * should probably be moved to gnc-lot.c.
+ * The conceptual difficulty here is that this works only if all of the
+ * realized gains in the lot are of the
+ */
+
+static gnc_commodity *
+find_first_currency (GNCLot *lot)
+{
+ SplitList *split_list, *node;
+
+ split_list = gnc_lot_get_split_list(lot);
+ for (node = split_list; node; node = node->next)
+ {
+ Split *s = node->data;
+ Transaction *trans;
+ if (FALSE == gnc_numeric_zero_p(xaccSplitGetAmount(s))) continue;
+ trans = xaccSplitGetParent (s);
+ return xaccTransGetCurrency (trans);
+ }
+ return NULL;
+}
+
+static gnc_numeric
+get_realized_gains (GNCLot *lot, gnc_commodity *currency)
+{
+ gnc_numeric zero = gnc_numeric_zero();
+ gnc_numeric gains = zero;
+ SplitList *split_list, *node;
+
+ if (!currency) return zero;
+
+ split_list = gnc_lot_get_split_list(lot);
+ for (node = split_list; node; node = node->next)
+ {
+ Split *s = node->data;
+ Transaction *trans;
+
+ if (FALSE == gnc_numeric_zero_p(xaccSplitGetAmount(s))) continue;
+ trans = xaccSplitGetParent (s);
+ if (FALSE == gnc_commodity_equal (xaccTransGetCurrency(trans), currency)) continue;
+
+ gains = gnc_numeric_add (gains, xaccSplitGetValue (s), GNC_DENOM_AUTO, GNC_HOW_DENOM_FIXED);
+ }
+ return gains;
+}
+
+/* ======================================================================== */
+
+static void
+gnc_lot_viewer_fill (GNCLotViewer *lv)
+{
+ LotList *lot_list, *node;
+ GNCLot *this_lot, *selected_lot = NULL;
+ GtkListStore *store;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkTreeSelection *selection;
+ gboolean found = FALSE;
+
+ lot_list = xaccAccountGetLotList (lv->account);
+
+ selection = gtk_tree_view_get_selection(lv->lot_view);
+ if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ gtk_tree_model_get(model, &iter, LOT_COL_PNTR, &selected_lot, -1);
+
+ /* Crazy. Should update in place if possible. */
+ gtk_list_store_clear (lv->lot_store);
+
+ for (node = lot_list; node; node = node->next)
+ {
+ char obuff[MAX_DATE_LENGTH];
+ char cbuff[MAX_DATE_LENGTH];
+ char baln_buff[200];
+ char gain_buff[200];
+ GNCLot *lot = node->data;
+ Split *esplit = gnc_lot_get_earliest_split (lot);
+ Transaction *etrans = xaccSplitGetParent (esplit);
+ time_t open_date = xaccTransGetDate (etrans);
+ gnc_numeric amt_baln = gnc_lot_get_balance (lot);
+ gnc_commodity *currency = find_first_currency (lot);
+ gnc_numeric gains_baln = get_realized_gains (lot, currency);
+
+ store = lv->lot_store;
+ gtk_list_store_append(store, &iter);
+
+ /* Opening date */
+ qof_print_date_buff (obuff, MAX_DATE_LENGTH, open_date);
+ gtk_list_store_set(store, &iter, LOT_COL_OPEN, obuff, -1);
+
+ /* Closing date */
+ if (gnc_lot_is_closed (lot))
+ {
+ Split *fsplit = gnc_lot_get_latest_split (lot);
+ Transaction *ftrans = xaccSplitGetParent (fsplit);
+ time_t close_date = xaccTransGetDate (ftrans);
+
+ qof_print_date_buff (cbuff, MAX_DATE_LENGTH, close_date);
+ gtk_list_store_set(store, &iter, LOT_COL_CLOSE, cbuff, -1);
+ }
+ else
+ {
+ gtk_list_store_set(store, &iter, LOT_COL_CLOSE, _("Open"), -1);
+ }
+
+ /* Title */
+ gtk_list_store_set(store, &iter, LOT_COL_TITLE, gnc_lot_get_title(lot), -1);
+
+ /* Amount */
+ xaccSPrintAmount (baln_buff, amt_baln,
+ gnc_account_print_info (lv->account, TRUE));
+ gtk_list_store_set(store, &iter, LOT_COL_BALN, baln_buff, -1);
+
+ /* Capital Gains/Losses Appreciation/Depreciation */
+ xaccSPrintAmount (gain_buff, gains_baln,
+ gnc_commodity_print_info (currency, TRUE));
+ gtk_list_store_set(store, &iter, LOT_COL_GAINS, gain_buff, -1);
+
+ /* Self-reference */
+ gtk_list_store_set(store, &iter, LOT_COL_PNTR, lot, -1);
+ }
+ g_list_free(lot_list);
+
+ /* re-select the row that the user had previously selected,
+ * if possible. */
+ if (selected_lot)
+ {
+ model = GTK_TREE_MODEL(lv->lot_store);
+ if (gtk_tree_model_get_iter_first(model, &iter))
+ {
+ do
+ {
+ gtk_tree_model_get(model, &iter, LOT_COL_PNTR, &this_lot, -1);
+ if (this_lot == selected_lot)
+ {
+ gtk_tree_selection_select_iter(selection, &iter);
+ found = TRUE;
+ break;
+ }
+ }
+ while (gtk_tree_model_iter_next(model, &iter));
+ }
+ }
+
+ if (!found)
+ gtk_tree_selection_unselect_all(selection);
+}
+
+/* ======================================================================== */
+
+static void
+lv_refresh_handler (GHashTable *changes, gpointer user_data)
+{
+ GNCLotViewer *lv = user_data;
+ gnc_lot_viewer_fill (lv);
+ lv_show_splits (lv);
+}
+
+static void
+lv_close_handler (gpointer user_data)
+{
+ GNCLotViewer *lv = user_data;
+ GNCLot *lot = lv->selected_lot;
+
+ lv_save_current_row (lv);
+
+ gnc_save_window_size(GCONF_SECTION, GTK_WINDOW(lv->window));
+ gtk_widget_destroy (lv->window);
+}
+
+void
+lv_window_destroy_cb (GtkObject *object, gpointer user_data)
+{
+ GNCLotViewer *lv = user_data;
+ gnc_close_gui_component_by_data (LOT_VIEWER_CM_CLASS, lv);
+ gnc_unregister_gui_component_by_data (LOT_VIEWER_CM_CLASS, lv);
+ g_free (lv);
+}
+
+
+/* ======================================================================== */
+/* Divider moved */
+
+void
+lv_paned_notify_cb (GObject *gobject,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ const gchar *param_name;
+ gint value;
+
+ param_name = g_param_spec_get_name(pspec);
+ if (strcmp(param_name, "position") != 0)
+ return;
+ g_object_get(gobject, "position", &value, NULL);
+
+ if (GTK_IS_HPANED(gobject))
+ {
+ gnc_gconf_set_int(GCONF_SECTION, GCONF_KEY_HPOSITION, value, NULL);
+ }
+ else
+ {
+ gnc_gconf_set_int(GCONF_SECTION, GCONF_KEY_VPOSITION, value, NULL);
+ }
+}
+
+/* ======================================================================== */
+/* Any button was pressed */
+
+void
+lv_response_cb (GtkDialog *dialog, gint response, gpointer data)
+{
+ GNCLotViewer *lv = data;
+ GNCLot *lot = lv->selected_lot;
+
+ switch (response)
+ {
+ case GTK_RESPONSE_CLOSE:
+ lv_close_handler(lv);
+ return;
+
+ case RESPONSE_VIEW:
+ if (NULL == lot)
+ return;
+ printf ("UNIMPLEMENTED: need to display register showing only this one lot \n");
+ break;
+
+ case RESPONSE_DELETE:
+ if (NULL == lot)
+ return;
+ xaccAccountRemoveLot (gnc_lot_get_account(lot), lot);
+ gnc_lot_destroy (lot);
+ lv_unset_lot (lv);
+ gnc_lot_viewer_fill (lv);
+ break;
+
+ case RESPONSE_SCRUB_LOT:
+ if (NULL == lot)
+ return;
+ xaccScrubLot (lot);
+ gnc_lot_viewer_fill (lv);
+ lv_show_splits (lv);
+ break;
+
+ case RESPONSE_SCRUB_ACCOUNT:
+ gnc_suspend_gui_refresh ();
+ xaccAccountScrubLots (lv->account);
+ gnc_resume_gui_refresh ();
+ gnc_lot_viewer_fill (lv);
+ lv_show_splits (lv);
+ break;
+
+ case RESPONSE_NEW_LOT:
+ lv_save_current_row (lv);
+ lot = gnc_lot_make_default (lv->account);
+ xaccAccountInsertLot (lv->account, lot);
+ break;
+ }
+}
+
+/* ======================================================================== */
+
+static void
+lv_init_split_view (GNCLotViewer *lv)
+{
+ GtkTreeView *view;
+ GtkListStore *store;
+ GtkTreeViewColumn *column;
+ GtkTreeSelection *selection;
+ GtkCellRenderer *renderer;
+
+ g_return_if_fail(GTK_IS_TREE_VIEW(lv->split_view));
+
+ view = lv->split_view;
+ store = gtk_list_store_new(NUM_SPLIT_COLS, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_POINTER);
+ gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
+ g_object_unref(store);
+ lv->split_store = store;
+
+ /* Set up the columns */
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Date"), renderer,
+ "text", SPLIT_COL_DATE, NULL);
+ gtk_tree_view_append_column(view, column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Num"), renderer,
+ "text", SPLIT_COL_NUM, NULL);
+ gtk_tree_view_append_column(view, column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Description"), renderer,
+ "text", SPLIT_COL_DESCRIPTION, NULL);
+ gtk_tree_view_append_column(view, column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Amount"), renderer,
+ "text", SPLIT_COL_AMOUNT, NULL);
+ gtk_tree_view_append_column(view, column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Value"), renderer,
+ "text", SPLIT_COL_VALUE, NULL);
+ gtk_tree_view_append_column(view, column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Gain/Loss"), renderer,
+ "text", SPLIT_COL_GAIN_LOSS, NULL);
+ gtk_tree_view_append_column(view, column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Balance"), renderer,
+ "text", SPLIT_COL_BALANCE, NULL);
+ gtk_tree_view_append_column(view, column);
+}
+
+/* ======================================================================== */
+
+static void
+lv_init_lot_view (GNCLotViewer *lv)
+{
+ GtkTreeView *view;
+ GtkListStore *store;
+ GtkTreeViewColumn *column;
+ GtkTreeSelection *selection;
+ GtkCellRenderer *renderer;
+
+ g_return_if_fail(GTK_IS_TREE_VIEW(lv->lot_view));
+
+ view = lv->lot_view;
+ store = gtk_list_store_new(NUM_LOT_COLS, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_POINTER);
+ gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
+ g_object_unref(store);
+ lv->lot_store = store;
+
+ /* Set up the columns */
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Opened"), renderer,
+ "text", LOT_COL_OPEN, NULL);
+ gtk_tree_view_append_column(view, column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Closed"), renderer,
+ "text", LOT_COL_CLOSE, NULL);
+ gtk_tree_view_append_column(view, column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Title"), renderer,
+ "text", LOT_COL_TITLE, NULL);
+ gtk_tree_view_append_column(view, column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Balance"), renderer,
+ "text", LOT_COL_BALN, NULL);
+ gtk_tree_view_append_column(view, column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Gains"), renderer,
+ "text", LOT_COL_GAINS, NULL);
+ gtk_tree_view_append_column(view, column);
+
+ /* Set up the selection callbacks */
+ selection = gtk_tree_view_get_selection(view);
+ g_signal_connect(selection, "changed",
+ G_CALLBACK(lv_selection_changed_cb), lv);
+}
+
+/* ======================================================================== */
+
+static void
+lv_create (GNCLotViewer *lv)
+{
+ gchar *win_title;
+ gint position;
+ GtkBuilder *builder;
+
+
+ builder = gtk_builder_new();
+ gnc_builder_add_from_file (builder, "dialog-lot-viewer.glade", "Lot Viewer Window");
+
+ lv->window = GTK_WIDGET(gtk_builder_get_object (builder, "Lot Viewer Window"));
+
+ win_title=g_strdup_printf (_("Lots in Account %s"),
+ xaccAccountGetName(lv->account));
+ gtk_window_set_title (GTK_WINDOW (lv->window), win_title);
+ g_free (win_title);
+
+#ifdef LOTS_READY_FOR_SHOWTIME
+ lv->regview_button = GTK_BUTTON(glade_xml_get_widget (builder, "regview button"));
+#endif
+ lv->delete_button = GTK_BUTTON(gtk_builder_get_object (builder, "delete button"));
+ lv->scrub_lot_button = GTK_BUTTON(gtk_builder_get_object (builder, "scrub lot button"));
+ lv->new_lot_button = GTK_BUTTON(gtk_builder_get_object (builder, "new lot button"));
+
+ lv->lot_view = GTK_TREE_VIEW(gtk_builder_get_object (builder, "lot view"));
+ lv_init_lot_view(lv);
+ lv->lot_notes = GTK_TEXT_VIEW(gtk_builder_get_object (builder, "lot notes text"));
+ lv->title_entry = GTK_ENTRY (gtk_builder_get_object (builder, "lot title entry"));
+
+ lv->split_view = GTK_TREE_VIEW(gtk_builder_get_object (builder, "split view"));
+ lv_init_split_view(lv);
+
+ lv->lot_vpaned = GTK_PANED (gtk_builder_get_object (builder, "lot vpaned"));
+ position = gnc_gconf_get_int(GCONF_SECTION, GCONF_KEY_VPOSITION, NULL);
+ if (position)
+ gtk_paned_set_position (lv->lot_vpaned, position);
+
+ lv->lot_hpaned = GTK_PANED (gtk_builder_get_object (builder, "lot hpaned"));
+ position = gnc_gconf_get_int(GCONF_SECTION, GCONF_KEY_HPOSITION, NULL);
+ if (position)
+ gtk_paned_set_position (lv->lot_hpaned, position);
+
+ lv->selected_lot = NULL;
+
+ /* Setup signals */
+ gtk_builder_connect_signals(builder, lv);
+ g_object_unref(G_OBJECT(builder));
+
+ gnc_restore_window_size(GCONF_SECTION, GTK_WINDOW(lv->window));
+}
+
+/* ======================================================================== */
+
+GNCLotViewer *
+gnc_lot_viewer_dialog (Account *account)
+{
+ GNCLotViewer *lv;
+ gint component_id;
+
+ if (!account) return NULL;
+
+ lv = g_new0 (GNCLotViewer, 1);
+ lv->account = account;
+ lv_create (lv);
+ gnc_lot_viewer_fill (lv);
+
+ component_id = gnc_register_gui_component (LOT_VIEWER_CM_CLASS,
+ lv_refresh_handler,
+ lv_close_handler,
+ lv);
+
+ gnc_gui_component_watch_entity_type (component_id,
+ GNC_ID_LOT,
+ QOF_EVENT_CREATE | QOF_EVENT_ADD | QOF_EVENT_REMOVE | QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);
+
+ gtk_widget_show_all (lv->window);
+ gnc_window_adjust_for_screen (GTK_WINDOW(lv->window));
+
+ return lv;
+}
+
+/* ============================ END OF FILE =============================== */
Copied: gnucash/trunk/src/gnome/dialog-lot-viewer.h (from rev 21147, gnucash/trunk/src/gnome/lot-viewer.h)
===================================================================
--- gnucash/trunk/src/gnome/dialog-lot-viewer.h (rev 0)
+++ gnucash/trunk/src/gnome/dialog-lot-viewer.h 2011-08-10 21:10:42 UTC (rev 21148)
@@ -0,0 +1,35 @@
+/*******************************************************************\
+ * dialog-lot-viewer.h -- a basic lot viewer for GnuCash *
+ * Copyright (C) 2003 Linas Vepstas <linas at linas.org> *
+ * Copyright (C) 2011 Geert Janssens <geert at kobaltwit.be> *
+ * *
+ * 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 at gnu.org *
+ * *
+\********************************************************************/
+
+#ifndef LOT_VIEWER_H
+#define LOT_VIEWER_H
+
+#include "Account.h"
+
+typedef struct _GNCLotViewer GNCLotViewer;
+
+/** Create and realize and show a lot-viewing dialog. */
+GNCLotViewer * gnc_lot_viewer_dialog (Account *);
+
+#endif /* LOT_VIEWER_H */
Modified: gnucash/trunk/src/gnome/gnc-plugin-page-account-tree.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-page-account-tree.c 2011-08-10 21:10:29 UTC (rev 21147)
+++ gnucash/trunk/src/gnome/gnc-plugin-page-account-tree.c 2011-08-10 21:10:42 UTC (rev 21148)
@@ -60,7 +60,7 @@
#include "gnc-tree-model-account-types.h"
#include "gnc-ui.h"
#include "gnc-ui-util.h"
-#include "lot-viewer.h"
+#include "dialog-lot-viewer.h"
#include "window-reconcile.h"
#include "window-autoclear.h"
#include "window-main-summarybar.h"
Modified: gnucash/trunk/src/gnome/gnc-plugin-page-register.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-page-register.c 2011-08-10 21:10:29 UTC (rev 21147)
+++ gnucash/trunk/src/gnome/gnc-plugin-page-register.c 2011-08-10 21:10:42 UTC (rev 21148)
@@ -68,7 +68,7 @@
#include "gnc-main-window.h"
#include "gnc-session.h"
#include "gnucash-sheet.h"
-#include "lot-viewer.h"
+#include "dialog-lot-viewer.h"
#include "Scrub.h"
#include "qof.h"
#include "window-reconcile.h"
Modified: gnucash/trunk/src/gnome/gtkbuilder/Makefile.am
===================================================================
--- gnucash/trunk/src/gnome/gtkbuilder/Makefile.am 2011-08-10 21:10:29 UTC (rev 21147)
+++ gnucash/trunk/src/gnome/gtkbuilder/Makefile.am 2011-08-10 21:10:42 UTC (rev 21148)
@@ -8,8 +8,8 @@
autoclear.glade \
budget.glade \
commodities.glade \
+ dialog-lot-viewer.glade \
fincalc.glade \
- lots.glade \
newuser.glade \
owner.glade \
price.glade \
Copied: gnucash/trunk/src/gnome/gtkbuilder/dialog-lot-viewer.glade (from rev 21147, gnucash/trunk/src/gnome/gtkbuilder/lots.glade)
===================================================================
--- gnucash/trunk/src/gnome/gtkbuilder/dialog-lot-viewer.glade (rev 0)
+++ gnucash/trunk/src/gnome/gtkbuilder/dialog-lot-viewer.glade 2011-08-10 21:10:42 UTC (rev 21148)
@@ -0,0 +1,422 @@
+<?xml version="1.0"?>
+<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <!-- interface-naming-policy toplevel-contextual -->
+ <object class="GtkDialog" id="Lot Viewer Window">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Lot Viewer</property>
+ <property name="default_width">600</property>
+ <property name="default_height">400</property>
+ <property name="type_hint">dialog</property>
+ <signal name="destroy" handler="lv_window_destroy_cb"/>
+ <signal name="response" handler="lv_response_cb"/>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkVPaned" id="lot vpaned">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="orientation">vertical</property>
+ <property name="position">200</property>
+ <signal name="notify" handler="lv_paned_notify_cb"/>
+ <child>
+ <object class="GtkHPaned" id="lot hpaned">
+ <property name="width_request">300</property>
+ <property name="height_request">100</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="border_width">3</property>
+ <property name="position">200</property>
+ <signal name="notify" handler="lv_paned_notify_cb"/>
+ <child>
+ <object class="GtkTable" id="table1">
+ <property name="visible">True</property>
+ <property name="n_rows">5</property>
+ <child>
+ <object class="GtkEntry" id="lot title entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="tooltip_text" translatable="yes">Enter a name for the highlighted lot.</property>
+ <signal name="changed" handler="lv_title_entry_changed_cb"/>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options"></property>
+ <property name="x_padding">12</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label19">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes"><b>_Notes</b></property>
+ <property name="use_markup">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="vscrollbar_policy">never</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTextView" id="lot notes text">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="tooltip_text" translatable="yes">Enter any notes you want to make about this lot.</property>
+ <property name="wrap_mode">word</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_padding">12</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label20">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes"><b>_Title</b></property>
+ <property name="use_markup">True</property>
+ <property name="use_underline">True</property>
+ <property name="justify">center</property>
+ </object>
+ <packing>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="resize">False</property>
+ <property name="shrink">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkTable" id="table2">
+ <property name="visible">True</property>
+ <property name="n_rows">2</property>
+ <child>
+ <object class="GtkLabel" id="label9">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes"><b>_Lots in This Account</b></property>
+ <property name="use_markup">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow5">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="lot view">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="rules_hint">True</property>
+ <property name="enable_search">False</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_padding">12</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="resize">True</property>
+ <property name="shrink">True</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="resize">True</property>
+ <property name="shrink">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkTable" id="table3">
+ <property name="visible">True</property>
+ <property name="n_rows">2</property>
+ <child>
+ <object class="GtkLabel" id="label10">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes"><b>_Mini-Viewer</b></property>
+ <property name="use_markup">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="split view">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="rules_hint">True</property>
+ <property name="enable_search">False</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
+ <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
+ <property name="x_padding">12</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="resize">True</property>
+ <property name="shrink">True</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="new lot button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <child>
+ <object class="GtkAlignment" id="alignment3">
+ <property name="visible">True</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <child>
+ <object class="GtkHBox" id="hbox4">
+ <property name="visible">True</property>
+ <property name="spacing">2</property>
+ <child>
+ <object class="GtkImage" id="image3">
+ <property name="visible">True</property>
+ <property name="stock">gtk-new</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label21">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_New Lot</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="scrub account button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <child>
+ <object class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <child>
+ <object class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <property name="spacing">2</property>
+ <child>
+ <object class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="stock">gtk-clear</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label16">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Scrub _Account</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="scrub lot button">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">Scrub the highlighted lot</property>
+ <child>
+ <object class="GtkAlignment" id="alignment2">
+ <property name="visible">True</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <child>
+ <object class="GtkHBox" id="hbox3">
+ <property name="visible">True</property>
+ <property name="spacing">2</property>
+ <child>
+ <object class="GtkImage" id="image2">
+ <property name="visible">True</property>
+ <property name="stock">gtk-clear</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label17">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Scrub</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="delete button">
+ <property name="label">gtk-delete</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">Delete the highlighted lot</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button5">
+ <property name="label">gtk-close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="5">new lot button</action-widget>
+ <action-widget response="4">scrub account button</action-widget>
+ <action-widget response="3">scrub lot button</action-widget>
+ <action-widget response="2">delete button</action-widget>
+ <action-widget response="-7">button5</action-widget>
+ </action-widgets>
+ </object>
+</interface>
Deleted: gnucash/trunk/src/gnome/gtkbuilder/lots.glade
===================================================================
--- gnucash/trunk/src/gnome/gtkbuilder/lots.glade 2011-08-10 21:10:29 UTC (rev 21147)
+++ gnucash/trunk/src/gnome/gtkbuilder/lots.glade 2011-08-10 21:10:42 UTC (rev 21148)
@@ -1,420 +0,0 @@
-<?xml version="1.0"?>
-<interface>
- <requires lib="gtk+" version="2.16"/>
- <!-- interface-naming-policy toplevel-contextual -->
- <object class="GtkDialog" id="Lot Viewer Window">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Lot Viewer</property>
- <property name="default_width">600</property>
- <property name="default_height">400</property>
- <property name="type_hint">dialog</property>
- <signal name="destroy" handler="lv_window_destroy_cb"/>
- <signal name="response" handler="lv_response_cb"/>
- <child internal-child="vbox">
- <object class="GtkVBox" id="dialog-vbox1">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkVPaned" id="lot vpaned">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="orientation">vertical</property>
- <property name="position">200</property>
- <signal name="notify" handler="lv_paned_notify_cb"/>
- <child>
- <object class="GtkHPaned" id="lot hpaned">
- <property name="width_request">300</property>
- <property name="height_request">100</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="border_width">3</property>
- <property name="position">200</property>
- <signal name="notify" handler="lv_paned_notify_cb"/>
- <child>
- <object class="GtkTable" id="table1">
- <property name="visible">True</property>
- <property name="n_rows">5</property>
- <child>
- <object class="GtkEntry" id="lot title entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="tooltip_text" translatable="yes">Enter a name for the highlighted lot.</property>
- <signal name="changed" handler="lv_title_entry_changed_cb"/>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="y_options"></property>
- <property name="x_padding">12</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label19">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes"><b>_Notes</b></property>
- <property name="use_markup">True</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow" id="scrolledwindow2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hscrollbar_policy">never</property>
- <property name="vscrollbar_policy">never</property>
- <property name="shadow_type">in</property>
- <child>
- <object class="GtkTextView" id="lot notes text">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="tooltip_text" translatable="yes">Enter any notes you want to make about this lot.</property>
- <property name="wrap_mode">word</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
- <property name="x_padding">12</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label20">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label8">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes"><b>_Title</b></property>
- <property name="use_markup">True</property>
- <property name="use_underline">True</property>
- <property name="justify">center</property>
- </object>
- <packing>
- <property name="y_options"></property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="resize">False</property>
- <property name="shrink">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkTable" id="table2">
- <property name="visible">True</property>
- <property name="n_rows">2</property>
- <child>
- <object class="GtkLabel" id="label9">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes"><b>_Lots in This Account</b></property>
- <property name="use_markup">True</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow" id="scrolledwindow5">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="shadow_type">in</property>
- <child>
- <object class="GtkTreeView" id="lot view">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="rules_hint">True</property>
- <property name="enable_search">False</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_padding">12</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="resize">True</property>
- <property name="shrink">True</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="resize">True</property>
- <property name="shrink">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkTable" id="table3">
- <property name="visible">True</property>
- <property name="n_rows">2</property>
- <child>
- <object class="GtkLabel" id="label10">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes"><b>_Mini-Viewer</b></property>
- <property name="use_markup">True</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow" id="scrolledwindow4">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hscrollbar_policy">automatic</property>
- <property name="vscrollbar_policy">automatic</property>
- <property name="shadow_type">in</property>
- <child>
- <object class="GtkTreeView" id="split view">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="rules_hint">True</property>
- <property name="enable_search">False</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_padding">12</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="resize">True</property>
- <property name="shrink">True</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="position">2</property>
- </packing>
- </child>
- <child internal-child="action_area">
- <object class="GtkHButtonBox" id="dialog-action_area1">
- <property name="visible">True</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="new lot button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <child>
- <object class="GtkAlignment" id="alignment3">
- <property name="visible">True</property>
- <property name="xscale">0</property>
- <property name="yscale">0</property>
- <child>
- <object class="GtkHBox" id="hbox4">
- <property name="visible">True</property>
- <property name="spacing">2</property>
- <child>
- <object class="GtkImage" id="image3">
- <property name="visible">True</property>
- <property name="stock">gtk-new</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label21">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_New Lot</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="scrub account button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <child>
- <object class="GtkAlignment" id="alignment1">
- <property name="visible">True</property>
- <property name="xscale">0</property>
- <property name="yscale">0</property>
- <child>
- <object class="GtkHBox" id="hbox2">
- <property name="visible">True</property>
- <property name="spacing">2</property>
- <child>
- <object class="GtkImage" id="image1">
- <property name="visible">True</property>
- <property name="stock">gtk-clear</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label16">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Scrub _Account</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="scrub lot button">
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="tooltip_text" translatable="yes">Scrub the highlighted lot</property>
- <child>
- <object class="GtkAlignment" id="alignment2">
- <property name="visible">True</property>
- <property name="xscale">0</property>
- <property name="yscale">0</property>
- <child>
- <object class="GtkHBox" id="hbox3">
- <property name="visible">True</property>
- <property name="spacing">2</property>
- <child>
- <object class="GtkImage" id="image2">
- <property name="visible">True</property>
- <property name="stock">gtk-clear</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label17">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Scrub</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="delete button">
- <property name="label">gtk-delete</property>
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="tooltip_text" translatable="yes">Delete the highlighted lot</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="button5">
- <property name="label">gtk-close</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">4</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- </child>
- <action-widgets>
- <action-widget response="5">new lot button</action-widget>
- <action-widget response="4">scrub account button</action-widget>
- <action-widget response="3">scrub lot button</action-widget>
- <action-widget response="2">delete button</action-widget>
- <action-widget response="-7">button5</action-widget>
- </action-widgets>
- </object>
-</interface>
Deleted: gnucash/trunk/src/gnome/lot-viewer.c
===================================================================
--- gnucash/trunk/src/gnome/lot-viewer.c 2011-08-10 21:10:29 UTC (rev 21147)
+++ gnucash/trunk/src/gnome/lot-viewer.c 2011-08-10 21:10:42 UTC (rev 21148)
@@ -1,819 +0,0 @@
-/*******************************************************************\
- * lot-viewer.c -- a basic lot viewer for GnuCash *
- * Copyright (C) 2003 Linas Vepstas <linas at linas.org> *
- * *
- * 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 at gnu.org *
- * *
-\********************************************************************/
-
-/* XXX todo: The button "view lot in register" is not implemented.
- * it needs to open register window showing only the splits in the
- * given lot ...
- */
-
-#include "config.h"
-
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-
-#include "Account.h"
-#include "cap-gains.h"
-#include "gnc-commodity.h"
-#include "qof.h"
-#include "gnc-lot.h"
-#include "Scrub3.h"
-#include "Transaction.h"
-
-#include "dialog-utils.h"
-#include "lot-viewer.h"
-#include "gnc-component-manager.h"
-#include "gnc-ui-util.h"
-#include "gnc-gconf-utils.h"
-#include "misc-gnome-utils.h"
-
-#define LOT_VIEWER_CM_CLASS "lot-viewer"
-
-enum lot_cols
-{
- LOT_COL_OPEN = 0,
- LOT_COL_CLOSE,
- LOT_COL_TITLE,
- LOT_COL_BALN,
- LOT_COL_GAINS,
- LOT_COL_PNTR,
- NUM_LOT_COLS
-};
-
-enum split_cols
-{
- SPLIT_COL_DATE = 0,
- SPLIT_COL_NUM,
- SPLIT_COL_DESCRIPTION,
- SPLIT_COL_AMOUNT,
- SPLIT_COL_VALUE,
- SPLIT_COL_GAIN_LOSS,
- SPLIT_COL_BALANCE,
- SPLIT_COL_PNTR,
- NUM_SPLIT_COLS
-};
-
-#define RESPONSE_VIEW 1
-#define RESPONSE_DELETE 2
-#define RESPONSE_SCRUB_LOT 3
-#define RESPONSE_SCRUB_ACCOUNT 4
-#define RESPONSE_NEW_LOT 5
-
-#define GCONF_SECTION "dialogs/lot_viewer"
-#define GCONF_KEY_HPOSITION "hpane_position"
-#define GCONF_KEY_VPOSITION "vpane_position"
-
-struct _GNCLotViewer
-{
- GtkWidget * window;
-#ifdef LOTS_READY_FOR_SHOWTIME
- GtkButton * regview_button;
-#endif
- GtkButton * delete_button;
- GtkButton * scrub_lot_button;
- GtkButton * new_lot_button;
- GtkPaned * lot_hpaned;
- GtkPaned * lot_vpaned;
- GtkTreeView * lot_view;
- GtkListStore * lot_store;
- GtkTextView * lot_notes;
- GtkEntry * title_entry;
- GtkTreeView * split_view;
- GtkListStore * split_store;
-
- Account * account;
- GNCLot * selected_lot;
-};
-
-static void gnc_lot_viewer_fill (GNCLotViewer *lv);
-
-/* ======================================================================== */
-/* Callback prototypes */
-
-void lv_title_entry_changed_cb (GtkEntry *ent, gpointer user_data);
-void lv_response_cb (GtkDialog *dialog, gint response, gpointer data);
-void lv_window_destroy_cb (GtkObject *object, gpointer user_data);
-void lv_paned_notify_cb (GObject *gobject,
- GParamSpec *pspec,
- gpointer user_data);
-
-/* ======================================================================== */
-/* Put the splits into the split list */
-
-static void
-lv_show_splits (GNCLotViewer *lv)
-{
- GNCLot *lot = lv->selected_lot;
- SplitList *split_list, *node;
- gnc_numeric baln = gnc_numeric_zero();
- GtkListStore *store;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreeSelection *selection;
-
- if (NULL == lot) return;
-
- gtk_list_store_clear (lv->split_store);
- split_list = gnc_lot_get_split_list (lot);
- for (node = split_list; node; node = node->next)
- {
- Split *split = node->data;
- char dbuff[MAX_DATE_LENGTH];
- char amtbuff[200];
- char valbuff[200];
- char gainbuff[200];
- char balnbuff[200];
- gnc_commodity *currency;
- Transaction *trans = xaccSplitGetParent (split);
- time_t date = xaccTransGetDate (trans);
- gnc_numeric amnt, valu, gains;
- int row;
-
- /* Do not show gains splits */
- if (gnc_numeric_zero_p (xaccSplitGetAmount(split))) continue;
-
- store = lv->split_store;
- gtk_list_store_append(store, &iter);
-
- /* Date */
- qof_print_date_buff (dbuff, MAX_DATE_LENGTH, date);
- gtk_list_store_set (store, &iter, SPLIT_COL_DATE, dbuff, -1);
-
- /* Num */
- gtk_list_store_set (store, &iter, SPLIT_COL_NUM, xaccTransGetNum (trans), -1);
-
- /* Description */
- gtk_list_store_set (store, &iter, SPLIT_COL_DESCRIPTION, xaccTransGetDescription (trans), -1);
-
- /* Amount */
- amnt = xaccSplitGetAmount (split);
- xaccSPrintAmount (amtbuff, amnt,
- gnc_account_print_info (lv->account, TRUE));
- gtk_list_store_set (store, &iter, SPLIT_COL_AMOUNT, amtbuff, -1);
-
- /* Value. Invert the sign on the first, opening entry. */
- currency = xaccTransGetCurrency (trans);
- valu = xaccSplitGetValue (split);
- if (node != split_list)
- {
- valu = gnc_numeric_neg (valu);
- }
- xaccSPrintAmount (valbuff, valu,
- gnc_commodity_print_info (currency, TRUE));
- gtk_list_store_set (store, &iter, SPLIT_COL_VALUE, valbuff, -1);
-
- /* Gains. Blank if none. */
- gains = xaccSplitGetCapGains (split);
- if (gnc_numeric_zero_p(gains))
- {
- gainbuff[0] = 0;
- }
- else
- {
- xaccSPrintAmount (gainbuff, gains,
- gnc_commodity_print_info (currency, TRUE));
- }
- gtk_list_store_set (store, &iter, SPLIT_COL_GAIN_LOSS, gainbuff, -1);
-
- /* Balance of Gains */
- baln = gnc_numeric_add_fixed (baln, amnt);
- if (gnc_numeric_zero_p(baln))
- {
- balnbuff[0] = 0;
- }
- else
- {
- xaccSPrintAmount (balnbuff, baln,
- gnc_account_print_info (lv->account, TRUE));
- }
- gtk_list_store_set (store, &iter, SPLIT_COL_BALANCE, balnbuff, -1);
-
- /* Self-reference */
- gtk_list_store_set(store, &iter, SPLIT_COL_PNTR, split, -1);
- }
-}
-
-/* ======================================================================== */
-/* Remove all splits from the split list */
-
-static void
-lv_clear_splits (GNCLotViewer *lv)
-{
- gtk_list_store_clear (lv->split_store);
-}
-
-/* ======================================================================== */
-/* Save potential changes to the currently selected lot */
-static void
-lv_save_current_row (GNCLotViewer *lv)
-{
- GNCLot *lot = lv->selected_lot;
- const char * str;
- char * notes;
-
- if (lot)
- {
- gnc_lot_begin_edit(lot);
-
- /* Get the title, save_the_title */
- str = gtk_entry_get_text (lv->title_entry);
- gnc_lot_set_title (lot, str);
-
- /* Get the notes, save the notes */
- notes = xxxgtk_textview_get_text (lv->lot_notes);
- gnc_lot_set_notes (lot, notes);
- g_free(notes);
-
- gnc_lot_commit_edit(lot);
- }
-}
-
-/* ======================================================================== */
-/* Select a row in the lot list */
-
-static void
-lv_select_row (GNCLotViewer *lv,
- GNCLot *lot)
-{
- const char * str;
-
- lv_save_current_row (lv);
-
- str = gnc_lot_get_title (lot);
- if (!str) str = "";
- gtk_entry_set_text (lv->title_entry, str);
- gtk_editable_set_editable (GTK_EDITABLE(lv->title_entry), TRUE);
-
- /* Set the notes field */
- str = gnc_lot_get_notes (lot);
- if (!str) str = "";
- xxxgtk_textview_set_text (lv->lot_notes, str);
- gtk_text_view_set_editable (lv->lot_notes, TRUE);
-
- /* Don't set until end, to avoid recursion in gtkentry "changed" cb. */
- lv->selected_lot = lot;
- lv_show_splits (lv);
-
-#ifdef LOTS_READY_FOR_SHOWTIME
- gtk_widget_set_sensitive(GTK_WIDGET(lv->regview_button), TRUE);
-#endif
- gtk_widget_set_sensitive(GTK_WIDGET(lv->delete_button), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(lv->scrub_lot_button), TRUE);
-}
-
-/* ======================================================================== */
-
-static void
-lv_unset_lot (GNCLotViewer *lv)
-{
- /* Set immediately, to avoid recursion in gtkentry "changed" cb. */
- lv->selected_lot = NULL;
-
- /* Blank the title widget */
- gtk_entry_set_text (lv->title_entry, "");
- gtk_editable_set_editable (GTK_EDITABLE(lv->title_entry), FALSE);
-
- /* Blank the notes area */
- xxxgtk_textview_set_text (lv->lot_notes, "");
- gtk_text_view_set_editable (lv->lot_notes, FALSE);
-
- /* Erase the mini-view area */
- lv_clear_splits (lv);
-
-#ifdef LOTS_READY_FOR_SHOWTIME
- gtk_widget_set_sensitive(GTK_WIDGET(lv->regview_button), FALSE);
-#endif
- gtk_widget_set_sensitive(GTK_WIDGET(lv->delete_button), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(lv->scrub_lot_button), FALSE);
-}
-
-/* ======================================================================== */
-/* De-select a row the the lot list */
-
-static void
-lv_unselect_row (GNCLotViewer *lv)
-{
- lv_save_current_row (lv);
- lv_unset_lot (lv);
-}
-
-/* ======================================================================== */
-/* Callback triggered when the user changes the selected line in the lot list */
-
-static void
-lv_selection_changed_cb (GtkTreeSelection *selection,
- GNCLotViewer *lv)
-{
- GNCLot *lot;
- GtkTreeModel *model;
- GtkTreeIter iter;
-
- if (gtk_tree_selection_get_selected (selection, &model, &iter))
- {
- gtk_tree_model_get(model, &iter, LOT_COL_PNTR, &lot, -1);
- lv_select_row(lv, lot);
- }
- else
- {
- lv_unselect_row(lv);
- }
-}
-
-
-/* ======================================================================== */
-/* Callback triggered when user types a new lot title into the entry widget */
-
-void
-lv_title_entry_changed_cb (GtkEntry *ent, gpointer user_data)
-{
- GNCLotViewer *lv = user_data;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreeSelection *selection;
- const char * title;
- title = gtk_entry_get_text (lv->title_entry);
-
- selection = gtk_tree_view_get_selection(lv->lot_view);
- if (gtk_tree_selection_get_selected (selection, &model, &iter))
- {
- gtk_list_store_set(GTK_LIST_STORE(model), &iter, LOT_COL_TITLE, title, -1);
- }
-}
-
-/* ======================================================================== */
-/* Get the realized gains for this lot. This routine or a variant of it
- * should probably be moved to gnc-lot.c.
- * The conceptual difficulty here is that this works only if all of the
- * realized gains in the lot are of the
- */
-
-static gnc_commodity *
-find_first_currency (GNCLot *lot)
-{
- SplitList *split_list, *node;
-
- split_list = gnc_lot_get_split_list(lot);
- for (node = split_list; node; node = node->next)
- {
- Split *s = node->data;
- Transaction *trans;
- if (FALSE == gnc_numeric_zero_p(xaccSplitGetAmount(s))) continue;
- trans = xaccSplitGetParent (s);
- return xaccTransGetCurrency (trans);
- }
- return NULL;
-}
-
-static gnc_numeric
-get_realized_gains (GNCLot *lot, gnc_commodity *currency)
-{
- gnc_numeric zero = gnc_numeric_zero();
- gnc_numeric gains = zero;
- SplitList *split_list, *node;
-
- if (!currency) return zero;
-
- split_list = gnc_lot_get_split_list(lot);
- for (node = split_list; node; node = node->next)
- {
- Split *s = node->data;
- Transaction *trans;
-
- if (FALSE == gnc_numeric_zero_p(xaccSplitGetAmount(s))) continue;
- trans = xaccSplitGetParent (s);
- if (FALSE == gnc_commodity_equal (xaccTransGetCurrency(trans), currency)) continue;
-
- gains = gnc_numeric_add (gains, xaccSplitGetValue (s), GNC_DENOM_AUTO, GNC_HOW_DENOM_FIXED);
- }
- return gains;
-}
-
-/* ======================================================================== */
-
-static void
-gnc_lot_viewer_fill (GNCLotViewer *lv)
-{
- LotList *lot_list, *node;
- GNCLot *this_lot, *selected_lot = NULL;
- GtkListStore *store;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreeSelection *selection;
- gboolean found = FALSE;
-
- lot_list = xaccAccountGetLotList (lv->account);
-
- selection = gtk_tree_view_get_selection(lv->lot_view);
- if (gtk_tree_selection_get_selected (selection, &model, &iter))
- gtk_tree_model_get(model, &iter, LOT_COL_PNTR, &selected_lot, -1);
-
- /* Crazy. Should update in place if possible. */
- gtk_list_store_clear (lv->lot_store);
-
- for (node = lot_list; node; node = node->next)
- {
- char obuff[MAX_DATE_LENGTH];
- char cbuff[MAX_DATE_LENGTH];
- char baln_buff[200];
- char gain_buff[200];
- GNCLot *lot = node->data;
- Split *esplit = gnc_lot_get_earliest_split (lot);
- Transaction *etrans = xaccSplitGetParent (esplit);
- time_t open_date = xaccTransGetDate (etrans);
- gnc_numeric amt_baln = gnc_lot_get_balance (lot);
- gnc_commodity *currency = find_first_currency (lot);
- gnc_numeric gains_baln = get_realized_gains (lot, currency);
-
- store = lv->lot_store;
- gtk_list_store_append(store, &iter);
-
- /* Opening date */
- qof_print_date_buff (obuff, MAX_DATE_LENGTH, open_date);
- gtk_list_store_set(store, &iter, LOT_COL_OPEN, obuff, -1);
-
- /* Closing date */
- if (gnc_lot_is_closed (lot))
- {
- Split *fsplit = gnc_lot_get_latest_split (lot);
- Transaction *ftrans = xaccSplitGetParent (fsplit);
- time_t close_date = xaccTransGetDate (ftrans);
-
- qof_print_date_buff (cbuff, MAX_DATE_LENGTH, close_date);
- gtk_list_store_set(store, &iter, LOT_COL_CLOSE, cbuff, -1);
- }
- else
- {
- gtk_list_store_set(store, &iter, LOT_COL_CLOSE, _("Open"), -1);
- }
-
- /* Title */
- gtk_list_store_set(store, &iter, LOT_COL_TITLE, gnc_lot_get_title(lot), -1);
-
- /* Amount */
- xaccSPrintAmount (baln_buff, amt_baln,
- gnc_account_print_info (lv->account, TRUE));
- gtk_list_store_set(store, &iter, LOT_COL_BALN, baln_buff, -1);
-
- /* Capital Gains/Losses Appreciation/Depreciation */
- xaccSPrintAmount (gain_buff, gains_baln,
- gnc_commodity_print_info (currency, TRUE));
- gtk_list_store_set(store, &iter, LOT_COL_GAINS, gain_buff, -1);
-
- /* Self-reference */
- gtk_list_store_set(store, &iter, LOT_COL_PNTR, lot, -1);
- }
- g_list_free(lot_list);
-
- /* re-select the row that the user had previously selected,
- * if possible. */
- if (selected_lot)
- {
- model = GTK_TREE_MODEL(lv->lot_store);
- if (gtk_tree_model_get_iter_first(model, &iter))
- {
- do
- {
- gtk_tree_model_get(model, &iter, LOT_COL_PNTR, &this_lot, -1);
- if (this_lot == selected_lot)
- {
- gtk_tree_selection_select_iter(selection, &iter);
- found = TRUE;
- break;
- }
- }
- while (gtk_tree_model_iter_next(model, &iter));
- }
- }
-
- if (!found)
- gtk_tree_selection_unselect_all(selection);
-}
-
-/* ======================================================================== */
-
-static void
-lv_refresh_handler (GHashTable *changes, gpointer user_data)
-{
- GNCLotViewer *lv = user_data;
- gnc_lot_viewer_fill (lv);
- lv_show_splits (lv);
-}
-
-static void
-lv_close_handler (gpointer user_data)
-{
- GNCLotViewer *lv = user_data;
- GNCLot *lot = lv->selected_lot;
-
- lv_save_current_row (lv);
-
- gnc_save_window_size(GCONF_SECTION, GTK_WINDOW(lv->window));
- gtk_widget_destroy (lv->window);
-}
-
-void
-lv_window_destroy_cb (GtkObject *object, gpointer user_data)
-{
- GNCLotViewer *lv = user_data;
- gnc_close_gui_component_by_data (LOT_VIEWER_CM_CLASS, lv);
- gnc_unregister_gui_component_by_data (LOT_VIEWER_CM_CLASS, lv);
- g_free (lv);
-}
-
-
-/* ======================================================================== */
-/* Divider moved */
-
-void
-lv_paned_notify_cb (GObject *gobject,
- GParamSpec *pspec,
- gpointer user_data)
-{
- const gchar *param_name;
- gint value;
-
- param_name = g_param_spec_get_name(pspec);
- if (strcmp(param_name, "position") != 0)
- return;
- g_object_get(gobject, "position", &value, NULL);
-
- if (GTK_IS_HPANED(gobject))
- {
- gnc_gconf_set_int(GCONF_SECTION, GCONF_KEY_HPOSITION, value, NULL);
- }
- else
- {
- gnc_gconf_set_int(GCONF_SECTION, GCONF_KEY_VPOSITION, value, NULL);
- }
-}
-
-/* ======================================================================== */
-/* Any button was pressed */
-
-void
-lv_response_cb (GtkDialog *dialog, gint response, gpointer data)
-{
- GNCLotViewer *lv = data;
- GNCLot *lot = lv->selected_lot;
-
- switch (response)
- {
- case GTK_RESPONSE_CLOSE:
- lv_close_handler(lv);
- return;
-
- case RESPONSE_VIEW:
- if (NULL == lot)
- return;
- printf ("UNIMPLEMENTED: need to display register showing only this one lot \n");
- break;
-
- case RESPONSE_DELETE:
- if (NULL == lot)
- return;
- xaccAccountRemoveLot (gnc_lot_get_account(lot), lot);
- gnc_lot_destroy (lot);
- lv_unset_lot (lv);
- gnc_lot_viewer_fill (lv);
- break;
-
- case RESPONSE_SCRUB_LOT:
- if (NULL == lot)
- return;
- xaccScrubLot (lot);
- gnc_lot_viewer_fill (lv);
- lv_show_splits (lv);
- break;
-
- case RESPONSE_SCRUB_ACCOUNT:
- gnc_suspend_gui_refresh ();
- xaccAccountScrubLots (lv->account);
- gnc_resume_gui_refresh ();
- gnc_lot_viewer_fill (lv);
- lv_show_splits (lv);
- break;
-
- case RESPONSE_NEW_LOT:
- lv_save_current_row (lv);
- lot = gnc_lot_make_default (lv->account);
- xaccAccountInsertLot (lv->account, lot);
- break;
- }
-}
-
-/* ======================================================================== */
-
-static void
-lv_init_split_view (GNCLotViewer *lv)
-{
- GtkTreeView *view;
- GtkListStore *store;
- GtkTreeViewColumn *column;
- GtkTreeSelection *selection;
- GtkCellRenderer *renderer;
-
- g_return_if_fail(GTK_IS_TREE_VIEW(lv->split_view));
-
- view = lv->split_view;
- store = gtk_list_store_new(NUM_SPLIT_COLS, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_POINTER);
- gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
- g_object_unref(store);
- lv->split_store = store;
-
- /* Set up the columns */
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(_("Date"), renderer,
- "text", SPLIT_COL_DATE, NULL);
- gtk_tree_view_append_column(view, column);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(_("Num"), renderer,
- "text", SPLIT_COL_NUM, NULL);
- gtk_tree_view_append_column(view, column);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(_("Description"), renderer,
- "text", SPLIT_COL_DESCRIPTION, NULL);
- gtk_tree_view_append_column(view, column);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(_("Amount"), renderer,
- "text", SPLIT_COL_AMOUNT, NULL);
- gtk_tree_view_append_column(view, column);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(_("Value"), renderer,
- "text", SPLIT_COL_VALUE, NULL);
- gtk_tree_view_append_column(view, column);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(_("Gain/Loss"), renderer,
- "text", SPLIT_COL_GAIN_LOSS, NULL);
- gtk_tree_view_append_column(view, column);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(_("Balance"), renderer,
- "text", SPLIT_COL_BALANCE, NULL);
- gtk_tree_view_append_column(view, column);
-}
-
-/* ======================================================================== */
-
-static void
-lv_init_lot_view (GNCLotViewer *lv)
-{
- GtkTreeView *view;
- GtkListStore *store;
- GtkTreeViewColumn *column;
- GtkTreeSelection *selection;
- GtkCellRenderer *renderer;
-
- g_return_if_fail(GTK_IS_TREE_VIEW(lv->lot_view));
-
- view = lv->lot_view;
- store = gtk_list_store_new(NUM_LOT_COLS, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_POINTER);
- gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
- g_object_unref(store);
- lv->lot_store = store;
-
- /* Set up the columns */
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(_("Opened"), renderer,
- "text", LOT_COL_OPEN, NULL);
- gtk_tree_view_append_column(view, column);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(_("Closed"), renderer,
- "text", LOT_COL_CLOSE, NULL);
- gtk_tree_view_append_column(view, column);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(_("Title"), renderer,
- "text", LOT_COL_TITLE, NULL);
- gtk_tree_view_append_column(view, column);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(_("Balance"), renderer,
- "text", LOT_COL_BALN, NULL);
- gtk_tree_view_append_column(view, column);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(_("Gains"), renderer,
- "text", LOT_COL_GAINS, NULL);
- gtk_tree_view_append_column(view, column);
-
- /* Set up the selection callbacks */
- selection = gtk_tree_view_get_selection(view);
- g_signal_connect(selection, "changed",
- G_CALLBACK(lv_selection_changed_cb), lv);
-}
-
-/* ======================================================================== */
-
-static void
-lv_create (GNCLotViewer *lv)
-{
- gchar *win_title;
- gint position;
- GtkBuilder *builder;
-
-
- builder = gtk_builder_new();
- gnc_builder_add_from_file (builder, "lots.glade", "Lot Viewer Window");
-
- lv->window = GTK_WIDGET(gtk_builder_get_object (builder, "Lot Viewer Window"));
-
- win_title=g_strdup_printf (_("Lots in Account %s"),
- xaccAccountGetName(lv->account));
- gtk_window_set_title (GTK_WINDOW (lv->window), win_title);
- g_free (win_title);
-
-#ifdef LOTS_READY_FOR_SHOWTIME
- lv->regview_button = GTK_BUTTON(glade_xml_get_widget (builder, "regview button"));
-#endif
- lv->delete_button = GTK_BUTTON(gtk_builder_get_object (builder, "delete button"));
- lv->scrub_lot_button = GTK_BUTTON(gtk_builder_get_object (builder, "scrub lot button"));
- lv->new_lot_button = GTK_BUTTON(gtk_builder_get_object (builder, "new lot button"));
-
- lv->lot_view = GTK_TREE_VIEW(gtk_builder_get_object (builder, "lot view"));
- lv_init_lot_view(lv);
- lv->lot_notes = GTK_TEXT_VIEW(gtk_builder_get_object (builder, "lot notes text"));
- lv->title_entry = GTK_ENTRY (gtk_builder_get_object (builder, "lot title entry"));
-
- lv->split_view = GTK_TREE_VIEW(gtk_builder_get_object (builder, "split view"));
- lv_init_split_view(lv);
-
- lv->lot_vpaned = GTK_PANED (gtk_builder_get_object (builder, "lot vpaned"));
- position = gnc_gconf_get_int(GCONF_SECTION, GCONF_KEY_VPOSITION, NULL);
- if (position)
- gtk_paned_set_position (lv->lot_vpaned, position);
-
- lv->lot_hpaned = GTK_PANED (gtk_builder_get_object (builder, "lot hpaned"));
- position = gnc_gconf_get_int(GCONF_SECTION, GCONF_KEY_HPOSITION, NULL);
- if (position)
- gtk_paned_set_position (lv->lot_hpaned, position);
-
- lv->selected_lot = NULL;
-
- /* Setup signals */
- gtk_builder_connect_signals(builder, lv);
- g_object_unref(G_OBJECT(builder));
-
- gnc_restore_window_size(GCONF_SECTION, GTK_WINDOW(lv->window));
-}
-
-/* ======================================================================== */
-
-GNCLotViewer *
-gnc_lot_viewer_dialog (Account *account)
-{
- GNCLotViewer *lv;
- gint component_id;
-
- if (!account) return NULL;
-
- lv = g_new0 (GNCLotViewer, 1);
- lv->account = account;
- lv_create (lv);
- gnc_lot_viewer_fill (lv);
-
- component_id = gnc_register_gui_component (LOT_VIEWER_CM_CLASS,
- lv_refresh_handler,
- lv_close_handler,
- lv);
-
- gnc_gui_component_watch_entity_type (component_id,
- GNC_ID_LOT,
- QOF_EVENT_CREATE | QOF_EVENT_ADD | QOF_EVENT_REMOVE | QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);
-
- gtk_widget_show_all (lv->window);
- gnc_window_adjust_for_screen (GTK_WINDOW(lv->window));
-
- return lv;
-}
-
-/* ============================ END OF FILE =============================== */
Deleted: gnucash/trunk/src/gnome/lot-viewer.h
===================================================================
--- gnucash/trunk/src/gnome/lot-viewer.h 2011-08-10 21:10:29 UTC (rev 21147)
+++ gnucash/trunk/src/gnome/lot-viewer.h 2011-08-10 21:10:42 UTC (rev 21148)
@@ -1,34 +0,0 @@
-/*******************************************************************\
- * lot-viewer.h -- a basic lot viewer for GnuCash *
- * Copyright (C) 2003 Linas Vepstas <linas at linas.org> *
- * *
- * 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 at gnu.org *
- * *
-\********************************************************************/
-
-#ifndef LOT_VIEWER_H
-#define LOT_VIEWER_H
-
-#include "Account.h"
-
-typedef struct _GNCLotViewer GNCLotViewer;
-
-/** Create and realize and show a lot-viewing dialog. */
-GNCLotViewer * gnc_lot_viewer_dialog (Account *);
-
-#endif /* LOT_VIEWER_H */
More information about the gnucash-changes
mailing list