mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Gratuitous reformatting.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15625 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
64dd3d7bb4
commit
87a72a3ae0
File diff suppressed because it is too large
Load Diff
@ -75,40 +75,40 @@ typedef struct _GncSxInstances
|
||||
GDate next_instance_date;
|
||||
|
||||
/** GList<GncSxInstance*> **/
|
||||
GList *list; /* @fixme: s/list/?/ */
|
||||
GList *list; /* @fixme: s/list/?/ */
|
||||
} GncSxInstances;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SX_INSTANCE_STATE_IGNORED,
|
||||
SX_INSTANCE_STATE_POSTPONED,
|
||||
SX_INSTANCE_STATE_TO_CREATE,
|
||||
SX_INSTANCE_STATE_REMINDER,
|
||||
SX_INSTANCE_STATE_CREATED,
|
||||
SX_INSTANCE_STATE_MAX_STATE
|
||||
SX_INSTANCE_STATE_IGNORED,
|
||||
SX_INSTANCE_STATE_POSTPONED,
|
||||
SX_INSTANCE_STATE_TO_CREATE,
|
||||
SX_INSTANCE_STATE_REMINDER,
|
||||
SX_INSTANCE_STATE_CREATED,
|
||||
SX_INSTANCE_STATE_MAX_STATE
|
||||
} GncSxInstanceState;
|
||||
|
||||
typedef struct _GncSxVariable
|
||||
{
|
||||
gchar *name;
|
||||
gnc_numeric value; /**< only numeric values are supported. **/
|
||||
gboolean editable;
|
||||
gchar *name;
|
||||
gnc_numeric value; /**< only numeric values are supported. **/
|
||||
gboolean editable;
|
||||
} GncSxVariable;
|
||||
|
||||
typedef struct _GncSxInstance
|
||||
{
|
||||
GncSxInstances *parent; /**< the parent instances collection. **/
|
||||
void *temporal_state; /**< the sx creation temporal state. **/
|
||||
GncSxInstanceState orig_state; /**< the original state at generation time. **/
|
||||
GncSxInstanceState state; /**< the current state of the instance (during editing) **/
|
||||
GDate date; /**< the instance date. **/
|
||||
GHashTable *variable_bindings; /**< variable bindings. **/
|
||||
GncSxInstances *parent; /**< the parent instances collection. **/
|
||||
void *temporal_state; /**< the sx creation temporal state. **/
|
||||
GncSxInstanceState orig_state; /**< the original state at generation time. **/
|
||||
GncSxInstanceState state; /**< the current state of the instance (during editing) **/
|
||||
GDate date; /**< the instance date. **/
|
||||
GHashTable *variable_bindings; /**< variable bindings. **/
|
||||
} GncSxInstance;
|
||||
|
||||
typedef struct _GncSxVariableNeeded
|
||||
{
|
||||
GncSxInstance *instance;
|
||||
GncSxVariable *variable;
|
||||
GncSxInstance *instance;
|
||||
GncSxVariable *variable;
|
||||
} GncSxVariableNeeded;
|
||||
|
||||
GType gnc_sx_instance_model_get_type(void);
|
||||
@ -186,12 +186,12 @@ void gnc_sx_instance_model_effect_change(GncSxInstanceModel *model,
|
||||
|
||||
typedef struct _GncSxSummary
|
||||
{
|
||||
gboolean need_dialog; /**< If the dialog needs to be displayed. **/
|
||||
gboolean need_dialog; /**< If the dialog needs to be displayed. **/
|
||||
|
||||
gint num_instances; /**< The number of total instances (in any state). **/
|
||||
gint num_to_create_instances; /**< The number of (not-auto-create) to-create instances. **/
|
||||
gint num_auto_create_instances; /**< The total number of auto-create instances. **/
|
||||
gint num_auto_create_no_notify_instances; /**< The number of automatically-created instances that do no request notification. **/
|
||||
gint num_instances; /**< The number of total instances (in any state). **/
|
||||
gint num_to_create_instances; /**< The number of (not-auto-create) to-create instances. **/
|
||||
gint num_auto_create_instances; /**< The total number of auto-create instances. **/
|
||||
gint num_auto_create_no_notify_instances; /**< The number of automatically-created instances that do no request notification. **/
|
||||
} GncSxSummary;
|
||||
|
||||
/**
|
||||
|
@ -226,27 +226,27 @@ gnc_utf8_strip_invalid_strdup(const gchar* str)
|
||||
GList*
|
||||
gnc_g_list_map(GList* list, GncGMapFunc fn, gpointer user_data)
|
||||
{
|
||||
GList *rtn = NULL;
|
||||
for (; list != NULL; list = list->next)
|
||||
{
|
||||
rtn = g_list_append(rtn, (*fn)(list->data, user_data));
|
||||
}
|
||||
return rtn;
|
||||
GList *rtn = NULL;
|
||||
for (; list != NULL; list = list->next)
|
||||
{
|
||||
rtn = g_list_append(rtn, (*fn)(list->data, user_data));
|
||||
}
|
||||
return rtn;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_g_list_cut(GList **list, GList *cut_point)
|
||||
{
|
||||
if (list == NULL || *list == NULL)
|
||||
return;
|
||||
if (list == NULL || *list == NULL)
|
||||
return;
|
||||
|
||||
// if it's the first element.
|
||||
if (cut_point->prev == NULL)
|
||||
{
|
||||
*list = NULL;
|
||||
return;
|
||||
}
|
||||
// if it's the first element.
|
||||
if (cut_point->prev == NULL)
|
||||
{
|
||||
*list = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
cut_point->prev->next = NULL;
|
||||
cut_point->prev = NULL;
|
||||
cut_point->prev->next = NULL;
|
||||
cut_point->prev = NULL;
|
||||
}
|
||||
|
@ -84,14 +84,14 @@ gchar *gnc_utf8_strip_invalid_strdup (const gchar* str);
|
||||
typedef gpointer (*GncGMapFunc)(gpointer data, gpointer user_data);
|
||||
|
||||
/**
|
||||
* @return Caller-owned GList* of results of apply `fn` to `list` in order.
|
||||
* @return Caller-owned GList* of results of apply @a fn to @a list in order.
|
||||
**/
|
||||
GList* gnc_g_list_map(GList* list, GncGMapFunc fn, gpointer user_data);
|
||||
|
||||
/**
|
||||
* Cut a GList into two parts; the {@param cut_point} is the beginning of the
|
||||
* new list; {@param list} may need to be modified, but will be the list
|
||||
* before the {@param cut_point}.
|
||||
* Cut a GList into two parts; the @a cut_point is the beginning of the
|
||||
* new list; @a list may need to be modified, but will be the list
|
||||
* before the @a cut_point.
|
||||
**/
|
||||
void gnc_g_list_cut(GList **list, GList *cut_point);
|
||||
|
||||
|
@ -33,100 +33,100 @@ static guint gnc_dense_cal_model_signals[LAST_SIGNAL] = { 0 };
|
||||
static void
|
||||
gnc_dense_cal_model_base_init(gpointer g_class)
|
||||
{
|
||||
static gboolean initialized = FALSE;
|
||||
static gboolean initialized = FALSE;
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
gnc_dense_cal_model_signals[GDCM_ADDED]
|
||||
= g_signal_new("added",
|
||||
G_TYPE_FROM_CLASS(g_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
|
||||
0 /* default offset */,
|
||||
NULL /* accumulator */,
|
||||
NULL /* accum. data */,
|
||||
g_cclosure_marshal_VOID__UINT,
|
||||
G_TYPE_NONE /* return */,
|
||||
1 /* n_params */,
|
||||
G_TYPE_UINT /* param types */
|
||||
);
|
||||
if (!initialized)
|
||||
{
|
||||
gnc_dense_cal_model_signals[GDCM_ADDED]
|
||||
= g_signal_new("added",
|
||||
G_TYPE_FROM_CLASS(g_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
|
||||
0 /* default offset */,
|
||||
NULL /* accumulator */,
|
||||
NULL /* accum. data */,
|
||||
g_cclosure_marshal_VOID__UINT,
|
||||
G_TYPE_NONE /* return */,
|
||||
1 /* n_params */,
|
||||
G_TYPE_UINT /* param types */
|
||||
);
|
||||
|
||||
gnc_dense_cal_model_signals[GDCM_UPDATE]
|
||||
= g_signal_new("update",
|
||||
G_TYPE_FROM_CLASS(g_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
|
||||
0 /* default offset */,
|
||||
NULL /* accumulator */,
|
||||
NULL /* accum. data */,
|
||||
g_cclosure_marshal_VOID__UINT,
|
||||
G_TYPE_NONE /* return */,
|
||||
1 /* n_params */,
|
||||
G_TYPE_UINT /* param types */
|
||||
);
|
||||
gnc_dense_cal_model_signals[GDCM_UPDATE]
|
||||
= g_signal_new("update",
|
||||
G_TYPE_FROM_CLASS(g_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
|
||||
0 /* default offset */,
|
||||
NULL /* accumulator */,
|
||||
NULL /* accum. data */,
|
||||
g_cclosure_marshal_VOID__UINT,
|
||||
G_TYPE_NONE /* return */,
|
||||
1 /* n_params */,
|
||||
G_TYPE_UINT /* param types */
|
||||
);
|
||||
|
||||
gnc_dense_cal_model_signals[GDCM_REMOVE]
|
||||
= g_signal_new("removing",
|
||||
G_TYPE_FROM_CLASS(g_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
|
||||
0 /* default offset */,
|
||||
NULL /* accumulator */,
|
||||
NULL /* accum. data */,
|
||||
g_cclosure_marshal_VOID__UINT,
|
||||
G_TYPE_NONE /* return */,
|
||||
1 /* n_params */,
|
||||
G_TYPE_UINT /* param types */
|
||||
);
|
||||
gnc_dense_cal_model_signals[GDCM_REMOVE]
|
||||
= g_signal_new("removing",
|
||||
G_TYPE_FROM_CLASS(g_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
|
||||
0 /* default offset */,
|
||||
NULL /* accumulator */,
|
||||
NULL /* accum. data */,
|
||||
g_cclosure_marshal_VOID__UINT,
|
||||
G_TYPE_NONE /* return */,
|
||||
1 /* n_params */,
|
||||
G_TYPE_UINT /* param types */
|
||||
);
|
||||
|
||||
initialized = TRUE;
|
||||
}
|
||||
initialized = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
GType
|
||||
gnc_dense_cal_model_get_type(void)
|
||||
{
|
||||
static GType type = 0;
|
||||
if (type == 0) {
|
||||
static const GTypeInfo info = {
|
||||
sizeof(GncDenseCalModelIface),
|
||||
gnc_dense_cal_model_base_init, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
NULL, /* class_init */
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
0,
|
||||
0, /* n_preallocs */
|
||||
NULL /* instance_init */
|
||||
};
|
||||
type = g_type_register_static(G_TYPE_INTERFACE, "GncDenseCalModel", &info, 0);
|
||||
}
|
||||
return type;
|
||||
static GType type = 0;
|
||||
if (type == 0) {
|
||||
static const GTypeInfo info = {
|
||||
sizeof(GncDenseCalModelIface),
|
||||
gnc_dense_cal_model_base_init, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
NULL, /* class_init */
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
0,
|
||||
0, /* n_preallocs */
|
||||
NULL /* instance_init */
|
||||
};
|
||||
type = g_type_register_static(G_TYPE_INTERFACE, "GncDenseCalModel", &info, 0);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
GList*
|
||||
gnc_dense_cal_model_get_contained(GncDenseCalModel *model)
|
||||
{
|
||||
return (*GNC_DENSE_CAL_MODEL_GET_INTERFACE(model)->get_contained)(model);
|
||||
return (*GNC_DENSE_CAL_MODEL_GET_INTERFACE(model)->get_contained)(model);
|
||||
}
|
||||
|
||||
gchar*
|
||||
gnc_dense_cal_model_get_name(GncDenseCalModel *model, guint tag)
|
||||
{
|
||||
return (*GNC_DENSE_CAL_MODEL_GET_INTERFACE(model)->get_name)(model, tag);
|
||||
return (*GNC_DENSE_CAL_MODEL_GET_INTERFACE(model)->get_name)(model, tag);
|
||||
}
|
||||
|
||||
gchar*
|
||||
gnc_dense_cal_model_get_info(GncDenseCalModel *model, guint tag)
|
||||
{
|
||||
return (*GNC_DENSE_CAL_MODEL_GET_INTERFACE(model)->get_info)(model, tag);
|
||||
return (*GNC_DENSE_CAL_MODEL_GET_INTERFACE(model)->get_info)(model, tag);
|
||||
}
|
||||
|
||||
gint
|
||||
gnc_dense_cal_model_get_instance_count(GncDenseCalModel *model, guint tag)
|
||||
{
|
||||
return (*GNC_DENSE_CAL_MODEL_GET_INTERFACE(model)->get_instance_count)(model, tag);
|
||||
return (*GNC_DENSE_CAL_MODEL_GET_INTERFACE(model)->get_instance_count)(model, tag);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_dense_cal_model_get_instance(GncDenseCalModel *model, guint tag, gint instance_index, GDate *date)
|
||||
{
|
||||
return (*GNC_DENSE_CAL_MODEL_GET_INTERFACE(model)->get_instance)(model, tag, instance_index, date);
|
||||
return (*GNC_DENSE_CAL_MODEL_GET_INTERFACE(model)->get_instance)(model, tag, instance_index, date);
|
||||
}
|
||||
|
@ -37,19 +37,19 @@ G_BEGIN_DECLS
|
||||
typedef struct _GncDenseCalModel GncDenseCalModel; /* non existant */
|
||||
typedef struct _GncDenseCalModelIface
|
||||
{
|
||||
GTypeInterface parent;
|
||||
GTypeInterface parent;
|
||||
|
||||
/* signals */
|
||||
void (*insert)(GncDenseCalModel *mdl, gint tag);
|
||||
void (*update)(GncDenseCalModel *mdl, gint tag);
|
||||
void (*remove)(GncDenseCalModel *mdl, gint tag);
|
||||
/* signals */
|
||||
void (*insert)(GncDenseCalModel *mdl, gint tag);
|
||||
void (*update)(GncDenseCalModel *mdl, gint tag);
|
||||
void (*remove)(GncDenseCalModel *mdl, gint tag);
|
||||
|
||||
/* virtual table */
|
||||
GList* (*get_contained)(GncDenseCalModel *model);
|
||||
gchar* (*get_name)(GncDenseCalModel *model, guint tag);
|
||||
gchar* (*get_info)(GncDenseCalModel *model, guint tag);
|
||||
gint (*get_instance_count)(GncDenseCalModel *model, guint tag);
|
||||
void (*get_instance)(GncDenseCalModel *model, guint tag, gint instance_index, GDate *date);
|
||||
/* virtual table */
|
||||
GList* (*get_contained)(GncDenseCalModel *model);
|
||||
gchar* (*get_name)(GncDenseCalModel *model, guint tag);
|
||||
gchar* (*get_info)(GncDenseCalModel *model, guint tag);
|
||||
gint (*get_instance_count)(GncDenseCalModel *model, guint tag);
|
||||
void (*get_instance)(GncDenseCalModel *model, guint tag, gint instance_index, GDate *date);
|
||||
} GncDenseCalModelIface;
|
||||
|
||||
GType gnc_dense_cal_model_get_type(void);
|
||||
|
@ -31,22 +31,22 @@
|
||||
|
||||
struct _GncDenseCalStore
|
||||
{
|
||||
GObject parent;
|
||||
GObject parent;
|
||||
|
||||
GDate start_date;
|
||||
gdcs_end_type end_type;
|
||||
GDate end_date;
|
||||
gint n_occurrences;
|
||||
gchar *name;
|
||||
gchar *info;
|
||||
int num_marks;
|
||||
int num_real_marks;
|
||||
GDate **cal_marks;
|
||||
GDate start_date;
|
||||
gdcs_end_type end_type;
|
||||
GDate end_date;
|
||||
gint n_occurrences;
|
||||
gchar *name;
|
||||
gchar *info;
|
||||
int num_marks;
|
||||
int num_real_marks;
|
||||
GDate **cal_marks;
|
||||
};
|
||||
|
||||
struct _GncDenseCalStoreClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
static GObjectClass *parent_class = NULL;
|
||||
@ -64,132 +64,132 @@ static void gdcs_get_instance(GncDenseCalModel *model, guint tag, gint instance_
|
||||
static void
|
||||
gnc_dense_cal_store_class_init(GncDenseCalStoreClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
||||
parent_class = g_type_class_peek_parent(klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
||||
parent_class = g_type_class_peek_parent(klass);
|
||||
|
||||
object_class->finalize = gnc_dense_cal_store_finalize;
|
||||
object_class->finalize = gnc_dense_cal_store_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_dense_cal_store_iface_init(gpointer g_iface, gpointer iface_data)
|
||||
{
|
||||
GncDenseCalModelIface *iface = (GncDenseCalModelIface*)g_iface;
|
||||
iface->get_contained = gdcs_get_contained;
|
||||
iface->get_name = gdcs_get_name;
|
||||
iface->get_info = gdcs_get_info;
|
||||
iface->get_instance_count = gdcs_get_instance_count;
|
||||
iface->get_instance = gdcs_get_instance;
|
||||
GncDenseCalModelIface *iface = (GncDenseCalModelIface*)g_iface;
|
||||
iface->get_contained = gdcs_get_contained;
|
||||
iface->get_name = gdcs_get_name;
|
||||
iface->get_info = gdcs_get_info;
|
||||
iface->get_instance_count = gdcs_get_instance_count;
|
||||
iface->get_instance = gdcs_get_instance;
|
||||
}
|
||||
|
||||
GType
|
||||
gnc_dense_cal_store_get_type(void)
|
||||
{
|
||||
static GType type = 0;
|
||||
if (type == 0)
|
||||
{
|
||||
static const GTypeInfo info = {
|
||||
sizeof (GncDenseCalStoreClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc)gnc_dense_cal_store_class_init, /* class_init */
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof(GncDenseCalStore),
|
||||
0, /* n_preallocs */
|
||||
NULL /* instance_init */
|
||||
};
|
||||
static const GInterfaceInfo iDenseCalModelInfo = {
|
||||
(GInterfaceInitFunc)gnc_dense_cal_store_iface_init,
|
||||
NULL, /* interface finalize */
|
||||
NULL, /* interface data */
|
||||
};
|
||||
type = g_type_register_static(G_TYPE_OBJECT, "GncDenseCalStore", &info, 0);
|
||||
g_type_add_interface_static(type,
|
||||
GNC_TYPE_DENSE_CAL_MODEL,
|
||||
&iDenseCalModelInfo);
|
||||
}
|
||||
return type;
|
||||
static GType type = 0;
|
||||
if (type == 0)
|
||||
{
|
||||
static const GTypeInfo info = {
|
||||
sizeof (GncDenseCalStoreClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc)gnc_dense_cal_store_class_init, /* class_init */
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof(GncDenseCalStore),
|
||||
0, /* n_preallocs */
|
||||
NULL /* instance_init */
|
||||
};
|
||||
static const GInterfaceInfo iDenseCalModelInfo = {
|
||||
(GInterfaceInitFunc)gnc_dense_cal_store_iface_init,
|
||||
NULL, /* interface finalize */
|
||||
NULL, /* interface data */
|
||||
};
|
||||
type = g_type_register_static(G_TYPE_OBJECT, "GncDenseCalStore", &info, 0);
|
||||
g_type_add_interface_static(type,
|
||||
GNC_TYPE_DENSE_CAL_MODEL,
|
||||
&iDenseCalModelInfo);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
GncDenseCalStore*
|
||||
gnc_dense_cal_store_new(int num_marks)
|
||||
{
|
||||
GncDenseCalStore *model = g_object_new(GNC_TYPE_DENSE_CAL_STORE, NULL);
|
||||
model->num_marks = num_marks;
|
||||
model->cal_marks = g_new0(GDate*, num_marks);
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < model->num_marks; i++)
|
||||
{
|
||||
model->cal_marks[i] = g_date_new();
|
||||
}
|
||||
}
|
||||
model->num_real_marks = 0;
|
||||
g_date_clear(&model->start_date, 1);
|
||||
g_date_set_time_t(&model->start_date, time(NULL));
|
||||
model->end_type = NEVER_END;
|
||||
g_date_clear(&model->end_date, 1);
|
||||
g_date_set_time_t(&model->end_date, time(NULL));
|
||||
model->n_occurrences = 0;
|
||||
return model;
|
||||
GncDenseCalStore *model = g_object_new(GNC_TYPE_DENSE_CAL_STORE, NULL);
|
||||
model->num_marks = num_marks;
|
||||
model->cal_marks = g_new0(GDate*, num_marks);
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < model->num_marks; i++)
|
||||
{
|
||||
model->cal_marks[i] = g_date_new();
|
||||
}
|
||||
}
|
||||
model->num_real_marks = 0;
|
||||
g_date_clear(&model->start_date, 1);
|
||||
g_date_set_time_t(&model->start_date, time(NULL));
|
||||
model->end_type = NEVER_END;
|
||||
g_date_clear(&model->end_date, 1);
|
||||
g_date_set_time_t(&model->end_date, time(NULL));
|
||||
model->n_occurrences = 0;
|
||||
return model;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_dense_cal_store_clear(GncDenseCalStore *model)
|
||||
{
|
||||
model->num_real_marks = 0;
|
||||
g_signal_emit_by_name(model, "update", GUINT_TO_POINTER(1));
|
||||
model->num_real_marks = 0;
|
||||
g_signal_emit_by_name(model, "update", GUINT_TO_POINTER(1));
|
||||
}
|
||||
|
||||
void
|
||||
gnc_dense_cal_store_update_name(GncDenseCalStore *model, gchar *name)
|
||||
{
|
||||
if (model->name != NULL)
|
||||
{
|
||||
g_free(model->name);
|
||||
}
|
||||
model->name = g_strdup(name);
|
||||
g_signal_emit_by_name(model, "update", GUINT_TO_POINTER(1));
|
||||
if (model->name != NULL)
|
||||
{
|
||||
g_free(model->name);
|
||||
}
|
||||
model->name = g_strdup(name);
|
||||
g_signal_emit_by_name(model, "update", GUINT_TO_POINTER(1));
|
||||
}
|
||||
|
||||
void
|
||||
gnc_dense_cal_store_update_info(GncDenseCalStore *model, gchar *info)
|
||||
{
|
||||
if (model->info != NULL)
|
||||
{
|
||||
g_free(model->info);
|
||||
}
|
||||
model->info = g_strdup(info);
|
||||
g_signal_emit_by_name(model, "update", GUINT_TO_POINTER(1));
|
||||
if (model->info != NULL)
|
||||
{
|
||||
g_free(model->info);
|
||||
}
|
||||
model->info = g_strdup(info);
|
||||
g_signal_emit_by_name(model, "update", GUINT_TO_POINTER(1));
|
||||
}
|
||||
|
||||
static void
|
||||
gdcs_generic_update(GncDenseCalStore *trans, GDate *start, FreqSpec *fs)
|
||||
{
|
||||
int i;
|
||||
GDate date;
|
||||
int i;
|
||||
GDate date;
|
||||
|
||||
date = *start;
|
||||
/* go one day before what's in the box so we can get the correct start
|
||||
* date. */
|
||||
g_date_subtract_days(&date, 1);
|
||||
xaccFreqSpecGetNextInstance(fs, &date, &date);
|
||||
date = *start;
|
||||
/* go one day before what's in the box so we can get the correct start
|
||||
* date. */
|
||||
g_date_subtract_days(&date, 1);
|
||||
xaccFreqSpecGetNextInstance(fs, &date, &date);
|
||||
|
||||
i = 0;
|
||||
while ((i < trans->num_marks)
|
||||
&& g_date_valid(&date)
|
||||
/* Do checking against end restriction. */
|
||||
&& ((trans->end_type == NEVER_END)
|
||||
|| (trans->end_type == END_ON_DATE
|
||||
&& g_date_compare(&date, &trans->end_date) <= 0)
|
||||
|| (trans->end_type == END_AFTER_N_OCCS
|
||||
&& i < trans->n_occurrences)))
|
||||
{
|
||||
*trans->cal_marks[i++] = date;
|
||||
xaccFreqSpecGetNextInstance(fs, &date, &date);
|
||||
}
|
||||
trans->num_real_marks = (i == 0 ? 0 : (i-1));
|
||||
g_signal_emit_by_name(trans, "update", GUINT_TO_POINTER(1));
|
||||
i = 0;
|
||||
while ((i < trans->num_marks)
|
||||
&& g_date_valid(&date)
|
||||
/* Do checking against end restriction. */
|
||||
&& ((trans->end_type == NEVER_END)
|
||||
|| (trans->end_type == END_ON_DATE
|
||||
&& g_date_compare(&date, &trans->end_date) <= 0)
|
||||
|| (trans->end_type == END_AFTER_N_OCCS
|
||||
&& i < trans->n_occurrences)))
|
||||
{
|
||||
*trans->cal_marks[i++] = date;
|
||||
xaccFreqSpecGetNextInstance(fs, &date, &date);
|
||||
}
|
||||
trans->num_real_marks = (i == 0 ? 0 : (i-1));
|
||||
g_signal_emit_by_name(trans, "update", GUINT_TO_POINTER(1));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -225,24 +225,24 @@ gdcs_generic_update_recurrences(GncDenseCalStore *trans, GDate *start, GList *re
|
||||
void
|
||||
gnc_dense_cal_store_update_no_end(GncDenseCalStore *model, GDate *start, FreqSpec *fs)
|
||||
{
|
||||
model->end_type = NEVER_END;
|
||||
gdcs_generic_update(model, start, fs);
|
||||
model->end_type = NEVER_END;
|
||||
gdcs_generic_update(model, start, fs);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_dense_cal_store_update_count_end(GncDenseCalStore *model, GDate *start, FreqSpec *fs, int num_occur)
|
||||
{
|
||||
model->end_type = END_AFTER_N_OCCS;
|
||||
model->n_occurrences = num_occur;
|
||||
gdcs_generic_update(model, start, fs);
|
||||
model->end_type = END_AFTER_N_OCCS;
|
||||
model->n_occurrences = num_occur;
|
||||
gdcs_generic_update(model, start, fs);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_dense_cal_store_update_date_end(GncDenseCalStore *model, GDate *start, FreqSpec *fs, GDate *end_date)
|
||||
{
|
||||
model->end_type = END_ON_DATE;
|
||||
model->end_date = *end_date;
|
||||
gdcs_generic_update(model, start, fs);
|
||||
model->end_type = END_ON_DATE;
|
||||
model->end_date = *end_date;
|
||||
gdcs_generic_update(model, start, fs);
|
||||
}
|
||||
|
||||
void
|
||||
@ -263,83 +263,83 @@ gnc_dense_cal_store_update_recurrences_count_end(GncDenseCalStore *model, GDate
|
||||
void
|
||||
gnc_dense_cal_store_update_recurrences_date_end(GncDenseCalStore *model, GDate *start, GList *recurrences, GDate *end_date)
|
||||
{
|
||||
model->end_type = END_ON_DATE;
|
||||
model->end_date = *end_date;
|
||||
gdcs_generic_update_recurrences(model, start, recurrences);
|
||||
model->end_type = END_ON_DATE;
|
||||
model->end_date = *end_date;
|
||||
gdcs_generic_update_recurrences(model, start, recurrences);
|
||||
}
|
||||
|
||||
static GList*
|
||||
gdcs_get_contained(GncDenseCalModel *model)
|
||||
{
|
||||
GList *rtn = NULL;
|
||||
rtn = g_list_append(rtn, GUINT_TO_POINTER(1));
|
||||
return rtn;
|
||||
GList *rtn = NULL;
|
||||
rtn = g_list_append(rtn, GUINT_TO_POINTER(1));
|
||||
return rtn;
|
||||
}
|
||||
|
||||
static gchar*
|
||||
gdcs_get_name(GncDenseCalModel *model, guint tag)
|
||||
{
|
||||
GncDenseCalStore *mdl = GNC_DENSE_CAL_STORE(model);
|
||||
// assert(tag == 1)
|
||||
return mdl->name;
|
||||
GncDenseCalStore *mdl = GNC_DENSE_CAL_STORE(model);
|
||||
// assert(tag == 1)
|
||||
return mdl->name;
|
||||
}
|
||||
|
||||
static gchar*
|
||||
gdcs_get_info(GncDenseCalModel *model, guint tag)
|
||||
{
|
||||
GncDenseCalStore *mdl = GNC_DENSE_CAL_STORE(model);
|
||||
// assert(tag == 1)
|
||||
return mdl->info;
|
||||
GncDenseCalStore *mdl = GNC_DENSE_CAL_STORE(model);
|
||||
// assert(tag == 1)
|
||||
return mdl->info;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdcs_get_instance_count(GncDenseCalModel *model, guint tag)
|
||||
{
|
||||
GncDenseCalStore *mdl = GNC_DENSE_CAL_STORE(model);
|
||||
// assert(tag == 1)
|
||||
return mdl->num_real_marks;
|
||||
GncDenseCalStore *mdl = GNC_DENSE_CAL_STORE(model);
|
||||
// assert(tag == 1)
|
||||
return mdl->num_real_marks;
|
||||
}
|
||||
|
||||
static void
|
||||
gdcs_get_instance(GncDenseCalModel *model, guint tag, gint instance_index, GDate *date)
|
||||
{
|
||||
GncDenseCalStore *mdl = GNC_DENSE_CAL_STORE(model);
|
||||
// assert(tag == 1)
|
||||
// assert 0 < instance_index < model->num_marks;
|
||||
*date = *mdl->cal_marks[instance_index];
|
||||
GncDenseCalStore *mdl = GNC_DENSE_CAL_STORE(model);
|
||||
// assert(tag == 1)
|
||||
// assert 0 < instance_index < model->num_marks;
|
||||
*date = *mdl->cal_marks[instance_index];
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_dense_cal_store_finalize(GObject *obj)
|
||||
{
|
||||
int i;
|
||||
GncDenseCalStore *store;
|
||||
g_return_if_fail(obj != NULL);
|
||||
int i;
|
||||
GncDenseCalStore *store;
|
||||
g_return_if_fail(obj != NULL);
|
||||
|
||||
store = GNC_DENSE_CAL_STORE(obj);
|
||||
store = GNC_DENSE_CAL_STORE(obj);
|
||||
|
||||
if (store->name != NULL)
|
||||
{
|
||||
g_free(store->name);
|
||||
store->name = NULL;
|
||||
}
|
||||
if (store->name != NULL)
|
||||
{
|
||||
g_free(store->name);
|
||||
store->name = NULL;
|
||||
}
|
||||
|
||||
if (store->info != NULL)
|
||||
{
|
||||
g_free(store->info);
|
||||
store->info = NULL;
|
||||
}
|
||||
if (store->info != NULL)
|
||||
{
|
||||
g_free(store->info);
|
||||
store->info = NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < store->num_marks; i++)
|
||||
{
|
||||
g_free(store->cal_marks[i]);
|
||||
store->cal_marks[i] = NULL;
|
||||
}
|
||||
if (store->cal_marks != NULL)
|
||||
{
|
||||
g_free(store->cal_marks);
|
||||
store->cal_marks = NULL;
|
||||
}
|
||||
for (i = 0; i < store->num_marks; i++)
|
||||
{
|
||||
g_free(store->cal_marks[i]);
|
||||
store->cal_marks[i] = NULL;
|
||||
}
|
||||
if (store->cal_marks != NULL)
|
||||
{
|
||||
g_free(store->cal_marks);
|
||||
store->cal_marks = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS(parent_class)->finalize(obj);
|
||||
G_OBJECT_CLASS(parent_class)->finalize(obj);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -42,7 +42,7 @@ typedef struct _GncDenseCalClass GncDenseCalClass;
|
||||
|
||||
typedef struct _gdc_month_coords
|
||||
{
|
||||
gint x, y;
|
||||
gint x, y;
|
||||
} gdc_month_coords;
|
||||
|
||||
enum GDC_COLORS
|
||||
@ -84,39 +84,39 @@ struct _GncDenseCal
|
||||
|
||||
GdkColor weekColors[MAX_COLORS];
|
||||
|
||||
guint label_width;
|
||||
guint label_height;
|
||||
guint dayLabelHeight;
|
||||
guint label_width;
|
||||
guint label_height;
|
||||
guint dayLabelHeight;
|
||||
|
||||
GncDenseCalModel *model;
|
||||
GncDenseCalModel *model;
|
||||
|
||||
guint lastMarkTag;
|
||||
guint lastMarkTag;
|
||||
|
||||
/**
|
||||
* A GList of gdc_mark_data structs, one for each active/valid markTag.
|
||||
**/
|
||||
GList *markData;
|
||||
int numMarks;
|
||||
/* array of GList*s of per-cell markings. */
|
||||
GList **marks;
|
||||
/**
|
||||
* A GList of gdc_mark_data structs, one for each active/valid markTag.
|
||||
**/
|
||||
GList *markData;
|
||||
int numMarks;
|
||||
/* array of GList*s of per-cell markings. */
|
||||
GList **marks;
|
||||
|
||||
int disposed; /* private */
|
||||
int disposed; /* private */
|
||||
};
|
||||
|
||||
struct _GncDenseCalClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
typedef struct _gdc_mark_data
|
||||
{
|
||||
gchar *name;
|
||||
gchar *info;
|
||||
guint tag;
|
||||
/**
|
||||
* A GList of the dcal->marks indexes containing this mark.
|
||||
**/
|
||||
GList *ourMarks;
|
||||
gchar *name;
|
||||
gchar *info;
|
||||
guint tag;
|
||||
/**
|
||||
* A GList of the dcal->marks indexes containing this mark.
|
||||
**/
|
||||
GList *ourMarks;
|
||||
} gdc_mark_data;
|
||||
|
||||
GtkWidget* gnc_dense_cal_new (void);
|
||||
|
@ -41,230 +41,230 @@ static GObjectClass *parent_class = NULL;
|
||||
|
||||
struct _GncSxInstanceDenseCalAdapterClass
|
||||
{
|
||||
GObjectClass parent;
|
||||
GObjectClass parent;
|
||||
};
|
||||
|
||||
struct _GncSxInstanceDenseCalAdapter
|
||||
{
|
||||
GObject parent;
|
||||
gboolean disposed;
|
||||
GncSxInstanceModel *instances;
|
||||
GObject parent;
|
||||
gboolean disposed;
|
||||
GncSxInstanceModel *instances;
|
||||
};
|
||||
|
||||
static void
|
||||
gnc_sx_instance_dense_cal_adapter_class_init(GncSxInstanceDenseCalAdapterClass *klass)
|
||||
{
|
||||
GObjectClass *obj_class = G_OBJECT_CLASS(klass);
|
||||
GObjectClass *obj_class = G_OBJECT_CLASS(klass);
|
||||
|
||||
obj_class->dispose = gnc_sx_instance_dense_cal_adapter_dispose;
|
||||
obj_class->finalize = gnc_sx_instance_dense_cal_adapter_finalize;
|
||||
obj_class->dispose = gnc_sx_instance_dense_cal_adapter_dispose;
|
||||
obj_class->finalize = gnc_sx_instance_dense_cal_adapter_finalize;
|
||||
|
||||
parent_class = g_type_class_peek_parent(klass);
|
||||
parent_class = g_type_class_peek_parent(klass);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_sx_instance_dense_cal_adapter_init(GTypeInstance *instance, gpointer klass)
|
||||
{
|
||||
/*GncSxInstanceDenseCalAdapter *adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(instance);*/
|
||||
; /* nop */
|
||||
/*GncSxInstanceDenseCalAdapter *adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(instance);*/
|
||||
; /* nop */
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_sx_instance_dense_cal_adapter_interface_init(gpointer g_iface, gpointer iface_data)
|
||||
{
|
||||
GncDenseCalModelIface *iface = (GncDenseCalModelIface*)g_iface;
|
||||
iface->get_contained = gsidca_get_contained;
|
||||
iface->get_name = gsidca_get_name;
|
||||
iface->get_info = gsidca_get_info;
|
||||
iface->get_instance_count = gsidca_get_instance_count;
|
||||
iface->get_instance = gsidca_get_instance;
|
||||
GncDenseCalModelIface *iface = (GncDenseCalModelIface*)g_iface;
|
||||
iface->get_contained = gsidca_get_contained;
|
||||
iface->get_name = gsidca_get_name;
|
||||
iface->get_info = gsidca_get_info;
|
||||
iface->get_instance_count = gsidca_get_instance_count;
|
||||
iface->get_instance = gsidca_get_instance;
|
||||
}
|
||||
|
||||
static void
|
||||
gsidca_instances_added_cb(GncSxInstanceModel *model, SchedXaction *sx_added, gpointer user_data)
|
||||
{
|
||||
GncSxInstanceDenseCalAdapter *adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(user_data);
|
||||
g_debug("instance added\n");
|
||||
if (xaccSchedXactionGetEnabled(sx_added))
|
||||
{
|
||||
g_signal_emit_by_name(adapter, "added", GPOINTER_TO_UINT(sx_added));
|
||||
}
|
||||
GncSxInstanceDenseCalAdapter *adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(user_data);
|
||||
g_debug("instance added\n");
|
||||
if (xaccSchedXactionGetEnabled(sx_added))
|
||||
{
|
||||
g_signal_emit_by_name(adapter, "added", GPOINTER_TO_UINT(sx_added));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gsidca_instances_updated_cb(GncSxInstanceModel *model, SchedXaction *sx_updated, gpointer user_data)
|
||||
{
|
||||
GncSxInstanceDenseCalAdapter *adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(user_data);
|
||||
gnc_sx_instance_model_update_sx_instances(model, sx_updated);
|
||||
g_debug("instances updated\n");
|
||||
if (xaccSchedXactionGetEnabled(sx_updated))
|
||||
{
|
||||
g_signal_emit_by_name(adapter, "update", GPOINTER_TO_UINT((gpointer)sx_updated));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_signal_emit_by_name(adapter, "removing", GPOINTER_TO_UINT((gpointer)sx_updated));
|
||||
}
|
||||
GncSxInstanceDenseCalAdapter *adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(user_data);
|
||||
gnc_sx_instance_model_update_sx_instances(model, sx_updated);
|
||||
g_debug("instances updated\n");
|
||||
if (xaccSchedXactionGetEnabled(sx_updated))
|
||||
{
|
||||
g_signal_emit_by_name(adapter, "update", GPOINTER_TO_UINT((gpointer)sx_updated));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_signal_emit_by_name(adapter, "removing", GPOINTER_TO_UINT((gpointer)sx_updated));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gsidca_instances_removing_cb(GncSxInstanceModel *model, SchedXaction *sx_to_be_removed, gpointer user_data)
|
||||
{
|
||||
GncSxInstanceDenseCalAdapter *adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(user_data);
|
||||
g_debug("removing instance...\n");
|
||||
g_signal_emit_by_name(adapter, "removing", GPOINTER_TO_UINT(sx_to_be_removed));
|
||||
gnc_sx_instance_model_remove_sx_instances(model, sx_to_be_removed);
|
||||
GncSxInstanceDenseCalAdapter *adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(user_data);
|
||||
g_debug("removing instance...\n");
|
||||
g_signal_emit_by_name(adapter, "removing", GPOINTER_TO_UINT(sx_to_be_removed));
|
||||
gnc_sx_instance_model_remove_sx_instances(model, sx_to_be_removed);
|
||||
}
|
||||
|
||||
GncSxInstanceDenseCalAdapter*
|
||||
gnc_sx_instance_dense_cal_adapter_new(GncSxInstanceModel *instances)
|
||||
{
|
||||
GncSxInstanceDenseCalAdapter *adapter = g_object_new(GNC_TYPE_SX_INSTANCE_DENSE_CAL_ADAPTER, NULL);
|
||||
adapter->instances = instances;
|
||||
g_object_ref(G_OBJECT(adapter->instances));
|
||||
GncSxInstanceDenseCalAdapter *adapter = g_object_new(GNC_TYPE_SX_INSTANCE_DENSE_CAL_ADAPTER, NULL);
|
||||
adapter->instances = instances;
|
||||
g_object_ref(G_OBJECT(adapter->instances));
|
||||
|
||||
g_signal_connect(instances, "added", (GCallback)gsidca_instances_added_cb, adapter);
|
||||
g_signal_connect(instances, "updated", (GCallback)gsidca_instances_updated_cb, adapter);
|
||||
g_signal_connect(instances, "removing", (GCallback)gsidca_instances_removing_cb, adapter);
|
||||
return adapter;
|
||||
g_signal_connect(instances, "added", (GCallback)gsidca_instances_added_cb, adapter);
|
||||
g_signal_connect(instances, "updated", (GCallback)gsidca_instances_updated_cb, adapter);
|
||||
g_signal_connect(instances, "removing", (GCallback)gsidca_instances_removing_cb, adapter);
|
||||
return adapter;
|
||||
}
|
||||
|
||||
GType
|
||||
gnc_sx_instance_dense_cal_adapter_get_type(void)
|
||||
{
|
||||
static GType type = 0;
|
||||
if (type == 0)
|
||||
{
|
||||
static const GTypeInfo info = {
|
||||
sizeof (GncSxInstanceDenseCalAdapterClass),
|
||||
NULL, /* base init */
|
||||
NULL, /* base finalize */
|
||||
(GClassInitFunc)gnc_sx_instance_dense_cal_adapter_class_init,
|
||||
NULL, /* class finalize */
|
||||
NULL, /* class data */
|
||||
sizeof(GncSxInstanceDenseCalAdapter),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc)gnc_sx_instance_dense_cal_adapter_init
|
||||
};
|
||||
static const GInterfaceInfo iDenseCalModelInfo = {
|
||||
(GInterfaceInitFunc)gnc_sx_instance_dense_cal_adapter_interface_init,
|
||||
NULL, /* interface finalize */
|
||||
NULL, /* interface data */
|
||||
};
|
||||
static GType type = 0;
|
||||
if (type == 0)
|
||||
{
|
||||
static const GTypeInfo info = {
|
||||
sizeof (GncSxInstanceDenseCalAdapterClass),
|
||||
NULL, /* base init */
|
||||
NULL, /* base finalize */
|
||||
(GClassInitFunc)gnc_sx_instance_dense_cal_adapter_class_init,
|
||||
NULL, /* class finalize */
|
||||
NULL, /* class data */
|
||||
sizeof(GncSxInstanceDenseCalAdapter),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc)gnc_sx_instance_dense_cal_adapter_init
|
||||
};
|
||||
static const GInterfaceInfo iDenseCalModelInfo = {
|
||||
(GInterfaceInitFunc)gnc_sx_instance_dense_cal_adapter_interface_init,
|
||||
NULL, /* interface finalize */
|
||||
NULL, /* interface data */
|
||||
};
|
||||
|
||||
type = g_type_register_static (G_TYPE_OBJECT,
|
||||
"GncSxInstanceDenseCalAdapterType",
|
||||
&info, 0);
|
||||
g_type_add_interface_static(type,
|
||||
GNC_TYPE_DENSE_CAL_MODEL,
|
||||
&iDenseCalModelInfo);
|
||||
}
|
||||
return type;
|
||||
type = g_type_register_static (G_TYPE_OBJECT,
|
||||
"GncSxInstanceDenseCalAdapterType",
|
||||
&info, 0);
|
||||
g_type_add_interface_static(type,
|
||||
GNC_TYPE_DENSE_CAL_MODEL,
|
||||
&iDenseCalModelInfo);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
static gint
|
||||
gsidca_find_sx_with_tag(gconstpointer list_data,
|
||||
gconstpointer find_data)
|
||||
{
|
||||
GncSxInstances *sx_instances = (GncSxInstances*)list_data;
|
||||
return (GUINT_TO_POINTER(GPOINTER_TO_UINT(sx_instances->sx)) == find_data ? 0 : 1);
|
||||
GncSxInstances *sx_instances = (GncSxInstances*)list_data;
|
||||
return (GUINT_TO_POINTER(GPOINTER_TO_UINT(sx_instances->sx)) == find_data ? 0 : 1);
|
||||
}
|
||||
|
||||
// @@ fixme this list is leaked.
|
||||
static GList*
|
||||
gsidca_get_contained(GncDenseCalModel *model)
|
||||
{
|
||||
GncSxInstanceDenseCalAdapter *adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(model);
|
||||
//"removing return gnc_g_list_map(instances->sxes, sx_to_tag, null);
|
||||
GList *list = NULL, *sxes;
|
||||
for (sxes = adapter->instances->sx_instance_list; sxes != NULL; sxes = sxes->next)
|
||||
{
|
||||
GncSxInstances *sx_instances = (GncSxInstances*)sxes->data;
|
||||
if (xaccSchedXactionGetEnabled(sx_instances->sx))
|
||||
{
|
||||
list = g_list_append(list, GUINT_TO_POINTER(GPOINTER_TO_UINT(sx_instances->sx)));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
GncSxInstanceDenseCalAdapter *adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(model);
|
||||
//"removing return gnc_g_list_map(instances->sxes, sx_to_tag, null);
|
||||
GList *list = NULL, *sxes;
|
||||
for (sxes = adapter->instances->sx_instance_list; sxes != NULL; sxes = sxes->next)
|
||||
{
|
||||
GncSxInstances *sx_instances = (GncSxInstances*)sxes->data;
|
||||
if (xaccSchedXactionGetEnabled(sx_instances->sx))
|
||||
{
|
||||
list = g_list_append(list, GUINT_TO_POINTER(GPOINTER_TO_UINT(sx_instances->sx)));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
static gchar*
|
||||
gsidca_get_name(GncDenseCalModel *model, guint tag)
|
||||
{
|
||||
GncSxInstanceDenseCalAdapter *adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(model);
|
||||
GncSxInstances *insts
|
||||
= (GncSxInstances*)g_list_find_custom(adapter->instances->sx_instance_list, GUINT_TO_POINTER(tag), gsidca_find_sx_with_tag)->data;
|
||||
if (insts == NULL)
|
||||
return NULL;
|
||||
return xaccSchedXactionGetName(insts->sx);
|
||||
GncSxInstanceDenseCalAdapter *adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(model);
|
||||
GncSxInstances *insts
|
||||
= (GncSxInstances*)g_list_find_custom(adapter->instances->sx_instance_list, GUINT_TO_POINTER(tag), gsidca_find_sx_with_tag)->data;
|
||||
if (insts == NULL)
|
||||
return NULL;
|
||||
return xaccSchedXactionGetName(insts->sx);
|
||||
}
|
||||
|
||||
static gchar*
|
||||
gsidca_get_info(GncDenseCalModel *model, guint tag)
|
||||
{
|
||||
GncSxInstanceDenseCalAdapter *adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(model);
|
||||
// g_list_find(instances->sxes, {sx_to_tag, tag}).get_freq_spec().get_freq_str();
|
||||
FreqSpec *spec;
|
||||
GString *info;
|
||||
gchar *info_str;
|
||||
GncSxInstances *insts
|
||||
= (GncSxInstances*)g_list_find_custom(adapter->instances->sx_instance_list, GUINT_TO_POINTER(tag), gsidca_find_sx_with_tag)->data;
|
||||
if (insts == NULL)
|
||||
return NULL;
|
||||
spec = xaccSchedXactionGetFreqSpec(insts->sx);
|
||||
info = g_string_sized_new(16);
|
||||
xaccFreqSpecGetFreqStr(spec, info);
|
||||
info_str = info->str; // @fixme leaked... :/
|
||||
g_string_free(info, FALSE);
|
||||
return info_str;
|
||||
GncSxInstanceDenseCalAdapter *adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(model);
|
||||
// g_list_find(instances->sxes, {sx_to_tag, tag}).get_freq_spec().get_freq_str();
|
||||
FreqSpec *spec;
|
||||
GString *info;
|
||||
gchar *info_str;
|
||||
GncSxInstances *insts
|
||||
= (GncSxInstances*)g_list_find_custom(adapter->instances->sx_instance_list, GUINT_TO_POINTER(tag), gsidca_find_sx_with_tag)->data;
|
||||
if (insts == NULL)
|
||||
return NULL;
|
||||
spec = xaccSchedXactionGetFreqSpec(insts->sx);
|
||||
info = g_string_sized_new(16);
|
||||
xaccFreqSpecGetFreqStr(spec, info);
|
||||
info_str = info->str; // @fixme leaked... :/
|
||||
g_string_free(info, FALSE);
|
||||
return info_str;
|
||||
}
|
||||
|
||||
static gint
|
||||
gsidca_get_instance_count(GncDenseCalModel *model, guint tag)
|
||||
{
|
||||
GncSxInstanceDenseCalAdapter *adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(model);
|
||||
// g_list_find(instances->sxes, {sx_to_tag, tag}).length();
|
||||
GncSxInstances *insts
|
||||
= (GncSxInstances*)g_list_find_custom(adapter->instances->sx_instance_list, GUINT_TO_POINTER(tag), gsidca_find_sx_with_tag)->data;
|
||||
if (insts == NULL)
|
||||
return 0;
|
||||
return g_list_length(insts->list);
|
||||
GncSxInstanceDenseCalAdapter *adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(model);
|
||||
// g_list_find(instances->sxes, {sx_to_tag, tag}).length();
|
||||
GncSxInstances *insts
|
||||
= (GncSxInstances*)g_list_find_custom(adapter->instances->sx_instance_list, GUINT_TO_POINTER(tag), gsidca_find_sx_with_tag)->data;
|
||||
if (insts == NULL)
|
||||
return 0;
|
||||
return g_list_length(insts->list);
|
||||
}
|
||||
|
||||
static void
|
||||
gsidca_get_instance(GncDenseCalModel *model, guint tag, gint instance_index, GDate *date)
|
||||
{
|
||||
GncSxInstanceDenseCalAdapter *adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(model);
|
||||
GncSxInstance *inst;
|
||||
GncSxInstances *insts
|
||||
= (GncSxInstances*)g_list_find_custom(adapter->instances->sx_instance_list, GUINT_TO_POINTER(tag), gsidca_find_sx_with_tag)->data;
|
||||
if (insts == NULL)
|
||||
return;
|
||||
inst = (GncSxInstance*)g_list_nth_data(insts->list, instance_index);
|
||||
g_date_valid(&inst->date);
|
||||
*date = inst->date;
|
||||
g_date_valid(date);
|
||||
GncSxInstanceDenseCalAdapter *adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(model);
|
||||
GncSxInstance *inst;
|
||||
GncSxInstances *insts
|
||||
= (GncSxInstances*)g_list_find_custom(adapter->instances->sx_instance_list, GUINT_TO_POINTER(tag), gsidca_find_sx_with_tag)->data;
|
||||
if (insts == NULL)
|
||||
return;
|
||||
inst = (GncSxInstance*)g_list_nth_data(insts->list, instance_index);
|
||||
g_date_valid(&inst->date);
|
||||
*date = inst->date;
|
||||
g_date_valid(date);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_sx_instance_dense_cal_adapter_dispose(GObject *obj)
|
||||
{
|
||||
GncSxInstanceDenseCalAdapter *adapter;
|
||||
g_return_if_fail(obj != NULL);
|
||||
adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(obj);
|
||||
// g_return_if_fail(!adapter->disposed);
|
||||
if (adapter->disposed) return;
|
||||
adapter->disposed = TRUE;
|
||||
GncSxInstanceDenseCalAdapter *adapter;
|
||||
g_return_if_fail(obj != NULL);
|
||||
adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(obj);
|
||||
// g_return_if_fail(!adapter->disposed);
|
||||
if (adapter->disposed) return;
|
||||
adapter->disposed = TRUE;
|
||||
|
||||
g_object_unref(G_OBJECT(adapter->instances));
|
||||
adapter->instances = NULL;
|
||||
g_object_unref(G_OBJECT(adapter->instances));
|
||||
adapter->instances = NULL;
|
||||
|
||||
G_OBJECT_CLASS(parent_class)->dispose(obj);
|
||||
G_OBJECT_CLASS(parent_class)->dispose(obj);
|
||||
}
|
||||
|
||||
static void gnc_sx_instance_dense_cal_adapter_finalize(GObject *obj)
|
||||
{
|
||||
g_return_if_fail(obj != NULL);
|
||||
// nop
|
||||
G_OBJECT_CLASS(parent_class)->finalize(obj);
|
||||
g_return_if_fail(obj != NULL);
|
||||
// nop
|
||||
G_OBJECT_CLASS(parent_class)->finalize(obj);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -47,6 +47,4 @@ GncSxSinceLastRunDialog* gnc_ui_sx_since_last_run_dialog(GncSxInstanceModel *sx
|
||||
// eliminate...
|
||||
void gnc_ui_sxsincelast_dialog_create(void);
|
||||
|
||||
//void gnc_sx_slr_model_effect_change(GncSxSlrTreeModelAdapter *model, gboolean auto_create_only, GList **created_transaction_guids, GList **creation_errors);
|
||||
|
||||
#endif
|
||||
|
@ -67,18 +67,18 @@ static QofLogModule log_module = "gnc.gui.plugin-page";
|
||||
|
||||
typedef struct GncPluginPageSxListPrivate
|
||||
{
|
||||
gboolean disposed;
|
||||
gboolean disposed;
|
||||
|
||||
GtkWidget* widget;
|
||||
gint gnc_component_id;
|
||||
GtkWidget* widget;
|
||||
gint gnc_component_id;
|
||||
|
||||
GladeXML* gxml;
|
||||
GncSxInstanceDenseCalAdapter *dense_cal_model;
|
||||
GncDenseCal* gdcal;
|
||||
GladeXML* gxml;
|
||||
GncSxInstanceDenseCalAdapter *dense_cal_model;
|
||||
GncDenseCal* gdcal;
|
||||
|
||||
GncSxInstanceModel* instances;
|
||||
GncSxListTreeModelAdapter* tree_model;
|
||||
GtkTreeView* tree_view;
|
||||
GncSxInstanceModel* instances;
|
||||
GncSxListTreeModelAdapter* tree_model;
|
||||
GtkTreeView* tree_view;
|
||||
} GncPluginPageSxListPrivate;
|
||||
|
||||
#define GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(o) \
|
||||
@ -110,13 +110,13 @@ static void gnc_plugin_page_sx_list_cmd_delete(GtkAction *action, GncPluginPageS
|
||||
/* Command callbacks */
|
||||
|
||||
static GtkActionEntry gnc_plugin_page_sx_list_actions [] = {
|
||||
{ "SxListAction", NULL, N_("Scheduled"), NULL, NULL, NULL },
|
||||
{ "SxListNewAction", GNC_STOCK_NEW_ACCOUNT, N_("New"), NULL,
|
||||
N_("Create a new scheduled transaction"), G_CALLBACK(gnc_plugin_page_sx_list_cmd_new) },
|
||||
{ "SxListEditAction", GNC_STOCK_EDIT_ACCOUNT, N_("Edit"), NULL,
|
||||
N_("Edit the selected scheduled transaction"), G_CALLBACK(gnc_plugin_page_sx_list_cmd_edit) },
|
||||
{ "SxListDeleteAction", GNC_STOCK_DELETE_ACCOUNT, N_("Delete"), NULL,
|
||||
N_("Delete the selected scheduled transaction"), G_CALLBACK(gnc_plugin_page_sx_list_cmd_delete) },
|
||||
{ "SxListAction", NULL, N_("Scheduled"), NULL, NULL, NULL },
|
||||
{ "SxListNewAction", GNC_STOCK_NEW_ACCOUNT, N_("New"), NULL,
|
||||
N_("Create a new scheduled transaction"), G_CALLBACK(gnc_plugin_page_sx_list_cmd_new) },
|
||||
{ "SxListEditAction", GNC_STOCK_EDIT_ACCOUNT, N_("Edit"), NULL,
|
||||
N_("Edit the selected scheduled transaction"), G_CALLBACK(gnc_plugin_page_sx_list_cmd_edit) },
|
||||
{ "SxListDeleteAction", GNC_STOCK_DELETE_ACCOUNT, N_("Delete"), NULL,
|
||||
N_("Delete the selected scheduled transaction"), G_CALLBACK(gnc_plugin_page_sx_list_cmd_delete) },
|
||||
};
|
||||
/** The number of actions provided by this plugin. */
|
||||
static guint gnc_plugin_page_sx_list_n_actions = G_N_ELEMENTS (gnc_plugin_page_sx_list_actions);
|
||||
@ -124,302 +124,302 @@ static guint gnc_plugin_page_sx_list_n_actions = G_N_ELEMENTS (gnc_plugin_page_s
|
||||
GType
|
||||
gnc_plugin_page_sx_list_get_type (void)
|
||||
{
|
||||
static GType gnc_plugin_page_sx_list_type = 0;
|
||||
static GType gnc_plugin_page_sx_list_type = 0;
|
||||
|
||||
if (gnc_plugin_page_sx_list_type == 0) {
|
||||
static const GTypeInfo our_info = {
|
||||
sizeof (GncPluginPageSxListClass),
|
||||
NULL,
|
||||
NULL,
|
||||
(GClassInitFunc) gnc_plugin_page_sx_list_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof (GncPluginPageSxList),
|
||||
0,
|
||||
(GInstanceInitFunc) gnc_plugin_page_sx_list_init
|
||||
};
|
||||
if (gnc_plugin_page_sx_list_type == 0) {
|
||||
static const GTypeInfo our_info = {
|
||||
sizeof (GncPluginPageSxListClass),
|
||||
NULL,
|
||||
NULL,
|
||||
(GClassInitFunc) gnc_plugin_page_sx_list_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof (GncPluginPageSxList),
|
||||
0,
|
||||
(GInstanceInitFunc) gnc_plugin_page_sx_list_init
|
||||
};
|
||||
|
||||
gnc_plugin_page_sx_list_type = g_type_register_static (GNC_TYPE_PLUGIN_PAGE,
|
||||
GNC_PLUGIN_PAGE_SX_LIST_NAME,
|
||||
&our_info, 0);
|
||||
}
|
||||
gnc_plugin_page_sx_list_type = g_type_register_static (GNC_TYPE_PLUGIN_PAGE,
|
||||
GNC_PLUGIN_PAGE_SX_LIST_NAME,
|
||||
&our_info, 0);
|
||||
}
|
||||
|
||||
return gnc_plugin_page_sx_list_type;
|
||||
return gnc_plugin_page_sx_list_type;
|
||||
}
|
||||
|
||||
GncPluginPage *
|
||||
gnc_plugin_page_sx_list_new (void)
|
||||
{
|
||||
GncPluginPageSxList *plugin_page;
|
||||
plugin_page = g_object_new(GNC_TYPE_PLUGIN_PAGE_SX_LIST, NULL);
|
||||
return GNC_PLUGIN_PAGE(plugin_page);
|
||||
GncPluginPageSxList *plugin_page;
|
||||
plugin_page = g_object_new(GNC_TYPE_PLUGIN_PAGE_SX_LIST, NULL);
|
||||
return GNC_PLUGIN_PAGE(plugin_page);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_plugin_page_sx_list_class_init (GncPluginPageSxListClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
||||
GncPluginPageClass *gnc_plugin_class = GNC_PLUGIN_PAGE_CLASS(klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
||||
GncPluginPageClass *gnc_plugin_class = GNC_PLUGIN_PAGE_CLASS(klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent(klass);
|
||||
parent_class = g_type_class_peek_parent(klass);
|
||||
|
||||
object_class->dispose = gnc_plugin_page_sx_list_dispose;
|
||||
object_class->finalize = gnc_plugin_page_sx_list_finalize;
|
||||
object_class->dispose = gnc_plugin_page_sx_list_dispose;
|
||||
object_class->finalize = gnc_plugin_page_sx_list_finalize;
|
||||
|
||||
gnc_plugin_class->tab_icon = GNC_STOCK_ACCOUNT;
|
||||
gnc_plugin_class->plugin_name = GNC_PLUGIN_PAGE_SX_LIST_NAME;
|
||||
gnc_plugin_class->create_widget = gnc_plugin_page_sx_list_create_widget;
|
||||
gnc_plugin_class->destroy_widget = gnc_plugin_page_sx_list_destroy_widget;
|
||||
gnc_plugin_class->save_page = gnc_plugin_page_sx_list_save_page;
|
||||
gnc_plugin_class->recreate_page = gnc_plugin_page_sx_list_recreate_page;
|
||||
gnc_plugin_class->tab_icon = GNC_STOCK_ACCOUNT;
|
||||
gnc_plugin_class->plugin_name = GNC_PLUGIN_PAGE_SX_LIST_NAME;
|
||||
gnc_plugin_class->create_widget = gnc_plugin_page_sx_list_create_widget;
|
||||
gnc_plugin_class->destroy_widget = gnc_plugin_page_sx_list_destroy_widget;
|
||||
gnc_plugin_class->save_page = gnc_plugin_page_sx_list_save_page;
|
||||
gnc_plugin_class->recreate_page = gnc_plugin_page_sx_list_recreate_page;
|
||||
|
||||
g_type_class_add_private(klass, sizeof(GncPluginPageSxListPrivate));
|
||||
g_type_class_add_private(klass, sizeof(GncPluginPageSxListPrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_plugin_page_sx_list_init (GncPluginPageSxList *plugin_page)
|
||||
{
|
||||
GtkActionGroup *action_group;
|
||||
GncPluginPageSxListPrivate *priv;
|
||||
GncPluginPage *parent;
|
||||
GtkActionGroup *action_group;
|
||||
GncPluginPageSxListPrivate *priv;
|
||||
GncPluginPage *parent;
|
||||
|
||||
priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(plugin_page);
|
||||
priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(plugin_page);
|
||||
|
||||
/* Init parent declared variables */
|
||||
parent = GNC_PLUGIN_PAGE(plugin_page);
|
||||
g_object_set(G_OBJECT(plugin_page),
|
||||
"page-name", _("Scheduled Transactions"),
|
||||
"page-uri", "default:",
|
||||
"ui-description", "gnc-plugin-page-sx-list-ui.xml",
|
||||
NULL);
|
||||
/* Init parent declared variables */
|
||||
parent = GNC_PLUGIN_PAGE(plugin_page);
|
||||
g_object_set(G_OBJECT(plugin_page),
|
||||
"page-name", _("Scheduled Transactions"),
|
||||
"page-uri", "default:",
|
||||
"ui-description", "gnc-plugin-page-sx-list-ui.xml",
|
||||
NULL);
|
||||
|
||||
/* change me when the system supports multiple books */
|
||||
gnc_plugin_page_add_book(parent, gnc_get_current_book());
|
||||
/* change me when the system supports multiple books */
|
||||
gnc_plugin_page_add_book(parent, gnc_get_current_book());
|
||||
|
||||
/* Create menu and toolbar information */
|
||||
action_group =
|
||||
gnc_plugin_page_create_action_group(parent,
|
||||
"GncPluginPageSxListActions");
|
||||
gtk_action_group_add_actions(action_group,
|
||||
gnc_plugin_page_sx_list_actions,
|
||||
gnc_plugin_page_sx_list_n_actions,
|
||||
plugin_page);
|
||||
/* gnc_plugin_init_short_names (action_group, toolbar_labels); */
|
||||
/* Create menu and toolbar information */
|
||||
action_group =
|
||||
gnc_plugin_page_create_action_group(parent,
|
||||
"GncPluginPageSxListActions");
|
||||
gtk_action_group_add_actions(action_group,
|
||||
gnc_plugin_page_sx_list_actions,
|
||||
gnc_plugin_page_sx_list_n_actions,
|
||||
plugin_page);
|
||||
/* gnc_plugin_init_short_names (action_group, toolbar_labels); */
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_plugin_page_sx_list_dispose(GObject *object)
|
||||
{
|
||||
GncPluginPageSxList *page;
|
||||
GncPluginPageSxListPrivate *priv;
|
||||
GncPluginPageSxList *page;
|
||||
GncPluginPageSxListPrivate *priv;
|
||||
|
||||
page = GNC_PLUGIN_PAGE_SX_LIST (object);
|
||||
g_return_if_fail(GNC_IS_PLUGIN_PAGE_SX_LIST (page));
|
||||
priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
|
||||
g_return_if_fail(priv != NULL);
|
||||
page = GNC_PLUGIN_PAGE_SX_LIST (object);
|
||||
g_return_if_fail(GNC_IS_PLUGIN_PAGE_SX_LIST (page));
|
||||
priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
|
||||
g_return_if_fail(priv != NULL);
|
||||
|
||||
g_return_if_fail(!priv->disposed);
|
||||
priv->disposed = TRUE;
|
||||
g_return_if_fail(!priv->disposed);
|
||||
priv->disposed = TRUE;
|
||||
|
||||
g_object_unref(G_OBJECT(priv->dense_cal_model));
|
||||
priv->dense_cal_model = NULL;
|
||||
gtk_widget_unref(GTK_WIDGET(priv->gdcal));
|
||||
priv->gdcal = NULL;
|
||||
g_object_unref(G_OBJECT(priv->tree_model));
|
||||
priv->tree_model = NULL;
|
||||
g_object_unref(G_OBJECT(priv->instances));
|
||||
priv->instances = NULL;
|
||||
g_object_unref(G_OBJECT(priv->dense_cal_model));
|
||||
priv->dense_cal_model = NULL;
|
||||
gtk_widget_unref(GTK_WIDGET(priv->gdcal));
|
||||
priv->gdcal = NULL;
|
||||
g_object_unref(G_OBJECT(priv->tree_model));
|
||||
priv->tree_model = NULL;
|
||||
g_object_unref(G_OBJECT(priv->instances));
|
||||
priv->instances = NULL;
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose(object);
|
||||
G_OBJECT_CLASS (parent_class)->dispose(object);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_plugin_page_sx_list_finalize (GObject *object)
|
||||
{
|
||||
GncPluginPageSxList *page;
|
||||
GncPluginPageSxListPrivate *priv;
|
||||
GncPluginPageSxList *page;
|
||||
GncPluginPageSxListPrivate *priv;
|
||||
|
||||
page = GNC_PLUGIN_PAGE_SX_LIST (object);
|
||||
g_return_if_fail(GNC_IS_PLUGIN_PAGE_SX_LIST (page));
|
||||
priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
|
||||
g_return_if_fail(priv != NULL);
|
||||
page = GNC_PLUGIN_PAGE_SX_LIST (object);
|
||||
g_return_if_fail(GNC_IS_PLUGIN_PAGE_SX_LIST (page));
|
||||
priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
|
||||
g_return_if_fail(priv != NULL);
|
||||
|
||||
// by virtue of being a g_type_instance_..._private, does the private
|
||||
// data get freed somewhere else?
|
||||
// by virtue of being a g_type_instance_..._private, does the private
|
||||
// data get freed somewhere else?
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
/* Virtual Functions */
|
||||
static void
|
||||
gnc_plugin_page_sx_list_refresh_cb (GHashTable *changes, gpointer user_data)
|
||||
{
|
||||
GncPluginPageSxList *page = user_data;
|
||||
GncPluginPageSxListPrivate *priv;
|
||||
GncPluginPageSxList *page = user_data;
|
||||
GncPluginPageSxListPrivate *priv;
|
||||
|
||||
g_return_if_fail(GNC_IS_PLUGIN_PAGE_SX_LIST(page));
|
||||
g_return_if_fail(GNC_IS_PLUGIN_PAGE_SX_LIST(page));
|
||||
|
||||
/* We're only looking for forced updates here. */
|
||||
if (changes)
|
||||
return;
|
||||
/* We're only looking for forced updates here. */
|
||||
if (changes)
|
||||
return;
|
||||
|
||||
priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
|
||||
gtk_widget_queue_draw(priv->widget);
|
||||
priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
|
||||
gtk_widget_queue_draw(priv->widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_plugin_page_sx_list_close_cb (gpointer user_data)
|
||||
{
|
||||
GncPluginPage *plugin_page;
|
||||
GncPluginPageSxList *page;
|
||||
GncPluginPage *plugin_page;
|
||||
GncPluginPageSxList *page;
|
||||
|
||||
plugin_page = GNC_PLUGIN_PAGE(user_data);
|
||||
page = GNC_PLUGIN_PAGE_SX_LIST (plugin_page);
|
||||
gnc_main_window_close_page(plugin_page);
|
||||
plugin_page = GNC_PLUGIN_PAGE(user_data);
|
||||
page = GNC_PLUGIN_PAGE_SX_LIST (plugin_page);
|
||||
gnc_main_window_close_page(plugin_page);
|
||||
}
|
||||
|
||||
static void
|
||||
gppsl_selection_changed_cb(GtkTreeSelection *selection, gpointer user_data)
|
||||
{
|
||||
GncPluginPage *page;
|
||||
GtkAction *edit_action, *delete_action;
|
||||
gboolean selection_state = TRUE;
|
||||
GncPluginPage *page;
|
||||
GtkAction *edit_action, *delete_action;
|
||||
gboolean selection_state = TRUE;
|
||||
|
||||
page = GNC_PLUGIN_PAGE(user_data);
|
||||
edit_action = gnc_plugin_page_get_action(page, "SxListEditAction");
|
||||
delete_action = gnc_plugin_page_get_action(page, "SxListDeleteAction");
|
||||
selection_state
|
||||
= gtk_tree_selection_count_selected_rows(selection) == 0
|
||||
? FALSE
|
||||
: TRUE;
|
||||
gtk_action_set_sensitive(edit_action, selection_state);
|
||||
gtk_action_set_sensitive(delete_action, selection_state);
|
||||
page = GNC_PLUGIN_PAGE(user_data);
|
||||
edit_action = gnc_plugin_page_get_action(page, "SxListEditAction");
|
||||
delete_action = gnc_plugin_page_get_action(page, "SxListDeleteAction");
|
||||
selection_state
|
||||
= gtk_tree_selection_count_selected_rows(selection) == 0
|
||||
? FALSE
|
||||
: TRUE;
|
||||
gtk_action_set_sensitive(edit_action, selection_state);
|
||||
gtk_action_set_sensitive(delete_action, selection_state);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gnc_plugin_page_sx_list_create_widget (GncPluginPage *plugin_page)
|
||||
{
|
||||
GncPluginPageSxList *page;
|
||||
GncPluginPageSxListPrivate *priv;
|
||||
GncPluginPageSxList *page;
|
||||
GncPluginPageSxListPrivate *priv;
|
||||
|
||||
page = GNC_PLUGIN_PAGE_SX_LIST(plugin_page);
|
||||
priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
|
||||
if (priv->widget != NULL)
|
||||
return priv->widget;
|
||||
page = GNC_PLUGIN_PAGE_SX_LIST(plugin_page);
|
||||
priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
|
||||
if (priv->widget != NULL)
|
||||
return priv->widget;
|
||||
|
||||
priv->gxml = gnc_glade_xml_new("sched-xact.glade", "sx-list-vbox");
|
||||
priv->widget = glade_xml_get_widget(priv->gxml, "sx-list-vbox");
|
||||
priv->gxml = gnc_glade_xml_new("sched-xact.glade", "sx-list-vbox");
|
||||
priv->widget = glade_xml_get_widget(priv->gxml, "sx-list-vbox");
|
||||
|
||||
{
|
||||
//gint half_way;
|
||||
// half_way = plugin_page->notebook_page->allocation.height * 0.5;
|
||||
// fixme; get a real value:
|
||||
gtk_paned_set_position(GTK_PANED(priv->widget), 160);
|
||||
}
|
||||
{
|
||||
//gint half_way;
|
||||
// half_way = plugin_page->notebook_page->allocation.height * 0.5;
|
||||
// fixme; get a real value:
|
||||
gtk_paned_set_position(GTK_PANED(priv->widget), 160);
|
||||
}
|
||||
|
||||
{
|
||||
GDate end;
|
||||
g_date_clear(&end, 1);
|
||||
g_date_set_time_t(&end, time(NULL));
|
||||
g_date_add_years(&end, 1);
|
||||
priv->instances = GNC_SX_INSTANCE_MODEL(gnc_sx_get_instances(&end, TRUE));
|
||||
}
|
||||
{
|
||||
GDate end;
|
||||
g_date_clear(&end, 1);
|
||||
g_date_set_time_t(&end, time(NULL));
|
||||
g_date_add_years(&end, 1);
|
||||
priv->instances = GNC_SX_INSTANCE_MODEL(gnc_sx_get_instances(&end, TRUE));
|
||||
}
|
||||
|
||||
{
|
||||
GtkAction *edit_action, *delete_action;
|
||||
edit_action = gnc_plugin_page_get_action(GNC_PLUGIN_PAGE(page), "SxListEditAction");
|
||||
delete_action = gnc_plugin_page_get_action(GNC_PLUGIN_PAGE(page), "SxListDeleteAction");
|
||||
gtk_action_set_sensitive(edit_action, FALSE);
|
||||
gtk_action_set_sensitive(delete_action, FALSE);
|
||||
}
|
||||
{
|
||||
GtkAction *edit_action, *delete_action;
|
||||
edit_action = gnc_plugin_page_get_action(GNC_PLUGIN_PAGE(page), "SxListEditAction");
|
||||
delete_action = gnc_plugin_page_get_action(GNC_PLUGIN_PAGE(page), "SxListDeleteAction");
|
||||
gtk_action_set_sensitive(edit_action, FALSE);
|
||||
gtk_action_set_sensitive(delete_action, FALSE);
|
||||
}
|
||||
|
||||
{
|
||||
GtkCellRenderer *renderer;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkTreeSelection *selection;
|
||||
{
|
||||
GtkCellRenderer *renderer;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkTreeSelection *selection;
|
||||
|
||||
priv->tree_model = gnc_sx_list_tree_model_adapter_new(priv->instances);
|
||||
priv->tree_view = GTK_TREE_VIEW(glade_xml_get_widget(priv->gxml, "sx_list"));
|
||||
gtk_tree_view_set_model(priv->tree_view, GTK_TREE_MODEL(priv->tree_model));
|
||||
priv->tree_model = gnc_sx_list_tree_model_adapter_new(priv->instances);
|
||||
priv->tree_view = GTK_TREE_VIEW(glade_xml_get_widget(priv->gxml, "sx_list"));
|
||||
gtk_tree_view_set_model(priv->tree_view, GTK_TREE_MODEL(priv->tree_model));
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes("Name", renderer, "text", SXLTMA_COL_NAME, NULL);
|
||||
gtk_tree_view_column_set_sort_column_id(column, SXLTMA_COL_NAME);
|
||||
gtk_tree_view_append_column(priv->tree_view, column);
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes("Name", renderer, "text", SXLTMA_COL_NAME, NULL);
|
||||
gtk_tree_view_column_set_sort_column_id(column, SXLTMA_COL_NAME);
|
||||
gtk_tree_view_append_column(priv->tree_view, column);
|
||||
|
||||
renderer = gtk_cell_renderer_toggle_new();
|
||||
column = gtk_tree_view_column_new_with_attributes("Enabled", renderer, "active", SXLTMA_COL_ENABLED, NULL);
|
||||
gtk_tree_view_column_set_sort_column_id(column, SXLTMA_COL_ENABLED);
|
||||
gtk_tree_view_append_column(priv->tree_view, column);
|
||||
renderer = gtk_cell_renderer_toggle_new();
|
||||
column = gtk_tree_view_column_new_with_attributes("Enabled", renderer, "active", SXLTMA_COL_ENABLED, NULL);
|
||||
gtk_tree_view_column_set_sort_column_id(column, SXLTMA_COL_ENABLED);
|
||||
gtk_tree_view_append_column(priv->tree_view, column);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes("Frequency", renderer, "text", SXLTMA_COL_FREQUENCY, NULL);
|
||||
gtk_tree_view_column_set_sort_column_id(column, SXLTMA_COL_FREQUENCY);
|
||||
gtk_tree_view_append_column(priv->tree_view, column);
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes("Frequency", renderer, "text", SXLTMA_COL_FREQUENCY, NULL);
|
||||
gtk_tree_view_column_set_sort_column_id(column, SXLTMA_COL_FREQUENCY);
|
||||
gtk_tree_view_append_column(priv->tree_view, column);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes("Last Occur", renderer, "text", SXLTMA_COL_LAST_OCCUR, NULL);
|
||||
gtk_tree_view_column_set_sort_column_id(column, SXLTMA_COL_LAST_OCCUR);
|
||||
gtk_tree_view_append_column(priv->tree_view, column);
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes("Last Occur", renderer, "text", SXLTMA_COL_LAST_OCCUR, NULL);
|
||||
gtk_tree_view_column_set_sort_column_id(column, SXLTMA_COL_LAST_OCCUR);
|
||||
gtk_tree_view_append_column(priv->tree_view, column);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes("Next Occur", renderer, "text", SXLTMA_COL_NEXT_OCCUR, NULL);
|
||||
gtk_tree_view_column_set_sort_column_id(column, SXLTMA_COL_NEXT_OCCUR);
|
||||
gtk_tree_view_append_column(priv->tree_view, column);
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes("Next Occur", renderer, "text", SXLTMA_COL_NEXT_OCCUR, NULL);
|
||||
gtk_tree_view_column_set_sort_column_id(column, SXLTMA_COL_NEXT_OCCUR);
|
||||
gtk_tree_view_append_column(priv->tree_view, column);
|
||||
|
||||
selection = gtk_tree_view_get_selection(priv->tree_view);
|
||||
gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
|
||||
g_signal_connect(G_OBJECT(selection), "changed", (GCallback)gppsl_selection_changed_cb, (gpointer)page);
|
||||
selection = gtk_tree_view_get_selection(priv->tree_view);
|
||||
gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
|
||||
g_signal_connect(G_OBJECT(selection), "changed", (GCallback)gppsl_selection_changed_cb, (gpointer)page);
|
||||
|
||||
g_signal_connect(G_OBJECT(priv->tree_view), "row-activated", (GCallback)gppsl_row_activated_cb, (gpointer)page);
|
||||
}
|
||||
g_signal_connect(G_OBJECT(priv->tree_view), "row-activated", (GCallback)gppsl_row_activated_cb, (gpointer)page);
|
||||
}
|
||||
|
||||
{
|
||||
GtkWidget *w;
|
||||
{
|
||||
GtkWidget *w;
|
||||
|
||||
priv->dense_cal_model = gnc_sx_instance_dense_cal_adapter_new(GNC_SX_INSTANCE_MODEL(priv->instances));
|
||||
priv->gdcal = GNC_DENSE_CAL(gnc_dense_cal_new_with_model(GNC_DENSE_CAL_MODEL(priv->dense_cal_model)));
|
||||
// gobject-2.10: g_object_ref_sink(G_OBJECT(priv->gdcal));
|
||||
g_object_ref(G_OBJECT(priv->gdcal));
|
||||
gtk_object_sink(GTK_OBJECT(priv->gdcal));
|
||||
priv->dense_cal_model = gnc_sx_instance_dense_cal_adapter_new(GNC_SX_INSTANCE_MODEL(priv->instances));
|
||||
priv->gdcal = GNC_DENSE_CAL(gnc_dense_cal_new_with_model(GNC_DENSE_CAL_MODEL(priv->dense_cal_model)));
|
||||
// gobject-2.10: g_object_ref_sink(G_OBJECT(priv->gdcal));
|
||||
g_object_ref(G_OBJECT(priv->gdcal));
|
||||
gtk_object_sink(GTK_OBJECT(priv->gdcal));
|
||||
|
||||
gnc_dense_cal_set_months_per_col(priv->gdcal, 4);
|
||||
gnc_dense_cal_set_num_months(priv->gdcal, 12);
|
||||
gnc_dense_cal_set_months_per_col(priv->gdcal, 4);
|
||||
gnc_dense_cal_set_num_months(priv->gdcal, 12);
|
||||
|
||||
w = glade_xml_get_widget(priv->gxml, "upcoming_cal_hbox");
|
||||
gtk_container_add(GTK_CONTAINER(w), GTK_WIDGET(priv->gdcal));
|
||||
gtk_widget_show_all(w);
|
||||
}
|
||||
w = glade_xml_get_widget(priv->gxml, "upcoming_cal_hbox");
|
||||
gtk_container_add(GTK_CONTAINER(w), GTK_WIDGET(priv->gdcal));
|
||||
gtk_widget_show_all(w);
|
||||
}
|
||||
|
||||
priv->gnc_component_id = gnc_register_gui_component("plugin-page-sx-list",
|
||||
gnc_plugin_page_sx_list_refresh_cb,
|
||||
gnc_plugin_page_sx_list_close_cb,
|
||||
page);
|
||||
priv->gnc_component_id = gnc_register_gui_component("plugin-page-sx-list",
|
||||
gnc_plugin_page_sx_list_refresh_cb,
|
||||
gnc_plugin_page_sx_list_close_cb,
|
||||
page);
|
||||
|
||||
/* @@fixme */
|
||||
/* gnc_restore_window_size(SX_LIST_GCONF_SECTION, GTK_WINDOW(priv->widget)); */
|
||||
/* @@fixme */
|
||||
/* gnc_restore_window_size(SX_LIST_GCONF_SECTION, GTK_WINDOW(priv->widget)); */
|
||||
|
||||
return priv->widget;
|
||||
return priv->widget;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_plugin_page_sx_list_destroy_widget (GncPluginPage *plugin_page)
|
||||
{
|
||||
GncPluginPageSxList *page;
|
||||
GncPluginPageSxListPrivate *priv;
|
||||
GncPluginPageSxList *page;
|
||||
GncPluginPageSxListPrivate *priv;
|
||||
|
||||
page = GNC_PLUGIN_PAGE_SX_LIST (plugin_page);
|
||||
priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
|
||||
page = GNC_PLUGIN_PAGE_SX_LIST (plugin_page);
|
||||
priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
|
||||
|
||||
if (priv->widget) {
|
||||
g_object_unref(G_OBJECT(priv->widget));
|
||||
priv->widget = NULL;
|
||||
}
|
||||
if (priv->widget) {
|
||||
g_object_unref(G_OBJECT(priv->widget));
|
||||
priv->widget = NULL;
|
||||
}
|
||||
|
||||
if (priv->gnc_component_id) {
|
||||
gnc_unregister_gui_component(priv->gnc_component_id);
|
||||
priv->gnc_component_id = 0;
|
||||
}
|
||||
if (priv->gnc_component_id) {
|
||||
gnc_unregister_gui_component(priv->gnc_component_id);
|
||||
priv->gnc_component_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -435,19 +435,19 @@ gnc_plugin_page_sx_list_save_page (GncPluginPage *plugin_page,
|
||||
GKeyFile *key_file,
|
||||
const gchar *group_name)
|
||||
{
|
||||
GncPluginPageSxList *page;
|
||||
GncPluginPageSxListPrivate *priv;
|
||||
GncPluginPageSxList *page;
|
||||
GncPluginPageSxListPrivate *priv;
|
||||
|
||||
g_return_if_fail(GNC_IS_PLUGIN_PAGE_SX_LIST(plugin_page));
|
||||
g_return_if_fail(key_file != NULL);
|
||||
g_return_if_fail(group_name != NULL);
|
||||
g_return_if_fail(GNC_IS_PLUGIN_PAGE_SX_LIST(plugin_page));
|
||||
g_return_if_fail(key_file != NULL);
|
||||
g_return_if_fail(group_name != NULL);
|
||||
|
||||
page = GNC_PLUGIN_PAGE_SX_LIST(plugin_page);
|
||||
priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
|
||||
page = GNC_PLUGIN_PAGE_SX_LIST(plugin_page);
|
||||
priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
|
||||
|
||||
#if 0
|
||||
gnc_tree_view_account_save(GNC_TREE_VIEW_ACCOUNT(priv->tree_view),
|
||||
&priv->fd, key_file, group_name);
|
||||
gnc_tree_view_account_save(GNC_TREE_VIEW_ACCOUNT(priv->tree_view),
|
||||
&priv->fd, key_file, group_name);
|
||||
#endif /* 0 */
|
||||
}
|
||||
|
||||
@ -464,24 +464,24 @@ gnc_plugin_page_sx_list_recreate_page (GtkWidget *window,
|
||||
GKeyFile *key_file,
|
||||
const gchar *group_name)
|
||||
{
|
||||
GncPluginPageSxList *page;
|
||||
GncPluginPageSxListPrivate *priv;
|
||||
GncPluginPageSxList *page;
|
||||
GncPluginPageSxListPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(key_file, NULL);
|
||||
g_return_val_if_fail(group_name, NULL);
|
||||
g_return_val_if_fail(key_file, NULL);
|
||||
g_return_val_if_fail(group_name, NULL);
|
||||
|
||||
/* Create the new page. */
|
||||
page = GNC_PLUGIN_PAGE_SX_LIST(gnc_plugin_page_sx_list_new());
|
||||
priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
|
||||
/* Create the new page. */
|
||||
page = GNC_PLUGIN_PAGE_SX_LIST(gnc_plugin_page_sx_list_new());
|
||||
priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
|
||||
|
||||
/* Install it now so we can them manipulate the created widget */
|
||||
gnc_main_window_open_page(GNC_MAIN_WINDOW(window), GNC_PLUGIN_PAGE(page));
|
||||
/* Install it now so we can them manipulate the created widget */
|
||||
gnc_main_window_open_page(GNC_MAIN_WINDOW(window), GNC_PLUGIN_PAGE(page));
|
||||
|
||||
#if 0
|
||||
gnc_tree_view_account_restore(GNC_TREE_VIEW_ACCOUNT(priv->tree_view),
|
||||
&priv->fd, key_file, group_name);
|
||||
gnc_tree_view_account_restore(GNC_TREE_VIEW_ACCOUNT(priv->tree_view),
|
||||
&priv->fd, key_file, group_name);
|
||||
#endif /* 0 */
|
||||
return GNC_PLUGIN_PAGE(page);
|
||||
return GNC_PLUGIN_PAGE(page);
|
||||
}
|
||||
|
||||
|
||||
@ -490,60 +490,60 @@ gnc_plugin_page_sx_list_recreate_page (GtkWidget *window,
|
||||
static SchedXaction*
|
||||
_sx_for_path(gpointer data, gpointer user_data)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GncSxListTreeModelAdapter *model = GNC_SX_LIST_TREE_MODEL_ADAPTER(user_data);
|
||||
gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, (GtkTreePath*)data);
|
||||
return gnc_sx_list_tree_model_adapter_get_sx_instances(model, &iter)->sx;
|
||||
GtkTreeIter iter;
|
||||
GncSxListTreeModelAdapter *model = GNC_SX_LIST_TREE_MODEL_ADAPTER(user_data);
|
||||
gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, (GtkTreePath*)data);
|
||||
return gnc_sx_list_tree_model_adapter_get_sx_instances(model, &iter)->sx;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_plugin_page_sx_list_cmd_new(GtkAction *action, GncPluginPageSxList *page)
|
||||
{
|
||||
FreqSpec *fs;
|
||||
SchedXaction *new_sx;
|
||||
gboolean new_sx_flag = TRUE;
|
||||
FreqSpec *fs;
|
||||
SchedXaction *new_sx;
|
||||
gboolean new_sx_flag = TRUE;
|
||||
|
||||
new_sx = xaccSchedXactionMalloc(gnc_get_current_book());
|
||||
/* Give decent initial FreqSpec for SX */
|
||||
fs = xaccSchedXactionGetFreqSpec(new_sx);
|
||||
{
|
||||
GDate *now;
|
||||
now = g_date_new();
|
||||
g_date_set_time_t(now, time(NULL));
|
||||
xaccFreqSpecSetMonthly(fs, now, 1);
|
||||
xaccFreqSpecSetUIType(fs, UIFREQ_MONTHLY);
|
||||
g_date_free(now);
|
||||
}
|
||||
gnc_ui_scheduled_xaction_editor_dialog_create(new_sx, new_sx_flag);
|
||||
new_sx = xaccSchedXactionMalloc(gnc_get_current_book());
|
||||
/* Give decent initial FreqSpec for SX */
|
||||
fs = xaccSchedXactionGetFreqSpec(new_sx);
|
||||
{
|
||||
GDate *now;
|
||||
now = g_date_new();
|
||||
g_date_set_time_t(now, time(NULL));
|
||||
xaccFreqSpecSetMonthly(fs, now, 1);
|
||||
xaccFreqSpecSetUIType(fs, UIFREQ_MONTHLY);
|
||||
g_date_free(now);
|
||||
}
|
||||
gnc_ui_scheduled_xaction_editor_dialog_create(new_sx, new_sx_flag);
|
||||
}
|
||||
|
||||
static void
|
||||
_edit_sx(gpointer data, gpointer user_data)
|
||||
{
|
||||
gnc_ui_scheduled_xaction_editor_dialog_create((SchedXaction*)data, FALSE);
|
||||
gnc_ui_scheduled_xaction_editor_dialog_create((SchedXaction*)data, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_plugin_page_sx_list_cmd_edit(GtkAction *action, GncPluginPageSxList *page)
|
||||
{
|
||||
GncPluginPageSxListPrivate *priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
|
||||
GtkTreeSelection *selection;
|
||||
GList *selected_paths, *to_edit;
|
||||
GtkTreeModel *model;
|
||||
GncPluginPageSxListPrivate *priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
|
||||
GtkTreeSelection *selection;
|
||||
GList *selected_paths, *to_edit;
|
||||
GtkTreeModel *model;
|
||||
|
||||
selection = gtk_tree_view_get_selection(priv->tree_view);
|
||||
selected_paths = gtk_tree_selection_get_selected_rows(selection, &model);
|
||||
if (g_list_length(selected_paths) == 0)
|
||||
{
|
||||
g_warning("no selection edit.");
|
||||
return;
|
||||
}
|
||||
selection = gtk_tree_view_get_selection(priv->tree_view);
|
||||
selected_paths = gtk_tree_selection_get_selected_rows(selection, &model);
|
||||
if (g_list_length(selected_paths) == 0)
|
||||
{
|
||||
g_warning("no selection edit.");
|
||||
return;
|
||||
}
|
||||
|
||||
to_edit = gnc_g_list_map(selected_paths, (GncGMapFunc)_sx_for_path, model);
|
||||
g_list_foreach(to_edit, (GFunc)_edit_sx, NULL);
|
||||
g_list_free(to_edit);
|
||||
g_list_foreach(selected_paths, (GFunc)gtk_tree_path_free, NULL);
|
||||
g_list_free(selected_paths);
|
||||
to_edit = gnc_g_list_map(selected_paths, (GncGMapFunc)_sx_for_path, model);
|
||||
g_list_foreach(to_edit, (GFunc)_edit_sx, NULL);
|
||||
g_list_free(to_edit);
|
||||
g_list_foreach(selected_paths, (GFunc)gtk_tree_path_free, NULL);
|
||||
g_list_free(selected_paths);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -552,55 +552,55 @@ gppsl_row_activated_cb(GtkTreeView *tree_view,
|
||||
GtkTreeViewColumn *column,
|
||||
gpointer user_data)
|
||||
{
|
||||
GncPluginPageSxList *page = GNC_PLUGIN_PAGE_SX_LIST(user_data);
|
||||
GncPluginPageSxListPrivate *priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
|
||||
SchedXaction *sx = _sx_for_path(path, priv->tree_model);
|
||||
gnc_ui_scheduled_xaction_editor_dialog_create(sx, FALSE);
|
||||
GncPluginPageSxList *page = GNC_PLUGIN_PAGE_SX_LIST(user_data);
|
||||
GncPluginPageSxListPrivate *priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
|
||||
SchedXaction *sx = _sx_for_path(path, priv->tree_model);
|
||||
gnc_ui_scheduled_xaction_editor_dialog_create(sx, FALSE);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_destroy_sx(gpointer data, gpointer user_data)
|
||||
{
|
||||
SchedXactions *sxes;
|
||||
SchedXaction *sx = (SchedXaction*)data;
|
||||
GNCBook *book;
|
||||
book = gnc_get_current_book();
|
||||
sxes = gnc_book_get_schedxactions(book);
|
||||
gnc_sxes_del_sx(sxes, sx);
|
||||
xaccSchedXactionFree(sx);
|
||||
SchedXactions *sxes;
|
||||
SchedXaction *sx = (SchedXaction*)data;
|
||||
GNCBook *book;
|
||||
book = gnc_get_current_book();
|
||||
sxes = gnc_book_get_schedxactions(book);
|
||||
gnc_sxes_del_sx(sxes, sx);
|
||||
xaccSchedXactionFree(sx);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_plugin_page_sx_list_cmd_delete(GtkAction *action, GncPluginPageSxList *page)
|
||||
{
|
||||
GncPluginPageSxListPrivate *priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
|
||||
GtkTreeSelection *selection;
|
||||
GList *selected_paths, *to_delete = NULL;
|
||||
GtkTreeModel *model;
|
||||
GncPluginPageSxListPrivate *priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
|
||||
GtkTreeSelection *selection;
|
||||
GList *selected_paths, *to_delete = NULL;
|
||||
GtkTreeModel *model;
|
||||
|
||||
/* @@fixme -- add (suppressible?) confirmation dialog */
|
||||
/* @@fixme -- add (suppressible?) confirmation dialog */
|
||||
|
||||
selection = gtk_tree_view_get_selection(priv->tree_view);
|
||||
selected_paths = gtk_tree_selection_get_selected_rows(selection, &model);
|
||||
if (g_list_length(selected_paths) == 0)
|
||||
{
|
||||
g_warning("no selection for delete.");
|
||||
return;
|
||||
}
|
||||
selection = gtk_tree_view_get_selection(priv->tree_view);
|
||||
selected_paths = gtk_tree_selection_get_selected_rows(selection, &model);
|
||||
if (g_list_length(selected_paths) == 0)
|
||||
{
|
||||
g_warning("no selection for delete.");
|
||||
return;
|
||||
}
|
||||
|
||||
to_delete = gnc_g_list_map(selected_paths, (GncGMapFunc)_sx_for_path, model);
|
||||
{
|
||||
GList *list;
|
||||
for (list = to_delete; list != NULL; list = list->next)
|
||||
{
|
||||
g_debug("to-delete [%s]\n", xaccSchedXactionGetName((SchedXaction*)list->data));
|
||||
}
|
||||
}
|
||||
g_list_foreach(to_delete, (GFunc)_destroy_sx, NULL);
|
||||
g_list_free(to_delete);
|
||||
g_list_foreach(selected_paths, (GFunc)gtk_tree_path_free, NULL);
|
||||
g_list_free(selected_paths);
|
||||
to_delete = gnc_g_list_map(selected_paths, (GncGMapFunc)_sx_for_path, model);
|
||||
{
|
||||
GList *list;
|
||||
for (list = to_delete; list != NULL; list = list->next)
|
||||
{
|
||||
g_debug("to-delete [%s]\n", xaccSchedXactionGetName((SchedXaction*)list->data));
|
||||
}
|
||||
}
|
||||
g_list_foreach(to_delete, (GFunc)_destroy_sx, NULL);
|
||||
g_list_free(to_delete);
|
||||
g_list_foreach(selected_paths, (GFunc)gtk_tree_path_free, NULL);
|
||||
g_list_free(selected_paths);
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
@ -53,12 +53,12 @@ G_BEGIN_DECLS
|
||||
/* typedefs & structures */
|
||||
typedef struct
|
||||
{
|
||||
GncPluginPage gnc_plugin_page;
|
||||
GncPluginPage gnc_plugin_page;
|
||||
} GncPluginPageSxList;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GncPluginPageClass gnc_plugin_page;
|
||||
GncPluginPageClass gnc_plugin_page;
|
||||
} GncPluginPageSxListClass;
|
||||
|
||||
/* function prototypes */
|
||||
|
@ -29,18 +29,18 @@
|
||||
|
||||
struct _GncSxListTreeModelAdapter
|
||||
{
|
||||
GObject parent;
|
||||
GObject parent;
|
||||
|
||||
/* protected */
|
||||
gboolean disposed;
|
||||
GncSxInstanceModel *instances;
|
||||
GtkTreeStore *orig;
|
||||
GtkTreeModelSort *real;
|
||||
/* protected */
|
||||
gboolean disposed;
|
||||
GncSxInstanceModel *instances;
|
||||
GtkTreeStore *orig;
|
||||
GtkTreeModelSort *real;
|
||||
};
|
||||
|
||||
struct _GncSxListTreeModelAdapterClass
|
||||
{
|
||||
GObjectClass parent;
|
||||
GObjectClass parent;
|
||||
};
|
||||
|
||||
static GObjectClass *parent_class = NULL;
|
||||
@ -57,71 +57,71 @@ static GncSxInstances* gsltma_get_sx_instances_from_orig_iter(GncSxListTreeModel
|
||||
GType
|
||||
gnc_sx_list_tree_model_adapter_get_type(void)
|
||||
{
|
||||
static GType type = 0;
|
||||
if (type == 0) {
|
||||
static const GTypeInfo info = {
|
||||
sizeof (GncSxListTreeModelAdapterClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc)gnc_sx_list_tree_model_adapter_class_init, /* class_init */
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GncSxListTreeModelAdapter),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc)gnc_sx_list_tree_model_adapter_init /* instance_init */
|
||||
};
|
||||
static const GInterfaceInfo itree_model_info = {
|
||||
(GInterfaceInitFunc) gsltma_tree_model_interface_init, /* interface_init */
|
||||
NULL, /* interface_finalize */
|
||||
NULL /* interface_data */
|
||||
};
|
||||
static const GInterfaceInfo itree_sortable_info = {
|
||||
(GInterfaceInitFunc) gsltma_tree_sortable_interface_init, /* interface_init */
|
||||
NULL, /* interface_finalize */
|
||||
NULL /* interface_data */
|
||||
};
|
||||
static GType type = 0;
|
||||
if (type == 0) {
|
||||
static const GTypeInfo info = {
|
||||
sizeof (GncSxListTreeModelAdapterClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc)gnc_sx_list_tree_model_adapter_class_init, /* class_init */
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GncSxListTreeModelAdapter),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc)gnc_sx_list_tree_model_adapter_init /* instance_init */
|
||||
};
|
||||
static const GInterfaceInfo itree_model_info = {
|
||||
(GInterfaceInitFunc) gsltma_tree_model_interface_init, /* interface_init */
|
||||
NULL, /* interface_finalize */
|
||||
NULL /* interface_data */
|
||||
};
|
||||
static const GInterfaceInfo itree_sortable_info = {
|
||||
(GInterfaceInitFunc) gsltma_tree_sortable_interface_init, /* interface_init */
|
||||
NULL, /* interface_finalize */
|
||||
NULL /* interface_data */
|
||||
};
|
||||
|
||||
type = g_type_register_static (G_TYPE_OBJECT,
|
||||
"GncSxListTreeModelAdapterType",
|
||||
&info, 0);
|
||||
g_type_add_interface_static(type,
|
||||
GTK_TYPE_TREE_MODEL,
|
||||
&itree_model_info);
|
||||
g_type_add_interface_static(type,
|
||||
GTK_TYPE_TREE_SORTABLE,
|
||||
&itree_sortable_info);
|
||||
}
|
||||
return type;
|
||||
type = g_type_register_static (G_TYPE_OBJECT,
|
||||
"GncSxListTreeModelAdapterType",
|
||||
&info, 0);
|
||||
g_type_add_interface_static(type,
|
||||
GTK_TYPE_TREE_MODEL,
|
||||
&itree_model_info);
|
||||
g_type_add_interface_static(type,
|
||||
GTK_TYPE_TREE_SORTABLE,
|
||||
&itree_sortable_info);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_sx_list_tree_model_adapter_class_init(GncSxListTreeModelAdapterClass *klass)
|
||||
{
|
||||
GObjectClass *obj_class = G_OBJECT_CLASS(klass);
|
||||
GObjectClass *obj_class = G_OBJECT_CLASS(klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent(klass);
|
||||
parent_class = g_type_class_peek_parent(klass);
|
||||
|
||||
obj_class->dispose = gnc_sx_list_tree_model_adapter_dispose;
|
||||
obj_class->finalize = gnc_sx_list_tree_model_adapter_finalize;
|
||||
obj_class->dispose = gnc_sx_list_tree_model_adapter_dispose;
|
||||
obj_class->finalize = gnc_sx_list_tree_model_adapter_finalize;
|
||||
|
||||
}
|
||||
|
||||
static GtkTreeModelFlags
|
||||
gsltma_get_flags(GtkTreeModel *tree_model)
|
||||
{
|
||||
return gtk_tree_model_get_flags(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real));
|
||||
return gtk_tree_model_get_flags(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real));
|
||||
}
|
||||
|
||||
static gint
|
||||
gsltma_get_n_columns(GtkTreeModel *tree_model)
|
||||
{
|
||||
return gtk_tree_model_get_n_columns(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real));
|
||||
return gtk_tree_model_get_n_columns(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real));
|
||||
}
|
||||
|
||||
static GType
|
||||
gsltma_get_column_type(GtkTreeModel *tree_model, gint index)
|
||||
{
|
||||
return gtk_tree_model_get_column_type(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real), index);
|
||||
return gtk_tree_model_get_column_type(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real), index);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -129,14 +129,14 @@ gsltma_get_iter(GtkTreeModel *tree_model,
|
||||
GtkTreeIter *iter,
|
||||
GtkTreePath *path)
|
||||
{
|
||||
return gtk_tree_model_get_iter(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real), iter, path);
|
||||
return gtk_tree_model_get_iter(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real), iter, path);
|
||||
}
|
||||
|
||||
static GtkTreePath*
|
||||
gsltma_get_path(GtkTreeModel *tree_model,
|
||||
GtkTreeIter *iter)
|
||||
{
|
||||
return gtk_tree_model_get_path(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real), iter);
|
||||
return gtk_tree_model_get_path(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real), iter);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -145,14 +145,14 @@ gsltma_get_value(GtkTreeModel *tree_model,
|
||||
gint column,
|
||||
GValue *value)
|
||||
{
|
||||
gtk_tree_model_get_value(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real), iter, column, value);
|
||||
gtk_tree_model_get_value(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real), iter, column, value);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gsltma_iter_next(GtkTreeModel *tree_model,
|
||||
GtkTreeIter *iter)
|
||||
{
|
||||
return gtk_tree_model_iter_next(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real), iter);
|
||||
return gtk_tree_model_iter_next(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real), iter);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -160,21 +160,21 @@ gsltma_iter_children(GtkTreeModel *tree_model,
|
||||
GtkTreeIter *iter,
|
||||
GtkTreeIter *parent)
|
||||
{
|
||||
return gtk_tree_model_iter_children(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real), iter, parent);
|
||||
return gtk_tree_model_iter_children(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real), iter, parent);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gsltma_iter_has_child(GtkTreeModel *tree_model,
|
||||
GtkTreeIter *iter)
|
||||
{
|
||||
return gtk_tree_model_iter_has_child(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real), iter);
|
||||
return gtk_tree_model_iter_has_child(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real), iter);
|
||||
}
|
||||
|
||||
static gint
|
||||
gsltma_iter_n_children(GtkTreeModel *tree_model,
|
||||
GtkTreeIter *iter)
|
||||
{
|
||||
return gtk_tree_model_iter_n_children(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real), iter);
|
||||
return gtk_tree_model_iter_n_children(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real), iter);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -183,7 +183,7 @@ gsltma_iter_nth_child(GtkTreeModel *tree_model,
|
||||
GtkTreeIter *parent,
|
||||
gint n)
|
||||
{
|
||||
return gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real), iter, parent, n);
|
||||
return gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real), iter, parent, n);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -191,41 +191,41 @@ gsltma_iter_parent(GtkTreeModel *tree_model,
|
||||
GtkTreeIter *iter,
|
||||
GtkTreeIter *child)
|
||||
{
|
||||
return gtk_tree_model_iter_parent(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real), iter, child);
|
||||
return gtk_tree_model_iter_parent(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real), iter, child);
|
||||
}
|
||||
|
||||
static void
|
||||
gsltma_ref_node(GtkTreeModel *tree_model,
|
||||
GtkTreeIter *iter)
|
||||
{
|
||||
gtk_tree_model_ref_node(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real), iter);
|
||||
gtk_tree_model_ref_node(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real), iter);
|
||||
}
|
||||
|
||||
static void
|
||||
gsltma_unref_node(GtkTreeModel *tree_model,
|
||||
GtkTreeIter *iter)
|
||||
{
|
||||
gtk_tree_model_unref_node(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real), iter);
|
||||
gtk_tree_model_unref_node(GTK_TREE_MODEL(GNC_SX_LIST_TREE_MODEL_ADAPTER(tree_model)->real), iter);
|
||||
}
|
||||
|
||||
static void
|
||||
gsltma_tree_model_interface_init(gpointer g_iface, gpointer iface_data)
|
||||
{
|
||||
GtkTreeModelIface *tree_model = (GtkTreeModelIface*)g_iface;
|
||||
tree_model->get_flags = gsltma_get_flags;
|
||||
tree_model->get_n_columns = gsltma_get_n_columns;
|
||||
tree_model->get_column_type = gsltma_get_column_type;
|
||||
tree_model->get_iter = gsltma_get_iter;
|
||||
tree_model->get_path = gsltma_get_path;
|
||||
tree_model->get_value = gsltma_get_value;
|
||||
tree_model->iter_next = gsltma_iter_next;
|
||||
tree_model->iter_children = gsltma_iter_children;
|
||||
tree_model->iter_has_child = gsltma_iter_has_child;
|
||||
tree_model->iter_n_children = gsltma_iter_n_children;
|
||||
tree_model->iter_nth_child = gsltma_iter_nth_child;
|
||||
tree_model->iter_parent = gsltma_iter_parent;
|
||||
tree_model->ref_node = gsltma_ref_node;
|
||||
tree_model->unref_node = gsltma_unref_node;
|
||||
GtkTreeModelIface *tree_model = (GtkTreeModelIface*)g_iface;
|
||||
tree_model->get_flags = gsltma_get_flags;
|
||||
tree_model->get_n_columns = gsltma_get_n_columns;
|
||||
tree_model->get_column_type = gsltma_get_column_type;
|
||||
tree_model->get_iter = gsltma_get_iter;
|
||||
tree_model->get_path = gsltma_get_path;
|
||||
tree_model->get_value = gsltma_get_value;
|
||||
tree_model->iter_next = gsltma_iter_next;
|
||||
tree_model->iter_children = gsltma_iter_children;
|
||||
tree_model->iter_has_child = gsltma_iter_has_child;
|
||||
tree_model->iter_n_children = gsltma_iter_n_children;
|
||||
tree_model->iter_nth_child = gsltma_iter_nth_child;
|
||||
tree_model->iter_parent = gsltma_iter_parent;
|
||||
tree_model->ref_node = gsltma_ref_node;
|
||||
tree_model->unref_node = gsltma_unref_node;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -233,9 +233,9 @@ gsltma_get_sort_column_id(GtkTreeSortable *sortable,
|
||||
gint *sort_column_id,
|
||||
GtkSortType *order)
|
||||
{
|
||||
return gtk_tree_sortable_get_sort_column_id(GTK_TREE_SORTABLE(GNC_SX_LIST_TREE_MODEL_ADAPTER(sortable)->real),
|
||||
sort_column_id,
|
||||
order);
|
||||
return gtk_tree_sortable_get_sort_column_id(GTK_TREE_SORTABLE(GNC_SX_LIST_TREE_MODEL_ADAPTER(sortable)->real),
|
||||
sort_column_id,
|
||||
order);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -243,9 +243,9 @@ gsltma_set_sort_column_id(GtkTreeSortable *sortable,
|
||||
gint sort_column_id,
|
||||
GtkSortType order)
|
||||
{
|
||||
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(GNC_SX_LIST_TREE_MODEL_ADAPTER(sortable)->real),
|
||||
sort_column_id,
|
||||
order);
|
||||
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(GNC_SX_LIST_TREE_MODEL_ADAPTER(sortable)->real),
|
||||
sort_column_id,
|
||||
order);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -255,11 +255,11 @@ gsltma_set_sort_func(GtkTreeSortable *sortable,
|
||||
gpointer data,
|
||||
GtkDestroyNotify destroy)
|
||||
{
|
||||
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(GNC_SX_LIST_TREE_MODEL_ADAPTER(sortable)->real),
|
||||
sort_column_id,
|
||||
func,
|
||||
data,
|
||||
destroy);
|
||||
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(GNC_SX_LIST_TREE_MODEL_ADAPTER(sortable)->real),
|
||||
sort_column_id,
|
||||
func,
|
||||
data,
|
||||
destroy);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -268,30 +268,30 @@ gsltma_set_default_sort_func(GtkTreeSortable *sortable,
|
||||
gpointer data,
|
||||
GtkDestroyNotify destroy)
|
||||
{
|
||||
gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(GNC_SX_LIST_TREE_MODEL_ADAPTER(sortable)->real),
|
||||
func, data, destroy);
|
||||
gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(GNC_SX_LIST_TREE_MODEL_ADAPTER(sortable)->real),
|
||||
func, data, destroy);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gsltma_has_default_sort_func(GtkTreeSortable *sortable)
|
||||
{
|
||||
return gtk_tree_sortable_has_default_sort_func(GTK_TREE_SORTABLE(GNC_SX_LIST_TREE_MODEL_ADAPTER(sortable)->real));
|
||||
return gtk_tree_sortable_has_default_sort_func(GTK_TREE_SORTABLE(GNC_SX_LIST_TREE_MODEL_ADAPTER(sortable)->real));
|
||||
}
|
||||
|
||||
static void
|
||||
gsltma_tree_sortable_interface_init(gpointer g_iface, gpointer iface_data)
|
||||
{
|
||||
GtkTreeSortableIface *tree_sortable = (GtkTreeSortableIface*)g_iface;
|
||||
tree_sortable->get_sort_column_id = gsltma_get_sort_column_id;
|
||||
tree_sortable->set_sort_column_id = gsltma_set_sort_column_id;
|
||||
tree_sortable->set_sort_func = gsltma_set_sort_func;
|
||||
tree_sortable->set_default_sort_func = gsltma_set_default_sort_func;
|
||||
tree_sortable->has_default_sort_func = gsltma_has_default_sort_func;
|
||||
tree_sortable->get_sort_column_id = gsltma_get_sort_column_id;
|
||||
tree_sortable->set_sort_column_id = gsltma_set_sort_column_id;
|
||||
tree_sortable->set_sort_func = gsltma_set_sort_func;
|
||||
tree_sortable->set_default_sort_func = gsltma_set_default_sort_func;
|
||||
tree_sortable->has_default_sort_func = gsltma_has_default_sort_func;
|
||||
GtkTreeSortableIface *tree_sortable = (GtkTreeSortableIface*)g_iface;
|
||||
tree_sortable->get_sort_column_id = gsltma_get_sort_column_id;
|
||||
tree_sortable->set_sort_column_id = gsltma_set_sort_column_id;
|
||||
tree_sortable->set_sort_func = gsltma_set_sort_func;
|
||||
tree_sortable->set_default_sort_func = gsltma_set_default_sort_func;
|
||||
tree_sortable->has_default_sort_func = gsltma_has_default_sort_func;
|
||||
tree_sortable->get_sort_column_id = gsltma_get_sort_column_id;
|
||||
tree_sortable->set_sort_column_id = gsltma_set_sort_column_id;
|
||||
tree_sortable->set_sort_func = gsltma_set_sort_func;
|
||||
tree_sortable->set_default_sort_func = gsltma_set_default_sort_func;
|
||||
tree_sortable->has_default_sort_func = gsltma_has_default_sort_func;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -300,7 +300,7 @@ gsltma_proxy_row_changed(GtkTreeModel *treemodel,
|
||||
GtkTreeIter *arg2,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_signal_emit_by_name(user_data, "row-changed", arg1, arg2);
|
||||
g_signal_emit_by_name(user_data, "row-changed", arg1, arg2);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -308,7 +308,7 @@ gsltma_proxy_row_deleted(GtkTreeModel *treemodel,
|
||||
GtkTreePath *arg1,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_signal_emit_by_name(user_data, "row-deleted", arg1);
|
||||
g_signal_emit_by_name(user_data, "row-deleted", arg1);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -317,7 +317,7 @@ gsltma_proxy_row_has_child_toggled(GtkTreeModel *treemodel,
|
||||
GtkTreeIter *arg2,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_signal_emit_by_name(user_data, "row-has-child-toggled", arg1, arg2);
|
||||
g_signal_emit_by_name(user_data, "row-has-child-toggled", arg1, arg2);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -326,7 +326,7 @@ gsltma_proxy_row_inserted(GtkTreeModel *treemodel,
|
||||
GtkTreeIter *arg2,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_signal_emit_by_name(user_data, "row-inserted", arg1, arg2);
|
||||
g_signal_emit_by_name(user_data, "row-inserted", arg1, arg2);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -336,281 +336,281 @@ gsltma_proxy_rows_reordered(GtkTreeModel *treemodel,
|
||||
gpointer arg3,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_signal_emit_by_name(user_data, "rows-reordered", arg1, arg2, arg3);
|
||||
g_signal_emit_by_name(user_data, "rows-reordered", arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
static void
|
||||
gsltma_proxy_sort_column_changed(GtkTreeSortable *sortable, gpointer user_data)
|
||||
{
|
||||
g_signal_emit_by_name(user_data, "sort-column-changed");
|
||||
g_signal_emit_by_name(user_data, "sort-column-changed");
|
||||
}
|
||||
|
||||
static gint
|
||||
_name_comparator(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data)
|
||||
{
|
||||
gint rtn;
|
||||
GncSxListTreeModelAdapter *adapter = GNC_SX_LIST_TREE_MODEL_ADAPTER(user_data);
|
||||
GncSxInstances *a_inst, *b_inst;
|
||||
gchar *a_caseless, *b_caseless;
|
||||
gint rtn;
|
||||
GncSxListTreeModelAdapter *adapter = GNC_SX_LIST_TREE_MODEL_ADAPTER(user_data);
|
||||
GncSxInstances *a_inst, *b_inst;
|
||||
gchar *a_caseless, *b_caseless;
|
||||
|
||||
a_inst = gsltma_get_sx_instances_from_orig_iter(adapter, a);
|
||||
b_inst = gsltma_get_sx_instances_from_orig_iter(adapter, b);
|
||||
a_inst = gsltma_get_sx_instances_from_orig_iter(adapter, a);
|
||||
b_inst = gsltma_get_sx_instances_from_orig_iter(adapter, b);
|
||||
|
||||
if (a_inst == NULL && b_inst == NULL) return 0;
|
||||
if (a_inst == NULL) return 1;
|
||||
if (b_inst == NULL) return -1;
|
||||
if (a_inst == NULL && b_inst == NULL) return 0;
|
||||
if (a_inst == NULL) return 1;
|
||||
if (b_inst == NULL) return -1;
|
||||
|
||||
a_caseless = g_utf8_casefold(xaccSchedXactionGetName(a_inst->sx), -1);
|
||||
b_caseless = g_utf8_casefold(xaccSchedXactionGetName(b_inst->sx), -1);
|
||||
rtn = safe_strcmp(a_caseless, b_caseless);
|
||||
g_free(a_caseless);
|
||||
g_free(b_caseless);
|
||||
a_caseless = g_utf8_casefold(xaccSchedXactionGetName(a_inst->sx), -1);
|
||||
b_caseless = g_utf8_casefold(xaccSchedXactionGetName(b_inst->sx), -1);
|
||||
rtn = safe_strcmp(a_caseless, b_caseless);
|
||||
g_free(a_caseless);
|
||||
g_free(b_caseless);
|
||||
|
||||
return rtn;
|
||||
return rtn;
|
||||
}
|
||||
|
||||
static gint
|
||||
_freq_comparator(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data)
|
||||
{
|
||||
GncSxListTreeModelAdapter *adapter = GNC_SX_LIST_TREE_MODEL_ADAPTER(user_data);
|
||||
GncSxInstances *a_inst, *b_inst;
|
||||
GncSxListTreeModelAdapter *adapter = GNC_SX_LIST_TREE_MODEL_ADAPTER(user_data);
|
||||
GncSxInstances *a_inst, *b_inst;
|
||||
|
||||
a_inst = gsltma_get_sx_instances_from_orig_iter(adapter, a);
|
||||
b_inst = gsltma_get_sx_instances_from_orig_iter(adapter, b);
|
||||
a_inst = gsltma_get_sx_instances_from_orig_iter(adapter, a);
|
||||
b_inst = gsltma_get_sx_instances_from_orig_iter(adapter, b);
|
||||
|
||||
if (a_inst == NULL && b_inst == NULL) return 0;
|
||||
if (a_inst == NULL) return 1;
|
||||
if (b_inst == NULL) return -1;
|
||||
if (a_inst == NULL && b_inst == NULL) return 0;
|
||||
if (a_inst == NULL) return 1;
|
||||
if (b_inst == NULL) return -1;
|
||||
|
||||
return gnc_freq_spec_compare(xaccSchedXactionGetFreqSpec(a_inst->sx),
|
||||
xaccSchedXactionGetFreqSpec(b_inst->sx));
|
||||
return gnc_freq_spec_compare(xaccSchedXactionGetFreqSpec(a_inst->sx),
|
||||
xaccSchedXactionGetFreqSpec(b_inst->sx));
|
||||
}
|
||||
|
||||
static gint
|
||||
_safe_invalidable_date_compare(GDate *a, GDate *b)
|
||||
{
|
||||
if (!g_date_valid(a) && !g_date_valid(b))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (!g_date_valid(a))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (!g_date_valid(b))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return g_date_compare(a, b);
|
||||
if (!g_date_valid(a) && !g_date_valid(b))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (!g_date_valid(a))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (!g_date_valid(b))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return g_date_compare(a, b);
|
||||
}
|
||||
|
||||
static gint
|
||||
_last_occur_comparator(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data)
|
||||
{
|
||||
GncSxListTreeModelAdapter *adapter = GNC_SX_LIST_TREE_MODEL_ADAPTER(user_data);
|
||||
GncSxInstances *a_inst, *b_inst;
|
||||
GncSxListTreeModelAdapter *adapter = GNC_SX_LIST_TREE_MODEL_ADAPTER(user_data);
|
||||
GncSxInstances *a_inst, *b_inst;
|
||||
|
||||
a_inst = gsltma_get_sx_instances_from_orig_iter(adapter, a);
|
||||
b_inst = gsltma_get_sx_instances_from_orig_iter(adapter, b);
|
||||
a_inst = gsltma_get_sx_instances_from_orig_iter(adapter, a);
|
||||
b_inst = gsltma_get_sx_instances_from_orig_iter(adapter, b);
|
||||
|
||||
return _safe_invalidable_date_compare(xaccSchedXactionGetLastOccurDate(a_inst->sx),
|
||||
xaccSchedXactionGetLastOccurDate(b_inst->sx));
|
||||
return _safe_invalidable_date_compare(xaccSchedXactionGetLastOccurDate(a_inst->sx),
|
||||
xaccSchedXactionGetLastOccurDate(b_inst->sx));
|
||||
}
|
||||
|
||||
static gint
|
||||
_next_occur_comparator(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data)
|
||||
{
|
||||
GncSxListTreeModelAdapter *adapter = GNC_SX_LIST_TREE_MODEL_ADAPTER(user_data);
|
||||
GncSxInstances *a_inst, *b_inst;
|
||||
GncSxListTreeModelAdapter *adapter = GNC_SX_LIST_TREE_MODEL_ADAPTER(user_data);
|
||||
GncSxInstances *a_inst, *b_inst;
|
||||
|
||||
a_inst = gsltma_get_sx_instances_from_orig_iter(adapter, a);
|
||||
b_inst = gsltma_get_sx_instances_from_orig_iter(adapter, b);
|
||||
a_inst = gsltma_get_sx_instances_from_orig_iter(adapter, a);
|
||||
b_inst = gsltma_get_sx_instances_from_orig_iter(adapter, b);
|
||||
|
||||
return _safe_invalidable_date_compare(&a_inst->next_instance_date,
|
||||
&b_inst->next_instance_date);
|
||||
return _safe_invalidable_date_compare(&a_inst->next_instance_date,
|
||||
&b_inst->next_instance_date);
|
||||
}
|
||||
|
||||
static gint
|
||||
_enabled_comparator(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data)
|
||||
{
|
||||
GncSxListTreeModelAdapter *adapter = GNC_SX_LIST_TREE_MODEL_ADAPTER(user_data);
|
||||
GncSxInstances *a_inst, *b_inst;
|
||||
GncSxListTreeModelAdapter *adapter = GNC_SX_LIST_TREE_MODEL_ADAPTER(user_data);
|
||||
GncSxInstances *a_inst, *b_inst;
|
||||
|
||||
a_inst = gsltma_get_sx_instances_from_orig_iter(adapter, a);
|
||||
b_inst = gsltma_get_sx_instances_from_orig_iter(adapter, b);
|
||||
a_inst = gsltma_get_sx_instances_from_orig_iter(adapter, a);
|
||||
b_inst = gsltma_get_sx_instances_from_orig_iter(adapter, b);
|
||||
|
||||
if (xaccSchedXactionGetEnabled(a_inst->sx) && !xaccSchedXactionGetEnabled(b_inst->sx)) return 1;
|
||||
if (!xaccSchedXactionGetEnabled(a_inst->sx) && xaccSchedXactionGetEnabled(b_inst->sx)) return -1;
|
||||
return 0;
|
||||
if (xaccSchedXactionGetEnabled(a_inst->sx) && !xaccSchedXactionGetEnabled(b_inst->sx)) return 1;
|
||||
if (!xaccSchedXactionGetEnabled(a_inst->sx) && xaccSchedXactionGetEnabled(b_inst->sx)) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_sx_list_tree_model_adapter_init(GTypeInstance *instance, gpointer klass)
|
||||
{
|
||||
GncSxListTreeModelAdapter *adapter = GNC_SX_LIST_TREE_MODEL_ADAPTER(instance);
|
||||
adapter->orig = gtk_tree_store_new(5, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
|
||||
adapter->real = GTK_TREE_MODEL_SORT(gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(adapter->orig)));
|
||||
GncSxListTreeModelAdapter *adapter = GNC_SX_LIST_TREE_MODEL_ADAPTER(instance);
|
||||
adapter->orig = gtk_tree_store_new(5, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
|
||||
adapter->real = GTK_TREE_MODEL_SORT(gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(adapter->orig)));
|
||||
|
||||
// setup sorting
|
||||
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(adapter->real), SXLTMA_COL_NAME, _name_comparator, adapter, NULL);
|
||||
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(adapter->real), SXLTMA_COL_ENABLED, _enabled_comparator, adapter, NULL);
|
||||
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(adapter->real), SXLTMA_COL_FREQUENCY, _freq_comparator, adapter, NULL);
|
||||
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(adapter->real), SXLTMA_COL_LAST_OCCUR, _last_occur_comparator, adapter, NULL);
|
||||
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(adapter->real), SXLTMA_COL_NEXT_OCCUR, _next_occur_comparator, adapter, NULL);
|
||||
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(adapter->real), SXLTMA_COL_NEXT_OCCUR, GTK_SORT_ASCENDING);
|
||||
// setup sorting
|
||||
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(adapter->real), SXLTMA_COL_NAME, _name_comparator, adapter, NULL);
|
||||
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(adapter->real), SXLTMA_COL_ENABLED, _enabled_comparator, adapter, NULL);
|
||||
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(adapter->real), SXLTMA_COL_FREQUENCY, _freq_comparator, adapter, NULL);
|
||||
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(adapter->real), SXLTMA_COL_LAST_OCCUR, _last_occur_comparator, adapter, NULL);
|
||||
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(adapter->real), SXLTMA_COL_NEXT_OCCUR, _next_occur_comparator, adapter, NULL);
|
||||
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(adapter->real), SXLTMA_COL_NEXT_OCCUR, GTK_SORT_ASCENDING);
|
||||
|
||||
g_signal_connect(adapter->real, "row-changed", G_CALLBACK(gsltma_proxy_row_changed), adapter);
|
||||
g_signal_connect(adapter->real, "row-deleted", G_CALLBACK(gsltma_proxy_row_deleted), adapter);
|
||||
g_signal_connect(adapter->real, "row-has-child-toggled", G_CALLBACK(gsltma_proxy_row_has_child_toggled), adapter);
|
||||
g_signal_connect(adapter->real, "row-inserted", G_CALLBACK(gsltma_proxy_row_inserted), adapter);
|
||||
g_signal_connect(adapter->real, "rows-reordered", G_CALLBACK(gsltma_proxy_rows_reordered), adapter);
|
||||
g_signal_connect(adapter->real, "row-changed", G_CALLBACK(gsltma_proxy_row_changed), adapter);
|
||||
g_signal_connect(adapter->real, "row-deleted", G_CALLBACK(gsltma_proxy_row_deleted), adapter);
|
||||
g_signal_connect(adapter->real, "row-has-child-toggled", G_CALLBACK(gsltma_proxy_row_has_child_toggled), adapter);
|
||||
g_signal_connect(adapter->real, "row-inserted", G_CALLBACK(gsltma_proxy_row_inserted), adapter);
|
||||
g_signal_connect(adapter->real, "rows-reordered", G_CALLBACK(gsltma_proxy_rows_reordered), adapter);
|
||||
|
||||
g_signal_connect(adapter->real, "sort-column-changed", G_CALLBACK(gsltma_proxy_sort_column_changed), adapter);
|
||||
g_signal_connect(adapter->real, "sort-column-changed", G_CALLBACK(gsltma_proxy_sort_column_changed), adapter);
|
||||
}
|
||||
|
||||
static void
|
||||
_format_conditional_date(GDate *date, char *date_buf, int buf_max_length)
|
||||
{
|
||||
if (date == NULL || !g_date_valid(date))
|
||||
{
|
||||
g_stpcpy(date_buf, "never");
|
||||
}
|
||||
else
|
||||
{
|
||||
qof_print_gdate(date_buf, buf_max_length, date);
|
||||
}
|
||||
if (date == NULL || !g_date_valid(date))
|
||||
{
|
||||
g_stpcpy(date_buf, "never");
|
||||
}
|
||||
else
|
||||
{
|
||||
qof_print_gdate(date_buf, buf_max_length, date);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gsltma_populate_tree_store(GncSxListTreeModelAdapter *model)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GList *list;
|
||||
GtkTreeIter iter;
|
||||
GList *list;
|
||||
|
||||
for (list = model->instances->sx_instance_list; list != NULL; list = list->next)
|
||||
{
|
||||
GncSxInstances *instances = (GncSxInstances*)list->data;
|
||||
gchar *frequency_str;
|
||||
char last_occur_date_buf[MAX_DATE_LENGTH+1];
|
||||
char next_occur_date_buf[MAX_DATE_LENGTH+1];
|
||||
for (list = model->instances->sx_instance_list; list != NULL; list = list->next)
|
||||
{
|
||||
GncSxInstances *instances = (GncSxInstances*)list->data;
|
||||
gchar *frequency_str;
|
||||
char last_occur_date_buf[MAX_DATE_LENGTH+1];
|
||||
char next_occur_date_buf[MAX_DATE_LENGTH+1];
|
||||
|
||||
frequency_str = recurrenceListToString(gnc_sx_get_schedule(instances->sx));
|
||||
frequency_str = recurrenceListToString(gnc_sx_get_schedule(instances->sx));
|
||||
|
||||
_format_conditional_date(xaccSchedXactionGetLastOccurDate(instances->sx),
|
||||
last_occur_date_buf, MAX_DATE_LENGTH);
|
||||
_format_conditional_date(&instances->next_instance_date,
|
||||
next_occur_date_buf, MAX_DATE_LENGTH);
|
||||
_format_conditional_date(xaccSchedXactionGetLastOccurDate(instances->sx),
|
||||
last_occur_date_buf, MAX_DATE_LENGTH);
|
||||
_format_conditional_date(&instances->next_instance_date,
|
||||
next_occur_date_buf, MAX_DATE_LENGTH);
|
||||
|
||||
gtk_tree_store_append(model->orig, &iter, NULL);
|
||||
gtk_tree_store_set(model->orig, &iter,
|
||||
SXLTMA_COL_NAME, xaccSchedXactionGetName(instances->sx),
|
||||
SXLTMA_COL_ENABLED, xaccSchedXactionGetEnabled(instances->sx),
|
||||
SXLTMA_COL_FREQUENCY, frequency_str,
|
||||
SXLTMA_COL_LAST_OCCUR, last_occur_date_buf,
|
||||
SXLTMA_COL_NEXT_OCCUR, next_occur_date_buf,
|
||||
-1);
|
||||
g_free(frequency_str);
|
||||
}
|
||||
gtk_tree_store_append(model->orig, &iter, NULL);
|
||||
gtk_tree_store_set(model->orig, &iter,
|
||||
SXLTMA_COL_NAME, xaccSchedXactionGetName(instances->sx),
|
||||
SXLTMA_COL_ENABLED, xaccSchedXactionGetEnabled(instances->sx),
|
||||
SXLTMA_COL_FREQUENCY, frequency_str,
|
||||
SXLTMA_COL_LAST_OCCUR, last_occur_date_buf,
|
||||
SXLTMA_COL_NEXT_OCCUR, next_occur_date_buf,
|
||||
-1);
|
||||
g_free(frequency_str);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gsltma_added_cb(GncSxInstanceModel *instances, SchedXaction *sx_added, gpointer user_data)
|
||||
{
|
||||
GncSxListTreeModelAdapter *model = GNC_SX_LIST_TREE_MODEL_ADAPTER(user_data);
|
||||
gtk_tree_store_clear(model->orig);
|
||||
gsltma_populate_tree_store(model);
|
||||
GncSxListTreeModelAdapter *model = GNC_SX_LIST_TREE_MODEL_ADAPTER(user_data);
|
||||
gtk_tree_store_clear(model->orig);
|
||||
gsltma_populate_tree_store(model);
|
||||
}
|
||||
|
||||
static void
|
||||
gsltma_updated_cb(GncSxInstanceModel *instances, SchedXaction *sx_updated, gpointer user_data)
|
||||
{
|
||||
GncSxListTreeModelAdapter *model = GNC_SX_LIST_TREE_MODEL_ADAPTER(user_data);
|
||||
gnc_sx_instance_model_update_sx_instances(instances, sx_updated);
|
||||
gtk_tree_store_clear(model->orig);
|
||||
gsltma_populate_tree_store(model);
|
||||
GncSxListTreeModelAdapter *model = GNC_SX_LIST_TREE_MODEL_ADAPTER(user_data);
|
||||
gnc_sx_instance_model_update_sx_instances(instances, sx_updated);
|
||||
gtk_tree_store_clear(model->orig);
|
||||
gsltma_populate_tree_store(model);
|
||||
}
|
||||
|
||||
static void
|
||||
gsltma_removing_cb(GncSxInstanceModel *instances, SchedXaction *sx_removing, gpointer user_data)
|
||||
{
|
||||
GncSxListTreeModelAdapter *model = GNC_SX_LIST_TREE_MODEL_ADAPTER(user_data);
|
||||
gnc_sx_instance_model_remove_sx_instances(instances, sx_removing);
|
||||
gtk_tree_store_clear(model->orig);
|
||||
gsltma_populate_tree_store(model);
|
||||
GncSxListTreeModelAdapter *model = GNC_SX_LIST_TREE_MODEL_ADAPTER(user_data);
|
||||
gnc_sx_instance_model_remove_sx_instances(instances, sx_removing);
|
||||
gtk_tree_store_clear(model->orig);
|
||||
gsltma_populate_tree_store(model);
|
||||
}
|
||||
|
||||
GncSxListTreeModelAdapter*
|
||||
gnc_sx_list_tree_model_adapter_new(GncSxInstanceModel *instances)
|
||||
{
|
||||
GncSxListTreeModelAdapter *rtn;
|
||||
GncSxListTreeModelAdapter *rtn;
|
||||
|
||||
rtn = GNC_SX_LIST_TREE_MODEL_ADAPTER(g_object_new(GNC_TYPE_SX_LIST_TREE_MODEL_ADAPTER, NULL));
|
||||
rtn->instances = instances;
|
||||
g_object_ref(G_OBJECT(rtn->instances));
|
||||
rtn = GNC_SX_LIST_TREE_MODEL_ADAPTER(g_object_new(GNC_TYPE_SX_LIST_TREE_MODEL_ADAPTER, NULL));
|
||||
rtn->instances = instances;
|
||||
g_object_ref(G_OBJECT(rtn->instances));
|
||||
|
||||
gsltma_populate_tree_store(rtn);
|
||||
gsltma_populate_tree_store(rtn);
|
||||
|
||||
g_signal_connect(G_OBJECT(rtn->instances), "added", (GCallback)gsltma_added_cb, (gpointer)rtn);
|
||||
g_signal_connect(G_OBJECT(rtn->instances), "updated", (GCallback)gsltma_updated_cb, (gpointer)rtn);
|
||||
g_signal_connect(G_OBJECT(rtn->instances), "removing", (GCallback)gsltma_removing_cb, (gpointer)rtn);
|
||||
g_signal_connect(G_OBJECT(rtn->instances), "added", (GCallback)gsltma_added_cb, (gpointer)rtn);
|
||||
g_signal_connect(G_OBJECT(rtn->instances), "updated", (GCallback)gsltma_updated_cb, (gpointer)rtn);
|
||||
g_signal_connect(G_OBJECT(rtn->instances), "removing", (GCallback)gsltma_removing_cb, (gpointer)rtn);
|
||||
|
||||
return rtn;
|
||||
return rtn;
|
||||
}
|
||||
|
||||
GncSxInstances*
|
||||
gsltma_get_sx_instances_from_orig_iter(GncSxListTreeModelAdapter *model, GtkTreeIter *orig_iter)
|
||||
{
|
||||
GtkTreePath *path;
|
||||
gint *indices;
|
||||
gint index;
|
||||
GtkTreePath *path;
|
||||
gint *indices;
|
||||
gint index;
|
||||
|
||||
path = gtk_tree_model_get_path(GTK_TREE_MODEL(model->orig), orig_iter);
|
||||
if (gtk_tree_path_get_depth(path) > 1)
|
||||
{
|
||||
gtk_tree_path_free(path);
|
||||
return NULL;
|
||||
}
|
||||
indices = gtk_tree_path_get_indices(path);
|
||||
index = indices[0];
|
||||
path = gtk_tree_model_get_path(GTK_TREE_MODEL(model->orig), orig_iter);
|
||||
if (gtk_tree_path_get_depth(path) > 1)
|
||||
{
|
||||
gtk_tree_path_free(path);
|
||||
return NULL;
|
||||
}
|
||||
indices = gtk_tree_path_get_indices(path);
|
||||
index = indices[0];
|
||||
|
||||
gtk_tree_path_free(path);
|
||||
return (GncSxInstances*)g_list_nth_data(model->instances->sx_instance_list, index);
|
||||
gtk_tree_path_free(path);
|
||||
return (GncSxInstances*)g_list_nth_data(model->instances->sx_instance_list, index);
|
||||
}
|
||||
|
||||
GncSxInstances*
|
||||
gnc_sx_list_tree_model_adapter_get_sx_instances(GncSxListTreeModelAdapter *model, GtkTreeIter *sort_iter)
|
||||
{
|
||||
GtkTreeIter translated_iter;
|
||||
gtk_tree_model_sort_convert_iter_to_child_iter(model->real,
|
||||
&translated_iter,
|
||||
sort_iter);
|
||||
return gsltma_get_sx_instances_from_orig_iter(model, &translated_iter);
|
||||
GtkTreeIter translated_iter;
|
||||
gtk_tree_model_sort_convert_iter_to_child_iter(model->real,
|
||||
&translated_iter,
|
||||
sort_iter);
|
||||
return gsltma_get_sx_instances_from_orig_iter(model, &translated_iter);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_sx_list_tree_model_adapter_dispose(GObject *obj)
|
||||
{
|
||||
GncSxListTreeModelAdapter *adapter;
|
||||
GncSxListTreeModelAdapter *adapter;
|
||||
|
||||
g_return_if_fail(obj != NULL);
|
||||
adapter = GNC_SX_LIST_TREE_MODEL_ADAPTER(obj);
|
||||
g_return_if_fail(obj != NULL);
|
||||
adapter = GNC_SX_LIST_TREE_MODEL_ADAPTER(obj);
|
||||
|
||||
if (adapter->disposed) return;
|
||||
adapter->disposed = TRUE;
|
||||
if (adapter->disposed) return;
|
||||
adapter->disposed = TRUE;
|
||||
|
||||
g_object_unref(G_OBJECT(adapter->instances));
|
||||
adapter->instances = NULL;
|
||||
g_object_unref(G_OBJECT(adapter->real));
|
||||
adapter->real = NULL;
|
||||
g_object_unref(G_OBJECT(adapter->orig));
|
||||
adapter->orig = NULL;
|
||||
g_object_unref(G_OBJECT(adapter->instances));
|
||||
adapter->instances = NULL;
|
||||
g_object_unref(G_OBJECT(adapter->real));
|
||||
adapter->real = NULL;
|
||||
g_object_unref(G_OBJECT(adapter->orig));
|
||||
adapter->orig = NULL;
|
||||
|
||||
G_OBJECT_CLASS(parent_class)->dispose(obj);
|
||||
G_OBJECT_CLASS(parent_class)->dispose(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_sx_list_tree_model_adapter_finalize(GObject *obj)
|
||||
{
|
||||
g_return_if_fail(obj != NULL);
|
||||
G_OBJECT_CLASS(parent_class)->finalize(obj);
|
||||
g_return_if_fail(obj != NULL);
|
||||
G_OBJECT_CLASS(parent_class)->finalize(obj);
|
||||
}
|
||||
|
@ -43,11 +43,11 @@ typedef struct _GncSxListTreeModelAdapterClass GncSxListTreeModelAdapterClass;
|
||||
|
||||
// model columns
|
||||
enum {
|
||||
SXLTMA_COL_NAME = 0,
|
||||
SXLTMA_COL_ENABLED,
|
||||
SXLTMA_COL_FREQUENCY,
|
||||
SXLTMA_COL_LAST_OCCUR,
|
||||
SXLTMA_COL_NEXT_OCCUR
|
||||
SXLTMA_COL_NAME = 0,
|
||||
SXLTMA_COL_ENABLED,
|
||||
SXLTMA_COL_FREQUENCY,
|
||||
SXLTMA_COL_LAST_OCCUR,
|
||||
SXLTMA_COL_NEXT_OCCUR
|
||||
};
|
||||
|
||||
GType gnc_sx_list_tree_model_adapter_get_type(void);
|
||||
|
Loading…
Reference in New Issue
Block a user