mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Enabled SX UI support:
- Add a check-box to the SX list tree-view to show the SX enabled status. - Don't show non-enabled SX's on the SX dense calendar. Patch from Peter McAlpine <peter@aoeu.ca> git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15511 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
068540a938
commit
7a67941355
@ -82,8 +82,11 @@ gsidca_instances_added_cb(GncSxInstanceModel *model, SchedXaction *sx_added, gpo
|
||||
{
|
||||
GncSxInstanceDenseCalAdapter *adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(user_data);
|
||||
printf("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)
|
||||
@ -91,8 +94,15 @@ gsidca_instances_updated_cb(GncSxInstanceModel *model, SchedXaction *sx_updated,
|
||||
GncSxInstanceDenseCalAdapter *adapter = GNC_SX_INSTANCE_DENSE_CAL_ADAPTER(user_data);
|
||||
gnc_sx_instance_model_update_sx_instances(model, sx_updated);
|
||||
printf("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)
|
||||
@ -167,8 +177,11 @@ gsidca_get_contained(GncDenseCalModel *model)
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -362,6 +362,11 @@ gnc_plugin_page_sx_list_create_widget (GncPluginPage *plugin_page)
|
||||
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_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);
|
||||
|
@ -430,15 +430,30 @@ _next_occur_comparator(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpoi
|
||||
&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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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(4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
|
||||
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);
|
||||
@ -492,6 +507,7 @@ gsltma_populate_tree_store(GncSxListTreeModelAdapter *model)
|
||||
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->str,
|
||||
SXLTMA_COL_LAST_OCCUR, last_occur_date_buf,
|
||||
SXLTMA_COL_NEXT_OCCUR, next_occur_date_buf,
|
||||
|
@ -44,6 +44,7 @@ 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
|
||||
|
Loading…
Reference in New Issue
Block a user