2000-10-23 09:41:51 +00:00
|
|
|
/********************************************************************
|
|
|
|
|
* dialog-commodity.h -- "select" and "new" commodity windows *
|
2000-03-16 07:12:49 +00:00
|
|
|
* (GnuCash) *
|
|
|
|
|
* Copyright (C) 2000 Bill Gribble <grib@billgribble.com> *
|
2006-08-02 18:13:30 +00:00
|
|
|
* Copyright (c) 2006 David Hampton <hampton@employees.org> *
|
2000-03-16 07:12:49 +00:00
|
|
|
* *
|
|
|
|
|
* 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*
|
2000-04-27 05:23:46 +00:00
|
|
|
* along with this program; if not, contact: *
|
|
|
|
|
* *
|
|
|
|
|
* Free Software Foundation Voice: +1-617-542-5942 *
|
2005-11-17 05:35:02 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
|
|
|
|
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
2000-10-23 09:41:51 +00:00
|
|
|
********************************************************************/
|
2000-03-16 07:12:49 +00:00
|
|
|
|
2005-11-02 03:32:36 +00:00
|
|
|
/** @addtogroup GUI
|
|
|
|
|
@{ */
|
|
|
|
|
/** @addtogroup GuiCommodity Commodity windows
|
2003-05-11 00:45:03 +00:00
|
|
|
@{ */
|
|
|
|
|
/** @file dialog-commodity.h
|
|
|
|
|
@brief "select" and "new" commodity windows
|
|
|
|
|
@author Copyright (C) 2000 Bill Gribble <grib@billgribble.com>
|
|
|
|
|
*/
|
|
|
|
|
|
2001-09-10 07:01:57 +00:00
|
|
|
#ifndef GNC_DIALOG_COMMODITY_H
|
|
|
|
|
#define GNC_DIALOG_COMMODITY_H
|
|
|
|
|
|
2006-03-07 21:59:15 +00:00
|
|
|
#include <gtk/gtk.h>
|
2000-10-23 09:41:51 +00:00
|
|
|
#include "gnc-commodity.h"
|
|
|
|
|
|
2003-06-23 17:53:03 +00:00
|
|
|
/** The dialog commodity types are used to determine what commodity
|
|
|
|
|
* namespaces the currency dialog will present to a user. These
|
|
|
|
|
* values can be safely changed from one release to the next. Note
|
|
|
|
|
* that if values are added, the routines in dialog-commodity.c will
|
|
|
|
|
* need to be updated to match.
|
|
|
|
|
*/
|
2010-03-02 21:42:11 +00:00
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
DIAG_COMM_CURRENCY, /**< Dialog box should only allow selection
|
2003-06-23 17:53:03 +00:00
|
|
|
of a currency. */
|
2010-03-02 21:42:11 +00:00
|
|
|
DIAG_COMM_NON_CURRENCY, /**< Dialog box should allow selection of
|
2003-06-23 17:53:03 +00:00
|
|
|
anything but a currency. */
|
2016-12-15 13:39:09 -08:00
|
|
|
DIAG_COMM_NON_CURRENCY_SELECT, /**< Dialog box should allow selection of
|
|
|
|
|
* anything but a currency and should include
|
|
|
|
|
* the "ALL" namespace to display all such
|
|
|
|
|
* commodities in a single list. */
|
2010-03-02 21:42:11 +00:00
|
|
|
DIAG_COMM_ALL, /**< Dialog box should allow selection of
|
2003-06-23 17:53:03 +00:00
|
|
|
anything. */
|
|
|
|
|
} dialog_commodity_mode;
|
|
|
|
|
|
2001-09-14 07:01:40 +00:00
|
|
|
typedef void (* gnc_commodity_help_callback)(void);
|
|
|
|
|
|
2003-05-11 00:45:03 +00:00
|
|
|
/** This function is used to set the action routine for the help
|
|
|
|
|
* button in the commodity dialog windows. If the action routine is
|
|
|
|
|
* unset, the help button will not be visible to the user.
|
2010-03-02 21:42:11 +00:00
|
|
|
*
|
2003-05-11 00:45:03 +00:00
|
|
|
* @param cb The function to be called when the user clicks the help
|
|
|
|
|
* button. */
|
2001-09-14 07:01:40 +00:00
|
|
|
void gnc_ui_commodity_set_help_callback (gnc_commodity_help_callback cb);
|
|
|
|
|
|
2002-10-18 06:24:04 +00:00
|
|
|
|
2003-05-11 00:45:03 +00:00
|
|
|
/** @name Commodity Selection */
|
|
|
|
|
/** @{ */
|
|
|
|
|
|
|
|
|
|
/** Ask the user to select a commodity from the existing set of
|
|
|
|
|
* commodities. Arguments to this function determine the message
|
|
|
|
|
* placed at the top of the dialog but force no restriction on the
|
|
|
|
|
* commodities that may be chosen. The user will also have the
|
|
|
|
|
* option of creating a new commodity from this dialog box.. If the
|
|
|
|
|
* user decides to create a new one, those provided values are used
|
|
|
|
|
* as default values for the new commodity.
|
|
|
|
|
*
|
|
|
|
|
* @param orig_sel A pointer to a commodity that should initially be
|
|
|
|
|
* selected in the dialog box.
|
|
|
|
|
*
|
|
|
|
|
* @param parent The parent window of the new dialog.
|
|
|
|
|
*
|
|
|
|
|
* @param user_message A string that will be installed in the top of
|
|
|
|
|
* the dialog box as an instruction to the user. If NULL, a generic
|
|
|
|
|
* instruction will be used.
|
|
|
|
|
*
|
2006-02-11 20:00:52 +00:00
|
|
|
* @param cusip If present, a note will be added to the user
|
2003-05-11 00:45:03 +00:00
|
|
|
* instruction providing this exchange specific code, and this will
|
2006-02-11 20:00:52 +00:00
|
|
|
* be the default exchange specific data for any newly created
|
|
|
|
|
* commodities.
|
2003-05-11 00:45:03 +00:00
|
|
|
*
|
|
|
|
|
* @param fullname If present, a note will be added to the user
|
|
|
|
|
* instruction providing this commodity's full name, and this will be
|
|
|
|
|
* the default fullname for any newly created commodities.
|
|
|
|
|
*
|
|
|
|
|
* @param mnemonic If present, a note will be added to the user
|
|
|
|
|
* instruction providing this commodity's mnemonic, and this will be
|
|
|
|
|
* the default mnemonic for any newly created commodities.
|
|
|
|
|
*
|
2003-06-23 17:53:03 +00:00
|
|
|
* @param mode Determines which namespaces the user may select a
|
|
|
|
|
* commodity from.
|
|
|
|
|
*
|
2003-05-11 00:45:03 +00:00
|
|
|
* @return The commodity selected. May or may not be a newly created
|
|
|
|
|
* commodity.
|
|
|
|
|
*/
|
2010-03-02 21:42:11 +00:00
|
|
|
gnc_commodity *
|
|
|
|
|
gnc_ui_select_commodity_modal_full(gnc_commodity * orig_sel,
|
|
|
|
|
GtkWidget * parent,
|
|
|
|
|
dialog_commodity_mode mode,
|
|
|
|
|
const char * user_message,
|
|
|
|
|
const char * cusip,
|
|
|
|
|
const char * fullname,
|
|
|
|
|
const char * mnemonic);
|
2003-05-11 00:45:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Ask the user to select a commodity from the existing set of
|
|
|
|
|
* commodities. The user will also have the
|
|
|
|
|
* option of creating a new commodity from this dialog box.. If the
|
|
|
|
|
* user decides to create a new one, those provided values are used
|
|
|
|
|
* as default values for the new commodity.
|
|
|
|
|
*
|
|
|
|
|
* @param orig_sel A pointer to a commodity that should initially be
|
|
|
|
|
* selected in the dialog box.
|
|
|
|
|
*
|
2003-06-23 17:53:03 +00:00
|
|
|
* @param parent The parent window for this new selection window.
|
|
|
|
|
*
|
|
|
|
|
* @param mode Determines which namespaces the user may select a
|
|
|
|
|
* commodity from.
|
|
|
|
|
*
|
2003-05-11 00:45:03 +00:00
|
|
|
* @return The commodity selected. May or may not be a newly created
|
|
|
|
|
* commodity.
|
|
|
|
|
*/
|
2010-03-02 21:42:11 +00:00
|
|
|
gnc_commodity *
|
|
|
|
|
gnc_ui_select_commodity_modal(gnc_commodity * orig_sel,
|
2003-06-23 17:53:03 +00:00
|
|
|
GtkWidget * parent,
|
|
|
|
|
dialog_commodity_mode mode);
|
2003-05-11 00:45:03 +00:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @name Commodity Creation or Modification */
|
|
|
|
|
/** @{ */
|
|
|
|
|
|
|
|
|
|
/** Ask the user to provide the information necessary to create a new
|
|
|
|
|
* commodity.
|
|
|
|
|
*
|
|
|
|
|
* @param namespace If present, this will be the default namespace
|
|
|
|
|
* for the new commodity. This value will be ignored if it is the
|
|
|
|
|
* namespace for ISO 4217 currencies.
|
|
|
|
|
*
|
|
|
|
|
* @param parent The parent window of the new dialog.
|
|
|
|
|
*
|
2006-02-11 20:00:52 +00:00
|
|
|
* @param cusip If present, this will be the default exchange
|
|
|
|
|
* specific data for the new commodity.
|
2003-05-11 00:45:03 +00:00
|
|
|
*
|
|
|
|
|
* @param fullname If present, this will be the default fullname for
|
|
|
|
|
* the new commodity.
|
|
|
|
|
*
|
|
|
|
|
* @param mnemonic If present, this will be the default mnemonic for
|
|
|
|
|
* the new commodity.
|
|
|
|
|
*
|
2013-10-24 12:28:57 +00:00
|
|
|
* @param user_symbol If present, this will be the default user symbol
|
|
|
|
|
* for the new commodity.
|
|
|
|
|
*
|
2003-05-11 00:45:03 +00:00
|
|
|
* @param fraction If present, this will be the default fraction for
|
|
|
|
|
* the new commodity. If absent, a default of 1000 will be used.
|
2010-03-02 21:42:11 +00:00
|
|
|
*
|
2003-05-11 00:45:03 +00:00
|
|
|
* @return The newly created commodity, or NULL if the user cancelled.
|
|
|
|
|
*/
|
2010-03-02 21:42:11 +00:00
|
|
|
gnc_commodity *
|
2014-08-12 13:56:53 -04:00
|
|
|
gnc_ui_new_commodity_modal_full(const char * name_space,
|
2010-03-02 21:42:11 +00:00
|
|
|
GtkWidget * parent,
|
|
|
|
|
const char * cusip,
|
|
|
|
|
const char * fullname,
|
|
|
|
|
const char * mnemonic,
|
2013-10-24 12:28:57 +00:00
|
|
|
const char * user_symbol,
|
2010-03-02 21:42:11 +00:00
|
|
|
int fraction);
|
2002-10-18 06:24:04 +00:00
|
|
|
|
2003-05-11 00:45:03 +00:00
|
|
|
/** Ask the user to provide the information necessary to create a new
|
|
|
|
|
* commodity.
|
|
|
|
|
*
|
2009-01-22 21:14:08 +00:00
|
|
|
* @param default_namespace If present, this will be the default namespace
|
2003-05-11 00:45:03 +00:00
|
|
|
* for the new commodity. This value will be ignored if it is the
|
|
|
|
|
* namespace for ISO 4217 currencies.
|
|
|
|
|
*
|
|
|
|
|
* @param parent The parent window of the new dialog.
|
2010-03-02 21:42:11 +00:00
|
|
|
*
|
2003-05-11 00:45:03 +00:00
|
|
|
* @return The newly created commodity, or NULL if the user cancelled.
|
|
|
|
|
*/
|
2010-03-02 21:42:11 +00:00
|
|
|
gnc_commodity *
|
|
|
|
|
gnc_ui_new_commodity_modal(const char * default_namespace,
|
2005-11-02 03:32:36 +00:00
|
|
|
GtkWidget * parent);
|
2000-03-16 07:12:49 +00:00
|
|
|
|
2003-05-11 00:45:03 +00:00
|
|
|
/** Allow the user to edit the information about a commodity. For
|
|
|
|
|
* currencies, only the price quote information may be changed. For
|
|
|
|
|
* any other commodity, all aspects of the commodity information may
|
|
|
|
|
* be changed except that the namespace may not be changed to
|
|
|
|
|
* indicate a currency. The new information overwrites any old
|
|
|
|
|
* information, so this routine may not be used to create new
|
|
|
|
|
* commodities.
|
|
|
|
|
*
|
|
|
|
|
* @param commodity The commodity to edit.
|
|
|
|
|
*
|
|
|
|
|
* @param parent The parent window of the new dialog.
|
2010-03-02 21:42:11 +00:00
|
|
|
*
|
2003-05-11 00:45:03 +00:00
|
|
|
* @return The newly created commodity, or NULL if the user cancelled.
|
|
|
|
|
*/
|
2001-04-11 09:34:07 +00:00
|
|
|
gboolean
|
|
|
|
|
gnc_ui_edit_commodity_modal(gnc_commodity *commodity,
|
|
|
|
|
GtkWidget * parent);
|
2003-05-11 00:45:03 +00:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @name Auxiliary Dialog Functions */
|
|
|
|
|
/** @{ */
|
|
|
|
|
|
|
|
|
|
/** Given a combo box, fill in the known commodity namespaces and then
|
|
|
|
|
* select one.
|
|
|
|
|
*
|
2012-06-13 15:23:25 +00:00
|
|
|
* @param cbwe The widget to populate with information.
|
2003-05-11 00:45:03 +00:00
|
|
|
*
|
|
|
|
|
* @param sel The namespace that should be initially selected when
|
|
|
|
|
* the combo box appears.
|
|
|
|
|
*
|
2003-06-23 17:53:03 +00:00
|
|
|
* @param mode Determines which namespaces the user may select a
|
|
|
|
|
* commodity
|
2003-05-11 00:45:03 +00:00
|
|
|
*
|
|
|
|
|
* @return The currently selected namespace.
|
|
|
|
|
*
|
|
|
|
|
* @note The returned string must be freed by the caller.
|
|
|
|
|
*/
|
2012-06-13 15:23:25 +00:00
|
|
|
void gnc_ui_update_namespace_picker(GtkWidget *cbwe,
|
2010-03-02 21:42:11 +00:00
|
|
|
const gchar *sel,
|
|
|
|
|
dialog_commodity_mode mode);
|
2001-03-14 11:24:56 +00:00
|
|
|
|
2003-05-11 00:45:03 +00:00
|
|
|
/** Given a combo box, return the currently selected namespaces.
|
|
|
|
|
*
|
2012-06-13 15:23:25 +00:00
|
|
|
* @param cbwe The combo box of namespaces.
|
2003-05-11 00:45:03 +00:00
|
|
|
*
|
|
|
|
|
* @return The currently selected namespace.
|
|
|
|
|
*
|
|
|
|
|
* @note This string is owned by the engine and must not be freed by
|
|
|
|
|
* the caller.
|
|
|
|
|
*/
|
2012-06-13 15:23:25 +00:00
|
|
|
gchar *gnc_ui_namespace_picker_ns (GtkWidget *cbwe);
|
2001-04-03 21:42:13 +00:00
|
|
|
|
2003-05-11 00:45:03 +00:00
|
|
|
/** Given a combo box, fill in all the known commodities for the
|
|
|
|
|
* specified namespace, and then select one.
|
|
|
|
|
*
|
2012-06-13 15:23:25 +00:00
|
|
|
* @param cbwe The widget to populate with information.
|
2003-05-11 00:45:03 +00:00
|
|
|
*
|
|
|
|
|
* @param namespace All commodities with this namespace will be added
|
|
|
|
|
* to the combo box.
|
|
|
|
|
*
|
|
|
|
|
* @param sel The commodity that should be initially selected when
|
|
|
|
|
* the combo box appears.
|
|
|
|
|
*/
|
2012-06-13 15:23:25 +00:00
|
|
|
void gnc_ui_update_commodity_picker(GtkWidget *cbwe,
|
2014-08-12 13:56:53 -04:00
|
|
|
const gchar *name_space,
|
2006-08-02 18:13:30 +00:00
|
|
|
const gchar *sel);
|
2003-05-11 00:45:03 +00:00
|
|
|
/** @} */
|
2000-03-16 07:12:49 +00:00
|
|
|
|
|
|
|
|
#endif
|
2003-05-11 00:45:03 +00:00
|
|
|
/** @} */
|
2005-11-02 03:32:36 +00:00
|
|
|
/** @} */
|