From 2ab6650e9a4bd53508572cd9494f1adc4d82be92 Mon Sep 17 00:00:00 2001 From: Christoph Holtermann Date: Wed, 5 Dec 2018 21:50:15 +0100 Subject: [PATCH] Replace deprecated g_type_class_add_private use G_DEFINE_TYPE_WITH_PRIVATE and adapt name of private property to work with G_DEFINE_TYPE_WITH_PRIVATE --- libgnucash/engine/gnc-budget.c | 24 ++++++------ libgnucash/engine/gnc-commodity.c | 64 +++++++++++++++---------------- libgnucash/engine/gnc-lot.c | 42 ++++++++++---------- 3 files changed, 62 insertions(+), 68 deletions(-) diff --git a/libgnucash/engine/gnc-budget.c b/libgnucash/engine/gnc-budget.c index 9619dbcd29..ab49be6c51 100644 --- a/libgnucash/engine/gnc-budget.c +++ b/libgnucash/engine/gnc-budget.c @@ -58,7 +58,7 @@ typedef struct QofInstanceClass parent_class; } BudgetClass; -typedef struct BudgetPrivate +typedef struct GncBudgetPrivate { /* The name is an arbitrary string assigned by the user. */ gchar* name; @@ -71,10 +71,10 @@ typedef struct BudgetPrivate /* Number of periods */ guint num_periods; -} BudgetPrivate; +} GncBudgetPrivate; #define GET_PRIVATE(o) \ - (G_TYPE_INSTANCE_GET_PRIVATE((o), GNC_TYPE_BUDGET, BudgetPrivate)) + (G_TYPE_INSTANCE_GET_PRIVATE((o), GNC_TYPE_BUDGET, GncBudgetPrivate)) struct _GncBudgetClass { @@ -82,12 +82,12 @@ struct _GncBudgetClass }; /* GObject Initialization */ -G_DEFINE_TYPE(GncBudget, gnc_budget, QOF_TYPE_INSTANCE) +G_DEFINE_TYPE_WITH_PRIVATE(GncBudget, gnc_budget, QOF_TYPE_INSTANCE) static void gnc_budget_init(GncBudget* budget) { - BudgetPrivate* priv; + GncBudgetPrivate* priv; GDate *date; priv = GET_PRIVATE(budget); @@ -120,7 +120,7 @@ gnc_budget_get_property( GObject* object, GParamSpec* pspec) { GncBudget* budget; - BudgetPrivate* priv; + GncBudgetPrivate* priv; g_return_if_fail(GNC_IS_BUDGET(object)); @@ -191,8 +191,6 @@ gnc_budget_class_init(GncBudgetClass* klass) gobject_class->get_property = gnc_budget_get_property; gobject_class->set_property = gnc_budget_set_property; - g_type_class_add_private(klass, sizeof(BudgetPrivate)); - g_object_class_install_property( gobject_class, PROP_NAME, @@ -248,7 +246,7 @@ static void gnc_budget_free(QofInstance *inst) { GncBudget *budget; - BudgetPrivate* priv; + GncBudgetPrivate* priv; if (inst == NULL) return; @@ -370,7 +368,7 @@ gnc_budget_clone(const GncBudget* old_b) void gnc_budget_set_name(GncBudget* budget, const gchar* name) { - BudgetPrivate* priv; + GncBudgetPrivate* priv; g_return_if_fail(GNC_IS_BUDGET(budget) && name); @@ -395,7 +393,7 @@ gnc_budget_get_name(const GncBudget* budget) void gnc_budget_set_description(GncBudget* budget, const gchar* description) { - BudgetPrivate* priv; + GncBudgetPrivate* priv; g_return_if_fail(GNC_IS_BUDGET(budget)); g_return_if_fail(description); @@ -420,7 +418,7 @@ gnc_budget_get_description(const GncBudget* budget) void gnc_budget_set_recurrence(GncBudget *budget, const Recurrence *r) { - BudgetPrivate* priv; + GncBudgetPrivate* priv; g_return_if_fail(budget && r); priv = GET_PRIVATE(budget); @@ -451,7 +449,7 @@ gnc_budget_get_guid(const GncBudget* budget) void gnc_budget_set_num_periods(GncBudget* budget, guint num_periods) { - BudgetPrivate* priv; + GncBudgetPrivate* priv; g_return_if_fail(GNC_IS_BUDGET(budget)); diff --git a/libgnucash/engine/gnc-commodity.c b/libgnucash/engine/gnc-commodity.c index 2a028cedfd..7d775a7ad2 100644 --- a/libgnucash/engine/gnc-commodity.c +++ b/libgnucash/engine/gnc-commodity.c @@ -66,7 +66,7 @@ struct gnc_commodity_s QofInstance inst; }; -typedef struct CommodityPrivate +typedef struct gnc_commodityPrivate { gnc_commodity_namespace *name_space; @@ -87,10 +87,10 @@ typedef struct CommodityPrivate /* the default display_symbol, set in iso-4217-currencies at start-up */ const char * default_symbol; -} CommodityPrivate; +} gnc_commodityPrivate; #define GET_PRIVATE(o) \ - (G_TYPE_INSTANCE_GET_PRIVATE((o), GNC_TYPE_COMMODITY, CommodityPrivate)) + (G_TYPE_INSTANCE_GET_PRIVATE((o), GNC_TYPE_COMMODITY, gnc_commodityPrivate)) struct _GncCommodityClass { @@ -629,7 +629,7 @@ mark_commodity_dirty (gnc_commodity *cm) } static void -reset_printname(CommodityPrivate *priv) +reset_printname(gnc_commodityPrivate *priv) { g_free(priv->printname); priv->printname = g_strdup_printf("%s (%s)", @@ -638,7 +638,7 @@ reset_printname(CommodityPrivate *priv) } static void -reset_unique_name(CommodityPrivate *priv) +reset_unique_name(gnc_commodityPrivate *priv) { gnc_commodity_namespace *ns; @@ -650,12 +650,12 @@ reset_unique_name(CommodityPrivate *priv) } /* GObject Initialization */ -G_DEFINE_TYPE(gnc_commodity, gnc_commodity, QOF_TYPE_INSTANCE); +G_DEFINE_TYPE_WITH_PRIVATE(gnc_commodity, gnc_commodity, QOF_TYPE_INSTANCE); static void gnc_commodity_init(gnc_commodity* com) { - CommodityPrivate* priv; + gnc_commodityPrivate* priv; priv = GET_PRIVATE(com); @@ -696,7 +696,7 @@ gnc_commodity_get_property (GObject *object, GParamSpec *pspec) { gnc_commodity *commodity; - CommodityPrivate* priv; + gnc_commodityPrivate* priv; g_return_if_fail(GNC_IS_COMMODITY(object)); @@ -794,8 +794,6 @@ gnc_commodity_class_init(struct _GncCommodityClass* klass) gobject_class->set_property = gnc_commodity_set_property; gobject_class->get_property = gnc_commodity_get_property; - g_type_class_add_private(klass, sizeof(CommodityPrivate)); - g_object_class_install_property(gobject_class, PROP_NAMESPACE, g_param_spec_object ("namespace", @@ -925,7 +923,7 @@ commodity_free(gnc_commodity * cm) { QofBook *book; gnc_commodity_table *table; - CommodityPrivate* priv; + gnc_commodityPrivate* priv; if (!cm) return; @@ -980,8 +978,8 @@ gnc_commodity_destroy(gnc_commodity * cm) void gnc_commodity_copy(gnc_commodity * dest, const gnc_commodity *src) { - CommodityPrivate* src_priv = GET_PRIVATE(src); - CommodityPrivate* dest_priv = GET_PRIVATE(dest); + gnc_commodityPrivate* src_priv = GET_PRIVATE(src); + gnc_commodityPrivate* dest_priv = GET_PRIVATE(dest); gnc_commodity_set_fullname (dest, src_priv->fullname); gnc_commodity_set_mnemonic (dest, src_priv->mnemonic); @@ -997,8 +995,8 @@ gnc_commodity_copy(gnc_commodity * dest, const gnc_commodity *src) gnc_commodity * gnc_commodity_clone(const gnc_commodity *src, QofBook *dest_book) { - CommodityPrivate* src_priv; - CommodityPrivate* dest_priv; + gnc_commodityPrivate* src_priv; + gnc_commodityPrivate* dest_priv; gnc_commodity * dest = g_object_new(GNC_TYPE_COMMODITY, NULL); qof_instance_init_data (&dest->inst, GNC_ID_COMMODITY, dest_book); @@ -1147,7 +1145,7 @@ gnc_commodity_get_quote_flag(const gnc_commodity *cm) gnc_quote_source* gnc_commodity_get_quote_source(const gnc_commodity *cm) { - CommodityPrivate* priv; + gnc_commodityPrivate* priv; if (!cm) return NULL; priv = GET_PRIVATE(cm); @@ -1233,7 +1231,7 @@ gnc_commodity_get_nice_symbol (const gnc_commodity *cm) void gnc_commodity_set_mnemonic(gnc_commodity * cm, const char * mnemonic) { - CommodityPrivate* priv; + gnc_commodityPrivate* priv; if (!cm) return; priv = GET_PRIVATE(cm); @@ -1259,7 +1257,7 @@ gnc_commodity_set_namespace(gnc_commodity * cm, const char * name_space) QofBook *book; gnc_commodity_table *table; gnc_commodity_namespace *nsp; - CommodityPrivate* priv; + gnc_commodityPrivate* priv; if (!cm) return; priv = GET_PRIVATE(cm); @@ -1286,7 +1284,7 @@ gnc_commodity_set_namespace(gnc_commodity * cm, const char * name_space) void gnc_commodity_set_fullname(gnc_commodity * cm, const char * fullname) { - CommodityPrivate* priv; + gnc_commodityPrivate* priv; if (!cm) return; priv = GET_PRIVATE(cm); @@ -1309,7 +1307,7 @@ void gnc_commodity_set_cusip(gnc_commodity * cm, const char * cusip) { - CommodityPrivate* priv; + gnc_commodityPrivate* priv; if (!cm) return; @@ -1374,7 +1372,7 @@ gnc_commodity_set_auto_quote_control_flag(gnc_commodity *cm, void gnc_commodity_user_set_quote_flag(gnc_commodity *cm, const gboolean flag) { - CommodityPrivate* priv; + gnc_commodityPrivate* priv; ENTER ("(cm=%p, flag=%d)", cm, flag); @@ -1444,7 +1442,7 @@ gnc_commodity_set_quote_source(gnc_commodity *cm, gnc_quote_source *src) void gnc_commodity_set_quote_tz(gnc_commodity *cm, const char *tz) { - CommodityPrivate* priv; + gnc_commodityPrivate* priv; if (!cm) return; @@ -1525,7 +1523,7 @@ gnc_commodity_set_default_symbol(gnc_commodity * cm, void gnc_commodity_increment_usage_count(gnc_commodity *cm) { - CommodityPrivate* priv; + gnc_commodityPrivate* priv; ENTER("(cm=%p)", cm); @@ -1560,7 +1558,7 @@ gnc_commodity_increment_usage_count(gnc_commodity *cm) void gnc_commodity_decrement_usage_count(gnc_commodity *cm) { - CommodityPrivate* priv; + gnc_commodityPrivate* priv; ENTER("(cm=%p)", cm); @@ -1603,8 +1601,8 @@ gnc_commodity_decrement_usage_count(gnc_commodity *cm) gboolean gnc_commodity_equiv(const gnc_commodity * a, const gnc_commodity * b) { - CommodityPrivate* priv_a; - CommodityPrivate* priv_b; + gnc_commodityPrivate* priv_a; + gnc_commodityPrivate* priv_b; if (a == b) return TRUE; if (!a || !b) return FALSE; @@ -1619,8 +1617,8 @@ gnc_commodity_equiv(const gnc_commodity * a, const gnc_commodity * b) gboolean gnc_commodity_equal(const gnc_commodity * a, const gnc_commodity * b) { - CommodityPrivate* priv_a; - CommodityPrivate* priv_b; + gnc_commodityPrivate* priv_a; + gnc_commodityPrivate* priv_b; gboolean same_book; if (a == b) return TRUE; @@ -1935,7 +1933,7 @@ gnc_commodity_table_insert(gnc_commodity_table * table, gnc_commodity_namespace * nsp = NULL; gnc_commodity *c; const char *ns_name; - CommodityPrivate* priv; + gnc_commodityPrivate* priv; QofBook *book; if (!table) return NULL; @@ -2015,7 +2013,7 @@ gnc_commodity_table_remove(gnc_commodity_table * table, { gnc_commodity_namespace * nsp; gnc_commodity *c; - CommodityPrivate* priv; + gnc_commodityPrivate* priv; const char *ns_name; if (!table) return; @@ -2125,7 +2123,7 @@ gnc_commodity_table_get_namespaces_list(const gnc_commodity_table * table) gboolean gnc_commodity_is_iso(const gnc_commodity * cm) { - CommodityPrivate* priv; + gnc_commodityPrivate* priv; if (!cm) return FALSE; @@ -2196,7 +2194,7 @@ static void get_quotables_helper1(gpointer key, gpointer value, gpointer data) { gnc_commodity *comm = value; - CommodityPrivate* priv = GET_PRIVATE(comm); + gnc_commodityPrivate* priv = GET_PRIVATE(comm); GList ** l = data; if (!priv->quote_flag || @@ -2209,7 +2207,7 @@ static gboolean get_quotables_helper2 (gnc_commodity *comm, gpointer data) { GList ** l = data; - CommodityPrivate* priv = GET_PRIVATE(comm); + gnc_commodityPrivate* priv = GET_PRIVATE(comm); if (!priv->quote_flag || !priv->quote_source || !priv->quote_source->supported) diff --git a/libgnucash/engine/gnc-lot.c b/libgnucash/engine/gnc-lot.c index 7df4483dbb..a0afc04814 100644 --- a/libgnucash/engine/gnc-lot.c +++ b/libgnucash/engine/gnc-lot.c @@ -75,7 +75,7 @@ enum PROP_MARKER, /* Runtime */ }; -typedef struct LotPrivate +typedef struct GNCLotPrivate { /* Account to which this lot applies. All splits in the lot must * belong to this account. @@ -92,22 +92,22 @@ typedef struct LotPrivate /* traversal marker, handy for preventing recursion */ unsigned char marker; -} LotPrivate; +} GNCLotPrivate; #define GET_PRIVATE(o) \ - (G_TYPE_INSTANCE_GET_PRIVATE((o), GNC_TYPE_LOT, LotPrivate)) + (G_TYPE_INSTANCE_GET_PRIVATE((o), GNC_TYPE_LOT, GNCLotPrivate)) #define gnc_lot_set_guid(L,G) qof_instance_set_guid(QOF_INSTANCE(L),&(G)) /* ============================================================= */ /* GObject Initialization */ -G_DEFINE_TYPE(GNCLot, gnc_lot, QOF_TYPE_INSTANCE) +G_DEFINE_TYPE_WITH_PRIVATE(GNCLot, gnc_lot, QOF_TYPE_INSTANCE) static void gnc_lot_init(GNCLot* lot) { - LotPrivate* priv; + GNCLotPrivate* priv; priv = GET_PRIVATE(lot); priv->account = NULL; @@ -132,7 +132,7 @@ static void gnc_lot_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) { GNCLot* lot; - LotPrivate* priv; + GNCLotPrivate* priv; gchar *key; g_return_if_fail(GNC_IS_LOT(object)); @@ -169,7 +169,7 @@ gnc_lot_set_property (GObject* object, GParamSpec* pspec) { GNCLot* lot; - LotPrivate* priv; + GNCLotPrivate* priv; gchar *key = NULL; g_return_if_fail(GNC_IS_LOT(object)); @@ -212,8 +212,6 @@ gnc_lot_class_init(GNCLotClass* klass) gobject_class->get_property = gnc_lot_get_property; gobject_class->set_property = gnc_lot_set_property; - g_type_class_add_private(klass, sizeof(LotPrivate)); - g_object_class_install_property( gobject_class, PROP_IS_CLOSED, @@ -277,7 +275,7 @@ static void gnc_lot_free(GNCLot* lot) { GList *node; - LotPrivate* priv; + GNCLotPrivate* priv; if (!lot) return; ENTER ("(lot=%p)", lot); @@ -364,7 +362,7 @@ gnc_lot_get_book (GNCLot *lot) gboolean gnc_lot_is_closed (GNCLot *lot) { - LotPrivate* priv; + GNCLotPrivate* priv; if (!lot) return TRUE; priv = GET_PRIVATE(lot); if (0 > priv->is_closed) gnc_lot_get_balance (lot); @@ -374,7 +372,7 @@ gnc_lot_is_closed (GNCLot *lot) Account * gnc_lot_get_account (const GNCLot *lot) { - LotPrivate* priv; + GNCLotPrivate* priv; if (!lot) return NULL; priv = GET_PRIVATE(lot); return priv->account; @@ -385,7 +383,7 @@ gnc_lot_set_account(GNCLot* lot, Account* account) { if (lot != NULL) { - LotPrivate* priv; + GNCLotPrivate* priv; priv = GET_PRIVATE(lot); priv->account = account; } @@ -394,7 +392,7 @@ gnc_lot_set_account(GNCLot* lot, Account* account) void gnc_lot_set_closed_unknown(GNCLot* lot) { - LotPrivate* priv; + GNCLotPrivate* priv; if (lot != NULL) { priv = GET_PRIVATE(lot); @@ -405,7 +403,7 @@ gnc_lot_set_closed_unknown(GNCLot* lot) SplitList * gnc_lot_get_split_list (const GNCLot *lot) { - LotPrivate* priv; + GNCLotPrivate* priv; if (!lot) return NULL; priv = GET_PRIVATE(lot); return priv->splits; @@ -413,7 +411,7 @@ gnc_lot_get_split_list (const GNCLot *lot) gint gnc_lot_count_splits (const GNCLot *lot) { - LotPrivate* priv; + GNCLotPrivate* priv; if (!lot) return 0; priv = GET_PRIVATE(lot); return g_list_length (priv->splits); @@ -475,7 +473,7 @@ gnc_lot_set_notes (GNCLot *lot, const char *str) gnc_numeric gnc_lot_get_balance (GNCLot *lot) { - LotPrivate* priv; + GNCLotPrivate* priv; GList *node; gnc_numeric zero = gnc_numeric_zero(); gnc_numeric baln = zero; @@ -518,7 +516,7 @@ void gnc_lot_get_balance_before (const GNCLot *lot, const Split *split, gnc_numeric *amount, gnc_numeric *value) { - LotPrivate* priv; + GNCLotPrivate* priv; GList *node; gnc_numeric zero = gnc_numeric_zero(); gnc_numeric amt = zero; @@ -567,7 +565,7 @@ gnc_lot_get_balance_before (const GNCLot *lot, const Split *split, void gnc_lot_add_split (GNCLot *lot, Split *split) { - LotPrivate* priv; + GNCLotPrivate* priv; Account * acc; if (!lot || !split) return; priv = GET_PRIVATE(lot); @@ -619,7 +617,7 @@ gnc_lot_add_split (GNCLot *lot, Split *split) void gnc_lot_remove_split (GNCLot *lot, Split *split) { - LotPrivate* priv; + GNCLotPrivate* priv; if (!lot || !split) return; priv = GET_PRIVATE(lot); @@ -646,7 +644,7 @@ gnc_lot_remove_split (GNCLot *lot, Split *split) Split * gnc_lot_get_earliest_split (GNCLot *lot) { - LotPrivate* priv; + GNCLotPrivate* priv; if (!lot) return NULL; priv = GET_PRIVATE(lot); if (! priv->splits) return NULL; @@ -658,7 +656,7 @@ gnc_lot_get_earliest_split (GNCLot *lot) Split * gnc_lot_get_latest_split (GNCLot *lot) { - LotPrivate* priv; + GNCLotPrivate* priv; SplitList *node; if (!lot) return NULL;