diff --git a/ChangeLog b/ChangeLog index 6aa410c59e..417514b74f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-04-10 Dave Peticolas + + * src/gnome/dialog-commodities.c: new file. commodity editor. + unfinished. + 2001-04-10 Christian Stimming * src/scm/report/net-worth-timeseries.scm: Fixed date argument @@ -20,6 +25,10 @@ * src/scm/report/{Makefile.am, report-list.scm}: add new barchart. +2001-04-09 Dave Peticolas + + * src/gnome/dialog-price-editor.c: more work + 2001-04-09 Robert Graham Merkel * src/scm/report/balance-sheet.scm (balance-sheet-renderer): diff --git a/doc/sgml/C/xacc-about.sgml b/doc/sgml/C/xacc-about.sgml index b5ea9f78d2..dd77deac95 100644 --- a/doc/sgml/C/xacc-about.sgml +++ b/doc/sgml/C/xacc-about.sgml @@ -1299,8 +1299,7 @@ For now, this is what we have. scheme -- scheme and guile code -- src/scm plus - src/guile -- in parenthesis is src/guile -- in parenthesis is *.c + *.h + *.scm @@ -1311,7 +1310,8 @@ For now, this is what we have. Languages -- the number of languages that the application messages have been translated to. In parenthesis, the number of messages - in the message files grep msgstr *.po |wc, + in thousands. diff --git a/doc/sgml/C/xacc-reports.sgml b/doc/sgml/C/xacc-reports.sgml index a86e18268f..6197f34306 100644 --- a/doc/sgml/C/xacc-reports.sgml +++ b/doc/sgml/C/xacc-reports.sgml @@ -120,6 +120,7 @@ examine some of the other reports in src/scm/report rendering this with a HTML widget. (Future versions of GnuCash will hopefully support a more flexible system). + diff --git a/po/POTFILES.in b/po/POTFILES.in index 99529d2db1..62bde80d4d 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -12,10 +12,12 @@ src/gnome/dialog-account-picker.c src/gnome/dialog-account.c src/gnome/dialog-budget.c src/gnome/dialog-column-view.c +src/gnome/dialog-commodities.c src/gnome/dialog-commodity.c src/gnome/dialog-filebox.c src/gnome/dialog-fincalc.c src/gnome/dialog-options.c +src/gnome/dialog-price-editor.c src/gnome/dialog-progress.c src/gnome/dialog-totd.c src/gnome/dialog-transfer.c diff --git a/src/gnc-ui.h b/src/gnc-ui.h index a5b3f361d9..ab27661f33 100644 --- a/src/gnc-ui.h +++ b/src/gnc-ui.h @@ -90,6 +90,7 @@ gboolean gnc_dup_trans_dialog (gncUIWidget parent, time_t *date_p, void gnc_tax_info_dialog (gncUIWidget parent); void gnc_stock_split_dialog (Account * initial); void gnc_prices_dialog (gncUIWidget parent); +void gnc_commodities_dialog (gncUIWidget parent); /* Open a dialog asking for username and password. The heading and * either 'initial_*' arguments may be NULL. If the dialog returns diff --git a/src/gnome/Makefile.am b/src/gnome/Makefile.am index 98ccdfc3c9..15ac7d4228 100644 --- a/src/gnome/Makefile.am +++ b/src/gnome/Makefile.am @@ -8,6 +8,7 @@ libgncgnome_a_SOURCES = \ dialog-account.c \ dialog-budget.c \ dialog-column-view.c \ + dialog-commodities.c \ dialog-commodity.c \ dialog-dup-trans.c \ dialog-filebox.c \ diff --git a/src/gnome/dialog-commodities.c b/src/gnome/dialog-commodities.c new file mode 100644 index 0000000000..3d7d16313b --- /dev/null +++ b/src/gnome/dialog-commodities.c @@ -0,0 +1,395 @@ +/********************************************************************\ + * dialog-commodities.c -- commodities dialog * + * Copyright (C) 2001 Gnumatic, Inc. * + * Author: Dave Peticolas * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation; either version 2 of * + * the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License* + * along with this program; if not, contact: * + * * + * Free Software Foundation Voice: +1-617-542-5942 * + * 59 Temple Place - Suite 330 Fax: +1-617-542-2652 * + * Boston, MA 02111-1307, USA gnu@gnu.org * +\********************************************************************/ + +#include "config.h" + +#include + +#include "FileDialog.h" +#include "dialog-commodity.h" +#include "dialog-utils.h" +#include "glade-gnc-dialogs.h" +#include "glade-support.h" +#include "gnc-commodity.h" +#include "gnc-component-manager.h" +#include "gnc-engine-util.h" +#include "gnc-ui.h" +#include "messages.h" + + +#define DIALOG_COMMODITIES_CM_CLASS "dialog-commodities" + +/* This static indicates the debugging module that this .o belongs to. */ +/* static short module = MOD_GUI; */ + +typedef struct +{ + GtkWidget * dialog; + + GtkWidget * commodity_list; + GtkWidget * edit_button; + GtkWidget * remove_button; + + gnc_commodity *commodity; + gboolean new; +} CommoditiesDialog; + + +static gint last_width = 0; +static gint last_height = 0; + + +static int +commodity_compare (gconstpointer a, gconstpointer b) +{ + gnc_commodity *comm_a = (gnc_commodity *) a; + gnc_commodity *comm_b = (gnc_commodity *) b; + gint fraction_a; + gint fraction_b; + + SAFE_STRCMP (gnc_commodity_get_namespace (comm_a), + gnc_commodity_get_namespace (comm_b)); + + SAFE_STRCMP (gnc_commodity_get_mnemonic (comm_a), + gnc_commodity_get_mnemonic (comm_b)); + + SAFE_STRCMP (gnc_commodity_get_fullname (comm_a), + gnc_commodity_get_fullname (comm_b)); + + SAFE_STRCMP (gnc_commodity_get_exchange_code (comm_a), + gnc_commodity_get_exchange_code (comm_b)); + + fraction_a = gnc_commodity_get_fraction (comm_a); + fraction_b = gnc_commodity_get_fraction (comm_b); + + if (fraction_a < fraction_b) + return -1; + + if (fraction_b < fraction_a) + return 1; + + return 0; +} + +static int +namespace_compare (gconstpointer a, gconstpointer b) +{ + return safe_strcmp (a, b); +} + +static void +gnc_load_namespace (gpointer data, gpointer user_data) +{ + const char *namespace = data; + CommoditiesDialog *cd = user_data; + gnc_commodity_table *ct; + GList *commodities; + GList *node; + + ct = gnc_engine_commodities (); + + commodities = gnc_commodity_table_get_commodities (ct, namespace); + + commodities = g_list_sort (commodities, commodity_compare); + + for (node = commodities; node; node = node->next) + { + gnc_commodity *commodity = node->data; + const char *text[5]; + gint row; + + text[0] = gnc_commodity_get_namespace (commodity); + text[1] = gnc_commodity_get_mnemonic (commodity); + text[2] = gnc_commodity_get_fullname (commodity); + text[3] = gnc_commodity_get_exchange_code (commodity); + text[4] = g_strdup_printf ("%d", gnc_commodity_get_fraction (commodity)); + + row = gtk_clist_append (GTK_CLIST (cd->commodity_list), (char **)text); + + g_free ((char *) text[4]); + + gtk_clist_set_row_data (GTK_CLIST (cd->commodity_list), row, commodity); + } + + g_list_free (commodities); +} + +static guint +gnc_commodities_load_commodities (CommoditiesDialog *cd) +{ + gnc_commodity_table *ct; + GList *namespaces; + GList *node; + int new_row; + guint size; + + ct = gnc_engine_commodities (); + + namespaces = gnc_commodity_table_get_namespaces (ct); + namespaces = g_list_sort (namespaces, namespace_compare); + + gtk_clist_freeze (GTK_CLIST (cd->commodity_list)); + + gtk_clist_clear (GTK_CLIST (cd->commodity_list)); + + g_list_foreach (namespaces, gnc_load_namespace, cd); + + gtk_clist_thaw (GTK_CLIST (cd->commodity_list)); + + gtk_clist_columns_autosize (GTK_CLIST (cd->commodity_list)); + + new_row = gtk_clist_find_row_from_data (GTK_CLIST (cd->commodity_list), + cd->commodity); + if (new_row < 0) + new_row = 0; + + gtk_clist_select_row (GTK_CLIST (cd->commodity_list), new_row, 0); + if (gtk_clist_row_is_visible (GTK_CLIST (cd->commodity_list), new_row) + != GTK_VISIBILITY_FULL) + gtk_clist_moveto (GTK_CLIST (cd->commodity_list), + new_row, 0, 0.5, 0.0); + + size = gnc_commodity_table_get_size (ct); + + gtk_widget_set_sensitive (cd->edit_button, size != 0); + gtk_widget_set_sensitive (cd->remove_button, size != 0); + + g_list_free (namespaces); + + return size; +} + +static void +window_destroy_cb (GtkObject *object, gpointer data) +{ + CommoditiesDialog *cd = data; + + gnc_unregister_gui_component_by_data (DIALOG_COMMODITIES_CM_CLASS, cd); + + g_free (cd); +} + +static void +close_clicked (GtkWidget *widget, gpointer data) +{ + CommoditiesDialog *cd = data; + + gnc_close_gui_component_by_data (DIALOG_COMMODITIES_CM_CLASS, cd); +} + +static void +edit_clicked (GtkWidget *widget, gpointer data) +{ + CommoditiesDialog *cd = data; + + if (!cd->commodity) + return; +} + +static void +remove_clicked (GtkWidget *widget, gpointer data) +{ + CommoditiesDialog *cd = data; + const char *message = _("Are you sure you want to delete the\n" + "current commodity?"); + + if (!cd->commodity) + return; +} + +static void +add_clicked (GtkWidget *widget, gpointer data) +{ + CommoditiesDialog *cd = data; +} + +static void +select_commodity_cb (GtkCList *clist, gint row, gint col, + GdkEventButton *event, gpointer data) +{ + CommoditiesDialog *cd = data; + + cd->commodity = gtk_clist_get_row_data (clist, row); + cd->new = FALSE; + + gtk_widget_set_sensitive (cd->edit_button, + cd->commodity != NULL); + gtk_widget_set_sensitive (cd->remove_button, + cd->commodity != NULL); +} + +static void +unselect_commodity_cb (GtkCTree *ctre, gint row, gint col, + GdkEventButton *event, gpointer data) +{ + CommoditiesDialog *cd = data; + + cd->commodity = NULL; + cd->new = FALSE; + + gtk_widget_set_sensitive (cd->edit_button, FALSE); + gtk_widget_set_sensitive (cd->remove_button, FALSE); +} + +static void +commodities_set_min_widths (CommoditiesDialog *cd) +{ + const char *titles[] = { _("Type"), + _("Symbol"), + _("Name"), + _("Code"), + _("Fraction") }; + + GtkStyle *style = gtk_widget_get_style (cd->commodity_list); + GdkFont *font = NULL; + gint width; + gint i; + + if (style != NULL) + font = style->font; + + if (font != NULL) + for (i = 0; i < 5; i++) + { + width = gdk_string_width (font, titles[i]); + gtk_clist_set_column_min_width (GTK_CLIST (cd->commodity_list), + i, width + 5); + } +} + +static void +gnc_commodities_dialog_create (GtkWidget * parent, CommoditiesDialog *cd) +{ + GtkWidget *dialog; + + dialog = create_Commodities_Dialog (); + cd->dialog = dialog; + + gnome_dialog_button_connect (GNOME_DIALOG (dialog), 0, + GTK_SIGNAL_FUNC (close_clicked), cd); + + gtk_signal_connect (GTK_OBJECT (dialog), "destroy", + GTK_SIGNAL_FUNC (window_destroy_cb), cd); + + /* parent */ + if (parent != NULL) + gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (parent)); + + /* default to ok */ + gnome_dialog_set_default (GNOME_DIALOG(dialog), 0); + + /* commodity tree */ + { + GtkWidget *list; + + list = lookup_widget (dialog, "commodity_list"); + cd->commodity_list = list; + + gtk_signal_connect (GTK_OBJECT(list), "select_row", + GTK_SIGNAL_FUNC(select_commodity_cb), cd); + + gtk_signal_connect (GTK_OBJECT(list), "unselect_row", + GTK_SIGNAL_FUNC(unselect_commodity_cb), cd); + } + + /* buttons */ + { + GtkWidget *button; + + button = lookup_widget (dialog, "edit_button"); + cd->edit_button = button; + + gtk_signal_connect (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (edit_clicked), cd); + + button = lookup_widget (dialog, "remove_button"); + cd->remove_button = button; + + gtk_signal_connect (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (remove_clicked), cd); + + button = lookup_widget (dialog, "add_button"); + + gtk_signal_connect (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (add_clicked), cd); + } + + gnc_commodities_load_commodities (cd); + commodities_set_min_widths (cd); + + if (last_width == 0) + gnc_get_window_size ("commodities_win", &last_width, &last_height); + + if (last_height == 0) + last_height = 400; + + gtk_window_set_default_size (GTK_WINDOW(cd->dialog), + last_width, last_height); +} + +static void +close_handler (gpointer user_data) +{ + CommoditiesDialog *cd = user_data; + + gdk_window_get_geometry (GTK_WIDGET(cd->dialog)->window, + NULL, NULL, &last_width, &last_height, NULL); + + gnc_save_window_size ("commodities_win", last_width, last_height); + + gnome_dialog_close (GNOME_DIALOG (cd->dialog)); +} + +static void +refresh_handler (GHashTable *changes, gpointer user_data) +{ + CommoditiesDialog *cd = user_data; + + gnc_commodities_load_commodities (cd); +} + +/********************************************************************\ + * gnc_commodities_dialog * + * opens up a window to edit price information * + * * + * Args: parent - the parent of the window to be created * + * Return: nothing * +\********************************************************************/ +void +gnc_commodities_dialog (GtkWidget * parent) +{ + CommoditiesDialog *cd; + gint component_id; + + cd = g_new0 (CommoditiesDialog, 1); + + gnc_commodities_dialog_create (parent, cd); + + component_id = gnc_register_gui_component (DIALOG_COMMODITIES_CM_CLASS, + refresh_handler, close_handler, + cd); + + gtk_widget_grab_focus (cd->commodity_list); + + gtk_widget_show (cd->dialog); +} diff --git a/src/gnome/dialog-price-editor.c b/src/gnome/dialog-price-editor.c index b4f8f874ca..2981650ba0 100644 --- a/src/gnome/dialog-price-editor.c +++ b/src/gnome/dialog-price-editor.c @@ -207,6 +207,10 @@ gnc_prices_load_prices (PricesDialog *pdb_dialog) pdb_dialog->prices = prices; gtk_clist_select_row (GTK_CLIST (pdb_dialog->price_list), new_row, 0); + if (gtk_clist_row_is_visible (GTK_CLIST (pdb_dialog->price_list), new_row) + != GTK_VISIBILITY_FULL) + gtk_clist_moveto (GTK_CLIST (pdb_dialog->price_list), + new_row, 0, 0.5, 0.0); gtk_widget_set_sensitive (pdb_dialog->edit_button, prices != NULL); gtk_widget_set_sensitive (pdb_dialog->remove_button, prices != NULL); @@ -730,13 +734,9 @@ gnc_prices_dialog_create (GtkWidget * parent, PricesDialog *pdb_dialog) /* default to ok */ gnome_dialog_set_default (GNOME_DIALOG(dialog), 0); - /* price information */ - - /* price tree */ { GtkWidget *income_radio; - GtkWidget *scroll; GtkWidget *list; list = lookup_widget (dialog, "price_list"); diff --git a/src/gnome/glade-gnc-dialogs.c b/src/gnome/glade-gnc-dialogs.c index 534d7320f0..d642203ebf 100644 --- a/src/gnome/glade-gnc-dialogs.c +++ b/src/gnome/glade-gnc-dialogs.c @@ -7485,7 +7485,7 @@ create_Price_Dialog (void) GtkWidget *ok_button; GtkWidget *cancel_button; - Price_Dialog = gnome_dialog_new (_("Price Dialog"), NULL); + Price_Dialog = gnome_dialog_new (_("Price Editor"), NULL); gtk_object_set_data (GTK_OBJECT (Price_Dialog), "Price_Dialog", Price_Dialog); gtk_window_set_modal (GTK_WINDOW (Price_Dialog), TRUE); gtk_window_set_policy (GTK_WINDOW (Price_Dialog), FALSE, FALSE, FALSE); @@ -7658,3 +7658,167 @@ create_Price_Dialog (void) return Price_Dialog; } +GtkWidget* +create_Commodities_Dialog (void) +{ + GtkWidget *Commodities_Dialog; + GtkWidget *vbox127; + GtkWidget *hbox107; + GtkWidget *frame51; + GtkWidget *vbox128; + GtkWidget *scrolledwindow33; + GtkWidget *commodity_list; + GtkWidget *label8477426; + GtkWidget *label8477427; + GtkWidget *label8477428; + GtkWidget *label8477429; + GtkWidget *label8477430; + GtkWidget *hbuttonbox7; + GtkWidget *add_button; + GtkWidget *remove_button; + GtkWidget *edit_button; + GtkWidget *hbuttonbox6; + GtkWidget *close_button; + GtkTooltips *tooltips; + + tooltips = gtk_tooltips_new (); + + Commodities_Dialog = gnome_dialog_new (_("Commodities"), NULL); + gtk_object_set_data (GTK_OBJECT (Commodities_Dialog), "Commodities_Dialog", Commodities_Dialog); + gtk_window_set_policy (GTK_WINDOW (Commodities_Dialog), TRUE, TRUE, FALSE); + + vbox127 = GNOME_DIALOG (Commodities_Dialog)->vbox; + gtk_object_set_data (GTK_OBJECT (Commodities_Dialog), "vbox127", vbox127); + gtk_widget_show (vbox127); + + hbox107 = gtk_hbox_new (FALSE, 2); + gtk_widget_ref (hbox107); + gtk_object_set_data_full (GTK_OBJECT (Commodities_Dialog), "hbox107", hbox107, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (hbox107); + gtk_box_pack_start (GTK_BOX (vbox127), hbox107, TRUE, TRUE, 0); + + frame51 = gtk_frame_new (_("Commodities")); + gtk_widget_ref (frame51); + gtk_object_set_data_full (GTK_OBJECT (Commodities_Dialog), "frame51", frame51, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (frame51); + gtk_box_pack_start (GTK_BOX (hbox107), frame51, TRUE, TRUE, 0); + gtk_container_set_border_width (GTK_CONTAINER (frame51), 3); + + vbox128 = gtk_vbox_new (FALSE, 0); + gtk_widget_ref (vbox128); + gtk_object_set_data_full (GTK_OBJECT (Commodities_Dialog), "vbox128", vbox128, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (vbox128); + gtk_container_add (GTK_CONTAINER (frame51), vbox128); + + scrolledwindow33 = gtk_scrolled_window_new (NULL, NULL); + gtk_widget_ref (scrolledwindow33); + gtk_object_set_data_full (GTK_OBJECT (Commodities_Dialog), "scrolledwindow33", scrolledwindow33, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (scrolledwindow33); + gtk_box_pack_start (GTK_BOX (vbox128), scrolledwindow33, TRUE, TRUE, 0); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow33), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); + + commodity_list = gtk_clist_new (5); + gtk_widget_ref (commodity_list); + gtk_object_set_data_full (GTK_OBJECT (Commodities_Dialog), "commodity_list", commodity_list, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (commodity_list); + gtk_container_add (GTK_CONTAINER (scrolledwindow33), commodity_list); + gtk_clist_set_column_width (GTK_CLIST (commodity_list), 0, 80); + gtk_clist_set_column_width (GTK_CLIST (commodity_list), 1, 80); + gtk_clist_set_column_width (GTK_CLIST (commodity_list), 2, 80); + gtk_clist_set_column_width (GTK_CLIST (commodity_list), 3, 80); + gtk_clist_set_column_width (GTK_CLIST (commodity_list), 4, 80); + gtk_clist_column_titles_show (GTK_CLIST (commodity_list)); + + label8477426 = gtk_label_new (_("Type")); + gtk_widget_ref (label8477426); + gtk_object_set_data_full (GTK_OBJECT (Commodities_Dialog), "label8477426", label8477426, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label8477426); + gtk_clist_set_column_widget (GTK_CLIST (commodity_list), 0, label8477426); + + label8477427 = gtk_label_new (_("Symbol")); + gtk_widget_ref (label8477427); + gtk_object_set_data_full (GTK_OBJECT (Commodities_Dialog), "label8477427", label8477427, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label8477427); + gtk_clist_set_column_widget (GTK_CLIST (commodity_list), 1, label8477427); + + label8477428 = gtk_label_new (_("Name")); + gtk_widget_ref (label8477428); + gtk_object_set_data_full (GTK_OBJECT (Commodities_Dialog), "label8477428", label8477428, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label8477428); + gtk_clist_set_column_widget (GTK_CLIST (commodity_list), 2, label8477428); + + label8477429 = gtk_label_new (_("Code")); + gtk_widget_ref (label8477429); + gtk_object_set_data_full (GTK_OBJECT (Commodities_Dialog), "label8477429", label8477429, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label8477429); + gtk_clist_set_column_widget (GTK_CLIST (commodity_list), 3, label8477429); + + label8477430 = gtk_label_new (_("Fraction")); + gtk_widget_ref (label8477430); + gtk_object_set_data_full (GTK_OBJECT (Commodities_Dialog), "label8477430", label8477430, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label8477430); + gtk_clist_set_column_widget (GTK_CLIST (commodity_list), 4, label8477430); + + hbuttonbox7 = gtk_hbutton_box_new (); + gtk_widget_ref (hbuttonbox7); + gtk_object_set_data_full (GTK_OBJECT (Commodities_Dialog), "hbuttonbox7", hbuttonbox7, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (hbuttonbox7); + gtk_box_pack_start (GTK_BOX (vbox128), hbuttonbox7, FALSE, FALSE, 0); + gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox7), GTK_BUTTONBOX_SPREAD); + + add_button = gtk_button_new_with_label (_("Add")); + gtk_widget_ref (add_button); + gtk_object_set_data_full (GTK_OBJECT (Commodities_Dialog), "add_button", add_button, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (add_button); + gtk_container_add (GTK_CONTAINER (hbuttonbox7), add_button); + GTK_WIDGET_SET_FLAGS (add_button, GTK_CAN_DEFAULT); + gtk_tooltips_set_tip (tooltips, add_button, _("Add a new price."), NULL); + + remove_button = gtk_button_new_with_label (_("Remove")); + gtk_widget_ref (remove_button); + gtk_object_set_data_full (GTK_OBJECT (Commodities_Dialog), "remove_button", remove_button, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (remove_button); + gtk_container_add (GTK_CONTAINER (hbuttonbox7), remove_button); + GTK_WIDGET_SET_FLAGS (remove_button, GTK_CAN_DEFAULT); + gtk_tooltips_set_tip (tooltips, remove_button, _("Remove the current price"), NULL); + + edit_button = gtk_button_new_with_label (_("Edit")); + gtk_widget_ref (edit_button); + gtk_object_set_data_full (GTK_OBJECT (Commodities_Dialog), "edit_button", edit_button, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (edit_button); + gtk_container_add (GTK_CONTAINER (hbuttonbox7), edit_button); + GTK_WIDGET_SET_FLAGS (edit_button, GTK_CAN_DEFAULT); + + hbuttonbox6 = GNOME_DIALOG (Commodities_Dialog)->action_area; + gtk_object_set_data (GTK_OBJECT (Commodities_Dialog), "hbuttonbox6", hbuttonbox6); + gtk_widget_show (hbuttonbox6); + gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox6), GTK_BUTTONBOX_END); + gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbuttonbox6), 8); + + gnome_dialog_append_button (GNOME_DIALOG (Commodities_Dialog), GNOME_STOCK_BUTTON_CLOSE); + close_button = GTK_WIDGET (g_list_last (GNOME_DIALOG (Commodities_Dialog)->buttons)->data); + gtk_widget_ref (close_button); + gtk_object_set_data_full (GTK_OBJECT (Commodities_Dialog), "close_button", close_button, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (close_button); + GTK_WIDGET_SET_FLAGS (close_button, GTK_CAN_DEFAULT); + + gtk_object_set_data (GTK_OBJECT (Commodities_Dialog), "tooltips", tooltips); + + return Commodities_Dialog; +} + diff --git a/src/gnome/glade-gnc-dialogs.h b/src/gnome/glade-gnc-dialogs.h index 51190dd245..70d943faab 100644 --- a/src/gnome/glade-gnc-dialogs.h +++ b/src/gnome/glade-gnc-dialogs.h @@ -27,3 +27,4 @@ GtkWidget* create_Edit_Column_View_Page (void); GtkWidget* create_Edit_Report_Size (void); GtkWidget* create_Prices_Dialog (void); GtkWidget* create_Price_Dialog (void); +GtkWidget* create_Commodities_Dialog (void); diff --git a/src/gnome/gnc-dialogs.glade b/src/gnome/gnc-dialogs.glade index fd47eb09d4..7d9eba0501 100644 --- a/src/gnome/gnc-dialogs.glade +++ b/src/gnome/gnc-dialogs.glade @@ -11048,7 +11048,7 @@ quit without making any changes. GnomeDialog Price Dialog False - Price Dialog + Price Editor GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE True @@ -11363,4 +11363,225 @@ Unknown + + GnomeDialog + Commodities Dialog + Commodities + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + True + False + False + False + + + GtkVBox + GnomeDialog:vbox + vbox127 + False + 8 + + 4 + True + True + + + + GtkHButtonBox + GnomeDialog:action_area + hbuttonbox6 + GTK_BUTTONBOX_END + 8 + 85 + 27 + 7 + 0 + + 0 + False + True + GTK_PACK_END + + + + GtkButton + close_button + True + True + GNOME_STOCK_BUTTON_CLOSE + + + + + GtkHBox + hbox107 + False + 2 + + 0 + True + True + + + + GtkFrame + frame51 + 3 + + 0 + GTK_SHADOW_ETCHED_IN + + 0 + True + True + + + + GtkVBox + vbox128 + False + 0 + + + GtkScrolledWindow + scrolledwindow33 + GTK_POLICY_NEVER + GTK_POLICY_ALWAYS + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + 0 + True + True + + + + GtkCList + commodity_list + True + 5 + 80,80,80,80,80 + GTK_SELECTION_SINGLE + True + GTK_SHADOW_IN + + + GtkLabel + CList:title + label8477426 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + label8477427 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + label8477428 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + label8477429 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + label8477430 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + + + GtkHButtonBox + hbuttonbox7 + GTK_BUTTONBOX_SPREAD + 30 + 85 + 27 + 7 + 0 + + 0 + False + False + + + + GtkButton + add_button + Add a new price. + True + True + + GTK_RELIEF_NORMAL + + + + GtkButton + remove_button + Remove the current price + True + True + + GTK_RELIEF_NORMAL + + + + GtkButton + edit_button + True + True + + GTK_RELIEF_NORMAL + + + + + + + + diff --git a/src/gnome/window-main.c b/src/gnome/window-main.c index 8aec3e6fa6..d4b80fb896 100644 --- a/src/gnome/window-main.c +++ b/src/gnome/window-main.c @@ -830,6 +830,12 @@ gnc_ui_mainWindow_prices_cb(GtkWidget *widget, gpointer data) gnc_prices_dialog (NULL); } +static void +gnc_ui_mainWindow_commodities_cb(GtkWidget *widget, gpointer data) +{ + gnc_commodities_dialog (NULL); +} + static gboolean gnc_ui_mainWindow_delete_cb(GtkWidget *widget, GdkEvent *event, @@ -1328,6 +1334,14 @@ gnc_main_create_menus(GnomeApp *app, GtkWidget *account_tree, GNOME_APP_PIXMAP_NONE, NULL, 0, 0, NULL }, + { + GNOME_APP_UI_ITEM, + N_("Commodity _Editor"), + N_("View and edit the commodities for stocks and mutual funds"), + gnc_ui_mainWindow_commodities_cb, NULL, NULL, + GNOME_APP_PIXMAP_NONE, NULL, + 0, 0, NULL + }, { GNOME_APP_UI_ITEM, N_("_Price Editor"), diff --git a/src/scm/prefs.scm b/src/scm/prefs.scm index e04ffcf69c..dedd5690f3 100644 --- a/src/scm/prefs.scm +++ b/src/scm/prefs.scm @@ -626,6 +626,14 @@ the current value of the path.") (gnc:make-internal-option "__gui" "account_win_height" 0)) +(gnc:register-configuration-option + (gnc:make-internal-option + "__gui" "commodities_win_width" 0)) + +(gnc:register-configuration-option + (gnc:make-internal-option + "__gui" "commodities_win_height" 0)) + (gnc:register-configuration-option (gnc:make-internal-option "__gui" "help_win_width" 0))