Skip to content

Commit

Permalink
2001-05-08 Dave Peticolas <dave@krondo.com>
Browse files Browse the repository at this point in the history
	* src/scm/price-quotes.scm: add currency quote support

	* src/gnome/dialog-account.c: add currency quote support

	* src/engine/Account.c: allow CURRENCY accounts to have price
	source set.

	* src/quotes/finance-quote-helper.in: add currency quote support


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4128 57a11ea4-9604-0410-9ed3-97b8803252fd
  • Loading branch information
jdavisp3 committed May 8, 2001
1 parent f9fb478 commit 4fae9be
Show file tree
Hide file tree
Showing 7 changed files with 271 additions and 98 deletions.
11 changes: 11 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2001-05-08 Dave Peticolas <dave@krondo.com>

* src/scm/price-quotes.scm: add currency quote support

* src/gnome/dialog-account.c: add currency quote support

* src/engine/Account.c: allow CURRENCY accounts to have price
source set.

* src/quotes/finance-quote-helper.in: add currency quote support

2001-05-07 Christian Stimming <stimming@tuhh.de>

* src/scm/commodity-utilities.scm: Always use the absolute value
Expand Down
8 changes: 4 additions & 4 deletions src/engine/Account.c
Original file line number Diff line number Diff line change
Expand Up @@ -2115,7 +2115,7 @@ xaccAccountSetPriceSrc(Account *acc, const char *src)
{
GNCAccountType t = xaccAccountGetType(acc);

if((t == STOCK) || (t == MUTUAL)) {
if((t == STOCK) || (t == MUTUAL) || (t == CURRENCY)) {
kvp_frame_set_slot_nc(acc->kvp_data,
"old-price-source",
src ? kvp_value_new_string(src) : NULL);
Expand All @@ -2136,7 +2136,7 @@ xaccAccountGetPriceSrc(Account *acc)
if(!acc) return NULL;

t = xaccAccountGetType(acc);
if((t == STOCK) || (t == MUTUAL))
if((t == STOCK) || (t == MUTUAL) || (t == CURRENCY))
{
kvp_value *value = kvp_frame_get_slot(acc->kvp_data, "old-price-source");
if(value) return (kvp_value_get_string(value));
Expand All @@ -2157,7 +2157,7 @@ xaccAccountSetQuoteTZ(Account *acc, const char *tz)
{
GNCAccountType t = xaccAccountGetType(acc);

if((t == STOCK) || (t == MUTUAL)) {
if((t == STOCK) || (t == MUTUAL) || (t == CURRENCY)) {
kvp_frame_set_slot_nc(acc->kvp_data,
"old-quote-tz",
kvp_value_new_string(tz));
Expand All @@ -2178,7 +2178,7 @@ xaccAccountGetQuoteTZ(Account *acc)
if(!acc) return NULL;

t = xaccAccountGetType(acc);
if((t == STOCK) || (t == MUTUAL))
if((t == STOCK) || (t == MUTUAL) || (t == CURRENCY))
{
kvp_value *value = kvp_frame_get_slot(acc->kvp_data, "old-quote-tz");
if(value) return (kvp_value_get_string(value));
Expand Down
80 changes: 73 additions & 7 deletions src/gnome/dialog-account.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ struct _AccountWindow

/* These probably don't belong here anymore, but until we figure out
what we want, we'll leave them alone. */
GtkWidget * get_quote_check;
GtkWidget * source_menu;
GtkWidget * quote_tz_menu;
GtkWidget * quote_frame;

GtkWidget * tax_related_button;

Expand Down Expand Up @@ -150,9 +150,11 @@ gnc_account_to_ui(AccountWindow *aw)
return;

string = xaccAccountGetName (account);
if (string == NULL) string = "";
gtk_entry_set_text(GTK_ENTRY(aw->name_entry), string);

string = xaccAccountGetDescription (account);
if (string == NULL) string = "";
gtk_entry_set_text(GTK_ENTRY(aw->description_entry), string);

commodity = xaccAccountGetCurrency (account);
Expand All @@ -164,6 +166,7 @@ gnc_account_to_ui(AccountWindow *aw)
commodity);

string = xaccAccountGetCode (account);
if (string == NULL) string = "";
gtk_entry_set_text(GTK_ENTRY(aw->code_entry), string);

string = xaccAccountGetNotes (account);
Expand All @@ -183,7 +186,11 @@ gnc_account_to_ui(AccountWindow *aw)
{
/* we'll let GetPriceSrc handle the account type checking... */
const char* price_src = xaccAccountGetPriceSrc (account);
if (price_src)

gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (aw->get_quote_check),
price_src != NULL);

if (price_src && aw->type != CURRENCY)
gtk_option_menu_set_history (GTK_OPTION_MENU (aw->source_menu),
gnc_get_source_code (price_src));
}
Expand Down Expand Up @@ -303,13 +310,37 @@ gnc_ui_to_account(AccountWindow *aw)

if ((STOCK == aw->type) || (MUTUAL == aw->type) || (CURRENCY == aw->type))
{
gboolean get_quote;

commodity = gnc_commodity_edit_get_commodity
(GNC_COMMODITY_EDIT (aw->security_edit));
if (commodity &&
!gnc_commodity_equiv (commodity, xaccAccountGetSecurity(account)))
xaccAccountSetSecurity (account, commodity);

if ((STOCK == aw->type) || (MUTUAL == aw->type))
get_quote = gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (aw->get_quote_check));

if (!get_quote)
{
if (xaccAccountGetPriceSrc (account))
xaccAccountSetPriceSrc (account, NULL);
}
else if (CURRENCY == aw->type)
{
gint code;

old_string = xaccAccountGetPriceSrc (account);
if (safe_strcmp ("CURRENCY", old_string) != 0)
xaccAccountSetPriceSrc (account, "CURRENCY");

code = gnc_option_menu_get_active (aw->quote_tz_menu);
string = gnc_timezone_menu_position_to_string(code);
old_string = xaccAccountGetQuoteTZ (account);
if (safe_strcmp (string, old_string) != 0)
xaccAccountSetQuoteTZ (account, string);
}
else if ((STOCK == aw->type) || (MUTUAL == aw->type))
{
gint code;

Expand Down Expand Up @@ -1286,6 +1317,7 @@ gnc_type_list_select_cb(GtkCList * type_list, gint row, gint column,
GdkEventButton * event, gpointer data)
{
AccountWindow * aw = data;
gboolean get_quote;
gboolean sensitive;

if (aw == NULL)
Expand All @@ -1301,12 +1333,21 @@ gnc_type_list_select_cb(GtkCList * type_list, gint row, gint column,

last_used_account_type = row;

get_quote = gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (aw->get_quote_check));

sensitive = (aw->type == STOCK ||
aw->type == MUTUAL ||
aw->type == CURRENCY);

gtk_widget_set_sensitive(aw->security_edit, sensitive);
gtk_widget_set_sensitive(aw->quote_frame, sensitive);
gtk_widget_set_sensitive(aw->get_quote_check, sensitive);
gtk_widget_set_sensitive(aw->quote_tz_menu, sensitive && get_quote);

sensitive = (aw->type == STOCK ||
aw->type == MUTUAL);

gtk_widget_set_sensitive(aw->source_menu, sensitive && get_quote);

sensitive = (aw->type != EQUITY &&
aw->type != CURRENCY &&
Expand All @@ -1332,7 +1373,9 @@ gnc_type_list_unselect_cb(GtkCList * type_list, gint row, gint column,
aw->type = BAD_TYPE;

gtk_widget_set_sensitive(aw->security_edit, FALSE);
gtk_widget_set_sensitive(aw->quote_frame, FALSE);
gtk_widget_set_sensitive(aw->get_quote_check, FALSE);
gtk_widget_set_sensitive(aw->source_menu, FALSE);
gtk_widget_set_sensitive(aw->quote_tz_menu, FALSE);
}


Expand Down Expand Up @@ -1492,6 +1535,27 @@ opening_equity_cb (GtkWidget *w, gpointer data)
gtk_widget_set_sensitive (aw->transfer_account_frame, !use_equity);
}

static void
get_quote_check_cb (GtkWidget *w, gpointer data)
{
AccountWindow *aw = data;
gboolean get_quote;
gboolean sensitive;

get_quote = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));

sensitive = (aw->type == STOCK ||
aw->type == MUTUAL ||
aw->type == CURRENCY);

gtk_widget_set_sensitive(aw->quote_tz_menu, sensitive && get_quote);

sensitive = (aw->type == STOCK ||
aw->type == MUTUAL);

gtk_widget_set_sensitive(aw->source_menu, sensitive && get_quote);
}

/********************************************************************\
* gnc_account_window_create *
* creates a window to create a new account. *
Expand Down Expand Up @@ -1554,6 +1618,10 @@ gnc_account_window_create(AccountWindow *aw)
aw->security_edit = gnc_commodity_edit_new ();
gtk_box_pack_start(GTK_BOX(box), aw->security_edit, TRUE, TRUE, 0);

aw->get_quote_check = gtk_object_get_data (awo, "get_quote_check");
gtk_signal_connect (GTK_OBJECT (aw->get_quote_check), "toggled",
GTK_SIGNAL_FUNC (get_quote_check_cb), aw);

box = gtk_object_get_data(awo, "source_box");
aw->source_menu = gnc_ui_source_menu_create(aw_get_account (aw));
gtk_box_pack_start(GTK_BOX(box), aw->source_menu, TRUE, TRUE, 0);
Expand All @@ -1562,8 +1630,6 @@ gnc_account_window_create(AccountWindow *aw)
aw->quote_tz_menu = gnc_ui_quote_tz_menu_create(aw_get_account (aw));
gtk_box_pack_start(GTK_BOX(box), aw->quote_tz_menu, TRUE, TRUE, 0);

aw->quote_frame = gtk_object_get_data (awo, "price_quote_frame");

box = gtk_object_get_data(awo, "parent_scroll");

aw->top_level_account = xaccMallocAccount();
Expand Down
20 changes: 18 additions & 2 deletions src/gnome/glade-gnc-dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -3404,6 +3404,8 @@ create_Account_Dialog (void)
GtkWidget *frame30;
GtkWidget *parent_scroll;
GtkWidget *price_quote_frame;
GtkWidget *vbox129;
GtkWidget *get_quote_check;
GtkWidget *hbox103;
GtkWidget *vbox116;
GtkWidget *label813;
Expand Down Expand Up @@ -3638,13 +3640,27 @@ create_Account_Dialog (void)
gtk_box_pack_start (GTK_BOX (vbox75), price_quote_frame, FALSE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (price_quote_frame), 3);

vbox129 = gtk_vbox_new (FALSE, 3);
gtk_widget_ref (vbox129);
gtk_object_set_data_full (GTK_OBJECT (Account_Dialog), "vbox129", vbox129,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (vbox129);
gtk_container_add (GTK_CONTAINER (price_quote_frame), vbox129);
gtk_container_set_border_width (GTK_CONTAINER (vbox129), 3);

get_quote_check = gtk_check_button_new_with_label (_("Get Online Quotes"));
gtk_widget_ref (get_quote_check);
gtk_object_set_data_full (GTK_OBJECT (Account_Dialog), "get_quote_check", get_quote_check,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (get_quote_check);
gtk_box_pack_start (GTK_BOX (vbox129), get_quote_check, FALSE, FALSE, 0);

hbox103 = gtk_hbox_new (FALSE, 2);
gtk_widget_ref (hbox103);
gtk_object_set_data_full (GTK_OBJECT (Account_Dialog), "hbox103", hbox103,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (hbox103);
gtk_container_add (GTK_CONTAINER (price_quote_frame), hbox103);
gtk_container_set_border_width (GTK_CONTAINER (hbox103), 3);
gtk_box_pack_start (GTK_BOX (vbox129), hbox103, TRUE, TRUE, 0);

vbox116 = gtk_vbox_new (TRUE, 0);
gtk_widget_ref (vbox116);
Expand Down
Loading

0 comments on commit 4fae9be

Please sign in to comment.