Skip to content

Commit

Permalink
Merge Richard Cohen's 'declare-type-gnc-tree-model' into stable.
Browse files Browse the repository at this point in the history
  • Loading branch information
jralls committed Jun 16, 2023
2 parents 48cf3a9 + c87f9db commit eee5f67
Show file tree
Hide file tree
Showing 13 changed files with 176 additions and 1,186 deletions.
23 changes: 8 additions & 15 deletions gnucash/gnome-utils/gnc-tree-model-account-types.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,15 @@ gnc_tree_model_account_types_finalize (GObject * object);
static void
gnc_tree_model_account_types_tree_model_init (GtkTreeModelIface * iface);

typedef struct GncTreeModelAccountTypesPrivate
struct _GncTreeModelAccountTypes
{
guint32 selected;
} GncTreeModelAccountTypesPrivate;
GObject gobject;
int stamp;

#define GNC_TREE_MODEL_ACCOUNT_TYPES_GET_PRIVATE(o) \
((GncTreeModelAccountTypesPrivate*)gnc_tree_model_account_types_get_instance_private((GncTreeModelAccountTypes*)o))
guint32 selected;
};

G_DEFINE_TYPE_WITH_CODE(GncTreeModelAccountTypes, gnc_tree_model_account_types, G_TYPE_OBJECT,
G_ADD_PRIVATE(GncTreeModelAccountTypes)
G_IMPLEMENT_INTERFACE(GTK_TYPE_TREE_MODEL,
gnc_tree_model_account_types_tree_model_init))

Expand Down Expand Up @@ -88,12 +87,8 @@ gnc_tree_model_account_types_finalize (GObject * object)
GtkTreeModel *
gnc_tree_model_account_types_new (guint32 selected)
{
GncTreeModelAccountTypes *model;
GncTreeModelAccountTypesPrivate *priv;

model = g_object_new (GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES, NULL);
priv = GNC_TREE_MODEL_ACCOUNT_TYPES_GET_PRIVATE(model);
priv->selected = selected;
GncTreeModelAccountTypes *model = g_object_new (GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES, NULL);
model->selected = selected;

return GTK_TREE_MODEL (model);
}
Expand Down Expand Up @@ -407,13 +402,11 @@ gnc_tree_model_account_types_get_value (GtkTreeModel * tree_model,
GValue * value)
{
GncTreeModelAccountTypes *model = GNC_TREE_MODEL_ACCOUNT_TYPES(tree_model);
GncTreeModelAccountTypesPrivate *priv;

g_return_if_fail (GNC_IS_TREE_MODEL_ACCOUNT_TYPES (model));
g_return_if_fail (iter != NULL);
g_return_if_fail (iter->stamp == model->stamp);

priv = GNC_TREE_MODEL_ACCOUNT_TYPES_GET_PRIVATE(model);
switch (column)
{
case GNC_TREE_MODEL_ACCOUNT_TYPES_COL_TYPE:
Expand All @@ -427,7 +420,7 @@ gnc_tree_model_account_types_get_value (GtkTreeModel * tree_model,
break;
case GNC_TREE_MODEL_ACCOUNT_TYPES_COL_SELECTED:
g_value_init (value, G_TYPE_BOOLEAN);
g_value_set_boolean (value, priv->selected &
g_value_set_boolean (value, model->selected &
(1 << GPOINTER_TO_INT (iter->user_data)));
break;
default:
Expand Down
19 changes: 1 addition & 18 deletions gnucash/gnome-utils/gnc-tree-model-account-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ G_BEGIN_DECLS

/* type macros */
#define GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES (gnc_tree_model_account_types_get_type ())
#define GNC_TREE_MODEL_ACCOUNT_TYPES(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES, GncTreeModelAccountTypes))
#define GNC_TREE_MODEL_ACCOUNT_TYPES_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES, GncTreeModelAccountTypesClass))
#define GNC_IS_TREE_MODEL_ACCOUNT_TYPES(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES))
#define GNC_IS_TREE_MODEL_ACCOUNT_TYPES_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES))
#define GNC_TREE_MODEL_ACCOUNT_TYPES_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES, GncTreeModelAccountTypesClass))
G_DECLARE_FINAL_TYPE (GncTreeModelAccountTypes, gnc_tree_model_account_types, GNC, TREE_MODEL_ACCOUNT_TYPES, GObject)

typedef enum
{
Expand All @@ -58,20 +54,7 @@ typedef enum
GNC_TREE_MODEL_ACCOUNT_TYPES_NUM_COLUMNS
} GncTreeModelAccountTypesColumn;

/* typedefs & structures */
typedef struct
{
GObject gobject;
int stamp;
} GncTreeModelAccountTypes;

typedef struct
{
GObjectClass gobject;
} GncTreeModelAccountTypesClass;

/* function prototypes */
GType gnc_tree_model_account_types_get_type (void);

/* Choose one of two methods to use the GncTreeModelAccountTypes
objects defined here, depending on how you want to deal with
Expand Down

0 comments on commit eee5f67

Please sign in to comment.