Skip to content

Commit

Permalink
[dialog-commodities.cpp] convert to c++
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherlam committed Sep 30, 2024
1 parent 4b0c350 commit 18bb96f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion gnucash/gnome/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ set (gnc_gnome_SOURCES
dialog-doclink.c
dialog-billterms.c
dialog-choose-owner.c
dialog-commodities.c
dialog-commodities.cpp
dialog-customer.c
dialog-custom-report.c
dialog-date-close.c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,15 @@ typedef struct


void gnc_commodities_window_destroy_cb (GtkWidget *object, CommoditiesDialog *cd);

extern "C" {
void gnc_commodities_dialog_add_clicked (GtkWidget *widget, gpointer data);
void gnc_commodities_dialog_edit_clicked (GtkWidget *widget, gpointer data);
void gnc_commodities_dialog_remove_clicked (GtkWidget *widget, gpointer data);
void gnc_commodities_dialog_close_clicked (GtkWidget *widget, gpointer data);
void gnc_commodities_show_currencies_toggled (GtkToggleButton *toggle, CommoditiesDialog *cd);
}

gboolean gnc_commodities_window_key_press_cb (GtkWidget *widget,
GdkEventKey *event,
gpointer data);
Expand All @@ -93,7 +97,7 @@ gnc_commodities_window_delete_event_cb (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
CommoditiesDialog *cd = data;
auto cd = static_cast<CommoditiesDialog*>(data);
// this cb allows the window size to be saved on closing with the X
gnc_save_window_size (GNC_PREFS_GROUP,
GTK_WINDOW(cd->window));
Expand All @@ -103,7 +107,7 @@ gnc_commodities_window_delete_event_cb (GtkWidget *widget,
void
gnc_commodities_dialog_edit_clicked (GtkWidget *widget, gpointer data)
{
CommoditiesDialog *cd = data;
auto cd = static_cast<CommoditiesDialog*>(data);
gnc_commodity *commodity;

commodity = gnc_tree_view_commodity_get_selected_commodity (cd->commodity_tree);
Expand Down Expand Up @@ -147,7 +151,7 @@ row_activated_cb (GtkTreeView *view, GtkTreePath *path,
void
gnc_commodities_dialog_remove_clicked (GtkWidget *widget, gpointer data)
{
CommoditiesDialog *cd = data;
auto cd = static_cast<CommoditiesDialog*>(data);
GNCPriceDB *pdb;
GList *node;
GList *prices;
Expand All @@ -167,7 +171,7 @@ gnc_commodities_dialog_remove_clicked (GtkWidget *widget, gpointer data)

for (node = accounts; node; node = node->next)
{
Account *account = node->data;
Account *account = GNC_ACCOUNT(node->data);

if (commodity == xaccAccountGetCommodity (account))
{
Expand Down Expand Up @@ -226,7 +230,7 @@ gnc_commodities_dialog_remove_clicked (GtkWidget *widget, gpointer data)

ct = gnc_commodity_table_get_table (cd->book);
for (node = prices; node; node = node->next)
gnc_pricedb_remove_price(pdb, node->data);
gnc_pricedb_remove_price(pdb, GNC_PRICE(node->data));

gnc_commodity_table_remove (ct, commodity);
gnc_commodity_destroy (commodity);
Expand All @@ -243,7 +247,7 @@ gnc_commodities_dialog_remove_clicked (GtkWidget *widget, gpointer data)
void
gnc_commodities_dialog_add_clicked (GtkWidget *widget, gpointer data)
{
CommoditiesDialog *cd = data;
auto cd = static_cast<CommoditiesDialog*>(data);
gnc_commodity *commodity;
gnc_commodity *ret_commodity;
const char *name_space;
Expand All @@ -261,7 +265,7 @@ gnc_commodities_dialog_add_clicked (GtkWidget *widget, gpointer data)
void
gnc_commodities_dialog_close_clicked (GtkWidget *widget, gpointer data)
{
CommoditiesDialog *cd = data;
auto cd = static_cast<CommoditiesDialog*>(data);

gnc_close_gui_component_by_data (DIALOG_COMMODITIES_CM_CLASS, cd);
}
Expand Down Expand Up @@ -291,7 +295,7 @@ static gboolean
gnc_commodities_dialog_filter_ns_func (gnc_commodity_namespace *name_space,
gpointer data)
{
CommoditiesDialog *cd = data;
auto cd = static_cast<CommoditiesDialog*>(data);
const gchar *name;
GList *list;

Expand All @@ -315,7 +319,7 @@ static gboolean
gnc_commodities_dialog_filter_cm_func (gnc_commodity *commodity,
gpointer data)
{
CommoditiesDialog *cd = data;
auto cd = static_cast<CommoditiesDialog*>(data);

if (cd->show_currencies)
return TRUE;
Expand Down Expand Up @@ -394,7 +398,7 @@ gnc_commodities_dialog_create (GtkWidget * parent, CommoditiesDialog *cd)
static void
close_handler (gpointer user_data)
{
CommoditiesDialog *cd = user_data;
auto cd = static_cast<CommoditiesDialog*>(user_data);

gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(cd->window));

Expand All @@ -406,7 +410,7 @@ close_handler (gpointer user_data)
static void
refresh_handler (GHashTable *changes, gpointer user_data)
{
CommoditiesDialog *cd = user_data;
auto cd = static_cast<CommoditiesDialog*>(user_data);

g_return_if_fail(cd != NULL);

Expand All @@ -417,7 +421,7 @@ static gboolean
show_handler (const char *klass, gint component_id,
gpointer user_data, gpointer iter_data)
{
CommoditiesDialog *cd = user_data;
auto cd = static_cast<CommoditiesDialog*>(user_data);

if (!cd)
return(FALSE);
Expand All @@ -429,7 +433,7 @@ gboolean
gnc_commodities_window_key_press_cb (GtkWidget *widget, GdkEventKey *event,
gpointer data)
{
CommoditiesDialog *cd = data;
auto cd = static_cast<CommoditiesDialog*>(data);

if (event->keyval == GDK_KEY_Escape)
{
Expand All @@ -450,14 +454,13 @@ gnc_commodities_window_key_press_cb (GtkWidget *widget, GdkEventKey *event,
void
gnc_commodities_dialog (GtkWidget * parent)
{
CommoditiesDialog *cd;
gint component_id;

if (gnc_forall_gui_components (DIALOG_COMMODITIES_CM_CLASS,
show_handler, NULL))
return;

cd = g_new0 (CommoditiesDialog, 1);
auto cd = static_cast<CommoditiesDialog*>(g_new0 (CommoditiesDialog, 1));

gnc_commodities_dialog_create (parent, cd);

Expand Down
2 changes: 1 addition & 1 deletion po/POTFILES.in
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ gnucash/gnome/business-options-gnome.cpp
gnucash/gnome/business-urls.c
gnucash/gnome/dialog-billterms.c
gnucash/gnome/dialog-choose-owner.c
gnucash/gnome/dialog-commodities.c
gnucash/gnome/dialog-commodities.cpp
gnucash/gnome/dialog-customer.c
gnucash/gnome/dialog-custom-report.c
gnucash/gnome/dialog-date-close.c
Expand Down

0 comments on commit 18bb96f

Please sign in to comment.