Skip to content

Commit

Permalink
Refactor: DECLARE_FINAL GncSxInstanceModel < GObject
Browse files Browse the repository at this point in the history
  • Loading branch information
richardcohen committed Jun 29, 2023
1 parent 9713683 commit d30fdd8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
14 changes: 11 additions & 3 deletions libgnucash/app-utils/gnc-sx-instance-model.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ typedef struct
gnc_numeric amount;
} ScrubItem;

enum
{
REMOVING, UPDATED, ADDED,
LAST_SIGNAL
};

static guint signals[LAST_SIGNAL] = { 0 };

static void
scrub_sx_split_numeric (Split* split, gboolean is_credit, GList **changes)
{
Expand Down Expand Up @@ -670,7 +678,7 @@ gnc_sx_instance_model_class_init (GncSxInstanceModelClass *klass)
object_class->dispose = gnc_sx_instance_model_dispose;
object_class->finalize = gnc_sx_instance_model_finalize;

klass->removing_signal_id =
signals[REMOVING] =
g_signal_new("removing",
GNC_TYPE_SX_INSTANCE_MODEL,
G_SIGNAL_RUN_FIRST,
Expand All @@ -682,7 +690,7 @@ gnc_sx_instance_model_class_init (GncSxInstanceModelClass *klass)
1,
G_TYPE_POINTER);

klass->updated_signal_id =
signals[UPDATED] =
g_signal_new("updated",
GNC_TYPE_SX_INSTANCE_MODEL,
G_SIGNAL_RUN_FIRST,
Expand All @@ -694,7 +702,7 @@ gnc_sx_instance_model_class_init (GncSxInstanceModelClass *klass)
1,
G_TYPE_POINTER);

klass->added_signal_id =
signals[ADDED] =
g_signal_new("added",
GNC_TYPE_SX_INSTANCE_MODEL,
G_SIGNAL_RUN_FIRST,
Expand Down
17 changes: 1 addition & 16 deletions libgnucash/app-utils/gnc-sx-instance-model.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@
G_BEGIN_DECLS

#define GNC_TYPE_SX_INSTANCE_MODEL (gnc_sx_instance_model_get_type ())
#define GNC_SX_INSTANCE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_SX_INSTANCE_MODEL, GncSxInstanceModel))
#define GNC_SX_INSTANCE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_SX_INSTANCE_MODEL, GncSxInstanceModelClass))
#define GNC_IS_SX_INSTANCE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_SX_INSTANCE_MODEL))
#define GNC_IS_SX_INSTANCE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_SX_INSTANCE_MODEL))
#define GNC_SX_INSTANCE_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_SX_INSTANCE_MODEL, GncSxInstanceModelClass))
G_DECLARE_FINAL_TYPE (GncSxInstanceModel, gnc_sx_instance_model, GNC, SX_INSTANCE_MODEL, GObject)

typedef struct _GncSxInstanceModel
{
Expand All @@ -59,15 +55,6 @@ typedef struct _GncSxInstanceModel
GList *sx_instance_list; /* <GncSxInstances*> */
} GncSxInstanceModel;

typedef struct _GncSxInstanceModelClass
{
GObjectClass parent;

guint removing_signal_id;
guint updated_signal_id;
guint added_signal_id;
} GncSxInstanceModelClass;

typedef struct _GncSxInstances
{
SchedXaction *sx;
Expand Down Expand Up @@ -113,8 +100,6 @@ typedef struct _GncSxVariableNeeded
GncSxVariable *variable;
} GncSxVariableNeeded;

GType gnc_sx_instance_model_get_type(void);

/** Shorthand for get_instances(now, FALSE); */
GncSxInstanceModel* gnc_sx_get_current_instances(void);

Expand Down

0 comments on commit d30fdd8

Please sign in to comment.