r14912 - gnucash/branches/sx-cleanup/src - Focus first unbound variable on SLR dialog "OK" with unbound variables.
Joshua Sled
jsled at cvs.gnucash.org
Sat Sep 30 12:56:42 EDT 2006
Author: jsled
Date: 2006-09-30 12:56:41 -0400 (Sat, 30 Sep 2006)
New Revision: 14912
Trac: http://svn.gnucash.org/trac/changeset/14912
Modified:
gnucash/branches/sx-cleanup/src/doc/sx.rst
gnucash/branches/sx-cleanup/src/gnome/dialog-sx-since-last-run.c
Log:
Focus first unbound variable on SLR dialog "OK" with unbound variables.
Modified: gnucash/branches/sx-cleanup/src/doc/sx.rst
===================================================================
--- gnucash/branches/sx-cleanup/src/doc/sx.rst 2006-09-30 15:14:23 UTC (rev 14911)
+++ gnucash/branches/sx-cleanup/src/doc/sx.rst 2006-09-30 16:56:41 UTC (rev 14912)
@@ -49,6 +49,7 @@
- [x] add mutation support to sx instance model
- [x] state machine
- [x] add variable state to sx instance model
+ - [ ] handle (hidden/system not for editing) variables.
- [x] add sx_upcoming_instance_model()
- [ ] add effect_auto_create()
- [/] add some sort of "ready to go" flag and api
Modified: gnucash/branches/sx-cleanup/src/gnome/dialog-sx-since-last-run.c
===================================================================
--- gnucash/branches/sx-cleanup/src/gnome/dialog-sx-since-last-run.c 2006-09-30 15:14:23 UTC (rev 14911)
+++ gnucash/branches/sx-cleanup/src/gnome/dialog-sx-since-last-run.c 2006-09-30 16:56:41 UTC (rev 14912)
@@ -657,27 +657,38 @@
}
}
-void
-gnc_sx_slr_model_change_variable(GncSxSlrTreeModelAdapter *model, GncSxInstance *instance, GncSxVariable *variable, gnc_numeric *new_value)
+static GtkTreePath*
+_get_path_for_variable(GncSxSlrTreeModelAdapter *model, GncSxInstance *instance, GncSxVariable *variable)
{
GList *variables;
+ int indices[3];
GtkTreePath *path;
- GtkTreeIter iter;
- int indices[3];
- GString *tmp_str;
indices[0] = g_list_index(model->instances->sx_instance_list, instance->parent);
if (indices[0] == -1)
- return;
+ return NULL;
indices[1] = g_list_index(instance->parent->list, instance);
if (indices[1] == -1)
- return;
+ return NULL;
variables = gnc_sx_instance_get_variables(instance);
indices[2] = g_list_index(variables, variable);
g_list_free(variables);
if (indices[2] == -1)
+ return NULL;
+ path = gtk_tree_path_new_from_indices(indices[0], indices[1], indices[2], -1);
+ return path;
+}
+
+void
+gnc_sx_slr_model_change_variable(GncSxSlrTreeModelAdapter *model, GncSxInstance *instance, GncSxVariable *variable, gnc_numeric *new_value)
+{
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ GString *tmp_str;
+
+ path = _get_path_for_variable(model, instance, variable);
+ if (path == NULL)
return;
- path = gtk_tree_path_new_from_indices(indices[0], indices[1], indices[2], -1);
gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path);
variable->value = *new_value;
@@ -894,21 +905,18 @@
GNCLedgerDisplay *ledger;
GncPluginPage *page;
Query *book_query, *guid_query, *query;
- GList *created_txn_guid_iter;
+ GList *guid_iter;
book_query = xaccMallocQuery();
guid_query = xaccMallocQuery();
xaccQuerySetBook(book_query, gnc_get_current_book());
- for (created_txn_guid_iter = created_txn_guids;
- created_txn_guid_iter != NULL;
- created_txn_guid_iter = created_txn_guid_iter->next)
+ for (guid_iter = created_txn_guids; guid_iter != NULL; guid_iter = guid_iter->next)
{
- xaccQueryAddGUIDMatch(guid_query, (GUID*)created_txn_guid_iter->data, GNC_ID_TRANS, QUERY_OR);
+ xaccQueryAddGUIDMatch(guid_query, (GUID*)guid_iter->data, GNC_ID_TRANS, QUERY_OR);
}
query = xaccQueryMerge(book_query, guid_query, QUERY_AND);
// inspired by dialog-find-transactions:do_find_cb:
- // do_find_cb (QueryNew *query, gpointer user_data, gpointer *result)
ledger = gnc_ledger_display_query(query, SEARCH_LEDGER, REG_STYLE_JOURNAL);
gnc_ledger_display_refresh(ledger);
page = gnc_plugin_page_register_new_ledger(ledger);
@@ -937,10 +945,22 @@
printf("%d variables unbound\n", g_list_length(unbound_variables));
if (g_list_length(unbound_variables) > 0)
{
- //printf("%d variables unbound\n", g_list_length(unbound_variables));
// focus first variable
- //GtkTreePath *variable_path = _get_path_for_variable(model, instance, variable);
- // gtk_tree_view_set_cursor(app_dialog->instance_view, );
+ GncSxSlrVariableNeeded *first_unbound;
+ GtkTreePath *variable_path;
+ GtkTreeViewColumn *variable_col;
+ gint variable_view_column = 2;
+ gboolean start_editing = TRUE;
+
+ first_unbound = (GncSxSlrVariableNeeded*)unbound_variables->data;
+ variable_path = _get_path_for_variable(app_dialog->editing_model, first_unbound->instance, first_unbound->variable);
+ variable_col = gtk_tree_view_get_column(app_dialog->instance_view, variable_view_column);
+
+ gtk_tree_view_set_cursor(app_dialog->instance_view, variable_path, variable_col, start_editing);
+
+ gtk_tree_path_free(variable_path);
+ g_list_foreach(unbound_variables, (GFunc)g_free, NULL);
+ g_list_free(unbound_variables);
return;
}
}
More information about the gnucash-changes
mailing list