GnuCash  5.6-150-g038405b370+
dialog-commodities.cpp
1 /********************************************************************\
2  * dialog-commodities.c -- commodities dialog *
3  * Copyright (C) 2001 Gnumatic, Inc. *
4  * Author: Dave Peticolas <dave@krondo.com> *
5  * Copyright (C) 2003,2005 David Hampton *
6  * *
7  * This program is free software; you can redistribute it and/or *
8  * modify it under the terms of the GNU General Public License as *
9  * published by the Free Software Foundation; either version 2 of *
10  * the License, or (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License*
18  * along with this program; if not, contact: *
19  * *
20  * Free Software Foundation Voice: +1-617-542-5942 *
21  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
22  * Boston, MA 02110-1301, USA gnu@gnu.org *
23 \********************************************************************/
24 
25 #include <config.h>
26 
27 #include <gtk/gtk.h>
28 #include <glib/gi18n.h>
29 
30 #include "dialog-commodity.h"
31 #include "gnc-commodity.hpp"
32 #include "dialog-utils.h"
33 #include "gnc-commodity.h"
34 #include "gnc-component-manager.h"
35 #include "qof.h"
37 #include "gnc-prefs.h"
38 #include "gnc-ui.h"
39 #include "gnc-ui-util.h"
40 #include "gnc-gnome-utils.h"
41 #include "gnc-session.h"
42 #include "gnc-warnings.h"
43 #include "Account.hpp"
44 
45 #include <vector>
46 #include <string>
47 
48 #define DIALOG_COMMODITIES_CM_CLASS "dialog-commodities"
49 #define STATE_SECTION "dialogs/edit_commodities"
50 #define GNC_PREFS_GROUP "dialogs.commodities"
51 #define GNC_PREF_INCL_ISO "include-iso"
52 
53 /* This static indicates the debugging module that this .o belongs to. */
54 /* static short module = MOD_GUI; */
55 
56 typedef struct
57 {
58  GtkWidget * window;
59  QofSession *session;
60  QofBook *book;
61 
62  GncTreeViewCommodity * commodity_tree;
63  GtkWidget * edit_button;
64  GtkWidget * remove_button;
65  gboolean show_currencies;
66  GtkWidget * rename_namespace_button;
67 
68  gboolean is_new;
70 
71 
72 void gnc_commodities_window_destroy_cb (GtkWidget *object, CommoditiesDialog *cd);
73 
74 extern "C" {
75 void gnc_commodities_dialog_add_clicked (GtkWidget *widget, gpointer data);
76 void gnc_commodities_dialog_edit_clicked (GtkWidget *widget, gpointer data);
77 void gnc_commodities_dialog_remove_clicked (GtkWidget *widget, gpointer data);
78 void gnc_commodities_dialog_close_clicked (GtkWidget *widget, gpointer data);
79 
80 void gnc_commodities_dialog_rename_namespace_clicked (GtkWidget *widget, gpointer data);
81 
82 void gnc_commodities_show_currencies_toggled (GtkToggleButton *toggle, CommoditiesDialog *cd);
83 }
84 
85 gboolean gnc_commodities_window_key_press_cb (GtkWidget *widget,
86  GdkEventKey *event,
87  gpointer data);
88 
89 
90 void
91 gnc_commodities_window_destroy_cb (GtkWidget *object, CommoditiesDialog *cd)
92 {
93  gnc_unregister_gui_component_by_data (DIALOG_COMMODITIES_CM_CLASS, cd);
94 
95  if (cd->window)
96  {
97  gtk_widget_destroy (cd->window);
98  cd->window = NULL;
99  }
100  g_free (cd);
101 }
102 
103 static gboolean
104 gnc_commodities_window_delete_event_cb (GtkWidget *widget,
105  GdkEvent *event,
106  gpointer data)
107 {
108  auto cd = static_cast<CommoditiesDialog*>(data);
109  // this cb allows the window size to be saved on closing with the X
110  gnc_save_window_size (GNC_PREFS_GROUP,
111  GTK_WINDOW(cd->window));
112  return FALSE;
113 }
114 
115 void
116 gnc_commodities_dialog_edit_clicked (GtkWidget *widget, gpointer data)
117 {
118  auto cd = static_cast<CommoditiesDialog*>(data);
119  gnc_commodity *commodity;
120 
121  commodity = gnc_tree_view_commodity_get_selected_commodity (cd->commodity_tree);
122  if (commodity == NULL)
123  return;
124 
125  if (gnc_ui_edit_commodity_modal (commodity, cd->window))
126  {
127  gnc_tree_view_commodity_select_commodity (cd->commodity_tree, commodity);
128  gnc_gui_refresh_all ();
129  }
130 }
131 
132 static void
133 row_activated_cb (GtkTreeView *view, GtkTreePath *path,
134  GtkTreeViewColumn *column, CommoditiesDialog *cd)
135 {
136  GtkTreeModel *model;
137  GtkTreeIter iter;
138 
139  g_return_if_fail(view);
140 
141  model = gtk_tree_view_get_model(view);
142  if (gtk_tree_model_get_iter(model, &iter, path))
143  {
144  if (gtk_tree_model_iter_has_child(model, &iter))
145  {
146  /* There are children, so it's not a commodity.
147  * Just expand or collapse the row. */
148  if (gtk_tree_view_row_expanded(view, path))
149  gtk_tree_view_collapse_row(view, path);
150  else
151  gtk_tree_view_expand_row(view, path, FALSE);
152  }
153  else
154  /* It's a commodity, so click the Edit button. */
155  gnc_commodities_dialog_edit_clicked (NULL, cd);
156  }
157 }
158 
159 void
160 gnc_commodities_dialog_remove_clicked (GtkWidget *widget, gpointer data)
161 {
162  auto cd = static_cast<CommoditiesDialog*>(data);
163  GNCPriceDB *pdb;
164  GList *node;
165  GList *prices;
166  gnc_commodity *commodity;
167  GtkWidget *dialog;
168  const gchar *message, *warning;
169  gint response;
170 
171  commodity = gnc_tree_view_commodity_get_selected_commodity (cd->commodity_tree);
172  if (commodity == NULL)
173  return;
174 
175  std::vector<Account*> commodity_accounts;
176 
177  gnc_account_foreach_descendant (gnc_book_get_root_account(cd->book),
178  [commodity, &commodity_accounts](auto acct)
179  {
180  if (commodity == xaccAccountGetCommodity (acct))
181  commodity_accounts.push_back (acct);
182  });
183 
184  /* FIXME check for transaction references */
185 
186  if (!commodity_accounts.empty())
187  {
188  std::string msg{_("This commodity is currently used by the following accounts. You may "
189  "not delete it.\n")};
190 
191  for (const auto acct : commodity_accounts)
192  {
193  auto full_name = gnc_account_get_full_name (acct);
194  msg.append ("\n* ").append (full_name);
195  g_free (full_name);
196  }
197 
198  gnc_warning_dialog (GTK_WINDOW (cd->window), "%s", msg.c_str());
199  return;
200  }
201 
202  pdb = gnc_pricedb_get_db (cd->book);
203  prices = gnc_pricedb_get_prices (pdb, commodity, NULL);
204  if (prices)
205  {
206  message = _("This commodity has price quotes. Are "
207  "you sure you want to delete the selected "
208  "commodity and its price quotes?");
209  warning = GNC_PREF_WARN_PRICE_COMM_DEL_QUOTES;
210  }
211  else
212  {
213  message = _("Are you sure you want to delete the "
214  "selected commodity?");
215  warning = GNC_PREF_WARN_PRICE_COMM_DEL;
216  }
217 
218  dialog = gtk_message_dialog_new (GTK_WINDOW(cd->window),
219  GTK_DIALOG_DESTROY_WITH_PARENT,
220  GTK_MESSAGE_QUESTION,
221  GTK_BUTTONS_NONE,
222  "%s", _("Delete commodity?"));
223  gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG(dialog),
224  "%s", message);
225  gtk_dialog_add_buttons (GTK_DIALOG(dialog),
226  _("_Cancel"), GTK_RESPONSE_CANCEL,
227  _("_Delete"), GTK_RESPONSE_OK,
228  (gchar *)NULL);
229  response = gnc_dialog_run (GTK_DIALOG(dialog), warning);
230  gtk_widget_destroy (dialog);
231 
232  if (response == GTK_RESPONSE_OK)
233  {
234  gnc_commodity_table *ct;
235 
236  ct = gnc_commodity_table_get_table (cd->book);
237  for (node = prices; node; node = node->next)
238  gnc_pricedb_remove_price(pdb, GNC_PRICE(node->data));
239 
240  gnc_commodity_table_remove (ct, commodity);
241  gnc_commodity_destroy (commodity);
242  commodity = NULL;
243 
244  // to be consistent, unselect all after remove
245  gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW(cd->commodity_tree)));
246  }
247 
248  gnc_price_list_destroy(prices);
249  gnc_gui_refresh_all ();
250 }
251 
252 void
253 gnc_commodities_dialog_add_clicked (GtkWidget *widget, gpointer data)
254 {
255  auto cd = static_cast<CommoditiesDialog*>(data);
256  gnc_commodity *commodity;
257  gnc_commodity *ret_commodity;
258  const char *name_space;
259 
260  commodity = gnc_tree_view_commodity_get_selected_commodity (cd->commodity_tree);
261  if (commodity)
262  name_space = gnc_commodity_get_namespace (commodity);
263  else
264  name_space = NULL;
265 
266  ret_commodity = gnc_ui_new_commodity_modal (name_space, cd->window);
267  gnc_tree_view_commodity_select_commodity (cd->commodity_tree, ret_commodity);
268 }
269 
270 void
271 gnc_commodities_dialog_close_clicked (GtkWidget *widget, gpointer data)
272 {
273  auto cd = static_cast<CommoditiesDialog*>(data);
274 
275  gnc_close_gui_component_by_data (DIALOG_COMMODITIES_CM_CLASS, cd);
276 }
277 
278 void
279 gnc_commodities_dialog_rename_namespace_clicked (GtkWidget *widget, gpointer data)
280 {
281  auto cd = static_cast<CommoditiesDialog*>(data);
282  auto ns = gnc_tree_view_commodity_get_selected_namespace (cd->commodity_tree);
283 
284  if (!ns)
285  return;
286 
287  const auto ns_name = gnc_commodity_namespace_get_name (ns);
288 
289  GtkBuilder *builder = gtk_builder_new();
290  gnc_builder_add_from_file (builder, "dialog-commodities.glade", "rename_namespace_dialog");
291 
292  GtkDialog *dialog = GTK_DIALOG(gtk_builder_get_object (builder, "rename_namespace_dialog"));
293  GtkWidget *entry = GTK_WIDGET(gtk_builder_get_object (builder, "rename_entry"));
294  GtkWidget *label = GTK_WIDGET(gtk_builder_get_object (builder, "rename_label"));
295 
296  // Set the name for this dialog so it can be easily manipulated with css
297  gtk_widget_set_name (GTK_WIDGET(dialog), "gnc-id-rename-namespace");
298  gnc_widget_style_context_add_class (GTK_WIDGET(dialog), "gnc-class-securities");
299 
300  // Entry
301  gtk_entry_set_text (GTK_ENTRY(entry), ns_name);
302  gtk_editable_select_region (GTK_EDITABLE(entry), 0, -1);
303  gtk_entry_set_activates_default (GTK_ENTRY(entry), true);
304 
305  // Set our parent
306  gtk_window_set_transient_for (GTK_WINDOW(dialog),
307  GTK_WINDOW(gtk_widget_get_toplevel(widget)));
308 
309  gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, nullptr);
310  g_object_unref (G_OBJECT(builder));
311 
312  gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_OK);
313 
314  bool rename_ok = false;
315  while (!rename_ok && gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
316  {
317  const auto commodity_table = gnc_get_current_commodities ();
318  const auto new_ns_name = gtk_entry_get_text (GTK_ENTRY(entry));
319 
320  if (new_ns_name && *new_ns_name)
321  {
322  rename_ok = gnc_commodity_table_rename_namespace (commodity_table,
323  ns_name,
324  new_ns_name);
325  if (rename_ok)
326  qof_book_mark_session_dirty (gnc_get_current_book());
327  else
328  gtk_label_set_text (GTK_LABEL(label),
329  _("Rename failed, possibly new name exists"));
330  }
331  else
332  gtk_label_set_text (GTK_LABEL(label), _("No new name"));
333  }
334  gtk_widget_destroy (GTK_WIDGET(dialog));
335 }
336 
337 static void
338 gnc_commodities_dialog_selection_changed (GtkTreeSelection *selection,
339  CommoditiesDialog *cd)
340 {
341  gboolean remove_ok;
342  gnc_commodity *commodity;
343 
344  commodity = gnc_tree_view_commodity_get_selected_commodity (cd->commodity_tree);
345  remove_ok = commodity && !gnc_commodity_is_iso(commodity);
346  gtk_widget_set_sensitive (cd->edit_button, commodity != NULL);
347  gtk_widget_set_sensitive (cd->remove_button, remove_ok);
348 
349  gtk_widget_set_sensitive (cd->rename_namespace_button, !commodity);
350 
351  if (!commodity)
352  {
353  gnc_commodity_namespace *ns = gnc_tree_view_commodity_get_selected_namespace (cd->commodity_tree);
354  const char *ns_name = gnc_commodity_namespace_get_name (ns);
355 
356  gtk_widget_set_sensitive (cd->rename_namespace_button,
357  !(g_strcmp0 (ns_name, GNC_COMMODITY_NS_LEGACY) == 0 ||
358  g_strcmp0 (ns_name, GNC_COMMODITY_NS_CURRENCY) == 0));
359  }
360 }
361 
362 void
363 gnc_commodities_show_currencies_toggled (GtkToggleButton *toggle,
364  CommoditiesDialog *cd)
365 {
366  cd->show_currencies = gtk_toggle_button_get_active (toggle);
367  gnc_tree_view_commodity_refilter (cd->commodity_tree);
368 }
369 
370 static gboolean
371 gnc_commodities_dialog_filter_ns_func (gnc_commodity_namespace *name_space,
372  gpointer data)
373 {
374  auto cd = static_cast<CommoditiesDialog*>(data);
375  const gchar *name;
376  GList *list;
377 
378  /* Never show the template list */
379  name = gnc_commodity_namespace_get_name (name_space);
380  if (g_strcmp0 (name, GNC_COMMODITY_NS_TEMPLATE) == 0)
381  return FALSE;
382 
383  /* Check whether or not to show commodities */
384  if (!cd->show_currencies && gnc_commodity_namespace_is_iso(name))
385  return FALSE;
386 
387  /* Show any other namespace that has commodities */
389  gboolean rv = (list != NULL);
390  g_list_free (list);
391  return rv;
392 }
393 
394 static gboolean
395 gnc_commodities_dialog_filter_cm_func (gnc_commodity *commodity,
396  gpointer data)
397 {
398  auto cd = static_cast<CommoditiesDialog*>(data);
399 
400  if (cd->show_currencies)
401  return TRUE;
402  return !gnc_commodity_is_iso(commodity);
403 }
404 
405 static void
406 gnc_commodities_dialog_create (GtkWidget * parent, CommoditiesDialog *cd)
407 {
408  GtkWidget *button;
409  GtkWidget *scrolled_window;
410  GtkBuilder *builder;
411  GtkTreeView *view;
412  GtkTreeSelection *selection;
413 
414  builder = gtk_builder_new();
415  gnc_builder_add_from_file (builder, "dialog-commodities.glade", "securities_window");
416 
417  cd->window = GTK_WIDGET(gtk_builder_get_object (builder, "securities_window"));
418  cd->session = gnc_get_current_session();
419  cd->book = qof_session_get_book(cd->session);
420  cd->show_currencies = gnc_prefs_get_bool(GNC_PREFS_GROUP, GNC_PREF_INCL_ISO);
421 
422  // Set the name for this dialog so it can be easily manipulated with css
423  gtk_widget_set_name (GTK_WIDGET(cd->window), "gnc-id-commodity");
424  gnc_widget_style_context_add_class (GTK_WIDGET(cd->window), "gnc-class-securities");
425 
426  /* buttons */
427  cd->remove_button = GTK_WIDGET(gtk_builder_get_object (builder, "remove_button"));
428  cd->edit_button = GTK_WIDGET(gtk_builder_get_object (builder, "edit_button"));
429 
430  cd->rename_namespace_button = GTK_WIDGET(gtk_builder_get_object (builder, "rename_namespace_button"));
431  gtk_widget_set_sensitive (cd->rename_namespace_button, FALSE);
432 
433  /* commodity tree */
434  scrolled_window = GTK_WIDGET(gtk_builder_get_object (builder, "commodity_list_window"));
435  view = gnc_tree_view_commodity_new(cd->book,
436  "state-section", STATE_SECTION,
437  "show-column-menu", TRUE,
438  NULL);
439  cd->commodity_tree = GNC_TREE_VIEW_COMMODITY(view);
440  gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET(view));
441  gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(cd->commodity_tree), TRUE);
442  gnc_tree_view_commodity_set_filter (cd->commodity_tree,
443  gnc_commodities_dialog_filter_ns_func,
444  gnc_commodities_dialog_filter_cm_func,
445  cd, NULL);
446  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
447  g_signal_connect (G_OBJECT (selection), "changed",
448  G_CALLBACK (gnc_commodities_dialog_selection_changed), cd);
449 
450  g_signal_connect (G_OBJECT (cd->commodity_tree), "row-activated",
451  G_CALLBACK (row_activated_cb), cd);
452 
453  /* Show currency button */
454  button = GTK_WIDGET(gtk_builder_get_object (builder, "show_currencies_button"));
455  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(button), cd->show_currencies);
456 
457  /* default to 'close' button */
458  button = GTK_WIDGET(gtk_builder_get_object (builder, "close_button"));
459  gtk_widget_grab_default (button);
460  gtk_widget_grab_focus (button);
461 
462  g_signal_connect (cd->window, "destroy",
463  G_CALLBACK(gnc_commodities_window_destroy_cb), cd);
464 
465  g_signal_connect (cd->window, "delete-event",
466  G_CALLBACK(gnc_commodities_window_delete_event_cb), cd);
467 
468  g_signal_connect (cd->window, "key_press_event",
469  G_CALLBACK (gnc_commodities_window_key_press_cb), cd);
470 
471  gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, cd);
472  g_object_unref (G_OBJECT(builder));
473 
474  gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(cd->window), GTK_WINDOW(parent));
475 }
476 
477 static void
478 close_handler (gpointer user_data)
479 {
480  auto cd = static_cast<CommoditiesDialog*>(user_data);
481 
482  gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(cd->window));
483 
484  gnc_prefs_set_bool (GNC_PREFS_GROUP, GNC_PREF_INCL_ISO, cd->show_currencies);
485 
486  gtk_widget_destroy (cd->window);
487 }
488 
489 static void
490 refresh_handler (GHashTable *changes, gpointer user_data)
491 {
492  auto cd = static_cast<CommoditiesDialog*>(user_data);
493 
494  g_return_if_fail(cd != NULL);
495 
496  gnc_tree_view_commodity_refilter (cd->commodity_tree);
497 }
498 
499 static gboolean
500 show_handler (const char *klass, gint component_id,
501  gpointer user_data, gpointer iter_data)
502 {
503  auto cd = static_cast<CommoditiesDialog*>(user_data);
504 
505  if (!cd)
506  return(FALSE);
507  gtk_window_present (GTK_WINDOW(cd->window));
508  return(TRUE);
509 }
510 
511 gboolean
512 gnc_commodities_window_key_press_cb (GtkWidget *widget, GdkEventKey *event,
513  gpointer data)
514 {
515  auto cd = static_cast<CommoditiesDialog*>(data);
516 
517  if (event->keyval == GDK_KEY_Escape)
518  {
519  close_handler (cd);
520  return TRUE;
521  }
522  else
523  return FALSE;
524 }
525 
526 /********************************************************************\
527  * gnc_commodities_dialog *
528  * opens up a window to edit price information *
529  * *
530  * Args: parent - the parent of the window to be created *
531  * Return: nothing *
532 \********************************************************************/
533 void
534 gnc_commodities_dialog (GtkWidget * parent)
535 {
536  gint component_id;
537 
538  if (gnc_forall_gui_components (DIALOG_COMMODITIES_CM_CLASS,
539  show_handler, NULL))
540  return;
541 
542  auto cd = static_cast<CommoditiesDialog*>(g_new0 (CommoditiesDialog, 1));
543 
544  gnc_commodities_dialog_create (parent, cd);
545 
546  component_id = gnc_register_gui_component (DIALOG_COMMODITIES_CM_CLASS,
547  refresh_handler, close_handler,
548  cd);
549  gnc_gui_component_set_session (component_id, cd->session);
550 
551  gtk_widget_grab_focus (GTK_WIDGET(cd->commodity_tree));
552 
553  gtk_widget_show (cd->window);
554 }
void gnc_price_list_destroy(PriceList *prices)
gnc_price_list_destroy - destroy the given price list, calling gnc_price_unref on all the prices incl...
GtkTreeView * gnc_tree_view_commodity_new(QofBook *book, const gchar *first_property_name,...)
Create a new commodity tree view.
gnc_commodity_table * gnc_commodity_table_get_table(QofBook *book)
Returns the commodity table associated with a book.
void gnc_tree_view_commodity_set_filter(GncTreeViewCommodity *view, gnc_tree_view_commodity_ns_filter_func ns_func, gnc_tree_view_commodity_cm_filter_func cm_func, gpointer data, GDestroyNotify destroy)
This function attaches a filter function to the given commodity tree.
utility functions for the GnuCash UI
gnc_commodity * gnc_ui_new_commodity_modal(const char *default_namespace, GtkWidget *parent)
Ask the user to provide the information necessary to create a new commodity.
Commodity handling public routines (C++ api)
gboolean gnc_ui_edit_commodity_modal(gnc_commodity *commodity, GtkWidget *parent)
Given an existing commodity, uses the gnc_ui_build_commodity_dialog() routine to build a basic edit d...
const char * gnc_commodity_get_namespace(const gnc_commodity *cm)
Retrieve the namespace for the specified commodity.
gnc_commodity_namespace * gnc_tree_view_commodity_get_selected_namespace(GncTreeViewCommodity *view)
This function returns the namespace associated with the selected item in the commodity tree view...
GList * gnc_commodity_namespace_get_commodity_list(const gnc_commodity_namespace *name_space)
Return a list of all commodity data structures in the specified namespace.
GNCPriceDB * gnc_pricedb_get_db(QofBook *book)
Return the pricedb associated with the book.
const char * gnc_commodity_namespace_get_name(const gnc_commodity_namespace *ns)
Return the textual name of a namespace data structure.
QofBook * qof_session_get_book(const QofSession *session)
Returns the QofBook of this session.
Definition: qofsession.cpp:575
gchar * gnc_account_get_full_name(const Account *account)
The gnc_account_get_full_name routine returns the fully qualified name of the account using the given...
Definition: Account.cpp:3279
void gnc_tree_view_commodity_select_commodity(GncTreeViewCommodity *view, gnc_commodity *commodity)
Select the commodity in the associated commodity tree view.
Account public routines (C++ api)
gboolean gnc_prefs_set_bool(const gchar *group, const gchar *pref_name, gboolean value)
Store a boolean value into the preferences backend.
Definition: gnc-prefs.cpp:277
gboolean gnc_commodity_namespace_is_iso(const char *name_space)
Checks to see if the specified commodity namespace is the namespace for ISO 4217 currencies.
#define GNC_COMMODITY_NS_LEGACY
The commodity namespace definitions are used to tag a commodity by its type, or a stocks by the excha...
Gnome specific utility functions.
bool gnc_commodity_table_rename_namespace(const gnc_commodity_table *table, const char *namespace_name, const char *new_namespace_name)
This function renames a namespace.
void qof_book_mark_session_dirty(QofBook *book)
The qof_book_mark_dirty() routine marks the book as having been modified.
Definition: qofbook.cpp:397
gboolean gnc_pricedb_remove_price(GNCPriceDB *db, GNCPrice *p)
Remove a price from the pricedb and unref the price.
Generic api to store and retrieve preferences.
gnc_commodity * gnc_tree_view_commodity_get_selected_commodity(GncTreeViewCommodity *view)
This function returns the commodity associated with the selected item in the commodity tree view...
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.
GtkTreeView implementation for gnucash commodity tree.
void gnc_commodity_table_remove(gnc_commodity_table *table, gnc_commodity *comm)
Remove a commodity from the commodity table.
void gnc_tree_view_commodity_refilter(GncTreeViewCommodity *view)
This function forces the commodity tree filter to be evaluated.
"select" and "new" commodity windows
Commodity handling public routines.
void gnc_commodity_destroy(gnc_commodity *cm)
Destroy a commodity.
gboolean gnc_commodity_is_iso(const gnc_commodity *cm)
Checks to see if the specified commodity is an ISO 4217 recognized currency.
PriceList * gnc_pricedb_get_prices(GNCPriceDB *db, const gnc_commodity *commodity, const gnc_commodity *currency)
Return all the prices for a given commodity in another.