r14566 - gnucash/branches/sx-cleanup - Dense-calendar model interface, implementations; the SX-List dense-cal works again, and with of add/remove ops.
Joshua Sled
jsled at cvs.gnucash.org
Tue Jul 25 23:11:39 EDT 2006
Author: jsled
Date: 2006-07-25 23:11:36 -0400 (Tue, 25 Jul 2006)
New Revision: 14566
Trac: http://svn.gnucash.org/trac/changeset/14566
Modified:
gnucash/branches/sx-cleanup/ChangeLog
gnucash/branches/sx-cleanup/src/doc/sx.rst
gnucash/branches/sx-cleanup/src/gnome-utils/gnc-dense-cal.c
gnucash/branches/sx-cleanup/src/gnome-utils/gnc-dense-cal.h
gnucash/branches/sx-cleanup/src/gnome/dialog-sx-editor.c
gnucash/branches/sx-cleanup/src/gnome/dialog-sx-from-trans.c
gnucash/branches/sx-cleanup/src/gnome/gnc-plugin-page-sx-list.c
Log:
Dense-calendar model interface, implementations; the SX-List dense-cal works again, and with of add/remove ops.
- GncDenseCalModel interface
- GncDenseCalTransient model impl.
- Add GncSxInstanceDenseCalAdapter (between GncSxInstanceModel and GncDenseCalModel)
- Start to hook up 'added' and 'removing' signals on the GncSxInstanceModel.
Modified: gnucash/branches/sx-cleanup/ChangeLog
===================================================================
--- gnucash/branches/sx-cleanup/ChangeLog 2006-07-26 02:36:53 UTC (rev 14565)
+++ gnucash/branches/sx-cleanup/ChangeLog 2006-07-26 03:11:36 UTC (rev 14566)
@@ -1,3 +1,16 @@
+2006-07-25 Joshua Sled <jsled at asynchronous.org>
+
+ * src/gnome-utils/gnc-dense-cal.c:
+ Add GncDenseCalModel interface, support.
+ Add unfinished GncDenseCalTransient model impl. for
+ one-off being-edited-SX calendar usage.
+
+ * src/gnome/gnc-plugin-page-sx-list.c:
+ Add GncSxInstanceDenseCalAdapter between GncSxInstanceModel and
+ GncDenseCalModel. Start to hook up 'added' and 'removing' signals
+ on the GncSxInstanceModel. The SX-List dense-cal works again, and
+ reflects both removed and new SXes.
+
2006-07-16 Joshua Sled <jsled at asynchronous.org>
* src/engine/SX-book-p.h:
Modified: gnucash/branches/sx-cleanup/src/doc/sx.rst
===================================================================
--- gnucash/branches/sx-cleanup/src/doc/sx.rst 2006-07-26 02:36:53 UTC (rev 14565)
+++ gnucash/branches/sx-cleanup/src/doc/sx.rst 2006-07-26 03:11:36 UTC (rev 14566)
@@ -25,10 +25,9 @@
- gnc_dense_cal
- change number-month properties to display (width, length)
- - upcoming_instances_add_to_gnc_dense_cal(GncSxUpcomingInstances *future);
- - set_model(GncTemporalInstancesModel *mdl)
+ x set_model(GncTemporalInstancesModel *mdl)
- new interface creation.
- - register callbacks for signals
+ x register callbacks for signals
- transaction creation
- verification routine
Modified: gnucash/branches/sx-cleanup/src/gnome/dialog-sx-editor.c
===================================================================
--- gnucash/branches/sx-cleanup/src/gnome/dialog-sx-editor.c 2006-07-26 02:36:53 UTC (rev 14565)
+++ gnucash/branches/sx-cleanup/src/gnome/dialog-sx-editor.c 2006-07-26 03:11:36 UTC (rev 14566)
@@ -1584,7 +1584,7 @@
}
if ( sxed->markId != -1 ) {
- gnc_dense_cal_mark_remove( sxed->example_cal, sxed->markId );
+ // gnc_dense_cal_mark_remove( sxed->example_cal, sxed->markId );
sxed->markId = -1;
}
@@ -1643,9 +1643,10 @@
}
info = g_string_sized_new( 16 );
xaccFreqSpecGetFreqStr( fs, info );
- sxed->markId = gnc_dense_cal_mark( sxed->example_cal, i,
+ sxed->markId = -1;
+ /*sxed->markId = gnc_dense_cal_mark( sxed->example_cal, i,
sxed->cal_marks,
- name, info->str );
+ name, info->str );*/
gtk_widget_queue_draw( GTK_WIDGET( sxed->example_cal ) );
g_string_free( info, TRUE );
Modified: gnucash/branches/sx-cleanup/src/gnome/dialog-sx-from-trans.c
===================================================================
--- gnucash/branches/sx-cleanup/src/gnome/dialog-sx-from-trans.c 2006-07-26 02:36:53 UTC (rev 14565)
+++ gnucash/branches/sx-cleanup/src/gnome/dialog-sx-from-trans.c 2006-07-26 03:11:36 UTC (rev 14566)
@@ -735,7 +735,7 @@
}
/* remove old marks */
if ( sxfti->mark_id != -1 ) {
- gnc_dense_cal_mark_remove( sxfti->example_cal, sxfti->mark_id );
+ //gnc_dense_cal_mark_remove( sxfti->example_cal, sxfti->mark_id );
sxfti->mark_id = -1;
}
if ( i > 0 ) {
@@ -748,10 +748,12 @@
name = gtk_editable_get_chars( GTK_EDITABLE(w), 0, -1 );
info = g_string_sized_new( 16 );
xaccFreqSpecGetFreqStr( fs, info );
+ /*
sxfti->mark_id =
gnc_dense_cal_mark( sxfti->example_cal,
i, sxfti->cal_marks,
- name, info->str );
+ name, info->str );*/
+ sxfti->mark_id = -1;
gtk_widget_queue_draw( GTK_WIDGET(sxfti->example_cal) );
g_free( name );
g_string_free( info, TRUE );
Modified: gnucash/branches/sx-cleanup/src/gnome/gnc-plugin-page-sx-list.c
===================================================================
--- gnucash/branches/sx-cleanup/src/gnome/gnc-plugin-page-sx-list.c 2006-07-26 02:36:53 UTC (rev 14565)
+++ gnucash/branches/sx-cleanup/src/gnome/gnc-plugin-page-sx-list.c 2006-07-26 03:11:36 UTC (rev 14566)
@@ -36,6 +36,7 @@
#include "config.h"
#include <gtk/gtk.h>
+#include <glib.h>
#include <glib/gi18n.h>
#include <glade/glade-xml.h>
#ifndef HAVE_GLIB26
@@ -60,6 +61,7 @@
#define PLUGIN_PAGE_SX_LIST_CM_CLASS "plugin-page-sx-list"
#define GCONF_SECTION "window/pages/sx_list"
+typedef struct _GncSxInstanceDenseCalAdapter GncSxInstanceDenseCalAdapter;
typedef struct _GncSxInstanceModel GncSxInstanceModel;
typedef struct _GncSxListTreeModelAdapter GncSxListTreeModelAdapter;
@@ -70,6 +72,7 @@
gint gppsl_event_handler_id;
GladeXML* gxml;
+ GncSxInstanceDenseCalAdapter *dense_cal_model;
GncDenseCal* gdcal;
GncSxInstanceModel* instances;
@@ -83,6 +86,8 @@
static GObjectClass *parent_class = NULL;
+/* ------------------------------------------------------------ */
+
struct _GncSxInstanceModel
{
GObject parent;
@@ -90,21 +95,23 @@
/* private */
gint qof_event_handler_id;
- // signals
- //void (*added)(GncSxInstance *sx); // gpointer user_data
- //void (*removed)(GncSxInstance *sx); // gpointer user_data
- //void (*changed)(GncSxInstance *inst); // gpointer user_data
+ /* signals */
+ /* void (*added)(GncSxInstance *sx); // gpointer user_data */
+ /* void (*removed)(GncSxInstance *sx); // gpointer user_data */
+ /* void (*changed)(GncSxInstance *inst); // gpointer user_data */
/* public */
GDate range_end;
- GList *sx_instance_list; // <GncSxInstances*>
+ GList *sx_instance_list; /* <GncSxInstances*> */
};
typedef struct _GncSxInstanceModelClass
{
GObjectClass parent;
+ guint removing_signal_id;
guint updated_signal_id;
+ guint added_signal_id;
} GncSxInstanceModelClass;
typedef struct _GncSxInstances
@@ -150,11 +157,40 @@
/* ------------------------------------------------------------ */
+typedef struct _GncSxInstanceDenseCalAdapterClass
+{
+ GObjectClass parent;
+} GncSxInstanceDenseCalAdapterClass;
+
+struct _GncSxInstanceDenseCalAdapter
+{
+ GObject parent;
+
+ GncSxInstanceModel *instances;
+};
+
+GncSxInstanceDenseCalAdapter* gnc_sx_instance_dense_cal_adapter_new(GncSxInstanceModel *instances);
+GType gnc_sx_instance_dense_cal_adapter_get_type(void);
+static GList* gsidca_get_contained(GncDenseCalModel *model);
+static gchar* gsidca_get_name(GncDenseCalModel *model, guint tag);
+static gchar* gsidca_get_info(GncDenseCalModel *model, guint tag);
+static gint gsidca_get_instance_count(GncDenseCalModel *model, guint tag);
+static void gsidca_get_instance(GncDenseCalModel *model, guint tag, gint instance_index, GDate *date);
+
+#define GNC_TYPE_SX_INSTANCE_DENSE_CAL_ADAPTER (gnc_sx_instance_dense_cal_adapter_get_type ())
+#define GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_SX_INSTANCE_DENSE_CAL_ADAPTER, GncSxInstanceDenseCalAdapter))
+#define GNC_SX_INSTANCE_DENSE_CAL_ADAPTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_SX_INSTANCE_DENSE_CAL_ADAPTER, GncSxInstanceDenseCalAdapterClass))
+#define GNC_IS_SX_INSTANCE_DENSE_CAL_ADAPTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_SX_INSTANCE_DENSE_CAL_ADAPTER))
+#define GNC_IS_SX_INSTANCE_DENSE_CAL_ADAPTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_SX_INSTANCE_DENSE_CAL_ADAPTER))
+#define GNC_SX_INSTANCE_DENSE_CAL_ADAPTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_SX_INSTANCE_DENSE_CAL_ADAPTER, GncSxInstanceDenseCalAdapterClass))
+
+/* ------------------------------------------------------------ */
+
struct _GncSxListTreeModelAdapter
{
GObject parent;
- /* private */
+ /* protected */
GncSxInstanceModel *instances;
GtkTreeStore *real;
};
@@ -313,7 +349,7 @@
gnc_plugin_page_sx_list_actions,
gnc_plugin_page_sx_list_n_actions,
plugin_page);
- //gnc_plugin_init_short_names (action_group, toolbar_labels);
+ /* gnc_plugin_init_short_names (action_group, toolbar_labels); */
LEAVE("page %p, priv %p, action group %p",
plugin_page, priv, action_group);
@@ -448,10 +484,13 @@
{
GtkWidget *w;
- w = glade_xml_get_widget(priv->gxml, "upcoming_cal_hbox");
- priv->gdcal = GNC_DENSE_CAL(gnc_dense_cal_new());
+
+ 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)));
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);
}
@@ -462,8 +501,8 @@
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;
}
@@ -494,10 +533,10 @@
static void
gppsl_event_handler(QofEntity *ent, QofEventId event_type, gpointer user_data, gpointer evt_data)
{
- // if (type != SX)
- // return;
- // - correlate SX to tree_store data
- // - update || add || remove
+ /* if (type != SX)
+ return; */
+ /* - correlate SX to tree_store data */
+ /* - update || add || remove */
return;
}
@@ -530,7 +569,7 @@
#if 0
gnc_tree_view_account_save(GNC_TREE_VIEW_ACCOUNT(priv->tree_view),
&priv->fd, key_file, group_name);
-#endif // 0
+#endif /* 0 */
LEAVE(" ");
}
@@ -566,7 +605,7 @@
#if 0
gnc_tree_view_account_restore(GNC_TREE_VIEW_ACCOUNT(priv->tree_view),
&priv->fd, key_file, group_name);
-#endif // 0
+#endif /* 0 */
LEAVE(" ");
return GNC_PLUGIN_PAGE(page);
}
@@ -666,7 +705,7 @@
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);
@@ -690,7 +729,7 @@
g_list_free(selected_paths);
}
-#if 0 // compare/sort fns
+#if 0 /* compare/sort fns */
static gint
gnc_sxd_clist_compare_sx_name( GtkCList *cl, gconstpointer a, gconstpointer b )
{
@@ -763,7 +802,7 @@
return g_date_compare( &gda, &gdb );
}
-#endif // 0 - compare/sort fns
+#endif /* 0 - compare/sort fns */
/* ------------------------------------------------------------ */
@@ -784,12 +823,12 @@
remind_end = creation_end;
g_date_add_days(&remind_end, xaccSchedXactionGetAdvanceReminder(sx));
- // postponed
+ /* postponed */
{
- // @@fixme - defer list.
+ /* @@fixme - defer list. */
}
- // to-create
+ /* to-create */
g_date_clear(&cur_date, 1);
sequence_ctx = gnc_sx_create_temporal_state(sx);
cur_date = xaccSchedXactionGetInstanceAfter(sx, &cur_date, sequence_ctx);
@@ -799,34 +838,30 @@
&& (g_date_compare(&cur_date, &creation_end) <= 0))
{
GncSxInstance *inst;
- char str[64];
- g_date_strftime(str, 64, "%c", &cur_date);
-
inst = g_new0(GncSxInstance, 1);
inst->parent = instances;
inst->type = TO_CREATE;
g_date_clear(&inst->date, 1);
inst->date = cur_date;
+
instances->upcoming = g_list_append(instances->upcoming, inst);
gnc_sx_incr_temporal_state(sx, sequence_ctx);
cur_date = xaccSchedXactionGetInstanceAfter(sx, &cur_date, sequence_ctx);
}
- // reminders
+ /* reminders */
while (g_date_valid(&cur_date) && g_date_compare(&cur_date, &remind_end) <= 0)
{
GncSxInstance *inst;
- char str[64];
- g_date_strftime(str, 64, "%c", &cur_date);
-
inst = g_new0(GncSxInstance, 1);
inst->parent = instances;
inst->type = REMINDER;
g_date_clear(&inst->date, 1);
inst->date = cur_date;
- instances->upcoming = g_list_append(instances->upcoming, inst);
+ instances->remind = g_list_append(instances->remind, inst);
+
gnc_sx_incr_temporal_state(sx, sequence_ctx);
cur_date = xaccSchedXactionGetInstanceAfter(sx, &cur_date, sequence_ctx);
}
@@ -899,16 +934,40 @@
object_class->dispose = gnc_sx_instance_model_dispose;
object_class->finalize = gnc_sx_instance_model_finalize;
+ klass->removing_signal_id =
+ g_signal_new("removing",
+ GNC_TYPE_SX_INSTANCE_MODEL,
+ G_SIGNAL_RUN_FIRST,
+ 0, /* class offset */
+ NULL, /* accumulator */
+ NULL, /* accum data */
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER);
+
klass->updated_signal_id =
g_signal_new("updated",
GNC_TYPE_SX_INSTANCE_MODEL,
G_SIGNAL_RUN_FIRST,
- 0, // class offset
- NULL, // accumulator
- NULL, // accum data
+ 0, /* class offset */
+ NULL, /* accumulator */
+ NULL, /* accum data */
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0, NULL);
+
+ klass->added_signal_id =
+ g_signal_new("added",
+ GNC_TYPE_SX_INSTANCE_MODEL,
+ G_SIGNAL_RUN_FIRST,
+ 0, /* class offset */
+ NULL, /* accumulator */
+ NULL, /* accum data */
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER);
}
static void
@@ -926,11 +985,11 @@
{
GncSxInstanceModel *instances = GNC_SX_INSTANCE_MODEL(user_data);
- // selection rules {
+ /* selection rules {
// (gnc_collection_get_schedxaction_list(book), GNC_EVENT_ITEM_ADDED)
// (gnc_collection_get_schedxaction_list(book), GNC_EVENT_ITEM_REMOVED)
// (GNC_IS_SX(ent), QOF_EVENT_MODIFIED)
- // }
+ // } */
if (!(GNC_IS_SX(ent) || GNC_IS_SXES(ent)))
return;
@@ -940,7 +999,7 @@
sx = GNC_SX(ent);
if (event_type & QOF_EVENT_MODIFY)
{
- // @re-generate instance, update
+ /* @re-generate instance, update*/
}
/* else { unsupported event type; ignore } */
}
@@ -955,7 +1014,7 @@
gpointer sx_instance_to_remove = NULL;
GList *list;
- // find, remove, update
+ /* find, remove, update */
for (list = instances->sx_instance_list; list != NULL; list = list->next)
{
if (sx == ((GncSxInstances*)list->data)->sx)
@@ -966,24 +1025,203 @@
}
if (sx_instance_to_remove != NULL)
{
+ g_signal_emit_by_name(instances, "removing", GUINT_TO_POINTER(GPOINTER_TO_UINT(((GncSxInstances*)sx_instance_to_remove)->sx)));
instances->sx_instance_list = g_list_remove(instances->sx_instance_list, sx_instance_to_remove);
- g_signal_emit_by_name(instances, "updated");
+ g_signal_emit_by_name(instances, "updated"); // @@fixme remove
}
else { printf("err\n"); }
}
else if (event_type & GNC_EVENT_ITEM_ADDED)
{
- // generate instances, add to instance list, emit update.
+ /* generate instances, add to instance list, emit update. */
instances->sx_instance_list
= g_list_append(instances->sx_instance_list,
(*_gnc_sx_gen_instances)((gpointer)sx, (gpointer)&instances->range_end));
- g_signal_emit_by_name(instances, "updated");
+ g_signal_emit_by_name(instances, "added", GUINT_TO_POINTER(GPOINTER_TO_UINT(sx)));
+ g_signal_emit_by_name(instances, "updated"); // @fixme remove
}
- // else { printf("unsupported event type [%d]\n", event_type); }
+ /* else { printf("unsupported event type [%d]\n", event_type); } */
}
}
+/* ------------------------------------------------------------ */
+static void
+gnc_sx_instance_dense_cal_adapter_class_init(GncSxInstanceDenseCalAdapterClass *klass)
+{
+ ; /* nop */
+}
+
+static void
+gnc_sx_instance_dense_cal_adapter_init(GTypeInstance *instance, gpointer klass)
+{
+ /*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;
+}
+
+static void
+gsidca_instances_added_cb(GncSxInstanceModel *model, gpointer instance_added, gpointer user_data)
+{
+ GncSxInstanceDenseCalAdapter *adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(user_data);
+ g_signal_emit_by_name(adapter, "added", GPOINTER_TO_UINT(instance_added));
+}
+
+static void
+gsidca_instances_updated_cb(GncSxInstanceModel *model, gpointer user_data)
+{
+ GncSxInstanceDenseCalAdapter *adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(user_data);
+ // @@fixme figure out which; emit appropriate signal.
+ GList *exposed_tags;
+ printf("instances updated\n");
+ for (exposed_tags = gsidca_get_contained(GNC_DENSE_CAL_MODEL(adapter)); exposed_tags != NULL; exposed_tags = exposed_tags->next)
+ {
+ g_signal_emit_by_name(adapter, "update", GPOINTER_TO_UINT(exposed_tags->data));
+ }
+}
+
+static void
+gsidca_instances_removing_cb(GncSxInstanceModel *model, gpointer instance_to_be_removed, gpointer user_data)
+{
+ GncSxInstanceDenseCalAdapter *adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(user_data);
+ printf("removing instance...\n");
+ g_signal_emit_by_name(adapter, "removing", GPOINTER_TO_UINT(instance_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_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 */
+ };
+
+ 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);
+}
+
+static GList*
+gsidca_get_contained(GncDenseCalModel *model)
+{
+ GncSxInstanceDenseCalAdapter *adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(model);
+ //"removing return 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;
+ 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);
+}
+
+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;
+}
+
+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->upcoming);
+}
+
+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->upcoming, instance_index);
+ g_date_valid(&inst->date);
+ *date = inst->date;
+ g_date_valid(date);
+}
+
/* ------------------------------------------------------------ */
GType
@@ -1021,7 +1259,7 @@
static void
gnc_sx_list_tree_model_adapter_class_init(GncSxListTreeModelAdapterClass *klass)
{
- ; // nop
+ ; /* nop */
}
static GtkTreeModelFlags
Modified: gnucash/branches/sx-cleanup/src/gnome-utils/gnc-dense-cal.c
===================================================================
--- gnucash/branches/sx-cleanup/src/gnome-utils/gnc-dense-cal.c 2006-07-26 02:36:53 UTC (rev 14565)
+++ gnucash/branches/sx-cleanup/src/gnome-utils/gnc-dense-cal.c 2006-07-26 03:11:36 UTC (rev 14566)
@@ -1,6 +1,6 @@
/********************************************************************\
* gnc-dense-cal.c : a custom densely-dispalyed calendar widget *
- * Copyright (C) 2002 Joshua Sled <jsled at asynchronous.org> *
+ * Copyright (C) 2002,2006 Joshua Sled <jsled at asynchronous.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
@@ -23,6 +23,7 @@
#include "config.h"
#include <gtk/gtk.h>
+#include <glib.h>
#include <glib/gi18n.h>
#include "glib-compat.h"
#include <math.h>
@@ -32,6 +33,231 @@
/* For PERR, only... */
#include "gnc-engine.h"
+enum { GDCM_ADDED, GDCM_UPDATE, GDCM_REMOVE, LAST_SIGNAL };
+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;
+
+ 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_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;
+ }
+}
+
+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;
+}
+
+GList*
+gnc_dense_cal_model_get_contained(GncDenseCalModel *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);
+}
+
+gchar*
+gnc_dense_cal_model_get_info(GncDenseCalModel *model, guint 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);
+}
+
+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);
+}
+
+/* ------------------------------------------------------------ */
+
+static GList* gdctm_get_contained(GncDenseCalModel *model);
+static gchar* gdctm_get_name(GncDenseCalModel *model, guint tag);
+static gchar* gdctm_get_info(GncDenseCalModel *model, guint tag);
+static gint gdctm_get_instance_count(GncDenseCalModel *model, guint tag);
+static void gdctm_get_instance(GncDenseCalModel *model, guint tag, gint instance_index, GDate *date);
+
+static void
+gnc_dense_cal_transient_dense_cal_model_iface_init(gpointer g_iface, gpointer iface_data)
+{
+ GncDenseCalModelIface *iface = (GncDenseCalModelIface*)g_iface;
+ iface->get_contained = gdctm_get_contained;
+ iface->get_name = gdctm_get_name;
+ iface->get_info = gdctm_get_info;
+ iface->get_instance_count = gdctm_get_instance_count;
+ iface->get_instance = gdctm_get_instance;
+}
+
+GType
+gnc_dense_cal_transient_model_get_type(void)
+{
+ static GType type = 0;
+ if (type == 0)
+ {
+ static const GTypeInfo info = {
+ sizeof (GncDenseCalTransientModel),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ NULL, /* class_init */
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ 0,
+ 0, /* n_preallocs */
+ NULL /* instance_init */
+ };
+ static const GInterfaceInfo iDenseCalModelInfo = {
+ (GInterfaceInitFunc)gnc_dense_cal_transient_dense_cal_model_iface_init,
+ NULL, /* interface finalize */
+ NULL, /* interface data */
+ };
+ type = g_type_register_static(G_TYPE_OBJECT, "GncDenseCalTransientModel", &info, 0);
+ g_type_add_interface_static(type,
+ GNC_TYPE_DENSE_CAL_MODEL,
+ &iDenseCalModelInfo);
+ }
+ return type;
+}
+
+GncDenseCalTransientModel*
+gnc_dense_cal_transient_model_new(gchar *name, gchar *info, int num_marks)
+{
+ GncDenseCalTransientModel *model = g_object_new(GNC_TYPE_DENSE_CAL_TRANSIENT_MODEL, NULL);
+ model->name = name;
+ model->info = info;
+ model->num_marks = num_marks;
+ model->cal_marks = g_new0(GDate*, num_marks);
+ return model;
+}
+
+void
+gnc_dense_cal_transient_model_update_no_end(GDate *start, FreqSpec *fs)
+{
+ // emit_by_name("update");
+}
+
+void
+gnc_dense_cal_transient_model_update_count_end(GDate *start, FreqSpec *fs, int numOccur)
+{
+ // emit_by_name("update");
+}
+
+void
+gnc_dense_cal_transient_model_update_date_end(GDate *start, FreqSpec *fs, GDate *endDate)
+{
+ // emit_by_name("update");
+}
+
+static GList*
+gdctm_get_contained(GncDenseCalModel *model)
+{
+ GList *rtn = NULL;
+ rtn = g_list_append(rtn, GUINT_TO_POINTER(1));
+ return rtn;
+}
+
+static gchar*
+gdctm_get_name(GncDenseCalModel *model, guint tag)
+{
+ GncDenseCalTransientModel *mdl = GNC_DENSE_CAL_TRANSIENT_MODEL(model);
+ // assert(tag == 1)
+ return mdl->name;
+}
+
+static gchar*
+gdctm_get_info(GncDenseCalModel *model, guint tag)
+{
+ GncDenseCalTransientModel *mdl = GNC_DENSE_CAL_TRANSIENT_MODEL(model);
+ // assert(tag == 1)
+ return mdl->info;
+}
+
+static gint
+gdctm_get_instance_count(GncDenseCalModel *model, guint tag)
+{
+ GncDenseCalTransientModel *mdl = GNC_DENSE_CAL_TRANSIENT_MODEL(model);
+ // assert(tag == 1)
+ return mdl->num_marks;
+}
+
+static void
+gdctm_get_instance(GncDenseCalModel *model, guint tag, gint instance_index, GDate *date)
+{
+ GncDenseCalTransientModel *mdl = GNC_DENSE_CAL_TRANSIENT_MODEL(model);
+ // assert(tag == 1)
+ // assert 0 < instance_index < model->num_marks;
+ *date = *mdl->cal_marks[instance_index];
+}
+
+/* ------------------------------------------------------------ */
+
/**
* Todo:
* . marking
@@ -84,16 +310,6 @@
static const gchar* MARK_COLOR = "Yellow";
-static const gchar* MARKS_LOST_SIGNAL_NAME = "marks_lost";
-
-/* SIGNALS */
-enum gnc_dense_cal_signal_enum {
- MARKS_LOST_SIGNAL,
- LAST_SIGNAL
-};
-
-static guint gnc_dense_cal_signals[LAST_SIGNAL] = { 0 };
-
static QofLogModule log_module = GNC_MOD_SX;
static void gnc_dense_cal_class_init (GncDenseCalClass *class);
@@ -154,6 +370,13 @@
static void doc_coords( GncDenseCal *dcal, int dayOfCal,
int *x1, int *y1, int *x2, int *y2 );
+static void gdc_mark_add(GncDenseCal *dcal, guint tag, gchar *name, gchar *info, guint size, GDate **dateArray);
+static void gdc_mark_remove(GncDenseCal *dcal, guint mark_to_remove);
+
+static void gdc_add_tag_markings(GncDenseCal *cal, guint tag);
+static void gdc_add_markings(GncDenseCal *cal);
+static void gdc_remove_markings(GncDenseCal *cal);
+
static GtkWidgetClass *parent_class = NULL;
/*static const gchar* MONTH_NAMES[] = {
@@ -236,16 +459,6 @@
parent_class = g_type_class_peek_parent (klass);
- gnc_dense_cal_signals[MARKS_LOST_SIGNAL] =
- g_signal_new (MARKS_LOST_SIGNAL_NAME,
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GncDenseCalClass, marks_lost_cb),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
object_class->finalize = gnc_dense_cal_finalize;
object_class->dispose = gnc_dense_cal_dispose;
@@ -396,6 +609,14 @@
return GTK_WIDGET (dcal);
}
+GtkWidget*
+gnc_dense_cal_new_with_model(GncDenseCalModel *model)
+{
+ GncDenseCal *cal = GNC_DENSE_CAL(gnc_dense_cal_new());
+ gnc_dense_cal_set_model(cal, model);
+ return GTK_WIDGET(cal);
+}
+
static void
recompute_first_of_month_offset( GncDenseCal *dcal )
{
@@ -687,7 +908,10 @@
createNew:
dcal->numMarks = num_weeks(dcal) * 7;
dcal->marks = g_new0( GList*, dcal->numMarks );
- g_signal_emit_by_name( dcal, MARKS_LOST_SIGNAL_NAME );
+ if (dcal->model)
+ {
+ gdc_add_markings(dcal);
+ }
}
static void
@@ -892,8 +1116,6 @@
int i;
int x1, x2, y1, y2;
GdkColor markColor, black;
- GList *l;
- gdc_mark_data *gdcmd;
gdk_color_parse( MARK_COLOR, &markColor );
gdk_colormap_alloc_color( gdk_colormap_get_system(), &markColor, TRUE, TRUE );
@@ -902,13 +1124,13 @@
/* FIXME: use a different GC for this */
gdk_gc_set_foreground( widget->style->fg_gc[widget->state], &markColor );
for ( i=0; i<dcal->numMarks; i++ ) {
- for ( l = dcal->marks[i]; l ; l = l->next ) {
- gdcmd = (gdc_mark_data*)l->data;
- doc_coords( dcal, i, &x1, &y1, &x2, &y2 );
- gdk_draw_rectangle( dcal->drawbuf,
- widget->style->fg_gc[widget->state],
- TRUE, x1, y1, (x2-x1), (y2-y1) );
- }
+ if (dcal->marks[i] != NULL)
+ {
+ doc_coords( dcal, i, &x1, &y1, &x2, &y2 );
+ gdk_draw_rectangle( dcal->drawbuf,
+ widget->style->fg_gc[widget->state],
+ TRUE, x1, y1, (x2-x1), (y2-y1) );
+ }
}
gdk_gc_set_foreground( widget->style->fg_gc[widget->state], &black );
}
@@ -1529,9 +1751,10 @@
/* soc == start-of-calendar */
GDate soc;
+ g_date_clear(&soc, 1);
g_date_set_dmy( &soc, 1, dcal->month, dcal->year );
/* ensure not before calendar start. */
- if ( g_date_get_julian(d) < g_date_get_julian(&soc) ) {
+ if (g_date_get_julian(d) < g_date_get_julian(&soc)) {
return -1;
}
/* do computation here, since we're going to change the
@@ -1546,13 +1769,110 @@
return toRet;
}
+static void
+gdc_add_tag_markings(GncDenseCal *cal, guint tag)
+{
+ gchar *name, *info;
+ gint num_marks, idx;
+ GDate **dates;
+
+ // copy the values into the old marking function.
+ name = gnc_dense_cal_model_get_name(cal->model, tag);
+ info = gnc_dense_cal_model_get_info(cal->model, tag);
+ num_marks = gnc_dense_cal_model_get_instance_count(cal->model, tag);
+ dates = g_new0(GDate*, num_marks);
+ for (idx = 0; idx < num_marks; idx++)
+ {
+ dates[idx] = g_date_new();
+ gnc_dense_cal_model_get_instance(cal->model, tag, idx, dates[idx]);
+ }
+
+ gdc_mark_add(cal, tag, name, info, num_marks, dates);
+
+ for (idx = 0; idx < num_marks; idx++)
+ {
+ g_date_free(dates[idx]);
+ }
+ g_free(dates);
+}
+
+static void
+gdc_add_markings(GncDenseCal *cal)
+{
+ GList *tags;
+ tags = gnc_dense_cal_model_get_contained(cal->model);
+ for (; tags != NULL; tags = tags->next)
+ {
+ guint tag = GPOINTER_TO_UINT(tags->data);
+ gdc_add_tag_markings(cal, tag);
+ }
+}
+
+static void
+gdc_remove_markings(GncDenseCal *cal)
+{
+ GList *tags;
+ tags = gnc_dense_cal_model_get_contained(cal->model);
+ for (; tags != NULL; tags = tags->next)
+ {
+ guint tag = GPOINTER_TO_UINT(tags->data);
+ gdc_mark_remove(cal, tag);
+ }
+}
+
+static void
+gdc_model_added_cb(GncDenseCalModel *model, guint added_tag, gpointer user_data)
+{
+ GncDenseCal *cal = GNC_DENSE_CAL(user_data);
+ printf("gdc_model_added_cb update\n");
+ gdc_add_tag_markings(cal, added_tag);
+}
+
+static void
+gdc_model_update_cb(GncDenseCalModel *model, guint update_tag, gpointer user_data)
+{
+ GncDenseCal *cal = GNC_DENSE_CAL(user_data);
+ printf("gdc_model_update_cb update for tag [%d]\n", update_tag);
+ gdc_mark_remove(cal, update_tag);
+ gdc_add_tag_markings(cal, update_tag);
+}
+
+static void
+gdc_model_removing_cb(GncDenseCalModel *model, guint remove_tag, gpointer user_data)
+{
+ GncDenseCal *cal = GNC_DENSE_CAL(user_data);
+ printf("gdc_model_removing_cb update [%d]\n", remove_tag);
+ gdc_mark_remove(cal, remove_tag);
+}
+
+void
+gnc_dense_cal_set_model(GncDenseCal *cal, GncDenseCalModel *model)
+{
+ if (cal->model != NULL)
+ {
+ gdc_remove_markings(cal);
+ // g_object_unref(cal->model);
+ cal->model = NULL;
+ }
+ cal->model = model;
+ //g_object_ref(model);
+ g_signal_connect(G_OBJECT(cal->model), "added", (GCallback)gdc_model_added_cb, cal);
+ g_signal_connect(G_OBJECT(cal->model), "update", (GCallback)gdc_model_update_cb, cal);
+ g_signal_connect(G_OBJECT(cal->model), "removing", (GCallback)gdc_model_removing_cb, cal);
+
+ gdc_add_markings(cal);
+}
+
/**
* Marks the given array of GDate*s on the calendar with the given name.
**/
-guint
-gnc_dense_cal_mark( GncDenseCal *dcal,
- guint size, GDate **dateArray,
- gchar *name, gchar *info )
+static void
+gdc_mark_add(GncDenseCal *dcal,
+ guint tag,
+ gchar *name,
+ gchar *info,
+ guint size,
+ GDate **dateArray)
{
guint i;
gint doc;
@@ -1561,7 +1881,7 @@
if ( size == 0 ) {
PERR( "0 size not allowed\n" );
- return -1;
+ return;
}
newMark = g_new0( gdc_mark_data, 1 );
@@ -1573,8 +1893,9 @@
if ( info ) {
newMark->info = g_strdup(info);
}
- newMark->tag = dcal->lastMarkTag++;
+ newMark->tag = tag;
newMark->ourMarks = NULL;
+ printf("saving mark with tag [%d]\n", newMark->tag);
for ( i=0; i<size; i++ ) {
d = dateArray[i];
@@ -1594,11 +1915,10 @@
dcal->markData = g_list_append( dcal->markData, (gpointer)newMark );
gnc_dense_cal_draw_to_buffer( dcal );
gtk_widget_queue_draw( GTK_WIDGET( dcal ) );
- return newMark->tag;
}
-void
-gnc_dense_cal_mark_remove( GncDenseCal *dcal, guint markToRemove )
+static void
+gdc_mark_remove(GncDenseCal *dcal, guint markToRemove)
{
GList *l, *calMarkL;
gint doc;
@@ -1616,12 +1936,15 @@
if ( gdcmd->tag == markToRemove )
break;
}
- g_assert( l != NULL );
if ( l == NULL ) {
DEBUG( "l == null" );
return;
}
- g_assert( gdcmd != NULL );
+ if (gdcmd == NULL)
+ {
+ DEBUG("gdcmd == null");
+ return;
+ }
l = NULL;
for ( calMarkL = gdcmd->ourMarks;
Modified: gnucash/branches/sx-cleanup/src/gnome-utils/gnc-dense-cal.h
===================================================================
--- gnucash/branches/sx-cleanup/src/gnome-utils/gnc-dense-cal.h 2006-07-26 02:36:53 UTC (rev 14565)
+++ gnucash/branches/sx-cleanup/src/gnome-utils/gnc-dense-cal.h 2006-07-26 03:11:36 UTC (rev 14566)
@@ -1,9 +1,6 @@
-#ifndef _DENSECAL_H_
-#define _DENSECAL_H_
-
/********************************************************************\
* gnc-dense-cal.h : a custom densely-dispalyed calendar widget *
- * Copyright (C) 2002 Joshua Sled <jsled at asynchronous.org> *
+ * Copyright (C) 2002,2006 Joshua Sled <jsled at asynchronous.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
@@ -23,15 +20,115 @@
* Boston, MA 02110-1301, USA gnu at gnu.org *
\********************************************************************/
+#ifndef _DENSECAL_H_
+#define _DENSECAL_H_
+
#include <gdk/gdk.h>
#include <gtk/gtkadjustment.h>
#include <gtk/gtkwidget.h>
#include <glib.h>
+#include <FreqSpec.h>
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+G_BEGIN_DECLS
+#define GNC_TYPE_DENSE_CAL_MODEL (gnc_dense_cal_model_get_type())
+#define GNC_DENSE_CAL_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_DENSE_CAL_MODEL, GncDenseCalModel))
+#define GNC_IS_DENSE_CAL_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_DENSE_CAL_MODEL))
+#define GNC_DENSE_CAL_MODEL_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GNC_TYPE_DENSE_CAL_MODEL, GncDenseCalModelIface))
+
+typedef struct _GncDenseCalModel GncDenseCalModel; /* non existant */
+typedef struct _GncDenseCalModelIface GncDenseCalModelIface;
+
+struct _GncDenseCalModelIface
+{
+ GTypeInterface parent;
+
+ /* 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);
+};
+
+GType gnc_dense_cal_model_get_type(void);
+
+/* @fixme: glist mem alloc policy... ? */
+GList* gnc_dense_cal_model_get_contained(GncDenseCalModel *model);
+gchar* gnc_dense_cal_model_get_name(GncDenseCalModel *model, guint tag);
+gchar* gnc_dense_cal_model_get_info(GncDenseCalModel *model, guint tag);
+gint gnc_dense_cal_model_get_instance_count(GncDenseCalModel *model, guint tag);
+void gnc_dense_cal_model_get_instance(GncDenseCalModel *model, guint tag, gint instance_index, GDate *date);
+
+/* ------------------------------------------------------------ */
+#define GNC_TYPE_DENSE_CAL_TRANSIENT_MODEL (gnc_dense_cal_transient_model_get_type())
+#define GNC_DENSE_CAL_TRANSIENT_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_DENSE_CAL_TRANSIENT_MODEL, GncDenseCalTransientModel))
+#define GNC_DENSE_CAL_TRANSIENT_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_DENSE_CAL_TRANSIENT_MODEL, GncDenseCalTransientModelClass))
+#define GNC_IS_DENSE_CAL_TRANSIENT_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_DENSE_CAL_TRANSIENT_MODEL))
+#define GNC_IS_DENSE_CAL_TRANSIENT_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_DENSE_CAL_TRANSIENT_MODEL))
+#define GNC_DENSE_CAL_TRANSIENT_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_DENSE_CAL_TRANSIENT_MODEL, GncDenseCalTransientModel))
+
+typedef struct _GncDenseCalTransientModel
+{
+ GObject parent;
+ gchar *name;
+ gchar *info;
+ int num_marks;
+ GDate **cal_marks;
+} GncDenseCalTransientModel;
+
+typedef struct _GncDenseCalTransientModelClass
+{
+ GObjectClass parent_class;
+} GncDenseCalTransientModelClass;
+
+GType gnc_dense_cal_transient_model_get_type(void);
+GncDenseCalTransientModel* gnc_dense_cal_transient_model_new(gchar *name, gchar *info, int num_marks);
+void gnc_dense_cal_transient_model_update_no_end(GDate *start, FreqSpec *fs);
+void gnc_dense_cal_transient_model_update_count_end(GDate *start, FreqSpec *fs, int numOccur);
+void gnc_dense_cal_transient_model_update_date_end(GDate *start, FreqSpec *fs, GDate *endDate);
+
+/* ------------------------------------------------------------ */
+
+#if 0
+#define GNC_TYPE_DENSE_CAL_STORE (gnc_dense_cal_store_get_type())
+#define GNC_DENSE_CAL_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_DENSE_CAL_STORE, GncDenseCalStore))
+#define GNC_DENSE_CAL_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_DENSE_CAL_STORE, GncDenseCalStoreClass))
+#define GNC_IS_DENSE_CAL_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_DENSE_CAL_STORE))
+#define GNC_IS_DENSE_CAL_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_DENSE_CAL_STORE))
+#define GNC_DENSE_CAL_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_DENSE_CAL_STORE, GncDenseCalStore))
+
+typedef struct _GncDenseCalStore GncDenseCalStore;
+typedef struct _GncDenseCalStoreClass GncDenseCalStoreClass;
+
+struct _GncDenseCalStoreClass
+{
+ GObjectClass parent_class;
+};
+
+struct GncDenseCalStore
+{
+ GObject parent;
+};
+
+GType gnc_dense_cal_store_get_type(void);
+GncDenseCalStore *gnc_dense_cal_store_new(void);
+void gnc_dense_cal_store_clear(GncDenseCalStore *store);
+guint gnc_dense_cal_store_add(GncDenseCalStore *dcal,
+ gchar *name,
+ gchar *info,
+ guint size,
+ GDate **daysArray);
+void gnc_dense_cal_store_remove(GncDenseCalStore *dcal, guint markToRemove);
+#endif // 0
+
+/* ------------------------------------------------------------ */
+
#define GNC_TYPE_DENSE_CAL (gnc_dense_cal_get_type ())
#define GNC_DENSE_CAL(obj) GTK_CHECK_CAST (obj, gnc_dense_cal_get_type (), GncDenseCal)
#define GNC_DENSE_CAL_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gnc_dense_cal_get_type (), GncDenseCalClass)
@@ -92,6 +189,8 @@
guint label_height;
guint dayLabelHeight;
+ GncDenseCalModel *model;
+
guint lastMarkTag;
/**
@@ -108,7 +207,6 @@
struct _GncDenseCalClass
{
GtkWidgetClass parent_class;
- void (*marks_lost_cb)( GncDenseCal *dcal, gpointer user_data );
};
typedef struct _gdc_mark_data {
@@ -123,9 +221,12 @@
} gdc_mark_data;
GtkWidget* gnc_dense_cal_new (void);
+GtkWidget* gnc_dense_cal_new_with_model (GncDenseCalModel *model);
GType gnc_dense_cal_get_type (void);
-void gnc_dense_cal_set_month( GncDenseCal *dcal, GDateMonth mon );
+void gnc_dense_cal_set_model(GncDenseCal *cal, GncDenseCalModel *model);
+
+void gnc_dense_cal_set_month(GncDenseCal *dcal, GDateMonth mon);
/**
* @param year Julian year: 2000 = 2000AD.
**/
@@ -137,13 +238,13 @@
GDateMonth gnc_dense_cal_get_month( GncDenseCal *dcal );
GDateYear gnc_dense_cal_get_year( GncDenseCal *dcal );
+#if 0
guint gnc_dense_cal_mark( GncDenseCal *dcal,
guint size, GDate **daysArray,
gchar *name, gchar *info );
void gnc_dense_cal_mark_remove( GncDenseCal *dcal, guint markToRemove );
+#endif // 0
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+G_END_DECLS
#endif /* _DENSECAL_H_ */
More information about the gnucash-changes
mailing list