r18791 - gnucash/trunk/src/gnome-utils - Re-indentation of source code, next batch: src/gnome-utils/*
Christian Stimming
cstim at code.gnucash.org
Tue Mar 2 16:42:14 EST 2010
Author: cstim
Date: 2010-03-02 16:42:11 -0500 (Tue, 02 Mar 2010)
New Revision: 18791
Trac: http://svn.gnucash.org/trac/changeset/18791
Modified:
gnucash/trunk/src/gnome-utils/QuickFill.c
gnucash/trunk/src/gnome-utils/QuickFill.h
gnucash/trunk/src/gnome-utils/account-quickfill.c
gnucash/trunk/src/gnome-utils/account-quickfill.h
gnucash/trunk/src/gnome-utils/cursors.c
gnucash/trunk/src/gnome-utils/dialog-account.c
gnucash/trunk/src/gnome-utils/dialog-account.h
gnucash/trunk/src/gnome-utils/dialog-book-close.c
gnucash/trunk/src/gnome-utils/dialog-commodity.c
gnucash/trunk/src/gnome-utils/dialog-commodity.h
gnucash/trunk/src/gnome-utils/dialog-file-access.c
gnucash/trunk/src/gnome-utils/dialog-options.c
gnucash/trunk/src/gnome-utils/dialog-options.h
gnucash/trunk/src/gnome-utils/dialog-preferences.c
gnucash/trunk/src/gnome-utils/dialog-preferences.h
gnucash/trunk/src/gnome-utils/dialog-query-list.c
gnucash/trunk/src/gnome-utils/dialog-query-list.h
gnucash/trunk/src/gnome-utils/dialog-reset-warnings.c
gnucash/trunk/src/gnome-utils/dialog-totd.c
gnucash/trunk/src/gnome-utils/dialog-totd.h
gnucash/trunk/src/gnome-utils/dialog-transfer.c
gnucash/trunk/src/gnome-utils/dialog-transfer.h
gnucash/trunk/src/gnome-utils/dialog-utils.c
gnucash/trunk/src/gnome-utils/dialog-utils.h
gnucash/trunk/src/gnome-utils/druid-gconf-setup.c
gnucash/trunk/src/gnome-utils/druid-gnc-xml-import.c
gnucash/trunk/src/gnome-utils/druid-utils.c
gnucash/trunk/src/gnome-utils/druid-utils.h
gnucash/trunk/src/gnome-utils/gnc-account-sel.c
gnucash/trunk/src/gnome-utils/gnc-account-sel.h
gnucash/trunk/src/gnome-utils/gnc-amount-edit.c
gnucash/trunk/src/gnome-utils/gnc-amount-edit.h
gnucash/trunk/src/gnome-utils/gnc-autosave.c
gnucash/trunk/src/gnome-utils/gnc-autosave.h
gnucash/trunk/src/gnome-utils/gnc-commodity-edit.c
gnucash/trunk/src/gnome-utils/gnc-commodity-edit.h
gnucash/trunk/src/gnome-utils/gnc-currency-edit.c
gnucash/trunk/src/gnome-utils/gnc-currency-edit.h
gnucash/trunk/src/gnome-utils/gnc-date-delta.c
gnucash/trunk/src/gnome-utils/gnc-date-delta.h
gnucash/trunk/src/gnome-utils/gnc-date-edit.c
gnucash/trunk/src/gnome-utils/gnc-date-edit.h
gnucash/trunk/src/gnome-utils/gnc-date-format.c
gnucash/trunk/src/gnome-utils/gnc-date-format.h
gnucash/trunk/src/gnome-utils/gnc-dense-cal-model.c
gnucash/trunk/src/gnome-utils/gnc-dense-cal-model.h
gnucash/trunk/src/gnome-utils/gnc-dense-cal-store.c
gnucash/trunk/src/gnome-utils/gnc-dense-cal-store.h
gnucash/trunk/src/gnome-utils/gnc-dense-cal.c
gnucash/trunk/src/gnome-utils/gnc-dense-cal.h
gnucash/trunk/src/gnome-utils/gnc-dialog.c
gnucash/trunk/src/gnome-utils/gnc-dialog.h
gnucash/trunk/src/gnome-utils/gnc-druid-gnome.c
gnucash/trunk/src/gnome-utils/gnc-druid-gnome.h
gnucash/trunk/src/gnome-utils/gnc-druid-provider-edge-gnome.c
gnucash/trunk/src/gnome-utils/gnc-druid-provider-edge-gnome.h
gnucash/trunk/src/gnome-utils/gnc-druid-provider-file-gnome.c
gnucash/trunk/src/gnome-utils/gnc-druid-provider-file-gnome.h
gnucash/trunk/src/gnome-utils/gnc-druid-provider-multifile-gnome.c
gnucash/trunk/src/gnome-utils/gnc-druid-provider-multifile-gnome.h
gnucash/trunk/src/gnome-utils/gnc-embedded-window.c
gnucash/trunk/src/gnome-utils/gnc-embedded-window.h
gnucash/trunk/src/gnome-utils/gnc-file.c
gnucash/trunk/src/gnome-utils/gnc-file.h
gnucash/trunk/src/gnome-utils/gnc-frequency.c
gnucash/trunk/src/gnome-utils/gnc-frequency.h
gnucash/trunk/src/gnome-utils/gnc-general-select.c
gnucash/trunk/src/gnome-utils/gnc-general-select.h
gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c
gnucash/trunk/src/gnome-utils/gnc-gnome-utils.h
gnucash/trunk/src/gnome-utils/gnc-gui-query.c
gnucash/trunk/src/gnome-utils/gnc-gui-query.h
gnucash/trunk/src/gnome-utils/gnc-icons.c
gnucash/trunk/src/gnome-utils/gnc-main-window.c
gnucash/trunk/src/gnome-utils/gnc-main-window.h
gnucash/trunk/src/gnome-utils/gnc-menu-extensions.c
gnucash/trunk/src/gnome-utils/gnc-menu-extensions.h
gnucash/trunk/src/gnome-utils/gnc-period-select.c
gnucash/trunk/src/gnome-utils/gnc-period-select.h
gnucash/trunk/src/gnome-utils/gnc-plugin-file-history.c
gnucash/trunk/src/gnome-utils/gnc-plugin-file-history.h
gnucash/trunk/src/gnome-utils/gnc-plugin-manager.c
gnucash/trunk/src/gnome-utils/gnc-plugin-manager.h
gnucash/trunk/src/gnome-utils/gnc-plugin-menu-additions.c
gnucash/trunk/src/gnome-utils/gnc-plugin-menu-additions.h
gnucash/trunk/src/gnome-utils/gnc-plugin-page.c
gnucash/trunk/src/gnome-utils/gnc-plugin-page.h
gnucash/trunk/src/gnome-utils/gnc-plugin.c
gnucash/trunk/src/gnome-utils/gnc-plugin.h
gnucash/trunk/src/gnome-utils/gnc-query-list.c
gnucash/trunk/src/gnome-utils/gnc-query-list.h
gnucash/trunk/src/gnome-utils/gnc-recurrence.c
gnucash/trunk/src/gnome-utils/gnc-splash.c
gnucash/trunk/src/gnome-utils/gnc-sx-instance-dense-cal-adapter.c
gnucash/trunk/src/gnome-utils/gnc-sx-instance-dense-cal-adapter.h
gnucash/trunk/src/gnome-utils/gnc-sx-list-tree-model-adapter.c
gnucash/trunk/src/gnome-utils/gnc-sx-list-tree-model-adapter.h
gnucash/trunk/src/gnome-utils/gnc-tree-model-account-types.c
gnucash/trunk/src/gnome-utils/gnc-tree-model-account-types.h
gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c
gnucash/trunk/src/gnome-utils/gnc-tree-model-account.h
gnucash/trunk/src/gnome-utils/gnc-tree-model-budget.c
gnucash/trunk/src/gnome-utils/gnc-tree-model-budget.h
gnucash/trunk/src/gnome-utils/gnc-tree-model-commodity.c
gnucash/trunk/src/gnome-utils/gnc-tree-model-commodity.h
gnucash/trunk/src/gnome-utils/gnc-tree-model-price.c
gnucash/trunk/src/gnome-utils/gnc-tree-model-price.h
gnucash/trunk/src/gnome-utils/gnc-tree-model-selection.c
gnucash/trunk/src/gnome-utils/gnc-tree-model-selection.h
gnucash/trunk/src/gnome-utils/gnc-tree-model.c
gnucash/trunk/src/gnome-utils/gnc-tree-model.h
gnucash/trunk/src/gnome-utils/gnc-tree-view-account.c
gnucash/trunk/src/gnome-utils/gnc-tree-view-account.h
gnucash/trunk/src/gnome-utils/gnc-tree-view-commodity.c
gnucash/trunk/src/gnome-utils/gnc-tree-view-commodity.h
gnucash/trunk/src/gnome-utils/gnc-tree-view-price.c
gnucash/trunk/src/gnome-utils/gnc-tree-view-price.h
gnucash/trunk/src/gnome-utils/gnc-tree-view-sx-list.c
gnucash/trunk/src/gnome-utils/gnc-tree-view.c
gnucash/trunk/src/gnome-utils/gnc-tree-view.h
gnucash/trunk/src/gnome-utils/gnc-window.c
gnucash/trunk/src/gnome-utils/gnc-window.h
gnucash/trunk/src/gnome-utils/gnctreemodelsort.c
gnucash/trunk/src/gnome-utils/gnctreemodelsort.h
gnucash/trunk/src/gnome-utils/gtktreedatalist.c
gnucash/trunk/src/gnome-utils/gtktreedatalist.h
gnucash/trunk/src/gnome-utils/misc-gnome-utils.c
gnucash/trunk/src/gnome-utils/print-session.c
gnucash/trunk/src/gnome-utils/search-param.c
gnucash/trunk/src/gnome-utils/search-param.h
gnucash/trunk/src/gnome-utils/test/test-gnc-dialog.c
gnucash/trunk/src/gnome-utils/test/test-link-module.c
gnucash/trunk/src/gnome-utils/window-main-summarybar.c
Log:
Re-indentation of source code, next batch: src/gnome-utils/*
This also strips trailing whitespaces from lines where they existed.
This re-indentation was done using astyle-1.24 using the following options:
astyle --indent=spaces=4 --brackets=break --pad-oper --pad-header --suffix=none
Modified: gnucash/trunk/src/gnome-utils/QuickFill.c
===================================================================
--- gnucash/trunk/src/gnome-utils/QuickFill.c 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/QuickFill.c 2010-03-02 21:42:11 UTC (rev 18791)
@@ -34,9 +34,9 @@
struct _QuickFill
{
- char *text; /* the first matching text string */
- int len; /* number of chars in text string */
- GHashTable *matches; /* array of children in the tree */
+ char *text; /* the first matching text string */
+ int len; /* number of chars in text string */
+ GHashTable *matches; /* array of children in the tree */
};
@@ -45,7 +45,7 @@
int depth, QuickFillSort sort);
static void gnc_quickfill_remove_recursive (QuickFill *qf, const gchar *text,
- gint depth, QuickFillSort sort);
+ gint depth, QuickFillSort sort);
/* This static indicates the debugging module that this .o belongs to. */
static QofLogModule log_module = GNC_MOD_REGISTER;
@@ -56,22 +56,22 @@
QuickFill *
gnc_quickfill_new (void)
{
- QuickFill *qf;
+ QuickFill *qf;
- if (sizeof (guint) < sizeof (gunichar))
- {
- PWARN ("Can't use quickfill");
- return NULL;
- }
+ if (sizeof (guint) < sizeof (gunichar))
+ {
+ PWARN ("Can't use quickfill");
+ return NULL;
+ }
- qf = g_new (QuickFill, 1);
+ qf = g_new (QuickFill, 1);
- qf->text = NULL;
- qf->len = 0;
+ qf->text = NULL;
+ qf->len = 0;
- qf->matches = g_hash_table_new (g_direct_hash, g_direct_equal);
+ qf->matches = g_hash_table_new (g_direct_hash, g_direct_equal);
- return qf;
+ return qf;
}
/********************************************************************\
@@ -80,40 +80,40 @@
static gboolean
destroy_helper (gpointer key, gpointer value, gpointer data)
{
- gnc_quickfill_destroy (value);
- return TRUE;
+ gnc_quickfill_destroy (value);
+ return TRUE;
}
void
gnc_quickfill_destroy (QuickFill *qf)
{
- if (qf == NULL)
- return;
+ if (qf == NULL)
+ return;
- g_hash_table_foreach (qf->matches, (GHFunc)destroy_helper, NULL);
- g_hash_table_destroy (qf->matches);
- qf->matches = NULL;
+ g_hash_table_foreach (qf->matches, (GHFunc)destroy_helper, NULL);
+ g_hash_table_destroy (qf->matches);
+ qf->matches = NULL;
- if (qf->text)
- CACHE_REMOVE(qf->text);
- qf->text = NULL;
- qf->len = 0;
+ if (qf->text)
+ CACHE_REMOVE(qf->text);
+ qf->text = NULL;
+ qf->len = 0;
- g_free (qf);
+ g_free (qf);
}
void
gnc_quickfill_purge (QuickFill *qf)
{
- if (qf == NULL)
- return;
+ if (qf == NULL)
+ return;
- g_hash_table_foreach_remove (qf->matches, destroy_helper, NULL);
+ g_hash_table_foreach_remove (qf->matches, destroy_helper, NULL);
- if (qf->text)
- CACHE_REMOVE (qf->text);
- qf->text = NULL;
- qf->len = 0;
+ if (qf->text)
+ CACHE_REMOVE (qf->text);
+ qf->text = NULL;
+ qf->len = 0;
}
/********************************************************************\
@@ -122,10 +122,10 @@
const char *
gnc_quickfill_string (QuickFill *qf)
{
- if (qf == NULL)
- return NULL;
+ if (qf == NULL)
+ return NULL;
- return qf->text;
+ return qf->text;
}
/********************************************************************\
@@ -134,13 +134,13 @@
QuickFill *
gnc_quickfill_get_char_match (QuickFill *qf, gunichar uc)
{
- guint key = g_unichar_toupper (uc);
+ guint key = g_unichar_toupper (uc);
- if (NULL == qf) return NULL;
+ if (NULL == qf) return NULL;
- DEBUG ("xaccGetQuickFill(): index = %u\n", key);
+ DEBUG ("xaccGetQuickFill(): index = %u\n", key);
- return g_hash_table_lookup (qf->matches, GUINT_TO_POINTER (key));
+ return g_hash_table_lookup (qf->matches, GUINT_TO_POINTER (key));
}
/********************************************************************\
@@ -150,26 +150,26 @@
gnc_quickfill_get_string_len_match (QuickFill *qf,
const char *str, int len)
{
- const char *c;
- gunichar uc;
+ const char *c;
+ gunichar uc;
- if (NULL == qf) return NULL;
- if (NULL == str) return NULL;
+ if (NULL == qf) return NULL;
+ if (NULL == str) return NULL;
- c = str;
- while (*c && (len > 0))
- {
- if (qf == NULL)
- return NULL;
+ c = str;
+ while (*c && (len > 0))
+ {
+ if (qf == NULL)
+ return NULL;
- uc = g_utf8_get_char (c);
- qf = gnc_quickfill_get_char_match (qf, uc);
+ uc = g_utf8_get_char (c);
+ qf = gnc_quickfill_get_char_match (qf, uc);
- c = g_utf8_next_char (c);
- len--;
- }
+ c = g_utf8_next_char (c);
+ len--;
+ }
- return qf;
+ return qf;
}
/********************************************************************\
@@ -178,10 +178,10 @@
QuickFill *
gnc_quickfill_get_string_match (QuickFill *qf, const char *str)
{
- if (NULL == qf) return NULL;
- if (NULL == str) return NULL;
+ if (NULL == qf) return NULL;
+ if (NULL == str) return NULL;
- return gnc_quickfill_get_string_len_match (qf, str, g_utf8_strlen (str, -1));
+ return gnc_quickfill_get_string_len_match (qf, str, g_utf8_strlen (str, -1));
}
/********************************************************************\
@@ -190,36 +190,36 @@
static void
unique_len_helper (gpointer key, gpointer value, gpointer data)
{
- QuickFill **qf_p = data;
+ QuickFill **qf_p = data;
- *qf_p = value;
+ *qf_p = value;
}
QuickFill *
gnc_quickfill_get_unique_len_match (QuickFill *qf, int *length)
{
- if (length != NULL)
- *length = 0;
+ if (length != NULL)
+ *length = 0;
- if (qf == NULL)
- return NULL;
+ if (qf == NULL)
+ return NULL;
- while (1)
- {
- guint count;
+ while (1)
+ {
+ guint count;
- count = g_hash_table_size (qf->matches);
+ count = g_hash_table_size (qf->matches);
- if (count != 1)
- {
- return qf;
- }
+ if (count != 1)
+ {
+ return qf;
+ }
- g_hash_table_foreach (qf->matches, unique_len_helper, &qf);
+ g_hash_table_foreach (qf->matches, unique_len_helper, &qf);
- if (length != NULL)
- (*length)++;
- }
+ if (length != NULL)
+ (*length)++;
+ }
}
/********************************************************************\
@@ -228,15 +228,15 @@
void
gnc_quickfill_insert (QuickFill *qf, const char *text, QuickFillSort sort)
{
- gchar *normalized_str;
+ gchar *normalized_str;
- if (NULL == qf) return;
- if (NULL == text) return;
+ if (NULL == qf) return;
+ if (NULL == text) return;
- normalized_str = g_utf8_normalize (text, -1, G_NORMALIZE_NFC);
- quickfill_insert_recursive (qf, normalized_str, 0, sort);
- g_free (normalized_str);
+ normalized_str = g_utf8_normalize (text, -1, G_NORMALIZE_NFC);
+ quickfill_insert_recursive (qf, normalized_str, 0, sort);
+ g_free (normalized_str);
}
/********************************************************************\
@@ -246,63 +246,63 @@
quickfill_insert_recursive (QuickFill *qf, const char *text, int depth,
QuickFillSort sort)
{
- guint key;
- char *old_text;
- QuickFill *match_qf;
- int len;
- char *key_char;
- gunichar key_char_uc;
+ guint key;
+ char *old_text;
+ QuickFill *match_qf;
+ int len;
+ char *key_char;
+ gunichar key_char_uc;
- if (qf == NULL)
- return;
+ if (qf == NULL)
+ return;
- if ((text == NULL) || (g_utf8_strlen (text, -1) <= depth))
- return;
+ if ((text == NULL) || (g_utf8_strlen (text, -1) <= depth))
+ return;
- key_char = g_utf8_offset_to_pointer (text, depth);
+ key_char = g_utf8_offset_to_pointer (text, depth);
- key_char_uc = g_utf8_get_char (key_char);
- key = g_unichar_toupper (key_char_uc);
+ key_char_uc = g_utf8_get_char (key_char);
+ key = g_unichar_toupper (key_char_uc);
- match_qf = g_hash_table_lookup (qf->matches, GUINT_TO_POINTER (key));
- if (match_qf == NULL)
- {
- match_qf = gnc_quickfill_new ();
- g_hash_table_insert (qf->matches, GUINT_TO_POINTER (key), match_qf);
- }
+ match_qf = g_hash_table_lookup (qf->matches, GUINT_TO_POINTER (key));
+ if (match_qf == NULL)
+ {
+ match_qf = gnc_quickfill_new ();
+ g_hash_table_insert (qf->matches, GUINT_TO_POINTER (key), match_qf);
+ }
- old_text = match_qf->text;
+ old_text = match_qf->text;
- switch (sort)
- {
+ switch (sort)
+ {
case QUICKFILL_ALPHA:
- if (old_text && (g_utf8_collate (text, old_text) >= 0))
- break;
+ if (old_text && (g_utf8_collate (text, old_text) >= 0))
+ break;
case QUICKFILL_LIFO:
default:
- len = g_utf8_strlen (text, -1);
+ len = g_utf8_strlen (text, -1);
- /* If there's no string there already, just put the new one in. */
- if (old_text == NULL)
- {
+ /* If there's no string there already, just put the new one in. */
+ if (old_text == NULL)
+ {
+ match_qf->text = CACHE_INSERT((gpointer) text);
+ match_qf->len = len;
+ break;
+ }
+
+ /* Leave prefixes in place */
+ if ((len > match_qf->len) &&
+ (strncmp(text, old_text, strlen(old_text)) == 0))
+ break;
+
+ CACHE_REMOVE(old_text);
match_qf->text = CACHE_INSERT((gpointer) text);
match_qf->len = len;
break;
- }
+ }
- /* Leave prefixes in place */
- if ((len > match_qf->len) &&
- (strncmp(text, old_text, strlen(old_text)) == 0))
- break;
-
- CACHE_REMOVE(old_text);
- match_qf->text = CACHE_INSERT((gpointer) text);
- match_qf->len = len;
- break;
- }
-
- quickfill_insert_recursive (match_qf, text, ++depth, sort);
+ quickfill_insert_recursive (match_qf, text, ++depth, sort);
}
/********************************************************************\
@@ -311,14 +311,14 @@
void
gnc_quickfill_remove (QuickFill *qf, const gchar *text, QuickFillSort sort)
{
- gchar *normalized_str;
+ gchar *normalized_str;
- if (qf == NULL) return;
- if (text == NULL) return;
+ if (qf == NULL) return;
+ if (text == NULL) return;
- normalized_str = g_utf8_normalize (text, -1, G_NORMALIZE_NFC);
- gnc_quickfill_remove_recursive (qf, normalized_str, 0, sort);
- g_free (normalized_str);
+ normalized_str = g_utf8_normalize (text, -1, G_NORMALIZE_NFC);
+ gnc_quickfill_remove_recursive (qf, normalized_str, 0, sort);
+ g_free (normalized_str);
}
/********************************************************************\
@@ -326,28 +326,33 @@
struct _BestText
{
- gchar *text;
- QuickFillSort sort;
+ gchar *text;
+ QuickFillSort sort;
};
static void
best_text_helper (gpointer key, gpointer value, gpointer user_data)
{
- QuickFill *qf = value;
- struct _BestText *best = user_data;
+ QuickFill *qf = value;
+ struct _BestText *best = user_data;
- if (best->text == NULL) {
- /* start with the first text */
- best->text = qf->text;
+ if (best->text == NULL)
+ {
+ /* start with the first text */
+ best->text = qf->text;
- } else if (best->text == QUICKFILL_LIFO) {
- /* we do not track history, so ignore it */
- return;
+ }
+ else if (best->text == QUICKFILL_LIFO)
+ {
+ /* we do not track history, so ignore it */
+ return;
- } else if (g_utf8_collate (qf->text, best->text) < 0) {
- /* even better text */
- best->text = qf->text;
- }
+ }
+ else if (g_utf8_collate (qf->text, best->text) < 0)
+ {
+ /* even better text */
+ best->text = qf->text;
+ }
}
@@ -356,79 +361,92 @@
gnc_quickfill_remove_recursive (QuickFill *qf, const gchar *text, gint depth,
QuickFillSort sort)
{
- QuickFill *match_qf;
- gchar *child_text;
- gint child_len;
+ QuickFill *match_qf;
+ gchar *child_text;
+ gint child_len;
- child_text = NULL;
- child_len = 0;
+ child_text = NULL;
+ child_len = 0;
- if (depth < g_utf8_strlen (text, -1)) {
- /* process next letter */
+ if (depth < g_utf8_strlen (text, -1))
+ {
+ /* process next letter */
- gchar *key_char;
- gunichar key_char_uc;
- guint key;
+ gchar *key_char;
+ gunichar key_char_uc;
+ guint key;
- key_char = g_utf8_offset_to_pointer (text, depth);
- key_char_uc = g_utf8_get_char (key_char);
- key = g_unichar_toupper (key_char_uc);
+ key_char = g_utf8_offset_to_pointer (text, depth);
+ key_char_uc = g_utf8_get_char (key_char);
+ key = g_unichar_toupper (key_char_uc);
- match_qf = g_hash_table_lookup (qf->matches, GUINT_TO_POINTER (key));
- if (match_qf) {
- /* remove text from child qf */
- gnc_quickfill_remove_recursive (match_qf, text, depth + 1, sort);
+ match_qf = g_hash_table_lookup (qf->matches, GUINT_TO_POINTER (key));
+ if (match_qf)
+ {
+ /* remove text from child qf */
+ gnc_quickfill_remove_recursive (match_qf, text, depth + 1, sort);
- if (match_qf->text == NULL) {
- /* text was the only word with a prefix up to match_qf */
- g_hash_table_remove (qf->matches, GUINT_TO_POINTER (key));
- gnc_quickfill_destroy (match_qf);
+ if (match_qf->text == NULL)
+ {
+ /* text was the only word with a prefix up to match_qf */
+ g_hash_table_remove (qf->matches, GUINT_TO_POINTER (key));
+ gnc_quickfill_destroy (match_qf);
- } else {
- /* remember remaining best child string */
- child_text = match_qf->text;
- child_len = match_qf->len;
- }
+ }
+ else
+ {
+ /* remember remaining best child string */
+ child_text = match_qf->text;
+ child_len = match_qf->len;
+ }
+ }
}
- }
- if (qf->text == NULL)
- return;
+ if (qf->text == NULL)
+ return;
- if (strcmp (text, qf->text) == 0) {
- /* the currently best text is about to be removed */
+ if (strcmp (text, qf->text) == 0)
+ {
+ /* the currently best text is about to be removed */
- gchar *best_text = NULL;
- gint best_len = 0;
+ gchar *best_text = NULL;
+ gint best_len = 0;
- if (child_text != NULL) {
- /* other children are pretty good as well */
- best_text = child_text;
- best_len = child_len;
+ if (child_text != NULL)
+ {
+ /* other children are pretty good as well */
+ best_text = child_text;
+ best_len = child_len;
- } else {
- if (g_hash_table_size (qf->matches) != 0) {
- /* otherwise search for another good text */
- struct _BestText bts;
- bts.text = NULL;
- bts.sort = sort;
+ }
+ else
+ {
+ if (g_hash_table_size (qf->matches) != 0)
+ {
+ /* otherwise search for another good text */
+ struct _BestText bts;
+ bts.text = NULL;
+ bts.sort = sort;
- g_hash_table_foreach (qf->matches, (GHFunc) best_text_helper, &bts);
- best_text = bts.text;
- best_len = (best_text == NULL) ? 0 : g_utf8_strlen (best_text, -1);
- }
- }
+ g_hash_table_foreach (qf->matches, (GHFunc) best_text_helper, &bts);
+ best_text = bts.text;
+ best_len = (best_text == NULL) ? 0 : g_utf8_strlen (best_text, -1);
+ }
+ }
- /* now replace or clear text */
- CACHE_REMOVE(qf->text);
- if (best_text != NULL) {
- qf->text = CACHE_INSERT((gpointer) best_text);
- qf->len = best_len;
- } else {
- qf->text = NULL;
- qf->len = 0;
+ /* now replace or clear text */
+ CACHE_REMOVE(qf->text);
+ if (best_text != NULL)
+ {
+ qf->text = CACHE_INSERT((gpointer) best_text);
+ qf->len = best_len;
+ }
+ else
+ {
+ qf->text = NULL;
+ qf->len = 0;
+ }
}
- }
}
/********************** END OF FILE ********************************* \
Modified: gnucash/trunk/src/gnome-utils/QuickFill.h
===================================================================
--- gnucash/trunk/src/gnome-utils/QuickFill.h 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/QuickFill.h 2010-03-02 21:42:11 UTC (rev 18791)
@@ -55,8 +55,8 @@
typedef enum
{
- QUICKFILL_LIFO,
- QUICKFILL_ALPHA
+ QUICKFILL_LIFO,
+ QUICKFILL_ALPHA
} QuickFillSort;
typedef struct _QuickFill QuickFill;
@@ -96,13 +96,13 @@
* use the gnc_mbstowcs() routine.
*/
QuickFill * gnc_quickfill_get_string_match (QuickFill *qf,
- const char *str);
+ const char *str);
/** Same as gnc_quickfill_get_string_match(), except that the
* string length is explicitly specified.
*/
QuickFill * gnc_quickfill_get_string_len_match (QuickFill *qf,
- const char *str, int len);
+ const char *str, int len);
/** Walk a 'unique' part of the QuickFill tree. This routine is
* typically used to assist in the tab-completion of strings.
Modified: gnucash/trunk/src/gnome-utils/account-quickfill.c
===================================================================
--- gnucash/trunk/src/gnome-utils/account-quickfill.c 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/account-quickfill.c 2010-03-02 21:42:11 UTC (rev 18791)
@@ -32,7 +32,7 @@
static void shared_quickfill_gconf_changed (GConfEntry *entry, gpointer qfb);
static void listen_for_account_events (QofInstance *entity, QofEventId event_type,
- gpointer user_data, gpointer event_data);
+ gpointer user_data, gpointer event_data);
/* Column indices for the list store */
#define ACCOUNT_NAME 0
@@ -42,68 +42,72 @@
/* ===================================================================== */
/* In order to speed up register starts for registers that have a huge
* number of accounts in them (where 'huge' is >500) we build a quickfill
- * cache of account names. This cache is needed because some users on
+ * cache of account names. This cache is needed because some users on
* some machines experience register open times in the tens of seconds
* type timescales. Building the quickfill list accounts for almost
- * all of that cpu time (about 90% of the xfer_cell build time for 600
+ * all of that cpu time (about 90% of the xfer_cell build time for 600
* accounts).
*/
-typedef struct {
- QuickFill *qf;
- gboolean load_list_store;
- GtkListStore *list_store;
- QofBook *book;
- Account *root;
- gint listener;
- AccountBoolCB dont_add_cb;
- gpointer dont_add_data;
+typedef struct
+{
+ QuickFill *qf;
+ gboolean load_list_store;
+ GtkListStore *list_store;
+ QofBook *book;
+ Account *root;
+ gint listener;
+ AccountBoolCB dont_add_cb;
+ gpointer dont_add_data;
} QFB;
-static void
+static void
shared_quickfill_destroy (QofBook *book, gpointer key, gpointer user_data)
{
- QFB *qfb = user_data;
- gnc_gconf_general_remove_cb(KEY_ACCOUNT_SEPARATOR,
- shared_quickfill_gconf_changed,
- qfb);
- gnc_gconf_general_remove_cb(KEY_SHOW_LEAF_ACCOUNT_NAMES,
- shared_quickfill_gconf_changed,
- qfb);
- gnc_quickfill_destroy (qfb->qf);
- g_object_unref(qfb->list_store);
- qof_event_unregister_handler (qfb->listener);
- g_free (qfb);
+ QFB *qfb = user_data;
+ gnc_gconf_general_remove_cb(KEY_ACCOUNT_SEPARATOR,
+ shared_quickfill_gconf_changed,
+ qfb);
+ gnc_gconf_general_remove_cb(KEY_SHOW_LEAF_ACCOUNT_NAMES,
+ shared_quickfill_gconf_changed,
+ qfb);
+ gnc_quickfill_destroy (qfb->qf);
+ g_object_unref(qfb->list_store);
+ qof_event_unregister_handler (qfb->listener);
+ g_free (qfb);
}
-typedef struct find_data {
- GList *accounts;
- GList *refs;
+typedef struct find_data
+{
+ GList *accounts;
+ GList *refs;
} find_data;
static gboolean
shared_quickfill_find_accounts (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer user_data)
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer user_data)
{
- Account *account = NULL;
- find_data *data = user_data;
- GtkTreeRowReference* ref;
- GList *tmp;
+ Account *account = NULL;
+ find_data *data = user_data;
+ GtkTreeRowReference* ref;
+ GList *tmp;
- gtk_tree_model_get(model, iter, ACCOUNT_POINTER, &account, -1);
- for (tmp = data->accounts; tmp; tmp = g_list_next(tmp)) {
- if (tmp->data == account) {
- ref = gtk_tree_row_reference_new(model, path);
- data->refs = g_list_append(data->refs, ref);
- data->accounts = g_list_remove_link(data->accounts, tmp);
- return (data->accounts == NULL);
+ gtk_tree_model_get(model, iter, ACCOUNT_POINTER, &account, -1);
+ for (tmp = data->accounts; tmp; tmp = g_list_next(tmp))
+ {
+ if (tmp->data == account)
+ {
+ ref = gtk_tree_row_reference_new(model, path);
+ data->refs = g_list_append(data->refs, ref);
+ data->accounts = g_list_remove_link(data->accounts, tmp);
+ return (data->accounts == NULL);
+ }
}
- }
- return FALSE;
+ return FALSE;
}
@@ -111,271 +115,287 @@
static void
load_shared_qf_cb (Account *account, gpointer data)
{
- QFB *qfb = data;
- char *name;
- GtkTreeIter iter;
+ QFB *qfb = data;
+ char *name;
+ GtkTreeIter iter;
- if (qfb->dont_add_cb)
- {
- gboolean skip = (qfb->dont_add_cb) (account, qfb->dont_add_data);
- if (skip) return;
- }
+ if (qfb->dont_add_cb)
+ {
+ gboolean skip = (qfb->dont_add_cb) (account, qfb->dont_add_data);
+ if (skip) return;
+ }
- name = gnc_get_account_name_for_register (account);
- if (NULL == name) return;
- gnc_quickfill_insert (qfb->qf, name, QUICKFILL_ALPHA);
- if (qfb->load_list_store) {
- gtk_list_store_append (qfb->list_store, &iter);
- gtk_list_store_set (qfb->list_store, &iter,
- ACCOUNT_NAME, name,
- ACCOUNT_POINTER, account,
- -1);
- }
- g_free(name);
+ name = gnc_get_account_name_for_register (account);
+ if (NULL == name) return;
+ gnc_quickfill_insert (qfb->qf, name, QUICKFILL_ALPHA);
+ if (qfb->load_list_store)
+ {
+ gtk_list_store_append (qfb->list_store, &iter);
+ gtk_list_store_set (qfb->list_store, &iter,
+ ACCOUNT_NAME, name,
+ ACCOUNT_POINTER, account,
+ -1);
+ }
+ g_free(name);
}
static void
shared_quickfill_gconf_changed (GConfEntry *entry, gpointer user_data)
{
- QFB *qfb = user_data;
+ QFB *qfb = user_data;
- /* Reload the quickfill */
- gnc_quickfill_purge(qfb->qf);
- gtk_list_store_clear(qfb->list_store);
- qfb->load_list_store = TRUE;
- gnc_account_foreach_descendant(qfb->root, load_shared_qf_cb, qfb);
- qfb->load_list_store = FALSE;
+ /* Reload the quickfill */
+ gnc_quickfill_purge(qfb->qf);
+ gtk_list_store_clear(qfb->list_store);
+ qfb->load_list_store = TRUE;
+ gnc_account_foreach_descendant(qfb->root, load_shared_qf_cb, qfb);
+ qfb->load_list_store = FALSE;
}
-/* Build the quickfill list out of account names.
+/* Build the quickfill list out of account names.
* Essentially same loop as in gnc_load_xfer_cell() above.
*/
static QFB *
build_shared_quickfill (QofBook *book, Account *root, const char * key,
AccountBoolCB cb, gpointer data)
{
- QFB *qfb;
+ QFB *qfb;
- qfb = g_new0(QFB, 1);
- qfb->qf = gnc_quickfill_new ();
- qfb->book = book;
- qfb->root = root;
- qfb->listener = 0;
- qfb->dont_add_cb = cb;
- qfb->dont_add_data = data;
- qfb->load_list_store = TRUE;
- qfb->list_store =
- gtk_list_store_new (NUM_ACCOUNT_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER);
+ qfb = g_new0(QFB, 1);
+ qfb->qf = gnc_quickfill_new ();
+ qfb->book = book;
+ qfb->root = root;
+ qfb->listener = 0;
+ qfb->dont_add_cb = cb;
+ qfb->dont_add_data = data;
+ qfb->load_list_store = TRUE;
+ qfb->list_store =
+ gtk_list_store_new (NUM_ACCOUNT_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER);
- gnc_gconf_general_register_cb(KEY_ACCOUNT_SEPARATOR,
- shared_quickfill_gconf_changed,
- qfb);
+ gnc_gconf_general_register_cb(KEY_ACCOUNT_SEPARATOR,
+ shared_quickfill_gconf_changed,
+ qfb);
- gnc_gconf_general_register_cb(KEY_SHOW_LEAF_ACCOUNT_NAMES,
- shared_quickfill_gconf_changed,
- qfb);
+ gnc_gconf_general_register_cb(KEY_SHOW_LEAF_ACCOUNT_NAMES,
+ shared_quickfill_gconf_changed,
+ qfb);
- gnc_account_foreach_descendant(root, load_shared_qf_cb, qfb);
- qfb->load_list_store = FALSE;
+ gnc_account_foreach_descendant(root, load_shared_qf_cb, qfb);
+ qfb->load_list_store = FALSE;
- qfb->listener =
- qof_event_register_handler (listen_for_account_events, qfb);
+ qfb->listener =
+ qof_event_register_handler (listen_for_account_events, qfb);
- qof_book_set_data_fin (book, key, qfb, shared_quickfill_destroy);
+ qof_book_set_data_fin (book, key, qfb, shared_quickfill_destroy);
- return qfb;
+ return qfb;
}
QuickFill *
-gnc_get_shared_account_name_quickfill (Account *root,
- const char * key,
+gnc_get_shared_account_name_quickfill (Account *root,
+ const char * key,
AccountBoolCB cb, gpointer cb_data)
{
- QFB *qfb;
- QofBook *book;
+ QFB *qfb;
+ QofBook *book;
- book = gnc_account_get_book (root);
- qfb = qof_book_get_data (book, key);
+ book = gnc_account_get_book (root);
+ qfb = qof_book_get_data (book, key);
- if (qfb) return qfb->qf;
+ if (qfb) return qfb->qf;
- qfb = build_shared_quickfill (book, root, key, cb, cb_data);
- return qfb->qf;
+ qfb = build_shared_quickfill (book, root, key, cb, cb_data);
+ return qfb->qf;
}
GtkListStore *
-gnc_get_shared_account_name_list_store (Account *root,
- const char * key,
- AccountBoolCB cb, gpointer cb_data)
+gnc_get_shared_account_name_list_store (Account *root,
+ const char * key,
+ AccountBoolCB cb, gpointer cb_data)
{
- QFB *qfb;
- QofBook *book;
+ QFB *qfb;
+ QofBook *book;
- book = gnc_account_get_book (root);
- qfb = qof_book_get_data (book, key);
+ book = gnc_account_get_book (root);
+ qfb = qof_book_get_data (book, key);
- if (qfb) return qfb->list_store;
+ if (qfb) return qfb->list_store;
- qfb = build_shared_quickfill (book, root, key, cb, cb_data);
- return qfb->list_store;
+ qfb = build_shared_quickfill (book, root, key, cb, cb_data);
+ return qfb->list_store;
}
-/* Since we are maintaining a 'global' quickfill list, we need to
+/* Since we are maintaining a 'global' quickfill list, we need to
* update it whenever the user creates a new account. So listen
* for account modification events, and add new accounts.
*/
static void
listen_for_account_events (QofInstance *entity, QofEventId event_type,
- gpointer user_data, gpointer event_data)
+ gpointer user_data, gpointer event_data)
{
- QFB *qfb = user_data;
- QuickFill *qf = qfb->qf;
- QuickFill *match;
- char * name;
- const char *match_str;
- Account *account;
- GtkTreeIter iter;
- find_data data = { 0 };
- GtkTreePath *path;
- GList *tmp;
+ QFB *qfb = user_data;
+ QuickFill *qf = qfb->qf;
+ QuickFill *match;
+ char * name;
+ const char *match_str;
+ Account *account;
+ GtkTreeIter iter;
+ find_data data = { 0 };
+ GtkTreePath *path;
+ GList *tmp;
- if (0 == (event_type & (QOF_EVENT_MODIFY | QOF_EVENT_ADD | QOF_EVENT_REMOVE)))
- return;
+ if (0 == (event_type & (QOF_EVENT_MODIFY | QOF_EVENT_ADD | QOF_EVENT_REMOVE)))
+ return;
- if (!GNC_IS_ACCOUNT (entity))
- return;
- account = GNC_ACCOUNT (entity);
+ if (!GNC_IS_ACCOUNT (entity))
+ return;
+ account = GNC_ACCOUNT (entity);
- ENTER("entity %p, event type %x, user data %p, ecent data %p",
- entity, event_type, user_data, event_data);
+ ENTER("entity %p, event type %x, user data %p, ecent data %p",
+ entity, event_type, user_data, event_data);
- if (gnc_account_get_root(account) != qfb->root) {
- LEAVE("root account mismatch");
- return;
- }
+ if (gnc_account_get_root(account) != qfb->root)
+ {
+ LEAVE("root account mismatch");
+ return;
+ }
- name = gnc_get_account_name_for_register(account);
- if (NULL == name) {
- LEAVE("account has no name");
- return;
- }
+ name = gnc_get_account_name_for_register(account);
+ if (NULL == name)
+ {
+ LEAVE("account has no name");
+ return;
+ }
- switch (event_type) {
+ switch (event_type)
+ {
case QOF_EVENT_MODIFY:
- DEBUG("modify %s", name);
+ DEBUG("modify %s", name);
- /* Find the account (and all its descendants) in the model. The
- * full name of all these accounts has changed. */
- data.accounts = gnc_account_get_descendants(account);
- data.accounts = g_list_prepend(data.accounts, account);
- gtk_tree_model_foreach(GTK_TREE_MODEL(qfb->list_store),
- shared_quickfill_find_accounts, &data);
+ /* Find the account (and all its descendants) in the model. The
+ * full name of all these accounts has changed. */
+ data.accounts = gnc_account_get_descendants(account);
+ data.accounts = g_list_prepend(data.accounts, account);
+ gtk_tree_model_foreach(GTK_TREE_MODEL(qfb->list_store),
+ shared_quickfill_find_accounts, &data);
- /* Update the existing items in the list store. Its possible
- * that the change has caused an existing item to now become
- * hidden, in which case it needs to be removed from the list
- * store. Otherwise its a simple update of the name string. */
- for (tmp = data.refs; tmp; tmp = g_list_next(tmp)) {
- path = gtk_tree_row_reference_get_path(tmp->data);
- gtk_tree_row_reference_free(tmp->data);
- if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(qfb->list_store),
- &iter, path)) {
- gtk_tree_path_free(path);
- continue;
- }
- gtk_tree_path_free(path);
- gtk_tree_model_get(GTK_TREE_MODEL(qfb->list_store), &iter,
- ACCOUNT_POINTER, &account,
- -1);
- if (qfb->dont_add_cb &&
- qfb->dont_add_cb(account, qfb->dont_add_data)) {
- gtk_list_store_remove(qfb->list_store, &iter);
- } else {
- gchar *aname = gnc_get_account_name_for_register(account);
- gtk_list_store_set(qfb->list_store, &iter,
- ACCOUNT_NAME, aname,
- -1);
- g_free(aname);
- }
- }
+ /* Update the existing items in the list store. Its possible
+ * that the change has caused an existing item to now become
+ * hidden, in which case it needs to be removed from the list
+ * store. Otherwise its a simple update of the name string. */
+ for (tmp = data.refs; tmp; tmp = g_list_next(tmp))
+ {
+ path = gtk_tree_row_reference_get_path(tmp->data);
+ gtk_tree_row_reference_free(tmp->data);
+ if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(qfb->list_store),
+ &iter, path))
+ {
+ gtk_tree_path_free(path);
+ continue;
+ }
+ gtk_tree_path_free(path);
+ gtk_tree_model_get(GTK_TREE_MODEL(qfb->list_store), &iter,
+ ACCOUNT_POINTER, &account,
+ -1);
+ if (qfb->dont_add_cb &&
+ qfb->dont_add_cb(account, qfb->dont_add_data))
+ {
+ gtk_list_store_remove(qfb->list_store, &iter);
+ }
+ else
+ {
+ gchar *aname = gnc_get_account_name_for_register(account);
+ gtk_list_store_set(qfb->list_store, &iter,
+ ACCOUNT_NAME, aname,
+ -1);
+ g_free(aname);
+ }
+ }
- /* Any accounts that weren't found in the tree are accounts that
- * were hidden but have now become visible. Add them to the list
- * store. */
- for (tmp = data.accounts; tmp; tmp = g_list_next(tmp)) {
- account = tmp->data;
- if (qfb->dont_add_cb) {
- if (qfb->dont_add_cb(account, qfb->dont_add_data)) {
- continue;
- }
- }
- gtk_list_store_append (qfb->list_store, &iter);
- gtk_list_store_set (qfb->list_store, &iter,
- ACCOUNT_NAME, name,
- ACCOUNT_POINTER, account,
- -1);
- }
- break;
+ /* Any accounts that weren't found in the tree are accounts that
+ * were hidden but have now become visible. Add them to the list
+ * store. */
+ for (tmp = data.accounts; tmp; tmp = g_list_next(tmp))
+ {
+ account = tmp->data;
+ if (qfb->dont_add_cb)
+ {
+ if (qfb->dont_add_cb(account, qfb->dont_add_data))
+ {
+ continue;
+ }
+ }
+ gtk_list_store_append (qfb->list_store, &iter);
+ gtk_list_store_set (qfb->list_store, &iter,
+ ACCOUNT_NAME, name,
+ ACCOUNT_POINTER, account,
+ -1);
+ }
+ break;
case QOF_EVENT_REMOVE:
- DEBUG("remove %s", name);
+ DEBUG("remove %s", name);
- /* Remove from qf */
- gnc_quickfill_remove(qfb->qf, name, QUICKFILL_ALPHA);
+ /* Remove from qf */
+ gnc_quickfill_remove(qfb->qf, name, QUICKFILL_ALPHA);
- /* Does the account exist in the model? */
- data.accounts = g_list_append(NULL, account);
- gtk_tree_model_foreach(GTK_TREE_MODEL(qfb->list_store),
- shared_quickfill_find_accounts, &data);
+ /* Does the account exist in the model? */
+ data.accounts = g_list_append(NULL, account);
+ gtk_tree_model_foreach(GTK_TREE_MODEL(qfb->list_store),
+ shared_quickfill_find_accounts, &data);
- /* Remove from list store */
- for (tmp = data.refs; tmp; tmp = g_list_next(tmp)) {
- path = gtk_tree_row_reference_get_path (tmp->data);
- gtk_tree_row_reference_free (tmp->data);
- if (gtk_tree_model_get_iter(GTK_TREE_MODEL(qfb->list_store),
- &iter, path)) {
- gtk_list_store_remove(qfb->list_store, &iter);
- }
- gtk_tree_path_free(path);
- }
- break;
+ /* Remove from list store */
+ for (tmp = data.refs; tmp; tmp = g_list_next(tmp))
+ {
+ path = gtk_tree_row_reference_get_path (tmp->data);
+ gtk_tree_row_reference_free (tmp->data);
+ if (gtk_tree_model_get_iter(GTK_TREE_MODEL(qfb->list_store),
+ &iter, path))
+ {
+ gtk_list_store_remove(qfb->list_store, &iter);
+ }
+ gtk_tree_path_free(path);
+ }
+ break;
case QOF_EVENT_ADD:
- DEBUG("add %s", name);
- if (qfb->dont_add_cb &&
- qfb->dont_add_cb(account, qfb->dont_add_data))
- break;
+ DEBUG("add %s", name);
+ if (qfb->dont_add_cb &&
+ qfb->dont_add_cb(account, qfb->dont_add_data))
+ break;
- match = gnc_quickfill_get_string_match (qf, name);
- if (match) {
- match_str = gnc_quickfill_string (match);
- if (match_str && (safe_strcmp(match_str, name) != 0)) {
- PINFO ("got match for %s", name);
- break;
- }
- }
+ match = gnc_quickfill_get_string_match (qf, name);
+ if (match)
+ {
+ match_str = gnc_quickfill_string (match);
+ if (match_str && (safe_strcmp(match_str, name) != 0))
+ {
+ PINFO ("got match for %s", name);
+ break;
+ }
+ }
- PINFO ("insert new account %s into qf=%p", name, qf);
- gnc_quickfill_insert (qf, name, QUICKFILL_ALPHA);
- gtk_list_store_append (qfb->list_store, &iter);
- gtk_list_store_set (qfb->list_store, &iter,
- ACCOUNT_NAME, name,
- ACCOUNT_POINTER, account,
- -1);
- break;
+ PINFO ("insert new account %s into qf=%p", name, qf);
+ gnc_quickfill_insert (qf, name, QUICKFILL_ALPHA);
+ gtk_list_store_append (qfb->list_store, &iter);
+ gtk_list_store_set (qfb->list_store, &iter,
+ ACCOUNT_NAME, name,
+ ACCOUNT_POINTER, account,
+ -1);
+ break;
default:
- DEBUG("other %s", name);
- break;
- }
+ DEBUG("other %s", name);
+ break;
+ }
- if (data.accounts)
- g_list_free(data.accounts);
- if (data.refs)
- g_list_free(data.refs);
- g_free(name);
- LEAVE(" ");
+ if (data.accounts)
+ g_list_free(data.accounts);
+ if (data.refs)
+ g_list_free(data.refs);
+ g_free(name);
+ LEAVE(" ");
}
/* ====================== END OF FILE ================================== */
Modified: gnucash/trunk/src/gnome-utils/account-quickfill.h
===================================================================
--- gnucash/trunk/src/gnome-utils/account-quickfill.h 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/account-quickfill.h 2010-03-02 21:42:11 UTC (rev 18791)
@@ -69,13 +69,13 @@
* events.
*/
QuickFill * gnc_get_shared_account_name_quickfill (Account *root,
- const char * key,
- AccountBoolCB skip_cb,
- gpointer cb_data);
+ const char * key,
+ AccountBoolCB skip_cb,
+ gpointer cb_data);
GtkListStore *
gnc_get_shared_account_name_list_store (Account *root,
- const char * key,
- AccountBoolCB cb, gpointer cb_data);
+ const char * key,
+ AccountBoolCB cb, gpointer cb_data);
#endif
Modified: gnucash/trunk/src/gnome-utils/cursors.c
===================================================================
--- gnucash/trunk/src/gnome-utils/cursors.c 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/cursors.c 2010-03-02 21:42:11 UTC (rev 18791)
@@ -38,40 +38,40 @@
typedef enum
{
- GNC_CURSOR_NORMAL = -1,
- GNC_CURSOR_BUSY = GDK_WATCH
+ GNC_CURSOR_NORMAL = -1,
+ GNC_CURSOR_BUSY = GDK_WATCH
} GNCCursorType;
/********************************************************************\
- * gnc_ui_set_cursor *
- * sets the cursor to the specified type *
- * *
+ * gnc_ui_set_cursor *
+ * sets the cursor to the specified type *
+ * *
* Args: w - the widget over which to change the cursor *
* type - the type of cursor to make *
- * Return: none *
+ * Return: none *
\********************************************************************/
static void
gnc_ui_set_cursor (GdkWindow *win, GNCCursorType type, gboolean update_now)
{
- GdkCursor *cursor = NULL;
+ GdkCursor *cursor = NULL;
- if (win == NULL)
- return;
+ if (win == NULL)
+ return;
- if (type != GNC_CURSOR_NORMAL)
- cursor = gdk_cursor_new (type);
+ if (type != GNC_CURSOR_NORMAL)
+ cursor = gdk_cursor_new (type);
- gdk_window_set_cursor (win, cursor);
+ gdk_window_set_cursor (win, cursor);
- if (update_now && type != GNC_CURSOR_NORMAL)
- {
- while (gtk_events_pending ())
- gtk_main_iteration ();
- }
+ if (update_now && type != GNC_CURSOR_NORMAL)
+ {
+ while (gtk_events_pending ())
+ gtk_main_iteration ();
+ }
- if (type != GNC_CURSOR_NORMAL)
- gdk_cursor_unref (cursor);
+ if (type != GNC_CURSOR_NORMAL)
+ gdk_cursor_unref (cursor);
}
@@ -85,56 +85,56 @@
* call returns. *
* Return: none *
\********************************************************************/
-void
+void
gnc_set_busy_cursor (GtkWidget *w, gboolean update_now)
{
- if (w != NULL)
- gnc_ui_set_cursor (w->window, GNC_CURSOR_BUSY, update_now);
- else
- {
- GList *containerstop, *node;
-
- for (containerstop = node = gtk_window_list_toplevels (); node; node = node->next)
+ if (w != NULL)
+ gnc_ui_set_cursor (w->window, GNC_CURSOR_BUSY, update_now);
+ else
{
- w = node->data;
+ GList *containerstop, *node;
- if (!w || !GTK_IS_WIDGET (w) || !w->window)
- continue;
+ for (containerstop = node = gtk_window_list_toplevels (); node; node = node->next)
+ {
+ w = node->data;
- gnc_ui_set_cursor (w->window, GNC_CURSOR_BUSY, update_now);
+ if (!w || !GTK_IS_WIDGET (w) || !w->window)
+ continue;
+
+ gnc_ui_set_cursor (w->window, GNC_CURSOR_BUSY, update_now);
+ }
+ g_list_free (containerstop);
}
- g_list_free (containerstop);
- }
}
/********************************************************************\
- * gnc_unset_busy_cursor *
- * sets the cursor to the default cursor for the given window. *
+ * gnc_unset_busy_cursor *
+ * sets the cursor to the default cursor for the given window. *
* if the window is null, sets the cursor for all toplevel windows*
- * *
- * Args: w - the widget over which to make cursor normal *
- * Return: none *
+ * *
+ * Args: w - the widget over which to make cursor normal *
+ * Return: none *
\********************************************************************/
-void
+void
gnc_unset_busy_cursor (GtkWidget *w)
{
- if (w != NULL)
- gnc_ui_set_cursor (w->window, GNC_CURSOR_NORMAL, FALSE);
- else
- {
- GList *containerstop, *node;
-
- for (containerstop = node = gtk_window_list_toplevels (); node; node = node->next)
+ if (w != NULL)
+ gnc_ui_set_cursor (w->window, GNC_CURSOR_NORMAL, FALSE);
+ else
{
- w = GTK_WIDGET (node->data);
+ GList *containerstop, *node;
- if (!w || !GTK_IS_WIDGET (w) || GTK_WIDGET_NO_WINDOW(w))
- continue;
+ for (containerstop = node = gtk_window_list_toplevels (); node; node = node->next)
+ {
+ w = GTK_WIDGET (node->data);
- gnc_ui_set_cursor (w->window, GNC_CURSOR_NORMAL, FALSE);
+ if (!w || !GTK_IS_WIDGET (w) || GTK_WIDGET_NO_WINDOW(w))
+ continue;
+
+ gnc_ui_set_cursor (w->window, GNC_CURSOR_NORMAL, FALSE);
+ }
+ g_list_free (containerstop);
}
- g_list_free (containerstop);
- }
}
Modified: gnucash/trunk/src/gnome-utils/dialog-account.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-account.c 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/dialog-account.c 2010-03-02 21:42:11 UTC (rev 18791)
@@ -55,79 +55,80 @@
#define GCONF_SECTION "dialogs/account"
#define DEFAULT_COLOR "#ededececebeb"
-enum account_cols {
- ACCOUNT_COL_FULLNAME = 0,
- ACCOUNT_COL_FIELDNAME,
- ACCOUNT_COL_OLD_VALUE,
- ACCOUNT_COL_NEW_VALUE,
- NUM_ACCOUNT_COLS
+enum account_cols
+{
+ ACCOUNT_COL_FULLNAME = 0,
+ ACCOUNT_COL_FIELDNAME,
+ ACCOUNT_COL_OLD_VALUE,
+ ACCOUNT_COL_NEW_VALUE,
+ NUM_ACCOUNT_COLS
};
typedef enum
{
- NEW_ACCOUNT,
- EDIT_ACCOUNT
+ NEW_ACCOUNT,
+ EDIT_ACCOUNT
} AccountDialogType;
typedef struct _AccountWindow
{
- QofBook *book;
- gboolean modal;
- GtkWidget *dialog;
+ QofBook *book;
+ gboolean modal;
+ GtkWidget *dialog;
- AccountDialogType dialog_type;
+ AccountDialogType dialog_type;
- GUID account;
- Account *created_account;
+ GUID account;
+ Account *created_account;
- gchar **subaccount_names;
- gchar **next_name;
+ gchar **subaccount_names;
+ gchar **next_name;
- GNCAccountType type;
+ GNCAccountType type;
- GtkWidget * notebook;
+ GtkWidget * notebook;
- GtkWidget * name_entry;
- GtkWidget * description_entry;
- GtkWidget * color_entry_button;
- GtkWidget * color_default_button;
- GtkWidget * code_entry;
- GtkTextBuffer * notes_text_buffer;
+ GtkWidget * name_entry;
+ GtkWidget * description_entry;
+ GtkWidget * color_entry_button;
+ GtkWidget * color_default_button;
+ GtkWidget * code_entry;
+ GtkTextBuffer * notes_text_buffer;
- GtkWidget * commodity_edit;
- dialog_commodity_mode commodity_mode;
- GtkWidget * account_scu;
+ GtkWidget * commodity_edit;
+ dialog_commodity_mode commodity_mode;
+ GtkWidget * account_scu;
- guint32 valid_types;
- GNCAccountType preferred_account_type;
- GtkWidget * type_view;
- GtkTreeView * parent_tree;
+ guint32 valid_types;
+ GNCAccountType preferred_account_type;
+ GtkWidget * type_view;
+ GtkTreeView * parent_tree;
- GtkWidget * opening_balance_edit;
- GtkWidget * opening_balance_date_edit;
- GtkWidget * opening_balance_page;
+ GtkWidget * opening_balance_edit;
+ GtkWidget * opening_balance_date_edit;
+ GtkWidget * opening_balance_page;
- GtkWidget * opening_equity_radio;
- GtkWidget * transfer_account_scroll;
- GtkWidget * transfer_tree;
+ GtkWidget * opening_equity_radio;
+ GtkWidget * transfer_account_scroll;
+ GtkWidget * transfer_tree;
- GtkWidget * tax_related_button;
- GtkWidget * placeholder_button;
- GtkWidget * hidden_button;
+ GtkWidget * tax_related_button;
+ GtkWidget * placeholder_button;
+ GtkWidget * hidden_button;
- gint component_id;
+ gint component_id;
} AccountWindow;
typedef struct _RenumberDialog
{
- GtkWidget *dialog;
- GtkWidget *prefix;
- GtkWidget *interval;
- GtkWidget *example1;
- GtkWidget *example2;
+ GtkWidget *dialog;
+ GtkWidget *prefix;
+ GtkWidget *interval;
+ GtkWidget *example1;
+ GtkWidget *example2;
- Account *parent;
- gint num_children;
+ Account *parent;
+ gint num_children;
} RenumberDialog;
/** Static Globals *******************************************************/
@@ -149,111 +150,118 @@
static void
aw_call_destroy_callbacks (Account* acc)
{
- GList *node;
- void (*cb)(Account*);
+ GList *node;
+ void (*cb)(Account*);
- for (node = ac_destroy_cb_list; node; node = node->next) {
- cb = node->data;
- (cb)(acc);
- }
+ for (node = ac_destroy_cb_list; node; node = node->next)
+ {
+ cb = node->data;
+ (cb)(acc);
+ }
}
static Account *
aw_get_account (AccountWindow *aw)
{
- if (!aw)
- return NULL;
+ if (!aw)
+ return NULL;
- return xaccAccountLookup (&aw->account, aw->book);
+ return xaccAccountLookup (&aw->account, aw->book);
}
static void
gnc_account_commodity_from_type (AccountWindow * aw, gboolean update)
{
- dialog_commodity_mode new_mode;
+ dialog_commodity_mode new_mode;
- if (aw->type == ACCT_TYPE_TRADING)
- new_mode = DIAG_COMM_ALL;
- else if ((aw->type == ACCT_TYPE_STOCK) || (aw->type == ACCT_TYPE_MUTUAL))
- new_mode = DIAG_COMM_NON_CURRENCY;
- else
- new_mode = DIAG_COMM_CURRENCY;
+ if (aw->type == ACCT_TYPE_TRADING)
+ new_mode = DIAG_COMM_ALL;
+ else if ((aw->type == ACCT_TYPE_STOCK) || (aw->type == ACCT_TYPE_MUTUAL))
+ new_mode = DIAG_COMM_NON_CURRENCY;
+ else
+ new_mode = DIAG_COMM_CURRENCY;
- if (update && (new_mode != aw->commodity_mode)) {
- gnc_general_select_set_selected(GNC_GENERAL_SELECT (aw->commodity_edit),
- NULL);
- }
+ if (update && (new_mode != aw->commodity_mode))
+ {
+ gnc_general_select_set_selected(GNC_GENERAL_SELECT (aw->commodity_edit),
+ NULL);
+ }
- aw->commodity_mode = new_mode;
+ aw->commodity_mode = new_mode;
}
/* Copy the account values to the GUI widgets */
static void
gnc_account_to_ui(AccountWindow *aw)
{
- Account *account;
- gnc_commodity * commodity;
- const char *string;
- GdkColor color;
- gboolean flag, nonstd_scu;
- gint index;
+ Account *account;
+ gnc_commodity * commodity;
+ const char *string;
+ GdkColor color;
+ gboolean flag, nonstd_scu;
+ gint index;
- ENTER("%p", aw);
- account = aw_get_account (aw);
- if (!account) {
- LEAVE("no account");
- return;
- }
+ ENTER("%p", aw);
+ account = aw_get_account (aw);
+ if (!account)
+ {
+ LEAVE("no account");
+ return;
+ }
- string = xaccAccountGetName (account);
- if (string == NULL) string = "";
- gtk_entry_set_text(GTK_ENTRY(aw->name_entry), string);
+ string = xaccAccountGetName (account);
+ if (string == NULL) string = "";
+ gtk_entry_set_text(GTK_ENTRY(aw->name_entry), string);
- string = xaccAccountGetDescription (account);
- if (string == NULL) string = "";
- gtk_entry_set_text(GTK_ENTRY(aw->description_entry), string);
+ string = xaccAccountGetDescription (account);
+ if (string == NULL) string = "";
+ gtk_entry_set_text(GTK_ENTRY(aw->description_entry), string);
- string = xaccAccountGetColor (account);
- if (string == NULL) string = "";
- if (gdk_color_parse(string, &color)) {
- gtk_color_button_set_color(GTK_COLOR_BUTTON(aw->color_entry_button), &color);
- }
+ string = xaccAccountGetColor (account);
+ if (string == NULL) string = "";
+ if (gdk_color_parse(string, &color))
+ {
+ gtk_color_button_set_color(GTK_COLOR_BUTTON(aw->color_entry_button), &color);
+ }
- commodity = xaccAccountGetCommodity (account);
- gnc_general_select_set_selected (GNC_GENERAL_SELECT (aw->commodity_edit),
- commodity);
- gnc_account_commodity_from_type (aw, FALSE);
+ commodity = xaccAccountGetCommodity (account);
+ gnc_general_select_set_selected (GNC_GENERAL_SELECT (aw->commodity_edit),
+ commodity);
+ gnc_account_commodity_from_type (aw, FALSE);
- nonstd_scu = xaccAccountGetNonStdSCU (account);
- if (nonstd_scu) {
- index = xaccAccountGetCommoditySCUi(account);
- index = log10(index) + 1;
- } else {
- index = 0;
- }
- gtk_combo_box_set_active(GTK_COMBO_BOX(aw->account_scu), index);
+ nonstd_scu = xaccAccountGetNonStdSCU (account);
+ if (nonstd_scu)
+ {
+ index = xaccAccountGetCommoditySCUi(account);
+ index = log10(index) + 1;
+ }
+ else
+ {
+ index = 0;
+ }
+ gtk_combo_box_set_active(GTK_COMBO_BOX(aw->account_scu), index);
- string = xaccAccountGetCode (account);
- if (string == NULL) string = "";
- gtk_entry_set_text(GTK_ENTRY(aw->code_entry), string);
+ string = xaccAccountGetCode (account);
+ if (string == NULL) string = "";
+ gtk_entry_set_text(GTK_ENTRY(aw->code_entry), string);
- string = xaccAccountGetNotes (account);
- if (string == NULL) string = "";
+ string = xaccAccountGetNotes (account);
+ if (string == NULL) string = "";
- gtk_text_buffer_set_text (aw->notes_text_buffer, string, strlen(string));
+ gtk_text_buffer_set_text (aw->notes_text_buffer, string, strlen(string));
- flag = xaccAccountGetTaxRelated (account);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (aw->tax_related_button),
- flag);
+ flag = xaccAccountGetTaxRelated (account);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (aw->tax_related_button),
+ flag);
- flag = xaccAccountGetPlaceholder (account);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (aw->placeholder_button),
- flag);
+ flag = xaccAccountGetPlaceholder (account);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (aw->placeholder_button),
+ flag);
- flag = xaccAccountGetHidden (account);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (aw->hidden_button),
- flag);
- LEAVE(" ");
+ flag = xaccAccountGetHidden (account);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (aw->hidden_button),
+ flag);
+ LEAVE(" ");
}
@@ -264,191 +272,198 @@
gnc_numeric balance,
time_t date)
{
- Transaction *trans;
- Split *split;
+ Transaction *trans;
+ Split *split;
- if (gnc_numeric_zero_p (balance))
- return TRUE;
+ if (gnc_numeric_zero_p (balance))
+ return TRUE;
- g_return_val_if_fail (account != NULL, FALSE);
- g_return_val_if_fail (transfer != NULL, FALSE);
+ g_return_val_if_fail (account != NULL, FALSE);
+ g_return_val_if_fail (transfer != NULL, FALSE);
- xaccAccountBeginEdit (account);
- xaccAccountBeginEdit (transfer);
+ xaccAccountBeginEdit (account);
+ xaccAccountBeginEdit (transfer);
- trans = xaccMallocTransaction (book);
+ trans = xaccMallocTransaction (book);
- xaccTransBeginEdit (trans);
+ xaccTransBeginEdit (trans);
- xaccTransSetCurrency (trans, xaccAccountGetCommodity (account));
- xaccTransSetDateSecs (trans, date);
- xaccTransSetDescription (trans, _("Opening Balance"));
+ xaccTransSetCurrency (trans, xaccAccountGetCommodity (account));
+ xaccTransSetDateSecs (trans, date);
+ xaccTransSetDescription (trans, _("Opening Balance"));
- split = xaccMallocSplit (book);
+ split = xaccMallocSplit (book);
- xaccTransAppendSplit (trans, split);
- xaccAccountInsertSplit (account, split);
+ xaccTransAppendSplit (trans, split);
+ xaccAccountInsertSplit (account, split);
- xaccSplitSetAmount (split, balance);
- xaccSplitSetValue (split, balance);
+ xaccSplitSetAmount (split, balance);
+ xaccSplitSetValue (split, balance);
- balance = gnc_numeric_neg (balance);
+ balance = gnc_numeric_neg (balance);
- split = xaccMallocSplit (book);
+ split = xaccMallocSplit (book);
- xaccTransAppendSplit (trans, split);
- xaccAccountInsertSplit (transfer, split);
+ xaccTransAppendSplit (trans, split);
+ xaccAccountInsertSplit (transfer, split);
- xaccSplitSetAmount (split, balance);
- xaccSplitSetValue (split, balance);
+ xaccSplitSetAmount (split, balance);
+ xaccSplitSetValue (split, balance);
- xaccTransCommitEdit (trans);
- xaccAccountCommitEdit (transfer);
- xaccAccountCommitEdit (account);
+ xaccTransCommitEdit (trans);
+ xaccAccountCommitEdit (transfer);
+ xaccAccountCommitEdit (account);
- return TRUE;
+ return TRUE;
}
/* Record the GUI values into the Account structure */
static void
gnc_ui_to_account(AccountWindow *aw)
{
- Account *account;
- gnc_commodity *commodity;
- Account *parent_account;
- const char *old_string;
- const char *string;
- GdkColor color;
- gboolean flag;
- gnc_numeric balance;
- gboolean use_equity, nonstd;
- time_t date;
- gint index, old_scu, new_scu;
- GtkTextIter start, end;
+ Account *account;
+ gnc_commodity *commodity;
+ Account *parent_account;
+ const char *old_string;
+ const char *string;
+ GdkColor color;
+ gboolean flag;
+ gnc_numeric balance;
+ gboolean use_equity, nonstd;
+ time_t date;
+ gint index, old_scu, new_scu;
+ GtkTextIter start, end;
- account = aw_get_account (aw);
- if (!account) {
- LEAVE("no account");
- return;
- }
+ account = aw_get_account (aw);
+ if (!account)
+ {
+ LEAVE("no account");
+ return;
+ }
- if (aw->dialog_type == EDIT_ACCOUNT
- && aw->type != xaccAccountGetType (account)) {
- /* Just refreshing won't work. */
- aw_call_destroy_callbacks (account);
- }
+ if (aw->dialog_type == EDIT_ACCOUNT
+ && aw->type != xaccAccountGetType (account))
+ {
+ /* Just refreshing won't work. */
+ aw_call_destroy_callbacks (account);
+ }
- xaccAccountBeginEdit (account);
+ xaccAccountBeginEdit (account);
- if (aw->type != xaccAccountGetType (account))
- xaccAccountSetType (account, aw->type);
+ if (aw->type != xaccAccountGetType (account))
+ xaccAccountSetType (account, aw->type);
- last_used_account_type = aw->type;
+ last_used_account_type = aw->type;
- string = gtk_entry_get_text (GTK_ENTRY(aw->name_entry));
- old_string = xaccAccountGetName (account);
- if (safe_strcmp (string, old_string) != 0)
- xaccAccountSetName (account, string);
+ string = gtk_entry_get_text (GTK_ENTRY(aw->name_entry));
+ old_string = xaccAccountGetName (account);
+ if (safe_strcmp (string, old_string) != 0)
+ xaccAccountSetName (account, string);
- string = gtk_entry_get_text (GTK_ENTRY(aw->description_entry));
- old_string = xaccAccountGetDescription (account);
- if (safe_strcmp (string, old_string) != 0)
- xaccAccountSetDescription (account, string);
+ string = gtk_entry_get_text (GTK_ENTRY(aw->description_entry));
+ old_string = xaccAccountGetDescription (account);
+ if (safe_strcmp (string, old_string) != 0)
+ xaccAccountSetDescription (account, string);
- gtk_color_button_get_color(GTK_COLOR_BUTTON(aw->color_entry_button), &color );
- string = gdk_color_to_string(&color);
- old_string = xaccAccountGetColor (account);
- if (safe_strcmp (string, old_string) != 0)
- xaccAccountSetColor (account, string);
+ gtk_color_button_get_color(GTK_COLOR_BUTTON(aw->color_entry_button), &color );
+ string = gdk_color_to_string(&color);
+ old_string = xaccAccountGetColor (account);
+ if (safe_strcmp (string, old_string) != 0)
+ xaccAccountSetColor (account, string);
- commodity = (gnc_commodity *)
- gnc_general_select_get_selected (GNC_GENERAL_SELECT (aw->commodity_edit));
- if (commodity &&
- !gnc_commodity_equiv(commodity, xaccAccountGetCommodity (account))) {
- xaccAccountSetCommodity (account, commodity);
- old_scu = 0;
- } else {
- old_scu = xaccAccountGetCommoditySCU(account);
- }
+ commodity = (gnc_commodity *)
+ gnc_general_select_get_selected (GNC_GENERAL_SELECT (aw->commodity_edit));
+ if (commodity &&
+ !gnc_commodity_equiv(commodity, xaccAccountGetCommodity (account)))
+ {
+ xaccAccountSetCommodity (account, commodity);
+ old_scu = 0;
+ }
+ else
+ {
+ old_scu = xaccAccountGetCommoditySCU(account);
+ }
- index = gtk_combo_box_get_active(GTK_COMBO_BOX(aw->account_scu));
- nonstd = (index != 0);
- if (nonstd != xaccAccountGetNonStdSCU(account))
- xaccAccountSetNonStdSCU(account, nonstd);
- new_scu = (nonstd ? pow(10,index-1) : gnc_commodity_get_fraction(commodity));
- if (old_scu != new_scu)
- xaccAccountSetCommoditySCU(account, new_scu);
+ index = gtk_combo_box_get_active(GTK_COMBO_BOX(aw->account_scu));
+ nonstd = (index != 0);
+ if (nonstd != xaccAccountGetNonStdSCU(account))
+ xaccAccountSetNonStdSCU(account, nonstd);
+ new_scu = (nonstd ? pow(10, index - 1) : gnc_commodity_get_fraction(commodity));
+ if (old_scu != new_scu)
+ xaccAccountSetCommoditySCU(account, new_scu);
- string = gtk_entry_get_text (GTK_ENTRY(aw->code_entry));
- old_string = xaccAccountGetCode (account);
- if (safe_strcmp (string, old_string) != 0)
- xaccAccountSetCode (account, string);
+ string = gtk_entry_get_text (GTK_ENTRY(aw->code_entry));
+ old_string = xaccAccountGetCode (account);
+ if (safe_strcmp (string, old_string) != 0)
+ xaccAccountSetCode (account, string);
- gtk_text_buffer_get_start_iter (aw->notes_text_buffer, &start);
- gtk_text_buffer_get_end_iter (aw->notes_text_buffer, &end);
- string = gtk_text_buffer_get_text (aw->notes_text_buffer, &start, &end, FALSE);
- old_string = xaccAccountGetNotes (account);
- if (safe_strcmp (string, old_string) != 0)
- xaccAccountSetNotes (account, string);
+ gtk_text_buffer_get_start_iter (aw->notes_text_buffer, &start);
+ gtk_text_buffer_get_end_iter (aw->notes_text_buffer, &end);
+ string = gtk_text_buffer_get_text (aw->notes_text_buffer, &start, &end, FALSE);
+ old_string = xaccAccountGetNotes (account);
+ if (safe_strcmp (string, old_string) != 0)
+ xaccAccountSetNotes (account, string);
- flag =
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (aw->tax_related_button));
- xaccAccountSetTaxRelated (account, flag);
+ flag =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (aw->tax_related_button));
+ xaccAccountSetTaxRelated (account, flag);
- flag =
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (aw->placeholder_button));
- xaccAccountSetPlaceholder (account, flag);
+ flag =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (aw->placeholder_button));
+ xaccAccountSetPlaceholder (account, flag);
- flag =
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (aw->hidden_button));
- xaccAccountSetHidden (account, flag);
+ flag =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (aw->hidden_button));
+ xaccAccountSetHidden (account, flag);
- parent_account = gnc_tree_view_account_get_selected_account (GNC_TREE_VIEW_ACCOUNT (aw->parent_tree));
+ parent_account = gnc_tree_view_account_get_selected_account (GNC_TREE_VIEW_ACCOUNT (aw->parent_tree));
- if (parent_account == NULL)
- parent_account = gnc_book_get_root_account(aw->book);
- if (parent_account != gnc_account_get_parent (account))
- gnc_account_append_child (parent_account, account);
+ if (parent_account == NULL)
+ parent_account = gnc_book_get_root_account(aw->book);
+ if (parent_account != gnc_account_get_parent (account))
+ gnc_account_append_child (parent_account, account);
- xaccAccountCommitEdit (account);
+ xaccAccountCommitEdit (account);
- balance = gnc_amount_edit_get_amount
- (GNC_AMOUNT_EDIT (aw->opening_balance_edit));
+ balance = gnc_amount_edit_get_amount
+ (GNC_AMOUNT_EDIT (aw->opening_balance_edit));
- if (gnc_numeric_zero_p (balance)) {
- LEAVE("zero balance");
- return;
- }
+ if (gnc_numeric_zero_p (balance))
+ {
+ LEAVE("zero balance");
+ return;
+ }
- if (gnc_reverse_balance (account))
- balance = gnc_numeric_neg (balance);
+ if (gnc_reverse_balance (account))
+ balance = gnc_numeric_neg (balance);
- date = gnome_date_edit_get_time (
- GNOME_DATE_EDIT (aw->opening_balance_date_edit));
+ date = gnome_date_edit_get_time (
+ GNOME_DATE_EDIT (aw->opening_balance_date_edit));
- use_equity = gtk_toggle_button_get_active
- (GTK_TOGGLE_BUTTON (aw->opening_equity_radio));
+ use_equity = gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (aw->opening_equity_radio));
- if (use_equity)
- {
- if (!gnc_account_create_opening_balance (account, balance, date, aw->book))
+ if (use_equity)
{
- const char *message = _("Could not create opening balance.");
- gnc_error_dialog(aw->dialog, "%s", message);
+ if (!gnc_account_create_opening_balance (account, balance, date, aw->book))
+ {
+ const char *message = _("Could not create opening balance.");
+ gnc_error_dialog(aw->dialog, "%s", message);
+ }
}
- }
- else
- {
- Account *transfer = NULL;
+ else
+ {
+ Account *transfer = NULL;
- transfer = gnc_tree_view_account_get_selected_account (GNC_TREE_VIEW_ACCOUNT (aw->transfer_tree));
- if (!transfer) {
- LEAVE("no transfer account");
- return;
+ transfer = gnc_tree_view_account_get_selected_account (GNC_TREE_VIEW_ACCOUNT (aw->transfer_tree));
+ if (!transfer)
+ {
+ LEAVE("no transfer account");
+ return;
+ }
+
+ gnc_account_create_transfer_balance (aw->book, account, transfer, balance, date);
}
-
- gnc_account_create_transfer_balance (aw->book, account, transfer, balance, date);
- }
LEAVE(" ");
}
@@ -456,129 +471,131 @@
static void
set_children_types (Account *account, GNCAccountType type)
{
- GList *children, *iter;
+ GList *children, *iter;
- children = gnc_account_get_children(account);
- if (children == NULL)
- return;
+ children = gnc_account_get_children(account);
+ if (children == NULL)
+ return;
- for (iter=children; iter; iter=iter->next) {
- account = iter->data;
- if (type == xaccAccountGetType(account))
- continue;
+ for (iter = children; iter; iter = iter->next)
+ {
+ account = iter->data;
+ if (type == xaccAccountGetType(account))
+ continue;
- /* Just refreshing won't work. */
- aw_call_destroy_callbacks (account);
+ /* Just refreshing won't work. */
+ aw_call_destroy_callbacks (account);
- xaccAccountBeginEdit (account);
- xaccAccountSetType (account, type);
- xaccAccountCommitEdit (account);
+ xaccAccountBeginEdit (account);
+ xaccAccountSetType (account, type);
+ xaccAccountCommitEdit (account);
- set_children_types (account, type);
- }
- g_list_free(children);
+ set_children_types (account, type);
+ }
+ g_list_free(children);
}
static void
make_children_compatible (AccountWindow *aw)
{
- Account *account;
+ Account *account;
- g_return_if_fail (aw);
+ g_return_if_fail (aw);
- if (aw->dialog_type == NEW_ACCOUNT)
- return;
+ if (aw->dialog_type == NEW_ACCOUNT)
+ return;
- account = aw_get_account (aw);
- g_return_if_fail (account);
+ account = aw_get_account (aw);
+ g_return_if_fail (account);
- if (xaccAccountTypesCompatible (xaccAccountGetType (account), aw->type))
- return;
+ if (xaccAccountTypesCompatible (xaccAccountGetType (account), aw->type))
+ return;
- set_children_types (account, aw->type);
+ set_children_types (account, aw->type);
}
static void
gnc_finish_ok (AccountWindow *aw)
{
- ENTER("aw %p", aw);
- gnc_suspend_gui_refresh ();
+ ENTER("aw %p", aw);
+ gnc_suspend_gui_refresh ();
- /* make the account changes */
- make_children_compatible (aw);
- gnc_ui_to_account (aw);
+ /* make the account changes */
+ make_children_compatible (aw);
+ gnc_ui_to_account (aw);
- gnc_resume_gui_refresh ();
+ gnc_resume_gui_refresh ();
- /* do it all again, if needed */
- if ((aw->dialog_type == NEW_ACCOUNT) && aw->next_name && *aw->next_name)
- {
- gnc_commodity *commodity;
- Account *parent;
- Account *account;
+ /* do it all again, if needed */
+ if ((aw->dialog_type == NEW_ACCOUNT) && aw->next_name && *aw->next_name)
+ {
+ gnc_commodity *commodity;
+ Account *parent;
+ Account *account;
- gnc_suspend_gui_refresh ();
+ gnc_suspend_gui_refresh ();
- parent = aw_get_account (aw);
- account = xaccMallocAccount (aw->book);
- aw->account = *xaccAccountGetGUID (account);
- aw->type = xaccAccountGetType (parent);
+ parent = aw_get_account (aw);
+ account = xaccMallocAccount (aw->book);
+ aw->account = *xaccAccountGetGUID (account);
+ aw->type = xaccAccountGetType (parent);
- xaccAccountSetName (account, *aw->next_name);
- aw->next_name++;
+ xaccAccountSetName (account, *aw->next_name);
+ aw->next_name++;
- gnc_account_to_ui (aw);
+ gnc_account_to_ui (aw);
- gnc_account_window_set_name (aw);
+ gnc_account_window_set_name (aw);
- commodity = xaccAccountGetCommodity (parent);
- gnc_general_select_set_selected (GNC_GENERAL_SELECT (aw->commodity_edit),
- commodity);
- gnc_account_commodity_from_type (aw, FALSE);
+ commodity = xaccAccountGetCommodity (parent);
+ gnc_general_select_set_selected (GNC_GENERAL_SELECT (aw->commodity_edit),
+ commodity);
+ gnc_account_commodity_from_type (aw, FALSE);
- gnc_tree_view_account_set_selected_account (
- GNC_TREE_VIEW_ACCOUNT (aw->parent_tree), parent);
+ gnc_tree_view_account_set_selected_account (
+ GNC_TREE_VIEW_ACCOUNT (aw->parent_tree), parent);
- gnc_resume_gui_refresh ();
- LEAVE("1");
- return;
- }
+ gnc_resume_gui_refresh ();
+ LEAVE("1");
+ return;
+ }
- /* save for posterity */
- aw->created_account = aw_get_account (aw);
+ /* save for posterity */
+ aw->created_account = aw_get_account (aw);
- /* so it doesn't get freed on close */
- aw->account = *xaccGUIDNULL ();
+ /* so it doesn't get freed on close */
+ aw->account = *xaccGUIDNULL ();
- gnc_close_gui_component (aw->component_id);
- LEAVE("2");
+ gnc_close_gui_component (aw->component_id);
+ LEAVE("2");
}
static void
add_children_to_expander (GObject *object, GParamSpec *param_spec, gpointer data)
{
- GtkExpander *expander = GTK_EXPANDER (object);
- Account *account = data;
- GtkWidget *scrolled_window;
- GtkTreeView *view;
+ GtkExpander *expander = GTK_EXPANDER (object);
+ Account *account = data;
+ GtkWidget *scrolled_window;
+ GtkTreeView *view;
- if (gtk_expander_get_expanded (expander) &&
- !gtk_bin_get_child (GTK_BIN (expander))) {
+ if (gtk_expander_get_expanded (expander) &&
+ !gtk_bin_get_child (GTK_BIN (expander)))
+ {
- view = gnc_tree_view_account_new_with_root (account, FALSE);
+ view = gnc_tree_view_account_new_with_root (account, FALSE);
- scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
- GTK_SHADOW_IN);
- gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (view));
+ scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_SHADOW_IN);
+ gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (view));
- gtk_container_add (GTK_CONTAINER (expander), scrolled_window);
- gtk_widget_show_all (scrolled_window);
- }
+ gtk_container_add (GTK_CONTAINER (expander), scrolled_window);
+ gtk_widget_show_all (scrolled_window);
+ }
}
/* Check whether there are children needing a type adjustment because of a
@@ -587,811 +604,846 @@
static gboolean
verify_children_compatible (AccountWindow *aw)
{
- Account *account;
- GtkWidget *dialog, *vbox, *hbox, *label, *expander;
- gchar *str;
- gboolean result;
+ Account *account;
+ GtkWidget *dialog, *vbox, *hbox, *label, *expander;
+ gchar *str;
+ gboolean result;
- if (aw == NULL)
- return FALSE;
+ if (aw == NULL)
+ return FALSE;
- account = aw_get_account (aw);
- if (!account)
- return FALSE;
+ account = aw_get_account (aw);
+ if (!account)
+ return FALSE;
- if (xaccAccountTypesCompatible (xaccAccountGetType (account), aw->type))
- return TRUE;
+ if (xaccAccountTypesCompatible (xaccAccountGetType (account), aw->type))
+ return TRUE;
- if (gnc_account_n_children(account) == 0)
- return TRUE;
+ if (gnc_account_n_children(account) == 0)
+ return TRUE;
- dialog = gtk_dialog_new_with_buttons ("",
- GTK_WINDOW(aw->dialog),
- GTK_DIALOG_DESTROY_WITH_PARENT |
- GTK_DIALOG_MODAL,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK,
- NULL);
+ dialog = gtk_dialog_new_with_buttons ("",
+ GTK_WINDOW(aw->dialog),
+ GTK_DIALOG_DESTROY_WITH_PARENT |
+ GTK_DIALOG_MODAL,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK,
+ NULL);
- gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog), TRUE);
+ gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog), TRUE);
- hbox = gtk_hbox_new (FALSE, 12);
- vbox = gtk_vbox_new (FALSE, 12);
+ hbox = gtk_hbox_new (FALSE, 12);
+ vbox = gtk_vbox_new (FALSE, 12);
- gtk_box_pack_start (
- GTK_BOX (hbox),
- gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG),
- FALSE, FALSE, 0);
+ gtk_box_pack_start (
+ GTK_BOX (hbox),
+ gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG),
+ FALSE, FALSE, 0);
- /* primary label */
- label = gtk_label_new (_("Give the children the same type?"));
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_label_set_selectable (GTK_LABEL (label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
- {
- gint size;
- PangoFontDescription *font_desc;
+ /* primary label */
+ label = gtk_label_new (_("Give the children the same type?"));
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_label_set_selectable (GTK_LABEL (label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
+ {
+ gint size;
+ PangoFontDescription *font_desc;
- size = pango_font_description_get_size (label->style->font_desc);
- font_desc = pango_font_description_new ();
- pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
- pango_font_description_set_size (font_desc, size * PANGO_SCALE_LARGE);
- gtk_widget_modify_font (label, font_desc);
- pango_font_description_free (font_desc);
- }
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+ size = pango_font_description_get_size (label->style->font_desc);
+ font_desc = pango_font_description_new ();
+ pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
+ pango_font_description_set_size (font_desc, size * PANGO_SCALE_LARGE);
+ gtk_widget_modify_font (label, font_desc);
+ pango_font_description_free (font_desc);
+ }
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
- /* secondary label */
- str = g_strdup_printf (_("The children of the edited account have to be "
- "changed to type \"%s\" to make them compatible."),
- xaccAccountGetTypeStr (aw->type));
- label = gtk_label_new (str);
- g_free (str);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_label_set_selectable (GTK_LABEL (label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+ /* secondary label */
+ str = g_strdup_printf (_("The children of the edited account have to be "
+ "changed to type \"%s\" to make them compatible."),
+ xaccAccountGetTypeStr (aw->type));
+ label = gtk_label_new (str);
+ g_free (str);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_label_set_selectable (GTK_LABEL (label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
- /* children */
- expander = gtk_expander_new_with_mnemonic (_("_Show children accounts"));
- gtk_expander_set_spacing (GTK_EXPANDER (expander), 6);
- g_signal_connect (G_OBJECT (expander), "notify::expanded",
- G_CALLBACK (add_children_to_expander), account);
- gtk_box_pack_start (GTK_BOX (vbox), expander, TRUE, TRUE, 0);
+ /* children */
+ expander = gtk_expander_new_with_mnemonic (_("_Show children accounts"));
+ gtk_expander_set_spacing (GTK_EXPANDER (expander), 6);
+ g_signal_connect (G_OBJECT (expander), "notify::expanded",
+ G_CALLBACK (add_children_to_expander), account);
+ gtk_box_pack_start (GTK_BOX (vbox), expander, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox,
- TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox,
+ TRUE, TRUE, 0);
- /* spacings */
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 14);
- gtk_container_set_border_width (
- GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 6);
+ /* spacings */
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 14);
+ gtk_container_set_border_width (
+ GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 6);
- gtk_widget_show_all (hbox);
+ gtk_widget_show_all (hbox);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
- result = (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK);
+ result = (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK);
- gtk_widget_destroy(dialog);
+ gtk_widget_destroy(dialog);
- return result;
+ return result;
}
static gboolean
gnc_filter_parent_accounts (Account *account, gpointer data)
{
- AccountWindow *aw = data;
- Account *aw_account = aw_get_account (aw);
+ AccountWindow *aw = data;
+ Account *aw_account = aw_get_account (aw);
- if (account == NULL)
- return FALSE;
+ if (account == NULL)
+ return FALSE;
- if (aw_account == NULL)
- return FALSE;
+ if (aw_account == NULL)
+ return FALSE;
- if (gnc_account_is_root(account))
- return TRUE;
+ if (gnc_account_is_root(account))
+ return TRUE;
- if (account == aw_account)
- return FALSE;
+ if (account == aw_account)
+ return FALSE;
- if (xaccAccountHasAncestor(account, aw_account))
- return FALSE;
+ if (xaccAccountHasAncestor(account, aw_account))
+ return FALSE;
- return TRUE;
+ return TRUE;
}
static gboolean
gnc_common_ok (AccountWindow *aw)
{
- Account *root, *account, *parent;
- gnc_commodity * commodity;
- gchar *fullname, *fullname_parent;
- const gchar *name, *separator;
+ Account *root, *account, *parent;
+ gnc_commodity * commodity;
+ gchar *fullname, *fullname_parent;
+ const gchar *name, *separator;
- ENTER("aw %p", aw);
- root = gnc_book_get_root_account (aw->book);
+ ENTER("aw %p", aw);
+ root = gnc_book_get_root_account (aw->book);
- separator = gnc_get_account_separator_string();
+ separator = gnc_get_account_separator_string();
- /* check for valid name */
- name = gtk_entry_get_text(GTK_ENTRY(aw->name_entry));
- if (safe_strcmp(name, "") == 0) {
- const char *message = _("The account must be given a name.");
- gnc_error_dialog(aw->dialog, "%s", message);
- LEAVE("bad name");
- return FALSE;
- }
+ /* check for valid name */
+ name = gtk_entry_get_text(GTK_ENTRY(aw->name_entry));
+ if (safe_strcmp(name, "") == 0)
+ {
+ const char *message = _("The account must be given a name.");
+ gnc_error_dialog(aw->dialog, "%s", message);
+ LEAVE("bad name");
+ return FALSE;
+ }
- /* check for a duplicate name */
- parent = gnc_tree_view_account_get_selected_account
- (GNC_TREE_VIEW_ACCOUNT (aw->parent_tree));
- if (parent == NULL) {
- account = gnc_account_lookup_by_full_name(root, name);
- } else {
- fullname_parent = gnc_account_get_full_name(parent);
- fullname = g_strconcat(fullname_parent, separator, name, NULL);
+ /* check for a duplicate name */
+ parent = gnc_tree_view_account_get_selected_account
+ (GNC_TREE_VIEW_ACCOUNT (aw->parent_tree));
+ if (parent == NULL)
+ {
+ account = gnc_account_lookup_by_full_name(root, name);
+ }
+ else
+ {
+ fullname_parent = gnc_account_get_full_name(parent);
+ fullname = g_strconcat(fullname_parent, separator, name, NULL);
- account = gnc_account_lookup_by_full_name(root, fullname);
+ account = gnc_account_lookup_by_full_name(root, fullname);
- g_free(fullname_parent);
- g_free(fullname);
- }
- if ((account != NULL) &&
- !guid_equal(&aw->account, xaccAccountGetGUID (account))) {
- const char *message = _("There is already an account with that name.");
- gnc_error_dialog(aw->dialog, "%s", message);
- LEAVE("duplicate name");
- return FALSE;
- }
+ g_free(fullname_parent);
+ g_free(fullname);
+ }
+ if ((account != NULL) &&
+ !guid_equal(&aw->account, xaccAccountGetGUID (account)))
+ {
+ const char *message = _("There is already an account with that name.");
+ gnc_error_dialog(aw->dialog, "%s", message);
+ LEAVE("duplicate name");
+ return FALSE;
+ }
- /* Parent check, probably not needed, but be safe */
- if (!gnc_filter_parent_accounts(parent, aw)) {
- const char *message = _("You must choose a valid parent account.");
- gnc_error_dialog(aw->dialog, "%s", message);
- LEAVE("invalid parent");
- return FALSE;
- }
+ /* Parent check, probably not needed, but be safe */
+ if (!gnc_filter_parent_accounts(parent, aw))
+ {
+ const char *message = _("You must choose a valid parent account.");
+ gnc_error_dialog(aw->dialog, "%s", message);
+ LEAVE("invalid parent");
+ return FALSE;
+ }
- /* check for valid type */
- if (aw->type == ACCT_TYPE_INVALID) {
- const char *message = _("You must select an account type.");
- gnc_error_dialog(aw->dialog, "%s", message);
- LEAVE("invalid type");
- return FALSE;
- }
+ /* check for valid type */
+ if (aw->type == ACCT_TYPE_INVALID)
+ {
+ const char *message = _("You must select an account type.");
+ gnc_error_dialog(aw->dialog, "%s", message);
+ LEAVE("invalid type");
+ return FALSE;
+ }
- /* check whether the types of child and parent are compatible */
- if (!xaccAccountTypesCompatible (aw->type, xaccAccountGetType (parent))) {
- const char *message = _("The selected account type is incompatible with "
- "the one of the selected parent.");
- gnc_error_dialog(aw->dialog, "%s", message);
- LEAVE("incompatible types");
- return FALSE;
- }
+ /* check whether the types of child and parent are compatible */
+ if (!xaccAccountTypesCompatible (aw->type, xaccAccountGetType (parent)))
+ {
+ const char *message = _("The selected account type is incompatible with "
+ "the one of the selected parent.");
+ gnc_error_dialog(aw->dialog, "%s", message);
+ LEAVE("incompatible types");
+ return FALSE;
+ }
- /* check for commodity */
- commodity = (gnc_commodity *)
- gnc_general_select_get_selected (GNC_GENERAL_SELECT (aw->commodity_edit));
- if (!commodity) {
- const char *message = _("You must choose a commodity.");
- gnc_error_dialog(aw->dialog, "%s", message);
- LEAVE("invalid commodity");
- return FALSE;
- }
+ /* check for commodity */
+ commodity = (gnc_commodity *)
+ gnc_general_select_get_selected (GNC_GENERAL_SELECT (aw->commodity_edit));
+ if (!commodity)
+ {
+ const char *message = _("You must choose a commodity.");
+ gnc_error_dialog(aw->dialog, "%s", message);
+ LEAVE("invalid commodity");
+ return FALSE;
+ }
- LEAVE("passed");
- return TRUE;
+ LEAVE("passed");
+ return TRUE;
}
static void
gnc_edit_account_ok(AccountWindow *aw)
{
- Account *account;
+ Account *account;
- ENTER("aw %p", aw);
+ ENTER("aw %p", aw);
- account = aw_get_account (aw);
- if (!account) {
- LEAVE(" ");
- return;
- }
+ account = aw_get_account (aw);
+ if (!account)
+ {
+ LEAVE(" ");
+ return;
+ }
- if (!gnc_common_ok(aw)) {
- LEAVE(" ");
- return;
- }
+ if (!gnc_common_ok(aw))
+ {
+ LEAVE(" ");
+ return;
+ }
- if (!verify_children_compatible (aw)) {
+ if (!verify_children_compatible (aw))
+ {
+ LEAVE(" ");
+ return;
+ }
+
+ gnc_finish_ok (aw);
LEAVE(" ");
- return;
- }
-
- gnc_finish_ok (aw);
- LEAVE(" ");
}
static void
gnc_new_account_ok (AccountWindow *aw)
{
- gnc_numeric balance;
+ gnc_numeric balance;
- ENTER("aw %p", aw);
+ ENTER("aw %p", aw);
- if (!gnc_common_ok(aw)) {
- LEAVE(" ");
- return;
- }
+ if (!gnc_common_ok(aw))
+ {
+ LEAVE(" ");
+ return;
+ }
- if (!gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (aw->opening_balance_edit)))
- {
- const char *message = _("You must enter a valid opening balance "
- "or leave it blank.");
- gnc_error_dialog(aw->dialog, "%s", message);
- LEAVE(" ");
- return;
- }
+ if (!gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (aw->opening_balance_edit)))
+ {
+ const char *message = _("You must enter a valid opening balance "
+ "or leave it blank.");
+ gnc_error_dialog(aw->dialog, "%s", message);
+ LEAVE(" ");
+ return;
+ }
- balance = gnc_amount_edit_get_amount
- (GNC_AMOUNT_EDIT (aw->opening_balance_edit));
+ balance = gnc_amount_edit_get_amount
+ (GNC_AMOUNT_EDIT (aw->opening_balance_edit));
- if (!gnc_numeric_zero_p (balance))
- {
- gboolean use_equity;
+ if (!gnc_numeric_zero_p (balance))
+ {
+ gboolean use_equity;
- use_equity = gtk_toggle_button_get_active
- (GTK_TOGGLE_BUTTON (aw->opening_equity_radio));
+ use_equity = gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (aw->opening_equity_radio));
- if (!use_equity)
- {
- Account *transfer = NULL;
+ if (!use_equity)
+ {
+ Account *transfer = NULL;
- transfer = gnc_tree_view_account_get_selected_account (GNC_TREE_VIEW_ACCOUNT (aw->transfer_tree));
- if (!transfer)
- {
- const char *message = _("You must select a transfer account or choose"
- " the opening balances equity account.");
- gnc_error_dialog(aw->dialog, "%s", message);
- LEAVE(" ");
- return;
- }
+ transfer = gnc_tree_view_account_get_selected_account (GNC_TREE_VIEW_ACCOUNT (aw->transfer_tree));
+ if (!transfer)
+ {
+ const char *message = _("You must select a transfer account or choose"
+ " the opening balances equity account.");
+ gnc_error_dialog(aw->dialog, "%s", message);
+ LEAVE(" ");
+ return;
+ }
+ }
}
- }
- gnc_finish_ok (aw);
- LEAVE(" ");
+ gnc_finish_ok (aw);
+ LEAVE(" ");
}
static void
gnc_account_window_response_cb (GtkDialog *dialog,
- gint response,
- gpointer data)
+ gint response,
+ gpointer data)
{
- AccountWindow *aw = data;
+ AccountWindow *aw = data;
- ENTER("dialog %p, response %d, aw %p", dialog, response, aw);
- switch (response) {
- case GTK_RESPONSE_OK:
- switch (aw->dialog_type) {
- case NEW_ACCOUNT:
- DEBUG("new acct dialog, OK");
- gnc_new_account_ok (aw);
- break;
- case EDIT_ACCOUNT:
- DEBUG("edit acct dialog, OK");
- gnc_edit_account_ok (aw);
- break;
- default:
- g_assert_not_reached ();
- return;
- }
- break;
- case GTK_RESPONSE_HELP:
- switch (aw->dialog_type) {
- case NEW_ACCOUNT:
- DEBUG("new acct dialog, HELP");
- gnc_gnome_help(HF_HELP, HL_ACC);
- break;
- case EDIT_ACCOUNT:
- DEBUG("edit acct dialog, HELP");
- gnc_gnome_help(HF_HELP, HL_ACCEDIT);
- break;
- default:
- g_assert_not_reached ();
- return;
- }
- break;
- case GTK_RESPONSE_CANCEL:
- default:
- DEBUG("CANCEL");
- gnc_close_gui_component (aw->component_id);
- break;
- }
- LEAVE(" ");
+ ENTER("dialog %p, response %d, aw %p", dialog, response, aw);
+ switch (response)
+ {
+ case GTK_RESPONSE_OK:
+ switch (aw->dialog_type)
+ {
+ case NEW_ACCOUNT:
+ DEBUG("new acct dialog, OK");
+ gnc_new_account_ok (aw);
+ break;
+ case EDIT_ACCOUNT:
+ DEBUG("edit acct dialog, OK");
+ gnc_edit_account_ok (aw);
+ break;
+ default:
+ g_assert_not_reached ();
+ return;
+ }
+ break;
+ case GTK_RESPONSE_HELP:
+ switch (aw->dialog_type)
+ {
+ case NEW_ACCOUNT:
+ DEBUG("new acct dialog, HELP");
+ gnc_gnome_help(HF_HELP, HL_ACC);
+ break;
+ case EDIT_ACCOUNT:
+ DEBUG("edit acct dialog, HELP");
+ gnc_gnome_help(HF_HELP, HL_ACCEDIT);
+ break;
+ default:
+ g_assert_not_reached ();
+ return;
+ }
+ break;
+ case GTK_RESPONSE_CANCEL:
+ default:
+ DEBUG("CANCEL");
+ gnc_close_gui_component (aw->component_id);
+ break;
+ }
+ LEAVE(" ");
}
static void
gnc_account_window_destroy_cb (GtkObject *object, gpointer data)
{
- AccountWindow *aw = data;
- Account *account;
+ AccountWindow *aw = data;
+ Account *account;
- ENTER("object %p, aw %p", object, aw);
- account = aw_get_account (aw);
+ ENTER("object %p, aw %p", object, aw);
+ account = aw_get_account (aw);
- gnc_suspend_gui_refresh ();
+ gnc_suspend_gui_refresh ();
- switch (aw->dialog_type)
- {
+ switch (aw->dialog_type)
+ {
case NEW_ACCOUNT:
- if (account != NULL)
- {
- xaccAccountBeginEdit (account);
- xaccAccountDestroy (account);
- aw->account = *xaccGUIDNULL ();
- }
+ if (account != NULL)
+ {
+ xaccAccountBeginEdit (account);
+ xaccAccountDestroy (account);
+ aw->account = *xaccGUIDNULL ();
+ }
- DEBUG ("account add window destroyed\n");
- break;
+ DEBUG ("account add window destroyed\n");
+ break;
case EDIT_ACCOUNT:
- break;
+ break;
default:
- PERR ("unexpected dialog type\n");
- gnc_resume_gui_refresh ();
- LEAVE(" ");
- return;
- }
+ PERR ("unexpected dialog type\n");
+ gnc_resume_gui_refresh ();
+ LEAVE(" ");
+ return;
+ }
- gnc_unregister_gui_component (aw->component_id);
+ gnc_unregister_gui_component (aw->component_id);
- gnc_resume_gui_refresh ();
+ gnc_resume_gui_refresh ();
- if (aw->subaccount_names) {
- g_strfreev(aw->subaccount_names);
- aw->subaccount_names = NULL;
- aw->next_name = NULL;
- }
+ if (aw->subaccount_names)
+ {
+ g_strfreev(aw->subaccount_names);
+ aw->subaccount_names = NULL;
+ aw->next_name = NULL;
+ }
- g_free (aw);
- LEAVE(" ");
+ g_free (aw);
+ LEAVE(" ");
}
static void
gnc_account_parent_changed_cb (GtkTreeSelection *selection, gpointer data)
{
- AccountWindow *aw = data;
- Account *parent_account;
- guint32 types, old_types;
- GtkTreeModel *type_model;
- GtkTreeSelection *type_selection;
- gboolean scroll_to = FALSE;
+ AccountWindow *aw = data;
+ Account *parent_account;
+ guint32 types, old_types;
+ GtkTreeModel *type_model;
+ GtkTreeSelection *type_selection;
+ gboolean scroll_to = FALSE;
- g_return_if_fail (aw);
+ g_return_if_fail (aw);
- parent_account = gnc_tree_view_account_get_selected_account (
- GNC_TREE_VIEW_ACCOUNT (aw->parent_tree));
- if (!parent_account)
- return;
+ parent_account = gnc_tree_view_account_get_selected_account (
+ GNC_TREE_VIEW_ACCOUNT (aw->parent_tree));
+ if (!parent_account)
+ return;
- if (gnc_account_is_root(parent_account)) {
- types = aw->valid_types;
- } else {
- types = aw->valid_types &
- xaccParentAccountTypesCompatibleWith (xaccAccountGetType (parent_account));
- }
+ if (gnc_account_is_root(parent_account))
+ {
+ types = aw->valid_types;
+ }
+ else
+ {
+ types = aw->valid_types &
+ xaccParentAccountTypesCompatibleWith (xaccAccountGetType (parent_account));
+ }
- type_model = gtk_tree_view_get_model (GTK_TREE_VIEW (aw->type_view));
- if (!type_model)
- return;
+ type_model = gtk_tree_view_get_model (GTK_TREE_VIEW (aw->type_view));
+ if (!type_model)
+ return;
- if (aw->type != aw->preferred_account_type &&
- (types & (1 << aw->preferred_account_type)) != 0) {
- /* we can change back to the preferred account type */
- aw->type = aw->preferred_account_type;
- scroll_to = TRUE;
- }
- else if ((types & (1 << aw->type)) == 0) {
- /* our type is invalid now */
- aw->type = ACCT_TYPE_INVALID;
- }
- else {
- /* no type change, but maybe list of valid types changed */
- old_types = gnc_tree_model_account_types_get_mask (type_model);
- if (old_types != types)
- scroll_to = TRUE;
- }
+ if (aw->type != aw->preferred_account_type &&
+ (types & (1 << aw->preferred_account_type)) != 0)
+ {
+ /* we can change back to the preferred account type */
+ aw->type = aw->preferred_account_type;
+ scroll_to = TRUE;
+ }
+ else if ((types & (1 << aw->type)) == 0)
+ {
+ /* our type is invalid now */
+ aw->type = ACCT_TYPE_INVALID;
+ }
+ else
+ {
+ /* no type change, but maybe list of valid types changed */
+ old_types = gnc_tree_model_account_types_get_mask (type_model);
+ if (old_types != types)
+ scroll_to = TRUE;
+ }
- gnc_tree_model_account_types_set_mask (type_model, types);
+ gnc_tree_model_account_types_set_mask (type_model, types);
- if (scroll_to) {
- type_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (aw->type_view));
- gnc_tree_model_account_types_set_selection(type_selection, 1 << aw->type);
- }
+ if (scroll_to)
+ {
+ type_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (aw->type_view));
+ gnc_tree_model_account_types_set_selection(type_selection, 1 << aw->type);
+ }
- gnc_account_window_set_name(aw);
+ gnc_account_window_set_name(aw);
}
static void
gnc_account_type_changed_cb (GtkTreeSelection *selection, gpointer data)
{
- AccountWindow *aw = data;
- gboolean sensitive;
- GNCAccountType type_id;
+ AccountWindow *aw = data;
+ gboolean sensitive;
+ GNCAccountType type_id;
- g_return_if_fail (aw != NULL);
+ g_return_if_fail (aw != NULL);
- sensitive = FALSE;
+ sensitive = FALSE;
- type_id = gnc_tree_model_account_types_get_selection_single(selection);
- if (type_id == ACCT_TYPE_NONE) {
- aw->type = ACCT_TYPE_INVALID;
- } else {
- aw->type = type_id;
- aw->preferred_account_type = type_id;
+ type_id = gnc_tree_model_account_types_get_selection_single(selection);
+ if (type_id == ACCT_TYPE_NONE)
+ {
+ aw->type = ACCT_TYPE_INVALID;
+ }
+ else
+ {
+ aw->type = type_id;
+ aw->preferred_account_type = type_id;
- gnc_account_commodity_from_type (aw, TRUE);
+ gnc_account_commodity_from_type (aw, TRUE);
- sensitive = (aw->type != ACCT_TYPE_EQUITY &&
- aw->type != ACCT_TYPE_CURRENCY &&
- aw->type != ACCT_TYPE_STOCK &&
- aw->type != ACCT_TYPE_MUTUAL &&
- aw->type != ACCT_TYPE_TRADING);
- }
+ sensitive = (aw->type != ACCT_TYPE_EQUITY &&
+ aw->type != ACCT_TYPE_CURRENCY &&
+ aw->type != ACCT_TYPE_STOCK &&
+ aw->type != ACCT_TYPE_MUTUAL &&
+ aw->type != ACCT_TYPE_TRADING);
+ }
- gtk_widget_set_sensitive (aw->opening_balance_page, sensitive);
+ gtk_widget_set_sensitive (aw->opening_balance_page, sensitive);
- if (!sensitive) {
- gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (aw->opening_balance_edit),
- gnc_numeric_zero ());
- }
+ if (!sensitive)
+ {
+ gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (aw->opening_balance_edit),
+ gnc_numeric_zero ());
+ }
}
static void
gnc_account_type_view_create (AccountWindow *aw)
{
- GtkTreeModel *model;
- GtkTreeSelection *selection;
- GtkCellRenderer *renderer;
- GtkTreeView *view;
+ GtkTreeModel *model;
+ GtkTreeSelection *selection;
+ GtkCellRenderer *renderer;
+ GtkTreeView *view;
- if (aw->valid_types == 0) {
- /* no type restrictions, choose aw->type */
- aw->valid_types = xaccAccountTypesValid () | (1 << aw->type);
- aw->preferred_account_type = aw->type;
- }
- else if ((aw->valid_types & (1 << aw->type)) != 0) {
- /* aw->type is valid */
- aw->preferred_account_type = aw->type;
- }
- else if ((aw->valid_types & (1 << last_used_account_type)) != 0) {
- /* last used account type is valid */
- aw->type = last_used_account_type;
- aw->preferred_account_type = last_used_account_type;
- }
- else {
- /* choose first valid account type */
- int i;
- aw->preferred_account_type = aw->type;
- aw->type = ACCT_TYPE_INVALID;
- for (i=0; i<32; i++)
- if ((aw->valid_types & (1 << i)) != 0) {
- aw->type = i;
- break;
- }
- }
+ if (aw->valid_types == 0)
+ {
+ /* no type restrictions, choose aw->type */
+ aw->valid_types = xaccAccountTypesValid () | (1 << aw->type);
+ aw->preferred_account_type = aw->type;
+ }
+ else if ((aw->valid_types & (1 << aw->type)) != 0)
+ {
+ /* aw->type is valid */
+ aw->preferred_account_type = aw->type;
+ }
+ else if ((aw->valid_types & (1 << last_used_account_type)) != 0)
+ {
+ /* last used account type is valid */
+ aw->type = last_used_account_type;
+ aw->preferred_account_type = last_used_account_type;
+ }
+ else
+ {
+ /* choose first valid account type */
+ int i;
+ aw->preferred_account_type = aw->type;
+ aw->type = ACCT_TYPE_INVALID;
+ for (i = 0; i < 32; i++)
+ if ((aw->valid_types & (1 << i)) != 0)
+ {
+ aw->type = i;
+ break;
+ }
+ }
- model = gnc_tree_model_account_types_filter_using_mask (aw->valid_types);
+ model = gnc_tree_model_account_types_filter_using_mask (aw->valid_types);
- view = GTK_TREE_VIEW (aw->type_view);
- gtk_tree_view_set_model (view, model);
- g_object_unref (G_OBJECT (model));
+ view = GTK_TREE_VIEW (aw->type_view);
+ gtk_tree_view_set_model (view, model);
+ g_object_unref (G_OBJECT (model));
- renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_insert_column_with_attributes (
- view, -1, NULL, renderer,
- "text", GNC_TREE_MODEL_ACCOUNT_TYPES_COL_NAME,
- NULL);
- gtk_tree_view_set_search_column (view, GNC_TREE_MODEL_ACCOUNT_TYPES_COL_NAME);
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_insert_column_with_attributes (
+ view, -1, NULL, renderer,
+ "text", GNC_TREE_MODEL_ACCOUNT_TYPES_COL_NAME,
+ NULL);
+ gtk_tree_view_set_search_column (view, GNC_TREE_MODEL_ACCOUNT_TYPES_COL_NAME);
- selection = gtk_tree_view_get_selection (view);
- g_signal_connect (G_OBJECT (selection), "changed",
- G_CALLBACK (gnc_account_type_changed_cb), aw);
+ selection = gtk_tree_view_get_selection (view);
+ g_signal_connect (G_OBJECT (selection), "changed",
+ G_CALLBACK (gnc_account_type_changed_cb), aw);
- gnc_tree_model_account_types_set_selection(selection, 1 << aw->type);
+ gnc_tree_model_account_types_set_selection(selection, 1 << aw->type);
}
static void
gnc_account_name_changed_cb(GtkWidget *widget, gpointer data)
{
- AccountWindow *aw = data;
+ AccountWindow *aw = data;
- gnc_account_window_set_name (aw);
+ gnc_account_window_set_name (aw);
}
static void
gnc_account_color_default_cb(GtkWidget *widget, gpointer data)
{
- GdkColor color;
- AccountWindow *aw = data;
+ GdkColor color;
+ AccountWindow *aw = data;
- gdk_color_parse( DEFAULT_COLOR, &color);
- gtk_color_button_set_color(GTK_COLOR_BUTTON(aw->color_entry_button), &color);
+ gdk_color_parse( DEFAULT_COLOR, &color);
+ gtk_color_button_set_color(GTK_COLOR_BUTTON(aw->color_entry_button), &color);
}
static void
commodity_changed_cb (GNCGeneralSelect *gsl, gpointer data)
{
- AccountWindow *aw = data;
- gnc_commodity *currency;
- GtkTreeSelection *selection;
+ AccountWindow *aw = data;
+ gnc_commodity *currency;
+ GtkTreeSelection *selection;
- currency = (gnc_commodity *) gnc_general_select_get_selected (gsl);
- if (!currency)
- return;
+ currency = (gnc_commodity *) gnc_general_select_get_selected (gsl);
+ if (!currency)
+ return;
- gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (aw->opening_balance_edit),
- gnc_commodity_get_fraction (currency));
- gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (aw->opening_balance_edit),
- gnc_commodity_print_info (currency, FALSE));
+ gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (aw->opening_balance_edit),
+ gnc_commodity_get_fraction (currency));
+ gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (aw->opening_balance_edit),
+ gnc_commodity_print_info (currency, FALSE));
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (aw->transfer_tree));
- gtk_tree_selection_unselect_all (selection);
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (aw->transfer_tree));
+ gtk_tree_selection_unselect_all (selection);
}
static gboolean
account_commodity_filter (GtkTreeSelection *selection,
- GtkTreeModel *unused_model,
- GtkTreePath *s_path,
- gboolean path_currently_selected,
- gpointer user_data)
+ GtkTreeModel *unused_model,
+ GtkTreePath *s_path,
+ gboolean path_currently_selected,
+ gpointer user_data)
{
- gnc_commodity *commodity;
- AccountWindow *aw;
- Account *account;
+ gnc_commodity *commodity;
+ AccountWindow *aw;
+ Account *account;
- g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), FALSE);
+ g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), FALSE);
- aw = user_data;
+ aw = user_data;
- if (path_currently_selected) {
- /* already selected, don't waste time. */
- return TRUE;
- }
+ if (path_currently_selected)
+ {
+ /* already selected, don't waste time. */
+ return TRUE;
+ }
- account = gnc_tree_view_account_get_account_from_path (GNC_TREE_VIEW_ACCOUNT (aw->transfer_tree), s_path);
- if (!account) {
- return FALSE;
- }
+ account = gnc_tree_view_account_get_account_from_path (GNC_TREE_VIEW_ACCOUNT (aw->transfer_tree), s_path);
+ if (!account)
+ {
+ return FALSE;
+ }
- commodity = (gnc_commodity *)
- gnc_general_select_get_selected (GNC_GENERAL_SELECT (aw->commodity_edit));
+ commodity = (gnc_commodity *)
+ gnc_general_select_get_selected (GNC_GENERAL_SELECT (aw->commodity_edit));
- return gnc_commodity_equiv (xaccAccountGetCommodity (account), commodity);
+ return gnc_commodity_equiv (xaccAccountGetCommodity (account), commodity);
}
static void
opening_equity_cb (GtkWidget *w, gpointer data)
{
- AccountWindow *aw = data;
- gboolean use_equity;
+ AccountWindow *aw = data;
+ gboolean use_equity;
- use_equity = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
+ use_equity = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
- gtk_widget_set_sensitive (aw->transfer_account_scroll, !use_equity);
+ gtk_widget_set_sensitive (aw->transfer_account_scroll, !use_equity);
}
/********************************************************************\
* gnc_account_window_create *
* creates a window to create a new account. *
- * *
+ * *
* Args: aw - the information structure for this window *
* Return: the created window *
\*******************************************************************/
static void
gnc_account_window_create(AccountWindow *aw)
{
- GtkWidget *amount;
- GObject *awo;
- GtkWidget *box;
- GtkWidget *label;
- GladeXML *xml;
- GtkTreeSelection *selection;
+ GtkWidget *amount;
+ GObject *awo;
+ GtkWidget *box;
+ GtkWidget *label;
+ GladeXML *xml;
+ GtkTreeSelection *selection;
- ENTER("aw %p, modal %d", aw, aw->modal);
- xml = gnc_glade_xml_new ("account.glade", "Account Dialog");
+ ENTER("aw %p, modal %d", aw, aw->modal);
+ xml = gnc_glade_xml_new ("account.glade", "Account Dialog");
- aw->dialog = glade_xml_get_widget (xml, "Account Dialog");
- awo = G_OBJECT (aw->dialog);
+ aw->dialog = glade_xml_get_widget (xml, "Account Dialog");
+ awo = G_OBJECT (aw->dialog);
- g_object_set_data (awo, "dialog_info", aw);
+ g_object_set_data (awo, "dialog_info", aw);
- g_signal_connect (awo, "destroy",
- G_CALLBACK (gnc_account_window_destroy_cb), aw);
+ g_signal_connect (awo, "destroy",
+ G_CALLBACK (gnc_account_window_destroy_cb), aw);
- if (!aw->modal)
- g_signal_connect (awo, "response",
- G_CALLBACK (gnc_account_window_response_cb), aw);
- else
- gtk_window_set_modal (GTK_WINDOW (aw->dialog), TRUE);
+ if (!aw->modal)
+ g_signal_connect (awo, "response",
+ G_CALLBACK (gnc_account_window_response_cb), aw);
+ else
+ gtk_window_set_modal (GTK_WINDOW (aw->dialog), TRUE);
- aw->notebook = glade_xml_get_widget (xml, "account_notebook");
+ aw->notebook = glade_xml_get_widget (xml, "account_notebook");
- aw->name_entry = glade_xml_get_widget (xml, "name_entry");
- g_signal_connect (G_OBJECT (aw->name_entry), "changed",
- G_CALLBACK (gnc_account_name_changed_cb), aw);
+ aw->name_entry = glade_xml_get_widget (xml, "name_entry");
+ g_signal_connect (G_OBJECT (aw->name_entry), "changed",
+ G_CALLBACK (gnc_account_name_changed_cb), aw);
- aw->description_entry = glade_xml_get_widget (xml, "description_entry");
+ aw->description_entry = glade_xml_get_widget (xml, "description_entry");
- aw->color_entry_button = glade_xml_get_widget (xml, "color_entry_button");
+ aw->color_entry_button = glade_xml_get_widget (xml, "color_entry_button");
- aw->color_default_button = glade_xml_get_widget (xml, "color_default_button");
- g_signal_connect (G_OBJECT (aw->color_default_button), "clicked",
- G_CALLBACK (gnc_account_color_default_cb), aw);
+ aw->color_default_button = glade_xml_get_widget (xml, "color_default_button");
+ g_signal_connect (G_OBJECT (aw->color_default_button), "clicked",
+ G_CALLBACK (gnc_account_color_default_cb), aw);
- aw->code_entry = glade_xml_get_widget (xml, "code_entry");
- aw->notes_text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (glade_xml_get_widget (xml, "notes_text")));
+ aw->code_entry = glade_xml_get_widget (xml, "code_entry");
+ aw->notes_text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (glade_xml_get_widget (xml, "notes_text")));
- box = glade_xml_get_widget (xml, "commodity_hbox");
- aw->commodity_edit = gnc_general_select_new (GNC_GENERAL_SELECT_TYPE_SELECT,
- gnc_commodity_edit_get_string,
- gnc_commodity_edit_new_select,
- &aw->commodity_mode);
- gtk_box_pack_start(GTK_BOX(box), aw->commodity_edit, TRUE, TRUE, 0);
- gtk_widget_show (aw->commodity_edit);
+ box = glade_xml_get_widget (xml, "commodity_hbox");
+ aw->commodity_edit = gnc_general_select_new (GNC_GENERAL_SELECT_TYPE_SELECT,
+ gnc_commodity_edit_get_string,
+ gnc_commodity_edit_new_select,
+ &aw->commodity_mode);
+ gtk_box_pack_start(GTK_BOX(box), aw->commodity_edit, TRUE, TRUE, 0);
+ gtk_widget_show (aw->commodity_edit);
- label = glade_xml_get_widget (xml, "security_label");
- gnc_general_select_make_mnemonic_target (GNC_GENERAL_SELECT(aw->commodity_edit), label);
+ label = glade_xml_get_widget (xml, "security_label");
+ gnc_general_select_make_mnemonic_target (GNC_GENERAL_SELECT(aw->commodity_edit), label);
- g_signal_connect (G_OBJECT (aw->commodity_edit), "changed",
- G_CALLBACK (commodity_changed_cb), aw);
+ g_signal_connect (G_OBJECT (aw->commodity_edit), "changed",
+ G_CALLBACK (commodity_changed_cb), aw);
- aw->account_scu = glade_xml_get_widget (xml, "account_scu");
+ aw->account_scu = glade_xml_get_widget (xml, "account_scu");
- box = glade_xml_get_widget (xml, "parent_scroll");
+ box = glade_xml_get_widget (xml, "parent_scroll");
- aw->parent_tree = gnc_tree_view_account_new(TRUE);
- gtk_container_add(GTK_CONTAINER(box), GTK_WIDGET(aw->parent_tree));
- gtk_widget_show(GTK_WIDGET(aw->parent_tree));
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (aw->parent_tree));
- g_signal_connect (G_OBJECT (selection), "changed",
- G_CALLBACK (gnc_account_parent_changed_cb), aw);
+ aw->parent_tree = gnc_tree_view_account_new(TRUE);
+ gtk_container_add(GTK_CONTAINER(box), GTK_WIDGET(aw->parent_tree));
+ gtk_widget_show(GTK_WIDGET(aw->parent_tree));
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (aw->parent_tree));
+ g_signal_connect (G_OBJECT (selection), "changed",
+ G_CALLBACK (gnc_account_parent_changed_cb), aw);
- aw->tax_related_button = glade_xml_get_widget (xml, "tax_related_button");
- aw->placeholder_button = glade_xml_get_widget (xml, "placeholder_button");
- aw->hidden_button = glade_xml_get_widget (xml, "hidden_button");
+ aw->tax_related_button = glade_xml_get_widget (xml, "tax_related_button");
+ aw->placeholder_button = glade_xml_get_widget (xml, "placeholder_button");
+ aw->hidden_button = glade_xml_get_widget (xml, "hidden_button");
- box = glade_xml_get_widget (xml, "opening_balance_box");
- amount = gnc_amount_edit_new ();
- aw->opening_balance_edit = amount;
- gtk_box_pack_start(GTK_BOX(box), amount, TRUE, TRUE, 0);
- gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (amount), TRUE);
- gtk_widget_show (amount);
+ box = glade_xml_get_widget (xml, "opening_balance_box");
+ amount = gnc_amount_edit_new ();
+ aw->opening_balance_edit = amount;
+ gtk_box_pack_start(GTK_BOX(box), amount, TRUE, TRUE, 0);
+ gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (amount), TRUE);
+ gtk_widget_show (amount);
- label = glade_xml_get_widget (xml, "balance_label");
- gtk_label_set_mnemonic_widget (GTK_LABEL(label), amount);
+ label = glade_xml_get_widget (xml, "balance_label");
+ gtk_label_set_mnemonic_widget (GTK_LABEL(label), amount);
- box = glade_xml_get_widget (xml, "opening_balance_date_box");
- aw->opening_balance_date_edit = glade_xml_get_widget (xml, "opening_balance_date_edit");
+ box = glade_xml_get_widget (xml, "opening_balance_date_box");
+ aw->opening_balance_date_edit = glade_xml_get_widget (xml, "opening_balance_date_edit");
- aw->opening_balance_page =
- gtk_notebook_get_nth_page (GTK_NOTEBOOK (aw->notebook), 1);
+ aw->opening_balance_page =
+ gtk_notebook_get_nth_page (GTK_NOTEBOOK (aw->notebook), 1);
- aw->opening_equity_radio = glade_xml_get_widget (xml,
- "opening_equity_radio");
- g_signal_connect (G_OBJECT (aw->opening_equity_radio), "toggled",
- G_CALLBACK (opening_equity_cb), aw);
+ aw->opening_equity_radio = glade_xml_get_widget (xml,
+ "opening_equity_radio");
+ g_signal_connect (G_OBJECT (aw->opening_equity_radio), "toggled",
+ G_CALLBACK (opening_equity_cb), aw);
- box = glade_xml_get_widget (xml, "transfer_account_scroll");
- aw->transfer_account_scroll = box;
+ box = glade_xml_get_widget (xml, "transfer_account_scroll");
+ aw->transfer_account_scroll = box;
- aw->transfer_tree = GTK_WIDGET(gnc_tree_view_account_new(FALSE));
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(aw->transfer_tree));
- gtk_tree_selection_set_select_function(selection, account_commodity_filter, aw, NULL);
+ aw->transfer_tree = GTK_WIDGET(gnc_tree_view_account_new(FALSE));
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(aw->transfer_tree));
+ gtk_tree_selection_set_select_function(selection, account_commodity_filter, aw, NULL);
- gtk_container_add(GTK_CONTAINER(box), GTK_WIDGET(aw->transfer_tree));
- gtk_widget_show (GTK_WIDGET(aw->transfer_tree));
+ gtk_container_add(GTK_CONTAINER(box), GTK_WIDGET(aw->transfer_tree));
+ gtk_widget_show (GTK_WIDGET(aw->transfer_tree));
- label = glade_xml_get_widget (xml, "parent_label");
- gtk_label_set_mnemonic_widget (GTK_LABEL(label), GTK_WIDGET(aw->parent_tree));
+ label = glade_xml_get_widget (xml, "parent_label");
+ gtk_label_set_mnemonic_widget (GTK_LABEL(label), GTK_WIDGET(aw->parent_tree));
- /* This goes at the end so the select callback has good data. */
- aw->type_view = glade_xml_get_widget (xml, "type_view");
- gnc_account_type_view_create (aw);
+ /* This goes at the end so the select callback has good data. */
+ aw->type_view = glade_xml_get_widget (xml, "type_view");
+ gnc_account_type_view_create (aw);
- gnc_restore_window_size (GCONF_SECTION, GTK_WINDOW(aw->dialog));
+ gnc_restore_window_size (GCONF_SECTION, GTK_WINDOW(aw->dialog));
- gtk_widget_grab_focus(GTK_WIDGET(aw->name_entry));
- LEAVE(" ");
+ gtk_widget_grab_focus(GTK_WIDGET(aw->name_entry));
+ LEAVE(" ");
}
static char *
get_ui_fullname (AccountWindow *aw)
{
- Account *parent_account;
- char *fullname;
- const gchar *name;
+ Account *parent_account;
+ char *fullname;
+ const gchar *name;
- name = gtk_entry_get_text (GTK_ENTRY(aw->name_entry));
- if (!name || *name == '\0')
- name = _("<No name>");
+ name = gtk_entry_get_text (GTK_ENTRY(aw->name_entry));
+ if (!name || *name == '\0')
+ name = _("<No name>");
- parent_account = gnc_tree_view_account_get_selected_account (GNC_TREE_VIEW_ACCOUNT (aw->parent_tree));
+ parent_account = gnc_tree_view_account_get_selected_account (GNC_TREE_VIEW_ACCOUNT (aw->parent_tree));
- if (parent_account && !gnc_account_is_root(parent_account))
- {
- char *parent_name;
- const gchar *separator;
+ if (parent_account && !gnc_account_is_root(parent_account))
+ {
+ char *parent_name;
+ const gchar *separator;
- parent_name = gnc_account_get_full_name (parent_account);
+ parent_name = gnc_account_get_full_name (parent_account);
- separator = gnc_get_account_separator_string ();
- fullname = g_strconcat (parent_name, separator, name, NULL);
+ separator = gnc_get_account_separator_string ();
+ fullname = g_strconcat (parent_name, separator, name, NULL);
- g_free (parent_name);
- }
- else
- fullname = g_strdup (name);
+ g_free (parent_name);
+ }
+ else
+ fullname = g_strdup (name);
- return fullname;
+ return fullname;
}
static void
gnc_account_window_set_name (AccountWindow *aw)
{
- char *fullname;
- char *title;
+ char *fullname;
+ char *title;
- if (!aw || !aw->parent_tree)
- return;
+ if (!aw || !aw->parent_tree)
+ return;
- fullname = get_ui_fullname (aw);
+ fullname = get_ui_fullname (aw);
- if (aw->dialog_type == EDIT_ACCOUNT)
- title = g_strconcat(_("Edit Account"), " - ", fullname, NULL);
- else if (aw->next_name && (g_strv_length(aw->next_name) > 0))
- {
- const char *format = _("(%d) New Accounts");
- char *prefix;
+ if (aw->dialog_type == EDIT_ACCOUNT)
+ title = g_strconcat(_("Edit Account"), " - ", fullname, NULL);
+ else if (aw->next_name && (g_strv_length(aw->next_name) > 0))
+ {
+ const char *format = _("(%d) New Accounts");
+ char *prefix;
- prefix = g_strdup_printf (format, g_strv_length(aw->next_name) + 1);
+ prefix = g_strdup_printf (format, g_strv_length(aw->next_name) + 1);
- title = g_strconcat (prefix, " - ", fullname, " ...", NULL);
+ title = g_strconcat (prefix, " - ", fullname, " ...", NULL);
- g_free (prefix);
- }
- else
- title = g_strconcat (_("New Account"), " - ", fullname, NULL);
+ g_free (prefix);
+ }
+ else
+ title = g_strconcat (_("New Account"), " - ", fullname, NULL);
- gtk_window_set_title (GTK_WINDOW(aw->dialog), title);
+ gtk_window_set_title (GTK_WINDOW(aw->dialog), title);
- g_free (fullname);
- g_free (title);
+ g_free (fullname);
+ g_free (title);
}
static void
close_handler (gpointer user_data)
{
- AccountWindow *aw = user_data;
+ AccountWindow *aw = user_data;
- ENTER("aw %p, modal %d", aw, aw->modal);
- gnc_save_window_size (GCONF_SECTION, GTK_WINDOW(aw->dialog));
+ ENTER("aw %p, modal %d", aw, aw->modal);
+ gnc_save_window_size (GCONF_SECTION, GTK_WINDOW(aw->dialog));
- gtk_widget_destroy (GTK_WIDGET (aw->dialog));
- LEAVE(" ");
+ gtk_widget_destroy (GTK_WIDGET (aw->dialog));
+ LEAVE(" ");
}
@@ -1405,40 +1457,40 @@
static void
gnc_ui_refresh_account_window (AccountWindow *aw)
{
- if (aw == NULL)
- return;
+ if (aw == NULL)
+ return;
-/* gnc_account_tree_refresh (GNC_ACCOUNT_TREE(aw->parent_tree));*/
+ /* gnc_account_tree_refresh (GNC_ACCOUNT_TREE(aw->parent_tree));*/
- gnc_account_window_set_name (aw);
+ gnc_account_window_set_name (aw);
}
static void
refresh_handler (GHashTable *changes, gpointer user_data)
{
- AccountWindow *aw = user_data;
- const EventInfo *info;
- Account *account;
+ AccountWindow *aw = user_data;
+ const EventInfo *info;
+ Account *account;
- account = aw_get_account (aw);
- if (!account)
- {
- gnc_close_gui_component (aw->component_id);
- return;
- }
+ account = aw_get_account (aw);
+ if (!account)
+ {
+ gnc_close_gui_component (aw->component_id);
+ return;
+ }
- if (changes)
- {
- info = gnc_gui_get_entity_events (changes, &aw->account);
- if (info && (info->event_mask & QOF_EVENT_DESTROY))
+ if (changes)
{
- gnc_close_gui_component (aw->component_id);
- return;
+ info = gnc_gui_get_entity_events (changes, &aw->account);
+ if (info && (info->event_mask & QOF_EVENT_DESTROY))
+ {
+ gnc_close_gui_component (aw->component_id);
+ return;
+ }
}
- }
- gnc_ui_refresh_account_window (aw);
+ gnc_ui_refresh_account_window (aw);
}
@@ -1446,137 +1498,149 @@
gnc_ui_new_account_window_internal (QofBook *book,
Account *base_account,
gchar **subaccount_names,
- GList *valid_types,
- gnc_commodity * default_commodity,
- gboolean modal)
+ GList *valid_types,
+ gnc_commodity * default_commodity,
+ gboolean modal)
{
- gnc_commodity *commodity, *parent_commodity;
- AccountWindow *aw;
- Account *account;
- GList *list;
+ gnc_commodity *commodity, *parent_commodity;
+ AccountWindow *aw;
+ Account *account;
+ GList *list;
- g_return_val_if_fail(book, NULL);
+ g_return_val_if_fail(book, NULL);
- aw = g_new0 (AccountWindow, 1);
+ aw = g_new0 (AccountWindow, 1);
- aw->book = book;
- aw->modal = modal;
- aw->dialog_type = NEW_ACCOUNT;
+ aw->book = book;
+ aw->modal = modal;
+ aw->dialog_type = NEW_ACCOUNT;
- aw->valid_types = 0;
- for (list = valid_types; list; list = list->next)
- aw->valid_types |= (1 << GPOINTER_TO_INT (list->data));
+ aw->valid_types = 0;
+ for (list = valid_types; list; list = list->next)
+ aw->valid_types |= (1 << GPOINTER_TO_INT (list->data));
- account = xaccMallocAccount (book);
- aw->account = *xaccAccountGetGUID (account);
+ account = xaccMallocAccount (book);
+ aw->account = *xaccAccountGetGUID (account);
- if (base_account) {
- aw->type = xaccAccountGetType (base_account);
- parent_commodity = xaccAccountGetCommodity (base_account);
- } else {
- aw->type = last_used_account_type;
- parent_commodity = gnc_default_currency ();
- }
+ if (base_account)
+ {
+ aw->type = xaccAccountGetType (base_account);
+ parent_commodity = xaccAccountGetCommodity (base_account);
+ }
+ else
+ {
+ aw->type = last_used_account_type;
+ parent_commodity = gnc_default_currency ();
+ }
- gnc_suspend_gui_refresh ();
+ gnc_suspend_gui_refresh ();
- if (subaccount_names && *subaccount_names)
- {
- xaccAccountSetName (account, subaccount_names[0]);
- aw->subaccount_names = subaccount_names;
- aw->next_name = subaccount_names + 1;
- }
+ if (subaccount_names && *subaccount_names)
+ {
+ xaccAccountSetName (account, subaccount_names[0]);
+ aw->subaccount_names = subaccount_names;
+ aw->next_name = subaccount_names + 1;
+ }
- gnc_account_window_create (aw);
- gnc_account_to_ui (aw);
+ gnc_account_window_create (aw);
+ gnc_account_to_ui (aw);
- gnc_resume_gui_refresh ();
+ gnc_resume_gui_refresh ();
- if (default_commodity != NULL) {
- commodity = default_commodity;
- if ((aw->type == ACCT_TYPE_STOCK) || (aw->type == ACCT_TYPE_MUTUAL))
- {
- gtk_entry_set_text(GTK_ENTRY(aw->name_entry),
- (gpointer) gnc_commodity_get_mnemonic(commodity));
- gtk_entry_set_text(GTK_ENTRY(aw->description_entry),
- (gpointer) gnc_commodity_get_fullname(commodity));
+ if (default_commodity != NULL)
+ {
+ commodity = default_commodity;
+ if ((aw->type == ACCT_TYPE_STOCK) || (aw->type == ACCT_TYPE_MUTUAL))
+ {
+ gtk_entry_set_text(GTK_ENTRY(aw->name_entry),
+ (gpointer) gnc_commodity_get_mnemonic(commodity));
+ gtk_entry_set_text(GTK_ENTRY(aw->description_entry),
+ (gpointer) gnc_commodity_get_fullname(commodity));
}
- } else if ((aw->type != ACCT_TYPE_STOCK) && (aw->type != ACCT_TYPE_MUTUAL)) {
- commodity = parent_commodity;
- } else {
- commodity = NULL;
- }
- gnc_general_select_set_selected (GNC_GENERAL_SELECT (aw->commodity_edit),
- commodity);
- gnc_account_commodity_from_type (aw, FALSE);
+ }
+ else if ((aw->type != ACCT_TYPE_STOCK) && (aw->type != ACCT_TYPE_MUTUAL))
+ {
+ commodity = parent_commodity;
+ }
+ else
+ {
+ commodity = NULL;
+ }
+ gnc_general_select_set_selected (GNC_GENERAL_SELECT (aw->commodity_edit),
+ commodity);
+ gnc_account_commodity_from_type (aw, FALSE);
- if (base_account == NULL) {
- base_account = gnc_book_get_root_account(book);
- }
+ if (base_account == NULL)
+ {
+ base_account = gnc_book_get_root_account(book);
+ }
- gtk_tree_view_collapse_all (aw->parent_tree);
- gnc_tree_view_account_set_selected_account (
- GNC_TREE_VIEW_ACCOUNT (aw->parent_tree), base_account);
+ gtk_tree_view_collapse_all (aw->parent_tree);
+ gnc_tree_view_account_set_selected_account (
+ GNC_TREE_VIEW_ACCOUNT (aw->parent_tree), base_account);
- gtk_widget_show (aw->dialog);
+ gtk_widget_show (aw->dialog);
- gnc_window_adjust_for_screen (GTK_WINDOW(aw->dialog));
+ gnc_window_adjust_for_screen (GTK_WINDOW(aw->dialog));
- gnc_account_window_set_name (aw);
+ gnc_account_window_set_name (aw);
- aw->component_id = gnc_register_gui_component (DIALOG_NEW_ACCOUNT_CM_CLASS,
- refresh_handler,
- modal ? NULL : close_handler,
- aw);
+ aw->component_id = gnc_register_gui_component (DIALOG_NEW_ACCOUNT_CM_CLASS,
+ refresh_handler,
+ modal ? NULL : close_handler,
+ aw);
- gnc_gui_component_set_session (aw->component_id, gnc_get_current_session());
- gnc_gui_component_watch_entity_type (aw->component_id,
- GNC_ID_ACCOUNT,
- QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);
- return aw;
+ gnc_gui_component_set_session (aw->component_id, gnc_get_current_session());
+ gnc_gui_component_watch_entity_type (aw->component_id,
+ GNC_ID_ACCOUNT,
+ QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);
+ return aw;
}
static gchar **
gnc_split_account_name (QofBook *book, const char *in_name, Account **base_account)
{
- Account *root, *account;
- gchar **names, **ptr, **out_names;
- GList *list, *node;
+ Account *root, *account;
+ gchar **names, **ptr, **out_names;
+ GList *list, *node;
- root = gnc_book_get_root_account (book);
- list = gnc_account_get_children(root);
- names = g_strsplit(in_name, gnc_get_account_separator_string(), -1);
+ root = gnc_book_get_root_account (book);
+ list = gnc_account_get_children(root);
+ names = g_strsplit(in_name, gnc_get_account_separator_string(), -1);
- for (ptr = names; *ptr; ptr++) {
- /* Stop if there are no children at the current level. */
- if (list == NULL)
- break;
+ for (ptr = names; *ptr; ptr++)
+ {
+ /* Stop if there are no children at the current level. */
+ if (list == NULL)
+ break;
- /* Look for the first name in the children. */
- for (node = list; node; node = g_list_next(node)) {
- account = node->data;
+ /* Look for the first name in the children. */
+ for (node = list; node; node = g_list_next(node))
+ {
+ account = node->data;
- if (safe_strcmp(xaccAccountGetName (account), *ptr) == 0) {
- /* We found an account. */
- *base_account = account;
- break;
- }
- }
+ if (safe_strcmp(xaccAccountGetName (account), *ptr) == 0)
+ {
+ /* We found an account. */
+ *base_account = account;
+ break;
+ }
+ }
- /* Was there a match? If no, stop the traversal. */
- if (node == NULL)
- break;
+ /* Was there a match? If no, stop the traversal. */
+ if (node == NULL)
+ break;
- g_list_free(list);
- list = gnc_account_get_children (account);
- }
+ g_list_free(list);
+ list = gnc_account_get_children (account);
+ }
- out_names = g_strdupv(ptr);
- g_strfreev(names);
- if (list)
- g_list_free(list);
- return out_names;
+ out_names = g_strdupv(ptr);
+ g_strfreev(names);
+ if (list)
+ g_list_free(list);
+ return out_names;
}
@@ -1587,74 +1651,76 @@
Account *
gnc_ui_new_accounts_from_name_window (const char *name)
{
- return gnc_ui_new_accounts_from_name_with_defaults (name, NULL, NULL, NULL);
+ return gnc_ui_new_accounts_from_name_with_defaults (name, NULL, NULL, NULL);
}
Account *
gnc_ui_new_accounts_from_name_window_with_types (const char *name,
- GList *valid_types)
+ GList *valid_types)
{
- return gnc_ui_new_accounts_from_name_with_defaults(name, valid_types, NULL, NULL);
+ return gnc_ui_new_accounts_from_name_with_defaults(name, valid_types, NULL, NULL);
}
Account *
gnc_ui_new_accounts_from_name_with_defaults (const char *name,
- GList *valid_types,
- gnc_commodity * default_commodity,
- Account * parent)
+ GList *valid_types,
+ gnc_commodity * default_commodity,
+ Account * parent)
{
- QofBook *book;
- AccountWindow *aw;
- Account *base_account = NULL;
- Account *created_account = NULL;
- gchar ** subaccount_names;
- gint response;
- gboolean done = FALSE;
+ QofBook *book;
+ AccountWindow *aw;
+ Account *base_account = NULL;
+ Account *created_account = NULL;
+ gchar ** subaccount_names;
+ gint response;
+ gboolean done = FALSE;
- ENTER("name %s, valid %p, commodity %p, account %p",
- name, valid_types, default_commodity, parent);
- book = gnc_get_current_book();
- if (!name || *name == '\0')
- {
- subaccount_names = NULL;
- base_account = NULL;
- }
- else
- subaccount_names = gnc_split_account_name (book, name, &base_account);
+ ENTER("name %s, valid %p, commodity %p, account %p",
+ name, valid_types, default_commodity, parent);
+ book = gnc_get_current_book();
+ if (!name || *name == '\0')
+ {
+ subaccount_names = NULL;
+ base_account = NULL;
+ }
+ else
+ subaccount_names = gnc_split_account_name (book, name, &base_account);
- if (parent != NULL)
+ if (parent != NULL)
{
- base_account=parent;
+ base_account = parent;
}
- aw = gnc_ui_new_account_window_internal (book, base_account, subaccount_names,
- valid_types, default_commodity,
- TRUE);
+ aw = gnc_ui_new_account_window_internal (book, base_account, subaccount_names,
+ valid_types, default_commodity,
+ TRUE);
- while (!done) {
- response = gtk_dialog_run (GTK_DIALOG(aw->dialog));
+ while (!done)
+ {
+ response = gtk_dialog_run (GTK_DIALOG(aw->dialog));
- /* This can destroy the dialog */
- gnc_account_window_response_cb (GTK_DIALOG(aw->dialog), response, (gpointer)aw);
+ /* This can destroy the dialog */
+ gnc_account_window_response_cb (GTK_DIALOG(aw->dialog), response, (gpointer)aw);
- switch (response) {
- case GTK_RESPONSE_OK:
- created_account = aw->created_account;
- done = (created_account != NULL);
- break;
+ switch (response)
+ {
+ case GTK_RESPONSE_OK:
+ created_account = aw->created_account;
+ done = (created_account != NULL);
+ break;
- case GTK_RESPONSE_HELP:
- done = FALSE;
- break;
+ case GTK_RESPONSE_HELP:
+ done = FALSE;
+ break;
- default:
- done = TRUE;
- break;
+ default:
+ done = TRUE;
+ break;
+ }
}
- }
- close_handler(aw);
- LEAVE("created %s (%p)", xaccAccountGetName(created_account), created_account);
- return created_account;
+ close_handler(aw);
+ LEAVE("created %s (%p)", xaccAccountGetName(created_account), created_account);
+ return created_account;
}
/************************************************************
@@ -1664,102 +1730,103 @@
static gboolean
find_by_account (gpointer find_data, gpointer user_data)
{
- Account *account = find_data;
- AccountWindow *aw = user_data;
+ Account *account = find_data;
+ AccountWindow *aw = user_data;
- if (!aw)
- return FALSE;
+ if (!aw)
+ return FALSE;
- return guid_equal (&aw->account, xaccAccountGetGUID (account));
+ return guid_equal (&aw->account, xaccAccountGetGUID (account));
}
/*
* opens up a window to edit an account
- *
+ *
* Args: account - the account to edit
* Return: EditAccountWindow object
*/
void
gnc_ui_edit_account_window(Account *account)
{
- AccountWindow * aw;
- Account *parent;
+ AccountWindow * aw;
+ Account *parent;
- if (account == NULL)
- return;
+ if (account == NULL)
+ return;
- aw = gnc_find_first_gui_component (DIALOG_EDIT_ACCOUNT_CM_CLASS,
- find_by_account, account);
- if (aw) {
- gtk_window_present(GTK_WINDOW(aw->dialog));
- return;
- }
+ aw = gnc_find_first_gui_component (DIALOG_EDIT_ACCOUNT_CM_CLASS,
+ find_by_account, account);
+ if (aw)
+ {
+ gtk_window_present(GTK_WINDOW(aw->dialog));
+ return;
+ }
- aw = g_new0 (AccountWindow, 1);
+ aw = g_new0 (AccountWindow, 1);
- aw->book = gnc_account_get_book(account);
- aw->modal = FALSE;
- aw->dialog_type = EDIT_ACCOUNT;
- aw->account = *xaccAccountGetGUID (account);
- aw->subaccount_names = NULL;
- aw->type = xaccAccountGetType (account);
+ aw->book = gnc_account_get_book(account);
+ aw->modal = FALSE;
+ aw->dialog_type = EDIT_ACCOUNT;
+ aw->account = *xaccAccountGetGUID (account);
+ aw->subaccount_names = NULL;
+ aw->type = xaccAccountGetType (account);
- gnc_suspend_gui_refresh ();
+ gnc_suspend_gui_refresh ();
- gnc_account_window_create (aw);
- gnc_account_to_ui (aw);
+ gnc_account_window_create (aw);
+ gnc_account_to_ui (aw);
- gnc_resume_gui_refresh ();
+ gnc_resume_gui_refresh ();
- gtk_widget_show_all (aw->dialog);
- gtk_widget_hide (aw->opening_balance_page);
+ gtk_widget_show_all (aw->dialog);
+ gtk_widget_hide (aw->opening_balance_page);
- parent = gnc_account_get_parent (account);
- if (parent == NULL)
- parent = account; /* must be at the root */
+ parent = gnc_account_get_parent (account);
+ if (parent == NULL)
+ parent = account; /* must be at the root */
- gtk_tree_view_collapse_all (aw->parent_tree);
- gnc_tree_view_account_set_selected_account (
- GNC_TREE_VIEW_ACCOUNT(aw->parent_tree), parent);
+ gtk_tree_view_collapse_all (aw->parent_tree);
+ gnc_tree_view_account_set_selected_account (
+ GNC_TREE_VIEW_ACCOUNT(aw->parent_tree), parent);
- gnc_account_window_set_name (aw);
+ gnc_account_window_set_name (aw);
- gnc_window_adjust_for_screen(GTK_WINDOW(aw->dialog));
+ gnc_window_adjust_for_screen(GTK_WINDOW(aw->dialog));
- aw->component_id = gnc_register_gui_component (DIALOG_EDIT_ACCOUNT_CM_CLASS,
- refresh_handler,
- close_handler, aw);
+ aw->component_id = gnc_register_gui_component (DIALOG_EDIT_ACCOUNT_CM_CLASS,
+ refresh_handler,
+ close_handler, aw);
- gnc_gui_component_set_session (aw->component_id, gnc_get_current_session());
- gnc_gui_component_watch_entity_type (aw->component_id,
- GNC_ID_ACCOUNT,
- QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);
+ gnc_gui_component_set_session (aw->component_id, gnc_get_current_session());
+ gnc_gui_component_watch_entity_type (aw->component_id,
+ GNC_ID_ACCOUNT,
+ QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);
- gtk_window_present(GTK_WINDOW(aw->dialog));
+ gtk_window_present(GTK_WINDOW(aw->dialog));
}
/*
* opens up a window to create a new account
- *
+ *
* Args: book - containing book for the new account
* parent - The initial parent for the new account (optional)
*/
void
gnc_ui_new_account_window(QofBook *book, Account *parent)
{
- g_return_if_fail(book != NULL);
- if (parent && book)
- g_return_if_fail(gnc_account_get_book(parent) == book);
+ g_return_if_fail(book != NULL);
+ if (parent && book)
+ g_return_if_fail(gnc_account_get_book(parent) == book);
- gnc_ui_new_account_window_internal (book, parent, NULL, NULL, NULL, FALSE);
+ gnc_ui_new_account_window_internal (book, parent, NULL, NULL, NULL, FALSE);
}
void
gnc_ui_new_account_with_types( QofBook *book,
GList *valid_types )
{
- gnc_ui_new_account_window_internal( book, NULL, NULL, valid_types, NULL, FALSE );
+ gnc_ui_new_account_window_internal( book, NULL, NULL, valid_types, NULL, FALSE );
}
/************************************************************
@@ -1775,13 +1842,13 @@
void
gnc_ui_register_account_destroy_callback (void (*cb)(Account *))
{
- if (!cb)
- return;
+ if (!cb)
+ return;
- if (g_list_index (ac_destroy_cb_list, cb) == -1)
- ac_destroy_cb_list = g_list_append (ac_destroy_cb_list, cb);
+ if (g_list_index (ac_destroy_cb_list, cb) == -1)
+ ac_destroy_cb_list = g_list_append (ac_destroy_cb_list, cb);
- return;
+ return;
}
/**************************************************/
@@ -1789,107 +1856,109 @@
static void
gnc_account_renumber_update_examples (RenumberDialog *data)
{
- gchar *str;
- gchar *prefix;
- gint interval, num_digits;
+ gchar *str;
+ gchar *prefix;
+ gint interval, num_digits;
- prefix = gtk_editable_get_chars(GTK_EDITABLE(data->prefix), 0, -1);
- interval = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(data->interval));
- num_digits = log10(data->num_children * interval) + 1;
+ prefix = gtk_editable_get_chars(GTK_EDITABLE(data->prefix), 0, -1);
+ interval = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(data->interval));
+ num_digits = log10(data->num_children * interval) + 1;
- str = g_strdup_printf("%s-%0*d", prefix, num_digits, interval);
- gtk_label_set_text(GTK_LABEL(data->example1), str);
- g_free(str);
+ str = g_strdup_printf("%s-%0*d", prefix, num_digits, interval);
+ gtk_label_set_text(GTK_LABEL(data->example1), str);
+ g_free(str);
- str = g_strdup_printf("%s-%0*d", prefix, num_digits,
- interval * data->num_children);
- gtk_label_set_text(GTK_LABEL(data->example2), str);
- g_free(str);
+ str = g_strdup_printf("%s-%0*d", prefix, num_digits,
+ interval * data->num_children);
+ gtk_label_set_text(GTK_LABEL(data->example2), str);
+ g_free(str);
- g_free(prefix);
+ g_free(prefix);
}
void
gnc_account_renumber_prefix_changed_cb (GtkEditable *editable,
- RenumberDialog *data)
+ RenumberDialog *data)
{
- gnc_account_renumber_update_examples(data);
+ gnc_account_renumber_update_examples(data);
}
void
gnc_account_renumber_interval_changed_cb (GtkSpinButton *spinbutton,
- RenumberDialog *data)
+ RenumberDialog *data)
{
- gnc_account_renumber_update_examples(data);
+ gnc_account_renumber_update_examples(data);
}
void
gnc_account_renumber_response_cb (GtkDialog *dialog,
- gint response,
- RenumberDialog *data)
+ gint response,
+ RenumberDialog *data)
{
- GList *children, *tmp;
- gchar *str;
- gchar *prefix;
- gint interval, num_digits, i;
+ GList *children, *tmp;
+ gchar *str;
+ gchar *prefix;
+ gint interval, num_digits, i;
- if (response == GTK_RESPONSE_OK) {
- gtk_widget_hide(data->dialog);
- children = gnc_account_get_children(data->parent);
- prefix = gtk_editable_get_chars(GTK_EDITABLE(data->prefix), 0, -1);
- interval =
- gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(data->interval));
- num_digits = log10(data->num_children * interval) + 1;
+ if (response == GTK_RESPONSE_OK)
+ {
+ gtk_widget_hide(data->dialog);
+ children = gnc_account_get_children(data->parent);
+ prefix = gtk_editable_get_chars(GTK_EDITABLE(data->prefix), 0, -1);
+ interval =
+ gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(data->interval));
+ num_digits = log10(data->num_children * interval) + 1;
- gnc_set_busy_cursor (NULL, TRUE);
- for (tmp = children, i = 1; tmp; tmp = g_list_next(tmp), i += 1) {
- str = g_strdup_printf("%s-%0*d", prefix, num_digits, interval * i);
- xaccAccountSetCode(tmp->data, str);
- g_free(str);
+ gnc_set_busy_cursor (NULL, TRUE);
+ for (tmp = children, i = 1; tmp; tmp = g_list_next(tmp), i += 1)
+ {
+ str = g_strdup_printf("%s-%0*d", prefix, num_digits, interval * i);
+ xaccAccountSetCode(tmp->data, str);
+ g_free(str);
+ }
+ gnc_unset_busy_cursor (NULL);
+ g_list_free(children);
}
- gnc_unset_busy_cursor (NULL);
- g_list_free(children);
- }
- gtk_widget_destroy(data->dialog);
- g_free(data);
+ gtk_widget_destroy(data->dialog);
+ g_free(data);
}
void
gnc_account_renumber_create_dialog (GtkWidget *window, Account *account)
{
- RenumberDialog *data;
- GladeXML *xml;
- GtkWidget *widget;
- gchar *string;
+ RenumberDialog *data;
+ GladeXML *xml;
+ GtkWidget *widget;
+ gchar *string;
- data = g_new(RenumberDialog, 1);
- data->parent = account;
- data->num_children = gnc_account_n_children(account);
+ data = g_new(RenumberDialog, 1);
+ data->parent = account;
+ data->num_children = gnc_account_n_children(account);
- xml = gnc_glade_xml_new ("account.glade", "Renumber Accounts");
- data->dialog = glade_xml_get_widget (xml, "Renumber Accounts");
- gtk_window_set_transient_for(GTK_WINDOW(data->dialog), GTK_WINDOW(window));
- g_object_set_data_full(G_OBJECT(data->dialog), "xml", xml, g_object_unref);
+ xml = gnc_glade_xml_new ("account.glade", "Renumber Accounts");
+ data->dialog = glade_xml_get_widget (xml, "Renumber Accounts");
+ gtk_window_set_transient_for(GTK_WINDOW(data->dialog), GTK_WINDOW(window));
+ g_object_set_data_full(G_OBJECT(data->dialog), "xml", xml, g_object_unref);
- widget = glade_xml_get_widget (xml, "header_label");
- string = g_strdup_printf(_( "Renumber the immediate sub-accounts of %s? "
- "This will replace the account code field of "
- "each child account with a newly generated code."),
- gnc_account_get_full_name(account));
- gtk_label_set_text(GTK_LABEL(widget), string);
- g_free(string);
+ widget = glade_xml_get_widget (xml, "header_label");
+ string = g_strdup_printf(_( "Renumber the immediate sub-accounts of %s? "
+ "This will replace the account code field of "
+ "each child account with a newly generated code."),
+ gnc_account_get_full_name(account));
+ gtk_label_set_text(GTK_LABEL(widget), string);
+ g_free(string);
- data->prefix = glade_xml_get_widget (xml, "prefix_entry");
- data->interval = glade_xml_get_widget (xml, "interval_spin");
- data->example1 = glade_xml_get_widget (xml, "example1_label");
- data->example2 = glade_xml_get_widget (xml, "example2_label");
+ data->prefix = glade_xml_get_widget (xml, "prefix_entry");
+ data->interval = glade_xml_get_widget (xml, "interval_spin");
+ data->example1 = glade_xml_get_widget (xml, "example1_label");
+ data->example2 = glade_xml_get_widget (xml, "example2_label");
- gtk_entry_set_text(GTK_ENTRY(data->prefix), xaccAccountGetCode(account));
- gnc_account_renumber_update_examples(data);
+ gtk_entry_set_text(GTK_ENTRY(data->prefix), xaccAccountGetCode(account));
+ gnc_account_renumber_update_examples(data);
- glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func,
- data);
-
- gtk_widget_show_all(data->dialog);
+ glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func,
+ data);
+
+ gtk_widget_show_all(data->dialog);
}
Modified: gnucash/trunk/src/gnome-utils/dialog-account.h
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-account.h 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/dialog-account.h 2010-03-02 21:42:11 UTC (rev 18791)
@@ -78,12 +78,12 @@
* responsible for freeing this list.
*/
void gnc_ui_new_account_with_types (QofBook *book,
- GList *valid_types);
+ GList *valid_types);
/** @} */
-/** @name Modal
+/** @name Modal
@{ */
/** Disply a modal window for creating a new account
@@ -108,7 +108,7 @@
*/
/* Note that the caller owns the valid_types list */
Account * gnc_ui_new_accounts_from_name_window_with_types (const char *name,
- GList *valid_types);
+ GList *valid_types);
/** Display a modal window for creating a new account. This function
@@ -130,9 +130,9 @@
* @return A pointer to the newly created account.
*/
Account * gnc_ui_new_accounts_from_name_with_defaults (const char *name,
- GList *valid_types,
- gnc_commodity * default_commodity,
- Account * parent);
+ GList *valid_types,
+ gnc_commodity * default_commodity,
+ Account * parent);
/*
* register a callback that get's called when the account has changed
Modified: gnucash/trunk/src/gnome-utils/dialog-book-close.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-book-close.c 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/dialog-book-close.c 2010-03-02 21:42:11 UTC (rev 18791)
@@ -49,71 +49,71 @@
struct CloseBookWindow
{
- /* Passed in by the creator */
- QofBook* book;
+ /* Passed in by the creator */
+ QofBook* book;
- /* Parts of the dialog */
- GtkWidget* dialog;
- GtkWidget* close_date_widget;
- GtkWidget* income_acct_widget;
- GtkWidget* expense_acct_widget;
- GtkWidget* desc_widget;
+ /* Parts of the dialog */
+ GtkWidget* dialog;
+ GtkWidget* close_date_widget;
+ GtkWidget* income_acct_widget;
+ GtkWidget* expense_acct_widget;
+ GtkWidget* desc_widget;
- /* The final settings */
- time_t close_date;
- const char* desc;
+ /* The final settings */
+ time_t close_date;
+ const char* desc;
- /* Component registration */
- gint component_manager_id;
+ /* Component registration */
+ gint component_manager_id;
};
struct CloseAccountsCB
{
- struct CloseBookWindow* cbw;
- Account* base_acct;
- GNCAccountType acct_type;
- GHashTable* txns;
- guint hash_size;
+ struct CloseBookWindow* cbw;
+ Account* base_acct;
+ GNCAccountType acct_type;
+ GHashTable* txns;
+ guint hash_size;
};
struct CACBTransactionList
{
- gnc_commodity* cmdty;
- Transaction* txn;
- gnc_numeric total;
+ gnc_commodity* cmdty;
+ Transaction* txn;
+ gnc_numeric total;
};
static struct CACBTransactionList*
find_or_create_txn(struct CloseAccountsCB* cacb, gnc_commodity* cmdty)
{
- struct CACBTransactionList* txn;
+ struct CACBTransactionList* txn;
- g_return_val_if_fail(cacb, NULL);
- g_return_val_if_fail(cmdty, NULL);
+ g_return_val_if_fail(cacb, NULL);
+ g_return_val_if_fail(cmdty, NULL);
- txn = g_hash_table_lookup(cacb->txns, cmdty);
- if (!txn)
- {
- kvp_frame* frame;
- txn = g_new0(struct CACBTransactionList, 1);
- txn->cmdty = cmdty;
- txn->total = gnc_numeric_zero();
- txn->txn = xaccMallocTransaction(cacb->cbw->book);
- xaccTransBeginEdit(txn->txn);
- xaccTransSetDateEnteredSecs(txn->txn, time(NULL));
- xaccTransSetDatePostedSecs(txn->txn, cacb->cbw->close_date);
- xaccTransSetDescription(txn->txn, cacb->cbw->desc);
- xaccTransSetCurrency(txn->txn, cmdty);
- frame = xaccTransGetSlots(txn->txn);
- /* Add a bool flag to indicate this txn was created automatically
- by the book closing feature. See
- https://lists.gnucash.org/pipermail/gnucash-devel/2008-August/023757.html */
- kvp_frame_set_gint64(frame, "book_closing", 1);
+ txn = g_hash_table_lookup(cacb->txns, cmdty);
+ if (!txn)
+ {
+ kvp_frame* frame;
+ txn = g_new0(struct CACBTransactionList, 1);
+ txn->cmdty = cmdty;
+ txn->total = gnc_numeric_zero();
+ txn->txn = xaccMallocTransaction(cacb->cbw->book);
+ xaccTransBeginEdit(txn->txn);
+ xaccTransSetDateEnteredSecs(txn->txn, time(NULL));
+ xaccTransSetDatePostedSecs(txn->txn, cacb->cbw->close_date);
+ xaccTransSetDescription(txn->txn, cacb->cbw->desc);
+ xaccTransSetCurrency(txn->txn, cmdty);
+ frame = xaccTransGetSlots(txn->txn);
+ /* Add a bool flag to indicate this txn was created automatically
+ by the book closing feature. See
+ https://lists.gnucash.org/pipermail/gnucash-devel/2008-August/023757.html */
+ kvp_frame_set_gint64(frame, "book_closing", 1);
- g_hash_table_insert(cacb->txns, cmdty, txn);
- }
+ g_hash_table_insert(cacb->txns, cmdty, txn);
+ }
- return txn;
+ return txn;
}
/* Make sure that the account is of the correct type.
@@ -124,259 +124,260 @@
*/
static void close_accounts_cb(Account *a, gpointer data)
{
- struct CloseAccountsCB* cacb = data;
- struct CACBTransactionList* txn;
- gnc_commodity* acct_commodity;
- Split* split;
- gnc_numeric bal;
+ struct CloseAccountsCB* cacb = data;
+ struct CACBTransactionList* txn;
+ gnc_commodity* acct_commodity;
+ Split* split;
+ gnc_numeric bal;
- g_return_if_fail(a);
- g_return_if_fail(cacb);
- g_return_if_fail(cacb->cbw);
- g_return_if_fail(cacb->txns);
+ g_return_if_fail(a);
+ g_return_if_fail(cacb);
+ g_return_if_fail(cacb->cbw);
+ g_return_if_fail(cacb->txns);
- if (cacb->acct_type != xaccAccountGetType(a))
- return;
+ if (cacb->acct_type != xaccAccountGetType(a))
+ return;
- bal = xaccAccountGetBalanceAsOfDate(a, cacb->cbw->close_date+1);
- if (gnc_numeric_zero_p(bal))
- return;
+ bal = xaccAccountGetBalanceAsOfDate(a, cacb->cbw->close_date + 1);
+ if (gnc_numeric_zero_p(bal))
+ return;
- acct_commodity = xaccAccountGetCommodity(a);
- g_assert(acct_commodity);
+ acct_commodity = xaccAccountGetCommodity(a);
+ g_assert(acct_commodity);
- txn = find_or_create_txn(cacb, acct_commodity);
- g_assert(txn);
-
- split = xaccMallocSplit(cacb->cbw->book);
- xaccSplitSetParent(split, txn->txn);
- xaccAccountBeginEdit(a);
- xaccAccountInsertSplit(a, split);
- xaccSplitSetBaseValue(split, gnc_numeric_neg(bal), acct_commodity);
- xaccAccountCommitEdit(a);
- txn->total = gnc_numeric_add(txn->total, bal, GNC_DENOM_AUTO,
- GNC_HOW_DENOM_FIXED | GNC_HOW_RND_NEVER);
+ txn = find_or_create_txn(cacb, acct_commodity);
+ g_assert(txn);
+
+ split = xaccMallocSplit(cacb->cbw->book);
+ xaccSplitSetParent(split, txn->txn);
+ xaccAccountBeginEdit(a);
+ xaccAccountInsertSplit(a, split);
+ xaccSplitSetBaseValue(split, gnc_numeric_neg(bal), acct_commodity);
+ xaccAccountCommitEdit(a);
+ txn->total = gnc_numeric_add(txn->total, bal, GNC_DENOM_AUTO,
+ GNC_HOW_DENOM_FIXED | GNC_HOW_RND_NEVER);
}
static void finish_txn_cb(gnc_commodity* cmdty,
- struct CACBTransactionList* txn,
- struct CloseAccountsCB* cacb)
+ struct CACBTransactionList* txn,
+ struct CloseAccountsCB* cacb)
{
- Account* acc;
- Split* split;
+ Account* acc;
+ Split* split;
- g_return_if_fail(cmdty);
- g_return_if_fail(txn);
- g_return_if_fail(cacb);
- g_return_if_fail(cacb->hash_size);
+ g_return_if_fail(cmdty);
+ g_return_if_fail(txn);
+ g_return_if_fail(cacb);
+ g_return_if_fail(cacb->hash_size);
- /* If we only have one currency and the base account uses
- * that currency, then we can use that account. Otherwise,
- * create a subaccount for each currency.
- */
- if (cacb->hash_size == 1 &&
- gnc_commodity_equal(cmdty, xaccAccountGetCommodity(cacb->base_acct)))
- acc = cacb->base_acct;
- else
- {
- /* See if we already have an account by that name */
- acc = gnc_account_lookup_by_name(cacb->base_acct,
- gnc_commodity_get_mnemonic(cmdty));
+ /* If we only have one currency and the base account uses
+ * that currency, then we can use that account. Otherwise,
+ * create a subaccount for each currency.
+ */
+ if (cacb->hash_size == 1 &&
+ gnc_commodity_equal(cmdty, xaccAccountGetCommodity(cacb->base_acct)))
+ acc = cacb->base_acct;
+ else
+ {
+ /* See if we already have an account by that name */
+ acc = gnc_account_lookup_by_name(cacb->base_acct,
+ gnc_commodity_get_mnemonic(cmdty));
- /* If not, then create one */
- if (!acc)
- {
- acc = xaccMallocAccount(cacb->cbw->book);
- xaccAccountBeginEdit(acc);
- xaccAccountSetType(acc, ACCT_TYPE_EQUITY);
- xaccAccountSetName(acc, gnc_commodity_get_mnemonic(cmdty));
- xaccAccountSetDescription(acc, gnc_commodity_get_mnemonic(cmdty));
- xaccAccountSetCommodity(acc, cmdty);
- gnc_account_append_child(cacb->base_acct, acc);
- xaccAccountCommitEdit(acc);
+ /* If not, then create one */
+ if (!acc)
+ {
+ acc = xaccMallocAccount(cacb->cbw->book);
+ xaccAccountBeginEdit(acc);
+ xaccAccountSetType(acc, ACCT_TYPE_EQUITY);
+ xaccAccountSetName(acc, gnc_commodity_get_mnemonic(cmdty));
+ xaccAccountSetDescription(acc, gnc_commodity_get_mnemonic(cmdty));
+ xaccAccountSetCommodity(acc, cmdty);
+ gnc_account_append_child(cacb->base_acct, acc);
+ xaccAccountCommitEdit(acc);
+ }
}
- }
- /* Make sure the account exists and is of the correct commodity */
- g_assert(acc);
- g_assert(gnc_commodity_equal(cmdty, xaccAccountGetCommodity(acc)));
+ /* Make sure the account exists and is of the correct commodity */
+ g_assert(acc);
+ g_assert(gnc_commodity_equal(cmdty, xaccAccountGetCommodity(acc)));
- /* Create the split for the Equity account to balance out
- * all the accounts of this. Use the "total".
- */
- split = xaccMallocSplit(cacb->cbw->book);
- xaccSplitSetParent(split, txn->txn);
- xaccAccountBeginEdit(acc);
- xaccAccountInsertSplit(acc, split);
- xaccSplitSetBaseValue(split, txn->total, cmdty);
- xaccAccountCommitEdit(acc);
- xaccTransCommitEdit(txn->txn);
+ /* Create the split for the Equity account to balance out
+ * all the accounts of this. Use the "total".
+ */
+ split = xaccMallocSplit(cacb->cbw->book);
+ xaccSplitSetParent(split, txn->txn);
+ xaccAccountBeginEdit(acc);
+ xaccAccountInsertSplit(acc, split);
+ xaccSplitSetBaseValue(split, txn->total, cmdty);
+ xaccAccountCommitEdit(acc);
+ xaccTransCommitEdit(txn->txn);
}
static void close_accounts_of_type(struct CloseBookWindow* cbw,
- Account* acct,
- GNCAccountType acct_type)
+ Account* acct,
+ GNCAccountType acct_type)
{
- struct CloseAccountsCB cacb;
- Account* root_acct;
+ struct CloseAccountsCB cacb;
+ Account* root_acct;
- g_return_if_fail(cbw);
- g_return_if_fail(acct);
+ g_return_if_fail(cbw);
+ g_return_if_fail(acct);
- cacb.cbw = cbw;
- cacb.base_acct = acct;
- cacb.acct_type = acct_type;
- cacb.txns = g_hash_table_new_full(g_direct_hash,
- (GEqualFunc)gnc_commodity_equal,
- NULL, g_free);
+ cacb.cbw = cbw;
+ cacb.base_acct = acct;
+ cacb.acct_type = acct_type;
+ cacb.txns = g_hash_table_new_full(g_direct_hash,
+ (GEqualFunc)gnc_commodity_equal,
+ NULL, g_free);
- /* Iterate through all accounts and set up the balancing splits */
- root_acct = gnc_book_get_root_account(cbw->book);
- gnc_account_foreach_descendant(root_acct, close_accounts_cb, &cacb);
+ /* Iterate through all accounts and set up the balancing splits */
+ root_acct = gnc_book_get_root_account(cbw->book);
+ gnc_account_foreach_descendant(root_acct, close_accounts_cb, &cacb);
- /* now iterate through the transactions and handle each currency */
- cacb.hash_size = g_hash_table_size(cacb.txns);
- if (cacb.hash_size)
- g_hash_table_foreach(cacb.txns, (GHFunc)finish_txn_cb, &cacb);
+ /* now iterate through the transactions and handle each currency */
+ cacb.hash_size = g_hash_table_size(cacb.txns);
+ if (cacb.hash_size)
+ g_hash_table_foreach(cacb.txns, (GHFunc)finish_txn_cb, &cacb);
- /* Destroy the table, freeing the used memory */
- g_hash_table_destroy(cacb.txns);
+ /* Destroy the table, freeing the used memory */
+ g_hash_table_destroy(cacb.txns);
}
static void close_handler(gpointer data)
{
- GtkWidget *dialog = data;
+ GtkWidget *dialog = data;
- gtk_widget_destroy(dialog);
+ gtk_widget_destroy(dialog);
}
static void destroy_cb(GtkObject *object, gpointer data)
{
- struct CloseBookWindow *cbw;
+ struct CloseBookWindow *cbw;
- cbw = g_object_get_data(G_OBJECT(object), "CloseBookWindow");
+ cbw = g_object_get_data(G_OBJECT(object), "CloseBookWindow");
- if (cbw->component_manager_id) {
- gnc_unregister_gui_component(cbw->component_manager_id);
- cbw->component_manager_id = 0;
- }
+ if (cbw->component_manager_id)
+ {
+ gnc_unregister_gui_component(cbw->component_manager_id);
+ cbw->component_manager_id = 0;
+ }
}
void
gnc_book_close_response_cb(GtkDialog *dialog, gint response, GtkDialog *unused)
{
- struct CloseBookWindow* cbw;
- Account* income_acct;
- Account* expense_acct;
+ struct CloseBookWindow* cbw;
+ Account* income_acct;
+ Account* expense_acct;
- g_return_if_fail(dialog);
+ g_return_if_fail(dialog);
- cbw = g_object_get_data(G_OBJECT(dialog), "CloseBookWindow");
- g_return_if_fail(cbw);
+ cbw = g_object_get_data(G_OBJECT(dialog), "CloseBookWindow");
+ g_return_if_fail(cbw);
- switch (response)
- {
- case GTK_RESPONSE_HELP:
- gnc_gnome_help(HF_HELP, HL_GLOBPREFS);
- break;
- case GTK_RESPONSE_OK:
- cbw->close_date = gnc_date_edit_get_date(GNC_DATE_EDIT(cbw->close_date_widget));
- cbw->close_date += (3600 * 12); /* Add 12 hours to the timestamp */
- cbw->desc = gtk_entry_get_text(GTK_ENTRY(cbw->desc_widget));
+ switch (response)
+ {
+ case GTK_RESPONSE_HELP:
+ gnc_gnome_help(HF_HELP, HL_GLOBPREFS);
+ break;
+ case GTK_RESPONSE_OK:
+ cbw->close_date = gnc_date_edit_get_date(GNC_DATE_EDIT(cbw->close_date_widget));
+ cbw->close_date += (3600 * 12); /* Add 12 hours to the timestamp */
+ cbw->desc = gtk_entry_get_text(GTK_ENTRY(cbw->desc_widget));
- income_acct = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(cbw->income_acct_widget));
- expense_acct = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(cbw->expense_acct_widget));
+ income_acct = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(cbw->income_acct_widget));
+ expense_acct = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(cbw->expense_acct_widget));
- if (!income_acct)
- {
- gnc_error_dialog(cbw->dialog, "%s",
- _("Please select an Equity account to hold the total Period Income."));
- break;
- }
+ if (!income_acct)
+ {
+ gnc_error_dialog(cbw->dialog, "%s",
+ _("Please select an Equity account to hold the total Period Income."));
+ break;
+ }
- if (!expense_acct)
- {
- gnc_error_dialog(cbw->dialog, "%s",
- _("Please select an Equity account to hold the total Period Expense."));
- break;
- }
+ if (!expense_acct)
+ {
+ gnc_error_dialog(cbw->dialog, "%s",
+ _("Please select an Equity account to hold the total Period Expense."));
+ break;
+ }
- gnc_suspend_gui_refresh();
- close_accounts_of_type(cbw, income_acct, ACCT_TYPE_INCOME);
- close_accounts_of_type(cbw, expense_acct, ACCT_TYPE_EXPENSE);
- gnc_resume_gui_refresh();
+ gnc_suspend_gui_refresh();
+ close_accounts_of_type(cbw, income_acct, ACCT_TYPE_INCOME);
+ close_accounts_of_type(cbw, expense_acct, ACCT_TYPE_EXPENSE);
+ gnc_resume_gui_refresh();
- /* FALLTHROUGH */
- default:
- gtk_widget_destroy(GTK_WIDGET(dialog));
- break;
- }
+ /* FALLTHROUGH */
+ default:
+ gtk_widget_destroy(GTK_WIDGET(dialog));
+ break;
+ }
}
void gnc_ui_close_book (QofBook* book)
{
- struct CloseBookWindow *cbw;
- GladeXML* xml;
- GtkWidget* box;
- GList* equity_list = NULL;
+ struct CloseBookWindow *cbw;
+ GladeXML* xml;
+ GtkWidget* box;
+ GList* equity_list = NULL;
- g_return_if_fail(book);
+ g_return_if_fail(book);
- cbw = g_new0(struct CloseBookWindow, 1);
- g_return_if_fail(cbw);
- cbw->book = book;
+ cbw = g_new0(struct CloseBookWindow, 1);
+ g_return_if_fail(cbw);
+ cbw->book = book;
- /* Open the dialog */
- xml = gnc_glade_xml_new("dialog-book-close.glade", "Close Book");
- cbw->dialog = glade_xml_get_widget(xml, "Close Book");
+ /* Open the dialog */
+ xml = gnc_glade_xml_new("dialog-book-close.glade", "Close Book");
+ cbw->dialog = glade_xml_get_widget(xml, "Close Book");
- /* close date */
- box = glade_xml_get_widget(xml, "date_box");
- cbw->close_date_widget = gnc_date_edit_new(time(NULL), FALSE, FALSE);
- gtk_box_pack_start(GTK_BOX(box), cbw->close_date_widget, TRUE, TRUE, 0);
+ /* close date */
+ box = glade_xml_get_widget(xml, "date_box");
+ cbw->close_date_widget = gnc_date_edit_new(time(NULL), FALSE, FALSE);
+ gtk_box_pack_start(GTK_BOX(box), cbw->close_date_widget, TRUE, TRUE, 0);
- /* income acct */
- equity_list = g_list_prepend(equity_list, GINT_TO_POINTER(ACCT_TYPE_EQUITY));
- box = glade_xml_get_widget(xml, "income_acct_box");
- cbw->income_acct_widget = gnc_account_sel_new();
- gnc_account_sel_set_acct_filters(GNC_ACCOUNT_SEL(cbw->income_acct_widget),
- equity_list, NULL);
- gnc_account_sel_set_new_account_ability(GNC_ACCOUNT_SEL(cbw->income_acct_widget), TRUE);
- gtk_box_pack_start(GTK_BOX(box), cbw->income_acct_widget, TRUE, TRUE, 0);
+ /* income acct */
+ equity_list = g_list_prepend(equity_list, GINT_TO_POINTER(ACCT_TYPE_EQUITY));
+ box = glade_xml_get_widget(xml, "income_acct_box");
+ cbw->income_acct_widget = gnc_account_sel_new();
+ gnc_account_sel_set_acct_filters(GNC_ACCOUNT_SEL(cbw->income_acct_widget),
+ equity_list, NULL);
+ gnc_account_sel_set_new_account_ability(GNC_ACCOUNT_SEL(cbw->income_acct_widget), TRUE);
+ gtk_box_pack_start(GTK_BOX(box), cbw->income_acct_widget, TRUE, TRUE, 0);
- /* expense acct */
- box = glade_xml_get_widget(xml, "expense_acct_box");
- cbw->expense_acct_widget = gnc_account_sel_new();
- gnc_account_sel_set_acct_filters(GNC_ACCOUNT_SEL(cbw->expense_acct_widget),
- equity_list, NULL);
- gnc_account_sel_set_new_account_ability(GNC_ACCOUNT_SEL(cbw->expense_acct_widget), TRUE);
- gtk_box_pack_start(GTK_BOX(box), cbw->expense_acct_widget, TRUE, TRUE, 0);
+ /* expense acct */
+ box = glade_xml_get_widget(xml, "expense_acct_box");
+ cbw->expense_acct_widget = gnc_account_sel_new();
+ gnc_account_sel_set_acct_filters(GNC_ACCOUNT_SEL(cbw->expense_acct_widget),
+ equity_list, NULL);
+ gnc_account_sel_set_new_account_ability(GNC_ACCOUNT_SEL(cbw->expense_acct_widget), TRUE);
+ gtk_box_pack_start(GTK_BOX(box), cbw->expense_acct_widget, TRUE, TRUE, 0);
- /* desc */
- cbw->desc_widget = glade_xml_get_widget(xml, "desc_entry");
+ /* desc */
+ cbw->desc_widget = glade_xml_get_widget(xml, "desc_entry");
- /* Autoconnect signals */
- glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func,
- cbw->dialog);
+ /* Autoconnect signals */
+ glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func,
+ cbw->dialog);
- /* Register dialog with component manager */
- cbw->component_manager_id =
- gnc_register_gui_component(DIALOG_BOOK_CLOSE_CM_CLASS, NULL, close_handler,
- cbw->dialog);
- gnc_gui_component_set_session(cbw->component_manager_id,
- gnc_get_current_session());
- g_signal_connect(cbw->dialog, "destroy", G_CALLBACK(destroy_cb), NULL);
+ /* Register dialog with component manager */
+ cbw->component_manager_id =
+ gnc_register_gui_component(DIALOG_BOOK_CLOSE_CM_CLASS, NULL, close_handler,
+ cbw->dialog);
+ gnc_gui_component_set_session(cbw->component_manager_id,
+ gnc_get_current_session());
+ g_signal_connect(cbw->dialog, "destroy", G_CALLBACK(destroy_cb), NULL);
- /* Clean up the xml data structure when the dialog is destroyed */
- g_object_set_data_full(G_OBJECT(cbw->dialog), "dialog-book-close.glade",
- xml, g_object_unref);
- g_object_set_data_full(G_OBJECT(cbw->dialog), "CloseBookWindow", cbw,
- g_free);
+ /* Clean up the xml data structure when the dialog is destroyed */
+ g_object_set_data_full(G_OBJECT(cbw->dialog), "dialog-book-close.glade",
+ xml, g_object_unref);
+ g_object_set_data_full(G_OBJECT(cbw->dialog), "CloseBookWindow", cbw,
+ g_free);
- /* Run the dialog */
- gtk_widget_show_all(cbw->dialog);
+ /* Run the dialog */
+ gtk_widget_show_all(cbw->dialog);
- g_list_free(equity_list);
+ g_list_free(equity_list);
}
Modified: gnucash/trunk/src/gnome-utils/dialog-commodity.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-commodity.c 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/dialog-commodity.c 2010-03-02 21:42:11 UTC (rev 18791)
@@ -49,50 +49,53 @@
static QofLogModule log_module = GNC_MOD_GUI;
-enum {
- SOURCE_COL_NAME = 0,
- SOURCE_COL_FQ_SUPPORTED,
- NUM_SOURCE_COLS
+enum
+{
+ SOURCE_COL_NAME = 0,
+ SOURCE_COL_FQ_SUPPORTED,
+ NUM_SOURCE_COLS
};
-struct select_commodity_window {
- GtkWidget * dialog;
- GtkWidget * namespace_combo;
- GtkWidget * commodity_combo;
- GtkWidget * select_user_prompt;
- GtkWidget * ok_button;
+struct select_commodity_window
+{
+ GtkWidget * dialog;
+ GtkWidget * namespace_combo;
+ GtkWidget * commodity_combo;
+ GtkWidget * select_user_prompt;
+ GtkWidget * ok_button;
- gnc_commodity * selection;
+ gnc_commodity * selection;
- const char * default_cusip;
- const char * default_fullname;
- const char * default_mnemonic;
- int default_fraction;
+ const char * default_cusip;
+ const char * default_fullname;
+ const char * default_mnemonic;
+ int default_fraction;
};
-struct commodity_window {
- GtkWidget * dialog;
- GtkWidget * table;
- GtkWidget * fullname_entry;
- GtkWidget * mnemonic_entry;
- GtkWidget * namespace_combo;
- GtkWidget * code_entry;
- GtkWidget * fraction_spinbutton;
- GtkWidget * get_quote_check;
- GtkWidget * source_label;
- GtkWidget * source_button[SOURCE_MAX];
- GtkWidget * source_menu[SOURCE_MAX];
- GtkWidget * quote_tz_label;
- GtkWidget * quote_tz_menu;
- GtkWidget * ok_button;
+struct commodity_window
+{
+ GtkWidget * dialog;
+ GtkWidget * table;
+ GtkWidget * fullname_entry;
+ GtkWidget * mnemonic_entry;
+ GtkWidget * namespace_combo;
+ GtkWidget * code_entry;
+ GtkWidget * fraction_spinbutton;
+ GtkWidget * get_quote_check;
+ GtkWidget * source_label;
+ GtkWidget * source_button[SOURCE_MAX];
+ GtkWidget * source_menu[SOURCE_MAX];
+ GtkWidget * quote_tz_label;
+ GtkWidget * quote_tz_menu;
+ GtkWidget * ok_button;
- guint comm_section_top;
- guint comm_section_bottom;
- guint fq_section_top;
- guint fq_section_bottom;
+ guint comm_section_top;
+ guint comm_section_bottom;
+ guint fq_section_top;
+ guint fq_section_bottom;
- gboolean is_currency;
- gnc_commodity *edit_commodity;
+ gboolean is_currency;
+ gnc_commodity *edit_commodity;
};
typedef struct select_commodity_window SelectCommodityWindow;
@@ -104,13 +107,13 @@
/* The commodity selection window */
static SelectCommodityWindow *
gnc_ui_select_commodity_create(const gnc_commodity * orig_sel,
- dialog_commodity_mode mode);
+ dialog_commodity_mode mode);
void gnc_ui_select_commodity_new_cb(GtkButton * button,
- gpointer user_data);
+ gpointer user_data);
void gnc_ui_select_commodity_changed_cb(GtkComboBoxEntry *cbe,
- gpointer user_data);
+ gpointer user_data);
void gnc_ui_select_commodity_namespace_changed_cb(GtkComboBoxEntry *cbe,
- gpointer user_data);
+ gpointer user_data);
/* The commodity creation window */
void gnc_ui_commodity_changed_cb(GtkWidget * dummy, gpointer user_data);
@@ -129,85 +132,87 @@
void
gnc_ui_commodity_set_help_callback (gnc_commodity_help_callback cb)
{
- help_callback = cb;
+ help_callback = cb;
}
/********************************************************************
* gnc_ui_select_commodity_modal_full()
********************************************************************/
-gnc_commodity *
-gnc_ui_select_commodity_modal_full(gnc_commodity * orig_sel,
- GtkWidget * parent,
- dialog_commodity_mode mode,
- const char * user_message,
- const char * cusip,
- const char * fullname,
- const char * mnemonic)
+gnc_commodity *
+gnc_ui_select_commodity_modal_full(gnc_commodity * orig_sel,
+ GtkWidget * parent,
+ dialog_commodity_mode mode,
+ const char * user_message,
+ const char * cusip,
+ const char * fullname,
+ const char * mnemonic)
{
- gnc_commodity * retval = NULL;
- const gchar *initial;
- gchar *user_prompt_text;
- SelectCommodityWindow * win;
- gboolean done;
- gint value;
-
- win = gnc_ui_select_commodity_create(orig_sel, mode);
- win->default_cusip=cusip;
- win->default_fullname=fullname;
- win->default_mnemonic=mnemonic;
-
- if (parent)
- gtk_window_set_transient_for (GTK_WINDOW (win->dialog), GTK_WINDOW (parent));
+ gnc_commodity * retval = NULL;
+ const gchar *initial;
+ gchar *user_prompt_text;
+ SelectCommodityWindow * win;
+ gboolean done;
+ gint value;
- if (user_message != NULL)
- initial = user_message;
- else if ((cusip != NULL) || (fullname != NULL) || (mnemonic != NULL))
- initial = _("\nPlease select a commodity to match:");
- else
- initial = "";
+ win = gnc_ui_select_commodity_create(orig_sel, mode);
+ win->default_cusip = cusip;
+ win->default_fullname = fullname;
+ win->default_mnemonic = mnemonic;
- user_prompt_text =
- g_strdup_printf("%s%s%s%s%s%s%s",
- initial,
- fullname ? _("\nCommodity: ") : "",
- fullname ? fullname : "",
- /* Translators: Replace here and later CUSIP by the name of your local
- National Securities Identifying Number
- like gb:SEDOL, de:WKN, ch:Valorennummer, fr:SICOVAM ...
- See http://en.wikipedia.org/wiki/ISIN for hints. */
- cusip ? _("\nExchange code (ISIN, CUSIP or similar): ") : "",
- cusip ? cusip : "",
- mnemonic ? _("\nMnemonic (Ticker symbol or similar): ") : "",
- mnemonic ? mnemonic : "");
- gtk_label_set_text ((GtkLabel *)(win->select_user_prompt),
- user_prompt_text);
- g_free(user_prompt_text);
+ if (parent)
+ gtk_window_set_transient_for (GTK_WINDOW (win->dialog), GTK_WINDOW (parent));
- /* Run the dialog, handling the terminal conditions. */
- done = FALSE;
- while (!done) {
- switch (value = gtk_dialog_run(GTK_DIALOG(win->dialog))) {
- case GTK_RESPONSE_OK:
- DEBUG("case OK");
- retval = win->selection;
- done = TRUE;
- break;
- case GNC_RESPONSE_NEW:
- DEBUG("case NEW");
- gnc_ui_select_commodity_new_cb(NULL, win);
- break;
- default: /* Cancel, Escape, Close, etc. */
- DEBUG("default: %d", value);
- retval = NULL;
- done = TRUE;
- break;
+ if (user_message != NULL)
+ initial = user_message;
+ else if ((cusip != NULL) || (fullname != NULL) || (mnemonic != NULL))
+ initial = _("\nPlease select a commodity to match:");
+ else
+ initial = "";
+
+ user_prompt_text =
+ g_strdup_printf("%s%s%s%s%s%s%s",
+ initial,
+ fullname ? _("\nCommodity: ") : "",
+ fullname ? fullname : "",
+ /* Translators: Replace here and later CUSIP by the name of your local
+ National Securities Identifying Number
+ like gb:SEDOL, de:WKN, ch:Valorennummer, fr:SICOVAM ...
+ See http://en.wikipedia.org/wiki/ISIN for hints. */
+ cusip ? _("\nExchange code (ISIN, CUSIP or similar): ") : "",
+ cusip ? cusip : "",
+ mnemonic ? _("\nMnemonic (Ticker symbol or similar): ") : "",
+ mnemonic ? mnemonic : "");
+ gtk_label_set_text ((GtkLabel *)(win->select_user_prompt),
+ user_prompt_text);
+ g_free(user_prompt_text);
+
+ /* Run the dialog, handling the terminal conditions. */
+ done = FALSE;
+ while (!done)
+ {
+ switch (value = gtk_dialog_run(GTK_DIALOG(win->dialog)))
+ {
+ case GTK_RESPONSE_OK:
+ DEBUG("case OK");
+ retval = win->selection;
+ done = TRUE;
+ break;
+ case GNC_RESPONSE_NEW:
+ DEBUG("case NEW");
+ gnc_ui_select_commodity_new_cb(NULL, win);
+ break;
+ default: /* Cancel, Escape, Close, etc. */
+ DEBUG("default: %d", value);
+ retval = NULL;
+ done = TRUE;
+ break;
+ }
}
- }
- gtk_widget_destroy (GTK_WIDGET (win->dialog)); /* Close and destroy */
- g_free(win);
-
- return retval;
+ gtk_widget_destroy (GTK_WIDGET (win->dialog)); /* Close and destroy */
+ g_free(win);
+
+ return retval;
}
/********************************************************************
@@ -217,15 +222,15 @@
gnc_commodity *
gnc_ui_select_commodity_modal(gnc_commodity * orig_sel,
GtkWidget * parent,
- dialog_commodity_mode mode)
+ dialog_commodity_mode mode)
{
- return gnc_ui_select_commodity_modal_full(orig_sel,
- parent,
- mode,
- NULL,
- NULL,
- NULL,
- NULL);
+ return gnc_ui_select_commodity_modal_full(orig_sel,
+ parent,
+ mode,
+ NULL,
+ NULL,
+ NULL,
+ NULL);
}
@@ -235,69 +240,70 @@
static SelectCommodityWindow *
gnc_ui_select_commodity_create(const gnc_commodity * orig_sel,
- dialog_commodity_mode mode)
+ dialog_commodity_mode mode)
{
- SelectCommodityWindow * retval = g_new0(SelectCommodityWindow, 1);
- GladeXML *xml;
- const char *title, *text;
- gchar *namespace;
- GtkWidget *button, *label;
+ SelectCommodityWindow * retval = g_new0(SelectCommodityWindow, 1);
+ GladeXML *xml;
+ const char *title, *text;
+ gchar *namespace;
+ GtkWidget *button, *label;
- xml = gnc_glade_xml_new ("commodity.glade", "Security Selector Dialog");
- glade_xml_signal_autoconnect_full( xml,
- gnc_glade_autoconnect_full_func,
- retval );
+ xml = gnc_glade_xml_new ("commodity.glade", "Security Selector Dialog");
+ glade_xml_signal_autoconnect_full( xml,
+ gnc_glade_autoconnect_full_func,
+ retval );
- retval->dialog = glade_xml_get_widget (xml, "Security Selector Dialog");
- retval->namespace_combo = glade_xml_get_widget (xml, "namespace_cbe");
- retval->commodity_combo = glade_xml_get_widget (xml, "commodity_cbe");
- retval->select_user_prompt = glade_xml_get_widget (xml, "select_user_prompt");
- retval->ok_button = glade_xml_get_widget (xml, "ok_button");
- label = glade_xml_get_widget (xml, "item_label");
+ retval->dialog = glade_xml_get_widget (xml, "Security Selector Dialog");
+ retval->namespace_combo = glade_xml_get_widget (xml, "namespace_cbe");
+ retval->commodity_combo = glade_xml_get_widget (xml, "commodity_cbe");
+ retval->select_user_prompt = glade_xml_get_widget (xml, "select_user_prompt");
+ retval->ok_button = glade_xml_get_widget (xml, "ok_button");
+ label = glade_xml_get_widget (xml, "item_label");
- gtk_combo_box_remove_text(GTK_COMBO_BOX(retval->namespace_combo), 0);
- gtk_combo_box_remove_text(GTK_COMBO_BOX(retval->commodity_combo), 0);
- gnc_cbe_require_list_item(GTK_COMBO_BOX_ENTRY(retval->namespace_combo));
- gnc_cbe_require_list_item(GTK_COMBO_BOX_ENTRY(retval->commodity_combo));
+ gtk_combo_box_remove_text(GTK_COMBO_BOX(retval->namespace_combo), 0);
+ gtk_combo_box_remove_text(GTK_COMBO_BOX(retval->commodity_combo), 0);
+ gnc_cbe_require_list_item(GTK_COMBO_BOX_ENTRY(retval->namespace_combo));
+ gnc_cbe_require_list_item(GTK_COMBO_BOX_ENTRY(retval->commodity_combo));
- gtk_label_set_text (GTK_LABEL (retval->select_user_prompt), "");
+ gtk_label_set_text (GTK_LABEL (retval->select_user_prompt), "");
#ifdef DRH
- g_signal_connect (G_OBJECT (retval->dialog), "close",
- G_CALLBACK (select_commodity_close), retval);
- g_signal_connect (G_OBJECT (retval->dialog), "response",
- G_CALLBACK (gnc_ui_select_commodity_response_cb), retval);
+ g_signal_connect (G_OBJECT (retval->dialog), "close",
+ G_CALLBACK (select_commodity_close), retval);
+ g_signal_connect (G_OBJECT (retval->dialog), "response",
+ G_CALLBACK (gnc_ui_select_commodity_response_cb), retval);
#endif
- switch (mode) {
+ switch (mode)
+ {
case DIAG_COMM_ALL:
- title = _("Select security/currency");
- text = _("_Security/currency:");
- break;
+ title = _("Select security/currency");
+ text = _("_Security/currency:");
+ break;
case DIAG_COMM_NON_CURRENCY:
- title = _("Select security");
- text = _("_Security:");
- break;
+ title = _("Select security");
+ text = _("_Security:");
+ break;
case DIAG_COMM_CURRENCY:
default:
- title = _("Select currency");
- text = _("Cu_rrency:");
- button = glade_xml_get_widget (xml, "new_button");
- gtk_widget_destroy(button);
- break;
- }
- gtk_window_set_title (GTK_WINDOW(retval->dialog), title);
- gtk_label_set_text_with_mnemonic (GTK_LABEL(label), text);
+ title = _("Select currency");
+ text = _("Cu_rrency:");
+ button = glade_xml_get_widget (xml, "new_button");
+ gtk_widget_destroy(button);
+ break;
+ }
+ gtk_window_set_title (GTK_WINDOW(retval->dialog), title);
+ gtk_label_set_text_with_mnemonic (GTK_LABEL(label), text);
- /* build the menus of namespaces and commodities */
- gnc_ui_update_namespace_picker(retval->namespace_combo,
- gnc_commodity_get_namespace(orig_sel),
- mode);
- namespace = gnc_ui_namespace_picker_ns(retval->namespace_combo);
- gnc_ui_update_commodity_picker(retval->commodity_combo, namespace,
- gnc_commodity_get_printname(orig_sel));
- g_free(namespace);
- return retval;
+ /* build the menus of namespaces and commodities */
+ gnc_ui_update_namespace_picker(retval->namespace_combo,
+ gnc_commodity_get_namespace(orig_sel),
+ mode);
+ namespace = gnc_ui_namespace_picker_ns(retval->namespace_combo);
+ gnc_ui_update_commodity_picker(retval->commodity_combo, namespace,
+ gnc_commodity_get_printname(orig_sel));
+ g_free(namespace);
+ return retval;
}
@@ -319,26 +325,27 @@
gnc_ui_select_commodity_new_cb(GtkButton * button,
gpointer user_data)
{
- SelectCommodityWindow * w = user_data;
+ SelectCommodityWindow * w = user_data;
- gchar * namespace = gnc_ui_namespace_picker_ns (w->namespace_combo);
+ gchar * namespace = gnc_ui_namespace_picker_ns (w->namespace_combo);
- const gnc_commodity * new_commodity =
- gnc_ui_new_commodity_modal_full(namespace,
- w->dialog,
- w->default_cusip,
- w->default_fullname,
- w->default_mnemonic,
- w->default_fraction);
- if(new_commodity) {
- gnc_ui_update_namespace_picker(w->namespace_combo,
- gnc_commodity_get_namespace(new_commodity),
- DIAG_COMM_ALL);
- gnc_ui_update_commodity_picker(w->commodity_combo,
- gnc_commodity_get_namespace(new_commodity),
- gnc_commodity_get_printname(new_commodity));
- }
- g_free(namespace);
+ const gnc_commodity * new_commodity =
+ gnc_ui_new_commodity_modal_full(namespace,
+ w->dialog,
+ w->default_cusip,
+ w->default_fullname,
+ w->default_mnemonic,
+ w->default_fraction);
+ if (new_commodity)
+ {
+ gnc_ui_update_namespace_picker(w->namespace_combo,
+ gnc_commodity_get_namespace(new_commodity),
+ DIAG_COMM_ALL);
+ gnc_ui_update_commodity_picker(w->commodity_combo,
+ gnc_commodity_get_namespace(new_commodity),
+ gnc_commodity_get_printname(new_commodity));
+ }
+ g_free(namespace);
}
@@ -359,25 +366,25 @@
*/
void
gnc_ui_select_commodity_changed_cb (GtkComboBoxEntry *cbe,
- gpointer user_data)
+ gpointer user_data)
{
- SelectCommodityWindow * w = user_data;
- gchar *namespace, *fullname;
- gboolean ok;
+ SelectCommodityWindow * w = user_data;
+ gchar *namespace, *fullname;
+ gboolean ok;
- ENTER("cbe=%p, user_data=%p", cbe, user_data);
- namespace = gnc_ui_namespace_picker_ns (w->namespace_combo);
- fullname = gtk_combo_box_get_active_text(GTK_COMBO_BOX(w->commodity_combo));
- DEBUG("namespace=%s, name=%s", namespace, fullname);
- w->selection = gnc_commodity_table_find_full(gnc_get_current_commodities(),
- namespace, fullname);
- g_free(fullname);
- g_free(namespace);
+ ENTER("cbe=%p, user_data=%p", cbe, user_data);
+ namespace = gnc_ui_namespace_picker_ns (w->namespace_combo);
+ fullname = gtk_combo_box_get_active_text(GTK_COMBO_BOX(w->commodity_combo));
+ DEBUG("namespace=%s, name=%s", namespace, fullname);
+ w->selection = gnc_commodity_table_find_full(gnc_get_current_commodities(),
+ namespace, fullname);
+ g_free(fullname);
+ g_free(namespace);
- ok = (w->selection != NULL);
- gtk_widget_set_sensitive(w->ok_button, ok);
- gtk_dialog_set_default_response(GTK_DIALOG(w->dialog), ok ? 0 : 2);
- LEAVE("sensitive=%d, default = %d", ok, ok ? 0 : 2);
+ ok = (w->selection != NULL);
+ gtk_widget_set_sensitive(w->ok_button, ok);
+ gtk_dialog_set_default_response(GTK_DIALOG(w->dialog), ok ? 0 : 2);
+ LEAVE("sensitive=%d, default = %d", ok, ok ? 0 : 2);
}
@@ -399,77 +406,79 @@
*/
void
gnc_ui_select_commodity_namespace_changed_cb (GtkComboBoxEntry *cbe,
- gpointer user_data)
+ gpointer user_data)
{
- SelectCommodityWindow * w = user_data;
- gchar *namespace;
+ SelectCommodityWindow * w = user_data;
+ gchar *namespace;
- ENTER("cbe=%p, user_data=%p", cbe, user_data);
- namespace = gnc_ui_namespace_picker_ns (w->namespace_combo);
- DEBUG("namespace=%s", namespace);
- gnc_ui_update_commodity_picker(w->commodity_combo, namespace, NULL);
- g_free(namespace);
- LEAVE(" ");
+ ENTER("cbe=%p, user_data=%p", cbe, user_data);
+ namespace = gnc_ui_namespace_picker_ns (w->namespace_combo);
+ DEBUG("namespace=%s", namespace);
+ gnc_ui_update_commodity_picker(w->commodity_combo, namespace, NULL);
+ g_free(namespace);
+ LEAVE(" ");
}
/********************************************************************
* gnc_ui_update_commodity_picker
********************************************************************/
-static int
+static int
collate(gconstpointer a, gconstpointer b)
{
- if (!a)
- return -1;
- if (!b)
- return 1;
- return g_utf8_collate(a, b);
+ if (!a)
+ return -1;
+ if (!b)
+ return 1;
+ return g_utf8_collate(a, b);
}
void
gnc_ui_update_commodity_picker (GtkWidget *cbe,
const gchar * namespace,
- const gchar * init_string)
+ const gchar * init_string)
{
- GList * commodities;
- GList * iterator = NULL;
- GList * commodity_items = NULL;
- GtkComboBox *combo_box;
- GtkTreeModel *model;
- gnc_commodity_table *table;
- gint current = 0, match = 0;
- gchar *name;
+ GList * commodities;
+ GList * iterator = NULL;
+ GList * commodity_items = NULL;
+ GtkComboBox *combo_box;
+ GtkTreeModel *model;
+ gnc_commodity_table *table;
+ gint current = 0, match = 0;
+ gchar *name;
- g_return_if_fail(GTK_IS_COMBO_BOX_ENTRY(cbe));
- g_return_if_fail(namespace);
+ g_return_if_fail(GTK_IS_COMBO_BOX_ENTRY(cbe));
+ g_return_if_fail(namespace);
- /* Erase the old entries */
- combo_box = GTK_COMBO_BOX(cbe);
- model = gtk_combo_box_get_model(combo_box);
- gtk_list_store_clear(GTK_LIST_STORE(model));
- gtk_combo_box_set_active(combo_box, -1);
+ /* Erase the old entries */
+ combo_box = GTK_COMBO_BOX(cbe);
+ model = gtk_combo_box_get_model(combo_box);
+ gtk_list_store_clear(GTK_LIST_STORE(model));
+ gtk_combo_box_set_active(combo_box, -1);
- table = gnc_book_get_commodity_table (gnc_get_current_book ());
- commodities = gnc_commodity_table_get_commodities(table, namespace);
- for(iterator = commodities; iterator; iterator = iterator->next) {
- commodity_items =
- g_list_append(commodity_items,
- (gpointer) gnc_commodity_get_printname(iterator->data));
- }
- g_list_free(commodities);
+ table = gnc_book_get_commodity_table (gnc_get_current_book ());
+ commodities = gnc_commodity_table_get_commodities(table, namespace);
+ for (iterator = commodities; iterator; iterator = iterator->next)
+ {
+ commodity_items =
+ g_list_append(commodity_items,
+ (gpointer) gnc_commodity_get_printname(iterator->data));
+ }
+ g_list_free(commodities);
- commodity_items = g_list_sort(commodity_items, collate);
- for (iterator = commodity_items; iterator; iterator = iterator->next) {
- name = (char *)iterator->data;
- gtk_combo_box_append_text(combo_box, name);
- if (init_string && g_utf8_collate(name, init_string) == 0)
- match = current;
- current++;
- }
+ commodity_items = g_list_sort(commodity_items, collate);
+ for (iterator = commodity_items; iterator; iterator = iterator->next)
+ {
+ name = (char *)iterator->data;
+ gtk_combo_box_append_text(combo_box, name);
+ if (init_string && g_utf8_collate(name, init_string) == 0)
+ match = current;
+ current++;
+ }
- gtk_combo_box_set_active(combo_box, match);
- g_list_free(commodity_items);
+ gtk_combo_box_set_active(combo_box, match);
+ g_list_free(commodity_items);
}
@@ -479,10 +488,11 @@
#if 0
void
-gnc_ui_select_commodity_destroy(SelectCommodityWindow * w) {
- g_return_if_fail (w != NULL);
+gnc_ui_select_commodity_destroy(SelectCommodityWindow * w)
+{
+ g_return_if_fail (w != NULL);
- gtk_widget_destroy (GTK_WIDGET (w->dialog));
+ gtk_widget_destroy (GTK_WIDGET (w->dialog));
}
/********************************************************************
@@ -492,57 +502,62 @@
static void
gnc_ui_select_commodity_response_cb (GtkDialog * dialog, gint response, gpointer data)
{
- SelectCommodityWindow * w = data;
- gchar *namespace;
- const gchar *fullname;
- gnc_commodity *commodity = NULL;
+ SelectCommodityWindow * w = data;
+ gchar *namespace;
+ const gchar *fullname;
+ gnc_commodity *commodity = NULL;
- switch (response) {
- case GTK_RESPONSE_OK:
- namespace = gnc_ui_namespace_picker_ns (w->namespace_combo);
- fullname = gtk_entry_get_text (GTK_ENTRY (w->commodity_entry));
+ switch (response)
+ {
+ case GTK_RESPONSE_OK:
+ namespace = gnc_ui_namespace_picker_ns (w->namespace_combo);
+ fullname = gtk_entry_get_text (GTK_ENTRY (w->commodity_entry));
- commodity = gnc_commodity_table_find_full (gnc_get_current_commodities (),
- namespace, fullname);
- g_free(namespace);
+ commodity = gnc_commodity_table_find_full (gnc_get_current_commodities (),
+ namespace, fullname);
+ g_free(namespace);
- if (commodity != NULL) {
- if (w->callback != NULL)
- (w->callback) (commodity, w->callback_data);
- gnc_ui_select_commodity_destroy (w);
- } else {
- gnc_warning_dialog (dialog,
- _("You must select a commodity. "
- "To create a new one, click \"New\""));
- }
- break;
- case GNC_RESPONSE_NEW:
- namespace = gnc_ui_namespace_picker_ns (w->namespace_combo);
+ if (commodity != NULL)
+ {
+ if (w->callback != NULL)
+ (w->callback) (commodity, w->callback_data);
+ gnc_ui_select_commodity_destroy (w);
+ }
+ else
+ {
+ gnc_warning_dialog (dialog,
+ _("You must select a commodity. "
+ "To create a new one, click \"New\""));
+ }
+ break;
+ case GNC_RESPONSE_NEW:
+ namespace = gnc_ui_namespace_picker_ns (w->namespace_combo);
- commodity = gnc_ui_new_commodity_modal_full (namespace,
- w->dialog,
- w->default_cusip,
- w->default_fullname,
- w->default_mnemonic,
- w->default_fraction);
- if (commodity != NULL) {
- namespace =
- gnc_ui_update_namespace_picker (w->namespace_combo,
- gnc_commodity_get_namespace
- (commodity), TRUE, FALSE);
- gnc_ui_update_commodity_picker (w->commodity_combo,
- gnc_commodity_get_namespace (commodity),
- gnc_commodity_get_printname (commodity));
+ commodity = gnc_ui_new_commodity_modal_full (namespace,
+ w->dialog,
+ w->default_cusip,
+ w->default_fullname,
+ w->default_mnemonic,
+ w->default_fraction);
+ if (commodity != NULL)
+ {
+ namespace =
+ gnc_ui_update_namespace_picker (w->namespace_combo,
+ gnc_commodity_get_namespace
+ (commodity), TRUE, FALSE);
+ gnc_ui_update_commodity_picker (w->commodity_combo,
+ gnc_commodity_get_namespace (commodity),
+ gnc_commodity_get_printname (commodity));
+ }
+ g_free(namespace);
+ break;
+ default:
+ if (w->callback != NULL)
+ (w->callback) (NULL, w->callback_data);
+
+ gnc_ui_select_commodity_destroy (w);
+ break;
}
- g_free(namespace);
- break;
- default:
- if (w->callback != NULL)
- (w->callback) (NULL, w->callback_data);
-
- gnc_ui_select_commodity_destroy (w);
- break;
- }
}
#endif
@@ -557,45 +572,45 @@
static void
gnc_set_commodity_section_sensitivity (GtkWidget *widget, gpointer user_data)
{
- CommodityWindow *cw = user_data;
- guint offset = 0;
+ CommodityWindow *cw = user_data;
+ guint offset = 0;
- gtk_container_child_get(GTK_CONTAINER(cw->table), widget,
- "top-attach", &offset,
- NULL);
+ gtk_container_child_get(GTK_CONTAINER(cw->table), widget,
+ "top-attach", &offset,
+ NULL);
- if ((offset < cw->comm_section_top) || (offset >= cw->comm_section_bottom))
- return;
- gtk_widget_set_sensitive(widget, !cw->is_currency);
+ if ((offset < cw->comm_section_top) || (offset >= cw->comm_section_bottom))
+ return;
+ gtk_widget_set_sensitive(widget, !cw->is_currency);
}
static void
gnc_ui_update_commodity_info (CommodityWindow *cw)
{
- gtk_container_foreach(GTK_CONTAINER(cw->table),
- gnc_set_commodity_section_sensitivity, cw);
+ gtk_container_foreach(GTK_CONTAINER(cw->table),
+ gnc_set_commodity_section_sensitivity, cw);
}
static void
gnc_set_fq_sensitivity (GtkWidget *widget, gpointer user_data)
{
- CommodityWindow *cw = user_data;
- guint offset = 0;
+ CommodityWindow *cw = user_data;
+ guint offset = 0;
- gtk_container_child_get(GTK_CONTAINER(cw->table), widget,
- "top-attach", &offset,
- NULL);
+ gtk_container_child_get(GTK_CONTAINER(cw->table), widget,
+ "top-attach", &offset,
+ NULL);
- if ((offset < cw->fq_section_top) || (offset >= cw->fq_section_bottom))
- return;
- g_object_set(widget, "sensitive", FALSE, NULL);
+ if ((offset < cw->fq_section_top) || (offset >= cw->fq_section_bottom))
+ return;
+ g_object_set(widget, "sensitive", FALSE, NULL);
}
static void
gnc_ui_update_fq_info (CommodityWindow *cw)
{
- gtk_container_foreach(GTK_CONTAINER(cw->table),
- gnc_set_fq_sensitivity, cw);
+ gtk_container_foreach(GTK_CONTAINER(cw->table),
+ gnc_set_fq_sensitivity, cw);
}
/********************************************************************
@@ -604,78 +619,83 @@
void
gnc_ui_update_namespace_picker (GtkWidget *cbe,
- const char * init_string,
- dialog_commodity_mode mode)
+ const char * init_string,
+ dialog_commodity_mode mode)
{
- GtkComboBox *combo_box;
- GtkTreeModel *model;
- GList *namespaces, *node;
- gint current = 0, match = 0;
+ GtkComboBox *combo_box;
+ GtkTreeModel *model;
+ GList *namespaces, *node;
+ gint current = 0, match = 0;
- g_return_if_fail(GTK_IS_COMBO_BOX_ENTRY(cbe));
+ g_return_if_fail(GTK_IS_COMBO_BOX_ENTRY(cbe));
- /* Erase the old entries */
- combo_box = GTK_COMBO_BOX(cbe);
- model = gtk_combo_box_get_model(combo_box);
- gtk_list_store_clear(GTK_LIST_STORE(model));
- gtk_combo_box_set_active(combo_box, -1);
+ /* Erase the old entries */
+ combo_box = GTK_COMBO_BOX(cbe);
+ model = gtk_combo_box_get_model(combo_box);
+ gtk_list_store_clear(GTK_LIST_STORE(model));
+ gtk_combo_box_set_active(combo_box, -1);
- /* fetch a list of the namespaces */
- switch (mode) {
+ /* fetch a list of the namespaces */
+ switch (mode)
+ {
case DIAG_COMM_ALL:
- namespaces =
- gnc_commodity_table_get_namespaces (gnc_get_current_commodities());
- break;
+ namespaces =
+ gnc_commodity_table_get_namespaces (gnc_get_current_commodities());
+ break;
- case DIAG_COMM_NON_CURRENCY:
- namespaces =
- gnc_commodity_table_get_namespaces (gnc_get_current_commodities());
- node = g_list_find_custom (namespaces, GNC_COMMODITY_NS_CURRENCY, collate);
- if (node) {
- namespaces = g_list_remove_link (namespaces, node);
- g_list_free_1 (node);
- }
+ case DIAG_COMM_NON_CURRENCY:
+ namespaces =
+ gnc_commodity_table_get_namespaces (gnc_get_current_commodities());
+ node = g_list_find_custom (namespaces, GNC_COMMODITY_NS_CURRENCY, collate);
+ if (node)
+ {
+ namespaces = g_list_remove_link (namespaces, node);
+ g_list_free_1 (node);
+ }
- if (gnc_commodity_namespace_is_iso (init_string))
- init_string = NULL;
- break;
+ if (gnc_commodity_namespace_is_iso (init_string))
+ init_string = NULL;
+ break;
- case DIAG_COMM_CURRENCY:
- default:
- namespaces = g_list_prepend (NULL, GNC_COMMODITY_NS_CURRENCY);
- break;
- }
+ case DIAG_COMM_CURRENCY:
+ default:
+ namespaces = g_list_prepend (NULL, GNC_COMMODITY_NS_CURRENCY);
+ break;
+ }
- /* stick them in the combobox */
- namespaces = g_list_sort(namespaces, collate);
- for (node = namespaces; node; node = node->next) {
- if (g_utf8_collate(node->data, GNC_COMMODITY_NS_LEGACY) == 0)
- continue;
- gtk_combo_box_append_text(combo_box, node->data);
- if (init_string && (g_utf8_collate(node->data, init_string) == 0))
- match = current;
- current++;
- }
+ /* stick them in the combobox */
+ namespaces = g_list_sort(namespaces, collate);
+ for (node = namespaces; node; node = node->next)
+ {
+ if (g_utf8_collate(node->data, GNC_COMMODITY_NS_LEGACY) == 0)
+ continue;
+ gtk_combo_box_append_text(combo_box, node->data);
+ if (init_string && (g_utf8_collate(node->data, init_string) == 0))
+ match = current;
+ current++;
+ }
- gtk_combo_box_set_active(combo_box, match);
- g_list_free(namespaces);
+ gtk_combo_box_set_active(combo_box, match);
+ g_list_free(namespaces);
}
gchar *
gnc_ui_namespace_picker_ns (GtkWidget *cbe)
{
- char *namespace;
+ char *namespace;
- g_return_val_if_fail(GTK_IS_COMBO_BOX_ENTRY (cbe), NULL);
+ g_return_val_if_fail(GTK_IS_COMBO_BOX_ENTRY (cbe), NULL);
- namespace = gtk_combo_box_get_active_text(GTK_COMBO_BOX(cbe));
+ namespace = gtk_combo_box_get_active_text(GTK_COMBO_BOX(cbe));
- if (safe_strcmp (namespace, GNC_COMMODITY_NS_ISO) == 0) {
- /* In case the user types in ISO4217, map it to CURRENCY. */
- g_free(namespace);
- return strdup(GNC_COMMODITY_NS_CURRENCY);
- } else
- return namespace;
+ if (safe_strcmp (namespace, GNC_COMMODITY_NS_ISO) == 0)
+ {
+ /* In case the user types in ISO4217, map it to CURRENCY. */
+ g_free(namespace);
+ return strdup(GNC_COMMODITY_NS_CURRENCY);
+ }
+ else
+ return namespace;
}
/********************************************************************/
@@ -683,56 +703,60 @@
void
gnc_ui_commodity_quote_info_cb (GtkWidget *w, gpointer data)
{
- CommodityWindow *cw = data;
- gboolean get_quote, allow_src, active;
- gchar *text;
- gint i;
+ CommodityWindow *cw = data;
+ gboolean get_quote, allow_src, active;
+ gchar *text;
+ gint i;
- ENTER(" ");
- get_quote = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
+ ENTER(" ");
+ get_quote = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
- text = gtk_combo_box_get_active_text(GTK_COMBO_BOX(cw->namespace_combo));
- allow_src = !gnc_commodity_namespace_is_iso(text);
- g_free(text);
- gtk_widget_set_sensitive(cw->source_label, get_quote && allow_src);
+ text = gtk_combo_box_get_active_text(GTK_COMBO_BOX(cw->namespace_combo));
+ allow_src = !gnc_commodity_namespace_is_iso(text);
+ g_free(text);
+ gtk_widget_set_sensitive(cw->source_label, get_quote && allow_src);
- for (i = SOURCE_SINGLE; i < SOURCE_MAX; i++) {
- if (!cw->source_button[i])
- continue;
- active =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cw->source_button[i]));
- gtk_widget_set_sensitive(cw->source_button[i], get_quote && allow_src);
- gtk_widget_set_sensitive(cw->source_menu[i], get_quote && allow_src && active);
- }
- gtk_widget_set_sensitive(cw->quote_tz_label, get_quote);
- gtk_widget_set_sensitive(cw->quote_tz_menu, get_quote);
- LEAVE(" ");
+ for (i = SOURCE_SINGLE; i < SOURCE_MAX; i++)
+ {
+ if (!cw->source_button[i])
+ continue;
+ active =
+ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cw->source_button[i]));
+ gtk_widget_set_sensitive(cw->source_button[i], get_quote && allow_src);
+ gtk_widget_set_sensitive(cw->source_menu[i], get_quote && allow_src && active);
+ }
+ gtk_widget_set_sensitive(cw->quote_tz_label, get_quote);
+ gtk_widget_set_sensitive(cw->quote_tz_menu, get_quote);
+ LEAVE(" ");
}
void
gnc_ui_commodity_changed_cb(GtkWidget * dummy, gpointer user_data)
{
- CommodityWindow * w = user_data;
- gchar *namespace;
- const char * fullname;
- const char * mnemonic;
- gboolean ok;
+ CommodityWindow * w = user_data;
+ gchar *namespace;
+ const char * fullname;
+ const char * mnemonic;
+ gboolean ok;
- ENTER("widget=%p, user_data=%p", dummy, user_data);
- if (!w->is_currency) {
- namespace = gnc_ui_namespace_picker_ns (w->namespace_combo);
- fullname = gtk_entry_get_text(GTK_ENTRY(w->fullname_entry));
- mnemonic = gtk_entry_get_text(GTK_ENTRY(w->mnemonic_entry));
- DEBUG("namespace=%s, name=%s, mnemonic=%s", namespace, fullname, mnemonic);
- ok = (fullname && namespace && mnemonic &&
- fullname[0] && namespace[0] && mnemonic[0]);
- g_free(namespace);
- } else {
- ok = TRUE;
- }
- gtk_widget_set_sensitive(w->ok_button, ok);
- gtk_dialog_set_default_response(GTK_DIALOG(w->dialog), ok ? 0 : 1);
- LEAVE("sensitive=%d, default = %d", ok, ok ? 0 : 1);
+ ENTER("widget=%p, user_data=%p", dummy, user_data);
+ if (!w->is_currency)
+ {
+ namespace = gnc_ui_namespace_picker_ns (w->namespace_combo);
+ fullname = gtk_entry_get_text(GTK_ENTRY(w->fullname_entry));
+ mnemonic = gtk_entry_get_text(GTK_ENTRY(w->mnemonic_entry));
+ DEBUG("namespace=%s, name=%s, mnemonic=%s", namespace, fullname, mnemonic);
+ ok = (fullname && namespace && mnemonic &&
+ fullname[0] && namespace[0] && mnemonic[0]);
+ g_free(namespace);
+ }
+ else
+ {
+ ok = TRUE;
+ }
+ gtk_widget_set_sensitive(w->ok_button, ok);
+ gtk_dialog_set_default_response(GTK_DIALOG(w->dialog), ok ? 0 : 1);
+ LEAVE("sensitive=%d, default = %d", ok, ok ? 0 : 1);
}
/********************************************************************\
@@ -745,49 +769,53 @@
static GtkWidget *
gnc_ui_source_menu_create(QuoteSourceType type)
{
- gint i, max;
- const gchar *name;
- gboolean supported;
- GtkListStore *store;
- GtkTreeIter iter;
- GtkWidget *combo;
- GtkCellRenderer *renderer;
- gnc_quote_source *source;
+ gint i, max;
+ const gchar *name;
+ gboolean supported;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GtkWidget *combo;
+ GtkCellRenderer *renderer;
+ gnc_quote_source *source;
- store = gtk_list_store_new(NUM_SOURCE_COLS, G_TYPE_STRING, G_TYPE_BOOLEAN);
- if (type == SOURCE_CURRENCY) {
- gtk_list_store_append(store, &iter);
- gtk_list_store_set(store, &iter,
- SOURCE_COL_NAME, _("Currency"),
- SOURCE_COL_FQ_SUPPORTED, TRUE,
- -1);
- } else {
- max = gnc_quote_source_num_entries(type);
- for (i = 0; i < max; i++) {
- source = gnc_quote_source_lookup_by_ti(type, i);
- if (source == NULL)
- break;
- name = gnc_quote_source_get_user_name(source);
- supported = gnc_quote_source_get_supported(source);
- gtk_list_store_append(store, &iter);
- gtk_list_store_set(store, &iter,
- SOURCE_COL_NAME, name,
- SOURCE_COL_FQ_SUPPORTED, supported,
- -1);
- }
- }
+ store = gtk_list_store_new(NUM_SOURCE_COLS, G_TYPE_STRING, G_TYPE_BOOLEAN);
+ if (type == SOURCE_CURRENCY)
+ {
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ SOURCE_COL_NAME, _("Currency"),
+ SOURCE_COL_FQ_SUPPORTED, TRUE,
+ -1);
+ }
+ else
+ {
+ max = gnc_quote_source_num_entries(type);
+ for (i = 0; i < max; i++)
+ {
+ source = gnc_quote_source_lookup_by_ti(type, i);
+ if (source == NULL)
+ break;
+ name = gnc_quote_source_get_user_name(source);
+ supported = gnc_quote_source_get_supported(source);
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ SOURCE_COL_NAME, name,
+ SOURCE_COL_FQ_SUPPORTED, supported,
+ -1);
+ }
+ }
- combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
- g_object_unref(store);
- renderer = gtk_cell_renderer_text_new();
- gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, TRUE);
- gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(combo), renderer,
- "text", SOURCE_COL_NAME);
- gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(combo), renderer,
- "sensitive", SOURCE_COL_FQ_SUPPORTED);
- gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
- gtk_widget_show(combo);
- return combo;
+ combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
+ g_object_unref(store);
+ renderer = gtk_cell_renderer_text_new();
+ gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, TRUE);
+ gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(combo), renderer,
+ "text", SOURCE_COL_NAME);
+ gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(combo), renderer,
+ "sensitive", SOURCE_COL_FQ_SUPPORTED);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
+ gtk_widget_show(combo);
+ return combo;
}
/********************************************************************\
@@ -797,342 +825,367 @@
static gchar *
known_timezones[] =
{
- "Asia/Tokyo",
- "Australia/Sydney",
- "America/New_York",
- "America/Chicago",
- "Europe/London",
- "Europe/Paris",
- NULL
+ "Asia/Tokyo",
+ "Australia/Sydney",
+ "America/New_York",
+ "America/Chicago",
+ "Europe/London",
+ "Europe/Paris",
+ NULL
};
static guint
gnc_find_timezone_menu_position(const gchar *timezone)
{
- /* returns 0 on failure, position otherwise. */
- gboolean found = FALSE;
- guint i = 0;
- while(!found && known_timezones[i]) {
- if(safe_strcmp(timezone, known_timezones[i]) != 0) {
- i++;
- } else {
- found = TRUE;
+ /* returns 0 on failure, position otherwise. */
+ gboolean found = FALSE;
+ guint i = 0;
+ while (!found && known_timezones[i])
+ {
+ if (safe_strcmp(timezone, known_timezones[i]) != 0)
+ {
+ i++;
+ }
+ else
+ {
+ found = TRUE;
+ }
}
- }
- if(found) return i + 1;
- return 0;
+ if (found) return i + 1;
+ return 0;
}
static gchar *
gnc_timezone_menu_position_to_string(guint pos)
{
- if(pos == 0) return NULL;
- return known_timezones[pos - 1];
+ if (pos == 0) return NULL;
+ return known_timezones[pos - 1];
}
static GtkWidget *
gnc_ui_quote_tz_menu_create(void)
{
- GtkWidget *combo;
- gchar **itemstr;
+ GtkWidget *combo;
+ gchar **itemstr;
- /* add items here as needed, but bear in mind that right now these
- must be timezones that GNU libc understands. Also, I'd prefer if
- we only add things here we *know* we need. That's because in
- order to be portable to non GNU OSes, we may have to support
- whatever we add here manually on those systems. */
+ /* add items here as needed, but bear in mind that right now these
+ must be timezones that GNU libc understands. Also, I'd prefer if
+ we only add things here we *know* we need. That's because in
+ order to be portable to non GNU OSes, we may have to support
+ whatever we add here manually on those systems. */
- combo = gtk_combo_box_new_text();
- gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Use local time"));
- for(itemstr = &known_timezones[0]; *itemstr; itemstr++) {
- gtk_combo_box_append_text(GTK_COMBO_BOX(combo), *itemstr);
- }
+ combo = gtk_combo_box_new_text();
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Use local time"));
+ for (itemstr = &known_timezones[0]; *itemstr; itemstr++)
+ {
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combo), *itemstr);
+ }
- gtk_widget_show(combo);
- return combo;
+ gtk_widget_show(combo);
+ return combo;
}
/** Build the new/edit commodity dialog box
*/
static CommodityWindow *
gnc_ui_build_commodity_dialog(const char * selected_namespace,
- GtkWidget *parent,
- const char * fullname,
- const char * mnemonic,
- const char * cusip,
- int fraction,
- gboolean edit)
+ GtkWidget *parent,
+ const char * fullname,
+ const char * mnemonic,
+ const char * cusip,
+ int fraction,
+ gboolean edit)
{
- CommodityWindow * retval = g_new0(CommodityWindow, 1);
- GtkWidget *help_button;
- GtkWidget *box;
- GtkWidget *menu;
- GtkWidget *widget, *sec_label;
- GladeXML *xml;
- gboolean include_iso;
- const gchar *title;
- gchar *text;
+ CommodityWindow * retval = g_new0(CommodityWindow, 1);
+ GtkWidget *help_button;
+ GtkWidget *box;
+ GtkWidget *menu;
+ GtkWidget *widget, *sec_label;
+ GladeXML *xml;
+ gboolean include_iso;
+ const gchar *title;
+ gchar *text;
- ENTER(" ");
- xml = gnc_glade_xml_new ("commodity.glade", "Security Dialog");
+ ENTER(" ");
+ xml = gnc_glade_xml_new ("commodity.glade", "Security Dialog");
- glade_xml_signal_autoconnect_full( xml,
- gnc_glade_autoconnect_full_func,
- retval );
+ glade_xml_signal_autoconnect_full( xml,
+ gnc_glade_autoconnect_full_func,
+ retval );
- retval->dialog = glade_xml_get_widget (xml, "Security Dialog");
- if (parent != NULL)
- gtk_window_set_transient_for (GTK_WINDOW (retval->dialog), GTK_WINDOW (parent));
- retval->edit_commodity = NULL;
+ retval->dialog = glade_xml_get_widget (xml, "Security Dialog");
+ if (parent != NULL)
+ gtk_window_set_transient_for (GTK_WINDOW (retval->dialog), GTK_WINDOW (parent));
+ retval->edit_commodity = NULL;
- help_button = glade_xml_get_widget (xml, "help_button");
- if (!help_callback)
- gtk_widget_hide (help_button);
+ help_button = glade_xml_get_widget (xml, "help_button");
+ if (!help_callback)
+ gtk_widget_hide (help_button);
- /* Determine the commodity section of the dialog */
- retval->table = glade_xml_get_widget (xml, "edit_table");
- sec_label = glade_xml_get_widget (xml, "security_label");
- gtk_container_child_get(GTK_CONTAINER(retval->table), sec_label,
- "bottom-attach", &retval->comm_section_top, NULL);
- widget = glade_xml_get_widget (xml, "quote_label");
- gtk_container_child_get(GTK_CONTAINER(retval->table), widget,
- "top-attach", &retval->comm_section_bottom, NULL);
+ /* Determine the commodity section of the dialog */
+ retval->table = glade_xml_get_widget (xml, "edit_table");
+ sec_label = glade_xml_get_widget (xml, "security_label");
+ gtk_container_child_get(GTK_CONTAINER(retval->table), sec_label,
+ "bottom-attach", &retval->comm_section_top, NULL);
+ widget = glade_xml_get_widget (xml, "quote_label");
+ gtk_container_child_get(GTK_CONTAINER(retval->table), widget,
+ "top-attach", &retval->comm_section_bottom, NULL);
- /* Get widget pointers */
- retval->fullname_entry = glade_xml_get_widget (xml, "fullname_entry");
- retval->mnemonic_entry = glade_xml_get_widget (xml, "mnemonic_entry");
- retval->namespace_combo = glade_xml_get_widget (xml, "namespace_cbe");
- retval->code_entry = glade_xml_get_widget (xml, "code_entry");
- retval->fraction_spinbutton = glade_xml_get_widget (xml,
- "fraction_spinbutton");
- retval->ok_button = glade_xml_get_widget (xml, "ok_button");
- retval->get_quote_check = glade_xml_get_widget (xml, "get_quote_check");
- retval->source_label = glade_xml_get_widget (xml, "source_label");
- retval->source_button[SOURCE_SINGLE] = glade_xml_get_widget (xml, "single_source_button");
- retval->source_button[SOURCE_MULTI] = glade_xml_get_widget (xml, "multi_source_button");
- retval->quote_tz_label = glade_xml_get_widget (xml, "quote_tz_label");
+ /* Get widget pointers */
+ retval->fullname_entry = glade_xml_get_widget (xml, "fullname_entry");
+ retval->mnemonic_entry = glade_xml_get_widget (xml, "mnemonic_entry");
+ retval->namespace_combo = glade_xml_get_widget (xml, "namespace_cbe");
+ retval->code_entry = glade_xml_get_widget (xml, "code_entry");
+ retval->fraction_spinbutton = glade_xml_get_widget (xml,
+ "fraction_spinbutton");
+ retval->ok_button = glade_xml_get_widget (xml, "ok_button");
+ retval->get_quote_check = glade_xml_get_widget (xml, "get_quote_check");
+ retval->source_label = glade_xml_get_widget (xml, "source_label");
+ retval->source_button[SOURCE_SINGLE] = glade_xml_get_widget (xml, "single_source_button");
+ retval->source_button[SOURCE_MULTI] = glade_xml_get_widget (xml, "multi_source_button");
+ retval->quote_tz_label = glade_xml_get_widget (xml, "quote_tz_label");
- /* Build custom widgets */
- box = glade_xml_get_widget (xml, "single_source_box");
- if (gnc_commodity_namespace_is_iso(selected_namespace)) {
- menu = gnc_ui_source_menu_create(SOURCE_CURRENCY);
- } else {
- menu = gnc_ui_source_menu_create(SOURCE_SINGLE);
- }
- retval->source_menu[SOURCE_SINGLE] = menu;
- gtk_box_pack_start(GTK_BOX(box), menu, TRUE, TRUE, 0);
+ /* Build custom widgets */
+ box = glade_xml_get_widget (xml, "single_source_box");
+ if (gnc_commodity_namespace_is_iso(selected_namespace))
+ {
+ menu = gnc_ui_source_menu_create(SOURCE_CURRENCY);
+ }
+ else
+ {
+ menu = gnc_ui_source_menu_create(SOURCE_SINGLE);
+ }
+ retval->source_menu[SOURCE_SINGLE] = menu;
+ gtk_box_pack_start(GTK_BOX(box), menu, TRUE, TRUE, 0);
- box = glade_xml_get_widget (xml, "multi_source_box");
- menu = gnc_ui_source_menu_create(SOURCE_MULTI);
- retval->source_menu[SOURCE_MULTI] = menu;
- gtk_box_pack_start(GTK_BOX(box), menu, TRUE, TRUE, 0);
-
- if (gnc_quote_source_num_entries(SOURCE_UNKNOWN)) {
- retval->source_button[SOURCE_UNKNOWN] =
- glade_xml_get_widget (xml, "unknown_source_button");
- box = glade_xml_get_widget (xml, "unknown_source_box");
- menu = gnc_ui_source_menu_create(SOURCE_UNKNOWN);
- retval->source_menu[SOURCE_UNKNOWN] = menu;
+ box = glade_xml_get_widget (xml, "multi_source_box");
+ menu = gnc_ui_source_menu_create(SOURCE_MULTI);
+ retval->source_menu[SOURCE_MULTI] = menu;
gtk_box_pack_start(GTK_BOX(box), menu, TRUE, TRUE, 0);
- } else {
- guint row;
- widget = glade_xml_get_widget (xml, "unknown_source_alignment");
- gtk_container_child_get(GTK_CONTAINER(retval->table), widget,
- "top-attach", &row, NULL);
- gtk_table_set_row_spacing(GTK_TABLE(retval->table), row, 0);
- gtk_widget_destroy(widget);
- widget = glade_xml_get_widget (xml, "unknown_source_box");
- gtk_widget_destroy(widget);
- }
+ if (gnc_quote_source_num_entries(SOURCE_UNKNOWN))
+ {
+ retval->source_button[SOURCE_UNKNOWN] =
+ glade_xml_get_widget (xml, "unknown_source_button");
+ box = glade_xml_get_widget (xml, "unknown_source_box");
+ menu = gnc_ui_source_menu_create(SOURCE_UNKNOWN);
+ retval->source_menu[SOURCE_UNKNOWN] = menu;
+ gtk_box_pack_start(GTK_BOX(box), menu, TRUE, TRUE, 0);
+ }
+ else
+ {
+ guint row;
- box = glade_xml_get_widget (xml, "quote_tz_box");
- retval->quote_tz_menu = gnc_ui_quote_tz_menu_create();
- gtk_box_pack_start(GTK_BOX(box), retval->quote_tz_menu, TRUE, TRUE, 0);
+ widget = glade_xml_get_widget (xml, "unknown_source_alignment");
+ gtk_container_child_get(GTK_CONTAINER(retval->table), widget,
+ "top-attach", &row, NULL);
+ gtk_table_set_row_spacing(GTK_TABLE(retval->table), row, 0);
+ gtk_widget_destroy(widget);
+ widget = glade_xml_get_widget (xml, "unknown_source_box");
+ gtk_widget_destroy(widget);
+ }
+ box = glade_xml_get_widget (xml, "quote_tz_box");
+ retval->quote_tz_menu = gnc_ui_quote_tz_menu_create();
+ gtk_box_pack_start(GTK_BOX(box), retval->quote_tz_menu, TRUE, TRUE, 0);
- /* Commodity editing is next to nil */
- if (gnc_commodity_namespace_is_iso(selected_namespace)) {
- retval->is_currency = TRUE;
- gnc_ui_update_commodity_info (retval);
- include_iso = TRUE;
- title = _("Edit currency");
- text = g_strdup_printf("<b>%s</b>", _("Currency Information"));
- } else {
- include_iso = FALSE;
- title = edit ? _("Edit security") : _("New security");
- text = g_strdup_printf("<b>%s</b>", _("Security Information"));
- }
- gtk_window_set_title(GTK_WINDOW(retval->dialog), title);
- gtk_label_set_markup(GTK_LABEL(sec_label), text);
- g_free(text);
- /* Are price quotes supported */
- if (gnc_quote_source_fq_installed()) {
- gtk_widget_destroy(glade_xml_get_widget (xml, "finance_quote_warning"));
- } else {
- /* Determine the price quote of the dialog */
- widget = glade_xml_get_widget (xml, "fq_warning_alignment");
- gtk_container_child_get(GTK_CONTAINER(retval->table), widget,
- "bottom-attach", &retval->fq_section_top, NULL);
- widget = glade_xml_get_widget (xml, "quote_tz_alignment");
- gtk_container_child_get(GTK_CONTAINER(retval->table), widget,
- "bottom-attach", &retval->fq_section_bottom, NULL);
- gnc_ui_update_fq_info (retval);
- }
+ /* Commodity editing is next to nil */
+ if (gnc_commodity_namespace_is_iso(selected_namespace))
+ {
+ retval->is_currency = TRUE;
+ gnc_ui_update_commodity_info (retval);
+ include_iso = TRUE;
+ title = _("Edit currency");
+ text = g_strdup_printf("<b>%s</b>", _("Currency Information"));
+ }
+ else
+ {
+ include_iso = FALSE;
+ title = edit ? _("Edit security") : _("New security");
+ text = g_strdup_printf("<b>%s</b>", _("Security Information"));
+ }
+ gtk_window_set_title(GTK_WINDOW(retval->dialog), title);
+ gtk_label_set_markup(GTK_LABEL(sec_label), text);
+ g_free(text);
+ /* Are price quotes supported */
+ if (gnc_quote_source_fq_installed())
+ {
+ gtk_widget_destroy(glade_xml_get_widget (xml, "finance_quote_warning"));
+ }
+ else
+ {
+ /* Determine the price quote of the dialog */
+ widget = glade_xml_get_widget (xml, "fq_warning_alignment");
+ gtk_container_child_get(GTK_CONTAINER(retval->table), widget,
+ "bottom-attach", &retval->fq_section_top, NULL);
+ widget = glade_xml_get_widget (xml, "quote_tz_alignment");
+ gtk_container_child_get(GTK_CONTAINER(retval->table), widget,
+ "bottom-attach", &retval->fq_section_bottom, NULL);
+ gnc_ui_update_fq_info (retval);
+ }
+
#ifdef DRH
- g_signal_connect (G_OBJECT (retval->dialog), "close",
- G_CALLBACK (commodity_close), retval);
+ g_signal_connect (G_OBJECT (retval->dialog), "close",
+ G_CALLBACK (commodity_close), retval);
#endif
- /* Fill in any data, top to bottom */
-
- gtk_entry_set_text (GTK_ENTRY (retval->fullname_entry), fullname ? fullname : "");
- gtk_entry_set_text (GTK_ENTRY (retval->mnemonic_entry), mnemonic ? mnemonic : "");
- gnc_cbe_add_completion(GTK_COMBO_BOX_ENTRY(retval->namespace_combo));
- gtk_combo_box_remove_text(GTK_COMBO_BOX(retval->namespace_combo), 0);
- gnc_ui_update_namespace_picker(retval->namespace_combo,
- selected_namespace,
- include_iso ? DIAG_COMM_ALL : DIAG_COMM_NON_CURRENCY);
- gtk_entry_set_text (GTK_ENTRY (retval->code_entry), cusip ? cusip : "");
- if (fraction > 0)
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (retval->fraction_spinbutton),
- fraction);
+ /* Fill in any data, top to bottom */
- LEAVE(" ");
- return retval;
+ gtk_entry_set_text (GTK_ENTRY (retval->fullname_entry), fullname ? fullname : "");
+ gtk_entry_set_text (GTK_ENTRY (retval->mnemonic_entry), mnemonic ? mnemonic : "");
+ gnc_cbe_add_completion(GTK_COMBO_BOX_ENTRY(retval->namespace_combo));
+ gtk_combo_box_remove_text(GTK_COMBO_BOX(retval->namespace_combo), 0);
+ gnc_ui_update_namespace_picker(retval->namespace_combo,
+ selected_namespace,
+ include_iso ? DIAG_COMM_ALL : DIAG_COMM_NON_CURRENCY);
+ gtk_entry_set_text (GTK_ENTRY (retval->code_entry), cusip ? cusip : "");
+ if (fraction > 0)
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (retval->fraction_spinbutton),
+ fraction);
+
+ LEAVE(" ");
+ return retval;
}
static void
gnc_ui_commodity_update_quote_info(CommodityWindow *win,
- gnc_commodity *commodity)
+ gnc_commodity *commodity)
{
- gnc_quote_source *source;
- QuoteSourceType type;
- gboolean has_quote_src;
- const char *quote_tz;
- int pos = 0;
+ gnc_quote_source *source;
+ QuoteSourceType type;
+ gboolean has_quote_src;
+ const char *quote_tz;
+ int pos = 0;
- ENTER(" ");
- has_quote_src = gnc_commodity_get_quote_flag (commodity);
- source = gnc_commodity_get_quote_source (commodity);
- if (source == NULL)
- source = gnc_commodity_get_default_quote_source (commodity);
- quote_tz = gnc_commodity_get_quote_tz (commodity);
+ ENTER(" ");
+ has_quote_src = gnc_commodity_get_quote_flag (commodity);
+ source = gnc_commodity_get_quote_source (commodity);
+ if (source == NULL)
+ source = gnc_commodity_get_default_quote_source (commodity);
+ quote_tz = gnc_commodity_get_quote_tz (commodity);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (win->get_quote_check),
- has_quote_src);
- if (!gnc_commodity_is_iso(commodity)) {
- type = gnc_quote_source_get_type(source);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->source_button[type]), TRUE);
- gtk_combo_box_set_active(GTK_COMBO_BOX(win->source_menu[type]),
- gnc_quote_source_get_index(source));
- }
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (win->get_quote_check),
+ has_quote_src);
+ if (!gnc_commodity_is_iso(commodity))
+ {
+ type = gnc_quote_source_get_type(source);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->source_button[type]), TRUE);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(win->source_menu[type]),
+ gnc_quote_source_get_index(source));
+ }
- if (quote_tz) {
- pos = gnc_find_timezone_menu_position(quote_tz);
+ if (quote_tz)
+ {
+ pos = gnc_find_timezone_menu_position(quote_tz);
// if(pos == 0) {
// PWARN("Unknown price quote timezone (%s), resetting to default.",
// quote_tz ? quote_tz : "(null)");
// }
- }
- gtk_combo_box_set_active(GTK_COMBO_BOX(win->quote_tz_menu), pos);
- LEAVE(" ");
+ }
+ gtk_combo_box_set_active(GTK_COMBO_BOX(win->quote_tz_menu), pos);
+ LEAVE(" ");
}
static gnc_commodity *
gnc_ui_common_commodity_modal(gnc_commodity *commodity,
- GtkWidget * parent,
- const char * namespace,
- const char * cusip,
- const char * fullname,
- const char * mnemonic,
- int fraction)
+ GtkWidget * parent,
+ const char * namespace,
+ const char * cusip,
+ const char * fullname,
+ const char * mnemonic,
+ int fraction)
{
- CommodityWindow * win;
- gnc_commodity *retval = NULL;
- gboolean done;
- gint value;
+ CommodityWindow * win;
+ gnc_commodity *retval = NULL;
+ gboolean done;
+ gint value;
- ENTER(" ");
+ ENTER(" ");
- /* If a commodity was provided, copy out the existing info */
- if (commodity) {
- namespace = gnc_commodity_get_namespace (commodity);
- fullname = gnc_commodity_get_fullname (commodity);
- mnemonic = gnc_commodity_get_mnemonic (commodity);
- cusip = gnc_commodity_get_cusip (commodity);
- fraction = gnc_commodity_get_fraction (commodity);
- } else {
- /* Not allowed to create new currencies */
- if (gnc_commodity_namespace_is_iso(namespace)) {
- namespace = NULL;
+ /* If a commodity was provided, copy out the existing info */
+ if (commodity)
+ {
+ namespace = gnc_commodity_get_namespace (commodity);
+ fullname = gnc_commodity_get_fullname (commodity);
+ mnemonic = gnc_commodity_get_mnemonic (commodity);
+ cusip = gnc_commodity_get_cusip (commodity);
+ fraction = gnc_commodity_get_fraction (commodity);
}
- }
+ else
+ {
+ /* Not allowed to create new currencies */
+ if (gnc_commodity_namespace_is_iso(namespace))
+ {
+ namespace = NULL;
+ }
+ }
- win = gnc_ui_build_commodity_dialog(namespace, parent, fullname,
- mnemonic, cusip, fraction,
- (commodity != NULL));
+ win = gnc_ui_build_commodity_dialog(namespace, parent, fullname,
+ mnemonic, cusip, fraction,
+ (commodity != NULL));
- /* Update stock quote info based on existing commodity */
- gnc_ui_commodity_update_quote_info(win, commodity);
- win->edit_commodity = commodity;
+ /* Update stock quote info based on existing commodity */
+ gnc_ui_commodity_update_quote_info(win, commodity);
+ win->edit_commodity = commodity;
- /* Update stock quote sensitivities based on check box */
- gnc_ui_commodity_quote_info_cb(win->get_quote_check, win);
+ /* Update stock quote sensitivities based on check box */
+ gnc_ui_commodity_quote_info_cb(win->get_quote_check, win);
- /* Run the dialog, handling the terminal conditions. */
- done = FALSE;
- while (!done) {
- value = gtk_dialog_run(GTK_DIALOG(win->dialog));
- switch (value) {
- case GTK_RESPONSE_OK:
- DEBUG("case OK");
- done = gnc_ui_commodity_dialog_to_object(win);
- retval = win->edit_commodity;
- break;
- case GTK_RESPONSE_HELP:
- DEBUG("case HELP");
- if (help_callback)
- help_callback ();
- break;
- default: /* Cancel, Escape, Close, etc. */
- DEBUG("default: %d", value);
- retval = NULL;
- done = TRUE;
- break;
+ /* Run the dialog, handling the terminal conditions. */
+ done = FALSE;
+ while (!done)
+ {
+ value = gtk_dialog_run(GTK_DIALOG(win->dialog));
+ switch (value)
+ {
+ case GTK_RESPONSE_OK:
+ DEBUG("case OK");
+ done = gnc_ui_commodity_dialog_to_object(win);
+ retval = win->edit_commodity;
+ break;
+ case GTK_RESPONSE_HELP:
+ DEBUG("case HELP");
+ if (help_callback)
+ help_callback ();
+ break;
+ default: /* Cancel, Escape, Close, etc. */
+ DEBUG("default: %d", value);
+ retval = NULL;
+ done = TRUE;
+ break;
+ }
}
- }
- gtk_widget_destroy (GTK_WIDGET (win->dialog)); /* Close and destroy */
- g_free(win);
+ gtk_widget_destroy (GTK_WIDGET (win->dialog)); /* Close and destroy */
+ g_free(win);
- LEAVE(" ");
- return retval;
+ LEAVE(" ");
+ return retval;
}
/** Create and run the new/edit commodity dialog.
*/
-gnc_commodity *
-gnc_ui_new_commodity_modal_full(const char * namespace,
- GtkWidget * parent,
- const char * cusip,
- const char * fullname,
- const char * mnemonic,
- int fraction)
+gnc_commodity *
+gnc_ui_new_commodity_modal_full(const char * namespace,
+ GtkWidget * parent,
+ const char * cusip,
+ const char * fullname,
+ const char * mnemonic,
+ int fraction)
{
- gnc_commodity *result;
+ gnc_commodity *result;
- ENTER(" ");
- result = gnc_ui_common_commodity_modal(NULL, parent, namespace, cusip,
- fullname, mnemonic, 10000);
- LEAVE(" ");
- return result;
+ ENTER(" ");
+ result = gnc_ui_common_commodity_modal(NULL, parent, namespace, cusip,
+ fullname, mnemonic, 10000);
+ LEAVE(" ");
+ return result;
}
/** External routine for popping up the new commodity dialog box.
@@ -1141,13 +1194,13 @@
gnc_ui_new_commodity_modal(const char * default_namespace,
GtkWidget * parent)
{
- gnc_commodity *result;
+ gnc_commodity *result;
- ENTER(" ");
- result = gnc_ui_common_commodity_modal(NULL, parent, default_namespace, NULL,
- NULL, NULL, 0);
- LEAVE(" ");
- return result;
+ ENTER(" ");
+ result = gnc_ui_common_commodity_modal(NULL, parent, default_namespace, NULL,
+ NULL, NULL, 0);
+ LEAVE(" ");
+ return result;
}
/********************************************************************
@@ -1163,13 +1216,13 @@
gnc_ui_edit_commodity_modal(gnc_commodity *commodity,
GtkWidget * parent)
{
- gnc_commodity *result;
+ gnc_commodity *result;
- ENTER(" ");
- result = gnc_ui_common_commodity_modal(commodity, parent, NULL, NULL,
- NULL, NULL, 0);
- LEAVE(" ");
- return result != NULL;
+ ENTER(" ");
+ result = gnc_ui_common_commodity_modal(commodity, parent, NULL, NULL,
+ NULL, NULL, 0);
+ LEAVE(" ");
+ return result != NULL;
}
@@ -1180,98 +1233,107 @@
gboolean
gnc_ui_commodity_dialog_to_object(CommodityWindow * w)
{
- gnc_quote_source *source;
- QuoteSourceType type;
- const char * fullname = gtk_entry_get_text(GTK_ENTRY(w->fullname_entry));
- gchar *namespace = gnc_ui_namespace_picker_ns (w->namespace_combo);
- const char * mnemonic = gtk_entry_get_text(GTK_ENTRY(w->mnemonic_entry));
- const char * code = gtk_entry_get_text(GTK_ENTRY(w->code_entry));
- QofBook * book = gnc_get_current_book ();
- int fraction = gtk_spin_button_get_value_as_int
- (GTK_SPIN_BUTTON(w->fraction_spinbutton));
- const char *string;
- gnc_commodity * c;
- gint selection;
+ gnc_quote_source *source;
+ QuoteSourceType type;
+ const char * fullname = gtk_entry_get_text(GTK_ENTRY(w->fullname_entry));
+ gchar *namespace = gnc_ui_namespace_picker_ns (w->namespace_combo);
+ const char * mnemonic = gtk_entry_get_text(GTK_ENTRY(w->mnemonic_entry));
+ const char * code = gtk_entry_get_text(GTK_ENTRY(w->code_entry));
+ QofBook * book = gnc_get_current_book ();
+ int fraction = gtk_spin_button_get_value_as_int
+ (GTK_SPIN_BUTTON(w->fraction_spinbutton));
+ const char *string;
+ gnc_commodity * c;
+ gint selection;
- ENTER(" ");
- /* Special case currencies */
- if (gnc_commodity_namespace_is_iso (namespace)) {
- if (w->edit_commodity) {
- c = w->edit_commodity;
- gnc_commodity_begin_edit(c);
- gnc_commodity_user_set_quote_flag (c, gtk_toggle_button_get_active
- (GTK_TOGGLE_BUTTON (w->get_quote_check)));
- selection = gtk_combo_box_get_active(GTK_COMBO_BOX(w->quote_tz_menu));
- string = gnc_timezone_menu_position_to_string(selection);
- gnc_commodity_set_quote_tz(c, string);
- gnc_commodity_commit_edit(c);
- return TRUE;
+ ENTER(" ");
+ /* Special case currencies */
+ if (gnc_commodity_namespace_is_iso (namespace))
+ {
+ if (w->edit_commodity)
+ {
+ c = w->edit_commodity;
+ gnc_commodity_begin_edit(c);
+ gnc_commodity_user_set_quote_flag (c, gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (w->get_quote_check)));
+ selection = gtk_combo_box_get_active(GTK_COMBO_BOX(w->quote_tz_menu));
+ string = gnc_timezone_menu_position_to_string(selection);
+ gnc_commodity_set_quote_tz(c, string);
+ gnc_commodity_commit_edit(c);
+ return TRUE;
+ }
+ gnc_warning_dialog(w->dialog, "%s",
+ _("You may not create a new national currency."));
+ return FALSE;
}
- gnc_warning_dialog(w->dialog, "%s",
- _("You may not create a new national currency."));
- return FALSE;
- }
- if(fullname && fullname[0] &&
- namespace && namespace[0] &&
- mnemonic && mnemonic[0]) {
- c = gnc_commodity_table_lookup (gnc_get_current_commodities(),
- namespace, mnemonic);
+ if (fullname && fullname[0] &&
+ namespace && namespace[0] &&
+ mnemonic && mnemonic[0])
+ {
+ c = gnc_commodity_table_lookup (gnc_get_current_commodities(),
+ namespace, mnemonic);
- if ((!w->edit_commodity && c) ||
- (w->edit_commodity && c && (c != w->edit_commodity))) {
- gnc_warning_dialog (w->dialog, "%s", _("That commodity already exists."));
- g_free(namespace);
- return FALSE;
- }
+ if ((!w->edit_commodity && c) ||
+ (w->edit_commodity && c && (c != w->edit_commodity)))
+ {
+ gnc_warning_dialog (w->dialog, "%s", _("That commodity already exists."));
+ g_free(namespace);
+ return FALSE;
+ }
- if (!w->edit_commodity) {
- c = gnc_commodity_new(book, fullname, namespace, mnemonic, code, fraction);
- w->edit_commodity = c;
- gnc_commodity_begin_edit(c);
- } else {
- c = w->edit_commodity;
- gnc_commodity_begin_edit(c);
+ if (!w->edit_commodity)
+ {
+ c = gnc_commodity_new(book, fullname, namespace, mnemonic, code, fraction);
+ w->edit_commodity = c;
+ gnc_commodity_begin_edit(c);
+ }
+ else
+ {
+ c = w->edit_commodity;
+ gnc_commodity_begin_edit(c);
- gnc_commodity_table_remove (gnc_get_current_commodities(), c);
+ gnc_commodity_table_remove (gnc_get_current_commodities(), c);
- gnc_commodity_set_fullname (c, fullname);
- gnc_commodity_set_mnemonic (c, mnemonic);
- gnc_commodity_set_namespace (c, namespace);
- gnc_commodity_set_cusip (c, code);
- gnc_commodity_set_fraction (c, fraction);
- }
+ gnc_commodity_set_fullname (c, fullname);
+ gnc_commodity_set_mnemonic (c, mnemonic);
+ gnc_commodity_set_namespace (c, namespace);
+ gnc_commodity_set_cusip (c, code);
+ gnc_commodity_set_fraction (c, fraction);
+ }
- gnc_commodity_user_set_quote_flag (c, gtk_toggle_button_get_active
- (GTK_TOGGLE_BUTTON (w->get_quote_check)));
+ gnc_commodity_user_set_quote_flag (c, gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (w->get_quote_check)));
- for (type = SOURCE_SINGLE; type < SOURCE_MAX; type++) {
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w->source_button[type])))
- break;
- }
- selection = gtk_combo_box_get_active(GTK_COMBO_BOX(w->source_menu[type]));
- source = gnc_quote_source_lookup_by_ti (type, selection);
- gnc_commodity_set_quote_source(c, source);
+ for (type = SOURCE_SINGLE; type < SOURCE_MAX; type++)
+ {
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w->source_button[type])))
+ break;
+ }
+ selection = gtk_combo_box_get_active(GTK_COMBO_BOX(w->source_menu[type]));
+ source = gnc_quote_source_lookup_by_ti (type, selection);
+ gnc_commodity_set_quote_source(c, source);
- selection = gtk_combo_box_get_active(GTK_COMBO_BOX(w->quote_tz_menu));
- string = gnc_timezone_menu_position_to_string(selection);
- gnc_commodity_set_quote_tz(c, string);
- gnc_commodity_commit_edit(c);
+ selection = gtk_combo_box_get_active(GTK_COMBO_BOX(w->quote_tz_menu));
+ string = gnc_timezone_menu_position_to_string(selection);
+ gnc_commodity_set_quote_tz(c, string);
+ gnc_commodity_commit_edit(c);
- /* remember the commodity */
- c = gnc_commodity_table_insert(gnc_get_current_commodities(), c);
- }
- else {
- gnc_warning_dialog(w->dialog, "%s",
- _("You must enter a non-empty \"Full name\", "
- "\"Symbol/abbreviation\", "
- "and \"Type\" for the commodity."));
+ /* remember the commodity */
+ c = gnc_commodity_table_insert(gnc_get_current_commodities(), c);
+ }
+ else
+ {
+ gnc_warning_dialog(w->dialog, "%s",
+ _("You must enter a non-empty \"Full name\", "
+ "\"Symbol/abbreviation\", "
+ "and \"Type\" for the commodity."));
+ g_free(namespace);
+ return FALSE;
+ }
g_free(namespace);
- return FALSE;
- }
- g_free(namespace);
- LEAVE(" ");
- return TRUE;
+ LEAVE(" ");
+ return TRUE;
}
/** @} */
Modified: gnucash/trunk/src/gnome-utils/dialog-commodity.h
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-commodity.h 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/dialog-commodity.h 2010-03-02 21:42:11 UTC (rev 18791)
@@ -43,12 +43,13 @@
* that if values are added, the routines in dialog-commodity.c will
* need to be updated to match.
*/
-typedef enum {
- DIAG_COMM_CURRENCY, /**< Dialog box should only allow selection
+typedef enum
+{
+ DIAG_COMM_CURRENCY, /**< Dialog box should only allow selection
of a currency. */
- DIAG_COMM_NON_CURRENCY, /**< Dialog box should allow selection of
+ DIAG_COMM_NON_CURRENCY, /**< Dialog box should allow selection of
anything but a currency. */
- DIAG_COMM_ALL, /**< Dialog box should allow selection of
+ DIAG_COMM_ALL, /**< Dialog box should allow selection of
anything. */
} dialog_commodity_mode;
@@ -57,7 +58,7 @@
/** This function is used to set the action routine for the help
* button in the commodity dialog windows. If the action routine is
* unset, the help button will not be visible to the user.
- *
+ *
* @param cb The function to be called when the user clicks the help
* button. */
void gnc_ui_commodity_set_help_callback (gnc_commodity_help_callback cb);
@@ -102,14 +103,14 @@
* @return The commodity selected. May or may not be a newly created
* commodity.
*/
-gnc_commodity *
-gnc_ui_select_commodity_modal_full(gnc_commodity * orig_sel,
- GtkWidget * parent,
- dialog_commodity_mode mode,
- const char * user_message,
- const char * cusip,
- const char * fullname,
- const char * mnemonic);
+gnc_commodity *
+gnc_ui_select_commodity_modal_full(gnc_commodity * orig_sel,
+ GtkWidget * parent,
+ dialog_commodity_mode mode,
+ const char * user_message,
+ const char * cusip,
+ const char * fullname,
+ const char * mnemonic);
/** Ask the user to select a commodity from the existing set of
@@ -129,8 +130,8 @@
* @return The commodity selected. May or may not be a newly created
* commodity.
*/
-gnc_commodity *
-gnc_ui_select_commodity_modal(gnc_commodity * orig_sel,
+gnc_commodity *
+gnc_ui_select_commodity_modal(gnc_commodity * orig_sel,
GtkWidget * parent,
dialog_commodity_mode mode);
/** @} */
@@ -159,16 +160,16 @@
*
* @param fraction If present, this will be the default fraction for
* the new commodity. If absent, a default of 1000 will be used.
- *
+ *
* @return The newly created commodity, or NULL if the user cancelled.
*/
-gnc_commodity *
-gnc_ui_new_commodity_modal_full(const char * namespace,
- GtkWidget * parent,
- const char * cusip,
- const char * fullname,
- const char * mnemonic,
- int fraction);
+gnc_commodity *
+gnc_ui_new_commodity_modal_full(const char * namespace,
+ GtkWidget * parent,
+ const char * cusip,
+ const char * fullname,
+ const char * mnemonic,
+ int fraction);
/** Ask the user to provide the information necessary to create a new
* commodity.
@@ -178,11 +179,11 @@
* namespace for ISO 4217 currencies.
*
* @param parent The parent window of the new dialog.
- *
+ *
* @return The newly created commodity, or NULL if the user cancelled.
*/
-gnc_commodity *
-gnc_ui_new_commodity_modal(const char * default_namespace,
+gnc_commodity *
+gnc_ui_new_commodity_modal(const char * default_namespace,
GtkWidget * parent);
/** Allow the user to edit the information about a commodity. For
@@ -196,7 +197,7 @@
* @param commodity The commodity to edit.
*
* @param parent The parent window of the new dialog.
- *
+ *
* @return The newly created commodity, or NULL if the user cancelled.
*/
gboolean
@@ -224,8 +225,8 @@
* @note The returned string must be freed by the caller.
*/
void gnc_ui_update_namespace_picker(GtkWidget *cbe,
- const gchar *sel,
- dialog_commodity_mode mode);
+ const gchar *sel,
+ dialog_commodity_mode mode);
/** Given a combo box, return the currently selected namespaces.
*
Modified: gnucash/trunk/src/gnome-utils/dialog-file-access.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-file-access.c 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/dialog-file-access.c 2010-03-02 21:42:11 UTC (rev 18791)
@@ -46,116 +46,133 @@
typedef struct FileAccessWindow
{
- /* Parts of the dialog */
- int type;
+ /* Parts of the dialog */
+ int type;
- GtkWidget* dialog;
- GtkWidget* frame_file;
- GtkWidget* frame_database;
- GtkFileChooser* fileChooser;
- GtkComboBox* cb_uri_type;
- GtkEntry* tf_host;
- GtkEntry* tf_database;
- GtkEntry* tf_username;
- GtkEntry* tf_password;
+ GtkWidget* dialog;
+ GtkWidget* frame_file;
+ GtkWidget* frame_database;
+ GtkFileChooser* fileChooser;
+ GtkComboBox* cb_uri_type;
+ GtkEntry* tf_host;
+ GtkEntry* tf_database;
+ GtkEntry* tf_username;
+ GtkEntry* tf_password;
} FileAccessWindow;
static gchar*
geturl( FileAccessWindow* faw )
{
- gchar* url;
- const gchar* host;
- const gchar* database;
- const gchar* username;
- const gchar* password;
- const gchar* type;
- const gchar* file;
+ gchar* url;
+ const gchar* host;
+ const gchar* database;
+ const gchar* username;
+ const gchar* password;
+ const gchar* type;
+ const gchar* file;
- host = gtk_entry_get_text( faw->tf_host );
- database = gtk_entry_get_text( faw->tf_database );
- username = gtk_entry_get_text( faw->tf_username );
- password = gtk_entry_get_text( faw->tf_password );
- file = gtk_file_chooser_get_filename( faw->fileChooser );
+ host = gtk_entry_get_text( faw->tf_host );
+ database = gtk_entry_get_text( faw->tf_database );
+ username = gtk_entry_get_text( faw->tf_username );
+ password = gtk_entry_get_text( faw->tf_password );
+ file = gtk_file_chooser_get_filename( faw->fileChooser );
- type = gtk_combo_box_get_active_text( faw->cb_uri_type );
- if ( (( strcmp( type, "xml" ) == 0 ) ||
- ( strcmp( type, "sqlite3" ) == 0 ) ||
- ( strcmp( type, "file" ) == 0 )) &&
- ( file == NULL ) )
- return NULL;
+ type = gtk_combo_box_get_active_text( faw->cb_uri_type );
+ if ( (( strcmp( type, "xml" ) == 0 ) ||
+ ( strcmp( type, "sqlite3" ) == 0 ) ||
+ ( strcmp( type, "file" ) == 0 )) &&
+ ( file == NULL ) )
+ return NULL;
- if( strcmp( type, "xml" ) == 0 ) {
- url = g_strdup_printf( "xml://%s", file );
- } else if( strcmp( type, "sqlite3" ) == 0 ) {
- url = g_strdup_printf( "sqlite3://%s", file );
- } else if( strcmp( type, "file" ) == 0 ) {
- url = g_strdup_printf( "file://%s", file );
- } else if( strcmp( type, "mysql" ) == 0 ) {
- url = g_strdup_printf( "mysql://%s:%s:%s:%s",
- host, database, username, password );
- } else {
- g_assert( strcmp( type, "postgres" ) == 0 );
- type = "postgres";
- url = g_strdup_printf( "postgres://%s:%s:%s:%s",
- host, database, username, password );
- }
+ if ( strcmp( type, "xml" ) == 0 )
+ {
+ url = g_strdup_printf( "xml://%s", file );
+ }
+ else if ( strcmp( type, "sqlite3" ) == 0 )
+ {
+ url = g_strdup_printf( "sqlite3://%s", file );
+ }
+ else if ( strcmp( type, "file" ) == 0 )
+ {
+ url = g_strdup_printf( "file://%s", file );
+ }
+ else if ( strcmp( type, "mysql" ) == 0 )
+ {
+ url = g_strdup_printf( "mysql://%s:%s:%s:%s",
+ host, database, username, password );
+ }
+ else
+ {
+ g_assert( strcmp( type, "postgres" ) == 0 );
+ type = "postgres";
+ url = g_strdup_printf( "postgres://%s:%s:%s:%s",
+ host, database, username, password );
+ }
- return url;
+ return url;
}
void
gnc_ui_file_access_response_cb(GtkDialog *dialog, gint response, GtkDialog *unused)
{
FileAccessWindow* faw;
- gchar* url;
+ gchar* url;
g_return_if_fail( dialog != NULL );
faw = g_object_get_data( G_OBJECT(dialog), "FileAccessWindow" );
g_return_if_fail( faw != NULL );
- switch( response ) {
+ switch ( response )
+ {
case GTK_RESPONSE_HELP:
gnc_gnome_help( HF_HELP, HL_GLOBPREFS );
break;
- case GTK_RESPONSE_OK:
- url = geturl( faw );
- if( url == NULL ) {
- return;
- }
- if( faw->type == FILE_ACCESS_OPEN ) {
- gnc_file_open_file( url );
- } else if( faw->type == FILE_ACCESS_SAVE_AS ) {
- gnc_file_do_save_as( url );
- }
- break;
+ case GTK_RESPONSE_OK:
+ url = geturl( faw );
+ if ( url == NULL )
+ {
+ return;
+ }
+ if ( faw->type == FILE_ACCESS_OPEN )
+ {
+ gnc_file_open_file( url );
+ }
+ else if ( faw->type == FILE_ACCESS_SAVE_AS )
+ {
+ gnc_file_do_save_as( url );
+ }
+ break;
- case GTK_RESPONSE_CANCEL:
- break;
+ case GTK_RESPONSE_CANCEL:
+ break;
default:
PERR( "Invalid response" );
break;
}
- if( response != GTK_RESPONSE_HELP ) {
+ if ( response != GTK_RESPONSE_HELP )
+ {
gtk_widget_destroy( GTK_WIDGET(dialog) );
- }
+ }
}
/* Activate the file chooser and deactivate the db selection fields */
static void
set_widget_sensitivity( FileAccessWindow* faw, gboolean is_file_based_uri )
{
- if (is_file_based_uri)
- {
- gtk_widget_show(faw->frame_file);
- gtk_widget_hide(faw->frame_database);
- } else {
- gtk_widget_show(faw->frame_database);
- gtk_widget_hide(faw->frame_file);
- }
+ if (is_file_based_uri)
+ {
+ gtk_widget_show(faw->frame_file);
+ gtk_widget_hide(faw->frame_database);
+ }
+ else
+ {
+ gtk_widget_show(faw->frame_database);
+ gtk_widget_hide(faw->frame_file);
+ }
// gtk_widget_set_sensitive( faw->frame_file, is_file_based_uri );
// gtk_widget_set_sensitive( faw->frame_database, !is_file_based_uri );
}
@@ -163,45 +180,51 @@
static void
set_widget_sensitivity_for_uri_type( FileAccessWindow* faw, const gchar* uri_type )
{
- if( strcmp( uri_type, "file" ) == 0 || strcmp( uri_type, "xml" ) == 0
- || strcmp( uri_type, "sqlite3" ) == 0 ) {
- set_widget_sensitivity( faw, /* is_file_based_uri */ TRUE );
- } else if( strcmp( uri_type, "mysql" ) == 0 || strcmp( uri_type, "postgres" ) == 0 ) {
- set_widget_sensitivity( faw, /* is_file_based_uri */ FALSE );
- } else {
- g_assert( FALSE );
- }
+ if ( strcmp( uri_type, "file" ) == 0 || strcmp( uri_type, "xml" ) == 0
+ || strcmp( uri_type, "sqlite3" ) == 0 )
+ {
+ set_widget_sensitivity( faw, /* is_file_based_uri */ TRUE );
+ }
+ else if ( strcmp( uri_type, "mysql" ) == 0 || strcmp( uri_type, "postgres" ) == 0 )
+ {
+ set_widget_sensitivity( faw, /* is_file_based_uri */ FALSE );
+ }
+ else
+ {
+ g_assert( FALSE );
+ }
}
static void
cb_uri_type_changed_cb( GtkComboBox* cb )
{
- GtkWidget* dialog;
+ GtkWidget* dialog;
FileAccessWindow* faw;
- const gchar* type;
+ const gchar* type;
- g_return_if_fail( cb != NULL );
+ g_return_if_fail( cb != NULL );
- dialog = gtk_widget_get_toplevel( GTK_WIDGET(cb) );
- g_return_if_fail( dialog != NULL );
+ dialog = gtk_widget_get_toplevel( GTK_WIDGET(cb) );
+ g_return_if_fail( dialog != NULL );
faw = g_object_get_data( G_OBJECT(dialog), "FileAccessWindow" );
g_return_if_fail( faw != NULL );
- type = gtk_combo_box_get_active_text( cb );
- set_widget_sensitivity_for_uri_type( faw, type );
+ type = gtk_combo_box_get_active_text( cb );
+ set_widget_sensitivity_for_uri_type( faw, type );
}
static const char*
get_default_database( void )
{
- const gchar* default_db;
+ const gchar* default_db;
- default_db = g_getenv( "GNC_DEFAULT_DATABASE" );
- if( default_db == NULL ) {
- default_db = DEFAULT_DATABASE;
- }
+ default_db = g_getenv( "GNC_DEFAULT_DATABASE" );
+ if ( default_db == NULL )
+ {
+ default_db = DEFAULT_DATABASE;
+ }
- return default_db;
+ return default_db;
}
static void
@@ -210,145 +233,166 @@
FileAccessWindow *faw;
GladeXML* xml;
GtkWidget* box;
- GList* ds_node;
- GtkButton* op;
- GtkWidget* align;
- GtkFileChooserWidget* fileChooser;
- GtkFileChooserAction fileChooserAction = GTK_FILE_CHOOSER_ACTION_OPEN;
- GList* list;
- GList* node;
- GtkWidget* uri_type_container;
- gboolean need_access_method_file = FALSE;
- gboolean need_access_method_mysql = FALSE;
- gboolean need_access_method_postgres = FALSE;
- gboolean need_access_method_sqlite3 = FALSE;
- gboolean need_access_method_xml = FALSE;
- gint access_method_index = -1;
- gint active_access_method_index = -1;
- const gchar* default_db;
- const gchar *button_label = NULL;
+ GList* ds_node;
+ GtkButton* op;
+ GtkWidget* align;
+ GtkFileChooserWidget* fileChooser;
+ GtkFileChooserAction fileChooserAction = GTK_FILE_CHOOSER_ACTION_OPEN;
+ GList* list;
+ GList* node;
+ GtkWidget* uri_type_container;
+ gboolean need_access_method_file = FALSE;
+ gboolean need_access_method_mysql = FALSE;
+ gboolean need_access_method_postgres = FALSE;
+ gboolean need_access_method_sqlite3 = FALSE;
+ gboolean need_access_method_xml = FALSE;
+ gint access_method_index = -1;
+ gint active_access_method_index = -1;
+ const gchar* default_db;
+ const gchar *button_label = NULL;
- g_return_if_fail( type == FILE_ACCESS_OPEN || type == FILE_ACCESS_SAVE_AS );
+ g_return_if_fail( type == FILE_ACCESS_OPEN || type == FILE_ACCESS_SAVE_AS );
faw = g_new0(FileAccessWindow, 1);
g_return_if_fail( faw != NULL );
- faw->type = type;
+ faw->type = type;
/* Open the dialog */
xml = gnc_glade_xml_new( "dialog-file-access.glade", "File Access" );
faw->dialog = glade_xml_get_widget( xml, "File Access" );
g_object_set_data_full( G_OBJECT(faw->dialog), "FileAccessWindow", faw,
- g_free );
+ g_free );
- faw->frame_file = glade_xml_get_widget( xml, "frame_file" );
- faw->frame_database = glade_xml_get_widget( xml, "frame_database" );
+ faw->frame_file = glade_xml_get_widget( xml, "frame_file" );
+ faw->frame_database = glade_xml_get_widget( xml, "frame_database" );
faw->tf_host = GTK_ENTRY(glade_xml_get_widget( xml, "tf_host" ));
- gtk_entry_set_text( faw->tf_host, DEFAULT_HOST );
+ gtk_entry_set_text( faw->tf_host, DEFAULT_HOST );
faw->tf_database = GTK_ENTRY(glade_xml_get_widget( xml, "tf_database" ));
- default_db = get_default_database();
- gtk_entry_set_text( faw->tf_database, default_db );
+ default_db = get_default_database();
+ gtk_entry_set_text( faw->tf_database, default_db );
faw->tf_username = GTK_ENTRY(glade_xml_get_widget( xml, "tf_username" ));
faw->tf_password = GTK_ENTRY(glade_xml_get_widget( xml, "tf_password" ));
- switch( type ) {
- case FILE_ACCESS_OPEN:
- gtk_window_set_title(GTK_WINDOW(faw->dialog), _("Open..."));
- button_label = "gtk-open";
- fileChooserAction = GTK_FILE_CHOOSER_ACTION_OPEN;
- break;
+ switch ( type )
+ {
+ case FILE_ACCESS_OPEN:
+ gtk_window_set_title(GTK_WINDOW(faw->dialog), _("Open..."));
+ button_label = "gtk-open";
+ fileChooserAction = GTK_FILE_CHOOSER_ACTION_OPEN;
+ break;
- case FILE_ACCESS_SAVE_AS:
- gtk_window_set_title(GTK_WINDOW(faw->dialog), _("Save As..."));
- button_label = "gtk-save-as";
- fileChooserAction = GTK_FILE_CHOOSER_ACTION_SAVE;
- break;
- }
+ case FILE_ACCESS_SAVE_AS:
+ gtk_window_set_title(GTK_WINDOW(faw->dialog), _("Save As..."));
+ button_label = "gtk-save-as";
+ fileChooserAction = GTK_FILE_CHOOSER_ACTION_SAVE;
+ break;
+ }
- op = GTK_BUTTON(glade_xml_get_widget( xml, "pb_op" ));
- if( op != NULL ) {
- gtk_button_set_label( op, button_label );
- gtk_button_set_use_stock( op, TRUE );
- }
+ op = GTK_BUTTON(glade_xml_get_widget( xml, "pb_op" ));
+ if ( op != NULL )
+ {
+ gtk_button_set_label( op, button_label );
+ gtk_button_set_use_stock( op, TRUE );
+ }
- align = glade_xml_get_widget( xml, "alignment_file_chooser" );
- fileChooser = GTK_FILE_CHOOSER_WIDGET(gtk_file_chooser_widget_new( fileChooserAction ));
- faw->fileChooser = GTK_FILE_CHOOSER(fileChooser);
- gtk_container_add( GTK_CONTAINER(align), GTK_WIDGET(fileChooser) );
+ align = glade_xml_get_widget( xml, "alignment_file_chooser" );
+ fileChooser = GTK_FILE_CHOOSER_WIDGET(gtk_file_chooser_widget_new( fileChooserAction ));
+ faw->fileChooser = GTK_FILE_CHOOSER(fileChooser);
+ gtk_container_add( GTK_CONTAINER(align), GTK_WIDGET(fileChooser) );
- uri_type_container = glade_xml_get_widget( xml, "vb_uri_type_container" );
- faw->cb_uri_type = GTK_COMBO_BOX(gtk_combo_box_new_text());
- gtk_container_add( GTK_CONTAINER(uri_type_container), GTK_WIDGET(faw->cb_uri_type) );
- gtk_box_set_child_packing( GTK_BOX(uri_type_container), GTK_WIDGET(faw->cb_uri_type),
- /*expand*/TRUE, /*fill*/FALSE, /*padding*/0, GTK_PACK_START );
- g_object_connect( G_OBJECT(faw->cb_uri_type),
- "signal::changed", cb_uri_type_changed_cb, NULL,
- NULL );
+ uri_type_container = glade_xml_get_widget( xml, "vb_uri_type_container" );
+ faw->cb_uri_type = GTK_COMBO_BOX(gtk_combo_box_new_text());
+ gtk_container_add( GTK_CONTAINER(uri_type_container), GTK_WIDGET(faw->cb_uri_type) );
+ gtk_box_set_child_packing( GTK_BOX(uri_type_container), GTK_WIDGET(faw->cb_uri_type),
+ /*expand*/TRUE, /*fill*/FALSE, /*padding*/0, GTK_PACK_START );
+ g_object_connect( G_OBJECT(faw->cb_uri_type),
+ "signal::changed", cb_uri_type_changed_cb, NULL,
+ NULL );
/* Autoconnect signals */
glade_xml_signal_autoconnect_full( xml, gnc_glade_autoconnect_full_func,
- faw->dialog );
+ faw->dialog );
- /* See what qof backends are available and add appropriate ones to the combo box */
- list = qof_backend_get_registered_access_method_list();
- for( node = list; node != NULL; node = node->next ) {
- const gchar* access_method = node->data;
+ /* See what qof backends are available and add appropriate ones to the combo box */
+ list = qof_backend_get_registered_access_method_list();
+ for ( node = list; node != NULL; node = node->next )
+ {
+ const gchar* access_method = node->data;
- /* For the different access methods, "mysql" and "postgres" are added if available. Access
- methods "xml" and "sqlite3" are compressed to "file" if opening a file, but when saving a file,
- both access methods are added. */
- if( strcmp( access_method, "mysql" ) == 0 ) {
- need_access_method_mysql = TRUE;
- } else if( strcmp( access_method, "postgres" ) == 0 ) {
- need_access_method_postgres = TRUE;
- } else if( strcmp( access_method, "xml" ) == 0 ) {
- if( type == FILE_ACCESS_OPEN ) {
- need_access_method_file = TRUE;
- } else {
- need_access_method_xml = TRUE;
- }
- } else if( strcmp( access_method, "sqlite3" ) == 0 ) {
- if( type == FILE_ACCESS_OPEN ) {
- need_access_method_file = TRUE;
- } else {
- need_access_method_sqlite3 = TRUE;
- }
- }
- }
- g_list_free(list);
+ /* For the different access methods, "mysql" and "postgres" are added if available. Access
+ methods "xml" and "sqlite3" are compressed to "file" if opening a file, but when saving a file,
+ both access methods are added. */
+ if ( strcmp( access_method, "mysql" ) == 0 )
+ {
+ need_access_method_mysql = TRUE;
+ }
+ else if ( strcmp( access_method, "postgres" ) == 0 )
+ {
+ need_access_method_postgres = TRUE;
+ }
+ else if ( strcmp( access_method, "xml" ) == 0 )
+ {
+ if ( type == FILE_ACCESS_OPEN )
+ {
+ need_access_method_file = TRUE;
+ }
+ else
+ {
+ need_access_method_xml = TRUE;
+ }
+ }
+ else if ( strcmp( access_method, "sqlite3" ) == 0 )
+ {
+ if ( type == FILE_ACCESS_OPEN )
+ {
+ need_access_method_file = TRUE;
+ }
+ else
+ {
+ need_access_method_sqlite3 = TRUE;
+ }
+ }
+ }
+ g_list_free(list);
- /* Now that the set of access methods has been ascertained, add them to the list, and set the
- default. */
- access_method_index = -1;
- if( need_access_method_file ) {
- gtk_combo_box_append_text( faw->cb_uri_type, "file" );
- active_access_method_index = ++access_method_index;
- }
- if( need_access_method_mysql ) {
- gtk_combo_box_append_text( faw->cb_uri_type, "mysql" );
- ++access_method_index;
- }
- if( need_access_method_postgres ) {
- gtk_combo_box_append_text( faw->cb_uri_type, "postgres" );
- ++access_method_index;
- }
- if( need_access_method_sqlite3 ) {
- gtk_combo_box_append_text( faw->cb_uri_type, "sqlite3" );
- active_access_method_index = ++access_method_index;
- }
- if( need_access_method_xml ) {
- gtk_combo_box_append_text( faw->cb_uri_type, "xml" );
- ++access_method_index;
+ /* Now that the set of access methods has been ascertained, add them to the list, and set the
+ default. */
+ access_method_index = -1;
+ if ( need_access_method_file )
+ {
+ gtk_combo_box_append_text( faw->cb_uri_type, "file" );
+ active_access_method_index = ++access_method_index;
+ }
+ if ( need_access_method_mysql )
+ {
+ gtk_combo_box_append_text( faw->cb_uri_type, "mysql" );
+ ++access_method_index;
+ }
+ if ( need_access_method_postgres )
+ {
+ gtk_combo_box_append_text( faw->cb_uri_type, "postgres" );
+ ++access_method_index;
+ }
+ if ( need_access_method_sqlite3 )
+ {
+ gtk_combo_box_append_text( faw->cb_uri_type, "sqlite3" );
+ active_access_method_index = ++access_method_index;
+ }
+ if ( need_access_method_xml )
+ {
+ gtk_combo_box_append_text( faw->cb_uri_type, "xml" );
+ ++access_method_index;
- // Set XML as default if it is offered (which mean we are in
- // the "Save As" dialog)
- active_access_method_index = access_method_index;
- }
- g_assert( active_access_method_index >= 0 );
+ // Set XML as default if it is offered (which mean we are in
+ // the "Save As" dialog)
+ active_access_method_index = access_method_index;
+ }
+ g_assert( active_access_method_index >= 0 );
/* Clean up the xml data structure when the dialog is destroyed */
g_object_set_data_full( G_OBJECT(faw->dialog), "dialog-file-access.glade",
- xml, g_object_unref );
+ xml, g_object_unref );
/* Run the dialog */
gtk_widget_show_all( faw->dialog );
@@ -362,12 +406,12 @@
void
gnc_ui_file_access_for_open( void )
{
- gnc_ui_file_access( FILE_ACCESS_OPEN );
+ gnc_ui_file_access( FILE_ACCESS_OPEN );
}
void
gnc_ui_file_access_for_save_as( void )
{
- gnc_ui_file_access( FILE_ACCESS_SAVE_AS );
+ gnc_ui_file_access( FILE_ACCESS_SAVE_AS );
}
Modified: gnucash/trunk/src/gnome-utils/dialog-options.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-options.c 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/dialog-options.c 2010-03-02 21:42:11 UTC (rev 18791)
@@ -77,196 +77,200 @@
struct gnc_option_win
{
- GtkWidget * dialog;
- GtkWidget * notebook;
- GtkWidget * page_list;
+ GtkWidget * dialog;
+ GtkWidget * notebook;
+ GtkWidget * page_list;
- gboolean toplevel;
+ gboolean toplevel;
- GtkTooltips * tips;
+ GtkTooltips * tips;
- GNCOptionWinCallback apply_cb;
- gpointer apply_cb_data;
+ GNCOptionWinCallback apply_cb;
+ gpointer apply_cb_data;
- GNCOptionWinCallback help_cb;
- gpointer help_cb_data;
+ GNCOptionWinCallback help_cb;
+ gpointer help_cb_data;
- GNCOptionWinCallback close_cb;
- gpointer close_cb_data;
+ GNCOptionWinCallback close_cb;
+ gpointer close_cb_data;
- /* Hold onto this for a complete reset */
- GNCOptionDB * option_db;
+ /* Hold onto this for a complete reset */
+ GNCOptionDB * option_db;
};
-typedef enum {
- GNC_RD_WID_AB_BUTTON_POS = 0,
- GNC_RD_WID_AB_WIDGET_POS,
- GNC_RD_WID_REL_BUTTON_POS,
- GNC_RD_WID_REL_WIDGET_POS} GNCRdPositions;
+typedef enum
+{
+ GNC_RD_WID_AB_BUTTON_POS = 0,
+ GNC_RD_WID_AB_WIDGET_POS,
+ GNC_RD_WID_REL_BUTTON_POS,
+ GNC_RD_WID_REL_WIDGET_POS
+} GNCRdPositions;
static GNCOptionWinCallback global_help_cb = NULL;
gpointer global_help_cb_data = NULL;
void gnc_options_dialog_response_cb(GtkDialog *dialog, gint response,
- GNCOptionWin *window);
+ GNCOptionWin *window);
static void gnc_options_dialog_reset_cb(GtkWidget * w, gpointer data);
void gnc_options_dialog_list_select_cb(GtkWidget * list, GtkWidget * item,
- gpointer data);
+ gpointer data);
static inline gint
color_d_to_i16 (double d)
{
- return (d * 0xFFFF);
+ return (d * 0xFFFF);
}
static inline double
color_i16_to_d (gint i16)
{
- return ((double)i16 / 0xFFFF);
+ return ((double)i16 / 0xFFFF);
}
static void
gnc_options_dialog_changed_internal (GtkWidget *widget, gboolean sensitive)
{
- GtkDialog *dialog;
+ GtkDialog *dialog;
- while (widget && !GTK_IS_DIALOG(widget))
- widget = gtk_widget_get_parent(widget);
- if (widget == NULL)
- return;
+ while (widget && !GTK_IS_DIALOG(widget))
+ widget = gtk_widget_get_parent(widget);
+ if (widget == NULL)
+ return;
- dialog = GTK_DIALOG(widget);
- gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_OK, sensitive);
- gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_APPLY, sensitive);
+ dialog = GTK_DIALOG(widget);
+ gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_OK, sensitive);
+ gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_APPLY, sensitive);
}
void
gnc_options_dialog_changed (GNCOptionWin *win)
{
- if (!win) return;
+ if (!win) return;
- gnc_options_dialog_changed_internal (win->dialog, TRUE);
+ gnc_options_dialog_changed_internal (win->dialog, TRUE);
}
void
gnc_option_changed_widget_cb(GtkWidget *widget, GNCOption *option)
{
- gnc_option_set_changed (option, TRUE);
- gnc_option_call_option_widget_changed_proc(option);
- gnc_options_dialog_changed_internal (widget, TRUE);
+ gnc_option_set_changed (option, TRUE);
+ gnc_option_call_option_widget_changed_proc(option);
+ gnc_options_dialog_changed_internal (widget, TRUE);
}
void
gnc_option_changed_option_cb(GtkWidget *dummy, GNCOption *option)
{
- GtkWidget *widget;
+ GtkWidget *widget;
- widget = gnc_option_get_widget (option);
- gnc_option_changed_widget_cb(widget, option);
+ widget = gnc_option_get_widget (option);
+ gnc_option_changed_widget_cb(widget, option);
}
static void
gnc_date_option_set_select_method(GNCOption *option, gboolean use_absolute,
gboolean set_buttons)
{
- GList* widget_list;
- GtkWidget *ab_button, *rel_button, *rel_widget, *ab_widget;
- GtkWidget *widget;
+ GList* widget_list;
+ GtkWidget *ab_button, *rel_button, *rel_widget, *ab_widget;
+ GtkWidget *widget;
- widget = gnc_option_get_widget (option);
+ widget = gnc_option_get_widget (option);
- widget_list = gtk_container_get_children(GTK_CONTAINER(widget));
- ab_button = g_list_nth_data(widget_list, GNC_RD_WID_AB_BUTTON_POS);
- ab_widget = g_list_nth_data(widget_list, GNC_RD_WID_AB_WIDGET_POS);
- rel_button = g_list_nth_data(widget_list, GNC_RD_WID_REL_BUTTON_POS);
- rel_widget = g_list_nth_data(widget_list, GNC_RD_WID_REL_WIDGET_POS);
- g_list_free(widget_list);
+ widget_list = gtk_container_get_children(GTK_CONTAINER(widget));
+ ab_button = g_list_nth_data(widget_list, GNC_RD_WID_AB_BUTTON_POS);
+ ab_widget = g_list_nth_data(widget_list, GNC_RD_WID_AB_WIDGET_POS);
+ rel_button = g_list_nth_data(widget_list, GNC_RD_WID_REL_BUTTON_POS);
+ rel_widget = g_list_nth_data(widget_list, GNC_RD_WID_REL_WIDGET_POS);
+ g_list_free(widget_list);
- if(use_absolute)
- {
- gtk_widget_set_sensitive(ab_widget, TRUE);
- gtk_widget_set_sensitive(rel_widget, FALSE);
- if(set_buttons)
+ if (use_absolute)
{
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ab_button), TRUE);
+ gtk_widget_set_sensitive(ab_widget, TRUE);
+ gtk_widget_set_sensitive(rel_widget, FALSE);
+ if (set_buttons)
+ {
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ab_button), TRUE);
+ }
}
- }
- else
- {
- gtk_widget_set_sensitive(rel_widget, TRUE);
- gtk_widget_set_sensitive(ab_widget, FALSE);
- if (set_buttons)
+ else
{
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rel_button), TRUE);
+ gtk_widget_set_sensitive(rel_widget, TRUE);
+ gtk_widget_set_sensitive(ab_widget, FALSE);
+ if (set_buttons)
+ {
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rel_button), TRUE);
+ }
}
- }
}
static void
gnc_rd_option_ab_set_cb(GtkWidget *widget, gpointer *raw_option)
{
- GNCOption *option = (GNCOption *) raw_option;
- gnc_date_option_set_select_method(option, TRUE, FALSE);
- gnc_option_changed_option_cb(widget, option);
+ GNCOption *option = (GNCOption *) raw_option;
+ gnc_date_option_set_select_method(option, TRUE, FALSE);
+ gnc_option_changed_option_cb(widget, option);
}
static void
gnc_rd_option_rel_set_cb(GtkWidget *widget, gpointer *raw_option)
{
- GNCOption *option = (GNCOption *) raw_option;
- gnc_date_option_set_select_method(option, FALSE, FALSE);
- gnc_option_changed_option_cb(widget, option);
- return;
+ GNCOption *option = (GNCOption *) raw_option;
+ gnc_date_option_set_select_method(option, FALSE, FALSE);
+ gnc_option_changed_option_cb(widget, option);
+ return;
}
static void
gnc_image_option_update_preview_cb (GtkFileChooser *chooser,
- GNCOption *option)
+ GNCOption *option)
{
- gchar *filename;
- GtkImage *image;
- GdkPixbuf *pixbuf;
- gboolean have_preview;
+ gchar *filename;
+ GtkImage *image;
+ GdkPixbuf *pixbuf;
+ gboolean have_preview;
- g_return_if_fail(chooser != NULL);
+ g_return_if_fail(chooser != NULL);
- ENTER("chooser %p, option %p", chooser, option);
- filename = gtk_file_chooser_get_preview_filename(chooser);
- DEBUG("chooser preview name is %s.", filename ? filename : "(null)");
- if (filename == NULL) {
- filename = g_strdup(g_object_get_data(G_OBJECT(chooser), LAST_SELECTION));
- DEBUG("using last selection of %s", filename ? filename : "(null)");
- if (filename == NULL) {
- LEAVE("no usable name");
- return;
+ ENTER("chooser %p, option %p", chooser, option);
+ filename = gtk_file_chooser_get_preview_filename(chooser);
+ DEBUG("chooser preview name is %s.", filename ? filename : "(null)");
+ if (filename == NULL)
+ {
+ filename = g_strdup(g_object_get_data(G_OBJECT(chooser), LAST_SELECTION));
+ DEBUG("using last selection of %s", filename ? filename : "(null)");
+ if (filename == NULL)
+ {
+ LEAVE("no usable name");
+ return;
+ }
}
- }
- image = GTK_IMAGE(gtk_file_chooser_get_preview_widget(chooser));
- pixbuf = gdk_pixbuf_new_from_file_at_size(filename, 128, 128, NULL);
- g_free(filename);
- have_preview = (pixbuf != NULL);
+ image = GTK_IMAGE(gtk_file_chooser_get_preview_widget(chooser));
+ pixbuf = gdk_pixbuf_new_from_file_at_size(filename, 128, 128, NULL);
+ g_free(filename);
+ have_preview = (pixbuf != NULL);
- gtk_image_set_from_pixbuf(image, pixbuf);
- if (pixbuf)
- g_object_unref(pixbuf);
+ gtk_image_set_from_pixbuf(image, pixbuf);
+ if (pixbuf)
+ g_object_unref(pixbuf);
- gtk_file_chooser_set_preview_widget_active(chooser, have_preview);
- LEAVE("preview visible is %d", have_preview);
+ gtk_file_chooser_set_preview_widget_active(chooser, have_preview);
+ LEAVE("preview visible is %d", have_preview);
}
static void
gnc_image_option_selection_changed_cb (GtkFileChooser *chooser,
- GNCOption *option)
+ GNCOption *option)
{
- gchar *filename;
+ gchar *filename;
- filename = gtk_file_chooser_get_preview_filename(chooser);
- if (!filename)
- return;
- g_object_set_data_full(G_OBJECT(chooser), LAST_SELECTION, filename, g_free);
+ filename = gtk_file_chooser_get_preview_filename(chooser);
+ if (!filename)
+ return;
+ g_object_set_data_full(G_OBJECT(chooser), LAST_SELECTION, filename, g_free);
}
/********************************************************************\
@@ -283,41 +287,41 @@
static void
gnc_option_set_ui_value_internal (GNCOption *option, gboolean use_default)
{
- gboolean bad_value = FALSE;
- GtkWidget *widget;
- char *type;
- SCM getter;
- SCM value;
- GNCOptionDef_t *option_def;
+ gboolean bad_value = FALSE;
+ GtkWidget *widget;
+ char *type;
+ SCM getter;
+ SCM value;
+ GNCOptionDef_t *option_def;
- widget = gnc_option_get_widget (option);
- if (!widget)
- return;
+ widget = gnc_option_get_widget (option);
+ if (!widget)
+ return;
- type = gnc_option_type(option);
+ type = gnc_option_type(option);
- if (use_default)
- getter = gnc_option_default_getter(option);
- else
- getter = gnc_option_getter(option);
+ if (use_default)
+ getter = gnc_option_default_getter(option);
+ else
+ getter = gnc_option_getter(option);
- value = scm_call_0(getter);
+ value = scm_call_0(getter);
- option_def = gnc_options_ui_get_option (type);
- if (option_def && option_def->set_value)
- {
- bad_value = option_def->set_value (option, use_default, widget, value);
- if (bad_value)
+ option_def = gnc_options_ui_get_option (type);
+ if (option_def && option_def->set_value)
{
- PERR("bad value\n");
+ bad_value = option_def->set_value (option, use_default, widget, value);
+ if (bad_value)
+ {
+ PERR("bad value\n");
+ }
}
- }
- else
- {
- PERR("Unknown type. Ignoring.\n");
- }
+ else
+ {
+ PERR("Unknown type. Ignoring.\n");
+ }
- free(type);
+ free(type);
}
@@ -331,30 +335,30 @@
static SCM
gnc_option_get_ui_value_internal (GNCOption *option)
{
- SCM result = SCM_UNDEFINED;
- GtkWidget *widget;
- char *type;
- GNCOptionDef_t *option_def;
+ SCM result = SCM_UNDEFINED;
+ GtkWidget *widget;
+ char *type;
+ GNCOptionDef_t *option_def;
- widget = gnc_option_get_widget (option);
- if (!widget)
- return result;
+ widget = gnc_option_get_widget (option);
+ if (!widget)
+ return result;
- type = gnc_option_type(option);
+ type = gnc_option_type(option);
- option_def = gnc_options_ui_get_option (type);
- if (option_def && option_def->get_value)
- {
- result = option_def->get_value (option, widget);
- }
- else
- {
- PERR("Unknown type for refresh. Ignoring.\n");
- }
+ option_def = gnc_options_ui_get_option (type);
+ if (option_def && option_def->get_value)
+ {
+ result = option_def->get_value (option, widget);
+ }
+ else
+ {
+ PERR("Unknown type for refresh. Ignoring.\n");
+ }
- free(type);
+ free(type);
- return result;
+ return result;
}
@@ -372,32 +376,32 @@
static void
gnc_option_set_selectable_internal (GNCOption *option, gboolean selectable)
{
- GtkWidget *widget;
+ GtkWidget *widget;
- widget = gnc_option_get_widget (option);
- if (!widget)
- return;
+ widget = gnc_option_get_widget (option);
+ if (!widget)
+ return;
- gtk_widget_set_sensitive (widget, selectable);
+ gtk_widget_set_sensitive (widget, selectable);
}
static void
gnc_option_default_cb(GtkWidget *widget, GNCOption *option)
{
- gnc_option_set_ui_value (option, TRUE);
- gnc_option_set_changed (option, TRUE);
- gnc_options_dialog_changed_internal (widget, TRUE);
+ gnc_option_set_ui_value (option, TRUE);
+ gnc_option_set_changed (option, TRUE);
+ gnc_options_dialog_changed_internal (widget, TRUE);
}
static void
gnc_option_show_hidden_toggled_cb(GtkWidget *widget, GNCOption* option)
{
- AccountViewInfo avi;
+ AccountViewInfo avi;
GncTreeViewAccount *tree_view;
tree_view = GNC_TREE_VIEW_ACCOUNT(gnc_option_get_widget (option));
gnc_tree_view_account_get_view_info (tree_view, &avi);
- avi.show_hidden = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+ avi.show_hidden = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
gnc_tree_view_account_set_view_info (tree_view, &avi);
gnc_option_changed_widget_cb(widget, option);
}
@@ -406,222 +410,224 @@
static void
gnc_option_multichoice_cb(GtkWidget *widget, gpointer data)
{
- GNCOption *option = data;
- gnc_option_changed_widget_cb(widget, option);
+ GNCOption *option = data;
+ gnc_option_changed_widget_cb(widget, option);
}
#else
static void
gnc_option_multichoice_cb(GtkWidget *w, gint index, gpointer data)
{
- GNCOption *option = data;
- GtkWidget *widget;
- GtkWidget *omenu;
- gpointer _current;
- gint current;
- char *type;
+ GNCOption *option = data;
+ GtkWidget *widget;
+ GtkWidget *omenu;
+ gpointer _current;
+ gint current;
+ char *type;
- widget = gnc_option_get_widget (option);
+ widget = gnc_option_get_widget (option);
- /* the option menu may be part of a date option widget, so we need to
- decomposit the enclosing hbox then */
- type = gnc_option_type (option);
- if (safe_strcmp (type, "date") == 0) {
- char *date_type = gnc_option_date_option_get_subtype(option);
- GList *children;
+ /* the option menu may be part of a date option widget, so we need to
+ decomposit the enclosing hbox then */
+ type = gnc_option_type (option);
+ if (safe_strcmp (type, "date") == 0)
+ {
+ char *date_type = gnc_option_date_option_get_subtype(option);
+ GList *children;
- if (safe_strcmp (date_type, "both") == 0) {
- children = gtk_container_get_children (GTK_CONTAINER (widget));
- widget = g_list_nth_data (children, GNC_RD_WID_REL_WIDGET_POS);
- g_list_free(children);
+ if (safe_strcmp (date_type, "both") == 0)
+ {
+ children = gtk_container_get_children (GTK_CONTAINER (widget));
+ widget = g_list_nth_data (children, GNC_RD_WID_REL_WIDGET_POS);
+ g_list_free(children);
+ }
+ free (date_type);
}
- free (date_type);
- }
- free (type);
+ free (type);
- _current = g_object_get_data(G_OBJECT(widget), "gnc_multichoice_index");
- current = GPOINTER_TO_INT(_current);
+ _current = g_object_get_data(G_OBJECT(widget), "gnc_multichoice_index");
+ current = GPOINTER_TO_INT(_current);
- if (current == index)
- return;
+ if (current == index)
+ return;
- gtk_option_menu_set_history(GTK_OPTION_MENU(widget), index);
- g_object_set_data(G_OBJECT(widget), "gnc_multichoice_index",
- GINT_TO_POINTER(index));
+ gtk_option_menu_set_history(GTK_OPTION_MENU(widget), index);
+ g_object_set_data(G_OBJECT(widget), "gnc_multichoice_index",
+ GINT_TO_POINTER(index));
- gnc_option_set_changed (option, TRUE);
+ gnc_option_set_changed (option, TRUE);
- gnc_option_call_option_widget_changed_proc(option);
+ gnc_option_call_option_widget_changed_proc(option);
- omenu = g_object_get_data(G_OBJECT(w), "gnc_option_menu");
- gnc_options_dialog_changed_internal (omenu, TRUE);
+ omenu = g_object_get_data(G_OBJECT(w), "gnc_option_menu");
+ gnc_options_dialog_changed_internal (omenu, TRUE);
}
#endif
static void
gnc_option_radiobutton_cb(GtkWidget *w, gpointer data)
{
- GNCOption *option = data;
- GtkWidget *widget;
- gpointer _current, _new_value;
- gint current, new_value;
+ GNCOption *option = data;
+ GtkWidget *widget;
+ gpointer _current, _new_value;
+ gint current, new_value;
- widget = gnc_option_get_widget (option);
+ widget = gnc_option_get_widget (option);
- _current = g_object_get_data(G_OBJECT(widget), "gnc_radiobutton_index");
- current = GPOINTER_TO_INT (_current);
+ _current = g_object_get_data(G_OBJECT(widget), "gnc_radiobutton_index");
+ current = GPOINTER_TO_INT (_current);
- _new_value = g_object_get_data (G_OBJECT(w), "gnc_radiobutton_index");
- new_value = GPOINTER_TO_INT (_new_value);
+ _new_value = g_object_get_data (G_OBJECT(w), "gnc_radiobutton_index");
+ new_value = GPOINTER_TO_INT (_new_value);
- if (current == new_value)
- return;
+ if (current == new_value)
+ return;
- g_object_set_data (G_OBJECT(widget), "gnc_radiobutton_index",
- GINT_TO_POINTER(new_value));
- gnc_option_changed_widget_cb(widget, option);
+ g_object_set_data (G_OBJECT(widget), "gnc_radiobutton_index",
+ GINT_TO_POINTER(new_value));
+ gnc_option_changed_widget_cb(widget, option);
}
static GtkWidget *
gnc_option_create_date_widget (GNCOption *option)
{
- GtkWidget * box = NULL;
- GtkWidget *rel_button= NULL, *ab_button=NULL;
- GtkWidget *rel_widget=NULL, *ab_widget=NULL;
- GtkWidget *entry;
- gboolean show_time, use24;
- char *type;
- int num_values;
+ GtkWidget * box = NULL;
+ GtkWidget *rel_button = NULL, *ab_button = NULL;
+ GtkWidget *rel_widget = NULL, *ab_widget = NULL;
+ GtkWidget *entry;
+ gboolean show_time, use24;
+ char *type;
+ int num_values;
- type = gnc_option_date_option_get_subtype(option);
- show_time = gnc_option_show_time(option);
- use24 = gnc_gconf_get_bool(GCONF_GENERAL, "24hour_time", FALSE);
+ type = gnc_option_date_option_get_subtype(option);
+ show_time = gnc_option_show_time(option);
+ use24 = gnc_gconf_get_bool(GCONF_GENERAL, "24hour_time", FALSE);
- if (safe_strcmp(type, "relative") != 0)
- {
- ab_widget = gnc_date_edit_new(time(NULL), show_time, use24);
- entry = GNC_DATE_EDIT(ab_widget)->date_entry;
- g_signal_connect(G_OBJECT(entry), "changed",
- G_CALLBACK(gnc_option_changed_option_cb), option);
- if (show_time)
+ if (safe_strcmp(type, "relative") != 0)
{
- entry = GNC_DATE_EDIT(ab_widget)->time_entry;
- g_signal_connect(G_OBJECT(entry), "changed",
- G_CALLBACK(gnc_option_changed_option_cb), option);
+ ab_widget = gnc_date_edit_new(time(NULL), show_time, use24);
+ entry = GNC_DATE_EDIT(ab_widget)->date_entry;
+ g_signal_connect(G_OBJECT(entry), "changed",
+ G_CALLBACK(gnc_option_changed_option_cb), option);
+ if (show_time)
+ {
+ entry = GNC_DATE_EDIT(ab_widget)->time_entry;
+ g_signal_connect(G_OBJECT(entry), "changed",
+ G_CALLBACK(gnc_option_changed_option_cb), option);
+ }
}
- }
- if (safe_strcmp(type, "absolute") != 0)
- {
- int i;
- num_values = gnc_option_num_permissible_values(option);
+ if (safe_strcmp(type, "absolute") != 0)
+ {
+ int i;
+ num_values = gnc_option_num_permissible_values(option);
- g_return_val_if_fail(num_values >= 0, NULL);
+ g_return_val_if_fail(num_values >= 0, NULL);
#ifdef GTKCOMBOBOX_TOOLTIPS_WORK
- {
- /* New code for GtkComboBox. Is not used because it is missing
- * the feature of per-item tooltips. Not yet implemented in gtk,
- * see http://bugzilla.gnome.org/show_bug.cgi?id=303717 , see
- * also gnc_option_create_multichoice_widget() below. */
- char *string;
- rel_widget = gtk_combo_box_new_text();
- for (i = 0; i < num_values; i++)
- {
- string = gnc_option_permissible_value_name(option, i);
- gtk_combo_box_append_text(GTK_COMBO_BOX(rel_widget), string);
- g_free(string);
- }
+ {
+ /* New code for GtkComboBox. Is not used because it is missing
+ * the feature of per-item tooltips. Not yet implemented in gtk,
+ * see http://bugzilla.gnome.org/show_bug.cgi?id=303717 , see
+ * also gnc_option_create_multichoice_widget() below. */
+ char *string;
+ rel_widget = gtk_combo_box_new_text();
+ for (i = 0; i < num_values; i++)
+ {
+ string = gnc_option_permissible_value_name(option, i);
+ gtk_combo_box_append_text(GTK_COMBO_BOX(rel_widget), string);
+ g_free(string);
+ }
- g_signal_connect(G_OBJECT(rel_widget), "changed",
- G_CALLBACK(gnc_option_multichoice_cb), option);
- }
+ g_signal_connect(G_OBJECT(rel_widget), "changed",
+ G_CALLBACK(gnc_option_multichoice_cb), option);
+ }
#else
- {
- /* Old 1-8-branch code for a GtkOptionMenu. We use this one
- * because it has a per-item tooltip which the GtkComboBox still
- * doesn't have. - cstim, 2006-02-25 */
- GNCOptionInfo *info;
- char **raw_strings;
- char **raw;
+ {
+ /* Old 1-8-branch code for a GtkOptionMenu. We use this one
+ * because it has a per-item tooltip which the GtkComboBox still
+ * doesn't have. - cstim, 2006-02-25 */
+ GNCOptionInfo *info;
+ char **raw_strings;
+ char **raw;
- info = g_new0(GNCOptionInfo, num_values);
- raw_strings = g_new0(char *, num_values * 2);
- raw = raw_strings;
+ info = g_new0(GNCOptionInfo, num_values);
+ raw_strings = g_new0(char *, num_values * 2);
+ raw = raw_strings;
- for (i = 0; i < num_values; i++)
- {
- *raw = gnc_option_permissible_value_name(option, i);
- info[i].name = *raw; /* (*raw && **raw) ? _(*raw) : ""; */
+ for (i = 0; i < num_values; i++)
+ {
+ *raw = gnc_option_permissible_value_name(option, i);
+ info[i].name = *raw; /* (*raw && **raw) ? _(*raw) : ""; */
- raw++;
+ raw++;
- *raw = gnc_option_permissible_value_description(option, i);
- info[i].tip = *raw; /* (*raw && **raw) ? _(*raw) : ""; */
+ *raw = gnc_option_permissible_value_description(option, i);
+ info[i].tip = *raw; /* (*raw && **raw) ? _(*raw) : ""; */
- if(safe_strcmp(type, "both") == 0)
- {
- info[i].callback = gnc_option_multichoice_cb; /* gnc_option_rd_combo_cb */
- }
- else
- {
- info[i].callback = gnc_option_multichoice_cb;
- }
- info[i].user_data = option;
- raw++;
- }
+ if (safe_strcmp(type, "both") == 0)
+ {
+ info[i].callback = gnc_option_multichoice_cb; /* gnc_option_rd_combo_cb */
+ }
+ else
+ {
+ info[i].callback = gnc_option_multichoice_cb;
+ }
+ info[i].user_data = option;
+ raw++;
+ }
- rel_widget = gnc_build_option_menu(info, num_values);
+ rel_widget = gnc_build_option_menu(info, num_values);
- for (i = 0; i < num_values * 2; i++)
- if (raw_strings[i])
- free(raw_strings[i]);
+ for (i = 0; i < num_values * 2; i++)
+ if (raw_strings[i])
+ free(raw_strings[i]);
- g_free(raw_strings);
- g_free(info);
+ g_free(raw_strings);
+ g_free(info);
+ }
+#endif
}
-#endif
- }
- if(safe_strcmp(type, "absolute") == 0)
- {
- free(type);
- gnc_option_set_widget (option, ab_widget);
- return ab_widget;
- }
- else if (safe_strcmp(type, "relative") == 0)
- {
- gnc_option_set_widget (option, rel_widget);
- free(type);
+ if (safe_strcmp(type, "absolute") == 0)
+ {
+ free(type);
+ gnc_option_set_widget (option, ab_widget);
+ return ab_widget;
+ }
+ else if (safe_strcmp(type, "relative") == 0)
+ {
+ gnc_option_set_widget (option, rel_widget);
+ free(type);
- return rel_widget;
- }
- else if (safe_strcmp(type, "both") == 0)
- {
- box = gtk_hbox_new(FALSE, 5);
+ return rel_widget;
+ }
+ else if (safe_strcmp(type, "both") == 0)
+ {
+ box = gtk_hbox_new(FALSE, 5);
- ab_button = gtk_radio_button_new(NULL);
- g_signal_connect(G_OBJECT(ab_button), "toggled",
- G_CALLBACK(gnc_rd_option_ab_set_cb), option);
+ ab_button = gtk_radio_button_new(NULL);
+ g_signal_connect(G_OBJECT(ab_button), "toggled",
+ G_CALLBACK(gnc_rd_option_ab_set_cb), option);
- rel_button = gtk_radio_button_new_from_widget(GTK_RADIO_BUTTON(ab_button));
- g_signal_connect(G_OBJECT(rel_button), "toggled",
- G_CALLBACK(gnc_rd_option_rel_set_cb), option);
+ rel_button = gtk_radio_button_new_from_widget(GTK_RADIO_BUTTON(ab_button));
+ g_signal_connect(G_OBJECT(rel_button), "toggled",
+ G_CALLBACK(gnc_rd_option_rel_set_cb), option);
- gtk_box_pack_start(GTK_BOX(box), ab_button, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(box), ab_widget, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(box), rel_button, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(box), rel_widget, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(box), ab_button, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(box), ab_widget, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(box), rel_button, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(box), rel_widget, FALSE, FALSE, 0);
- free(type);
+ free(type);
- gnc_option_set_widget (option, box);
+ gnc_option_set_widget (option, box);
- return box;
- }
- else /* can't happen */
- {
- return NULL;
- }
+ return box;
+ }
+ else /* can't happen */
+ {
+ return NULL;
+ }
}
static GtkWidget *
@@ -645,450 +651,455 @@
static GtkWidget *
gnc_option_create_multichoice_widget(GNCOption *option, GtkTooltips *tooltips)
{
- GtkWidget *widget;
- int num_values;
- int i;
+ GtkWidget *widget;
+ int num_values;
+ int i;
- num_values = gnc_option_num_permissible_values(option);
+ num_values = gnc_option_num_permissible_values(option);
- g_return_val_if_fail(num_values >= 0, NULL);
+ g_return_val_if_fail(num_values >= 0, NULL);
#ifndef GTKCOMBOBOX_TOOLTIPS_WORK
- {
- /* Old 1-8-branch code for a GtkOptionMenu. We use this one
- because it has a per-item tooltip which the GtkComboBox still
- doesn't have. - cstim, 2006-02-25 */
- GNCOptionInfo *info;
- char **raw_strings;
- char **raw;
+ {
+ /* Old 1-8-branch code for a GtkOptionMenu. We use this one
+ because it has a per-item tooltip which the GtkComboBox still
+ doesn't have. - cstim, 2006-02-25 */
+ GNCOptionInfo *info;
+ char **raw_strings;
+ char **raw;
- info = g_new0(GNCOptionInfo, num_values);
- raw_strings = g_new0(char *, num_values * 2);
- raw = raw_strings;
+ info = g_new0(GNCOptionInfo, num_values);
+ raw_strings = g_new0(char *, num_values * 2);
+ raw = raw_strings;
- for (i = 0; i < num_values; i++)
- {
- *raw = gnc_option_permissible_value_name(option, i);
- info[i].name = (*raw && **raw) ? _(*raw) : "";
+ for (i = 0; i < num_values; i++)
+ {
+ *raw = gnc_option_permissible_value_name(option, i);
+ info[i].name = (*raw && **raw) ? _(*raw) : "";
- raw++;
+ raw++;
- *raw = gnc_option_permissible_value_description(option, i);
- info[i].tip = (*raw && **raw) ? _(*raw) : "";
+ *raw = gnc_option_permissible_value_description(option, i);
+ info[i].tip = (*raw && **raw) ? _(*raw) : "";
- info[i].callback = gnc_option_multichoice_cb;
- info[i].user_data = option;
- raw++;
- }
+ info[i].callback = gnc_option_multichoice_cb;
+ info[i].user_data = option;
+ raw++;
+ }
- widget = gnc_build_option_menu(info, num_values);
+ widget = gnc_build_option_menu(info, num_values);
- for (i = 0; i < num_values * 2; i++)
- if (raw_strings[i])
- free(raw_strings[i]);
+ for (i = 0; i < num_values * 2; i++)
+ if (raw_strings[i])
+ free(raw_strings[i]);
- g_free(raw_strings);
- g_free(info);
- }
+ g_free(raw_strings);
+ g_free(info);
+ }
#else
- {
+ {
- /* New code for GtkComboBox. Is still unused because it is missing
- the feature of per-item tooltips. Not yet implemented in gtk,
- see http://bugzilla.gnome.org/show_bug.cgi?id=303717 */
- char *itemstring;
- /* char *description; */
- widget = gtk_combo_box_new_text();
- for (i = 0; i < num_values; i++) {
- itemstring = gnc_option_permissible_value_name(option, i);
- /* description = gnc_option_permissible_value_description(option, i); */
- gtk_combo_box_append_text(GTK_COMBO_BOX(widget),
- (itemstring && *itemstring) ? _(itemstring) : "");
- /*, (description && *description) ? _(description) : "" */
- /* Maybe the per-item tooltip will simply be added as such an
- additional argument as shown above, but we'll see. */
- if (itemstring)
- g_free(itemstring);
- /* if (description) g_free(description); */
+ /* New code for GtkComboBox. Is still unused because it is missing
+ the feature of per-item tooltips. Not yet implemented in gtk,
+ see http://bugzilla.gnome.org/show_bug.cgi?id=303717 */
+ char *itemstring;
+ /* char *description; */
+ widget = gtk_combo_box_new_text();
+ for (i = 0; i < num_values; i++)
+ {
+ itemstring = gnc_option_permissible_value_name(option, i);
+ /* description = gnc_option_permissible_value_description(option, i); */
+ gtk_combo_box_append_text(GTK_COMBO_BOX(widget),
+ (itemstring && *itemstring) ? _(itemstring) : "");
+ /*, (description && *description) ? _(description) : "" */
+ /* Maybe the per-item tooltip will simply be added as such an
+ additional argument as shown above, but we'll see. */
+ if (itemstring)
+ g_free(itemstring);
+ /* if (description) g_free(description); */
+ }
+ g_signal_connect(G_OBJECT(widget), "changed",
+ G_CALLBACK(gnc_option_multichoice_cb), option);
}
- g_signal_connect(G_OBJECT(widget), "changed",
- G_CALLBACK(gnc_option_multichoice_cb), option);
- }
#endif
- return widget;
+ return widget;
}
static void
radiobutton_destroy_cb (GtkObject *obj, gpointer data)
{
- GtkTooltips *tips = data;
+ GtkTooltips *tips = data;
- g_object_unref (tips);
+ g_object_unref (tips);
}
static GtkWidget *
gnc_option_create_radiobutton_widget(char *name, GNCOption *option)
{
- GtkTooltips *tooltips;
- GtkWidget *frame, *box;
- GtkWidget *widget = NULL;
- int num_values;
- char *label;
- char *tip;
- int i;
+ GtkTooltips *tooltips;
+ GtkWidget *frame, *box;
+ GtkWidget *widget = NULL;
+ int num_values;
+ char *label;
+ char *tip;
+ int i;
- num_values = gnc_option_num_permissible_values(option);
+ num_values = gnc_option_num_permissible_values(option);
- g_return_val_if_fail(num_values >= 0, NULL);
+ g_return_val_if_fail(num_values >= 0, NULL);
- /* Create our button frame */
- frame = gtk_frame_new (name);
+ /* Create our button frame */
+ frame = gtk_frame_new (name);
- /* Create the button box */
- box = gtk_hbox_new (FALSE, 5);
- gtk_container_add (GTK_CONTAINER (frame), box);
+ /* Create the button box */
+ box = gtk_hbox_new (FALSE, 5);
+ gtk_container_add (GTK_CONTAINER (frame), box);
- /* Create the tooltips */
- tooltips = gtk_tooltips_new ();
- g_object_ref_sink(tooltips);
+ /* Create the tooltips */
+ tooltips = gtk_tooltips_new ();
+ g_object_ref_sink(tooltips);
- /* Iterate over the options and create a radio button for each one */
- for (i = 0; i < num_values; i++)
- {
- label = gnc_option_permissible_value_name(option, i);
- tip = gnc_option_permissible_value_description(option, i);
+ /* Iterate over the options and create a radio button for each one */
+ for (i = 0; i < num_values; i++)
+ {
+ label = gnc_option_permissible_value_name(option, i);
+ tip = gnc_option_permissible_value_description(option, i);
- widget =
- gtk_radio_button_new_with_label_from_widget (widget ?
- GTK_RADIO_BUTTON (widget) :
- NULL,
- label && *label ? _(label) : "");
- g_object_set_data (G_OBJECT (widget), "gnc_radiobutton_index",
- GINT_TO_POINTER (i));
- gtk_tooltips_set_tip(tooltips, widget, tip && *tip ? _(tip) : "", NULL);
- g_signal_connect(G_OBJECT(widget), "toggled",
- G_CALLBACK(gnc_option_radiobutton_cb), option);
- gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 0);
+ widget =
+ gtk_radio_button_new_with_label_from_widget (widget ?
+ GTK_RADIO_BUTTON (widget) :
+ NULL,
+ label && *label ? _(label) : "");
+ g_object_set_data (G_OBJECT (widget), "gnc_radiobutton_index",
+ GINT_TO_POINTER (i));
+ gtk_tooltips_set_tip(tooltips, widget, tip && *tip ? _(tip) : "", NULL);
+ g_signal_connect(G_OBJECT(widget), "toggled",
+ G_CALLBACK(gnc_option_radiobutton_cb), option);
+ gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 0);
- if (label)
- free (label);
- if (tip)
- free (tip);
- }
+ if (label)
+ free (label);
+ if (tip)
+ free (tip);
+ }
- g_signal_connect (G_OBJECT (frame), "destroy",
- G_CALLBACK (radiobutton_destroy_cb), tooltips);
+ g_signal_connect (G_OBJECT (frame), "destroy",
+ G_CALLBACK (radiobutton_destroy_cb), tooltips);
- return frame;
+ return frame;
}
static void
gnc_option_account_cb(GtkTreeSelection *selection, gpointer data)
{
- GNCOption *option = data;
- GtkTreeView *tree_view;
+ GNCOption *option = data;
+ GtkTreeView *tree_view;
- tree_view = gtk_tree_selection_get_tree_view(selection);
+ tree_view = gtk_tree_selection_get_tree_view(selection);
- gnc_option_changed_widget_cb(GTK_WIDGET(tree_view), option);
+ gnc_option_changed_widget_cb(GTK_WIDGET(tree_view), option);
}
static void
gnc_option_account_select_all_cb(GtkWidget *widget, gpointer data)
{
- GNCOption *option = data;
- GncTreeViewAccount *tree_view;
- GtkTreeSelection *selection;
+ GNCOption *option = data;
+ GncTreeViewAccount *tree_view;
+ GtkTreeSelection *selection;
- tree_view = GNC_TREE_VIEW_ACCOUNT(gnc_option_get_widget (option));
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
- gtk_tree_selection_select_all(selection);
- gnc_option_changed_widget_cb(widget, option);
+ tree_view = GNC_TREE_VIEW_ACCOUNT(gnc_option_get_widget (option));
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
+ gtk_tree_selection_select_all(selection);
+ gnc_option_changed_widget_cb(widget, option);
}
static void
gnc_option_account_clear_all_cb(GtkWidget *widget, gpointer data)
{
- GNCOption *option = data;
- GncTreeViewAccount *tree_view;
- GtkTreeSelection *selection;
+ GNCOption *option = data;
+ GncTreeViewAccount *tree_view;
+ GtkTreeSelection *selection;
- tree_view = GNC_TREE_VIEW_ACCOUNT(gnc_option_get_widget (option));
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
- gtk_tree_selection_unselect_all(selection);
- gnc_option_changed_widget_cb(widget, option);
+ tree_view = GNC_TREE_VIEW_ACCOUNT(gnc_option_get_widget (option));
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
+ gtk_tree_selection_unselect_all(selection);
+ gnc_option_changed_widget_cb(widget, option);
}
static void
gnc_option_account_select_children_cb(GtkWidget *widget, gpointer data)
{
- GNCOption *option = data;
- GncTreeViewAccount *tree_view;
- Account *account;
+ GNCOption *option = data;
+ GncTreeViewAccount *tree_view;
+ Account *account;
- tree_view = GNC_TREE_VIEW_ACCOUNT(gnc_option_get_widget (option));
- account = gnc_tree_view_account_get_cursor_account(tree_view);
- if (!account)
- return;
+ tree_view = GNC_TREE_VIEW_ACCOUNT(gnc_option_get_widget (option));
+ account = gnc_tree_view_account_get_cursor_account(tree_view);
+ if (!account)
+ return;
- gnc_tree_view_account_select_subaccounts(tree_view, account);
+ gnc_tree_view_account_select_subaccounts(tree_view, account);
}
static GtkWidget *
gnc_option_create_account_widget(GNCOption *option, char *name, GtkTooltips *tooltips)
{
- gboolean multiple_selection;
- GtkWidget *scroll_win;
- GtkWidget *button;
- GtkWidget *frame;
- GtkWidget *tree;
- GtkWidget *vbox;
- GtkWidget *bbox;
- GList *acct_type_list;
- GtkTreeSelection *selection;
+ gboolean multiple_selection;
+ GtkWidget *scroll_win;
+ GtkWidget *button;
+ GtkWidget *frame;
+ GtkWidget *tree;
+ GtkWidget *vbox;
+ GtkWidget *bbox;
+ GList *acct_type_list;
+ GtkTreeSelection *selection;
- multiple_selection = gnc_option_multiple_selection(option);
- acct_type_list = gnc_option_get_account_type_list(option);
+ multiple_selection = gnc_option_multiple_selection(option);
+ acct_type_list = gnc_option_get_account_type_list(option);
- frame = gtk_frame_new(name);
+ frame = gtk_frame_new(name);
- vbox = gtk_vbox_new(FALSE, 0);
- gtk_container_add(GTK_CONTAINER(frame), vbox);
+ vbox = gtk_vbox_new(FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(frame), vbox);
- tree = GTK_WIDGET(gnc_tree_view_account_new (FALSE));
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(tree), FALSE);
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(tree));
- if (multiple_selection)
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
- else
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
+ tree = GTK_WIDGET(gnc_tree_view_account_new (FALSE));
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(tree), FALSE);
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(tree));
+ if (multiple_selection)
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+ else
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
- if (acct_type_list) {
- GList *node;
- AccountViewInfo avi;
- int i;
+ if (acct_type_list)
+ {
+ GList *node;
+ AccountViewInfo avi;
+ int i;
- gnc_tree_view_account_get_view_info (GNC_TREE_VIEW_ACCOUNT (tree), &avi);
+ gnc_tree_view_account_get_view_info (GNC_TREE_VIEW_ACCOUNT (tree), &avi);
- for (i = 0; i < NUM_ACCOUNT_TYPES; i++)
- avi.include_type[i] = FALSE;
- avi.show_hidden = FALSE;
+ for (i = 0; i < NUM_ACCOUNT_TYPES; i++)
+ avi.include_type[i] = FALSE;
+ avi.show_hidden = FALSE;
- for (node = acct_type_list; node; node = node->next) {
- GNCAccountType type = GPOINTER_TO_INT (node->data);
- avi.include_type[type] = TRUE;
+ for (node = acct_type_list; node; node = node->next)
+ {
+ GNCAccountType type = GPOINTER_TO_INT (node->data);
+ avi.include_type[type] = TRUE;
+ }
+
+ gnc_tree_view_account_set_view_info (GNC_TREE_VIEW_ACCOUNT (tree), &avi);
+ g_list_free (acct_type_list);
}
+ else
+ {
+ AccountViewInfo avi;
+ int i;
- gnc_tree_view_account_set_view_info (GNC_TREE_VIEW_ACCOUNT (tree), &avi);
- g_list_free (acct_type_list);
- } else {
- AccountViewInfo avi;
- int i;
+ gnc_tree_view_account_get_view_info (GNC_TREE_VIEW_ACCOUNT (tree), &avi);
- gnc_tree_view_account_get_view_info (GNC_TREE_VIEW_ACCOUNT (tree), &avi);
+ for (i = 0; i < NUM_ACCOUNT_TYPES; i++)
+ avi.include_type[i] = TRUE;
+ avi.show_hidden = FALSE;
+ gnc_tree_view_account_set_view_info (GNC_TREE_VIEW_ACCOUNT (tree), &avi);
+ }
- for (i = 0; i < NUM_ACCOUNT_TYPES; i++)
- avi.include_type[i] = TRUE;
- avi.show_hidden = FALSE;
- gnc_tree_view_account_set_view_info (GNC_TREE_VIEW_ACCOUNT (tree), &avi);
- }
+ scroll_win = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
- scroll_win = gtk_scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
+ gtk_box_pack_start(GTK_BOX(vbox), scroll_win, TRUE, TRUE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(scroll_win), 5);
+ gtk_container_add(GTK_CONTAINER(scroll_win), tree);
- gtk_box_pack_start(GTK_BOX(vbox), scroll_win, TRUE, TRUE, 0);
- gtk_container_set_border_width(GTK_CONTAINER(scroll_win), 5);
- gtk_container_add(GTK_CONTAINER(scroll_win), tree);
+ bbox = gtk_hbutton_box_new();
+ gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_SPREAD);
+ gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 10);
- bbox = gtk_hbutton_box_new();
- gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_SPREAD);
- gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 10);
+ if (multiple_selection)
+ {
+ button = gtk_button_new_with_label(_("Select All"));
+ gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
+ gtk_tooltips_set_tip(tooltips, button, _("Select all accounts."), NULL);
- if (multiple_selection)
- {
- button = gtk_button_new_with_label(_("Select All"));
- gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
- gtk_tooltips_set_tip(tooltips, button, _("Select all accounts."), NULL);
+ g_signal_connect(G_OBJECT(button), "clicked",
+ G_CALLBACK(gnc_option_account_select_all_cb), option);
- g_signal_connect(G_OBJECT(button), "clicked",
- G_CALLBACK(gnc_option_account_select_all_cb), option);
+ button = gtk_button_new_with_label(_("Clear All"));
+ gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
+ gtk_tooltips_set_tip(tooltips, button, _("Clear the selection and unselect all accounts."), NULL);
- button = gtk_button_new_with_label(_("Clear All"));
- gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
- gtk_tooltips_set_tip(tooltips, button, _("Clear the selection and unselect all accounts."), NULL);
+ g_signal_connect(G_OBJECT(button), "clicked",
+ G_CALLBACK(gnc_option_account_clear_all_cb), option);
- g_signal_connect(G_OBJECT(button), "clicked",
- G_CALLBACK(gnc_option_account_clear_all_cb), option);
+ button = gtk_button_new_with_label(_("Select Children"));
+ gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
+ gtk_tooltips_set_tip(tooltips, button, _("Select all descendents of selected account."), NULL);
- button = gtk_button_new_with_label(_("Select Children"));
+ g_signal_connect(G_OBJECT(button), "clicked",
+ G_CALLBACK(gnc_option_account_select_children_cb), option);
+ }
+
+ button = gtk_button_new_with_label(_("Select Default"));
gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
- gtk_tooltips_set_tip(tooltips, button, _("Select all descendents of selected account."), NULL);
+ gtk_tooltips_set_tip(tooltips, button, _("Select the default account selection."), NULL);
g_signal_connect(G_OBJECT(button), "clicked",
- G_CALLBACK(gnc_option_account_select_children_cb), option);
- }
+ G_CALLBACK(gnc_option_default_cb), option);
- button = gtk_button_new_with_label(_("Select Default"));
- gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
- gtk_tooltips_set_tip(tooltips, button, _("Select the default account selection."), NULL);
+ if (multiple_selection)
+ {
+ /* Put the "Show hidden" checkbox on a separate line since the 4 buttons make
+ the dialog too wide. */
+ bbox = gtk_hbutton_box_new();
+ gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_START);
+ gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
+ }
- g_signal_connect(G_OBJECT(button), "clicked",
- G_CALLBACK(gnc_option_default_cb), option);
+ button = gtk_check_button_new_with_label(_("Show Hidden Accounts"));
+ gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
+ gtk_tooltips_set_tip(tooltips, button, _("Show accounts that have been marked hidden."), NULL);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);
+ g_signal_connect(G_OBJECT(button), "toggled",
+ G_CALLBACK(gnc_option_show_hidden_toggled_cb), option);
- if (multiple_selection)
- {
- /* Put the "Show hidden" checkbox on a separate line since the 4 buttons make
- the dialog too wide. */
- bbox = gtk_hbutton_box_new();
- gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_START);
- gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
- }
+ gnc_option_set_widget (option, tree);
- button = gtk_check_button_new_with_label(_("Show Hidden Accounts"));
- gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
- gtk_tooltips_set_tip(tooltips, button, _("Show accounts that have been marked hidden."), NULL);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);
- g_signal_connect(G_OBJECT(button), "toggled",
- G_CALLBACK(gnc_option_show_hidden_toggled_cb), option);
-
- gnc_option_set_widget (option, tree);
-
- return frame;
+ return frame;
}
static void
gnc_option_list_changed_cb(GtkTreeSelection *selection,
- GNCOption *option)
+ GNCOption *option)
{
- GtkTreeView *view;
+ GtkTreeView *view;
- view = gtk_tree_selection_get_tree_view(selection);
- gnc_option_changed_widget_cb(GTK_WIDGET(view), option);
+ view = gtk_tree_selection_get_tree_view(selection);
+ gnc_option_changed_widget_cb(GTK_WIDGET(view), option);
}
static void
gnc_option_list_select_all_cb(GtkWidget *widget, gpointer data)
{
- GNCOption *option = data;
- GtkTreeView *view;
- GtkTreeSelection *selection;
+ GNCOption *option = data;
+ GtkTreeView *view;
+ GtkTreeSelection *selection;
- view = GTK_TREE_VIEW(gnc_option_get_widget (option));
- selection = gtk_tree_view_get_selection(view);
- gtk_tree_selection_select_all(selection);
- gnc_option_changed_widget_cb(GTK_WIDGET(view), option);
+ view = GTK_TREE_VIEW(gnc_option_get_widget (option));
+ selection = gtk_tree_view_get_selection(view);
+ gtk_tree_selection_select_all(selection);
+ gnc_option_changed_widget_cb(GTK_WIDGET(view), option);
}
static void
gnc_option_list_clear_all_cb(GtkWidget *widget, gpointer data)
{
- GNCOption *option = data;
- GtkTreeView *view;
- GtkTreeSelection *selection;
+ GNCOption *option = data;
+ GtkTreeView *view;
+ GtkTreeSelection *selection;
- view = GTK_TREE_VIEW(gnc_option_get_widget (option));
- selection = gtk_tree_view_get_selection(view);
- gtk_tree_selection_unselect_all(selection);
- gnc_option_changed_widget_cb(GTK_WIDGET(view), option);
+ view = GTK_TREE_VIEW(gnc_option_get_widget (option));
+ selection = gtk_tree_view_get_selection(view);
+ gtk_tree_selection_unselect_all(selection);
+ gnc_option_changed_widget_cb(GTK_WIDGET(view), option);
}
static GtkWidget *
gnc_option_create_list_widget(GNCOption *option, char *name, GtkTooltips *tooltips)
{
- GtkListStore *store;
- GtkTreeView *view;
- GtkTreeIter iter;
- GtkTreeViewColumn *column;
- GtkCellRenderer *renderer;
- GtkTreeSelection *selection;
+ GtkListStore *store;
+ GtkTreeView *view;
+ GtkTreeIter iter;
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+ GtkTreeSelection *selection;
- GtkWidget *button;
- GtkWidget *frame;
- GtkWidget *hbox;
- GtkWidget *bbox;
- gint num_values;
- gint i;
+ GtkWidget *button;
+ GtkWidget *frame;
+ GtkWidget *hbox;
+ GtkWidget *bbox;
+ gint num_values;
+ gint i;
- frame = gtk_frame_new(name);
- hbox = gtk_hbox_new(FALSE, 0);
- gtk_container_add(GTK_CONTAINER(frame), hbox);
+ frame = gtk_frame_new(name);
+ hbox = gtk_hbox_new(FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(frame), hbox);
- store = gtk_list_store_new(1, G_TYPE_STRING);
- view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)));
- g_object_unref(store);
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes("", renderer,
- "text", 0,
- NULL);
- gtk_tree_view_append_column(view, column);
- gtk_tree_view_set_headers_visible(view, FALSE);
+ store = gtk_list_store_new(1, G_TYPE_STRING);
+ view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)));
+ g_object_unref(store);
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes("", renderer,
+ "text", 0,
+ NULL);
+ gtk_tree_view_append_column(view, column);
+ gtk_tree_view_set_headers_visible(view, FALSE);
- num_values = gnc_option_num_permissible_values(option);
- for (i = 0; i < num_values; i++)
- {
- gchar *raw_string, *string;
+ num_values = gnc_option_num_permissible_values(option);
+ for (i = 0; i < num_values; i++)
+ {
+ gchar *raw_string, *string;
- raw_string = gnc_option_permissible_value_name(option, i);
- string = (raw_string && *raw_string) ? _(raw_string) : "";
- gtk_list_store_append(store, &iter);
- gtk_list_store_set(store, &iter,
- 0, string ? string : "",
- -1);
- g_free(raw_string);
- }
+ raw_string = gnc_option_permissible_value_name(option, i);
+ string = (raw_string && *raw_string) ? _(raw_string) : "";
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ 0, string ? string : "",
+ -1);
+ g_free(raw_string);
+ }
- gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(view), FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(view), FALSE, FALSE, 0);
- selection = gtk_tree_view_get_selection(view);
- gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
- g_signal_connect(selection, "changed",
- G_CALLBACK(gnc_option_list_changed_cb), option);
+ selection = gtk_tree_view_get_selection(view);
+ gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
+ g_signal_connect(selection, "changed",
+ G_CALLBACK(gnc_option_list_changed_cb), option);
- bbox = gtk_vbutton_box_new();
- gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_SPREAD);
- gtk_box_pack_start(GTK_BOX(hbox), bbox, FALSE, FALSE, 10);
+ bbox = gtk_vbutton_box_new();
+ gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_SPREAD);
+ gtk_box_pack_start(GTK_BOX(hbox), bbox, FALSE, FALSE, 10);
- button = gtk_button_new_with_label(_("Select All"));
- gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
- gtk_tooltips_set_tip(tooltips, button, _("Select all entries."), NULL);
+ button = gtk_button_new_with_label(_("Select All"));
+ gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
+ gtk_tooltips_set_tip(tooltips, button, _("Select all entries."), NULL);
- g_signal_connect(G_OBJECT(button), "clicked",
- G_CALLBACK(gnc_option_list_select_all_cb), option);
+ g_signal_connect(G_OBJECT(button), "clicked",
+ G_CALLBACK(gnc_option_list_select_all_cb), option);
- button = gtk_button_new_with_label(_("Clear All"));
- gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
- gtk_tooltips_set_tip(tooltips, button, _("Clear the selection and unselect all entries."), NULL);
+ button = gtk_button_new_with_label(_("Clear All"));
+ gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
+ gtk_tooltips_set_tip(tooltips, button, _("Clear the selection and unselect all entries."), NULL);
- g_signal_connect(G_OBJECT(button), "clicked",
- G_CALLBACK(gnc_option_list_clear_all_cb), option);
+ g_signal_connect(G_OBJECT(button), "clicked",
+ G_CALLBACK(gnc_option_list_clear_all_cb), option);
- button = gtk_button_new_with_label(_("Select Default"));
- gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
- gtk_tooltips_set_tip(tooltips, button, _("Select the default selection."), NULL);
+ button = gtk_button_new_with_label(_("Select Default"));
+ gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
+ gtk_tooltips_set_tip(tooltips, button, _("Select the default selection."), NULL);
- g_signal_connect(G_OBJECT(button), "clicked",
- G_CALLBACK(gnc_option_default_cb), option);
+ g_signal_connect(G_OBJECT(button), "clicked",
+ G_CALLBACK(gnc_option_default_cb), option);
- gnc_option_set_widget (option, GTK_WIDGET(view));
+ gnc_option_set_widget (option, GTK_WIDGET(view));
- return frame;
+ return frame;
}
static void
gnc_option_color_changed_cb(GtkColorButton *color_button, GNCOption *option)
{
- gnc_option_changed_widget_cb(GTK_WIDGET(color_button), option);
+ gnc_option_changed_widget_cb(GTK_WIDGET(color_button), option);
}
static void
gnc_option_font_changed_cb(GtkFontButton *font_button, GNCOption *option)
{
- gnc_option_changed_widget_cb(GTK_WIDGET(font_button), option);
+ gnc_option_changed_widget_cb(GTK_WIDGET(font_button), option);
}
static void
@@ -1096,67 +1107,69 @@
GtkBox *page_box,
GtkTooltips *tooltips)
{
- GtkWidget *enclosing = NULL;
- GtkWidget *value = NULL;
- gboolean packed = FALSE;
- char *raw_name, *raw_documentation;
- char *name, *documentation;
- char *type;
- GNCOptionDef_t *option_def;
+ GtkWidget *enclosing = NULL;
+ GtkWidget *value = NULL;
+ gboolean packed = FALSE;
+ char *raw_name, *raw_documentation;
+ char *name, *documentation;
+ char *type;
+ GNCOptionDef_t *option_def;
- ENTER("option %p(%s), box %p, tips %p",
- option, gnc_option_name(option), page_box, tooltips);
- type = gnc_option_type(option);
- if (type == NULL) {
- LEAVE("bad type");
- return;
- }
+ ENTER("option %p(%s), box %p, tips %p",
+ option, gnc_option_name(option), page_box, tooltips);
+ type = gnc_option_type(option);
+ if (type == NULL)
+ {
+ LEAVE("bad type");
+ return;
+ }
- raw_name = gnc_option_name(option);
- if (raw_name && *raw_name)
- name = _(raw_name);
- else
- name = NULL;
+ raw_name = gnc_option_name(option);
+ if (raw_name && *raw_name)
+ name = _(raw_name);
+ else
+ name = NULL;
- raw_documentation = gnc_option_documentation(option);
- if (raw_documentation && *raw_documentation)
- documentation = _(raw_documentation);
- else
- documentation = NULL;
+ raw_documentation = gnc_option_documentation(option);
+ if (raw_documentation && *raw_documentation)
+ documentation = _(raw_documentation);
+ else
+ documentation = NULL;
- option_def = gnc_options_ui_get_option (type);
- if (option_def && option_def->set_widget)
- {
- value = option_def->set_widget (option, page_box,
- tooltips, name, documentation,
- /* Return values */
- &enclosing, &packed);
- }
- else
- {
- PERR("Unknown option type. Ignoring option \"%s\".\n", name);
- }
+ option_def = gnc_options_ui_get_option (type);
+ if (option_def && option_def->set_widget)
+ {
+ value = option_def->set_widget (option, page_box,
+ tooltips, name, documentation,
+ /* Return values */
+ &enclosing, &packed);
+ }
+ else
+ {
+ PERR("Unknown option type. Ignoring option \"%s\".\n", name);
+ }
- if (!packed && (enclosing != NULL)) {
- /* Pack option widget into an extra eventbox because otherwise the
- "documentation" tooltip is not displayed. */
- GtkWidget *eventbox = gtk_event_box_new();
+ if (!packed && (enclosing != NULL))
+ {
+ /* Pack option widget into an extra eventbox because otherwise the
+ "documentation" tooltip is not displayed. */
+ GtkWidget *eventbox = gtk_event_box_new();
- gtk_container_add (GTK_CONTAINER (eventbox), enclosing);
- gtk_box_pack_start (page_box, eventbox, FALSE, FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (eventbox), enclosing);
+ gtk_box_pack_start (page_box, eventbox, FALSE, FALSE, 0);
- gtk_tooltips_set_tip (tooltips, eventbox, documentation, NULL);
- }
+ gtk_tooltips_set_tip (tooltips, eventbox, documentation, NULL);
+ }
- if (value != NULL)
- gtk_tooltips_set_tip(tooltips, value, documentation, NULL);
+ if (value != NULL)
+ gtk_tooltips_set_tip(tooltips, value, documentation, NULL);
- if (raw_name != NULL)
- free(raw_name);
- if (raw_documentation != NULL)
- free(raw_documentation);
- free(type);
- LEAVE(" ");
+ if (raw_name != NULL)
+ free(raw_name);
+ if (raw_documentation != NULL)
+ free(raw_documentation);
+ free(type);
+ LEAVE(" ");
}
static void
@@ -1164,105 +1177,108 @@
GNCOption *option,
GtkTooltips *tooltips)
{
- gnc_option_set_ui_widget(option, GTK_BOX(page), tooltips);
+ gnc_option_set_ui_widget(option, GTK_BOX(page), tooltips);
}
static gint
gnc_options_dialog_append_page(GNCOptionWin * propertybox,
GNCOptionSection *section,
- GtkTooltips *tooltips)
+ GtkTooltips *tooltips)
{
- GNCOption *option;
- GtkWidget *page_label;
- GtkWidget *options_box;
- GtkWidget *page_content_box;
- GtkWidget* notebook_page;
- GtkWidget *reset_button;
- GtkWidget *listitem = NULL;
- GtkWidget *buttonbox;
- gint num_options;
- const char *name;
- gint i, page_count, name_offset;
- gboolean advanced;
+ GNCOption *option;
+ GtkWidget *page_label;
+ GtkWidget *options_box;
+ GtkWidget *page_content_box;
+ GtkWidget* notebook_page;
+ GtkWidget *reset_button;
+ GtkWidget *listitem = NULL;
+ GtkWidget *buttonbox;
+ gint num_options;
+ const char *name;
+ gint i, page_count, name_offset;
+ gboolean advanced;
- name = gnc_option_section_name(section);
- if (!name)
- return -1;
+ name = gnc_option_section_name(section);
+ if (!name)
+ return -1;
- if (strncmp(name, "__", 2) == 0)
- return -1;
- advanced = (strncmp(name, "_+", 2) == 0);
- name_offset = (advanced) ? 2 : 0;
- page_label = gtk_label_new(_(name + name_offset));
- gtk_widget_show(page_label);
+ if (strncmp(name, "__", 2) == 0)
+ return -1;
+ advanced = (strncmp(name, "_+", 2) == 0);
+ name_offset = (advanced) ? 2 : 0;
+ page_label = gtk_label_new(_(name + name_offset));
+ gtk_widget_show(page_label);
- /* Build this options page */
- page_content_box = gtk_vbox_new(FALSE, 2);
- gtk_container_set_border_width(GTK_CONTAINER(page_content_box), 12);
+ /* Build this options page */
+ page_content_box = gtk_vbox_new(FALSE, 2);
+ gtk_container_set_border_width(GTK_CONTAINER(page_content_box), 12);
- /* Build space for the content - the options box */
- options_box = gtk_vbox_new(FALSE, 5);
- gtk_container_set_border_width(GTK_CONTAINER(options_box), 0);
- gtk_box_pack_start(GTK_BOX(page_content_box), options_box, TRUE, TRUE, 0);
+ /* Build space for the content - the options box */
+ options_box = gtk_vbox_new(FALSE, 5);
+ gtk_container_set_border_width(GTK_CONTAINER(options_box), 0);
+ gtk_box_pack_start(GTK_BOX(page_content_box), options_box, TRUE, TRUE, 0);
- /* Create all the options */
- num_options = gnc_option_section_num_options(section);
- for (i = 0; i < num_options; i++)
- {
- option = gnc_get_option_section_option(section, i);
- gnc_options_dialog_add_option(options_box, option,
- propertybox->tips);
- }
+ /* Create all the options */
+ num_options = gnc_option_section_num_options(section);
+ for (i = 0; i < num_options; i++)
+ {
+ option = gnc_get_option_section_option(section, i);
+ gnc_options_dialog_add_option(options_box, option,
+ propertybox->tips);
+ }
- /* Add a button box at the bottom of the page */
- buttonbox = gtk_hbutton_box_new();
- gtk_button_box_set_layout (GTK_BUTTON_BOX (buttonbox),
- GTK_BUTTONBOX_EDGE);
- gtk_container_set_border_width(GTK_CONTAINER (buttonbox), 5);
- gtk_box_pack_end(GTK_BOX(page_content_box), buttonbox, FALSE, FALSE, 0);
+ /* Add a button box at the bottom of the page */
+ buttonbox = gtk_hbutton_box_new();
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (buttonbox),
+ GTK_BUTTONBOX_EDGE);
+ gtk_container_set_border_width(GTK_CONTAINER (buttonbox), 5);
+ gtk_box_pack_end(GTK_BOX(page_content_box), buttonbox, FALSE, FALSE, 0);
- /* The reset button on each option page */
- reset_button = gtk_button_new_with_label (_("Defaults"));
- gtk_tooltips_set_tip(tooltips, reset_button,
- _("Reset all values to their defaults."), NULL);
+ /* The reset button on each option page */
+ reset_button = gtk_button_new_with_label (_("Defaults"));
+ gtk_tooltips_set_tip(tooltips, reset_button,
+ _("Reset all values to their defaults."), NULL);
- g_signal_connect(G_OBJECT(reset_button), "clicked",
- G_CALLBACK(gnc_options_dialog_reset_cb), propertybox);
- g_object_set_data(G_OBJECT(reset_button), "section", section);
- gtk_box_pack_end(GTK_BOX(buttonbox), reset_button, FALSE, FALSE, 0);
- gtk_widget_show_all(page_content_box);
- gtk_notebook_append_page(GTK_NOTEBOOK(propertybox->notebook),
- page_content_box, page_label);
+ g_signal_connect(G_OBJECT(reset_button), "clicked",
+ G_CALLBACK(gnc_options_dialog_reset_cb), propertybox);
+ g_object_set_data(G_OBJECT(reset_button), "section", section);
+ gtk_box_pack_end(GTK_BOX(buttonbox), reset_button, FALSE, FALSE, 0);
+ gtk_widget_show_all(page_content_box);
+ gtk_notebook_append_page(GTK_NOTEBOOK(propertybox->notebook),
+ page_content_box, page_label);
- /* Switch to selection from a list if the page count threshhold is reached */
- page_count = gtk_notebook_page_num(GTK_NOTEBOOK(propertybox->notebook),
- page_content_box);
+ /* Switch to selection from a list if the page count threshhold is reached */
+ page_count = gtk_notebook_page_num(GTK_NOTEBOOK(propertybox->notebook),
+ page_content_box);
- if (propertybox->page_list) {
- /* Build the matching list item for selecting from large page sets */
- listitem = gtk_list_item_new_with_label(_(name + name_offset));
- gtk_widget_show(listitem);
- gtk_container_add(GTK_CONTAINER(propertybox->page_list), listitem);
+ if (propertybox->page_list)
+ {
+ /* Build the matching list item for selecting from large page sets */
+ listitem = gtk_list_item_new_with_label(_(name + name_offset));
+ gtk_widget_show(listitem);
+ gtk_container_add(GTK_CONTAINER(propertybox->page_list), listitem);
- if (page_count > MAX_TAB_COUNT - 1) { /* Convert 1-based -> 0-based */
- gtk_widget_show(propertybox->page_list);
- gtk_notebook_set_show_tabs(GTK_NOTEBOOK(propertybox->notebook), FALSE);
- gtk_notebook_set_show_border(GTK_NOTEBOOK(propertybox->notebook), FALSE);
- }
+ if (page_count > MAX_TAB_COUNT - 1) /* Convert 1-based -> 0-based */
+ {
+ gtk_widget_show(propertybox->page_list);
+ gtk_notebook_set_show_tabs(GTK_NOTEBOOK(propertybox->notebook), FALSE);
+ gtk_notebook_set_show_border(GTK_NOTEBOOK(propertybox->notebook), FALSE);
+ }
- /* Tweak "advanced" pages for later handling. */
- if (advanced) {
- notebook_page =
- gtk_notebook_get_nth_page(GTK_NOTEBOOK(propertybox->notebook),
- page_count);
+ /* Tweak "advanced" pages for later handling. */
+ if (advanced)
+ {
+ notebook_page =
+ gtk_notebook_get_nth_page(GTK_NOTEBOOK(propertybox->notebook),
+ page_count);
- g_object_set_data(G_OBJECT(notebook_page), "listitem", listitem);
- g_object_set_data(G_OBJECT(notebook_page), "advanced",
- GINT_TO_POINTER(advanced));
+ g_object_set_data(G_OBJECT(notebook_page), "listitem", listitem);
+ g_object_set_data(G_OBJECT(notebook_page), "advanced",
+ GINT_TO_POINTER(advanced));
+ }
}
- }
- return(page_count);
+ return(page_count);
}
@@ -1279,174 +1295,182 @@
gnc_options_dialog_build_contents(GNCOptionWin *propertybox,
GNCOptionDB *odb)
{
- GNCOptionSection *section;
- gchar *default_section_name;
- gint default_page = -1;
- gint num_sections;
- gint page;
- gint i;
- guint j;
+ GNCOptionSection *section;
+ gchar *default_section_name;
+ gint default_page = -1;
+ gint num_sections;
+ gint page;
+ gint i;
+ guint j;
- g_return_if_fail (propertybox != NULL);
- g_return_if_fail (odb != NULL);
+ g_return_if_fail (propertybox != NULL);
+ g_return_if_fail (odb != NULL);
- gnc_option_db_set_ui_callbacks (odb,
- gnc_option_get_ui_value_internal,
- gnc_option_set_ui_value_internal,
- gnc_option_set_selectable_internal);
+ gnc_option_db_set_ui_callbacks (odb,
+ gnc_option_get_ui_value_internal,
+ gnc_option_set_ui_value_internal,
+ gnc_option_set_selectable_internal);
- propertybox->tips = gtk_tooltips_new();
- propertybox->option_db = odb;
+ propertybox->tips = gtk_tooltips_new();
+ propertybox->option_db = odb;
- g_object_ref_sink(propertybox->tips);
+ g_object_ref_sink(propertybox->tips);
- num_sections = gnc_option_db_num_sections(odb);
- default_section_name = gnc_option_db_get_default_section(odb);
+ num_sections = gnc_option_db_num_sections(odb);
+ default_section_name = gnc_option_db_get_default_section(odb);
- for (i = 0; i < num_sections; i++)
- {
- const char *section_name;
+ for (i = 0; i < num_sections; i++)
+ {
+ const char *section_name;
- section = gnc_option_db_get_section(odb, i);
- page = gnc_options_dialog_append_page(propertybox, section, propertybox->tips);
+ section = gnc_option_db_get_section(odb, i);
+ page = gnc_options_dialog_append_page(propertybox, section, propertybox->tips);
- section_name = gnc_option_section_name(section);
- if (safe_strcmp(section_name, default_section_name) == 0)
- default_page = page;
- }
+ section_name = gnc_option_section_name(section);
+ if (safe_strcmp(section_name, default_section_name) == 0)
+ default_page = page;
+ }
- if (default_section_name != NULL)
- free(default_section_name);
+ if (default_section_name != NULL)
+ free(default_section_name);
- /* call each option widget changed callbacks once at this point,
- * now that all options widgets exist.
- */
- for (i = 0; i < num_sections; i++)
- {
- section = gnc_option_db_get_section(odb, i);
+ /* call each option widget changed callbacks once at this point,
+ * now that all options widgets exist.
+ */
+ for (i = 0; i < num_sections; i++)
+ {
+ section = gnc_option_db_get_section(odb, i);
- for (j = 0; j < gnc_option_section_num_options(section); j++)
+ for (j = 0; j < gnc_option_section_num_options(section); j++)
+ {
+ gnc_option_call_option_widget_changed_proc(
+ gnc_get_option_section_option(section, j) );
+ }
+ }
+
+ gtk_notebook_popup_enable(GTK_NOTEBOOK(propertybox->notebook));
+ if (default_page >= 0)
{
- gnc_option_call_option_widget_changed_proc(
- gnc_get_option_section_option(section, j) );
+ gtk_notebook_set_current_page(GTK_NOTEBOOK(propertybox->notebook), default_page);
+ gtk_list_select_item(GTK_LIST(propertybox->page_list), default_page);
}
- }
-
- gtk_notebook_popup_enable(GTK_NOTEBOOK(propertybox->notebook));
- if (default_page >= 0) {
- gtk_notebook_set_current_page(GTK_NOTEBOOK(propertybox->notebook), default_page);
- gtk_list_select_item(GTK_LIST(propertybox->page_list), default_page);
- } else {
- /* GTKList doesn't default to selecting the first item. */
- gtk_list_select_item(GTK_LIST(propertybox->page_list), 0);
- }
- gnc_options_dialog_changed_internal(propertybox->dialog, FALSE);
- gtk_widget_show(propertybox->dialog);
+ else
+ {
+ /* GTKList doesn't default to selecting the first item. */
+ gtk_list_select_item(GTK_LIST(propertybox->page_list), 0);
+ }
+ gnc_options_dialog_changed_internal(propertybox->dialog, FALSE);
+ gtk_widget_show(propertybox->dialog);
}
GtkWidget *
gnc_options_dialog_widget(GNCOptionWin * win)
{
- return win->dialog;
+ return win->dialog;
}
GtkWidget *
gnc_options_dialog_notebook(GNCOptionWin * win)
{
- return win->notebook;
+ return win->notebook;
}
void
gnc_options_dialog_response_cb(GtkDialog *dialog, gint response, GNCOptionWin *window)
{
- GNCOptionWinCallback close_cb;
+ GNCOptionWinCallback close_cb;
- switch (response) {
- case GTK_RESPONSE_HELP:
- if(window->help_cb)
- (window->help_cb)(window, window->help_cb_data);
- break;
+ switch (response)
+ {
+ case GTK_RESPONSE_HELP:
+ if (window->help_cb)
+ (window->help_cb)(window, window->help_cb_data);
+ break;
- case GTK_RESPONSE_OK:
- case GTK_RESPONSE_APPLY:
- gnc_options_dialog_changed_internal (window->dialog, FALSE);
- close_cb = window->close_cb;
- window->close_cb = NULL;
- if (window->apply_cb)
- window->apply_cb (window, window->apply_cb_data);
- window->close_cb = close_cb;
- if (response == GTK_RESPONSE_APPLY)
- break;
- /* fall through */
+ case GTK_RESPONSE_OK:
+ case GTK_RESPONSE_APPLY:
+ gnc_options_dialog_changed_internal (window->dialog, FALSE);
+ close_cb = window->close_cb;
+ window->close_cb = NULL;
+ if (window->apply_cb)
+ window->apply_cb (window, window->apply_cb_data);
+ window->close_cb = close_cb;
+ if (response == GTK_RESPONSE_APPLY)
+ break;
+ /* fall through */
- default:
- if (window->close_cb) {
- (window->close_cb)(window, window->close_cb_data);
- } else {
- gtk_widget_hide(window->dialog);
+ default:
+ if (window->close_cb)
+ {
+ (window->close_cb)(window, window->close_cb_data);
+ }
+ else
+ {
+ gtk_widget_hide(window->dialog);
+ }
}
- }
}
static void
gnc_options_dialog_reset_cb(GtkWidget * w, gpointer data)
{
- GNCOptionWin *win = data;
- GNCOptionSection *section;
- gpointer val;
+ GNCOptionWin *win = data;
+ GNCOptionSection *section;
+ gpointer val;
- val = g_object_get_data(G_OBJECT(w), "section");
- g_return_if_fail (val);
- g_return_if_fail (win);
+ val = g_object_get_data(G_OBJECT(w), "section");
+ g_return_if_fail (val);
+ g_return_if_fail (win);
- section = (GNCOptionSection*)val;
- gnc_option_db_section_reset_widgets (section);
- gnc_options_dialog_changed_internal (win->dialog, TRUE);
+ section = (GNCOptionSection*)val;
+ gnc_option_db_section_reset_widgets (section);
+ gnc_options_dialog_changed_internal (win->dialog, TRUE);
}
void
gnc_options_dialog_list_select_cb(GtkWidget * list, GtkWidget * item,
- gpointer data)
+ gpointer data)
{
- GNCOptionWin * win = data;
- gint index;
+ GNCOptionWin * win = data;
+ gint index;
- g_return_if_fail (list);
- g_return_if_fail (win);
+ g_return_if_fail (list);
+ g_return_if_fail (win);
- index = gtk_list_child_position(GTK_LIST(list), item);
- gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), index);
+ index = gtk_list_child_position(GTK_LIST(list), item);
+ gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), index);
}
void
gnc_options_register_stocks (void)
{
#if 0
- static gboolean done = FALSE;
+ static gboolean done = FALSE;
- GtkStockItem items[] = {
- { GTK_STOCK_APPLY ,"gnc_option_apply_button", 0, 0, NULL },
- { GTK_STOCK_HELP ,"gnc_options_dialog_help", 0, 0, NULL },
- { GTK_STOCK_OK ,"gnc_options_dialog_ok", 0, 0, NULL },
- { GTK_STOCK_CANCEL ,"gnc_options_dialog_cancel", 0, 0, NULL },
- };
+ GtkStockItem items[] =
+ {
+ { GTK_STOCK_APPLY , "gnc_option_apply_button", 0, 0, NULL },
+ { GTK_STOCK_HELP , "gnc_options_dialog_help", 0, 0, NULL },
+ { GTK_STOCK_OK , "gnc_options_dialog_ok", 0, 0, NULL },
+ { GTK_STOCK_CANCEL , "gnc_options_dialog_cancel", 0, 0, NULL },
+ };
- if (done)
- {
- return;
- }
- done = TRUE;
+ if (done)
+ {
+ return;
+ }
+ done = TRUE;
- gtk_stock_add (items, G_N_ELEMENTS (items));
+ gtk_stock_add (items, G_N_ELEMENTS (items));
#endif
}
static void
component_close_handler (gpointer data)
{
- GNCOptionWin *window = data;
- gtk_dialog_response(GTK_DIALOG(window->dialog), GTK_RESPONSE_CANCEL);
+ GNCOptionWin *window = data;
+ gtk_dialog_response(GTK_DIALOG(window->dialog), GTK_RESPONSE_CANCEL);
}
/* gnc_options_dialog_new:
@@ -1460,35 +1484,35 @@
GNCOptionWin *
gnc_options_dialog_new(gchar *title)
{
- GNCOptionWin * retval;
- GladeXML *xml;
- GtkWidget * hbox;
- gint component_id;
+ GNCOptionWin * retval;
+ GladeXML *xml;
+ GtkWidget * hbox;
+ gint component_id;
- retval = g_new0(GNCOptionWin, 1);
- xml = gnc_glade_xml_new ("preferences.glade", "GnuCash Options");
- retval->dialog = glade_xml_get_widget (xml, "GnuCash Options");
- retval->page_list = glade_xml_get_widget (xml, "page_list");
+ retval = g_new0(GNCOptionWin, 1);
+ xml = gnc_glade_xml_new ("preferences.glade", "GnuCash Options");
+ retval->dialog = glade_xml_get_widget (xml, "GnuCash Options");
+ retval->page_list = glade_xml_get_widget (xml, "page_list");
- glade_xml_signal_autoconnect_full( xml,
- gnc_glade_autoconnect_full_func,
- retval );
+ glade_xml_signal_autoconnect_full( xml,
+ gnc_glade_autoconnect_full_func,
+ retval );
- if (title)
- gtk_window_set_title(GTK_WINDOW(retval->dialog), title);
+ if (title)
+ gtk_window_set_title(GTK_WINDOW(retval->dialog), title);
- /* glade doesn't suport a notebook with zero pages */
- hbox = glade_xml_get_widget (xml, "notebook placeholder");
- retval->notebook = gtk_notebook_new();
- gtk_widget_show(retval->notebook);
- gtk_box_pack_start(GTK_BOX(hbox), retval->notebook, TRUE, TRUE, 5);
+ /* glade doesn't suport a notebook with zero pages */
+ hbox = glade_xml_get_widget (xml, "notebook placeholder");
+ retval->notebook = gtk_notebook_new();
+ gtk_widget_show(retval->notebook);
+ gtk_box_pack_start(GTK_BOX(hbox), retval->notebook, TRUE, TRUE, 5);
- component_id = gnc_register_gui_component (DIALOG_OPTIONS_CM_CLASS,
- NULL, component_close_handler,
- retval);
- gnc_gui_component_set_session (component_id, gnc_get_current_session());
+ component_id = gnc_register_gui_component (DIALOG_OPTIONS_CM_CLASS,
+ NULL, component_close_handler,
+ retval);
+ gnc_gui_component_set_session (component_id, gnc_get_current_session());
- return retval;
+ return retval;
}
/* Creates a new GNCOptionWin structure, but assumes you have your own
@@ -1496,66 +1520,67 @@
GNCOptionWin *
gnc_options_dialog_new_w_dialog(gchar *title, GtkWidget *dialog)
{
- GNCOptionWin * retval;
+ GNCOptionWin * retval;
- retval = g_new0(GNCOptionWin, 1);
- retval->dialog = dialog;
- return retval;
+ retval = g_new0(GNCOptionWin, 1);
+ retval->dialog = dialog;
+ return retval;
}
void
gnc_options_dialog_set_apply_cb(GNCOptionWin * win, GNCOptionWinCallback cb,
gpointer data)
{
- win->apply_cb = cb;
- win->apply_cb_data = data;
+ win->apply_cb = cb;
+ win->apply_cb_data = data;
}
void
gnc_options_dialog_set_help_cb(GNCOptionWin * win, GNCOptionWinCallback cb,
gpointer data)
{
- win->help_cb = cb;
- win->help_cb_data = data;
+ win->help_cb = cb;
+ win->help_cb_data = data;
}
void
gnc_options_dialog_set_close_cb(GNCOptionWin * win, GNCOptionWinCallback cb,
gpointer data)
{
- win->close_cb = cb;
- win->close_cb_data = data;
+ win->close_cb = cb;
+ win->close_cb_data = data;
}
void
gnc_options_dialog_set_global_help_cb(GNCOptionWinCallback thunk,
gpointer cb_data)
{
- global_help_cb = thunk;
- global_help_cb_data = cb_data;
+ global_help_cb = thunk;
+ global_help_cb_data = cb_data;
}
/* This is for global program preferences. */
void
gnc_options_dialog_destroy(GNCOptionWin * win)
{
- if (!win) return;
+ if (!win) return;
- gnc_unregister_gui_component_by_data(DIALOG_OPTIONS_CM_CLASS, win);
+ gnc_unregister_gui_component_by_data(DIALOG_OPTIONS_CM_CLASS, win);
- gtk_widget_destroy(win->dialog);
+ gtk_widget_destroy(win->dialog);
- if(win->tips) {
- g_object_unref (win->tips);
- }
+ if (win->tips)
+ {
+ g_object_unref (win->tips);
+ }
- win->dialog = NULL;
- win->notebook = NULL;
- win->apply_cb = NULL;
- win->help_cb = NULL;
- win->tips = NULL;
+ win->dialog = NULL;
+ win->notebook = NULL;
+ win->apply_cb = NULL;
+ win->help_cb = NULL;
+ win->tips = NULL;
- g_free(win);
+ g_free(win);
}
@@ -1598,559 +1623,559 @@
*/
static GtkWidget *
gnc_option_set_ui_widget_boolean (GNCOption *option, GtkBox *page_box,
- GtkTooltips *tooltips,
- char *name, char *documentation,
- /* Return values */
- GtkWidget **enclosing, gboolean *packed)
+ GtkTooltips *tooltips,
+ char *name, char *documentation,
+ /* Return values */
+ GtkWidget **enclosing, gboolean *packed)
{
- GtkWidget *value;
+ GtkWidget *value;
- *enclosing = gtk_hbox_new(FALSE, 5);
- value = gtk_check_button_new_with_label(name);
+ *enclosing = gtk_hbox_new(FALSE, 5);
+ value = gtk_check_button_new_with_label(name);
- gnc_option_set_widget (option, value);
- gnc_option_set_ui_value(option, FALSE);
+ gnc_option_set_widget (option, value);
+ gnc_option_set_ui_value(option, FALSE);
- g_signal_connect(G_OBJECT(value), "toggled",
- G_CALLBACK(gnc_option_changed_widget_cb), option);
+ g_signal_connect(G_OBJECT(value), "toggled",
+ G_CALLBACK(gnc_option_changed_widget_cb), option);
- gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
- gtk_widget_show_all(*enclosing);
+ gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
+ gtk_widget_show_all(*enclosing);
- return value;
+ return value;
}
static GtkWidget *
gnc_option_set_ui_widget_string (GNCOption *option, GtkBox *page_box,
- GtkTooltips *tooltips,
- char *name, char *documentation,
- /* Return values */
- GtkWidget **enclosing, gboolean *packed)
+ GtkTooltips *tooltips,
+ char *name, char *documentation,
+ /* Return values */
+ GtkWidget **enclosing, gboolean *packed)
{
- GtkWidget *value;
- GtkWidget *label;
- gchar *colon_name;
+ GtkWidget *value;
+ GtkWidget *label;
+ gchar *colon_name;
- colon_name = g_strconcat(name, ":", NULL);
- label = gtk_label_new(colon_name);
- gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
- g_free(colon_name);
+ colon_name = g_strconcat(name, ":", NULL);
+ label = gtk_label_new(colon_name);
+ gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
+ g_free(colon_name);
- *enclosing = gtk_hbox_new(FALSE, 5);
- value = gtk_entry_new();
+ *enclosing = gtk_hbox_new(FALSE, 5);
+ value = gtk_entry_new();
- gnc_option_set_widget (option, value);
- gnc_option_set_ui_value(option, FALSE);
+ gnc_option_set_widget (option, value);
+ gnc_option_set_ui_value(option, FALSE);
- g_signal_connect(G_OBJECT(value), "changed",
- G_CALLBACK(gnc_option_changed_widget_cb), option);
+ g_signal_connect(G_OBJECT(value), "changed",
+ G_CALLBACK(gnc_option_changed_widget_cb), option);
- gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
- gtk_widget_show_all(*enclosing);
- return value;
+ gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
+ gtk_widget_show_all(*enclosing);
+ return value;
}
static GtkWidget *
gnc_option_set_ui_widget_text (GNCOption *option, GtkBox *page_box,
- GtkTooltips *tooltips,
- char *name, char *documentation,
- /* Return values */
- GtkWidget **enclosing, gboolean *packed)
+ GtkTooltips *tooltips,
+ char *name, char *documentation,
+ /* Return values */
+ GtkWidget **enclosing, gboolean *packed)
{
- GtkWidget *value;
- GtkWidget *frame;
- GtkWidget *scroll;
- GtkTextBuffer* text_buffer;
+ GtkWidget *value;
+ GtkWidget *frame;
+ GtkWidget *scroll;
+ GtkTextBuffer* text_buffer;
- frame = gtk_frame_new(name);
+ frame = gtk_frame_new(name);
- scroll = gtk_scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
- GTK_POLICY_NEVER,
- GTK_POLICY_AUTOMATIC);
- gtk_container_set_border_width(GTK_CONTAINER(scroll), 2);
+ scroll = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
+ GTK_POLICY_NEVER,
+ GTK_POLICY_AUTOMATIC);
+ gtk_container_set_border_width(GTK_CONTAINER(scroll), 2);
- gtk_container_add(GTK_CONTAINER(frame), scroll);
+ gtk_container_add(GTK_CONTAINER(frame), scroll);
- *enclosing = gtk_hbox_new(FALSE, 10);
- value = gtk_text_view_new();
- gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(value), GTK_WRAP_WORD);
- gtk_text_view_set_editable(GTK_TEXT_VIEW(value), TRUE);
- gtk_container_add (GTK_CONTAINER (scroll), value);
+ *enclosing = gtk_hbox_new(FALSE, 10);
+ value = gtk_text_view_new();
+ gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(value), GTK_WRAP_WORD);
+ gtk_text_view_set_editable(GTK_TEXT_VIEW(value), TRUE);
+ gtk_container_add (GTK_CONTAINER (scroll), value);
- gnc_option_set_widget (option, value);
- gnc_option_set_ui_value(option, FALSE);
+ gnc_option_set_widget (option, value);
+ gnc_option_set_ui_value(option, FALSE);
- text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(value));
- g_signal_connect(G_OBJECT(text_buffer), "changed",
- G_CALLBACK(gnc_option_changed_option_cb), option);
+ text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(value));
+ g_signal_connect(G_OBJECT(text_buffer), "changed",
+ G_CALLBACK(gnc_option_changed_option_cb), option);
- gtk_box_pack_start(GTK_BOX(*enclosing), frame, TRUE, TRUE, 0);
- gtk_widget_show_all(*enclosing);
- return value;
+ gtk_box_pack_start(GTK_BOX(*enclosing), frame, TRUE, TRUE, 0);
+ gtk_widget_show_all(*enclosing);
+ return value;
}
static GtkWidget *
gnc_option_set_ui_widget_currency (GNCOption *option, GtkBox *page_box,
- GtkTooltips *tooltips,
- char *name, char *documentation,
- /* Return values */
- GtkWidget **enclosing, gboolean *packed)
+ GtkTooltips *tooltips,
+ char *name, char *documentation,
+ /* Return values */
+ GtkWidget **enclosing, gboolean *packed)
{
- GtkWidget *value;
- GtkWidget *label;
- gchar *colon_name;
+ GtkWidget *value;
+ GtkWidget *label;
+ gchar *colon_name;
- colon_name = g_strconcat(name, ":", NULL);
- label = gtk_label_new(colon_name);
- gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
- g_free(colon_name);
+ colon_name = g_strconcat(name, ":", NULL);
+ label = gtk_label_new(colon_name);
+ gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
+ g_free(colon_name);
- *enclosing = gtk_hbox_new(FALSE, 5);
- value = gnc_currency_edit_new();
+ *enclosing = gtk_hbox_new(FALSE, 5);
+ value = gnc_currency_edit_new();
- gnc_option_set_widget (option, value);
- gnc_option_set_ui_value(option, FALSE);
+ gnc_option_set_widget (option, value);
+ gnc_option_set_ui_value(option, FALSE);
- g_signal_connect(G_OBJECT(value), "changed",
- G_CALLBACK(gnc_option_changed_widget_cb), option);
+ g_signal_connect(G_OBJECT(value), "changed",
+ G_CALLBACK(gnc_option_changed_widget_cb), option);
- gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
- gtk_widget_show_all(*enclosing);
- return value;
+ gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
+ gtk_widget_show_all(*enclosing);
+ return value;
}
static GtkWidget *
gnc_option_set_ui_widget_commodity (GNCOption *option, GtkBox *page_box,
- GtkTooltips *tooltips,
- char *name, char *documentation,
- /* Return values */
- GtkWidget **enclosing, gboolean *packed)
+ GtkTooltips *tooltips,
+ char *name, char *documentation,
+ /* Return values */
+ GtkWidget **enclosing, gboolean *packed)
{
- GtkWidget *value;
- GtkWidget *label;
- gchar *colon_name;
+ GtkWidget *value;
+ GtkWidget *label;
+ gchar *colon_name;
- colon_name = g_strconcat(name, ":", NULL);
- label = gtk_label_new(colon_name);
- gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
- g_free(colon_name);
+ colon_name = g_strconcat(name, ":", NULL);
+ label = gtk_label_new(colon_name);
+ gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
+ g_free(colon_name);
- *enclosing = gtk_hbox_new(FALSE, 5);
- value = gnc_general_select_new(GNC_GENERAL_SELECT_TYPE_SELECT,
- gnc_commodity_edit_get_string,
- gnc_commodity_edit_new_select,
- NULL);
+ *enclosing = gtk_hbox_new(FALSE, 5);
+ value = gnc_general_select_new(GNC_GENERAL_SELECT_TYPE_SELECT,
+ gnc_commodity_edit_get_string,
+ gnc_commodity_edit_new_select,
+ NULL);
- gnc_option_set_widget (option, value);
- gnc_option_set_ui_value(option, FALSE);
+ gnc_option_set_widget (option, value);
+ gnc_option_set_ui_value(option, FALSE);
- if (documentation != NULL)
- gtk_tooltips_set_tip(tooltips, GNC_GENERAL_SELECT(value)->entry,
- documentation, NULL);
+ if (documentation != NULL)
+ gtk_tooltips_set_tip(tooltips, GNC_GENERAL_SELECT(value)->entry,
+ documentation, NULL);
- g_signal_connect(G_OBJECT(GNC_GENERAL_SELECT(value)->entry), "changed",
- G_CALLBACK(gnc_option_changed_widget_cb), option);
+ g_signal_connect(G_OBJECT(GNC_GENERAL_SELECT(value)->entry), "changed",
+ G_CALLBACK(gnc_option_changed_widget_cb), option);
- gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
- gtk_widget_show_all(*enclosing);
- return value;
+ gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
+ gtk_widget_show_all(*enclosing);
+ return value;
}
static GtkWidget *
gnc_option_set_ui_widget_multichoice (GNCOption *option, GtkBox *page_box,
- GtkTooltips *tooltips,
- char *name, char *documentation,
- /* Return values */
- GtkWidget **enclosing, gboolean *packed)
+ GtkTooltips *tooltips,
+ char *name, char *documentation,
+ /* Return values */
+ GtkWidget **enclosing, gboolean *packed)
{
- GtkWidget *value;
- GtkWidget *label;
- gchar *colon_name;
+ GtkWidget *value;
+ GtkWidget *label;
+ gchar *colon_name;
- colon_name = g_strconcat(name, ":", NULL);
- label = gtk_label_new(colon_name);
- gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
- g_free(colon_name);
+ colon_name = g_strconcat(name, ":", NULL);
+ label = gtk_label_new(colon_name);
+ gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
+ g_free(colon_name);
- *enclosing = gtk_hbox_new(FALSE, 5);
+ *enclosing = gtk_hbox_new(FALSE, 5);
- value = gnc_option_create_multichoice_widget(option, tooltips);
- gnc_option_set_widget (option, value);
+ value = gnc_option_create_multichoice_widget(option, tooltips);
+ gnc_option_set_widget (option, value);
- gnc_option_set_ui_value(option, FALSE);
- gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
- gtk_widget_show_all(*enclosing);
- return value;
+ gnc_option_set_ui_value(option, FALSE);
+ gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
+ gtk_widget_show_all(*enclosing);
+ return value;
}
static GtkWidget *
gnc_option_set_ui_widget_date (GNCOption *option, GtkBox *page_box,
- GtkTooltips *tooltips,
- char *name, char *documentation,
- /* Return values */
- GtkWidget **enclosing, gboolean *packed)
+ GtkTooltips *tooltips,
+ char *name, char *documentation,
+ /* Return values */
+ GtkWidget **enclosing, gboolean *packed)
{
- GtkWidget *value;
- GtkWidget *label;
- gchar *colon_name;
- GtkWidget *eventbox;
+ GtkWidget *value;
+ GtkWidget *label;
+ gchar *colon_name;
+ GtkWidget *eventbox;
- colon_name = g_strconcat(name, ":", NULL);
- label = gtk_label_new(colon_name);
- gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
- g_free(colon_name);
+ colon_name = g_strconcat(name, ":", NULL);
+ label = gtk_label_new(colon_name);
+ gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
+ g_free(colon_name);
- *enclosing = gtk_hbox_new(FALSE, 5);
+ *enclosing = gtk_hbox_new(FALSE, 5);
- value = gnc_option_create_date_widget(option);
+ value = gnc_option_create_date_widget(option);
- gnc_option_set_widget (option, value);
+ gnc_option_set_widget (option, value);
- gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
- /* Pack option widget into an extra eventbox because otherwise the
- "documentation" tooltip is not displayed. */
- eventbox = gtk_event_box_new();
- gtk_container_add (GTK_CONTAINER (eventbox), *enclosing);
- gtk_box_pack_start(page_box, eventbox, FALSE, FALSE, 5);
- *packed = TRUE;
+ /* Pack option widget into an extra eventbox because otherwise the
+ "documentation" tooltip is not displayed. */
+ eventbox = gtk_event_box_new();
+ gtk_container_add (GTK_CONTAINER (eventbox), *enclosing);
+ gtk_box_pack_start(page_box, eventbox, FALSE, FALSE, 5);
+ *packed = TRUE;
- gtk_tooltips_set_tip (tooltips, eventbox, documentation, NULL);
+ gtk_tooltips_set_tip (tooltips, eventbox, documentation, NULL);
- gnc_option_set_ui_value(option, FALSE);
- gtk_widget_show_all(*enclosing);
- return value;
+ gnc_option_set_ui_value(option, FALSE);
+ gtk_widget_show_all(*enclosing);
+ return value;
}
static GtkWidget *
gnc_option_set_ui_widget_account_list (GNCOption *option, GtkBox *page_box,
- GtkTooltips *tooltips,
- char *name, char *documentation,
- /* Return values */
- GtkWidget **enclosing, gboolean *packed)
+ GtkTooltips *tooltips,
+ char *name, char *documentation,
+ /* Return values */
+ GtkWidget **enclosing, gboolean *packed)
{
- GtkWidget *value;
- GtkTreeSelection *selection;
+ GtkWidget *value;
+ GtkTreeSelection *selection;
- *enclosing = gnc_option_create_account_widget(option, name, tooltips);
- value = gnc_option_get_widget (option);
+ *enclosing = gnc_option_create_account_widget(option, name, tooltips);
+ value = gnc_option_get_widget (option);
- gtk_tooltips_set_tip(tooltips, *enclosing, documentation, NULL);
+ gtk_tooltips_set_tip(tooltips, *enclosing, documentation, NULL);
- gtk_box_pack_start(page_box, *enclosing, TRUE, TRUE, 5);
- *packed = TRUE;
+ gtk_box_pack_start(page_box, *enclosing, TRUE, TRUE, 5);
+ *packed = TRUE;
- //gtk_widget_realize(value);
+ //gtk_widget_realize(value);
- gnc_option_set_ui_value(option, FALSE);
+ gnc_option_set_ui_value(option, FALSE);
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(value));
- g_signal_connect(G_OBJECT(selection), "changed",
- G_CALLBACK(gnc_option_account_cb), option);
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(value));
+ g_signal_connect(G_OBJECT(selection), "changed",
+ G_CALLBACK(gnc_option_account_cb), option);
- // gtk_clist_set_row_height(GTK_CLIST(value), 0);
- // gtk_widget_set_size_request(value, -1, GTK_CLIST(value)->row_height * 10);
- gtk_widget_show_all(*enclosing);
- return value;
+ // gtk_clist_set_row_height(GTK_CLIST(value), 0);
+ // gtk_widget_set_size_request(value, -1, GTK_CLIST(value)->row_height * 10);
+ gtk_widget_show_all(*enclosing);
+ return value;
}
static GtkWidget *
gnc_option_set_ui_widget_account_sel (GNCOption *option, GtkBox *page_box,
- GtkTooltips *tooltips,
- char *name, char *documentation,
- /* Return values */
- GtkWidget **enclosing, gboolean *packed)
+ GtkTooltips *tooltips,
+ char *name, char *documentation,
+ /* Return values */
+ GtkWidget **enclosing, gboolean *packed)
{
- GtkWidget *value;
- GtkWidget *label;
- GList *acct_type_list;
- gchar *colon_name;
+ GtkWidget *value;
+ GtkWidget *label;
+ GList *acct_type_list;
+ gchar *colon_name;
- colon_name = g_strconcat(name, ":", NULL);
- label = gtk_label_new(colon_name);
- gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
- g_free(colon_name);
+ colon_name = g_strconcat(name, ":", NULL);
+ label = gtk_label_new(colon_name);
+ gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
+ g_free(colon_name);
- acct_type_list = gnc_option_get_account_type_list(option);
- value = gnc_account_sel_new();
- gnc_account_sel_set_acct_filters(GNC_ACCOUNT_SEL(value), acct_type_list, NULL);
+ acct_type_list = gnc_option_get_account_type_list(option);
+ value = gnc_account_sel_new();
+ gnc_account_sel_set_acct_filters(GNC_ACCOUNT_SEL(value), acct_type_list, NULL);
- g_signal_connect(value, "account_sel_changed",
- G_CALLBACK(gnc_option_changed_widget_cb), option);
+ g_signal_connect(value, "account_sel_changed",
+ G_CALLBACK(gnc_option_changed_widget_cb), option);
- gnc_option_set_widget (option, value);
- /* DOCUMENT ME: Why is the only option type that sets use_default to
- TRUE? */
- gnc_option_set_ui_value(option, TRUE);
+ gnc_option_set_widget (option, value);
+ /* DOCUMENT ME: Why is the only option type that sets use_default to
+ TRUE? */
+ gnc_option_set_ui_value(option, TRUE);
- *enclosing = gtk_hbox_new(FALSE, 5);
- gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
- gtk_widget_show_all(*enclosing);
- return value;
+ *enclosing = gtk_hbox_new(FALSE, 5);
+ gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
+ gtk_widget_show_all(*enclosing);
+ return value;
}
static GtkWidget *
gnc_option_set_ui_widget_list (GNCOption *option, GtkBox *page_box,
- GtkTooltips *tooltips,
- char *name, char *documentation,
- /* Return values */
- GtkWidget **enclosing, gboolean *packed)
+ GtkTooltips *tooltips,
+ char *name, char *documentation,
+ /* Return values */
+ GtkWidget **enclosing, gboolean *packed)
{
- GtkWidget *value;
- GtkWidget *eventbox;
+ GtkWidget *value;
+ GtkWidget *eventbox;
- *enclosing = gnc_option_create_list_widget(option, name, tooltips);
- value = gnc_option_get_widget (option);
+ *enclosing = gnc_option_create_list_widget(option, name, tooltips);
+ value = gnc_option_get_widget (option);
- /* Pack option widget into an extra eventbox because otherwise the
- "documentation" tooltip is not displayed. */
- eventbox = gtk_event_box_new();
- gtk_container_add (GTK_CONTAINER (eventbox), *enclosing);
- gtk_box_pack_start(page_box, eventbox, FALSE, FALSE, 5);
- *packed = TRUE;
+ /* Pack option widget into an extra eventbox because otherwise the
+ "documentation" tooltip is not displayed. */
+ eventbox = gtk_event_box_new();
+ gtk_container_add (GTK_CONTAINER (eventbox), *enclosing);
+ gtk_box_pack_start(page_box, eventbox, FALSE, FALSE, 5);
+ *packed = TRUE;
- gtk_tooltips_set_tip(tooltips, eventbox, documentation, NULL);
+ gtk_tooltips_set_tip(tooltips, eventbox, documentation, NULL);
- gnc_option_set_ui_value(option, FALSE);
- gtk_widget_show(*enclosing);
- return value;
+ gnc_option_set_ui_value(option, FALSE);
+ gtk_widget_show(*enclosing);
+ return value;
}
static GtkWidget *
gnc_option_set_ui_widget_number_range (GNCOption *option, GtkBox *page_box,
- GtkTooltips *tooltips,
- char *name, char *documentation,
- /* Return values */
- GtkWidget **enclosing, gboolean *packed)
+ GtkTooltips *tooltips,
+ char *name, char *documentation,
+ /* Return values */
+ GtkWidget **enclosing, gboolean *packed)
{
- GtkWidget *value;
- GtkWidget *label;
- gchar *colon_name;
- GtkAdjustment *adj;
- gdouble lower_bound = G_MINDOUBLE;
- gdouble upper_bound = G_MAXDOUBLE;
- gdouble step_size = 1.0;
- int num_decimals = 0;
+ GtkWidget *value;
+ GtkWidget *label;
+ gchar *colon_name;
+ GtkAdjustment *adj;
+ gdouble lower_bound = G_MINDOUBLE;
+ gdouble upper_bound = G_MAXDOUBLE;
+ gdouble step_size = 1.0;
+ int num_decimals = 0;
- colon_name = g_strconcat(name, ":", NULL);
- label = gtk_label_new(colon_name);
- gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
- g_free(colon_name);
+ colon_name = g_strconcat(name, ":", NULL);
+ label = gtk_label_new(colon_name);
+ gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
+ g_free(colon_name);
- *enclosing = gtk_hbox_new(FALSE, 5);
+ *enclosing = gtk_hbox_new(FALSE, 5);
- gnc_option_get_range_info(option, &lower_bound, &upper_bound,
- &num_decimals, &step_size);
- adj = GTK_ADJUSTMENT(gtk_adjustment_new(lower_bound, lower_bound,
- upper_bound, step_size,
- step_size * 5.0,
- step_size * 5.0));
- value = gtk_spin_button_new(adj, step_size, num_decimals);
- gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(value), TRUE);
+ gnc_option_get_range_info(option, &lower_bound, &upper_bound,
+ &num_decimals, &step_size);
+ adj = GTK_ADJUSTMENT(gtk_adjustment_new(lower_bound, lower_bound,
+ upper_bound, step_size,
+ step_size * 5.0,
+ step_size * 5.0));
+ value = gtk_spin_button_new(adj, step_size, num_decimals);
+ gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(value), TRUE);
- {
- gdouble biggest;
- gint num_digits;
+ {
+ gdouble biggest;
+ gint num_digits;
- biggest = ABS(lower_bound);
- biggest = MAX(biggest, ABS(upper_bound));
+ biggest = ABS(lower_bound);
+ biggest = MAX(biggest, ABS(upper_bound));
- num_digits = 0;
- while (biggest >= 1)
- {
- num_digits++;
- biggest = biggest / 10;
- }
+ num_digits = 0;
+ while (biggest >= 1)
+ {
+ num_digits++;
+ biggest = biggest / 10;
+ }
- if (num_digits == 0)
- num_digits = 1;
+ if (num_digits == 0)
+ num_digits = 1;
- num_digits += num_decimals;
+ num_digits += num_decimals;
- gtk_entry_set_width_chars(GTK_ENTRY(value), num_digits);
- }
+ gtk_entry_set_width_chars(GTK_ENTRY(value), num_digits);
+ }
- gnc_option_set_widget (option, value);
- gnc_option_set_ui_value(option, FALSE);
+ gnc_option_set_widget (option, value);
+ gnc_option_set_ui_value(option, FALSE);
- g_signal_connect(G_OBJECT(value), "changed",
- G_CALLBACK(gnc_option_changed_widget_cb), option);
+ g_signal_connect(G_OBJECT(value), "changed",
+ G_CALLBACK(gnc_option_changed_widget_cb), option);
- gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
- gtk_widget_show_all(*enclosing);
- return value;
+ gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
+ gtk_widget_show_all(*enclosing);
+ return value;
}
static GtkWidget *
gnc_option_set_ui_widget_color (GNCOption *option, GtkBox *page_box,
- GtkTooltips *tooltips,
- char *name, char *documentation,
- /* Return values */
- GtkWidget **enclosing, gboolean *packed)
+ GtkTooltips *tooltips,
+ char *name, char *documentation,
+ /* Return values */
+ GtkWidget **enclosing, gboolean *packed)
{
- GtkWidget *value;
- GtkWidget *label;
- gchar *colon_name;
- gboolean use_alpha;
+ GtkWidget *value;
+ GtkWidget *label;
+ gchar *colon_name;
+ gboolean use_alpha;
- colon_name = g_strconcat(name, ":", NULL);
- label = gtk_label_new(colon_name);
- gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
- g_free(colon_name);
+ colon_name = g_strconcat(name, ":", NULL);
+ label = gtk_label_new(colon_name);
+ gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
+ g_free(colon_name);
- *enclosing = gtk_hbox_new(FALSE, 5);
+ *enclosing = gtk_hbox_new(FALSE, 5);
- use_alpha = gnc_option_use_alpha(option);
+ use_alpha = gnc_option_use_alpha(option);
- value = gtk_color_button_new();
- gtk_color_button_set_title(GTK_COLOR_BUTTON(value), name);
- gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(value), use_alpha);
+ value = gtk_color_button_new();
+ gtk_color_button_set_title(GTK_COLOR_BUTTON(value), name);
+ gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(value), use_alpha);
- gnc_option_set_widget (option, value);
- gnc_option_set_ui_value(option, FALSE);
+ gnc_option_set_widget (option, value);
+ gnc_option_set_ui_value(option, FALSE);
- g_signal_connect(G_OBJECT(value), "color-set",
- G_CALLBACK(gnc_option_color_changed_cb), option);
+ g_signal_connect(G_OBJECT(value), "color-set",
+ G_CALLBACK(gnc_option_color_changed_cb), option);
- gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
- gtk_widget_show_all(*enclosing);
- return value;
+ gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
+ gtk_widget_show_all(*enclosing);
+ return value;
}
static GtkWidget *
gnc_option_set_ui_widget_font (GNCOption *option, GtkBox *page_box,
- GtkTooltips *tooltips,
- char *name, char *documentation,
- /* Return values */
- GtkWidget **enclosing, gboolean *packed)
+ GtkTooltips *tooltips,
+ char *name, char *documentation,
+ /* Return values */
+ GtkWidget **enclosing, gboolean *packed)
{
- GtkWidget *value;
- GtkWidget *label;
- gchar *colon_name;
+ GtkWidget *value;
+ GtkWidget *label;
+ gchar *colon_name;
- colon_name = g_strconcat(name, ":", NULL);
- label = gtk_label_new(colon_name);
- gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
- g_free(colon_name);
+ colon_name = g_strconcat(name, ":", NULL);
+ label = gtk_label_new(colon_name);
+ gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
+ g_free(colon_name);
- *enclosing = gtk_hbox_new(FALSE, 5);
- value = gtk_font_button_new();
- g_object_set(G_OBJECT(value),
- "use-font", TRUE,
- "show-style", TRUE,
- "show-size", TRUE,
- (char *)NULL);
+ *enclosing = gtk_hbox_new(FALSE, 5);
+ value = gtk_font_button_new();
+ g_object_set(G_OBJECT(value),
+ "use-font", TRUE,
+ "show-style", TRUE,
+ "show-size", TRUE,
+ (char *)NULL);
- gnc_option_set_widget (option, value);
+ gnc_option_set_widget (option, value);
- gnc_option_set_ui_value(option, FALSE);
+ gnc_option_set_ui_value(option, FALSE);
- g_signal_connect(G_OBJECT(value), "font-set",
- G_CALLBACK(gnc_option_font_changed_cb), option);
+ g_signal_connect(G_OBJECT(value), "font-set",
+ G_CALLBACK(gnc_option_font_changed_cb), option);
- gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
- gtk_widget_show_all(*enclosing);
- return value;
+ gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
+ gtk_widget_show_all(*enclosing);
+ return value;
}
static GtkWidget *
gnc_option_set_ui_widget_pixmap (GNCOption *option, GtkBox *page_box,
- GtkTooltips *tooltips,
- char *name, char *documentation,
- /* Return values */
- GtkWidget **enclosing, gboolean *packed)
+ GtkTooltips *tooltips,
+ char *name, char *documentation,
+ /* Return values */
+ GtkWidget **enclosing, gboolean *packed)
{
- GtkWidget *value;
- GtkWidget *label;
- GtkWidget *button;
- gchar *colon_name;
+ GtkWidget *value;
+ GtkWidget *label;
+ GtkWidget *button;
+ gchar *colon_name;
- ENTER("option %p(%s), name %s", option, gnc_option_name(option), name);
- colon_name = g_strconcat(name, ":", NULL);
- label = gtk_label_new(colon_name);
- gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
- g_free(colon_name);
+ ENTER("option %p(%s), name %s", option, gnc_option_name(option), name);
+ colon_name = g_strconcat(name, ":", NULL);
+ label = gtk_label_new(colon_name);
+ gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
+ g_free(colon_name);
- *enclosing = gtk_hbox_new(FALSE, 5);
+ *enclosing = gtk_hbox_new(FALSE, 5);
- button = gtk_button_new_with_label(_("Clear"));
- gtk_tooltips_set_tip(tooltips, button, _("Clear any selected image file."), NULL);
+ button = gtk_button_new_with_label(_("Clear"));
+ gtk_tooltips_set_tip(tooltips, button, _("Clear any selected image file."), NULL);
- value = gtk_file_chooser_button_new(_("Select image"),
- GTK_FILE_CHOOSER_ACTION_OPEN);
- gtk_tooltips_set_tip(tooltips, value, _("Select an image file."), NULL);
- g_object_set(G_OBJECT(value),
- "width-chars", 30,
- "preview-widget", gtk_image_new(),
- (char *)NULL);
- g_signal_connect(G_OBJECT (value), "selection-changed",
- G_CALLBACK(gnc_option_changed_widget_cb), option);
- g_signal_connect(G_OBJECT (value), "selection-changed",
- G_CALLBACK(gnc_image_option_selection_changed_cb), option);
- g_signal_connect(G_OBJECT (value), "update-preview",
- G_CALLBACK(gnc_image_option_update_preview_cb), option);
- g_signal_connect_swapped(G_OBJECT (button), "clicked",
- G_CALLBACK(gtk_file_chooser_unselect_all), value);
+ value = gtk_file_chooser_button_new(_("Select image"),
+ GTK_FILE_CHOOSER_ACTION_OPEN);
+ gtk_tooltips_set_tip(tooltips, value, _("Select an image file."), NULL);
+ g_object_set(G_OBJECT(value),
+ "width-chars", 30,
+ "preview-widget", gtk_image_new(),
+ (char *)NULL);
+ g_signal_connect(G_OBJECT (value), "selection-changed",
+ G_CALLBACK(gnc_option_changed_widget_cb), option);
+ g_signal_connect(G_OBJECT (value), "selection-changed",
+ G_CALLBACK(gnc_image_option_selection_changed_cb), option);
+ g_signal_connect(G_OBJECT (value), "update-preview",
+ G_CALLBACK(gnc_image_option_update_preview_cb), option);
+ g_signal_connect_swapped(G_OBJECT (button), "clicked",
+ G_CALLBACK(gtk_file_chooser_unselect_all), value);
- gnc_option_set_widget (option, value);
- gnc_option_set_ui_value(option, FALSE);
+ gnc_option_set_widget (option, value);
+ gnc_option_set_ui_value(option, FALSE);
- gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
- gtk_box_pack_end(GTK_BOX(*enclosing), button, FALSE, FALSE, 0);
- gtk_box_pack_end(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
+ gtk_box_pack_end(GTK_BOX(*enclosing), button, FALSE, FALSE, 0);
+ gtk_box_pack_end(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
- gtk_widget_show(value);
- gtk_widget_show(label);
- gtk_widget_show(*enclosing);
- LEAVE("new widget = %p", value);
- return value;
+ gtk_widget_show(value);
+ gtk_widget_show(label);
+ gtk_widget_show(*enclosing);
+ LEAVE("new widget = %p", value);
+ return value;
}
static GtkWidget *
gnc_option_set_ui_widget_radiobutton (GNCOption *option, GtkBox *page_box,
- GtkTooltips *tooltips,
- char *name, char *documentation,
- /* Return values */
- GtkWidget **enclosing, gboolean *packed)
+ GtkTooltips *tooltips,
+ char *name, char *documentation,
+ /* Return values */
+ GtkWidget **enclosing, gboolean *packed)
{
- GtkWidget *value;
+ GtkWidget *value;
- *enclosing = gtk_hbox_new(FALSE, 5);
+ *enclosing = gtk_hbox_new(FALSE, 5);
- value = gnc_option_create_radiobutton_widget(name, option);
- gnc_option_set_widget (option, value);
+ value = gnc_option_create_radiobutton_widget(name, option);
+ gnc_option_set_widget (option, value);
- gnc_option_set_ui_value(option, FALSE);
- gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
- gtk_widget_show_all(*enclosing);
- return value;
+ gnc_option_set_ui_value(option, FALSE);
+ gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
+ gtk_widget_show_all(*enclosing);
+ return value;
}
static GtkWidget *
gnc_option_set_ui_widget_dateformat (GNCOption *option, GtkBox *page_box,
- GtkTooltips *tooltips,
- char *name, char *documentation,
- /* Return values */
- GtkWidget **enclosing, gboolean *packed)
+ GtkTooltips *tooltips,
+ char *name, char *documentation,
+ /* Return values */
+ GtkWidget **enclosing, gboolean *packed)
{
- *enclosing = gnc_date_format_new_with_label(name);
- gnc_option_set_widget (option, *enclosing);
+ *enclosing = gnc_date_format_new_with_label(name);
+ gnc_option_set_widget (option, *enclosing);
- gnc_option_set_ui_value(option, FALSE);
- g_signal_connect(G_OBJECT(*enclosing), "format_changed",
- G_CALLBACK(gnc_option_changed_option_cb), option);
- gtk_widget_show_all(*enclosing);
- return *enclosing;
+ gnc_option_set_ui_value(option, FALSE);
+ g_signal_connect(G_OBJECT(*enclosing), "format_changed",
+ G_CALLBACK(gnc_option_changed_option_cb), option);
+ gtk_widget_show_all(*enclosing);
+ return *enclosing;
}
static GtkWidget *
@@ -2160,30 +2185,30 @@
/* Return values */
GtkWidget **enclosing, gboolean *packed)
{
- GtkWidget *value;
- GtkWidget *label;
- gchar *colon_name;
+ GtkWidget *value;
+ GtkWidget *label;
+ gchar *colon_name;
- colon_name = g_strconcat(name, ":", NULL);
- label = gtk_label_new(colon_name);
- gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
- g_free(colon_name);
+ colon_name = g_strconcat(name, ":", NULL);
+ label = gtk_label_new(colon_name);
+ gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
+ g_free(colon_name);
- *enclosing = gtk_hbox_new(FALSE, 5);
+ *enclosing = gtk_hbox_new(FALSE, 5);
- value = gnc_option_create_budget_widget(option);
+ value = gnc_option_create_budget_widget(option);
- gnc_option_set_widget (option, value);
- gnc_option_set_ui_value(option, FALSE);
+ gnc_option_set_widget (option, value);
+ gnc_option_set_ui_value(option, FALSE);
- /* Maybe connect destroy handler for tree model here? */
- g_signal_connect(G_OBJECT(value), "changed",
- G_CALLBACK(gnc_option_changed_widget_cb), option);
+ /* Maybe connect destroy handler for tree model here? */
+ g_signal_connect(G_OBJECT(value), "changed",
+ G_CALLBACK(gnc_option_changed_widget_cb), option);
- gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
- gtk_widget_show_all(*enclosing);
- return value;
+ gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
+ gtk_widget_show_all(*enclosing);
+ return value;
}
/*************************
@@ -2201,371 +2226,372 @@
static gboolean
gnc_option_set_ui_value_boolean (GNCOption *option, gboolean use_default,
- GtkWidget *widget, SCM value)
+ GtkWidget *widget, SCM value)
{
- if (scm_is_bool(value))
- {
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),
- scm_is_true(value));
- return FALSE;
- }
- else
- return TRUE;
+ if (scm_is_bool(value))
+ {
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),
+ scm_is_true(value));
+ return FALSE;
+ }
+ else
+ return TRUE;
}
static gboolean
gnc_option_set_ui_value_string (GNCOption *option, gboolean use_default,
- GtkWidget *widget, SCM value)
+ GtkWidget *widget, SCM value)
{
- if (scm_is_string(value))
- {
- const gchar *string = scm_to_locale_string(value);
- gtk_entry_set_text(GTK_ENTRY(widget), string);
- return FALSE;
- }
- else
- return TRUE;
+ if (scm_is_string(value))
+ {
+ const gchar *string = scm_to_locale_string(value);
+ gtk_entry_set_text(GTK_ENTRY(widget), string);
+ return FALSE;
+ }
+ else
+ return TRUE;
}
static gboolean
gnc_option_set_ui_value_text (GNCOption *option, gboolean use_default,
- GObject *object, SCM value)
+ GObject *object, SCM value)
{
- GtkTextBuffer *buffer;
+ GtkTextBuffer *buffer;
- if (GTK_IS_TEXT_BUFFER(object))
- buffer = GTK_TEXT_BUFFER(object);
- else
- buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(object));
+ if (GTK_IS_TEXT_BUFFER(object))
+ buffer = GTK_TEXT_BUFFER(object);
+ else
+ buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(object));
- if (scm_is_string(value))
- {
- const gchar *string = scm_to_locale_string(value);
- gtk_text_buffer_set_text (buffer, string, scm_i_string_length(value));
- return FALSE;
- }
- else
- return TRUE;
+ if (scm_is_string(value))
+ {
+ const gchar *string = scm_to_locale_string(value);
+ gtk_text_buffer_set_text (buffer, string, scm_i_string_length(value));
+ return FALSE;
+ }
+ else
+ return TRUE;
}
static gboolean
gnc_option_set_ui_value_currency (GNCOption *option, gboolean use_default,
- GtkWidget *widget, SCM value)
+ GtkWidget *widget, SCM value)
{
- gnc_commodity *commodity;
+ gnc_commodity *commodity;
- commodity = gnc_scm_to_commodity (value);
- if (commodity)
- {
- gnc_currency_edit_set_currency(GNC_CURRENCY_EDIT(widget), commodity);
- return FALSE;
- }
- else
- return TRUE;
+ commodity = gnc_scm_to_commodity (value);
+ if (commodity)
+ {
+ gnc_currency_edit_set_currency(GNC_CURRENCY_EDIT(widget), commodity);
+ return FALSE;
+ }
+ else
+ return TRUE;
}
static gboolean
gnc_option_set_ui_value_commodity (GNCOption *option, gboolean use_default,
- GtkWidget *widget, SCM value)
+ GtkWidget *widget, SCM value)
{
- gnc_commodity *commodity;
+ gnc_commodity *commodity;
- commodity = gnc_scm_to_commodity (value);
- if (commodity)
- {
- gnc_general_select_set_selected(GNC_GENERAL_SELECT (widget), commodity);
- return FALSE;
- }
- else
- return TRUE;
+ commodity = gnc_scm_to_commodity (value);
+ if (commodity)
+ {
+ gnc_general_select_set_selected(GNC_GENERAL_SELECT (widget), commodity);
+ return FALSE;
+ }
+ else
+ return TRUE;
}
static gboolean
gnc_option_set_ui_value_multichoice (GNCOption *option, gboolean use_default,
- GtkWidget *widget, SCM value)
+ GtkWidget *widget, SCM value)
{
- int index;
+ int index;
- index = gnc_option_permissible_value_index(option, value);
- if (index < 0)
- return TRUE;
- else
- {
+ index = gnc_option_permissible_value_index(option, value);
+ if (index < 0)
+ return TRUE;
+ else
+ {
#ifdef GTKCOMBOBOX_TOOLTIPS_WORK
- gtk_combo_box_set_active(GTK_COMBO_BOX(widget), index);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(widget), index);
#else
- gtk_option_menu_set_history(GTK_OPTION_MENU(widget), index);
- g_object_set_data(G_OBJECT(widget), "gnc_multichoice_index",
- GINT_TO_POINTER(index));
+ gtk_option_menu_set_history(GTK_OPTION_MENU(widget), index);
+ g_object_set_data(G_OBJECT(widget), "gnc_multichoice_index",
+ GINT_TO_POINTER(index));
#endif
- return FALSE;
- }
+ return FALSE;
+ }
}
static gboolean
gnc_option_set_ui_value_date (GNCOption *option, gboolean use_default,
- GtkWidget *widget, SCM value)
+ GtkWidget *widget, SCM value)
{
- int index;
- char *date_option_type;
- char *symbol_str;
- gboolean bad_value = FALSE;
+ int index;
+ char *date_option_type;
+ char *symbol_str;
+ gboolean bad_value = FALSE;
- date_option_type = gnc_option_date_option_get_subtype(option);
+ date_option_type = gnc_option_date_option_get_subtype(option);
- if (scm_is_pair(value))
- {
- symbol_str = gnc_date_option_value_get_type (value);
- if (symbol_str)
+ if (scm_is_pair(value))
{
- if (safe_strcmp(symbol_str, "relative") == 0)
- {
- SCM relative = gnc_date_option_value_get_relative (value);
+ symbol_str = gnc_date_option_value_get_type (value);
+ if (symbol_str)
+ {
+ if (safe_strcmp(symbol_str, "relative") == 0)
+ {
+ SCM relative = gnc_date_option_value_get_relative (value);
- index = gnc_option_permissible_value_index(option, relative);
- if (safe_strcmp(date_option_type, "relative") == 0)
- {
+ index = gnc_option_permissible_value_index(option, relative);
+ if (safe_strcmp(date_option_type, "relative") == 0)
+ {
#ifdef GTKCOMBOBOX_TOOLTIPS_WORK
- gtk_combo_box_set_active(GTK_COMBO_BOX(widget), index);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(widget), index);
#else
- g_object_set_data(G_OBJECT(widget),
- "gnc_multichoice_index",
- GINT_TO_POINTER(index));
- gtk_option_menu_set_history(GTK_OPTION_MENU(widget), index);
+ g_object_set_data(G_OBJECT(widget),
+ "gnc_multichoice_index",
+ GINT_TO_POINTER(index));
+ gtk_option_menu_set_history(GTK_OPTION_MENU(widget), index);
#endif
- }
- else if (safe_strcmp(date_option_type, "both") == 0)
- {
- GList *widget_list;
- GtkWidget *rel_date_widget;
+ }
+ else if (safe_strcmp(date_option_type, "both") == 0)
+ {
+ GList *widget_list;
+ GtkWidget *rel_date_widget;
- widget_list = gtk_container_get_children(GTK_CONTAINER(widget));
- rel_date_widget = g_list_nth_data(widget_list,
- GNC_RD_WID_REL_WIDGET_POS);
- g_list_free(widget_list);
- gnc_date_option_set_select_method(option, FALSE, TRUE);
+ widget_list = gtk_container_get_children(GTK_CONTAINER(widget));
+ rel_date_widget = g_list_nth_data(widget_list,
+ GNC_RD_WID_REL_WIDGET_POS);
+ g_list_free(widget_list);
+ gnc_date_option_set_select_method(option, FALSE, TRUE);
#ifdef GTKCOMBOBOX_TOOLTIPS_WORK
- gtk_combo_box_set_active(GTK_COMBO_BOX(rel_date_widget), index);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(rel_date_widget), index);
#else
- g_object_set_data(G_OBJECT(rel_date_widget),
- "gnc_multichoice_index",
- GINT_TO_POINTER(index));
- gtk_option_menu_set_history(GTK_OPTION_MENU(rel_date_widget),
- index);
+ g_object_set_data(G_OBJECT(rel_date_widget),
+ "gnc_multichoice_index",
+ GINT_TO_POINTER(index));
+ gtk_option_menu_set_history(GTK_OPTION_MENU(rel_date_widget),
+ index);
#endif
- }
- else
- {
- bad_value = TRUE;
- }
- }
- else if (safe_strcmp(symbol_str, "absolute") == 0)
- {
- Timespec ts;
+ }
+ else
+ {
+ bad_value = TRUE;
+ }
+ }
+ else if (safe_strcmp(symbol_str, "absolute") == 0)
+ {
+ Timespec ts;
- ts = gnc_date_option_value_get_absolute (value);
+ ts = gnc_date_option_value_get_absolute (value);
- if (safe_strcmp(date_option_type, "absolute") == 0)
- {
- gnc_date_edit_set_time(GNC_DATE_EDIT(widget), ts.tv_sec);
- }
- else if (safe_strcmp(date_option_type, "both") == 0)
- {
- GList *widget_list;
- GtkWidget *ab_widget;
+ if (safe_strcmp(date_option_type, "absolute") == 0)
+ {
+ gnc_date_edit_set_time(GNC_DATE_EDIT(widget), ts.tv_sec);
+ }
+ else if (safe_strcmp(date_option_type, "both") == 0)
+ {
+ GList *widget_list;
+ GtkWidget *ab_widget;
- widget_list = gtk_container_get_children(GTK_CONTAINER(widget));
- ab_widget = g_list_nth_data(widget_list,
- GNC_RD_WID_AB_WIDGET_POS);
- g_list_free(widget_list);
- gnc_date_option_set_select_method(option, TRUE, TRUE);
- gnc_date_edit_set_time(GNC_DATE_EDIT(ab_widget), ts.tv_sec);
- }
- else
- {
- bad_value = TRUE;
- }
- }
- else
- {
- bad_value = TRUE;
- }
+ widget_list = gtk_container_get_children(GTK_CONTAINER(widget));
+ ab_widget = g_list_nth_data(widget_list,
+ GNC_RD_WID_AB_WIDGET_POS);
+ g_list_free(widget_list);
+ gnc_date_option_set_select_method(option, TRUE, TRUE);
+ gnc_date_edit_set_time(GNC_DATE_EDIT(ab_widget), ts.tv_sec);
+ }
+ else
+ {
+ bad_value = TRUE;
+ }
+ }
+ else
+ {
+ bad_value = TRUE;
+ }
- if (symbol_str)
- free(symbol_str);
+ if (symbol_str)
+ free(symbol_str);
+ }
}
- }
- else
- {
- bad_value = TRUE;
- }
+ else
+ {
+ bad_value = TRUE;
+ }
- if (date_option_type)
- free(date_option_type);
+ if (date_option_type)
+ free(date_option_type);
- return bad_value;
+ return bad_value;
}
static gboolean
gnc_option_set_ui_value_account_list (GNCOption *option, gboolean use_default,
- GtkWidget *widget, SCM value)
+ GtkWidget *widget, SCM value)
{
- GList *list;
+ GList *list;
- list = gnc_scm_list_to_glist(value);
+ list = gnc_scm_list_to_glist(value);
- gnc_tree_view_account_set_selected_accounts (GNC_TREE_VIEW_ACCOUNT(widget),
- list, TRUE);
+ gnc_tree_view_account_set_selected_accounts (GNC_TREE_VIEW_ACCOUNT(widget),
+ list, TRUE);
- g_list_free(list);
- return FALSE;
+ g_list_free(list);
+ return FALSE;
}
static gboolean
gnc_option_set_ui_value_account_sel (GNCOption *option, gboolean use_default,
- GtkWidget *widget, SCM value)
+ GtkWidget *widget, SCM value)
{
- Account *acc = NULL;
+ Account *acc = NULL;
- if (value != SCM_BOOL_F) {
- if (!SWIG_IsPointer(value))
- scm_misc_error("gnc_option_set_ui_value_account_sel",
- "Option Value not a wcp.", value);
+ if (value != SCM_BOOL_F)
+ {
+ if (!SWIG_IsPointer(value))
+ scm_misc_error("gnc_option_set_ui_value_account_sel",
+ "Option Value not a wcp.", value);
- acc = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p_Account"), 4, 0);
- }
+ acc = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p_Account"), 4, 0);
+ }
- //doesn't default because this function is called to set a specific account
- gnc_account_sel_set_account (GNC_ACCOUNT_SEL(widget), acc, FALSE);
+ //doesn't default because this function is called to set a specific account
+ gnc_account_sel_set_account (GNC_ACCOUNT_SEL(widget), acc, FALSE);
- return FALSE;
+ return FALSE;
}
static gboolean
gnc_option_set_ui_value_list (GNCOption *option, gboolean use_default,
- GtkWidget *widget, SCM value)
+ GtkWidget *widget, SCM value)
{
- GtkTreeSelection *selection;
- GtkTreePath *path;
- gint row;
+ GtkTreeSelection *selection;
+ GtkTreePath *path;
+ gint row;
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
- gtk_tree_selection_unselect_all(selection);
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
+ gtk_tree_selection_unselect_all(selection);
- while (scm_is_list(value) && !scm_is_null(value))
- {
- SCM item;
+ while (scm_is_list(value) && !scm_is_null(value))
+ {
+ SCM item;
- item = SCM_CAR(value);
- value = SCM_CDR(value);
+ item = SCM_CAR(value);
+ value = SCM_CDR(value);
- row = gnc_option_permissible_value_index(option, item);
- if (row < 0)
- {
- return TRUE;
+ row = gnc_option_permissible_value_index(option, item);
+ if (row < 0)
+ {
+ return TRUE;
+ }
+
+ path = gtk_tree_path_new_from_indices(row, -1);
+ gtk_tree_selection_select_path(selection, path);
+ gtk_tree_path_free(path);
}
- path = gtk_tree_path_new_from_indices(row, -1);
- gtk_tree_selection_select_path(selection, path);
- gtk_tree_path_free(path);
- }
+ if (!scm_is_list(value) || !scm_is_null(value))
+ return TRUE;
- if (!scm_is_list(value) || !scm_is_null(value))
- return TRUE;
-
- return FALSE;
+ return FALSE;
}
static gboolean
gnc_option_set_ui_value_number_range (GNCOption *option, gboolean use_default,
- GtkWidget *widget, SCM value)
+ GtkWidget *widget, SCM value)
{
- GtkSpinButton *spinner;
- gdouble d_value;;
+ GtkSpinButton *spinner;
+ gdouble d_value;;
- spinner = GTK_SPIN_BUTTON(widget);
+ spinner = GTK_SPIN_BUTTON(widget);
- if (scm_is_number(value))
- {
- d_value = scm_num2dbl(value, G_STRFUNC);
- gtk_spin_button_set_value(spinner, d_value);
- return FALSE;
- }
- else
- return TRUE;
+ if (scm_is_number(value))
+ {
+ d_value = scm_num2dbl(value, G_STRFUNC);
+ gtk_spin_button_set_value(spinner, d_value);
+ return FALSE;
+ }
+ else
+ return TRUE;
}
static gboolean
gnc_option_set_ui_value_color (GNCOption *option, gboolean use_default,
- GtkWidget *widget, SCM value)
+ GtkWidget *widget, SCM value)
{
- gdouble red, green, blue, alpha;
+ gdouble red, green, blue, alpha;
- if (gnc_option_get_color_info(option, use_default,
- &red, &green, &blue, &alpha))
- {
- GtkColorButton *color_button;
- GdkColor color;
+ if (gnc_option_get_color_info(option, use_default,
+ &red, &green, &blue, &alpha))
+ {
+ GtkColorButton *color_button;
+ GdkColor color;
- DEBUG("red %f, green %f, blue %f, alpha %f", red, green, blue, alpha);
- color_button = GTK_COLOR_BUTTON(widget);
+ DEBUG("red %f, green %f, blue %f, alpha %f", red, green, blue, alpha);
+ color_button = GTK_COLOR_BUTTON(widget);
- color.red = color_d_to_i16(red);
- color.green = color_d_to_i16(green);
- color.blue = color_d_to_i16(blue);
- gtk_color_button_set_color(color_button, &color);
- gtk_color_button_set_alpha(color_button, color_d_to_i16(alpha));
- return FALSE;
- }
+ color.red = color_d_to_i16(red);
+ color.green = color_d_to_i16(green);
+ color.blue = color_d_to_i16(blue);
+ gtk_color_button_set_color(color_button, &color);
+ gtk_color_button_set_alpha(color_button, color_d_to_i16(alpha));
+ return FALSE;
+ }
- LEAVE("TRUE");
- return TRUE;
+ LEAVE("TRUE");
+ return TRUE;
}
static gboolean
gnc_option_set_ui_value_font (GNCOption *option, gboolean use_default,
- GtkWidget *widget, SCM value)
+ GtkWidget *widget, SCM value)
{
- if (scm_is_string(value))
- {
- const gchar *string = scm_to_locale_string(value);
- if ((string != NULL) && (*string != '\0'))
+ if (scm_is_string(value))
{
- GtkFontButton *font_button = GTK_FONT_BUTTON(widget);
- gtk_font_button_set_font_name(font_button, string);
+ const gchar *string = scm_to_locale_string(value);
+ if ((string != NULL) && (*string != '\0'))
+ {
+ GtkFontButton *font_button = GTK_FONT_BUTTON(widget);
+ gtk_font_button_set_font_name(font_button, string);
+ }
+ return FALSE;
}
- return FALSE;
- }
- else
- return TRUE;
+ else
+ return TRUE;
}
static gboolean
gnc_option_set_ui_value_pixmap (GNCOption *option, gboolean use_default,
- GtkWidget *widget, SCM value)
+ GtkWidget *widget, SCM value)
{
- ENTER("option %p(%s)", option, gnc_option_name(option));
- if (scm_is_string(value))
- {
- const gchar *string = scm_to_locale_string(value);
+ ENTER("option %p(%s)", option, gnc_option_name(option));
+ if (scm_is_string(value))
+ {
+ const gchar *string = scm_to_locale_string(value);
- if (string && *string)
- {
- gchar *test;
- DEBUG("string = %s", string);
- gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(widget), string);
- test = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
- g_object_set_data_full(G_OBJECT(widget), LAST_SELECTION,
- g_strdup(string), g_free);
- DEBUG("Set %s, retrieved %s", string, test ? test : "(null)");
- gnc_image_option_update_preview_cb(GTK_FILE_CHOOSER(widget), option);
+ if (string && *string)
+ {
+ gchar *test;
+ DEBUG("string = %s", string);
+ gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(widget), string);
+ test = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
+ g_object_set_data_full(G_OBJECT(widget), LAST_SELECTION,
+ g_strdup(string), g_free);
+ DEBUG("Set %s, retrieved %s", string, test ? test : "(null)");
+ gnc_image_option_update_preview_cb(GTK_FILE_CHOOSER(widget), option);
+ }
+ LEAVE("FALSE");
+ return FALSE;
}
- LEAVE("FALSE");
- return FALSE;
- }
- LEAVE("TRUE");
- return TRUE;
+ LEAVE("TRUE");
+ return TRUE;
}
static gboolean gnc_option_set_ui_value_budget(
@@ -2577,7 +2603,8 @@
GtkTreeIter iter;
// if (!scm_is_null(value)) {
- if (value != SCM_BOOL_F) {
+ if (value != SCM_BOOL_F)
+ {
if (!SWIG_IsPointer(value))
scm_misc_error("gnc_option_set_ui_value_budget",
"Option Value not a wcp.", value);
@@ -2586,7 +2613,7 @@
cb = GTK_COMBO_BOX(widget);
tm = gtk_combo_box_get_model(cb);
if (gnc_tree_model_budget_get_iter_for_budget(tm, &iter, bgt))
- gtk_combo_box_set_active_iter(cb, &iter);
+ gtk_combo_box_set_active_iter(cb, &iter);
}
@@ -2596,64 +2623,64 @@
static gboolean
gnc_option_set_ui_value_radiobutton (GNCOption *option, gboolean use_default,
- GtkWidget *widget, SCM value)
+ GtkWidget *widget, SCM value)
{
- int index;
+ int index;
- index = gnc_option_permissible_value_index(option, value);
- if (index < 0)
- return TRUE;
- else
- {
- GtkWidget *box, *button;
- GList *list;
- int i;
- gpointer val;
+ index = gnc_option_permissible_value_index(option, value);
+ if (index < 0)
+ return TRUE;
+ else
+ {
+ GtkWidget *box, *button;
+ GList *list;
+ int i;
+ gpointer val;
- list = gtk_container_get_children (GTK_CONTAINER (widget));
- box = list->data;
- g_list_free(list);
+ list = gtk_container_get_children (GTK_CONTAINER (widget));
+ box = list->data;
+ g_list_free(list);
- list = gtk_container_get_children (GTK_CONTAINER (box));
- for (i = 0; i < index && list; i++)
- list = list->next;
- g_return_val_if_fail (list, TRUE);
+ list = gtk_container_get_children (GTK_CONTAINER (box));
+ for (i = 0; i < index && list; i++)
+ list = list->next;
+ g_return_val_if_fail (list, TRUE);
- button = list->data;
- g_list_free(list);
- val = g_object_get_data (G_OBJECT (button), "gnc_radiobutton_index");
- g_return_val_if_fail (GPOINTER_TO_INT (val) == index, TRUE);
+ button = list->data;
+ g_list_free(list);
+ val = g_object_get_data (G_OBJECT (button), "gnc_radiobutton_index");
+ g_return_val_if_fail (GPOINTER_TO_INT (val) == index, TRUE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
- // g_object_set_data(G_OBJECT(widget), "gnc_radiobutton_index",
- // GINT_TO_POINTER(index));
- return FALSE;
- }
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
+ // g_object_set_data(G_OBJECT(widget), "gnc_radiobutton_index",
+ // GINT_TO_POINTER(index));
+ return FALSE;
+ }
}
static gboolean
gnc_option_set_ui_value_dateformat (GNCOption *option, gboolean use_default,
- GtkWidget *widget, SCM value)
+ GtkWidget *widget, SCM value)
{
- GNCDateFormat * gdf = GNC_DATE_FORMAT(widget);
- QofDateFormat format;
- GNCDateMonthFormat months;
- gboolean years;
- char *custom;
+ GNCDateFormat * gdf = GNC_DATE_FORMAT(widget);
+ QofDateFormat format;
+ GNCDateMonthFormat months;
+ gboolean years;
+ char *custom;
- if (gnc_dateformat_option_value_parse(value, &format, &months, &years, &custom))
- return TRUE;
+ if (gnc_dateformat_option_value_parse(value, &format, &months, &years, &custom))
+ return TRUE;
- gnc_date_format_set_format(gdf, format);
- gnc_date_format_set_months(gdf, months);
- gnc_date_format_set_years(gdf, years);
- gnc_date_format_set_custom(gdf, custom);
- gnc_date_format_refresh(gdf);
+ gnc_date_format_set_format(gdf, format);
+ gnc_date_format_set_months(gdf, months);
+ gnc_date_format_set_years(gdf, years);
+ gnc_date_format_set_custom(gdf, custom);
+ gnc_date_format_refresh(gdf);
- if (custom)
- free(custom);
+ if (custom)
+ free(custom);
- return FALSE;
+ return FALSE;
}
/*************************
@@ -2673,168 +2700,168 @@
static SCM
gnc_option_get_ui_value_boolean (GNCOption *option, GtkWidget *widget)
{
- gboolean active;
+ gboolean active;
- active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
- return SCM_BOOL(active);
+ active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+ return SCM_BOOL(active);
}
static SCM
gnc_option_get_ui_value_string (GNCOption *option, GtkWidget *widget)
{
- char * string;
- SCM result;
+ char * string;
+ SCM result;
- string = gtk_editable_get_chars(GTK_EDITABLE(widget), 0, -1);
- result = scm_makfrom0str(string);
- g_free(string);
- return result;
+ string = gtk_editable_get_chars(GTK_EDITABLE(widget), 0, -1);
+ result = scm_makfrom0str(string);
+ g_free(string);
+ return result;
}
static SCM
gnc_option_get_ui_value_text (GNCOption *option, GtkWidget *widget)
{
- char * string;
- SCM result;
+ char * string;
+ SCM result;
- string = xxxgtk_textview_get_text (GTK_TEXT_VIEW(widget));
- result = scm_makfrom0str(string);
- g_free(string);
- return result;
+ string = xxxgtk_textview_get_text (GTK_TEXT_VIEW(widget));
+ result = scm_makfrom0str(string);
+ g_free(string);
+ return result;
}
static SCM
gnc_option_get_ui_value_currency (GNCOption *option, GtkWidget *widget)
{
- gnc_commodity *commodity;
+ gnc_commodity *commodity;
- commodity =
- gnc_currency_edit_get_currency(GNC_CURRENCY_EDIT(widget));
+ commodity =
+ gnc_currency_edit_get_currency(GNC_CURRENCY_EDIT(widget));
- return (gnc_commodity_to_scm (commodity));
+ return (gnc_commodity_to_scm (commodity));
}
static SCM
gnc_option_get_ui_value_commodity (GNCOption *option, GtkWidget *widget)
{
- gnc_commodity *commodity;
+ gnc_commodity *commodity;
- commodity =
- gnc_general_select_get_selected(GNC_GENERAL_SELECT(widget));
+ commodity =
+ gnc_general_select_get_selected(GNC_GENERAL_SELECT(widget));
- return (gnc_commodity_to_scm(commodity));
+ return (gnc_commodity_to_scm(commodity));
}
static SCM
gnc_option_get_ui_value_multichoice (GNCOption *option, GtkWidget *widget)
{
- int index;
+ int index;
#ifdef GTKCOMBOBOX_TOOLTIPS_WORK
- index = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+ index = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
#else
- {
- gpointer _index = g_object_get_data(G_OBJECT(widget), "gnc_multichoice_index");
- index = GPOINTER_TO_INT(_index);
- }
+ {
+ gpointer _index = g_object_get_data(G_OBJECT(widget), "gnc_multichoice_index");
+ index = GPOINTER_TO_INT(_index);
+ }
#endif
- return (gnc_option_permissible_value(option, index));
+ return (gnc_option_permissible_value(option, index));
}
static SCM
gnc_option_get_ui_value_date (GNCOption *option, GtkWidget *widget)
{
- int index;
- SCM type, val,result = SCM_UNDEFINED;
- char *subtype = gnc_option_date_option_get_subtype(option);
+ int index;
+ SCM type, val, result = SCM_UNDEFINED;
+ char *subtype = gnc_option_date_option_get_subtype(option);
- if(safe_strcmp(subtype, "relative") == 0)
- {
+ if (safe_strcmp(subtype, "relative") == 0)
+ {
#ifdef GTKCOMBOBOX_TOOLTIPS_WORK
- index = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+ index = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
#else
- index = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget),
- "gnc_multichoice_index"));
+ index = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget),
+ "gnc_multichoice_index"));
#endif
- type = scm_str2symbol("relative");
- val = gnc_option_permissible_value(option, index);
- result = scm_cons(type, val);
- }
- else if (safe_strcmp(subtype, "absolute") == 0)
- {
- Timespec ts;
+ type = scm_str2symbol("relative");
+ val = gnc_option_permissible_value(option, index);
+ result = scm_cons(type, val);
+ }
+ else if (safe_strcmp(subtype, "absolute") == 0)
+ {
+ Timespec ts;
- ts.tv_sec = gnc_date_edit_get_date(GNC_DATE_EDIT(widget));
- ts.tv_nsec = 0;
+ ts.tv_sec = gnc_date_edit_get_date(GNC_DATE_EDIT(widget));
+ ts.tv_nsec = 0;
- result = scm_cons(scm_str2symbol("absolute"), gnc_timespec2timepair(ts));
- }
- else if (safe_strcmp(subtype, "both") == 0)
- {
- Timespec ts;
- int index;
- SCM val;
- GList *widget_list;
- GtkWidget *ab_button, *rel_widget, *ab_widget;
+ result = scm_cons(scm_str2symbol("absolute"), gnc_timespec2timepair(ts));
+ }
+ else if (safe_strcmp(subtype, "both") == 0)
+ {
+ Timespec ts;
+ int index;
+ SCM val;
+ GList *widget_list;
+ GtkWidget *ab_button, *rel_widget, *ab_widget;
- widget_list = gtk_container_get_children(GTK_CONTAINER(widget));
- ab_button = g_list_nth_data(widget_list, GNC_RD_WID_AB_BUTTON_POS);
- ab_widget = g_list_nth_data(widget_list, GNC_RD_WID_AB_WIDGET_POS);
- rel_widget = g_list_nth_data(widget_list, GNC_RD_WID_REL_WIDGET_POS);
- g_list_free(widget_list);
+ widget_list = gtk_container_get_children(GTK_CONTAINER(widget));
+ ab_button = g_list_nth_data(widget_list, GNC_RD_WID_AB_BUTTON_POS);
+ ab_widget = g_list_nth_data(widget_list, GNC_RD_WID_AB_WIDGET_POS);
+ rel_widget = g_list_nth_data(widget_list, GNC_RD_WID_REL_WIDGET_POS);
+ g_list_free(widget_list);
- /* if it's an absolute date */
- if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ab_button)))
- {
- ts.tv_sec = gnc_date_edit_get_date(GNC_DATE_EDIT(ab_widget));
- ts.tv_nsec = 0;
- result = scm_cons(scm_str2symbol("absolute"), gnc_timespec2timepair(ts));
- }
- else
- {
+ /* if it's an absolute date */
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ab_button)))
+ {
+ ts.tv_sec = gnc_date_edit_get_date(GNC_DATE_EDIT(ab_widget));
+ ts.tv_nsec = 0;
+ result = scm_cons(scm_str2symbol("absolute"), gnc_timespec2timepair(ts));
+ }
+ else
+ {
#ifdef GTKCOMBOBOX_TOOLTIPS_WORK
- index = gtk_combo_box_get_active(GTK_COMBO_BOX(rel_widget));
+ index = gtk_combo_box_get_active(GTK_COMBO_BOX(rel_widget));
#else
- index = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(rel_widget),
- "gnc_multichoice_index"));
+ index = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(rel_widget),
+ "gnc_multichoice_index"));
#endif
- val = gnc_option_permissible_value(option, index);
- result = scm_cons(scm_str2symbol("relative"), val);
+ val = gnc_option_permissible_value(option, index);
+ result = scm_cons(scm_str2symbol("relative"), val);
+ }
}
- }
- g_free(subtype);
- return result;
+ g_free(subtype);
+ return result;
}
static SCM
gnc_option_get_ui_value_account_list (GNCOption *option, GtkWidget *widget)
{
- GncTreeViewAccount *tree;
- GList *list;
- SCM result;
+ GncTreeViewAccount *tree;
+ GList *list;
+ SCM result;
- tree = GNC_TREE_VIEW_ACCOUNT(widget);
- list = gnc_tree_view_account_get_selected_accounts (tree);
+ tree = GNC_TREE_VIEW_ACCOUNT(widget);
+ list = gnc_tree_view_account_get_selected_accounts (tree);
- /* handover list */
- result = gnc_glist_to_scm_list(list, "_p_Account");
- g_list_free(list);
- return result;
+ /* handover list */
+ result = gnc_glist_to_scm_list(list, "_p_Account");
+ g_list_free(list);
+ return result;
}
static SCM
gnc_option_get_ui_value_account_sel (GNCOption *option, GtkWidget *widget)
{
- GNCAccountSel *gas;
- Account* acc;
+ GNCAccountSel *gas;
+ Account* acc;
- gas = GNC_ACCOUNT_SEL(widget);
- acc = gnc_account_sel_get_account (gas);
+ gas = GNC_ACCOUNT_SEL(widget);
+ acc = gnc_account_sel_get_account (gas);
- if (!acc)
- return SCM_BOOL_F;
+ if (!acc)
+ return SCM_BOOL_F;
- return SWIG_NewPointerObj(acc, SWIG_TypeQuery("_p_Account"), 0);
+ return SWIG_NewPointerObj(acc, SWIG_TypeQuery("_p_Account"), 0);
}
static SCM
@@ -2860,238 +2887,277 @@
static SCM
gnc_option_get_ui_value_list (GNCOption *option, GtkWidget *widget)
{
- GtkTreeSelection *selection;
- GtkTreePath *path;
- SCM result;
- gboolean selected;
- gint num_rows;
- gint row;
+ GtkTreeSelection *selection;
+ GtkTreePath *path;
+ SCM result;
+ gboolean selected;
+ gint num_rows;
+ gint row;
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
- num_rows = gnc_option_num_permissible_values(option);
- result = scm_c_eval_string("'()");
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
+ num_rows = gnc_option_num_permissible_values(option);
+ result = scm_c_eval_string("'()");
- for (row = 0; row < num_rows; row++)
- {
- path = gtk_tree_path_new_from_indices(row, -1);
- selected = gtk_tree_selection_path_is_selected(selection, path);
- gtk_tree_path_free(path);
- if (selected)
- result = scm_cons(gnc_option_permissible_value(option, row), result);
- }
+ for (row = 0; row < num_rows; row++)
+ {
+ path = gtk_tree_path_new_from_indices(row, -1);
+ selected = gtk_tree_selection_path_is_selected(selection, path);
+ gtk_tree_path_free(path);
+ if (selected)
+ result = scm_cons(gnc_option_permissible_value(option, row), result);
+ }
- return (scm_reverse(result));
+ return (scm_reverse(result));
}
static SCM
gnc_option_get_ui_value_number_range (GNCOption *option, GtkWidget *widget)
{
- GtkSpinButton *spinner;
- gdouble value;
+ GtkSpinButton *spinner;
+ gdouble value;
- spinner = GTK_SPIN_BUTTON(widget);
+ spinner = GTK_SPIN_BUTTON(widget);
- value = gtk_spin_button_get_value(spinner);
+ value = gtk_spin_button_get_value(spinner);
- return (scm_make_real(value));
+ return (scm_make_real(value));
}
static SCM
gnc_option_get_ui_value_color (GNCOption *option, GtkWidget *widget)
{
- SCM result;
- GtkColorButton *color_button;
- GdkColor color;
- gdouble red, green, blue, alpha;
- gdouble scale;
+ SCM result;
+ GtkColorButton *color_button;
+ GdkColor color;
+ gdouble red, green, blue, alpha;
+ gdouble scale;
- ENTER("option %p(%s), widget %p",
- option, gnc_option_name(option), widget);
+ ENTER("option %p(%s), widget %p",
+ option, gnc_option_name(option), widget);
- color_button = GTK_COLOR_BUTTON(widget);
- gtk_color_button_get_color(color_button, &color);
- red = color_i16_to_d(color.red);
- green = color_i16_to_d(color.green);
- blue = color_i16_to_d(color.blue);
- alpha = color_i16_to_d(gtk_color_button_get_alpha(color_button));
+ color_button = GTK_COLOR_BUTTON(widget);
+ gtk_color_button_get_color(color_button, &color);
+ red = color_i16_to_d(color.red);
+ green = color_i16_to_d(color.green);
+ blue = color_i16_to_d(color.blue);
+ alpha = color_i16_to_d(gtk_color_button_get_alpha(color_button));
- scale = gnc_option_color_range(option);
+ scale = gnc_option_color_range(option);
- result = SCM_EOL;
- result = scm_cons(scm_make_real(alpha * scale), result);
- result = scm_cons(scm_make_real(blue * scale), result);
- result = scm_cons(scm_make_real(green * scale), result);
- result = scm_cons(scm_make_real(red * scale), result);
- return result;
+ result = SCM_EOL;
+ result = scm_cons(scm_make_real(alpha * scale), result);
+ result = scm_cons(scm_make_real(blue * scale), result);
+ result = scm_cons(scm_make_real(green * scale), result);
+ result = scm_cons(scm_make_real(red * scale), result);
+ return result;
}
static SCM
gnc_option_get_ui_value_font (GNCOption *option, GtkWidget *widget)
{
- GtkFontButton *font_button = GTK_FONT_BUTTON(widget);
- const gchar * string;
+ GtkFontButton *font_button = GTK_FONT_BUTTON(widget);
+ const gchar * string;
- string = gtk_font_button_get_font_name(font_button);
- return (scm_makfrom0str(string));
+ string = gtk_font_button_get_font_name(font_button);
+ return (scm_makfrom0str(string));
}
static SCM
gnc_option_get_ui_value_pixmap (GNCOption *option, GtkWidget *widget)
{
- gchar *string;
- SCM result;
+ gchar *string;
+ SCM result;
- string = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
- DEBUG("filename %s", string ? string : "(null)");
- result = scm_makfrom0str(string ? string : "");
- g_free(string);
- return result;
+ string = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
+ DEBUG("filename %s", string ? string : "(null)");
+ result = scm_makfrom0str(string ? string : "");
+ g_free(string);
+ return result;
}
static SCM
gnc_option_get_ui_value_radiobutton (GNCOption *option, GtkWidget *widget)
{
- gpointer _index;
- int index;
+ gpointer _index;
+ int index;
- _index = g_object_get_data(G_OBJECT(widget), "gnc_radiobutton_index");
- index = GPOINTER_TO_INT(_index);
+ _index = g_object_get_data(G_OBJECT(widget), "gnc_radiobutton_index");
+ index = GPOINTER_TO_INT(_index);
- return (gnc_option_permissible_value(option, index));
+ return (gnc_option_permissible_value(option, index));
}
static SCM
gnc_option_get_ui_value_dateformat (GNCOption *option, GtkWidget *widget)
{
- GNCDateFormat *gdf = GNC_DATE_FORMAT(widget);
- QofDateFormat format;
- GNCDateMonthFormat months;
- gboolean years;
- const char* custom;
+ GNCDateFormat *gdf = GNC_DATE_FORMAT(widget);
+ QofDateFormat format;
+ GNCDateMonthFormat months;
+ gboolean years;
+ const char* custom;
- format = gnc_date_format_get_format(gdf);
- months = gnc_date_format_get_months(gdf);
- years = gnc_date_format_get_years(gdf);
- custom = gnc_date_format_get_custom(gdf);
+ format = gnc_date_format_get_format(gdf);
+ months = gnc_date_format_get_months(gdf);
+ years = gnc_date_format_get_years(gdf);
+ custom = gnc_date_format_get_custom(gdf);
- return (gnc_dateformat_option_set_value(format, months, years, custom));
+ return (gnc_dateformat_option_set_value(format, months, years, custom));
}
/* INITIALIZATION */
static void gnc_options_initialize_options (void)
{
- static GNCOptionDef_t options[] = {
- { "boolean", gnc_option_set_ui_widget_boolean,
- gnc_option_set_ui_value_boolean, gnc_option_get_ui_value_boolean },
- { "string", gnc_option_set_ui_widget_string,
- gnc_option_set_ui_value_string, gnc_option_get_ui_value_string },
- { "text", gnc_option_set_ui_widget_text,
- (GNCOptionUISetValue)gnc_option_set_ui_value_text,
- gnc_option_get_ui_value_text },
- { "currency", gnc_option_set_ui_widget_currency,
- gnc_option_set_ui_value_currency, gnc_option_get_ui_value_currency },
- { "commodity", gnc_option_set_ui_widget_commodity,
- gnc_option_set_ui_value_commodity, gnc_option_get_ui_value_commodity },
- { "multichoice", gnc_option_set_ui_widget_multichoice,
- gnc_option_set_ui_value_multichoice, gnc_option_get_ui_value_multichoice },
- { "date", gnc_option_set_ui_widget_date,
- gnc_option_set_ui_value_date, gnc_option_get_ui_value_date },
- { "account-list", gnc_option_set_ui_widget_account_list,
- gnc_option_set_ui_value_account_list, gnc_option_get_ui_value_account_list },
- { "account-sel", gnc_option_set_ui_widget_account_sel,
- gnc_option_set_ui_value_account_sel, gnc_option_get_ui_value_account_sel },
- { "list", gnc_option_set_ui_widget_list,
- gnc_option_set_ui_value_list, gnc_option_get_ui_value_list },
- { "number-range", gnc_option_set_ui_widget_number_range,
- gnc_option_set_ui_value_number_range, gnc_option_get_ui_value_number_range },
- { "color", gnc_option_set_ui_widget_color,
- gnc_option_set_ui_value_color, gnc_option_get_ui_value_color },
- { "font", gnc_option_set_ui_widget_font,
- gnc_option_set_ui_value_font, gnc_option_get_ui_value_font },
- { "pixmap", gnc_option_set_ui_widget_pixmap,
- gnc_option_set_ui_value_pixmap, gnc_option_get_ui_value_pixmap },
- { "radiobutton", gnc_option_set_ui_widget_radiobutton,
- gnc_option_set_ui_value_radiobutton, gnc_option_get_ui_value_radiobutton },
- { "dateformat", gnc_option_set_ui_widget_dateformat,
- gnc_option_set_ui_value_dateformat, gnc_option_get_ui_value_dateformat },
- { "budget", gnc_option_set_ui_widget_budget,
- gnc_option_set_ui_value_budget, gnc_option_get_ui_value_budget },
- { NULL, NULL, NULL, NULL }
- };
- int i;
+ static GNCOptionDef_t options[] =
+ {
+ {
+ "boolean", gnc_option_set_ui_widget_boolean,
+ gnc_option_set_ui_value_boolean, gnc_option_get_ui_value_boolean
+ },
+ {
+ "string", gnc_option_set_ui_widget_string,
+ gnc_option_set_ui_value_string, gnc_option_get_ui_value_string
+ },
+ {
+ "text", gnc_option_set_ui_widget_text,
+ (GNCOptionUISetValue)gnc_option_set_ui_value_text,
+ gnc_option_get_ui_value_text
+ },
+ {
+ "currency", gnc_option_set_ui_widget_currency,
+ gnc_option_set_ui_value_currency, gnc_option_get_ui_value_currency
+ },
+ {
+ "commodity", gnc_option_set_ui_widget_commodity,
+ gnc_option_set_ui_value_commodity, gnc_option_get_ui_value_commodity
+ },
+ {
+ "multichoice", gnc_option_set_ui_widget_multichoice,
+ gnc_option_set_ui_value_multichoice, gnc_option_get_ui_value_multichoice
+ },
+ {
+ "date", gnc_option_set_ui_widget_date,
+ gnc_option_set_ui_value_date, gnc_option_get_ui_value_date
+ },
+ {
+ "account-list", gnc_option_set_ui_widget_account_list,
+ gnc_option_set_ui_value_account_list, gnc_option_get_ui_value_account_list
+ },
+ {
+ "account-sel", gnc_option_set_ui_widget_account_sel,
+ gnc_option_set_ui_value_account_sel, gnc_option_get_ui_value_account_sel
+ },
+ {
+ "list", gnc_option_set_ui_widget_list,
+ gnc_option_set_ui_value_list, gnc_option_get_ui_value_list
+ },
+ {
+ "number-range", gnc_option_set_ui_widget_number_range,
+ gnc_option_set_ui_value_number_range, gnc_option_get_ui_value_number_range
+ },
+ {
+ "color", gnc_option_set_ui_widget_color,
+ gnc_option_set_ui_value_color, gnc_option_get_ui_value_color
+ },
+ {
+ "font", gnc_option_set_ui_widget_font,
+ gnc_option_set_ui_value_font, gnc_option_get_ui_value_font
+ },
+ {
+ "pixmap", gnc_option_set_ui_widget_pixmap,
+ gnc_option_set_ui_value_pixmap, gnc_option_get_ui_value_pixmap
+ },
+ {
+ "radiobutton", gnc_option_set_ui_widget_radiobutton,
+ gnc_option_set_ui_value_radiobutton, gnc_option_get_ui_value_radiobutton
+ },
+ {
+ "dateformat", gnc_option_set_ui_widget_dateformat,
+ gnc_option_set_ui_value_dateformat, gnc_option_get_ui_value_dateformat
+ },
+ {
+ "budget", gnc_option_set_ui_widget_budget,
+ gnc_option_set_ui_value_budget, gnc_option_get_ui_value_budget
+ },
+ { NULL, NULL, NULL, NULL }
+ };
+ int i;
- for (i = 0; options[i].option_name; i++)
- gnc_options_ui_register_option (&(options[i]));
+ for (i = 0; options[i].option_name; i++)
+ gnc_options_ui_register_option (&(options[i]));
}
/* Register a new option type in the UI */
void gnc_options_ui_register_option (GNCOptionDef_t *option)
{
- g_return_if_fail (optionTable);
- g_return_if_fail (option);
+ g_return_if_fail (optionTable);
+ g_return_if_fail (option);
- /* FIXME: should protect against repeat insertion. */
- g_hash_table_insert (optionTable, (gpointer)(option->option_name), option);
+ /* FIXME: should protect against repeat insertion. */
+ g_hash_table_insert (optionTable, (gpointer)(option->option_name), option);
}
GNCOptionDef_t * gnc_options_ui_get_option (const char *option_name)
{
- GNCOptionDef_t *retval;
- g_return_val_if_fail (optionTable, NULL);
- g_return_val_if_fail (option_name, NULL);
+ GNCOptionDef_t *retval;
+ g_return_val_if_fail (optionTable, NULL);
+ g_return_val_if_fail (option_name, NULL);
- retval = g_hash_table_lookup (optionTable, option_name);
- if (!retval) {
- PERR("Option lookup for type '%s' failed!", option_name);
- }
- return retval;
+ retval = g_hash_table_lookup (optionTable, option_name);
+ if (!retval)
+ {
+ PERR("Option lookup for type '%s' failed!", option_name);
+ }
+ return retval;
}
void gnc_options_ui_initialize (void)
{
- SWIG_GetModule(NULL); /* Work-around for SWIG bug. */
- // gnc_options_register_stocks ();
- g_return_if_fail (optionTable == NULL);
- optionTable = g_hash_table_new (g_str_hash, g_str_equal);
+ SWIG_GetModule(NULL); /* Work-around for SWIG bug. */
+ // gnc_options_register_stocks ();
+ g_return_if_fail (optionTable == NULL);
+ optionTable = g_hash_table_new (g_str_hash, g_str_equal);
- /* add known types */
- gnc_options_initialize_options ();
+ /* add known types */
+ gnc_options_initialize_options ();
}
struct scm_cb
{
- SCM apply_cb;
- SCM close_cb;
+ SCM apply_cb;
+ SCM close_cb;
};
static void
scm_apply_cb (GNCOptionWin *win, gpointer data)
{
- struct scm_cb *cbdata = data;
+ struct scm_cb *cbdata = data;
- if (gnc_option_db_get_changed (win->option_db)) {
- gnc_option_db_commit (win->option_db);
- if (cbdata->apply_cb != SCM_BOOL_F) {
- scm_call_0 (cbdata->apply_cb);
+ if (gnc_option_db_get_changed (win->option_db))
+ {
+ gnc_option_db_commit (win->option_db);
+ if (cbdata->apply_cb != SCM_BOOL_F)
+ {
+ scm_call_0 (cbdata->apply_cb);
+ }
}
- }
}
static void
scm_close_cb (GNCOptionWin *win, gpointer data)
{
- struct scm_cb *cbdata = data;
+ struct scm_cb *cbdata = data;
- if (cbdata->close_cb != SCM_BOOL_F) {
- scm_call_0 (cbdata->close_cb);
- scm_gc_unprotect_object (cbdata->close_cb);
- }
+ if (cbdata->close_cb != SCM_BOOL_F)
+ {
+ scm_call_0 (cbdata->close_cb);
+ scm_gc_unprotect_object (cbdata->close_cb);
+ }
- if (cbdata->apply_cb != SCM_BOOL_F)
- scm_gc_unprotect_object (cbdata->apply_cb);
+ if (cbdata->apply_cb != SCM_BOOL_F)
+ scm_gc_unprotect_object (cbdata->apply_cb);
- g_free (cbdata);
+ g_free (cbdata);
}
/* Both apply_cb and close_cb should be scheme functions with 0 arguments.
@@ -3099,20 +3165,20 @@
*/
void
gnc_options_dialog_set_scm_callbacks (GNCOptionWin *win, SCM apply_cb,
- SCM close_cb)
+ SCM close_cb)
{
- struct scm_cb *cbdata;
+ struct scm_cb *cbdata;
- cbdata = g_new0 (struct scm_cb, 1);
- cbdata->apply_cb = apply_cb;
- cbdata->close_cb = close_cb;
+ cbdata = g_new0 (struct scm_cb, 1);
+ cbdata->apply_cb = apply_cb;
+ cbdata->close_cb = close_cb;
- if (apply_cb != SCM_BOOL_F)
- scm_gc_protect_object (cbdata->apply_cb);
+ if (apply_cb != SCM_BOOL_F)
+ scm_gc_protect_object (cbdata->apply_cb);
- if (close_cb != SCM_BOOL_F)
- scm_gc_protect_object (cbdata->close_cb);
+ if (close_cb != SCM_BOOL_F)
+ scm_gc_protect_object (cbdata->close_cb);
- gnc_options_dialog_set_apply_cb (win, scm_apply_cb, cbdata);
- gnc_options_dialog_set_close_cb (win, scm_close_cb, cbdata);
+ gnc_options_dialog_set_apply_cb (win, scm_apply_cb, cbdata);
+ gnc_options_dialog_set_close_cb (win, scm_close_cb, cbdata);
}
Modified: gnucash/trunk/src/gnome-utils/dialog-options.h
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-options.h 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/dialog-options.h 2010-03-02 21:42:11 UTC (rev 18791)
@@ -52,9 +52,9 @@
void gnc_options_dialog_set_close_cb(GNCOptionWin * win,
GNCOptionWinCallback thunk,
gpointer cb_data);
-
+
void gnc_options_dialog_set_global_help_cb(GNCOptionWinCallback thunk,
- gpointer cb_data);
+ gpointer cb_data);
void gnc_options_dialog_build_contents(GNCOptionWin *win,
GNCOptionDB *odb);
@@ -63,35 +63,36 @@
* References to these functions will be held until the close_cb is called
*/
void gnc_options_dialog_set_scm_callbacks (GNCOptionWin *win,
- SCM apply_cb,
- SCM close_cb);
+ SCM apply_cb,
+ SCM close_cb);
/*****************************************************************/
/* Option Registration */
/* Function to set the UI widget based upon the option */
typedef GtkWidget *
- (*GNCOptionUISetWidget) (GNCOption *option, GtkBox *page_box,
- GtkTooltips *tooltips,
- char *name, char *documentation,
- /* Return values */
- GtkWidget **enclosing, gboolean *packed);
+(*GNCOptionUISetWidget) (GNCOption *option, GtkBox *page_box,
+ GtkTooltips *tooltips,
+ char *name, char *documentation,
+ /* Return values */
+ GtkWidget **enclosing, gboolean *packed);
/* Function to set the UI Value for a particular option */
typedef gboolean
- (*GNCOptionUISetValue) (GNCOption *option, gboolean use_default,
- GtkWidget *widget, SCM value);
+(*GNCOptionUISetValue) (GNCOption *option, gboolean use_default,
+ GtkWidget *widget, SCM value);
/* Function to get the UI Value for a particular option */
typedef SCM
- (*GNCOptionUIGetValue) (GNCOption *option, GtkWidget *widget);
+(*GNCOptionUIGetValue) (GNCOption *option, GtkWidget *widget);
-typedef struct gnc_option_def {
- const char * option_name;
- GNCOptionUISetWidget set_widget;
- GNCOptionUISetValue set_value;
- GNCOptionUIGetValue get_value;
+typedef struct gnc_option_def
+{
+ const char * option_name;
+ GNCOptionUISetWidget set_widget;
+ GNCOptionUISetValue set_value;
+ GNCOptionUIGetValue get_value;
} GNCOptionDef_t;
Modified: gnucash/trunk/src/gnome-utils/dialog-preferences.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-preferences.c 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/dialog-preferences.c 2010-03-02 21:42:11 UTC (rev 18791)
@@ -92,20 +92,21 @@
/** This data structure holds the information for a single addition to
* the preferences dialog. */
-typedef struct addition_t {
- /** The relative name of the file where the glade data for this
- * addition can be found. */
- gchar *filename;
- /** The name of the widget within the glade data file that should be
- * added to the preferences dialog. This should point to a
- * GtkTable widget that has four columns. */
- gchar *widgetname;
- /** The name of the tab within the preferences dialog where these
- * widgets should be placed. */
- gchar *tabname;
- /** TRUE if this addition represents a full page in the preferences
- * dialog. FALSE if this page may be combined with other pages. */
- gboolean full_page;
+typedef struct addition_t
+{
+ /** The relative name of the file where the glade data for this
+ * addition can be found. */
+ gchar *filename;
+ /** The name of the widget within the glade data file that should be
+ * added to the preferences dialog. This should point to a
+ * GtkTable widget that has four columns. */
+ gchar *widgetname;
+ /** The name of the tab within the preferences dialog where these
+ * widgets should be placed. */
+ gchar *tabname;
+ /** TRUE if this addition represents a full page in the preferences
+ * dialog. FALSE if this page may be combined with other pages. */
+ gboolean full_page;
} addition;
/** A list of all additions that have been made to the preferences
@@ -127,22 +128,22 @@
static void
gnc_account_separator_prefs_cb (GConfEntry *unused, GtkWidget *dialog)
{
- GtkWidget *label;
- gchar *sample;
+ GtkWidget *label;
+ gchar *sample;
- label = gnc_glade_lookup_widget(dialog, "sample_account");
- /* Translators: Both %s will be the account separator character; the
- resulting string is a demonstration how the account separator
- character will look like. You can replace these three account
- names with other account names that are more suitable for your
- language - just keep in mind to have exactly two %s in your
- translation. */
- sample = g_strdup_printf(_("Income%sSalary%sTaxable"),
- gnc_get_account_separator_string(),
- gnc_get_account_separator_string());
- DEBUG(" Label set to '%s'", sample);
- gtk_label_set_text(GTK_LABEL(label), sample);
- g_free(sample);
+ label = gnc_glade_lookup_widget(dialog, "sample_account");
+ /* Translators: Both %s will be the account separator character; the
+ resulting string is a demonstration how the account separator
+ character will look like. You can replace these three account
+ names with other account names that are more suitable for your
+ language - just keep in mind to have exactly two %s in your
+ translation. */
+ sample = g_strdup_printf(_("Income%sSalary%sTaxable"),
+ gnc_get_account_separator_string(),
+ gnc_get_account_separator_string());
+ DEBUG(" Label set to '%s'", sample);
+ gtk_label_set_text(GTK_LABEL(label), sample);
+ g_free(sample);
}
@@ -159,9 +160,9 @@
*/
static gint
gnc_prefs_compare_addins (addition *a,
- addition *b)
+ addition *b)
{
- return g_utf8_collate(a->tabname, b->tabname);
+ return g_utf8_collate(a->tabname, b->tabname);
}
@@ -185,69 +186,78 @@
*/
static void
gnc_preferences_add_page_internal (const gchar *filename,
- const gchar *widgetname,
- const gchar *tabname,
- gboolean full_page)
+ const gchar *widgetname,
+ const gchar *tabname,
+ gboolean full_page)
{
- addition *add_in, *preexisting;
- gboolean error = FALSE;
- GSList *ptr;
+ addition *add_in, *preexisting;
+ gboolean error = FALSE;
+ GSList *ptr;
- ENTER("file %s, widget %s, tab %s full page %d",
- filename, widgetname, tabname, full_page);
+ ENTER("file %s, widget %s, tab %s full page %d",
+ filename, widgetname, tabname, full_page);
- add_in = g_malloc(sizeof(addition));
- if (add_in == NULL) {
- g_critical("Unable to allocate memory.\n");
- LEAVE("no memory");
- return;
- }
+ add_in = g_malloc(sizeof(addition));
+ if (add_in == NULL)
+ {
+ g_critical("Unable to allocate memory.\n");
+ LEAVE("no memory");
+ return;
+ }
- add_in->filename = g_strdup(filename);
- add_in->widgetname = g_strdup(widgetname);
- add_in->tabname = g_strdup(tabname);
- add_in->full_page = full_page;
- if (!add_in->filename || !add_in->widgetname || !add_in->tabname) {
- g_critical("Unable to allocate memory.\n");
- g_free(add_in->filename);
- g_free(add_in->widgetname);
- g_free(add_in->tabname);
- g_free(add_in);
- LEAVE("no memory");
- return;
- }
+ add_in->filename = g_strdup(filename);
+ add_in->widgetname = g_strdup(widgetname);
+ add_in->tabname = g_strdup(tabname);
+ add_in->full_page = full_page;
+ if (!add_in->filename || !add_in->widgetname || !add_in->tabname)
+ {
+ g_critical("Unable to allocate memory.\n");
+ g_free(add_in->filename);
+ g_free(add_in->widgetname);
+ g_free(add_in->tabname);
+ g_free(add_in);
+ LEAVE("no memory");
+ return;
+ }
- ptr = g_slist_find_custom(add_ins, add_in, (GCompareFunc)gnc_prefs_compare_addins);
- if (ptr) {
- /* problem? */
- preexisting = ptr->data;
+ ptr = g_slist_find_custom(add_ins, add_in, (GCompareFunc)gnc_prefs_compare_addins);
+ if (ptr)
+ {
+ /* problem? */
+ preexisting = ptr->data;
- if (preexisting->full_page) {
- g_warning("New tab %s(%s/%s/%s) conflicts with existing tab %s(%s/%s/full)",
- add_in->tabname, add_in->filename, add_in->widgetname,
- add_in->full_page ? "full" : "partial",
- preexisting->tabname, preexisting->filename, preexisting->widgetname);
- error = TRUE;
- } else if (add_in->full_page) {
- g_warning("New tab %s(%s/%s/%s) conflicts with existing tab %s(%s/%s/partial)",
- add_in->tabname, add_in->filename, add_in->widgetname,
- add_in->full_page ? "full" : "partial",
- preexisting->tabname, preexisting->filename, preexisting->widgetname);
- error = TRUE;
+ if (preexisting->full_page)
+ {
+ g_warning("New tab %s(%s/%s/%s) conflicts with existing tab %s(%s/%s/full)",
+ add_in->tabname, add_in->filename, add_in->widgetname,
+ add_in->full_page ? "full" : "partial",
+ preexisting->tabname, preexisting->filename, preexisting->widgetname);
+ error = TRUE;
+ }
+ else if (add_in->full_page)
+ {
+ g_warning("New tab %s(%s/%s/%s) conflicts with existing tab %s(%s/%s/partial)",
+ add_in->tabname, add_in->filename, add_in->widgetname,
+ add_in->full_page ? "full" : "partial",
+ preexisting->tabname, preexisting->filename, preexisting->widgetname);
+ error = TRUE;
+ }
}
- }
- if (error) {
- g_free(add_in->filename);
- g_free(add_in->widgetname);
- g_free(add_in->tabname);
- g_free(add_in);
- LEAVE("err");
- return;
- } else {
- add_ins = g_slist_append(add_ins, add_in);
- }
- LEAVE("");
+ if (error)
+ {
+ g_free(add_in->filename);
+ g_free(add_in->widgetname);
+ g_free(add_in->tabname);
+ g_free(add_in);
+ LEAVE("err");
+ return;
+ }
+ else
+ {
+ add_ins = g_slist_append(add_ins, add_in);
+ }
+ LEAVE("");
}
@@ -259,10 +269,10 @@
* of its own preferences. */
void
gnc_preferences_add_page (const gchar *filename,
- const gchar *widgetname,
- const gchar *tabname)
+ const gchar *widgetname,
+ const gchar *tabname)
{
- gnc_preferences_add_page_internal(filename, widgetname, tabname, TRUE);
+ gnc_preferences_add_page_internal(filename, widgetname, tabname, TRUE);
}
@@ -274,10 +284,10 @@
* "Data Import" page with QIF and other methods. */
void
gnc_preferences_add_to_page (const gchar *filename,
- const gchar *widgetname,
- const gchar *tabname)
+ const gchar *widgetname,
+ const gchar *tabname)
{
- gnc_preferences_add_page_internal(filename, widgetname, tabname, FALSE);
+ gnc_preferences_add_page_internal(filename, widgetname, tabname, FALSE);
}
/****************************************/
@@ -299,21 +309,22 @@
* callback from gconf. */
static void
gnc_prefs_build_widget_table (GladeXML *xml,
- GtkWidget *dialog)
+ GtkWidget *dialog)
{
- GHashTable *table;
- GList *interesting, *runner;
- const gchar *name;
- GtkWidget *widget;
+ GHashTable *table;
+ GList *interesting, *runner;
+ const gchar *name;
+ GtkWidget *widget;
- table = g_object_get_data(G_OBJECT(dialog), WIDGET_HASH);
- interesting = glade_xml_get_widget_prefix(xml, "gconf");
- for (runner = interesting; runner; runner = g_list_next(runner)) {
- widget = runner->data;
- name = gtk_widget_get_name(widget);
- g_hash_table_insert(table, (gchar *)name, widget);
- }
- g_list_free(interesting);
+ table = g_object_get_data(G_OBJECT(dialog), WIDGET_HASH);
+ interesting = glade_xml_get_widget_prefix(xml, "gconf");
+ for (runner = interesting; runner; runner = g_list_next(runner))
+ {
+ widget = runner->data;
+ name = gtk_widget_get_name(widget);
+ g_hash_table_insert(table, (gchar *)name, widget);
+ }
+ g_list_free(interesting);
}
/** This data structure is used while building the preferences dialog
@@ -321,46 +332,49 @@
* construction. It maintains state information between invocations
* of the function gnc_prefs_move_table_entry which is called via a
* foreach loop over each item in the table. */
-struct copy_data {
- /** The table being copied from. */
- GtkTable *table_from;
- /** The table being copied to. */
- GtkTable *table_to;
- /** The number of lines offset from the old table to the new
- * table. */
- gint row_offset;
+struct copy_data
+{
+ /** The table being copied from. */
+ GtkTable *table_from;
+ /** The table being copied to. */
+ GtkTable *table_to;
+ /** The number of lines offset from the old table to the new
+ * table. */
+ gint row_offset;
};
static GtkWidget *
gnc_prefs_find_page (GtkNotebook *notebook, const gchar *name)
{
- int n_pages, i;
- GtkWidget *child;
- const gchar *child_name;
+ int n_pages, i;
+ GtkWidget *child;
+ const gchar *child_name;
- g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), NULL);
- g_return_val_if_fail (name, NULL);
+ g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), NULL);
+ g_return_val_if_fail (name, NULL);
- ENTER("");
+ ENTER("");
- n_pages = gtk_notebook_get_n_pages (notebook);
+ n_pages = gtk_notebook_get_n_pages (notebook);
- for (i=0; i<n_pages; i++) {
- child = gtk_notebook_get_nth_page (notebook, i);
- g_return_val_if_fail (child, NULL);
+ for (i = 0; i < n_pages; i++)
+ {
+ child = gtk_notebook_get_nth_page (notebook, i);
+ g_return_val_if_fail (child, NULL);
- child_name = gtk_notebook_get_tab_label_text (notebook, child);
- g_return_val_if_fail (child_name, NULL);
+ child_name = gtk_notebook_get_tab_label_text (notebook, child);
+ g_return_val_if_fail (child_name, NULL);
- if (g_utf8_collate (name, child_name) == 0) {
- LEAVE("found at index: %d", i);
- return child;
+ if (g_utf8_collate (name, child_name) == 0)
+ {
+ LEAVE("found at index: %d", i);
+ return child;
+ }
}
- }
- LEAVE("not found");
- return NULL;
+ LEAVE("not found");
+ return NULL;
}
@@ -378,31 +392,31 @@
*/
static void
gnc_prefs_move_table_entry (GtkWidget *child,
- gpointer data)
+ gpointer data)
{
- struct copy_data *copydata = data;
- GtkAttachOptions x_opts, y_opts;
- gint bottom, top, left, right, x_pad, y_pad;
+ struct copy_data *copydata = data;
+ GtkAttachOptions x_opts, y_opts;
+ gint bottom, top, left, right, x_pad, y_pad;
- ENTER("child %p, copy data %p", child, data);
- gtk_container_child_get(GTK_CONTAINER(copydata->table_from), child,
- "bottom-attach", &bottom,
- "left-attach", &left,
- "right-attach", &right,
- "top-attach", &top,
- "x-options", &x_opts,
- "x-padding", &x_pad,
- "y-options", &y_opts,
- "y-padding", &y_pad,
- NULL);
+ ENTER("child %p, copy data %p", child, data);
+ gtk_container_child_get(GTK_CONTAINER(copydata->table_from), child,
+ "bottom-attach", &bottom,
+ "left-attach", &left,
+ "right-attach", &right,
+ "top-attach", &top,
+ "x-options", &x_opts,
+ "x-padding", &x_pad,
+ "y-options", &y_opts,
+ "y-padding", &y_pad,
+ NULL);
- gtk_widget_ref(child);
- gtk_container_remove(GTK_CONTAINER(copydata->table_from), child);
- gtk_table_attach(copydata->table_to, child, left, right,
- top + copydata->row_offset, bottom + copydata->row_offset,
- x_opts, y_opts, x_pad, y_pad);
- gtk_widget_unref(child);
- LEAVE(" ");
+ gtk_widget_ref(child);
+ gtk_container_remove(GTK_CONTAINER(copydata->table_from), child);
+ gtk_table_attach(copydata->table_to, child, left, right,
+ top + copydata->row_offset, bottom + copydata->row_offset,
+ x_opts, y_opts, x_pad, y_pad);
+ gtk_widget_unref(child);
+ LEAVE(" ");
}
@@ -419,134 +433,141 @@
*/
static void
gnc_preferences_build_page (gpointer data,
- gpointer user_data)
+ gpointer user_data)
{
- GladeXML *xml;
- GtkWidget *dialog, *existing_content, *new_content, *label;
- GtkNotebook *notebook;
- addition *add_in;
- struct copy_data copydata;
- gint rows, cols;
+ GladeXML *xml;
+ GtkWidget *dialog, *existing_content, *new_content, *label;
+ GtkNotebook *notebook;
+ addition *add_in;
+ struct copy_data copydata;
+ gint rows, cols;
- ENTER("add_in %p, dialog %p", data, user_data);
- add_in = (addition *)data;
- dialog = user_data;
+ ENTER("add_in %p, dialog %p", data, user_data);
+ add_in = (addition *)data;
+ dialog = user_data;
- DEBUG("Opening %s to get %s:", add_in->filename, add_in->widgetname);
- xml = gnc_glade_xml_new(add_in->filename, add_in->widgetname);
- new_content = glade_xml_get_widget(xml, add_in->widgetname);
- DEBUG("done");
+ DEBUG("Opening %s to get %s:", add_in->filename, add_in->widgetname);
+ xml = gnc_glade_xml_new(add_in->filename, add_in->widgetname);
+ new_content = glade_xml_get_widget(xml, add_in->widgetname);
+ DEBUG("done");
- /* Add to the list of interesting widgets */
- gnc_prefs_build_widget_table(xml, dialog);
+ /* Add to the list of interesting widgets */
+ gnc_prefs_build_widget_table(xml, dialog);
- /* Clean up the xml data structure when the dialog is destroyed */
- g_object_set_data_full(G_OBJECT(dialog), add_in->filename,
- xml, g_object_unref);
+ /* Clean up the xml data structure when the dialog is destroyed */
+ g_object_set_data_full(G_OBJECT(dialog), add_in->filename,
+ xml, g_object_unref);
- /* Connect the signals in this glade file. The dialog is passed in
- * so the the callback can find "interesting" widgets from other
- * glade files if necessary (via the WIDGET_HASH hash
- * table). Widgets from the same glade file can be found with the
- * usual gnc_glade_lookup_widget() function. */
- glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func,
- dialog);
+ /* Connect the signals in this glade file. The dialog is passed in
+ * so the the callback can find "interesting" widgets from other
+ * glade files if necessary (via the WIDGET_HASH hash
+ * table). Widgets from the same glade file can be found with the
+ * usual gnc_glade_lookup_widget() function. */
+ glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func,
+ dialog);
- /* Prepare for recursion */
- notebook = g_object_get_data(G_OBJECT(dialog), NOTEBOOK);
+ /* Prepare for recursion */
+ notebook = g_object_get_data(G_OBJECT(dialog), NOTEBOOK);
- if (add_in->full_page) {
- label = gtk_label_new(add_in->tabname);
- gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
- gtk_notebook_append_page(notebook, new_content, label);
- LEAVE("appended page");
- return;
- }
+ if (add_in->full_page)
+ {
+ label = gtk_label_new(add_in->tabname);
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
+ gtk_notebook_append_page(notebook, new_content, label);
+ LEAVE("appended page");
+ return;
+ }
- /* Copied tables must match the size of the main table */
- if (!GTK_IS_TABLE(new_content)) {
- g_critical("The object name %s in file %s is not a GtkTable. It cannot "
- "be added to the preferences dialog.",
- add_in->widgetname, add_in->filename);
- LEAVE("");
- return;
- }
- g_object_get(G_OBJECT(new_content), "n-columns", &cols, NULL);
- if (cols != 4) {
- g_critical("The table %s in file %s does not have four columns. It cannot "
- "be added to the preferences dialog.",
- add_in->widgetname, add_in->filename);
- LEAVE("");
- return;
- }
+ /* Copied tables must match the size of the main table */
+ if (!GTK_IS_TABLE(new_content))
+ {
+ g_critical("The object name %s in file %s is not a GtkTable. It cannot "
+ "be added to the preferences dialog.",
+ add_in->widgetname, add_in->filename);
+ LEAVE("");
+ return;
+ }
+ g_object_get(G_OBJECT(new_content), "n-columns", &cols, NULL);
+ if (cols != 4)
+ {
+ g_critical("The table %s in file %s does not have four columns. It cannot "
+ "be added to the preferences dialog.",
+ add_in->widgetname, add_in->filename);
+ LEAVE("");
+ return;
+ }
- /* Does the page exist or must we create it */
- existing_content = gnc_prefs_find_page(notebook, add_in->tabname);
+ /* Does the page exist or must we create it */
+ existing_content = gnc_prefs_find_page(notebook, add_in->tabname);
- if (!existing_content) {
- /* No existing content with this name. Create a blank page */
- rows = 0;
- existing_content = gtk_table_new(0, 4, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(existing_content), 6);
- label = gtk_label_new(add_in->tabname);
- gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
- gtk_notebook_append_page(notebook, existing_content, label);
- gtk_widget_show_all(existing_content);
- DEBUG("created new page %s, appended it", add_in->tabname);
- } else {
- g_object_get(G_OBJECT(existing_content), "n-rows", &rows, NULL);
- DEBUG("found existing page %s", add_in->tabname);
- }
+ if (!existing_content)
+ {
+ /* No existing content with this name. Create a blank page */
+ rows = 0;
+ existing_content = gtk_table_new(0, 4, FALSE);
+ gtk_container_set_border_width(GTK_CONTAINER(existing_content), 6);
+ label = gtk_label_new(add_in->tabname);
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
+ gtk_notebook_append_page(notebook, existing_content, label);
+ gtk_widget_show_all(existing_content);
+ DEBUG("created new page %s, appended it", add_in->tabname);
+ }
+ else
+ {
+ g_object_get(G_OBJECT(existing_content), "n-rows", &rows, NULL);
+ DEBUG("found existing page %s", add_in->tabname);
+ }
- /* Maybe add a spacer row */
- DEBUG("rows is %d", rows);
- if (rows > 0) {
- label = gtk_label_new("");
- gtk_widget_show(label);
- gtk_table_attach(GTK_TABLE(existing_content), label, 0, 1, rows, rows+1,
- GTK_FILL, GTK_FILL, 0, 0);
- rows++;
- }
+ /* Maybe add a spacer row */
+ DEBUG("rows is %d", rows);
+ if (rows > 0)
+ {
+ label = gtk_label_new("");
+ gtk_widget_show(label);
+ gtk_table_attach(GTK_TABLE(existing_content), label, 0, 1, rows, rows + 1,
+ GTK_FILL, GTK_FILL, 0, 0);
+ rows++;
+ }
- /* Now copy all the entries in the table */
- copydata.table_from = GTK_TABLE(new_content);
- copydata.table_to = GTK_TABLE(existing_content);
- copydata.row_offset = rows;
- gtk_container_foreach(GTK_CONTAINER(new_content), gnc_prefs_move_table_entry,
- ©data);
+ /* Now copy all the entries in the table */
+ copydata.table_from = GTK_TABLE(new_content);
+ copydata.table_to = GTK_TABLE(existing_content);
+ copydata.row_offset = rows;
+ gtk_container_foreach(GTK_CONTAINER(new_content), gnc_prefs_move_table_entry,
+ ©data);
- g_object_ref_sink(new_content);
- LEAVE("added content to page");
+ g_object_ref_sink(new_content);
+ LEAVE("added content to page");
}
static gint
tab_cmp (GtkWidget *page_a, GtkWidget *page_b, GtkNotebook *notebook)
{
- return g_utf8_collate (gtk_notebook_get_tab_label_text (notebook, page_a),
- gtk_notebook_get_tab_label_text (notebook, page_b));
+ return g_utf8_collate (gtk_notebook_get_tab_label_text (notebook, page_a),
+ gtk_notebook_get_tab_label_text (notebook, page_b));
}
static void
gnc_prefs_sort_pages (GtkNotebook *notebook)
{
- gint n_pages, i;
- GList *tabs=NULL, *iter=NULL;
+ gint n_pages, i;
+ GList *tabs = NULL, *iter = NULL;
- g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
+ g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
- /* gather tabs */
- n_pages = gtk_notebook_get_n_pages (notebook);
- for (i=n_pages-1; i>=0; i--)
- tabs = g_list_prepend (tabs, gtk_notebook_get_nth_page (notebook, i));
+ /* gather tabs */
+ n_pages = gtk_notebook_get_n_pages (notebook);
+ for (i = n_pages - 1; i >= 0; i--)
+ tabs = g_list_prepend (tabs, gtk_notebook_get_nth_page (notebook, i));
- /* sort in local copy */
- tabs = g_list_sort_with_data (tabs, (GCompareDataFunc) tab_cmp, notebook);
+ /* sort in local copy */
+ tabs = g_list_sort_with_data (tabs, (GCompareDataFunc) tab_cmp, notebook);
- /* reorder tabs */
- for (i=0, iter=tabs; iter; i++, iter=iter->next)
- gtk_notebook_reorder_child (notebook, GTK_WIDGET (iter->data), i);
+ /* reorder tabs */
+ for (i = 0, iter = tabs; iter; i++, iter = iter->next)
+ gtk_notebook_reorder_child (notebook, GTK_WIDGET (iter->data), i);
- g_list_free (tabs);
+ g_list_free (tabs);
}
@@ -568,14 +589,14 @@
gnc_prefs_font_button_user_cb (GtkFontButton *fb,
gpointer user_data)
{
- const gchar *key, *font;
+ const gchar *key, *font;
- g_return_if_fail(GTK_IS_FONT_BUTTON(fb));
- key = gtk_widget_get_name(GTK_WIDGET(fb)) + PREFIX_LEN;
- font = gtk_font_button_get_font_name(fb);
+ g_return_if_fail(GTK_IS_FONT_BUTTON(fb));
+ key = gtk_widget_get_name(GTK_WIDGET(fb)) + PREFIX_LEN;
+ font = gtk_font_button_get_font_name(fb);
- DEBUG("font_button %s set", key);
- gnc_gconf_set_string(key, NULL, font, NULL);
+ DEBUG("font_button %s set", key);
+ gnc_gconf_set_string(key, NULL, font, NULL);
}
@@ -592,20 +613,20 @@
gnc_prefs_font_button_gconf_cb (GtkFontButton *fb,
GConfEntry *entry)
{
- const gchar *font;
+ const gchar *font;
- g_return_if_fail(GTK_IS_FONT_BUTTON(fb));
- ENTER("fb %p, entry %p", fb, entry);
+ g_return_if_fail(GTK_IS_FONT_BUTTON(fb));
+ ENTER("fb %p, entry %p", fb, entry);
- font = gconf_value_get_string(entry->value);
+ font = gconf_value_get_string(entry->value);
- g_signal_handlers_block_by_func(G_OBJECT(fb),
- G_CALLBACK(gnc_prefs_font_button_user_cb),
- NULL);
- gtk_font_button_set_font_name(fb, font);
- g_signal_handlers_unblock_by_func(G_OBJECT(fb),
- G_CALLBACK(gnc_prefs_font_button_user_cb), NULL);
- LEAVE(" ");
+ g_signal_handlers_block_by_func(G_OBJECT(fb),
+ G_CALLBACK(gnc_prefs_font_button_user_cb),
+ NULL);
+ gtk_font_button_set_font_name(fb, font);
+ g_signal_handlers_unblock_by_func(G_OBJECT(fb),
+ G_CALLBACK(gnc_prefs_font_button_user_cb), NULL);
+ LEAVE(" ");
}
@@ -619,23 +640,23 @@
static void
gnc_prefs_connect_font_button (GtkFontButton *fb)
{
- const gchar *name;
- gchar *font;
+ const gchar *name;
+ gchar *font;
- g_return_if_fail(GTK_IS_FONT_BUTTON(fb));
+ g_return_if_fail(GTK_IS_FONT_BUTTON(fb));
- /* Lookup font name based upon gconf setting */
- name = gtk_widget_get_name(GTK_WIDGET(fb)) + PREFIX_LEN;
- font = gnc_gconf_get_string(name, NULL, NULL);
+ /* Lookup font name based upon gconf setting */
+ name = gtk_widget_get_name(GTK_WIDGET(fb)) + PREFIX_LEN;
+ font = gnc_gconf_get_string(name, NULL, NULL);
- gtk_font_button_set_font_name(fb, font);
- DEBUG(" font_button %s set", name);
- g_free(font);
+ gtk_font_button_set_font_name(fb, font);
+ DEBUG(" font_button %s set", name);
+ g_free(font);
- g_signal_connect(G_OBJECT(fb), "font_set",
- G_CALLBACK(gnc_prefs_font_button_user_cb), NULL);
+ g_signal_connect(G_OBJECT(fb), "font_set",
+ G_CALLBACK(gnc_prefs_font_button_user_cb), NULL);
- gtk_widget_show_all(GTK_WIDGET(fb));
+ gtk_widget_show_all(GTK_WIDGET(fb));
}
@@ -655,24 +676,24 @@
*/
static void
gnc_prefs_radio_button_user_cb (GtkRadioButton *button,
- gpointer user_data)
+ gpointer user_data)
{
- gchar *key, *button_name;
- gboolean active;
+ gchar *key, *button_name;
+ gboolean active;
- g_return_if_fail(GTK_IS_RADIO_BUTTON(button));
- active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
- if (!active)
- return;
+ g_return_if_fail(GTK_IS_RADIO_BUTTON(button));
+ active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
+ if (!active)
+ return;
- /* Copy the widget name and split into gconf key and button value parts */
- key = g_strdup(gtk_widget_get_name(GTK_WIDGET(button)) + PREFIX_LEN);
- button_name = strrchr(key, '/');
- *button_name++ = '\0';
+ /* Copy the widget name and split into gconf key and button value parts */
+ key = g_strdup(gtk_widget_get_name(GTK_WIDGET(button)) + PREFIX_LEN);
+ button_name = strrchr(key, '/');
+ *button_name++ = '\0';
- DEBUG("Radio button group %s now set to %s", key, button_name);
- gnc_gconf_set_string(key, NULL, button_name, NULL);
- g_free(key);
+ DEBUG("Radio button group %s now set to %s", key, button_name);
+ gnc_gconf_set_string(key, NULL, button_name, NULL);
+ g_free(key);
}
@@ -687,15 +708,15 @@
static void
gnc_prefs_radio_button_gconf_cb (GtkRadioButton *button)
{
- g_return_if_fail(GTK_IS_RADIO_BUTTON(button));
- ENTER("button %p", button);
- g_signal_handlers_block_by_func(G_OBJECT(button),
- G_CALLBACK(gnc_prefs_radio_button_user_cb),
- NULL);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
- g_signal_handlers_unblock_by_func(G_OBJECT(button),
- G_CALLBACK(gnc_prefs_radio_button_user_cb), NULL);
- LEAVE(" ");
+ g_return_if_fail(GTK_IS_RADIO_BUTTON(button));
+ ENTER("button %p", button);
+ g_signal_handlers_block_by_func(G_OBJECT(button),
+ G_CALLBACK(gnc_prefs_radio_button_user_cb),
+ NULL);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
+ g_signal_handlers_unblock_by_func(G_OBJECT(button),
+ G_CALLBACK(gnc_prefs_radio_button_user_cb), NULL);
+ LEAVE(" ");
}
@@ -711,36 +732,39 @@
static void
gnc_prefs_connect_radio_button (GtkRadioButton *button)
{
- gchar *key, *button_name, *value;
- gboolean active;
- GSList *group;
+ gchar *key, *button_name, *value;
+ gboolean active;
+ GSList *group;
- g_return_if_fail(GTK_IS_RADIO_BUTTON(button));
+ g_return_if_fail(GTK_IS_RADIO_BUTTON(button));
- /* Copy the widget name and split into gconf key and button name parts */
- key = g_strdup(gtk_widget_get_name(GTK_WIDGET(button)) + PREFIX_LEN);
- button_name = strrchr(key, '/');
- *button_name++ = '\0';
+ /* Copy the widget name and split into gconf key and button name parts */
+ key = g_strdup(gtk_widget_get_name(GTK_WIDGET(button)) + PREFIX_LEN);
+ button_name = strrchr(key, '/');
+ *button_name++ = '\0';
- /* Get the current value. */
- value = gnc_gconf_get_string(key, NULL, NULL);
- if (value) {
- active = (g_utf8_collate(value, button_name) == 0);
- } else {
- /* Sigh. There's no gconf default for this key. Use the first
- * button in the dialog, which is the last button in the list. */
- group = gtk_radio_button_get_group(button);
- active = (button != g_slist_nth_data(group, g_slist_length(group)));
- }
- DEBUG(" Radio set %s, button %s initially set to %d",
- key, button_name, active);
+ /* Get the current value. */
+ value = gnc_gconf_get_string(key, NULL, NULL);
+ if (value)
+ {
+ active = (g_utf8_collate(value, button_name) == 0);
+ }
+ else
+ {
+ /* Sigh. There's no gconf default for this key. Use the first
+ * button in the dialog, which is the last button in the list. */
+ group = gtk_radio_button_get_group(button);
+ active = (button != g_slist_nth_data(group, g_slist_length(group)));
+ }
+ DEBUG(" Radio set %s, button %s initially set to %d",
+ key, button_name, active);
- /* Wire up the button */
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active);
- g_signal_connect(G_OBJECT(button), "toggled",
- G_CALLBACK(gnc_prefs_radio_button_user_cb), NULL);
- g_free(value);
- g_free(key);
+ /* Wire up the button */
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active);
+ g_signal_connect(G_OBJECT(button), "toggled",
+ G_CALLBACK(gnc_prefs_radio_button_user_cb), NULL);
+ g_free(value);
+ g_free(key);
}
/**********/
@@ -757,16 +781,16 @@
*/
static void
gnc_prefs_check_button_user_cb (GtkCheckButton *button,
- gpointer user_data)
+ gpointer user_data)
{
- const gchar *name;
- gboolean active;
+ const gchar *name;
+ gboolean active;
- g_return_if_fail(GTK_IS_CHECK_BUTTON(button));
- name = gtk_widget_get_name(GTK_WIDGET(button)) + PREFIX_LEN;
- active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
- DEBUG("Checkbox %s now %sactive", name, active ? "" : "in");
- gnc_gconf_set_bool(name, NULL, active, NULL);
+ g_return_if_fail(GTK_IS_CHECK_BUTTON(button));
+ name = gtk_widget_get_name(GTK_WIDGET(button)) + PREFIX_LEN;
+ active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
+ DEBUG("Checkbox %s now %sactive", name, active ? "" : "in");
+ gnc_gconf_set_bool(name, NULL, active, NULL);
}
@@ -781,17 +805,17 @@
*/
static void
gnc_prefs_check_button_gconf_cb (GtkCheckButton *button,
- gboolean active)
+ gboolean active)
{
- g_return_if_fail(GTK_IS_CHECK_BUTTON(button));
- ENTER("button %p, active %d", button, active);
- g_signal_handlers_block_by_func(G_OBJECT(button),
- G_CALLBACK(gnc_prefs_check_button_user_cb),
- NULL);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active);
- g_signal_handlers_unblock_by_func(G_OBJECT(button),
- G_CALLBACK(gnc_prefs_check_button_user_cb), NULL);
- LEAVE(" ");
+ g_return_if_fail(GTK_IS_CHECK_BUTTON(button));
+ ENTER("button %p, active %d", button, active);
+ g_signal_handlers_block_by_func(G_OBJECT(button),
+ G_CALLBACK(gnc_prefs_check_button_user_cb),
+ NULL);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active);
+ g_signal_handlers_unblock_by_func(G_OBJECT(button),
+ G_CALLBACK(gnc_prefs_check_button_user_cb), NULL);
+ LEAVE(" ");
}
@@ -806,15 +830,15 @@
static void
gnc_prefs_connect_check_button (GtkCheckButton *button)
{
- const gchar *name;
- gboolean active;
+ const gchar *name;
+ gboolean active;
- name = gtk_widget_get_name(GTK_WIDGET(button)) + PREFIX_LEN;
- active = gnc_gconf_get_bool(name, NULL, NULL);
- DEBUG(" Checkbox %s initially %sactive", name, active ? "" : "in");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active);
- g_signal_connect(G_OBJECT(button), "toggled",
- G_CALLBACK(gnc_prefs_check_button_user_cb), NULL);
+ name = gtk_widget_get_name(GTK_WIDGET(button)) + PREFIX_LEN;
+ active = gnc_gconf_get_bool(name, NULL, NULL);
+ DEBUG(" Checkbox %s initially %sactive", name, active ? "" : "in");
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active);
+ g_signal_connect(G_OBJECT(button), "toggled",
+ G_CALLBACK(gnc_prefs_check_button_user_cb), NULL);
}
/**********/
@@ -831,16 +855,16 @@
*/
static void
gnc_prefs_spin_button_user_cb (GtkSpinButton *spin,
- gpointer user_data)
+ gpointer user_data)
{
- const gchar *name;
- gdouble value;
+ const gchar *name;
+ gdouble value;
- g_return_if_fail(GTK_IS_SPIN_BUTTON(spin));
- name = gtk_widget_get_name(GTK_WIDGET(spin)) + PREFIX_LEN;
- value = gtk_spin_button_get_value(spin);
- DEBUG(" Spin button %s has value %f", name, value);
- gnc_gconf_set_float(name, NULL, value, NULL);
+ g_return_if_fail(GTK_IS_SPIN_BUTTON(spin));
+ name = gtk_widget_get_name(GTK_WIDGET(spin)) + PREFIX_LEN;
+ value = gtk_spin_button_get_value(spin);
+ DEBUG(" Spin button %s has value %f", name, value);
+ gnc_gconf_set_float(name, NULL, value, NULL);
}
@@ -855,17 +879,17 @@
*/
static void
gnc_prefs_spin_button_gconf_cb (GtkSpinButton *spin,
- gdouble value)
+ gdouble value)
{
- g_return_if_fail(GTK_IS_SPIN_BUTTON(spin));
- ENTER("button %p, value %f", spin, value);
- g_signal_handlers_block_by_func(G_OBJECT(spin),
- G_CALLBACK(gnc_prefs_spin_button_user_cb),
- NULL);
- gtk_spin_button_set_value(spin, value);
- g_signal_handlers_unblock_by_func(G_OBJECT(spin),
- G_CALLBACK(gnc_prefs_spin_button_user_cb), NULL);
- LEAVE(" ");
+ g_return_if_fail(GTK_IS_SPIN_BUTTON(spin));
+ ENTER("button %p, value %f", spin, value);
+ g_signal_handlers_block_by_func(G_OBJECT(spin),
+ G_CALLBACK(gnc_prefs_spin_button_user_cb),
+ NULL);
+ gtk_spin_button_set_value(spin, value);
+ g_signal_handlers_unblock_by_func(G_OBJECT(spin),
+ G_CALLBACK(gnc_prefs_spin_button_user_cb), NULL);
+ LEAVE(" ");
}
@@ -880,16 +904,16 @@
static void
gnc_prefs_connect_spin_button (GtkSpinButton *spin)
{
- const gchar *name;
- gdouble value;
+ const gchar *name;
+ gdouble value;
- g_return_if_fail(GTK_IS_SPIN_BUTTON(spin));
- name = gtk_widget_get_name(GTK_WIDGET(spin)) + PREFIX_LEN;
- value = gnc_gconf_get_float(name, NULL, NULL);
- gtk_spin_button_set_value(spin, value);
- DEBUG(" Spin button %s has initial value %f", name, value);
- g_signal_connect(G_OBJECT(spin), "value-changed",
- G_CALLBACK(gnc_prefs_spin_button_user_cb), NULL);
+ g_return_if_fail(GTK_IS_SPIN_BUTTON(spin));
+ name = gtk_widget_get_name(GTK_WIDGET(spin)) + PREFIX_LEN;
+ value = gnc_gconf_get_float(name, NULL, NULL);
+ gtk_spin_button_set_value(spin, value);
+ DEBUG(" Spin button %s has initial value %f", name, value);
+ g_signal_connect(G_OBJECT(spin), "value-changed",
+ G_CALLBACK(gnc_prefs_spin_button_user_cb), NULL);
}
@@ -907,16 +931,16 @@
*/
static void
gnc_prefs_combo_box_user_cb (GtkComboBox *box,
- gpointer user_data)
+ gpointer user_data)
{
- const gchar *name;
- gint active;
+ const gchar *name;
+ gint active;
- g_return_if_fail(GTK_IS_COMBO_BOX(box));
- name = gtk_widget_get_name(GTK_WIDGET(box)) + PREFIX_LEN;
- active = gtk_combo_box_get_active(box);
- DEBUG("Combo box %s set to item %d", name, active);
- gnc_gconf_set_int(name, NULL, active, NULL);
+ g_return_if_fail(GTK_IS_COMBO_BOX(box));
+ name = gtk_widget_get_name(GTK_WIDGET(box)) + PREFIX_LEN;
+ active = gtk_combo_box_get_active(box);
+ DEBUG("Combo box %s set to item %d", name, active);
+ gnc_gconf_set_int(name, NULL, active, NULL);
}
@@ -931,17 +955,17 @@
*/
static void
gnc_prefs_combo_box_gconf_cb (GtkComboBox *box,
- gint value)
+ gint value)
{
- g_return_if_fail(GTK_IS_COMBO_BOX(box));
- ENTER("box %p, value %d", box, value);
- g_signal_handlers_block_by_func(G_OBJECT(box),
- G_CALLBACK(gnc_prefs_combo_box_user_cb),
- NULL);
- gtk_combo_box_set_active(box, value);
- g_signal_handlers_unblock_by_func(G_OBJECT(box),
- G_CALLBACK(gnc_prefs_combo_box_user_cb), NULL);
- LEAVE(" ");
+ g_return_if_fail(GTK_IS_COMBO_BOX(box));
+ ENTER("box %p, value %d", box, value);
+ g_signal_handlers_block_by_func(G_OBJECT(box),
+ G_CALLBACK(gnc_prefs_combo_box_user_cb),
+ NULL);
+ gtk_combo_box_set_active(box, value);
+ g_signal_handlers_unblock_by_func(G_OBJECT(box),
+ G_CALLBACK(gnc_prefs_combo_box_user_cb), NULL);
+ LEAVE(" ");
}
@@ -955,16 +979,16 @@
static void
gnc_prefs_connect_combo_box (GtkComboBox *box)
{
- const gchar *name;
- gint active;
+ const gchar *name;
+ gint active;
- g_return_if_fail(GTK_IS_COMBO_BOX(box));
- name = gtk_widget_get_name(GTK_WIDGET(box)) + PREFIX_LEN;
- active = gnc_gconf_get_int(name, NULL, NULL);
- gtk_combo_box_set_active(GTK_COMBO_BOX(box), active);
- DEBUG(" Combo box %s set to item %d", name, active);
- g_signal_connect(G_OBJECT(box), "changed",
- G_CALLBACK(gnc_prefs_combo_box_user_cb), NULL);
+ g_return_if_fail(GTK_IS_COMBO_BOX(box));
+ name = gtk_widget_get_name(GTK_WIDGET(box)) + PREFIX_LEN;
+ active = gnc_gconf_get_int(name, NULL, NULL);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(box), active);
+ DEBUG(" Combo box %s set to item %d", name, active);
+ g_signal_connect(G_OBJECT(box), "changed",
+ G_CALLBACK(gnc_prefs_combo_box_user_cb), NULL);
}
@@ -982,18 +1006,18 @@
*/
static void
gnc_prefs_currency_edit_user_cb (GNCCurrencyEdit *gce,
- gpointer user_data)
+ gpointer user_data)
{
- const gchar *name, *mnemonic;
- gnc_commodity *currency;
+ const gchar *name, *mnemonic;
+ gnc_commodity *currency;
- g_return_if_fail(GNC_IS_CURRENCY_EDIT(gce));
- name = gtk_widget_get_name(GTK_WIDGET(gce)) + PREFIX_LEN;
- currency = gnc_currency_edit_get_currency(gce);
- mnemonic = gnc_commodity_get_mnemonic(currency);
+ g_return_if_fail(GNC_IS_CURRENCY_EDIT(gce));
+ name = gtk_widget_get_name(GTK_WIDGET(gce)) + PREFIX_LEN;
+ currency = gnc_currency_edit_get_currency(gce);
+ mnemonic = gnc_commodity_get_mnemonic(currency);
- DEBUG("currency_edit %s set to %s", name, mnemonic);
- gnc_gconf_set_string(name, NULL, mnemonic, NULL);
+ DEBUG("currency_edit %s set to %s", name, mnemonic);
+ gnc_gconf_set_string(name, NULL, mnemonic, NULL);
}
@@ -1008,33 +1032,34 @@
*/
static void
gnc_prefs_currency_edit_gconf_cb (GNCCurrencyEdit *gce,
- GConfEntry *entry)
+ GConfEntry *entry)
{
- const gchar *mnemonic;
- gnc_commodity *currency;
+ const gchar *mnemonic;
+ gnc_commodity *currency;
- g_return_if_fail(GNC_IS_CURRENCY_EDIT(gce));
- ENTER("gce %p, entry %p", gce, entry);
+ g_return_if_fail(GNC_IS_CURRENCY_EDIT(gce));
+ ENTER("gce %p, entry %p", gce, entry);
- mnemonic = gconf_value_get_string(entry->value);
- DEBUG("gce %p, mnemonic %s", gce, mnemonic);
- currency = gnc_commodity_table_lookup(gnc_get_current_commodities(),
- GNC_COMMODITY_NS_CURRENCY, mnemonic);
+ mnemonic = gconf_value_get_string(entry->value);
+ DEBUG("gce %p, mnemonic %s", gce, mnemonic);
+ currency = gnc_commodity_table_lookup(gnc_get_current_commodities(),
+ GNC_COMMODITY_NS_CURRENCY, mnemonic);
- /* If there isn't any such commodity, get the default */
- if (!currency) {
- currency = gnc_locale_default_currency();
- DEBUG("gce %p, default currency mnemonic %s",
- gce, gnc_commodity_get_mnemonic(currency));
- }
+ /* If there isn't any such commodity, get the default */
+ if (!currency)
+ {
+ currency = gnc_locale_default_currency();
+ DEBUG("gce %p, default currency mnemonic %s",
+ gce, gnc_commodity_get_mnemonic(currency));
+ }
- g_signal_handlers_block_by_func(G_OBJECT(gce),
- G_CALLBACK(gnc_prefs_currency_edit_user_cb),
- NULL);
- gnc_currency_edit_set_currency(GNC_CURRENCY_EDIT(gce), currency);
- g_signal_handlers_unblock_by_func(G_OBJECT(gce),
- G_CALLBACK(gnc_prefs_currency_edit_user_cb), NULL);
- LEAVE(" ");
+ g_signal_handlers_block_by_func(G_OBJECT(gce),
+ G_CALLBACK(gnc_prefs_currency_edit_user_cb),
+ NULL);
+ gnc_currency_edit_set_currency(GNC_CURRENCY_EDIT(gce), currency);
+ g_signal_handlers_unblock_by_func(G_OBJECT(gce),
+ G_CALLBACK(gnc_prefs_currency_edit_user_cb), NULL);
+ LEAVE(" ");
}
@@ -1048,32 +1073,32 @@
static void
gnc_prefs_connect_currency_edit (GNCCurrencyEdit *gce)
{
- gnc_commodity *currency;
- const gchar *name;
- gchar *mnemonic;
+ gnc_commodity *currency;
+ const gchar *name;
+ gchar *mnemonic;
- g_return_if_fail(GNC_IS_CURRENCY_EDIT(gce));
+ g_return_if_fail(GNC_IS_CURRENCY_EDIT(gce));
- /* Lookup commodity based upon gconf setting */
- name = gtk_widget_get_name(GTK_WIDGET(gce)) + PREFIX_LEN;
- mnemonic = gnc_gconf_get_string(name, NULL, NULL);
- currency = gnc_commodity_table_lookup(gnc_get_current_commodities(),
- GNC_COMMODITY_NS_CURRENCY, mnemonic);
- if (mnemonic)
- g_free(mnemonic);
+ /* Lookup commodity based upon gconf setting */
+ name = gtk_widget_get_name(GTK_WIDGET(gce)) + PREFIX_LEN;
+ mnemonic = gnc_gconf_get_string(name, NULL, NULL);
+ currency = gnc_commodity_table_lookup(gnc_get_current_commodities(),
+ GNC_COMMODITY_NS_CURRENCY, mnemonic);
+ if (mnemonic)
+ g_free(mnemonic);
- /* If there isn't any such commodity, get the default */
- if (!currency)
- currency = gnc_locale_default_currency();
+ /* If there isn't any such commodity, get the default */
+ if (!currency)
+ currency = gnc_locale_default_currency();
- gnc_currency_edit_set_currency(GNC_CURRENCY_EDIT(gce), currency);
- DEBUG(" currency_edit %s set to %s", name,
- gnc_commodity_get_mnemonic(currency));
+ gnc_currency_edit_set_currency(GNC_CURRENCY_EDIT(gce), currency);
+ DEBUG(" currency_edit %s set to %s", name,
+ gnc_commodity_get_mnemonic(currency));
- g_signal_connect(G_OBJECT(gce), "changed",
- G_CALLBACK(gnc_prefs_currency_edit_user_cb), NULL);
+ g_signal_connect(G_OBJECT(gce), "changed",
+ G_CALLBACK(gnc_prefs_currency_edit_user_cb), NULL);
- gtk_widget_show_all(GTK_WIDGET(gce));
+ gtk_widget_show_all(GTK_WIDGET(gce));
}
@@ -1090,15 +1115,15 @@
*/
static void
gnc_prefs_entry_user_cb (GtkEntry *entry,
- gpointer user_data)
+ gpointer user_data)
{
- const gchar *name, *text;
+ const gchar *name, *text;
- g_return_if_fail(GTK_IS_ENTRY(entry));
- name = gtk_widget_get_name(GTK_WIDGET(entry)) + PREFIX_LEN;
- text = gtk_entry_get_text(entry);
- DEBUG("Entry %s set to '%s'", name, text);
- gnc_gconf_set_string(name, NULL, text, NULL);
+ g_return_if_fail(GTK_IS_ENTRY(entry));
+ name = gtk_widget_get_name(GTK_WIDGET(entry)) + PREFIX_LEN;
+ text = gtk_entry_get_text(entry);
+ DEBUG("Entry %s set to '%s'", name, text);
+ gnc_gconf_set_string(name, NULL, text, NULL);
}
@@ -1112,17 +1137,17 @@
*/
static void
gnc_prefs_entry_gconf_cb (GtkEntry *entry,
- const gchar *value)
+ const gchar *value)
{
- g_return_if_fail(GTK_IS_ENTRY(entry));
- ENTER("entry %p, value '%s'", entry, value);
- g_signal_handlers_block_by_func(G_OBJECT(entry),
- G_CALLBACK(gnc_prefs_entry_user_cb),
- NULL);
- gtk_entry_set_text(entry, value);
- g_signal_handlers_unblock_by_func(G_OBJECT(entry),
- G_CALLBACK(gnc_prefs_entry_user_cb), NULL);
- LEAVE(" ");
+ g_return_if_fail(GTK_IS_ENTRY(entry));
+ ENTER("entry %p, value '%s'", entry, value);
+ g_signal_handlers_block_by_func(G_OBJECT(entry),
+ G_CALLBACK(gnc_prefs_entry_user_cb),
+ NULL);
+ gtk_entry_set_text(entry, value);
+ g_signal_handlers_unblock_by_func(G_OBJECT(entry),
+ G_CALLBACK(gnc_prefs_entry_user_cb), NULL);
+ LEAVE(" ");
}
@@ -1136,17 +1161,17 @@
static void
gnc_prefs_connect_entry (GtkEntry *entry)
{
- const gchar *name;
- gchar *text;
+ const gchar *name;
+ gchar *text;
- g_return_if_fail(GTK_IS_ENTRY(entry));
- name = gtk_widget_get_name(GTK_WIDGET(entry)) + PREFIX_LEN;
- text = gnc_gconf_get_string(name, NULL, NULL);
- gtk_entry_set_text(GTK_ENTRY(entry), text ? text : "");
- DEBUG(" Entry %s set to '%s'", name?name:"(null)", text?text:"(null)");
- g_free(text);
- g_signal_connect(G_OBJECT(entry), "changed",
- G_CALLBACK(gnc_prefs_entry_user_cb), NULL);
+ g_return_if_fail(GTK_IS_ENTRY(entry));
+ name = gtk_widget_get_name(GTK_WIDGET(entry)) + PREFIX_LEN;
+ text = gnc_gconf_get_string(name, NULL, NULL);
+ gtk_entry_set_text(GTK_ENTRY(entry), text ? text : "");
+ DEBUG(" Entry %s set to '%s'", name ? name : "(null)", text ? text : "(null)");
+ g_free(text);
+ g_signal_connect(G_OBJECT(entry), "changed",
+ G_CALLBACK(gnc_prefs_entry_user_cb), NULL);
}
@@ -1164,16 +1189,16 @@
*/
static void
gnc_prefs_period_select_user_cb (GncPeriodSelect *period,
- gpointer user_data)
+ gpointer user_data)
{
- const gchar *name;
- gint active;
+ const gchar *name;
+ gint active;
- g_return_if_fail(GNC_IS_PERIOD_SELECT(period));
- name = gtk_widget_get_name(GTK_WIDGET(period)) + PREFIX_LEN;
- active = gnc_period_select_get_active(period);
- DEBUG("Period select %s set to item %d", name, active);
- gnc_gconf_set_int(name, NULL, active, NULL);
+ g_return_if_fail(GNC_IS_PERIOD_SELECT(period));
+ name = gtk_widget_get_name(GTK_WIDGET(period)) + PREFIX_LEN;
+ active = gnc_period_select_get_active(period);
+ DEBUG("Period select %s set to item %d", name, active);
+ gnc_gconf_set_int(name, NULL, active, NULL);
}
@@ -1188,17 +1213,17 @@
*/
static void
gnc_prefs_period_select_gconf_cb (GncPeriodSelect *period,
- gint value)
+ gint value)
{
- g_return_if_fail(GNC_IS_PERIOD_SELECT(period));
- ENTER("period %p, value %d", period, value);
- g_signal_handlers_block_by_func(G_OBJECT(period),
- G_CALLBACK(gnc_prefs_period_select_user_cb),
- NULL);
- gnc_period_select_set_active(period, value);
- g_signal_handlers_unblock_by_func(G_OBJECT(period),
- G_CALLBACK(gnc_prefs_period_select_user_cb), NULL);
- LEAVE(" ");
+ g_return_if_fail(GNC_IS_PERIOD_SELECT(period));
+ ENTER("period %p, value %d", period, value);
+ g_signal_handlers_block_by_func(G_OBJECT(period),
+ G_CALLBACK(gnc_prefs_period_select_user_cb),
+ NULL);
+ gnc_period_select_set_active(period, value);
+ g_signal_handlers_unblock_by_func(G_OBJECT(period),
+ G_CALLBACK(gnc_prefs_period_select_user_cb), NULL);
+ LEAVE(" ");
}
@@ -1212,30 +1237,31 @@
static void
gnc_prefs_connect_period_select (GncPeriodSelect *period)
{
- const gchar *name;
- gint active;
- QofBook *book;
- KvpFrame *book_frame;
- gint64 month, day;
- GDate fy_end;
+ const gchar *name;
+ gint active;
+ QofBook *book;
+ KvpFrame *book_frame;
+ gint64 month, day;
+ GDate fy_end;
- g_return_if_fail(GNC_IS_PERIOD_SELECT(period));
- book = gnc_get_current_book();
- book_frame = qof_book_get_slots(book);
- month = kvp_frame_get_gint64(book_frame, "/book/fyear_end/month");
- day = kvp_frame_get_gint64(book_frame, "/book/fyear_end/day");
- if (g_date_valid_dmy(day, month, 2005 /* not leap year */)) {
- g_date_clear(&fy_end, 1);
- g_date_set_dmy(&fy_end, day, month, G_DATE_BAD_YEAR);
- gnc_period_select_set_fy_end(period, &fy_end);
- }
+ g_return_if_fail(GNC_IS_PERIOD_SELECT(period));
+ book = gnc_get_current_book();
+ book_frame = qof_book_get_slots(book);
+ month = kvp_frame_get_gint64(book_frame, "/book/fyear_end/month");
+ day = kvp_frame_get_gint64(book_frame, "/book/fyear_end/day");
+ if (g_date_valid_dmy(day, month, 2005 /* not leap year */))
+ {
+ g_date_clear(&fy_end, 1);
+ g_date_set_dmy(&fy_end, day, month, G_DATE_BAD_YEAR);
+ gnc_period_select_set_fy_end(period, &fy_end);
+ }
- name = gtk_widget_get_name(GTK_WIDGET(period)) + PREFIX_LEN;
- active = gnc_gconf_get_int(name, NULL, NULL);
- gnc_period_select_set_active(period, active);
- DEBUG(" Period select %s set to item %d", name, active);
- g_signal_connect(G_OBJECT(period), "changed",
- G_CALLBACK(gnc_prefs_period_select_user_cb), NULL);
+ name = gtk_widget_get_name(GTK_WIDGET(period)) + PREFIX_LEN;
+ active = gnc_gconf_get_int(name, NULL, NULL);
+ gnc_period_select_set_active(period, active);
+ DEBUG(" Period select %s set to item %d", name, active);
+ g_signal_connect(G_OBJECT(period), "changed",
+ G_CALLBACK(gnc_prefs_period_select_user_cb), NULL);
}
@@ -1253,17 +1279,17 @@
*/
static void
gnc_prefs_date_edit_user_cb (GNCDateEdit *gde,
- gpointer user_data)
+ gpointer user_data)
{
- const gchar *name;
- time_t time;
+ const gchar *name;
+ time_t time;
- g_return_if_fail(GNC_IS_DATE_EDIT(gde));
- name = gtk_widget_get_name(GTK_WIDGET(gde)) + PREFIX_LEN;
- time = gnc_date_edit_get_date(gde);
+ g_return_if_fail(GNC_IS_DATE_EDIT(gde));
+ name = gtk_widget_get_name(GTK_WIDGET(gde)) + PREFIX_LEN;
+ time = gnc_date_edit_get_date(gde);
- DEBUG("date_edit %s set", name);
- gnc_gconf_set_int(name, NULL, time, NULL);
+ DEBUG("date_edit %s set", name);
+ gnc_gconf_set_int(name, NULL, time, NULL);
}
@@ -1278,22 +1304,22 @@
*/
static void
gnc_prefs_date_edit_gconf_cb (GNCDateEdit *gde,
- GConfEntry *entry)
+ GConfEntry *entry)
{
- time_t time;
+ time_t time;
- g_return_if_fail(GNC_IS_DATE_EDIT(gde));
- ENTER("gde %p, entry %p", gde, entry);
+ g_return_if_fail(GNC_IS_DATE_EDIT(gde));
+ ENTER("gde %p, entry %p", gde, entry);
- time = gconf_value_get_int(entry->value);
+ time = gconf_value_get_int(entry->value);
- g_signal_handlers_block_by_func(G_OBJECT(gde),
- G_CALLBACK(gnc_prefs_date_edit_user_cb),
- NULL);
- gnc_date_edit_set_time(GNC_DATE_EDIT(gde), time);
- g_signal_handlers_unblock_by_func(G_OBJECT(gde),
- G_CALLBACK(gnc_prefs_date_edit_user_cb), NULL);
- LEAVE(" ");
+ g_signal_handlers_block_by_func(G_OBJECT(gde),
+ G_CALLBACK(gnc_prefs_date_edit_user_cb),
+ NULL);
+ gnc_date_edit_set_time(GNC_DATE_EDIT(gde), time);
+ g_signal_handlers_unblock_by_func(G_OBJECT(gde),
+ G_CALLBACK(gnc_prefs_date_edit_user_cb), NULL);
+ LEAVE(" ");
}
@@ -1307,22 +1333,22 @@
static void
gnc_prefs_connect_date_edit (GNCDateEdit *gde)
{
- const gchar *name;
- time_t time;
+ const gchar *name;
+ time_t time;
- g_return_if_fail(GNC_IS_DATE_EDIT(gde));
+ g_return_if_fail(GNC_IS_DATE_EDIT(gde));
- /* Lookup commodity based upon gconf setting */
- name = gtk_widget_get_name(GTK_WIDGET(gde)) + PREFIX_LEN;
- time = gnc_gconf_get_int(name, NULL, NULL);
+ /* Lookup commodity based upon gconf setting */
+ name = gtk_widget_get_name(GTK_WIDGET(gde)) + PREFIX_LEN;
+ time = gnc_gconf_get_int(name, NULL, NULL);
- gnc_date_edit_set_time(GNC_DATE_EDIT(gde), time);
- DEBUG(" date_edit %s set", name);
+ gnc_date_edit_set_time(GNC_DATE_EDIT(gde), time);
+ DEBUG(" date_edit %s set", name);
- g_signal_connect(G_OBJECT(gde), "date_changed",
- G_CALLBACK(gnc_prefs_date_edit_user_cb), NULL);
+ g_signal_connect(G_OBJECT(gde), "date_changed",
+ G_CALLBACK(gnc_prefs_date_edit_user_cb), NULL);
- gtk_widget_show_all(GTK_WIDGET(gde));
+ gtk_widget_show_all(GTK_WIDGET(gde));
}
@@ -1346,24 +1372,25 @@
void
gnc_preferences_response_cb(GtkDialog *dialog, gint response, GtkDialog *unused)
{
- switch (response) {
- case GTK_RESPONSE_HELP:
- gnc_gnome_help(HF_HELP, HL_GLOBPREFS);
- break;
+ switch (response)
+ {
+ case GTK_RESPONSE_HELP:
+ gnc_gnome_help(HF_HELP, HL_GLOBPREFS);
+ break;
- default:
- gnc_save_window_size(GCONF_SECTION, GTK_WINDOW(dialog));
- gnc_unregister_gui_component_by_data(DIALOG_PREFERENCES_CM_CLASS,
- dialog);
- gnc_gconf_general_remove_cb(
- KEY_ACCOUNT_SEPARATOR,
- (GncGconfGeneralCb)gnc_account_separator_prefs_cb,
- dialog);
- gnc_gconf_remove_notification(G_OBJECT(dialog), NULL,
- DIALOG_PREFERENCES_CM_CLASS);
- gtk_widget_destroy(GTK_WIDGET(dialog));
- break;
- }
+ default:
+ gnc_save_window_size(GCONF_SECTION, GTK_WINDOW(dialog));
+ gnc_unregister_gui_component_by_data(DIALOG_PREFERENCES_CM_CLASS,
+ dialog);
+ gnc_gconf_general_remove_cb(
+ KEY_ACCOUNT_SEPARATOR,
+ (GncGconfGeneralCb)gnc_account_separator_prefs_cb,
+ dialog);
+ gnc_gconf_remove_notification(G_OBJECT(dialog), NULL,
+ DIALOG_PREFERENCES_CM_CLASS);
+ gtk_widget_destroy(GTK_WIDGET(dialog));
+ break;
+ }
}
/********************/
@@ -1384,42 +1411,61 @@
*/
static void
gnc_prefs_connect_one (const gchar *name,
- GtkWidget *widget,
- gpointer user_data)
+ GtkWidget *widget,
+ gpointer user_data)
{
- /* These tests must be ordered from more specific widget to less
- * specific widget. Test custom widgets first */
- if (GNC_IS_CURRENCY_EDIT(widget)) { /* must be tested before combo_box */
- DEBUG(" %s - currency_edit", name);
- gnc_prefs_connect_currency_edit(GNC_CURRENCY_EDIT(widget));
- } else if (GNC_IS_PERIOD_SELECT(widget)) {
- DEBUG(" %s - period_Select", name);
- gnc_prefs_connect_period_select(GNC_PERIOD_SELECT(widget));
- } else if (GNC_IS_DATE_EDIT(widget)) {
- DEBUG(" %s - date_edit", name);
- gnc_prefs_connect_date_edit(GNC_DATE_EDIT(widget));
- } else if (GTK_IS_FONT_BUTTON(widget)) {
- DEBUG(" %s - entry", name);
- gnc_prefs_connect_font_button(GTK_FONT_BUTTON(widget));
- } else if (GTK_IS_RADIO_BUTTON(widget)) {
- DEBUG(" %s - radio button", name);
- gnc_prefs_connect_radio_button(GTK_RADIO_BUTTON(widget));
- } else if (GTK_IS_CHECK_BUTTON(widget)) {
- DEBUG(" %s - check button", name);
- gnc_prefs_connect_check_button(GTK_CHECK_BUTTON(widget));
- } else if (GTK_IS_SPIN_BUTTON(widget)) {
- DEBUG(" %s - spin button", name);
- gnc_prefs_connect_spin_button(GTK_SPIN_BUTTON(widget));
- } else if (GTK_IS_COMBO_BOX(widget)) {
- DEBUG(" %s - combo box", name);
- gnc_prefs_connect_combo_box(GTK_COMBO_BOX(widget));
- } else if (GTK_IS_ENTRY(widget)) {
- DEBUG(" %s - entry", name);
- gnc_prefs_connect_entry(GTK_ENTRY(widget));
- } else {
- DEBUG(" %s - unsupported %s", name,
- G_OBJECT_TYPE_NAME(G_OBJECT(widget)));
- }
+ /* These tests must be ordered from more specific widget to less
+ * specific widget. Test custom widgets first */
+ if (GNC_IS_CURRENCY_EDIT(widget)) /* must be tested before combo_box */
+ {
+ DEBUG(" %s - currency_edit", name);
+ gnc_prefs_connect_currency_edit(GNC_CURRENCY_EDIT(widget));
+ }
+ else if (GNC_IS_PERIOD_SELECT(widget))
+ {
+ DEBUG(" %s - period_Select", name);
+ gnc_prefs_connect_period_select(GNC_PERIOD_SELECT(widget));
+ }
+ else if (GNC_IS_DATE_EDIT(widget))
+ {
+ DEBUG(" %s - date_edit", name);
+ gnc_prefs_connect_date_edit(GNC_DATE_EDIT(widget));
+ }
+ else if (GTK_IS_FONT_BUTTON(widget))
+ {
+ DEBUG(" %s - entry", name);
+ gnc_prefs_connect_font_button(GTK_FONT_BUTTON(widget));
+ }
+ else if (GTK_IS_RADIO_BUTTON(widget))
+ {
+ DEBUG(" %s - radio button", name);
+ gnc_prefs_connect_radio_button(GTK_RADIO_BUTTON(widget));
+ }
+ else if (GTK_IS_CHECK_BUTTON(widget))
+ {
+ DEBUG(" %s - check button", name);
+ gnc_prefs_connect_check_button(GTK_CHECK_BUTTON(widget));
+ }
+ else if (GTK_IS_SPIN_BUTTON(widget))
+ {
+ DEBUG(" %s - spin button", name);
+ gnc_prefs_connect_spin_button(GTK_SPIN_BUTTON(widget));
+ }
+ else if (GTK_IS_COMBO_BOX(widget))
+ {
+ DEBUG(" %s - combo box", name);
+ gnc_prefs_connect_combo_box(GTK_COMBO_BOX(widget));
+ }
+ else if (GTK_IS_ENTRY(widget))
+ {
+ DEBUG(" %s - entry", name);
+ gnc_prefs_connect_entry(GTK_ENTRY(widget));
+ }
+ else
+ {
+ DEBUG(" %s - unsupported %s", name,
+ G_OBJECT_TYPE_NAME(G_OBJECT(widget)));
+ }
}
@@ -1437,64 +1483,64 @@
static GtkWidget *
gnc_preferences_dialog_create(void)
{
- GladeXML *xml;
- GtkWidget *dialog, *notebook, *label;
- GHashTable *table;
- GDate* gdate;
- gchar buf[128];
- gnc_commodity *locale_currency;
- const gchar *currency_name;
+ GladeXML *xml;
+ GtkWidget *dialog, *notebook, *label;
+ GHashTable *table;
+ GDate* gdate;
+ gchar buf[128];
+ gnc_commodity *locale_currency;
+ const gchar *currency_name;
- ENTER("");
- DEBUG("Opening preferences.glade:");
- xml = gnc_glade_xml_new(GLADE_FILENAME, "GnuCash Preferences");
- dialog = glade_xml_get_widget(xml, "GnuCash Preferences");
- DEBUG("autoconnect");
- glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func,
- dialog);
+ ENTER("");
+ DEBUG("Opening preferences.glade:");
+ xml = gnc_glade_xml_new(GLADE_FILENAME, "GnuCash Preferences");
+ dialog = glade_xml_get_widget(xml, "GnuCash Preferences");
+ DEBUG("autoconnect");
+ glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func,
+ dialog);
- /* Clean up the xml data structure when the dialog is destroyed */
- g_object_set_data_full(G_OBJECT(dialog), GLADE_FILENAME,
- xml, g_object_unref);
- DEBUG("done");
+ /* Clean up the xml data structure when the dialog is destroyed */
+ g_object_set_data_full(G_OBJECT(dialog), GLADE_FILENAME,
+ xml, g_object_unref);
+ DEBUG("done");
- notebook = glade_xml_get_widget(xml, "notebook1");
- table = g_hash_table_new(g_str_hash, g_str_equal);
- g_object_set_data(G_OBJECT(dialog), NOTEBOOK, notebook);
- g_object_set_data_full(G_OBJECT(dialog), WIDGET_HASH,
- table, (GDestroyNotify)g_hash_table_destroy);
+ notebook = glade_xml_get_widget(xml, "notebook1");
+ table = g_hash_table_new(g_str_hash, g_str_equal);
+ g_object_set_data(G_OBJECT(dialog), NOTEBOOK, notebook);
+ g_object_set_data_full(G_OBJECT(dialog), WIDGET_HASH,
+ table, (GDestroyNotify)g_hash_table_destroy);
- /* Add to the list of interesting widgets */
- gnc_prefs_build_widget_table(xml, dialog);
+ /* Add to the list of interesting widgets */
+ gnc_prefs_build_widget_table(xml, dialog);
- g_slist_foreach(add_ins, gnc_preferences_build_page, dialog);
+ g_slist_foreach(add_ins, gnc_preferences_build_page, dialog);
- /* Sort tabs alphabetically */
- gnc_prefs_sort_pages(GTK_NOTEBOOK(notebook));
- gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
+ /* Sort tabs alphabetically */
+ gnc_prefs_sort_pages(GTK_NOTEBOOK(notebook));
+ gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
- DEBUG("We have the following interesting widgets:");
- g_hash_table_foreach(table, (GHFunc)gnc_prefs_connect_one, dialog);
- DEBUG("Done with interesting widgets.");
+ DEBUG("We have the following interesting widgets:");
+ g_hash_table_foreach(table, (GHFunc)gnc_prefs_connect_one, dialog);
+ DEBUG("Done with interesting widgets.");
- /* Other stuff */
- gdate = g_date_new_dmy(31, G_DATE_JULY, 2005);
- g_date_strftime(buf, sizeof(buf), "%x", gdate);
- label = glade_xml_get_widget(xml, "locale_date_sample");
- gtk_label_set_text(GTK_LABEL(label), buf);
- g_date_free(gdate);
+ /* Other stuff */
+ gdate = g_date_new_dmy(31, G_DATE_JULY, 2005);
+ g_date_strftime(buf, sizeof(buf), "%x", gdate);
+ label = glade_xml_get_widget(xml, "locale_date_sample");
+ gtk_label_set_text(GTK_LABEL(label), buf);
+ g_date_free(gdate);
- locale_currency = gnc_locale_default_currency ();
- currency_name = gnc_commodity_get_printname(locale_currency);
- label = glade_xml_get_widget(xml, "locale_currency");
- gtk_label_set_label(GTK_LABEL(label), currency_name);
- label = glade_xml_get_widget(xml, "locale_currency2");
- gtk_label_set_label(GTK_LABEL(label), currency_name);
+ locale_currency = gnc_locale_default_currency ();
+ currency_name = gnc_commodity_get_printname(locale_currency);
+ label = glade_xml_get_widget(xml, "locale_currency");
+ gtk_label_set_label(GTK_LABEL(label), currency_name);
+ label = glade_xml_get_widget(xml, "locale_currency2");
+ gtk_label_set_label(GTK_LABEL(label), currency_name);
- gnc_account_separator_prefs_cb(NULL, dialog);
+ gnc_account_separator_prefs_cb(NULL, dialog);
- LEAVE("dialog %p", dialog);
- return dialog;
+ LEAVE("dialog %p", dialog);
+ return dialog;
}
@@ -1525,13 +1571,13 @@
*/
static gboolean
gnc_prefs_nearest_match (gpointer key,
- gpointer value,
- gpointer user_data)
+ gpointer value,
+ gpointer user_data)
{
- const gchar *widget_name = key;
- const gchar *gconf_name = user_data;
+ const gchar *widget_name = key;
+ const gchar *gconf_name = user_data;
- return (strncmp(widget_name, gconf_name, strlen(gconf_name)) == 0);
+ return (strncmp(widget_name, gconf_name, strlen(gconf_name)) == 0);
}
@@ -1548,102 +1594,126 @@
*/
static void
gnc_preferences_gconf_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer dialog)
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer dialog)
{
- GConfValue *value;
- const gchar *key, *string_value;
- gchar **parts, *name, *group_name = NULL;
- GtkWidget *widget;
- GHashTable *table;
+ GConfValue *value;
+ const gchar *key, *string_value;
+ gchar **parts, *name, *group_name = NULL;
+ GtkWidget *widget;
+ GHashTable *table;
- ENTER("key %s, value %p", entry->key, entry->value);
- key = gconf_entry_get_key(entry);
- value = gconf_entry_get_value(entry);
- if (!value) {
- /* Values can be unset */
- LEAVE("Unset valued for %s", key);
- return;
- }
+ ENTER("key %s, value %p", entry->key, entry->value);
+ key = gconf_entry_get_key(entry);
+ value = gconf_entry_get_value(entry);
+ if (!value)
+ {
+ /* Values can be unset */
+ LEAVE("Unset valued for %s", key);
+ return;
+ }
- parts = g_strsplit(entry->key, "/", 4);
- name = g_strconcat("gconf/", parts[3], NULL);
- g_strfreev(parts);
- DEBUG("proposed widget name %s", name);
+ parts = g_strsplit(entry->key, "/", 4);
+ name = g_strconcat("gconf/", parts[3], NULL);
+ g_strfreev(parts);
+ DEBUG("proposed widget name %s", name);
- /* Can't just do a glade lookup here because not all of the widgets
- * came from the same xml file. That's why the extra hash table. */
- table = g_object_get_data(G_OBJECT(dialog), WIDGET_HASH);
- widget = g_hash_table_lookup(table, name);
- if ((widget == NULL) && (entry->value->type == GCONF_VALUE_STRING)) {
- string_value = gconf_value_get_string(entry->value);
- group_name = name;
- name = g_strjoin("/", group_name, string_value, NULL);
- DEBUG("proposed widget name %s", name);
+ /* Can't just do a glade lookup here because not all of the widgets
+ * came from the same xml file. That's why the extra hash table. */
+ table = g_object_get_data(G_OBJECT(dialog), WIDGET_HASH);
widget = g_hash_table_lookup(table, name);
- if (widget == NULL) {
- /* Mutter, mutter. Someone must have typed a bad string into
- * gconf. Force the value to a legal string. Do this by
- * directly setting the first widget in the group. This will
- * ensure synchronization of Gnucash, Gconf, and the Prefs
- * Dialog. */
- DEBUG("bad value");
- widget = g_hash_table_find(table, gnc_prefs_nearest_match, group_name);
- if (widget) {
- DEBUG("forcing %s", gtk_widget_get_name(widget));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
- }
- g_free(group_name);
- g_free(name);
- LEAVE("no exact match");
- return;
+ if ((widget == NULL) && (entry->value->type == GCONF_VALUE_STRING))
+ {
+ string_value = gconf_value_get_string(entry->value);
+ group_name = name;
+ name = g_strjoin("/", group_name, string_value, NULL);
+ DEBUG("proposed widget name %s", name);
+ widget = g_hash_table_lookup(table, name);
+ if (widget == NULL)
+ {
+ /* Mutter, mutter. Someone must have typed a bad string into
+ * gconf. Force the value to a legal string. Do this by
+ * directly setting the first widget in the group. This will
+ * ensure synchronization of Gnucash, Gconf, and the Prefs
+ * Dialog. */
+ DEBUG("bad value");
+ widget = g_hash_table_find(table, gnc_prefs_nearest_match, group_name);
+ if (widget)
+ {
+ DEBUG("forcing %s", gtk_widget_get_name(widget));
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
+ }
+ g_free(group_name);
+ g_free(name);
+ LEAVE("no exact match");
+ return;
+ }
+ g_free(group_name);
}
- g_free(group_name);
- }
- if (widget != NULL) {
- /* These tests must be ordered from more specific widget to less
- * specific widget. Test custom widgets first */
- if (GNC_IS_CURRENCY_EDIT(widget)) { /* must come before combo box */
- DEBUG("widget %p - currency_edit", widget);
- gnc_prefs_currency_edit_gconf_cb(GNC_CURRENCY_EDIT(widget), entry);
- } else if (GNC_IS_PERIOD_SELECT(widget)) {
- DEBUG("widget %p - period_select", widget);
- gnc_prefs_period_select_gconf_cb(GNC_PERIOD_SELECT(widget),
- gconf_value_get_int(entry->value));
- } else if (GNC_IS_DATE_EDIT(widget)) {
- DEBUG("widget %p - date_edit", widget);
- gnc_prefs_date_edit_gconf_cb(GNC_DATE_EDIT(widget), entry);
- } else if (GTK_IS_FONT_BUTTON(widget)) {
- DEBUG("widget %p - font button", widget);
- gnc_prefs_font_button_gconf_cb(GTK_FONT_BUTTON(widget), entry);
- } else if (GTK_IS_RADIO_BUTTON(widget)) {
- DEBUG("widget %p - radio button", widget);
- gnc_prefs_radio_button_gconf_cb(GTK_RADIO_BUTTON(widget));
- } else if (GTK_IS_CHECK_BUTTON(widget)) {
- DEBUG("widget %p - check button", widget);
- gnc_prefs_check_button_gconf_cb(GTK_CHECK_BUTTON(widget),
- gconf_value_get_bool(entry->value));
- } else if (GTK_IS_SPIN_BUTTON(widget)) {
- DEBUG("widget %p - spin button", widget);
- gnc_prefs_spin_button_gconf_cb(GTK_SPIN_BUTTON(widget),
- gconf_value_get_float(entry->value));
- } else if (GTK_IS_COMBO_BOX(widget)) {
- DEBUG("widget %p - combo_box", widget);
- gnc_prefs_combo_box_gconf_cb(GTK_COMBO_BOX(widget),
- gconf_value_get_int(entry->value));
- } else if (GTK_IS_ENTRY(widget)) {
- DEBUG("widget %p - entry", widget);
- gnc_prefs_entry_gconf_cb(GTK_ENTRY(widget),
- gconf_value_get_string(entry->value));
- } else {
- DEBUG("widget %p - unsupported %s", widget,
- G_OBJECT_TYPE_NAME(G_OBJECT(widget)));
+ if (widget != NULL)
+ {
+ /* These tests must be ordered from more specific widget to less
+ * specific widget. Test custom widgets first */
+ if (GNC_IS_CURRENCY_EDIT(widget)) /* must come before combo box */
+ {
+ DEBUG("widget %p - currency_edit", widget);
+ gnc_prefs_currency_edit_gconf_cb(GNC_CURRENCY_EDIT(widget), entry);
+ }
+ else if (GNC_IS_PERIOD_SELECT(widget))
+ {
+ DEBUG("widget %p - period_select", widget);
+ gnc_prefs_period_select_gconf_cb(GNC_PERIOD_SELECT(widget),
+ gconf_value_get_int(entry->value));
+ }
+ else if (GNC_IS_DATE_EDIT(widget))
+ {
+ DEBUG("widget %p - date_edit", widget);
+ gnc_prefs_date_edit_gconf_cb(GNC_DATE_EDIT(widget), entry);
+ }
+ else if (GTK_IS_FONT_BUTTON(widget))
+ {
+ DEBUG("widget %p - font button", widget);
+ gnc_prefs_font_button_gconf_cb(GTK_FONT_BUTTON(widget), entry);
+ }
+ else if (GTK_IS_RADIO_BUTTON(widget))
+ {
+ DEBUG("widget %p - radio button", widget);
+ gnc_prefs_radio_button_gconf_cb(GTK_RADIO_BUTTON(widget));
+ }
+ else if (GTK_IS_CHECK_BUTTON(widget))
+ {
+ DEBUG("widget %p - check button", widget);
+ gnc_prefs_check_button_gconf_cb(GTK_CHECK_BUTTON(widget),
+ gconf_value_get_bool(entry->value));
+ }
+ else if (GTK_IS_SPIN_BUTTON(widget))
+ {
+ DEBUG("widget %p - spin button", widget);
+ gnc_prefs_spin_button_gconf_cb(GTK_SPIN_BUTTON(widget),
+ gconf_value_get_float(entry->value));
+ }
+ else if (GTK_IS_COMBO_BOX(widget))
+ {
+ DEBUG("widget %p - combo_box", widget);
+ gnc_prefs_combo_box_gconf_cb(GTK_COMBO_BOX(widget),
+ gconf_value_get_int(entry->value));
+ }
+ else if (GTK_IS_ENTRY(widget))
+ {
+ DEBUG("widget %p - entry", widget);
+ gnc_prefs_entry_gconf_cb(GTK_ENTRY(widget),
+ gconf_value_get_string(entry->value));
+ }
+ else
+ {
+ DEBUG("widget %p - unsupported %s", widget,
+ G_OBJECT_TYPE_NAME(G_OBJECT(widget)));
+ }
}
- }
- g_free(name);
- LEAVE(" ");
+ g_free(name);
+ LEAVE(" ");
}
@@ -1663,15 +1733,15 @@
*/
static gboolean
show_handler (const char *class, gint component_id,
- gpointer user_data, gpointer iter_data)
+ gpointer user_data, gpointer iter_data)
{
- GtkWidget *dialog;
+ GtkWidget *dialog;
- ENTER(" ");
- dialog = GTK_WIDGET(user_data);
- gtk_window_present(GTK_WINDOW(dialog));
- LEAVE(" ");
- return(TRUE);
+ ENTER(" ");
+ dialog = GTK_WIDGET(user_data);
+ gtk_window_present(GTK_WINDOW(dialog));
+ LEAVE(" ");
+ return(TRUE);
}
@@ -1684,13 +1754,13 @@
static void
close_handler (gpointer user_data)
{
- GtkWidget *dialog;
+ GtkWidget *dialog;
- ENTER(" ");
- dialog = GTK_WIDGET(user_data);
- gnc_unregister_gui_component_by_data(DIALOG_PREFERENCES_CM_CLASS, dialog);
- gtk_widget_destroy(dialog);
- LEAVE(" ");
+ ENTER(" ");
+ dialog = GTK_WIDGET(user_data);
+ gnc_unregister_gui_component_by_data(DIALOG_PREFERENCES_CM_CLASS, dialog);
+ gtk_widget_destroy(dialog);
+ LEAVE(" ");
}
@@ -1701,30 +1771,31 @@
void
gnc_preferences_dialog (void)
{
- GtkWidget *dialog;
+ GtkWidget *dialog;
- ENTER("");
- if (gnc_forall_gui_components(DIALOG_PREFERENCES_CM_CLASS,
- show_handler, NULL)) {
- LEAVE("existing window");
- return;
- }
+ ENTER("");
+ if (gnc_forall_gui_components(DIALOG_PREFERENCES_CM_CLASS,
+ show_handler, NULL))
+ {
+ LEAVE("existing window");
+ return;
+ }
- dialog = gnc_preferences_dialog_create();
+ dialog = gnc_preferences_dialog_create();
- gnc_restore_window_size(GCONF_SECTION, GTK_WINDOW(dialog));
- gtk_widget_show(dialog);
+ gnc_restore_window_size(GCONF_SECTION, GTK_WINDOW(dialog));
+ gtk_widget_show(dialog);
- gnc_gconf_add_notification(G_OBJECT(dialog), NULL,
- gnc_preferences_gconf_changed,
- DIALOG_PREFERENCES_CM_CLASS);
- gnc_gconf_general_register_cb(KEY_ACCOUNT_SEPARATOR,
- (GncGconfGeneralCb)gnc_account_separator_prefs_cb,
- dialog);
- gnc_register_gui_component(DIALOG_PREFERENCES_CM_CLASS,
- NULL, close_handler, dialog);
+ gnc_gconf_add_notification(G_OBJECT(dialog), NULL,
+ gnc_preferences_gconf_changed,
+ DIALOG_PREFERENCES_CM_CLASS);
+ gnc_gconf_general_register_cb(KEY_ACCOUNT_SEPARATOR,
+ (GncGconfGeneralCb)gnc_account_separator_prefs_cb,
+ dialog);
+ gnc_register_gui_component(DIALOG_PREFERENCES_CM_CLASS,
+ NULL, close_handler, dialog);
- LEAVE(" ");
+ LEAVE(" ");
}
/** @} */
Modified: gnucash/trunk/src/gnome-utils/dialog-preferences.h
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-preferences.h 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/dialog-preferences.h 2010-03-02 21:42:11 UTC (rev 18791)
@@ -27,7 +27,7 @@
/** @file dialog-preferences.h
@brief Dialog for handling user preferences.
@author Copyright (c) 2005 David Hampton <hampton at employees.org>
-
+
These functions are the external API available for the new user
preference dialog. Preferences are now stored in GConf. This
code ends up being nothing more than a pretty interface to set
@@ -68,16 +68,16 @@
* dialog with the specified tab name. The tab name may not be
* duplicated. For example, the Business code might have a full page
* of its own preferences.
- *
+ *
* @param filename The name of a glade file.
- *
+ *
* @param widgetname The name of the widget to extract from the glade file.
- *
+ *
* @param tabname The (translated!) name this page of preferences should have in
* the dialog notebook. */
void gnc_preferences_add_page (const gchar *filename,
- const gchar *widgetname,
- const gchar *tabname);
+ const gchar *widgetname,
+ const gchar *tabname);
/** This function adds a partial page of preferences to the
@@ -86,16 +86,16 @@
* the preferences dialog with the specified tab name. The tab name
* may be duplicated. For example, the HBCI preferences may share a
* "Data Import" page with QIF and other methods.
- *
+ *
* @param filename The name of a glade file.
- *
+ *
* @param widgetname The name of the widget to extract from the glade file.
- *
+ *
* @param tabname The (translated!) name this page of preferences should have in
* the dialog notebook. */
void gnc_preferences_add_to_page (const gchar *filename,
- const gchar *widgetname,
- const gchar *tabname);
+ const gchar *widgetname,
+ const gchar *tabname);
/** This function creates the preferences dialog and presents it to
Modified: gnucash/trunk/src/gnome-utils/dialog-query-list.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-query-list.c 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/dialog-query-list.c 2010-03-02 21:42:11 UTC (rev 18791)
@@ -35,144 +35,146 @@
#include "dialog-query-list.h"
#include "gnc-query-list.h"
-struct _DialogQueryList {
- GtkWidget * dialog;
- GtkWidget * label;
- GtkWidget * qlist;
- GtkWidget * button_box;
+struct _DialogQueryList
+{
+ GtkWidget * dialog;
+ GtkWidget * label;
+ GtkWidget * qlist;
+ GtkWidget * button_box;
- GNCDisplayListButton * buttons;
- gpointer user_data;
+ GNCDisplayListButton * buttons;
+ gpointer user_data;
- GList * books;
+ GList * books;
- gint component_id;
+ gint component_id;
};
static void
dql_clear_booklist (DialogQueryList *dql)
{
- GList *node;
+ GList *node;
- g_return_if_fail (dql);
+ g_return_if_fail (dql);
- for (node = dql->books; node; node = node->next)
- xaccGUIDFree ((GUID*)node->data);
- g_list_free (dql->books);
- dql->books = NULL;
+ for (node = dql->books; node; node = node->next)
+ xaccGUIDFree ((GUID*)node->data);
+ g_list_free (dql->books);
+ dql->books = NULL;
}
static void
dql_build_booklist (DialogQueryList *dql, Query *q)
{
- GList *node;
+ GList *node;
- g_return_if_fail (dql);
+ g_return_if_fail (dql);
- for (node = gncQueryGetBooks(q); node; node=node->next) {
- GNCBook *book = node->data;
- GUID *guid = xaccGUIDMalloc();
- *guid = *(gnc_book_get_guid(book));
- dql->books = g_list_prepend(dql->books, guid);
- }
+ for (node = gncQueryGetBooks(q); node; node = node->next)
+ {
+ GNCBook *book = node->data;
+ GUID *guid = xaccGUIDMalloc();
+ *guid = *(gnc_book_get_guid(book));
+ dql->books = g_list_prepend(dql->books, guid);
+ }
}
static void
gnc_dialog_query_run_callback (GNCDisplayListButton *cb, gpointer item,
- DialogQueryList *dql)
+ DialogQueryList *dql)
{
- if (!cb)
- return;
+ if (!cb)
+ return;
- if (cb->cb_fcn)
- (cb->cb_fcn)(item, dql->user_data);
+ if (cb->cb_fcn)
+ (cb->cb_fcn)(item, dql->user_data);
}
static void
gnc_dialog_query_list_button_clicked (GtkButton *button, DialogQueryList *dql)
{
- GNCDisplayListButton *cb;
- gpointer current;
+ GNCDisplayListButton *cb;
+ gpointer current;
- g_return_if_fail (dql);
- current = gnc_query_list_get_current_entry (GNC_QUERY_LIST (dql->qlist));
- if (!current)
- return;
+ g_return_if_fail (dql);
+ current = gnc_query_list_get_current_entry (GNC_QUERY_LIST (dql->qlist));
+ if (!current)
+ return;
- cb = g_object_get_data (G_OBJECT (button), "data");
- g_return_if_fail (cb);
+ cb = g_object_get_data (G_OBJECT (button), "data");
+ g_return_if_fail (cb);
- gnc_dialog_query_run_callback (cb, current, dql);
+ gnc_dialog_query_run_callback (cb, current, dql);
}
static void
gnc_dialog_query_list_double_click_entry (GNCQueryList *list, gpointer item,
- gpointer user_data)
+ gpointer user_data)
{
- DialogQueryList *dql = user_data;
+ DialogQueryList *dql = user_data;
- g_return_if_fail (dql);
- g_return_if_fail (item);
+ g_return_if_fail (dql);
+ g_return_if_fail (item);
- if (!dql->buttons)
- return;
+ if (!dql->buttons)
+ return;
- gnc_dialog_query_run_callback (dql->buttons, item, dql);
+ gnc_dialog_query_run_callback (dql->buttons, item, dql);
}
static int
gnc_dialog_query_list_delete_cb (GtkDialog *dialog, GdkEvent *event, DialogQueryList *dql)
{
- g_return_val_if_fail (dql, TRUE);
+ g_return_val_if_fail (dql, TRUE);
- gnc_unregister_gui_component (dql->component_id);
+ gnc_unregister_gui_component (dql->component_id);
- /* XXX: Clear/destroy the param_list? */
+ /* XXX: Clear/destroy the param_list? */
- /* destroy the book list */
- dql_clear_booklist (dql);
+ /* destroy the book list */
+ dql_clear_booklist (dql);
- /* Destroy and exit */
- gtk_widget_destroy(dql->dialog);
- g_free (dql);
- return FALSE;
+ /* Destroy and exit */
+ gtk_widget_destroy(dql->dialog);
+ g_free (dql);
+ return FALSE;
}
static void
close_handler (gpointer data)
{
- DialogQueryList * dql = data;
+ DialogQueryList * dql = data;
- g_return_if_fail (dql);
- gnc_dialog_query_list_delete_cb (GTK_DIALOG(dql->dialog), NULL, dql);
+ g_return_if_fail (dql);
+ gnc_dialog_query_list_delete_cb (GTK_DIALOG(dql->dialog), NULL, dql);
}
static void
gnc_dialog_query_list_refresh_handler (GHashTable *changes, gpointer user_data)
{
- DialogQueryList *dql = (DialogQueryList *)user_data;
- const EventInfo *info;
- GList *node;
+ DialogQueryList *dql = (DialogQueryList *)user_data;
+ const EventInfo *info;
+ GList *node;
- if (changes)
- {
- for (node = dql->books; node; node = node->next)
+ if (changes)
{
- info = gnc_gui_get_entity_events (changes, (const GUID*)(node->data));
- if (info && (info->event_mask & QOF_EVENT_DESTROY))
- {
- gnc_close_gui_component (dql->component_id);
- return;
- }
+ for (node = dql->books; node; node = node->next)
+ {
+ info = gnc_gui_get_entity_events (changes, (const GUID*)(node->data));
+ if (info && (info->event_mask & QOF_EVENT_DESTROY))
+ {
+ gnc_close_gui_component (dql->component_id);
+ return;
+ }
+ }
}
- }
}
static void
gnc_dialog_query_list_close (GtkButton *button, DialogQueryList *dql)
{
- /* Don't select anything */
- gnc_dialog_query_list_destroy (dql);
+ /* Don't select anything */
+ gnc_dialog_query_list_destroy (dql);
}
/*****************************************************************/
@@ -181,143 +183,144 @@
DialogQueryList *
gnc_dialog_query_list_new (GList *param_list, Query *q)
{
- GladeXML *xml;
- DialogQueryList *dql;
- GtkWidget *scroller, *close;
- GList *node;
+ GladeXML *xml;
+ DialogQueryList *dql;
+ GtkWidget *scroller, *close;
+ GList *node;
- dql = g_new0 (DialogQueryList, 1);
- xml = gnc_glade_xml_new ("dialog-query-list.glade", "Query List Dialog");
+ dql = g_new0 (DialogQueryList, 1);
+ xml = gnc_glade_xml_new ("dialog-query-list.glade", "Query List Dialog");
- /* Grab the dialog, save the dialog info */
- dql->dialog = glade_xml_get_widget (xml, "Query List Dialog");
- g_object_set_data (G_OBJECT (dql->dialog), "dialog-info", dql);
+ /* Grab the dialog, save the dialog info */
+ dql->dialog = glade_xml_get_widget (xml, "Query List Dialog");
+ g_object_set_data (G_OBJECT (dql->dialog), "dialog-info", dql);
- /* grab the widgets */
- dql->label = glade_xml_get_widget (xml, "dialog_label");
- dql->button_box = glade_xml_get_widget (xml, "button_vbox");
- scroller = glade_xml_get_widget (xml, "result_scroller");
- close = glade_xml_get_widget (xml, "close_button");
+ /* grab the widgets */
+ dql->label = glade_xml_get_widget (xml, "dialog_label");
+ dql->button_box = glade_xml_get_widget (xml, "button_vbox");
+ scroller = glade_xml_get_widget (xml, "result_scroller");
+ close = glade_xml_get_widget (xml, "close_button");
- /* build the query list */
- dql->qlist = gnc_query_list_new (param_list, q);
- gtk_container_add (GTK_CONTAINER (scroller), dql->qlist);
+ /* build the query list */
+ dql->qlist = gnc_query_list_new (param_list, q);
+ gtk_container_add (GTK_CONTAINER (scroller), dql->qlist);
- /* connect the double-click signal of the qlist */
- g_signal_connect (G_OBJECT (dql->qlist), "double_click_entry",
- G_CALLBACK(gnc_dialog_query_list_double_click_entry), dql);
-
+ /* connect the double-click signal of the qlist */
+ g_signal_connect (G_OBJECT (dql->qlist), "double_click_entry",
+ G_CALLBACK(gnc_dialog_query_list_double_click_entry), dql);
- /* connect to the close button */
- g_signal_connect (G_OBJECT (close), "clicked",
- G_CALLBACK (gnc_dialog_query_list_close), dql);
- /* connect to the cleanup */
- g_signal_connect (G_OBJECT (dql->dialog), "delete_event",
- G_CALLBACK (gnc_dialog_query_list_delete_cb), dql);
+ /* connect to the close button */
+ g_signal_connect (G_OBJECT (close), "clicked",
+ G_CALLBACK (gnc_dialog_query_list_close), dql);
+ /* connect to the cleanup */
+ g_signal_connect (G_OBJECT (dql->dialog), "delete_event",
+ G_CALLBACK (gnc_dialog_query_list_delete_cb), dql);
- /* register ourselves */
- dql->component_id =
- gnc_register_gui_component ("GNC Dialog Query List",
- gnc_dialog_query_list_refresh_handler,
- close_handler, dql);
- /* Build the book list */
- dql_build_booklist (dql, q);
+ /* register ourselves */
+ dql->component_id =
+ gnc_register_gui_component ("GNC Dialog Query List",
+ gnc_dialog_query_list_refresh_handler,
+ close_handler, dql);
- /* and register the books */
- for (node = dql->books; node; node = node->next)
- gnc_gui_component_watch_entity (dql->component_id, (GUID*)node->data,
- QOF_EVENT_DESTROY);
+ /* Build the book list */
+ dql_build_booklist (dql, q);
- return dql;
+ /* and register the books */
+ for (node = dql->books; node; node = node->next)
+ gnc_gui_component_watch_entity (dql->component_id, (GUID*)node->data,
+ QOF_EVENT_DESTROY);
+
+ return dql;
}
void gnc_dialog_query_list_set_title (DialogQueryList *dql, const char *title)
{
- if (!dql || !title) return;
- gtk_window_set_title (GTK_WINDOW (dql->dialog), title);
+ if (!dql || !title) return;
+ gtk_window_set_title (GTK_WINDOW (dql->dialog), title);
}
void gnc_dialog_query_list_set_label (DialogQueryList *dql, const char *label)
{
- if (!dql || !label) return;
- gtk_label_set_text (GTK_LABEL(dql->label), label);
+ if (!dql || !label) return;
+ gtk_label_set_text (GTK_LABEL(dql->label), label);
}
void gnc_dialog_query_list_set_buttons (DialogQueryList *dql,
- GNCDisplayListButton *buttons,
- gpointer user_data)
+ GNCDisplayListButton *buttons,
+ gpointer user_data)
{
- GtkWidget *button;
- int i;
+ GtkWidget *button;
+ int i;
- if (!dql || !buttons) return;
- g_return_if_fail (dql->buttons == NULL);
+ if (!dql || !buttons) return;
+ g_return_if_fail (dql->buttons == NULL);
- dql->buttons = buttons;
- dql->user_data = user_data;
+ dql->buttons = buttons;
+ dql->user_data = user_data;
- /* build up the buttons */
- for (i = 0; buttons[i].label; i++) {
- button = gtk_button_new_with_label (buttons[i].label);
- g_object_set_data (G_OBJECT (button), "data", &(dql->buttons[i]));
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK(gnc_dialog_query_list_button_clicked), dql);
- gtk_box_pack_start (GTK_BOX (dql->button_box), button, FALSE, FALSE, 3);
- }
+ /* build up the buttons */
+ for (i = 0; buttons[i].label; i++)
+ {
+ button = gtk_button_new_with_label (buttons[i].label);
+ g_object_set_data (G_OBJECT (button), "data", &(dql->buttons[i]));
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK(gnc_dialog_query_list_button_clicked), dql);
+ gtk_box_pack_start (GTK_BOX (dql->button_box), button, FALSE, FALSE, 3);
+ }
}
void gnc_dialog_query_list_set_numerics (DialogQueryList *dql, gboolean abs,
- gboolean inv_sort)
+ gboolean inv_sort)
{
- if (!dql) return;
+ if (!dql) return;
- gnc_query_list_set_numerics (GNC_QUERY_LIST(dql->qlist), abs, inv_sort);
+ gnc_query_list_set_numerics (GNC_QUERY_LIST(dql->qlist), abs, inv_sort);
}
void gnc_dialog_query_list_refresh (DialogQueryList *dql)
{
- if (!dql) return;
+ if (!dql) return;
- gnc_query_list_refresh (GNC_QUERY_LIST(dql->qlist));
- gtk_widget_show_all (dql->dialog);
+ gnc_query_list_refresh (GNC_QUERY_LIST(dql->qlist));
+ gtk_widget_show_all (dql->dialog);
}
void gnc_dialog_query_list_destroy (DialogQueryList *dql)
{
- if (!dql) return;
- gnc_close_gui_component (dql->component_id);
+ if (!dql) return;
+ gnc_close_gui_component (dql->component_id);
}
DialogQueryList *
gnc_dialog_query_list_create (GList *param_list, Query *q,
- const char *title, const char *label,
- gboolean abs, gboolean inv_sort,
- GNCDisplayListButton *buttons, gpointer user_data)
+ const char *title, const char *label,
+ gboolean abs, gboolean inv_sort,
+ GNCDisplayListButton *buttons, gpointer user_data)
{
- DialogQueryList *dql;
+ DialogQueryList *dql;
- if (!param_list || !q)
- return NULL;
+ if (!param_list || !q)
+ return NULL;
- dql = gnc_dialog_query_list_new (param_list, q);
- if (!dql)
- return NULL;
+ dql = gnc_dialog_query_list_new (param_list, q);
+ if (!dql)
+ return NULL;
- if (title)
- gnc_dialog_query_list_set_title (dql, title);
+ if (title)
+ gnc_dialog_query_list_set_title (dql, title);
- if (label)
- gnc_dialog_query_list_set_label (dql, label);
+ if (label)
+ gnc_dialog_query_list_set_label (dql, label);
- gnc_dialog_query_list_set_numerics (dql, abs, inv_sort);
+ gnc_dialog_query_list_set_numerics (dql, abs, inv_sort);
- if (buttons)
- gnc_dialog_query_list_set_buttons (dql, buttons, user_data);
+ if (buttons)
+ gnc_dialog_query_list_set_buttons (dql, buttons, user_data);
- gnc_dialog_query_list_refresh (dql);
+ gnc_dialog_query_list_refresh (dql);
- return dql;
+ return dql;
}
Modified: gnucash/trunk/src/gnome-utils/dialog-query-list.h
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-query-list.h 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/dialog-query-list.h 2010-03-02 21:42:11 UTC (rev 18791)
@@ -31,9 +31,10 @@
typedef struct _DialogQueryList DialogQueryList;
typedef void (*GNCDisplayListCB)(gpointer obj, gpointer user_data);
-typedef struct {
- const char * label;
- GNCDisplayListCB cb_fcn;
+typedef struct
+{
+ const char * label;
+ GNCDisplayListCB cb_fcn;
} GNCDisplayListButton;
DialogQueryList *
@@ -42,19 +43,19 @@
void gnc_dialog_query_list_set_title (DialogQueryList *dql, const char *title);
void gnc_dialog_query_list_set_label (DialogQueryList *dql, const char *label);
void gnc_dialog_query_list_set_buttons (DialogQueryList *dql,
- GNCDisplayListButton *buttons,
- gpointer user_data);
+ GNCDisplayListButton *buttons,
+ gpointer user_data);
void gnc_dialog_query_list_set_numerics (DialogQueryList *dql, gboolean abs,
- gboolean inv_sort);
+ gboolean inv_sort);
void gnc_dialog_query_list_refresh (DialogQueryList *dql);
void gnc_dialog_query_list_destroy (DialogQueryList *dql);
DialogQueryList *
gnc_dialog_query_list_create (GList *param_list, Query *q,
- const char *title, const char *label,
- gboolean abs, gboolean inv_sort,
- GNCDisplayListButton *buttons, gpointer user_data);
+ const char *title, const char *label,
+ gboolean abs, gboolean inv_sort,
+ GNCDisplayListButton *buttons, gpointer user_data);
#endif /* GNC_DIALOG_QUERY_LIST_H */
Modified: gnucash/trunk/src/gnome-utils/dialog-reset-warnings.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-reset-warnings.c 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/dialog-reset-warnings.c 2010-03-02 21:42:11 UTC (rev 18791)
@@ -49,382 +49,414 @@
static void
gnc_reset_warnings_update_widgets (GtkWidget *dialog_widget)
{
- GtkWidget *box1, *box2, *nada, *buttons;
- GtkWidget *apply;
- GList *list, *tmp;
- gboolean any = FALSE, checked = FALSE;
+ GtkWidget *box1, *box2, *nada, *buttons;
+ GtkWidget *apply;
+ GList *list, *tmp;
+ gboolean any = FALSE, checked = FALSE;
- ENTER(" ");
- box1 = gnc_glade_lookup_widget(dialog_widget, "perm_vbox_and_label");
- box2 = gnc_glade_lookup_widget(dialog_widget, "perm_vbox");
- list = gtk_container_get_children(GTK_CONTAINER(box2));
- if (list) {
- gtk_widget_show_all(box1);
- for (tmp = list; tmp; tmp = g_list_next(tmp)) {
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tmp->data))) {
- checked = TRUE;
- break;
- }
+ ENTER(" ");
+ box1 = gnc_glade_lookup_widget(dialog_widget, "perm_vbox_and_label");
+ box2 = gnc_glade_lookup_widget(dialog_widget, "perm_vbox");
+ list = gtk_container_get_children(GTK_CONTAINER(box2));
+ if (list)
+ {
+ gtk_widget_show_all(box1);
+ for (tmp = list; tmp; tmp = g_list_next(tmp))
+ {
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tmp->data)))
+ {
+ checked = TRUE;
+ break;
+ }
+ }
+ g_list_free(list);
+ any = TRUE;
}
- g_list_free(list);
- any = TRUE;
- } else {
- gtk_widget_hide(box1);
- }
+ else
+ {
+ gtk_widget_hide(box1);
+ }
- box1 = gnc_glade_lookup_widget(dialog_widget, "temp_vbox_and_label");
- box2 = gnc_glade_lookup_widget(dialog_widget, "temp_vbox");
- list = gtk_container_get_children(GTK_CONTAINER(box2));
- if (list) {
- gtk_widget_show_all(box1);
- for (tmp = list; tmp; tmp = g_list_next(tmp)) {
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tmp->data))) {
- checked = TRUE;
- break;
- }
+ box1 = gnc_glade_lookup_widget(dialog_widget, "temp_vbox_and_label");
+ box2 = gnc_glade_lookup_widget(dialog_widget, "temp_vbox");
+ list = gtk_container_get_children(GTK_CONTAINER(box2));
+ if (list)
+ {
+ gtk_widget_show_all(box1);
+ for (tmp = list; tmp; tmp = g_list_next(tmp))
+ {
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tmp->data)))
+ {
+ checked = TRUE;
+ break;
+ }
+ }
+ g_list_free(list);
+ any = TRUE;
}
- g_list_free(list);
- any = TRUE;
- } else {
- gtk_widget_hide(box1);
- }
+ else
+ {
+ gtk_widget_hide(box1);
+ }
- nada = gnc_glade_lookup_widget(dialog_widget, "no_warnings");
- buttons = gnc_glade_lookup_widget(dialog_widget, "hbuttonbox");
- apply = gnc_glade_lookup_widget(dialog_widget, "applybutton");
- if (any) {
- gtk_widget_show(buttons);
- gtk_widget_hide(nada);
- gtk_widget_set_sensitive(apply, checked);
- } else {
- gtk_widget_hide(buttons);
- gtk_widget_show(nada);
- gtk_widget_set_sensitive(apply, FALSE);
- }
- LEAVE(" ");
+ nada = gnc_glade_lookup_widget(dialog_widget, "no_warnings");
+ buttons = gnc_glade_lookup_widget(dialog_widget, "hbuttonbox");
+ apply = gnc_glade_lookup_widget(dialog_widget, "applybutton");
+ if (any)
+ {
+ gtk_widget_show(buttons);
+ gtk_widget_hide(nada);
+ gtk_widget_set_sensitive(apply, checked);
+ }
+ else
+ {
+ gtk_widget_hide(buttons);
+ gtk_widget_show(nada);
+ gtk_widget_set_sensitive(apply, FALSE);
+ }
+ LEAVE(" ");
}
static void
gnc_reset_warnings_select_common (GtkButton *button,
- gboolean selected)
+ gboolean selected)
{
- GtkWidget *vbox;
+ GtkWidget *vbox;
- ENTER("button %p, selected %d", button, selected);
- vbox = gnc_glade_lookup_widget(GTK_WIDGET(button), "perm_vbox");
- gtk_container_foreach(GTK_CONTAINER(vbox),
- (GtkCallback)gtk_toggle_button_set_active,
- GINT_TO_POINTER(selected));
- vbox = gnc_glade_lookup_widget(GTK_WIDGET(button), "temp_vbox");
- gtk_container_foreach(GTK_CONTAINER(vbox),
- (GtkCallback)gtk_toggle_button_set_active,
- GINT_TO_POINTER(selected));
- gnc_reset_warnings_update_widgets(GTK_WIDGET(button));
- LEAVE(" ");
+ ENTER("button %p, selected %d", button, selected);
+ vbox = gnc_glade_lookup_widget(GTK_WIDGET(button), "perm_vbox");
+ gtk_container_foreach(GTK_CONTAINER(vbox),
+ (GtkCallback)gtk_toggle_button_set_active,
+ GINT_TO_POINTER(selected));
+ vbox = gnc_glade_lookup_widget(GTK_WIDGET(button), "temp_vbox");
+ gtk_container_foreach(GTK_CONTAINER(vbox),
+ (GtkCallback)gtk_toggle_button_set_active,
+ GINT_TO_POINTER(selected));
+ gnc_reset_warnings_update_widgets(GTK_WIDGET(button));
+ LEAVE(" ");
}
void
gnc_reset_warnings_select_all_cb (GtkButton *button,
- gpointer user_data)
+ gpointer user_data)
{
- gnc_reset_warnings_select_common(button, TRUE);
+ gnc_reset_warnings_select_common(button, TRUE);
}
void
gnc_reset_warnings_unselect_all_cb (GtkButton *button,
- gpointer user_data)
+ gpointer user_data)
{
- gnc_reset_warnings_select_common(button, FALSE);
+ gnc_reset_warnings_select_common(button, FALSE);
}
static void
gnc_reset_warnings_find_remove (GtkWidget *widget,
- const gchar *name)
+ const gchar *name)
{
- ENTER("widget %p, name %s", widget, name);
- if (strcmp(gtk_widget_get_name(widget), name) == 0) {
- DEBUG("destroying widget %s", name);
- gtk_widget_destroy(widget);
- }
- LEAVE(" ");
+ ENTER("widget %p, name %s", widget, name);
+ if (strcmp(gtk_widget_get_name(widget), name) == 0)
+ {
+ DEBUG("destroying widget %s", name);
+ gtk_widget_destroy(widget);
+ }
+ LEAVE(" ");
}
static void
gnc_reset_warnings_apply_one (GtkWidget *widget,
- GtkDialog *dialog)
+ GtkDialog *dialog)
{
- const char *name;
+ const char *name;
- ENTER("widget %p, dialog %p", widget, dialog);
- if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
- LEAVE("not active");
- return;
- }
+ ENTER("widget %p, dialog %p", widget, dialog);
+ if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
+ {
+ LEAVE("not active");
+ return;
+ }
- name = gtk_widget_get_name(widget);
- gnc_gconf_unset(NULL, name, NULL);
- gtk_widget_destroy(widget);
- LEAVE(" ");
+ name = gtk_widget_get_name(widget);
+ gnc_gconf_unset(NULL, name, NULL);
+ gtk_widget_destroy(widget);
+ LEAVE(" ");
}
static void
gnc_reset_warnings_apply_changes (GtkDialog *dialog)
{
- GtkWidget *vbox;
+ GtkWidget *vbox;
- ENTER("dialog %p", dialog);
- vbox = gnc_glade_lookup_widget(GTK_WIDGET(dialog), "perm_vbox");
- gtk_container_foreach(GTK_CONTAINER(vbox),
- (GtkCallback)gnc_reset_warnings_apply_one,
- dialog);
- vbox = gnc_glade_lookup_widget(GTK_WIDGET(dialog), "temp_vbox");
- gtk_container_foreach(GTK_CONTAINER(vbox),
- (GtkCallback)gnc_reset_warnings_apply_one,
- dialog);
- gnc_reset_warnings_update_widgets(GTK_WIDGET(dialog));
- LEAVE(" ");
+ ENTER("dialog %p", dialog);
+ vbox = gnc_glade_lookup_widget(GTK_WIDGET(dialog), "perm_vbox");
+ gtk_container_foreach(GTK_CONTAINER(vbox),
+ (GtkCallback)gnc_reset_warnings_apply_one,
+ dialog);
+ vbox = gnc_glade_lookup_widget(GTK_WIDGET(dialog), "temp_vbox");
+ gtk_container_foreach(GTK_CONTAINER(vbox),
+ (GtkCallback)gnc_reset_warnings_apply_one,
+ dialog);
+ gnc_reset_warnings_update_widgets(GTK_WIDGET(dialog));
+ LEAVE(" ");
}
static void
gnc_reset_warnings_revert_changes (GtkDialog *dialog)
{
- GSList *entries, *tmp;
- GConfEntry *entry;
+ GSList *entries, *tmp;
+ GConfEntry *entry;
- ENTER("dialog %p", dialog);
+ ENTER("dialog %p", dialog);
- entries = g_object_get_data(G_OBJECT(dialog), GCONF_ENTRY_LIST);
- for (tmp = entries; tmp; tmp = g_slist_next(tmp)) {
- entry = tmp->data;
- gnc_gconf_set_int (NULL, entry->key,
- gconf_value_get_int(entry->value), NULL);
- }
- LEAVE(" ");
+ entries = g_object_get_data(G_OBJECT(dialog), GCONF_ENTRY_LIST);
+ for (tmp = entries; tmp; tmp = g_slist_next(tmp))
+ {
+ entry = tmp->data;
+ gnc_gconf_set_int (NULL, entry->key,
+ gconf_value_get_int(entry->value), NULL);
+ }
+ LEAVE(" ");
}
void
gnc_reset_warnings_response_cb (GtkDialog *dialog,
- gint response,
- gpointer user_data)
+ gint response,
+ gpointer user_data)
{
- switch (response) {
+ switch (response)
+ {
case GTK_RESPONSE_APPLY:
- gnc_reset_warnings_apply_changes(dialog);
- break;
+ gnc_reset_warnings_apply_changes(dialog);
+ break;
case GTK_RESPONSE_OK:
- gnc_gconf_remove_notification(G_OBJECT(dialog), GCONF_WARNINGS,
- DIALOG_RESET_WARNINGS_CM_CLASS);
- gnc_reset_warnings_apply_changes(dialog);
- gnc_save_window_size(GCONF_SECTION, GTK_WINDOW(dialog));
- gnc_unregister_gui_component_by_data(DIALOG_RESET_WARNINGS_CM_CLASS,
- dialog);
- gtk_widget_destroy(GTK_WIDGET(dialog));
- break;
+ gnc_gconf_remove_notification(G_OBJECT(dialog), GCONF_WARNINGS,
+ DIALOG_RESET_WARNINGS_CM_CLASS);
+ gnc_reset_warnings_apply_changes(dialog);
+ gnc_save_window_size(GCONF_SECTION, GTK_WINDOW(dialog));
+ gnc_unregister_gui_component_by_data(DIALOG_RESET_WARNINGS_CM_CLASS,
+ dialog);
+ gtk_widget_destroy(GTK_WIDGET(dialog));
+ break;
default:
- gnc_gconf_remove_notification(G_OBJECT(dialog), GCONF_WARNINGS,
- DIALOG_RESET_WARNINGS_CM_CLASS);
- gnc_reset_warnings_revert_changes(dialog);
- gnc_unregister_gui_component_by_data(DIALOG_RESET_WARNINGS_CM_CLASS,
- dialog);
- gtk_widget_destroy(GTK_WIDGET(dialog));
- }
+ gnc_gconf_remove_notification(G_OBJECT(dialog), GCONF_WARNINGS,
+ DIALOG_RESET_WARNINGS_CM_CLASS);
+ gnc_reset_warnings_revert_changes(dialog);
+ gnc_unregister_gui_component_by_data(DIALOG_RESET_WARNINGS_CM_CLASS,
+ dialog);
+ gtk_widget_destroy(GTK_WIDGET(dialog));
+ }
}
static void
gnc_reset_warnings_add_one (GConfEntry *entry, GtkWidget *box)
{
- const gchar *name, *schema_name, *desc, *long_desc = NULL;
- GtkWidget *checkbox;
- GConfSchema *schema = NULL;
+ const gchar *name, *schema_name, *desc, *long_desc = NULL;
+ GtkWidget *checkbox;
+ GConfSchema *schema = NULL;
- ENTER(" ");
- name = strrchr(entry->key, '/') + 1;
- schema_name = gconf_entry_get_schema_name(entry);
- if (schema_name)
- schema = gnc_gconf_get_schema(NULL, schema_name, NULL);
- if (schema) {
- DEBUG("found schema %p", schema);
- desc = gconf_schema_get_short_desc(schema);
- DEBUG("description %s", desc);
- long_desc = gconf_schema_get_long_desc(schema);
- checkbox = gtk_check_button_new_with_label(desc ? desc : name);
- if (long_desc) {
- GtkTooltips *tips;
- tips = g_object_get_data(G_OBJECT(box), TIPS_STRING);
- if (!tips) {
- tips = gtk_tooltips_new();
- g_object_set_data(G_OBJECT(box), TIPS_STRING, tips);
- }
- gtk_tooltips_set_tip(tips, checkbox, long_desc, NULL);
+ ENTER(" ");
+ name = strrchr(entry->key, '/') + 1;
+ schema_name = gconf_entry_get_schema_name(entry);
+ if (schema_name)
+ schema = gnc_gconf_get_schema(NULL, schema_name, NULL);
+ if (schema)
+ {
+ DEBUG("found schema %p", schema);
+ desc = gconf_schema_get_short_desc(schema);
+ DEBUG("description %s", desc);
+ long_desc = gconf_schema_get_long_desc(schema);
+ checkbox = gtk_check_button_new_with_label(desc ? desc : name);
+ if (long_desc)
+ {
+ GtkTooltips *tips;
+ tips = g_object_get_data(G_OBJECT(box), TIPS_STRING);
+ if (!tips)
+ {
+ tips = gtk_tooltips_new();
+ g_object_set_data(G_OBJECT(box), TIPS_STRING, tips);
+ }
+ gtk_tooltips_set_tip(tips, checkbox, long_desc, NULL);
+ }
+ gconf_schema_free(schema);
}
- gconf_schema_free(schema);
- } else {
- DEBUG("no schema");
- checkbox = gtk_check_button_new_with_label(name);
- }
+ else
+ {
+ DEBUG("no schema");
+ checkbox = gtk_check_button_new_with_label(name);
+ }
- gtk_widget_set_name(checkbox, entry->key);
- g_signal_connect_swapped(G_OBJECT(checkbox), "toggled",
- (GCallback)gnc_reset_warnings_update_widgets,
- box);
- gtk_box_pack_start_defaults(GTK_BOX(box), checkbox);
- LEAVE(" ");
+ gtk_widget_set_name(checkbox, entry->key);
+ g_signal_connect_swapped(G_OBJECT(checkbox), "toggled",
+ (GCallback)gnc_reset_warnings_update_widgets,
+ box);
+ gtk_box_pack_start_defaults(GTK_BOX(box), checkbox);
+ LEAVE(" ");
}
static GSList *
gnc_reset_warnings_add_section (const gchar *section, GtkWidget *box)
{
- GSList *entries, *tmp;
- GConfEntry *entry;
+ GSList *entries, *tmp;
+ GConfEntry *entry;
- ENTER(" ");
- entries = gnc_gconf_client_all_entries(section);
- for (tmp = entries; tmp; tmp = g_slist_next(tmp)) {
- entry = tmp->data;
- if (gconf_value_get_int(entry->value) != 0) {
- gnc_reset_warnings_add_one(entry, box);
+ ENTER(" ");
+ entries = gnc_gconf_client_all_entries(section);
+ for (tmp = entries; tmp; tmp = g_slist_next(tmp))
+ {
+ entry = tmp->data;
+ if (gconf_value_get_int(entry->value) != 0)
+ {
+ gnc_reset_warnings_add_one(entry, box);
+ }
}
- }
- LEAVE(" ");
- return entries;
+ LEAVE(" ");
+ return entries;
}
static void
gnc_reset_warnings_release_entries (GSList *entries)
{
- GSList *tmp;
+ GSList *tmp;
- ENTER(" ");
- for (tmp = entries; tmp; tmp = g_slist_next(tmp)) {
- gconf_entry_free(tmp->data);
- }
- g_slist_free(entries);
- LEAVE(" ");
+ ENTER(" ");
+ for (tmp = entries; tmp; tmp = g_slist_next(tmp))
+ {
+ gconf_entry_free(tmp->data);
+ }
+ g_slist_free(entries);
+ LEAVE(" ");
}
static void
gnc_reset_warnings_gconf_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer user_data)
{
- GtkWidget *dialog, *box;
- GList *list;
+ GtkWidget *dialog, *box;
+ GList *list;
- g_return_if_fail(GTK_IS_DIALOG(user_data));
+ g_return_if_fail(GTK_IS_DIALOG(user_data));
- ENTER("entry %p, data %p", entry, user_data);
- dialog = GTK_WIDGET(user_data);
- DEBUG("entry key '%s', value as %p, value as int %d", entry->key, entry->value, gconf_value_get_int(entry->value));
+ ENTER("entry %p, data %p", entry, user_data);
+ dialog = GTK_WIDGET(user_data);
+ DEBUG("entry key '%s', value as %p, value as int %d", entry->key, entry->value, gconf_value_get_int(entry->value));
- /* Which box is affected */
- if (strstr(entry->key, "permanent") != 0) {
- box = gnc_glade_lookup_widget(GTK_WIDGET(dialog), "perm_vbox");
- } else {
- box = gnc_glade_lookup_widget(GTK_WIDGET(dialog), "temp_vbox");
- }
+ /* Which box is affected */
+ if (strstr(entry->key, "permanent") != 0)
+ {
+ box = gnc_glade_lookup_widget(GTK_WIDGET(dialog), "perm_vbox");
+ }
+ else
+ {
+ box = gnc_glade_lookup_widget(GTK_WIDGET(dialog), "temp_vbox");
+ }
- if (gconf_value_get_int(entry->value) != 0) {
- gnc_reset_warnings_add_one (entry, box);
- DEBUG("added checkbox for %s", entry->key);
- } else {
- /* Don't know if we were invoked by the dialog removing the
- * warning, or if the remove happened somewhere else like
- * gconf-editor. Can't hurt to run the widgets and try to remove
- * it. Worst case we can't find it because its already been
- * deleted. */
- list = gtk_container_get_children(GTK_CONTAINER(box));
- g_list_foreach(list, (GFunc)gnc_reset_warnings_find_remove, entry->key);
- g_list_free(list);
- }
- gnc_reset_warnings_update_widgets(dialog);
- LEAVE(" ");
+ if (gconf_value_get_int(entry->value) != 0)
+ {
+ gnc_reset_warnings_add_one (entry, box);
+ DEBUG("added checkbox for %s", entry->key);
+ }
+ else
+ {
+ /* Don't know if we were invoked by the dialog removing the
+ * warning, or if the remove happened somewhere else like
+ * gconf-editor. Can't hurt to run the widgets and try to remove
+ * it. Worst case we can't find it because its already been
+ * deleted. */
+ list = gtk_container_get_children(GTK_CONTAINER(box));
+ g_list_foreach(list, (GFunc)gnc_reset_warnings_find_remove, entry->key);
+ g_list_free(list);
+ }
+ gnc_reset_warnings_update_widgets(dialog);
+ LEAVE(" ");
}
static gboolean
show_handler (const char *class, gint component_id,
- gpointer user_data, gpointer iter_data)
+ gpointer user_data, gpointer iter_data)
{
- GtkWidget *dialog;
+ GtkWidget *dialog;
- ENTER(" ");
- dialog = GTK_WIDGET(user_data);
- gtk_window_present(GTK_WINDOW(dialog));
- LEAVE(" ");
- return(TRUE);
+ ENTER(" ");
+ dialog = GTK_WIDGET(user_data);
+ gtk_window_present(GTK_WINDOW(dialog));
+ LEAVE(" ");
+ return(TRUE);
}
static void
close_handler (gpointer user_data)
{
- GtkWidget *dialog = user_data;
+ GtkWidget *dialog = user_data;
- ENTER(" ");
- dialog = GTK_WIDGET(user_data);
- gnc_unregister_gui_component_by_data(DIALOG_RESET_WARNINGS_CM_CLASS, dialog);
- gtk_widget_destroy(dialog);
- LEAVE(" ");
+ ENTER(" ");
+ dialog = GTK_WIDGET(user_data);
+ gnc_unregister_gui_component_by_data(DIALOG_RESET_WARNINGS_CM_CLASS, dialog);
+ gtk_widget_destroy(dialog);
+ LEAVE(" ");
}
void
gnc_reset_warnings_dialog (GtkWidget *main_window)
{
- GtkWidget *dialog, *box;
- GladeXML *xml;
- GSList *perm_list, *temp_list;
+ GtkWidget *dialog, *box;
+ GladeXML *xml;
+ GSList *perm_list, *temp_list;
- ENTER("");
- if (gnc_forall_gui_components(DIALOG_RESET_WARNINGS_CM_CLASS,
- show_handler, NULL)) {
- LEAVE("existing window");
- return;
- }
+ ENTER("");
+ if (gnc_forall_gui_components(DIALOG_RESET_WARNINGS_CM_CLASS,
+ show_handler, NULL))
+ {
+ LEAVE("existing window");
+ return;
+ }
- DEBUG("Opening dialog-reset-warnings.glade:");
- xml = gnc_glade_xml_new("dialog-reset-warnings.glade", "Reset Warnings");
- dialog = glade_xml_get_widget(xml, "Reset Warnings");
- glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func,
- dialog);
+ DEBUG("Opening dialog-reset-warnings.glade:");
+ xml = gnc_glade_xml_new("dialog-reset-warnings.glade", "Reset Warnings");
+ dialog = glade_xml_get_widget(xml, "Reset Warnings");
+ glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func,
+ dialog);
- DEBUG("permanent");
- box = glade_xml_get_widget(xml, "perm_vbox");
- perm_list = gnc_reset_warnings_add_section(GCONF_WARNINGS_PERM, box);
+ DEBUG("permanent");
+ box = glade_xml_get_widget(xml, "perm_vbox");
+ perm_list = gnc_reset_warnings_add_section(GCONF_WARNINGS_PERM, box);
- DEBUG("temporary");
- box = glade_xml_get_widget(xml, "temp_vbox");
- temp_list = gnc_reset_warnings_add_section(GCONF_WARNINGS_TEMP, box);
+ DEBUG("temporary");
+ box = glade_xml_get_widget(xml, "temp_vbox");
+ temp_list = gnc_reset_warnings_add_section(GCONF_WARNINGS_TEMP, box);
- g_object_set_data_full(G_OBJECT(dialog), GCONF_ENTRY_LIST,
- g_slist_concat (perm_list, temp_list),
- (GDestroyNotify)gnc_reset_warnings_release_entries);
+ g_object_set_data_full(G_OBJECT(dialog), GCONF_ENTRY_LIST,
+ g_slist_concat (perm_list, temp_list),
+ (GDestroyNotify)gnc_reset_warnings_release_entries);
- gnc_reset_warnings_update_widgets(dialog);
+ gnc_reset_warnings_update_widgets(dialog);
- gnc_gconf_add_notification(G_OBJECT(dialog), GCONF_WARNINGS,
- gnc_reset_warnings_gconf_changed,
- DIALOG_RESET_WARNINGS_CM_CLASS);
+ gnc_gconf_add_notification(G_OBJECT(dialog), GCONF_WARNINGS,
+ gnc_reset_warnings_gconf_changed,
+ DIALOG_RESET_WARNINGS_CM_CLASS);
- gnc_restore_window_size(GCONF_SECTION, GTK_WINDOW(dialog));
+ gnc_restore_window_size(GCONF_SECTION, GTK_WINDOW(dialog));
- gnc_register_gui_component (DIALOG_RESET_WARNINGS_CM_CLASS,
- NULL, close_handler, dialog);
+ gnc_register_gui_component (DIALOG_RESET_WARNINGS_CM_CLASS,
+ NULL, close_handler, dialog);
- gtk_widget_show(dialog);
- LEAVE(" ");
+ gtk_widget_show(dialog);
+ LEAVE(" ");
}
Modified: gnucash/trunk/src/gnome-utils/dialog-totd.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-totd.c 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/dialog-totd.c 2010-03-02 21:42:11 UTC (rev 18791)
@@ -20,7 +20,7 @@
* Free Software Foundation Voice: +1-617-542-5942
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
* Boston, MA 02110-1301, USA gnu at gnu.org
- */
+ */
#include "config.h"
@@ -77,23 +77,23 @@
*/
static void
gnc_new_tip_number (GtkWidget *widget,
- gint offset)
+ gint offset)
{
- GtkWidget *textview;
+ GtkWidget *textview;
- ENTER("widget %p, offset %d", widget, offset);
- current_tip_number += offset;
- DEBUG("clamp %d to '0 <= x < %d'", current_tip_number, tip_count);
- if (current_tip_number < 0)
- current_tip_number = tip_count - 1;
- if (current_tip_number >= tip_count)
- current_tip_number = 0;
- gnc_gconf_set_int(GCONF_SECTION, KEY_CURRENT_TIP, current_tip_number, NULL);
+ ENTER("widget %p, offset %d", widget, offset);
+ current_tip_number += offset;
+ DEBUG("clamp %d to '0 <= x < %d'", current_tip_number, tip_count);
+ if (current_tip_number < 0)
+ current_tip_number = tip_count - 1;
+ if (current_tip_number >= tip_count)
+ current_tip_number = 0;
+ gnc_gconf_set_int(GCONF_SECTION, KEY_CURRENT_TIP, current_tip_number, NULL);
- textview = gnc_glade_lookup_widget(widget, "tip_textview");
- gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)),
- _(tip_list[current_tip_number]), -1);
- LEAVE("");
+ textview = gnc_glade_lookup_widget(widget, "tip_textview");
+ gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)),
+ _(tip_list[current_tip_number]), -1);
+ LEAVE("");
}
@@ -102,39 +102,40 @@
/********************/
void gnc_totd_dialog_response (GtkDialog *dialog,
- gint response,
- gpointer user_data)
+ gint response,
+ gpointer user_data)
{
- ENTER("dialog %p, response %d, user_data %p", dialog, response, user_data);
- switch (response) {
+ ENTER("dialog %p, response %d, user_data %p", dialog, response, user_data);
+ switch (response)
+ {
case GNC_RESPONSE_FORWARD:
- gnc_new_tip_number(GTK_WIDGET(dialog), 1);
- break;
+ gnc_new_tip_number(GTK_WIDGET(dialog), 1);
+ break;
case GNC_RESPONSE_BACK:
- gnc_new_tip_number(GTK_WIDGET(dialog), -1);
- break;
+ gnc_new_tip_number(GTK_WIDGET(dialog), -1);
+ break;
case GTK_RESPONSE_CLOSE:
- gnc_save_window_size(GCONF_SECTION, GTK_WINDOW(dialog));
- /* fall through */
+ gnc_save_window_size(GCONF_SECTION, GTK_WINDOW(dialog));
+ /* fall through */
default:
- gnc_unregister_gui_component_by_data(DIALOG_TOTD_CM_CLASS, dialog);
- gtk_widget_destroy(GTK_WIDGET(dialog));
- break;
- }
- LEAVE("");
+ gnc_unregister_gui_component_by_data(DIALOG_TOTD_CM_CLASS, dialog);
+ gtk_widget_destroy(GTK_WIDGET(dialog));
+ break;
+ }
+ LEAVE("");
}
void
gnc_totd_dialog_startup_toggled (GtkToggleButton *button,
- gpointer user_data)
+ gpointer user_data)
{
- gboolean active;
+ gboolean active;
- active = gtk_toggle_button_get_active(button);
- gnc_gconf_set_bool(GCONF_SECTION, KEY_SHOW_TIPS, active, NULL);
+ active = gtk_toggle_button_get_active(button);
+ gnc_gconf_set_bool(GCONF_SECTION, KEY_SHOW_TIPS, active, NULL);
}
/********************/
@@ -144,56 +145,62 @@
static gboolean
gnc_totd_initialize (void)
{
- gchar *filename, *contents, *new, *found;
- gsize length;
- GError *error;
+ gchar *filename, *contents, *new, *found;
+ gsize length;
+ GError *error;
- /* Find the file */
- filename = gnc_gnome_locate_data_file("tip_of_the_day.list");
- if (!filename)
- return FALSE;
+ /* Find the file */
+ filename = gnc_gnome_locate_data_file("tip_of_the_day.list");
+ if (!filename)
+ return FALSE;
- /* Read it */
- if (!g_file_get_contents(filename, &contents, &length, &error)) {
- printf("Unable to read file: %s\n", error->message);
- g_error_free(error);
- g_free(filename);
- return FALSE;
- }
+ /* Read it */
+ if (!g_file_get_contents(filename, &contents, &length, &error))
+ {
+ printf("Unable to read file: %s\n", error->message);
+ g_error_free(error);
+ g_free(filename);
+ return FALSE;
+ }
- /* Replace maximal substrings of more than two newlines by \n\n,
- * remove leading and trailing \n\n */
- while ((found = strstr(contents, "\n\n\n")) != NULL) {
- *found++ = '\0';
- while (*found == '\n') found++;
- if (*contents && *found) {
- /* put \n\n between the two nonempty parts */
- new = g_strdup_printf("%s\n\n%s", contents, found);
- g_free(contents);
- contents = new;
- } else if (*found) {
- /* remove leading newlines */
- new = g_strdup(found);
- g_free(contents);
- contents = new;
+ /* Replace maximal substrings of more than two newlines by \n\n,
+ * remove leading and trailing \n\n */
+ while ((found = strstr(contents, "\n\n\n")) != NULL)
+ {
+ *found++ = '\0';
+ while (*found == '\n') found++;
+ if (*contents && *found)
+ {
+ /* put \n\n between the two nonempty parts */
+ new = g_strdup_printf("%s\n\n%s", contents, found);
+ g_free(contents);
+ contents = new;
+ }
+ else if (*found)
+ {
+ /* remove leading newlines */
+ new = g_strdup(found);
+ g_free(contents);
+ contents = new;
+ }
}
- }
- /* Split into multiple strings */
- tip_list = g_strsplit(contents, "\n\n", 0);
+ /* Split into multiple strings */
+ tip_list = g_strsplit(contents, "\n\n", 0);
- /* Convert any escaped characters while counting the strings */
- for (tip_count = 0; tip_list[tip_count] != NULL; tip_count++) {
+ /* Convert any escaped characters while counting the strings */
+ for (tip_count = 0; tip_list[tip_count] != NULL; tip_count++)
+ {
- g_strstrip(tip_list[tip_count]);
- new = g_strcompress(g_strdelimit(tip_list[tip_count], "\n", ' '));
- g_free(tip_list[tip_count]);
- tip_list[tip_count] = new;
- }
+ g_strstrip(tip_list[tip_count]);
+ new = g_strcompress(g_strdelimit(tip_list[tip_count], "\n", ' '));
+ g_free(tip_list[tip_count]);
+ tip_list[tip_count] = new;
+ }
- g_free(contents);
- g_free(filename);
- return TRUE;
+ g_free(contents);
+ g_free(filename);
+ return TRUE;
}
/** Raise the totd dialog to the top of the window stack. This
@@ -212,15 +219,15 @@
*/
static gboolean
show_handler (const char *class, gint component_id,
- gpointer user_data, gpointer iter_data)
+ gpointer user_data, gpointer iter_data)
{
- GtkWidget *dialog;
+ GtkWidget *dialog;
- ENTER(" ");
- dialog = GTK_WIDGET(user_data);
- gtk_window_present(GTK_WINDOW(dialog));
- LEAVE(" ");
- return(TRUE);
+ ENTER(" ");
+ dialog = GTK_WIDGET(user_data);
+ gtk_window_present(GTK_WINDOW(dialog));
+ LEAVE(" ");
+ return(TRUE);
}
/** Close the totd dialog.
@@ -232,13 +239,13 @@
static void
close_handler (gpointer user_data)
{
- GtkWidget *dialog;
+ GtkWidget *dialog;
- ENTER(" ");
- dialog = GTK_WIDGET(user_data);
- gnc_unregister_gui_component_by_data(DIALOG_TOTD_CM_CLASS, dialog);
- gtk_widget_destroy(dialog);
- LEAVE(" ");
+ ENTER(" ");
+ dialog = GTK_WIDGET(user_data);
+ gnc_unregister_gui_component_by_data(DIALOG_TOTD_CM_CLASS, dialog);
+ gtk_widget_destroy(dialog);
+ LEAVE(" ");
}
@@ -249,38 +256,40 @@
void
gnc_totd_dialog (GtkWindow *parent, gboolean startup)
{
- GladeXML *xml;
- GtkWidget *dialog, *button;
- gboolean show_tips;
+ GladeXML *xml;
+ GtkWidget *dialog, *button;
+ gboolean show_tips;
- show_tips = gnc_gconf_get_bool(GCONF_SECTION, KEY_SHOW_TIPS, NULL);
- if (startup && !show_tips)
- return;
+ show_tips = gnc_gconf_get_bool(GCONF_SECTION, KEY_SHOW_TIPS, NULL);
+ if (startup && !show_tips)
+ return;
- if (tip_count == -1) {
- if (!gnc_totd_initialize())
- return;
- current_tip_number = gnc_gconf_get_int(GCONF_SECTION, KEY_CURRENT_TIP, NULL);
- }
+ if (tip_count == -1)
+ {
+ if (!gnc_totd_initialize())
+ return;
+ current_tip_number = gnc_gconf_get_int(GCONF_SECTION, KEY_CURRENT_TIP, NULL);
+ }
- if (gnc_forall_gui_components(DIALOG_TOTD_CM_CLASS, show_handler, NULL)) {
- return;
- }
+ if (gnc_forall_gui_components(DIALOG_TOTD_CM_CLASS, show_handler, NULL))
+ {
+ return;
+ }
- xml = gnc_glade_xml_new ("totd.glade", "totd_dialog");
- dialog = glade_xml_get_widget (xml, "totd_dialog");
- gtk_window_set_transient_for(GTK_WINDOW (dialog), parent);
- glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func,
- dialog);
+ xml = gnc_glade_xml_new ("totd.glade", "totd_dialog");
+ dialog = glade_xml_get_widget (xml, "totd_dialog");
+ gtk_window_set_transient_for(GTK_WINDOW (dialog), parent);
+ glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func,
+ dialog);
- gnc_new_tip_number(dialog, 1);
+ gnc_new_tip_number(dialog, 1);
- button = glade_xml_get_widget(xml, "show_checkbutton");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (button), show_tips);
+ button = glade_xml_get_widget(xml, "show_checkbutton");
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (button), show_tips);
- gnc_restore_window_size(GCONF_SECTION, GTK_WINDOW(dialog));
- gtk_widget_show(GTK_WIDGET (dialog));
+ gnc_restore_window_size(GCONF_SECTION, GTK_WINDOW(dialog));
+ gtk_widget_show(GTK_WIDGET (dialog));
- gnc_register_gui_component(DIALOG_TOTD_CM_CLASS,
- NULL, close_handler, dialog);
+ gnc_register_gui_component(DIALOG_TOTD_CM_CLASS,
+ NULL, close_handler, dialog);
}
Modified: gnucash/trunk/src/gnome-utils/dialog-totd.h
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-totd.h 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/dialog-totd.h 2010-03-02 21:42:11 UTC (rev 18791)
@@ -19,11 +19,11 @@
* Free Software Foundation Voice: +1-617-542-5942
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
* Boston, MA 02110-1301, USA gnu at gnu.org
- */
+ */
#ifndef DIALOG_TOTD_H
#define DIALOG_TOTD_H
void gnc_totd_dialog (GtkWindow *parent, gboolean startup);
-#endif
+#endif
Modified: gnucash/trunk/src/gnome-utils/dialog-transfer.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-transfer.c 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/dialog-transfer.c 2010-03-02 21:42:11 UTC (rev 18791)
@@ -57,8 +57,8 @@
typedef enum
{
- XFER_DIALOG_FROM,
- XFER_DIALOG_TO
+ XFER_DIALOG_FROM,
+ XFER_DIALOG_TO
} XferDirection;
@@ -67,84 +67,84 @@
struct _xferDialog
{
- GtkWidget * dialog;
+ GtkWidget * dialog;
- GtkWidget * amount_edit;
- GtkWidget * date_entry;
- GtkWidget * num_entry;
- GtkWidget * description_entry;
- GtkWidget * memo_entry;
- GtkWidget * conv_forward;
- GtkWidget * conv_reverse;
+ GtkWidget * amount_edit;
+ GtkWidget * date_entry;
+ GtkWidget * num_entry;
+ GtkWidget * description_entry;
+ GtkWidget * memo_entry;
+ GtkWidget * conv_forward;
+ GtkWidget * conv_reverse;
- GtkWidget * from_window;
- GtkTreeView * from_tree_view;
- gnc_commodity * from_commodity;
- GtkWidget * to_window;
- GtkTreeView * to_tree_view;
- gnc_commodity * to_commodity;
+ GtkWidget * from_window;
+ GtkTreeView * from_tree_view;
+ gnc_commodity * from_commodity;
+ GtkWidget * to_window;
+ GtkTreeView * to_tree_view;
+ gnc_commodity * to_commodity;
- QuickFill * qf; /* Quickfill on transfer descriptions,
+ QuickFill * qf; /* Quickfill on transfer descriptions,
defaults to matching on the "From" account. */
- XferDirection quickfill; /* direction match on the account instead. */
+ XferDirection quickfill; /* direction match on the account instead. */
- /* stored data for the description quickfill selection function */
- gint desc_start_selection;
- gint desc_end_selection;
- guint desc_selection_source_id;
+ /* stored data for the description quickfill selection function */
+ gint desc_start_selection;
+ gint desc_end_selection;
+ guint desc_selection_source_id;
- GtkWidget * transferinfo_label;
+ GtkWidget * transferinfo_label;
- GtkWidget * from_transfer_label;
- GtkWidget * to_transfer_label;
+ GtkWidget * from_transfer_label;
+ GtkWidget * to_transfer_label;
- GtkWidget * from_currency_label;
- GtkWidget * to_currency_label;
+ GtkWidget * from_currency_label;
+ GtkWidget * to_currency_label;
- GtkWidget * from_show_button;
- GtkWidget * to_show_button;
+ GtkWidget * from_show_button;
+ GtkWidget * to_show_button;
- GtkWidget * curr_xfer_table;
+ GtkWidget * curr_xfer_table;
- GtkWidget * price_edit;
- GtkWidget * to_amount_edit;
+ GtkWidget * price_edit;
+ GtkWidget * to_amount_edit;
- GtkWidget * price_radio;
- GtkWidget * amount_radio;
+ GtkWidget * price_radio;
+ GtkWidget * amount_radio;
- GtkWidget * fetch_button;
+ GtkWidget * fetch_button;
- GtkTooltips *tips;
+ GtkTooltips *tips;
- QofBook * book;
- GNCPriceDB * pricedb;
+ QofBook * book;
+ GNCPriceDB * pricedb;
- /* Where to store the "exchange_rate" at exit (in lieu of
- * creating a transaction)
- */
- gnc_numeric * exch_rate;
+ /* Where to store the "exchange_rate" at exit (in lieu of
+ * creating a transaction)
+ */
+ gnc_numeric * exch_rate;
- /* Callback funtion to notify of the newly created Transaction */
- gnc_xfer_dialog_cb transaction_cb;
- /* , and its user_data */
- gpointer transaction_user_data;
+ /* Callback funtion to notify of the newly created Transaction */
+ gnc_xfer_dialog_cb transaction_cb;
+ /* , and its user_data */
+ gpointer transaction_user_data;
};
/** Structure passed to "filter tree accounts" function to provide it information */
typedef struct
{
- /** Show income/expense accounts in tree */
+ /** Show income/expense accounts in tree */
gboolean show_inc_exp;
- /** Show hidden accounts in tree */
- gboolean show_hidden;
+ /** Show hidden accounts in tree */
+ gboolean show_hidden;
} AccountTreeFilterInfo;
struct _acct_list_item
{
- char *acct_full_name;
- Account *acct;
+ char *acct_full_name;
+ Account *acct;
};
typedef struct _acct_list_item acct_list_item;
@@ -154,10 +154,10 @@
static void gnc_xfer_dialog_update_conv_info(XferDialog *xferData);
static Account *gnc_transfer_dialog_get_selected_account (XferDialog *dialog,
- XferDirection direction);
+ XferDirection direction);
static void gnc_transfer_dialog_set_selected_account (XferDialog *dialog,
- Account *account,
- XferDirection direction);
+ Account *account,
+ XferDirection direction);
void gnc_xfer_dialog_response_cb (GtkDialog *dialog, gint response, gpointer data);
void gnc_xfer_dialog_close_cb(GtkDialog *dialog, gpointer data);
@@ -166,84 +166,89 @@
static gnc_numeric
gnc_xfer_dialog_compute_price (XferDialog *xferData)
{
- gnc_numeric from_amt, to_amt;
+ gnc_numeric from_amt, to_amt;
- from_amt = gnc_amount_edit_get_amount(GNC_AMOUNT_EDIT(xferData->amount_edit));
- to_amt = gnc_amount_edit_get_amount(GNC_AMOUNT_EDIT(xferData->to_amount_edit));
+ from_amt = gnc_amount_edit_get_amount(GNC_AMOUNT_EDIT(xferData->amount_edit));
+ to_amt = gnc_amount_edit_get_amount(GNC_AMOUNT_EDIT(xferData->to_amount_edit));
- return(gnc_numeric_div(to_amt, from_amt, GNC_DENOM_AUTO, GNC_DENOM_REDUCE));
+ return(gnc_numeric_div(to_amt, from_amt, GNC_DENOM_AUTO, GNC_DENOM_REDUCE));
}
/* (maybe) update the price from the pricedb. */
static void
gnc_xfer_dialog_update_price (XferDialog *xferData)
{
- GNCPrice *prc;
- gnc_numeric price;
- Timespec date;
- gnc_commodity *from = xferData->from_commodity;
- gnc_commodity *to = xferData->to_commodity;
+ GNCPrice *prc;
+ gnc_numeric price;
+ Timespec date;
+ gnc_commodity *from = xferData->from_commodity;
+ gnc_commodity *to = xferData->to_commodity;
- if (!xferData) return;
- if (!xferData->from_commodity || ! xferData->to_commodity) return;
- if (gnc_commodity_equal (xferData->from_commodity, xferData->to_commodity))
- return;
- if (!xferData->pricedb) return;
+ if (!xferData) return;
+ if (!xferData->from_commodity || ! xferData->to_commodity) return;
+ if (gnc_commodity_equal (xferData->from_commodity, xferData->to_commodity))
+ return;
+ if (!xferData->pricedb) return;
- /* when do we update, and when do we NOT update? */
+ /* when do we update, and when do we NOT update? */
- /* XXX: I'm ALWAYS going to update whenver we get called */
+ /* XXX: I'm ALWAYS going to update whenver we get called */
- /* grab the price nearest to the DATE out of the pricedb */
- date = gnc_date_edit_get_date_ts (GNC_DATE_EDIT (xferData->date_entry));
- prc = gnc_pricedb_lookup_nearest_in_time (xferData->pricedb,
- from, to, date);
-
- if (prc) {
- /* grab the price from the pricedb */
- price = gnc_price_get_value (prc);
- PINFO("Found price: 1 %s = %f %s", gnc_commodity_get_mnemonic(from),
- gnc_numeric_to_double(price), gnc_commodity_get_mnemonic(to));
- } else {
+ /* grab the price nearest to the DATE out of the pricedb */
+ date = gnc_date_edit_get_date_ts (GNC_DATE_EDIT (xferData->date_entry));
prc = gnc_pricedb_lookup_nearest_in_time (xferData->pricedb,
- to, from, date);
- if (!prc)
- return;
- price = gnc_price_get_value (prc);
- PINFO("Found reverse price: 1 %s = %f %s", gnc_commodity_get_mnemonic(to),
- gnc_numeric_to_double(price), gnc_commodity_get_mnemonic(from));
- price = gnc_numeric_div (gnc_numeric_create (1, 1), price,
- GNC_DENOM_AUTO, GNC_DENOM_REDUCE);
- }
+ from, to, date);
- /* and set the price entry */
- gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (xferData->price_edit), price);
+ if (prc)
+ {
+ /* grab the price from the pricedb */
+ price = gnc_price_get_value (prc);
+ PINFO("Found price: 1 %s = %f %s", gnc_commodity_get_mnemonic(from),
+ gnc_numeric_to_double(price), gnc_commodity_get_mnemonic(to));
+ }
+ else
+ {
+ prc = gnc_pricedb_lookup_nearest_in_time (xferData->pricedb,
+ to, from, date);
+ if (!prc)
+ return;
+ price = gnc_price_get_value (prc);
+ PINFO("Found reverse price: 1 %s = %f %s", gnc_commodity_get_mnemonic(to),
+ gnc_numeric_to_double(price), gnc_commodity_get_mnemonic(from));
+ price = gnc_numeric_div (gnc_numeric_create (1, 1), price,
+ GNC_DENOM_AUTO, GNC_DENOM_REDUCE);
+ }
- /* And then update the to_amount */
- gnc_xfer_update_to_amount (xferData);
+ /* and set the price entry */
+ gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (xferData->price_edit), price);
+
+ /* And then update the to_amount */
+ gnc_xfer_update_to_amount (xferData);
}
static void
gnc_xfer_dialog_toggle_cb(GtkToggleButton *button, gpointer data)
{
- gnc_tree_view_account_refilter (GNC_TREE_VIEW_ACCOUNT (data));
+ gnc_tree_view_account_refilter (GNC_TREE_VIEW_ACCOUNT (data));
}
static gboolean
gnc_xfer_dialog_key_press_cb (GtkWidget *widget,
- GdkEventKey *event,
- gpointer unused)
+ GdkEventKey *event,
+ gpointer unused)
{
- GtkWidget *toplevel;
+ GtkWidget *toplevel;
- if ((event->keyval == GDK_Return) || (event->keyval == GDK_KP_Enter)) {
- toplevel = gtk_widget_get_toplevel (widget);
- if (GTK_WIDGET_TOPLEVEL(toplevel) && GTK_IS_WINDOW(toplevel)) {
- gtk_window_activate_default(GTK_WINDOW(toplevel));
- return TRUE;
+ if ((event->keyval == GDK_Return) || (event->keyval == GDK_KP_Enter))
+ {
+ toplevel = gtk_widget_get_toplevel (widget);
+ if (GTK_WIDGET_TOPLEVEL(toplevel) && GTK_IS_WINDOW(toplevel))
+ {
+ gtk_window_activate_default(GTK_WINDOW(toplevel));
+ return TRUE;
+ }
}
- }
- return FALSE;
+ return FALSE;
}
static void
@@ -252,100 +257,100 @@
const gnc_commodity *from_currency,
const gnc_commodity *to_currency)
{
- gnc_numeric from_rate;
- gnc_numeric to_rate;
- gnc_numeric price;
+ gnc_numeric from_rate;
+ gnc_numeric to_rate;
+ gnc_numeric price;
- if (!currency_active)
- {
- GtkEntry *entry;
+ if (!currency_active)
+ {
+ GtkEntry *entry;
- gnc_amount_edit_set_amount(GNC_AMOUNT_EDIT(xferData->price_edit),
- gnc_numeric_zero ());
- entry = GTK_ENTRY(gnc_amount_edit_gtk_entry
- (GNC_AMOUNT_EDIT(xferData->price_edit)));
- gtk_entry_set_text(entry, "");
+ gnc_amount_edit_set_amount(GNC_AMOUNT_EDIT(xferData->price_edit),
+ gnc_numeric_zero ());
+ entry = GTK_ENTRY(gnc_amount_edit_gtk_entry
+ (GNC_AMOUNT_EDIT(xferData->price_edit)));
+ gtk_entry_set_text(entry, "");
- gnc_xfer_update_to_amount (xferData);
+ gnc_xfer_update_to_amount (xferData);
- return;
- }
+ return;
+ }
- if (!gnc_is_euro_currency (from_currency) ||
- !gnc_is_euro_currency (to_currency))
- {
- gnc_xfer_dialog_update_price (xferData);
- return;
- }
+ if (!gnc_is_euro_currency (from_currency) ||
+ !gnc_is_euro_currency (to_currency))
+ {
+ gnc_xfer_dialog_update_price (xferData);
+ return;
+ }
- from_rate = gnc_euro_currency_get_rate (from_currency);
- to_rate = gnc_euro_currency_get_rate (to_currency);
+ from_rate = gnc_euro_currency_get_rate (from_currency);
+ to_rate = gnc_euro_currency_get_rate (to_currency);
- if (gnc_numeric_zero_p (from_rate) || gnc_numeric_zero_p (to_rate))
- gnc_xfer_dialog_update_price (xferData);
+ if (gnc_numeric_zero_p (from_rate) || gnc_numeric_zero_p (to_rate))
+ gnc_xfer_dialog_update_price (xferData);
- price = gnc_numeric_div (to_rate, from_rate, GNC_DENOM_AUTO, GNC_DENOM_REDUCE);
+ price = gnc_numeric_div (to_rate, from_rate, GNC_DENOM_AUTO, GNC_DENOM_REDUCE);
- gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT(xferData->price_edit), price);
+ gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT(xferData->price_edit), price);
- gnc_xfer_update_to_amount (xferData);
+ gnc_xfer_update_to_amount (xferData);
}
static void
gnc_xfer_dialog_curr_acct_activate(XferDialog *xferData)
{
- Account *to_account;
- Account *from_account;
- gboolean curr_active;
+ Account *to_account;
+ Account *from_account;
+ gboolean curr_active;
- from_account =
- gnc_transfer_dialog_get_selected_account (xferData, XFER_DIALOG_FROM);
+ from_account =
+ gnc_transfer_dialog_get_selected_account (xferData, XFER_DIALOG_FROM);
- to_account =
- gnc_transfer_dialog_get_selected_account (xferData, XFER_DIALOG_TO);
+ to_account =
+ gnc_transfer_dialog_get_selected_account (xferData, XFER_DIALOG_TO);
- curr_active = (xferData->exch_rate ||
- ((from_account != NULL) && (to_account != NULL)))
- && !gnc_commodity_equiv(xferData->from_commodity,
- xferData->to_commodity);
+ curr_active = (xferData->exch_rate ||
+ ((from_account != NULL) && (to_account != NULL)))
+ && !gnc_commodity_equiv(xferData->from_commodity,
+ xferData->to_commodity);
- gtk_widget_set_sensitive(xferData->curr_xfer_table, curr_active);
- gtk_widget_set_sensitive(xferData->price_edit,
- curr_active && gtk_toggle_button_get_active
- (GTK_TOGGLE_BUTTON(xferData->price_radio)));
- gtk_widget_set_sensitive(xferData->to_amount_edit,
- curr_active && gtk_toggle_button_get_active
- (GTK_TOGGLE_BUTTON(xferData->amount_radio)));
- gtk_widget_set_sensitive(xferData->price_radio, curr_active);
- gtk_widget_set_sensitive(xferData->amount_radio, curr_active);
+ gtk_widget_set_sensitive(xferData->curr_xfer_table, curr_active);
+ gtk_widget_set_sensitive(xferData->price_edit,
+ curr_active && gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON(xferData->price_radio)));
+ gtk_widget_set_sensitive(xferData->to_amount_edit,
+ curr_active && gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON(xferData->amount_radio)));
+ gtk_widget_set_sensitive(xferData->price_radio, curr_active);
+ gtk_widget_set_sensitive(xferData->amount_radio, curr_active);
- gnc_xfer_dialog_set_price_auto (xferData, curr_active,
- xferData->from_commodity, xferData->to_commodity);
- gnc_xfer_dialog_update_conv_info(xferData);
+ gnc_xfer_dialog_set_price_auto (xferData, curr_active,
+ xferData->from_commodity, xferData->to_commodity);
+ gnc_xfer_dialog_update_conv_info(xferData);
- if (!curr_active)
- {
- GtkEntry *entry;
+ if (!curr_active)
+ {
+ GtkEntry *entry;
- gnc_amount_edit_set_amount(GNC_AMOUNT_EDIT(xferData->to_amount_edit),
- gnc_numeric_zero ());
- entry = GTK_ENTRY(gnc_amount_edit_gtk_entry
- (GNC_AMOUNT_EDIT(xferData->to_amount_edit)));
- gtk_entry_set_text(entry, "");
- }
+ gnc_amount_edit_set_amount(GNC_AMOUNT_EDIT(xferData->to_amount_edit),
+ gnc_numeric_zero ());
+ entry = GTK_ENTRY(gnc_amount_edit_gtk_entry
+ (GNC_AMOUNT_EDIT(xferData->to_amount_edit)));
+ gtk_entry_set_text(entry, "");
+ }
}
static void
price_amount_radio_toggled_cb(GtkToggleButton *togglebutton, gpointer data)
{
- XferDialog *xferData = data;
+ XferDialog *xferData = data;
- gtk_widget_set_sensitive(xferData->price_edit, gtk_toggle_button_get_active
- (GTK_TOGGLE_BUTTON(xferData->price_radio)));
- gtk_widget_set_sensitive(xferData->to_amount_edit,
- gtk_toggle_button_get_active
- (GTK_TOGGLE_BUTTON(xferData->amount_radio)));
+ gtk_widget_set_sensitive(xferData->price_edit, gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON(xferData->price_radio)));
+ gtk_widget_set_sensitive(xferData->to_amount_edit,
+ gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON(xferData->amount_radio)));
}
@@ -358,212 +363,219 @@
static void
gnc_xfer_dialog_reload_quickfill( XferDialog *xferData )
{
- GList *splitlist, *node;
- Split *split;
- Transaction *trans;
- Account *account;
+ GList *splitlist, *node;
+ Split *split;
+ Transaction *trans;
+ Account *account;
- account = gnc_transfer_dialog_get_selected_account (xferData, xferData->quickfill);
+ account = gnc_transfer_dialog_get_selected_account (xferData, xferData->quickfill);
- /* get a new QuickFill to use */
- gnc_quickfill_destroy( xferData->qf );
- xferData->qf = gnc_quickfill_new();
+ /* get a new QuickFill to use */
+ gnc_quickfill_destroy( xferData->qf );
+ xferData->qf = gnc_quickfill_new();
- splitlist = xaccAccountGetSplitList( account );
+ splitlist = xaccAccountGetSplitList( account );
- for( node = splitlist; node; node = node->next )
- {
- split = node->data;
- trans = xaccSplitGetParent( split );
- gnc_quickfill_insert( xferData->qf,
- xaccTransGetDescription (trans), QUICKFILL_LIFO);
- }
+ for ( node = splitlist; node; node = node->next )
+ {
+ split = node->data;
+ trans = xaccSplitGetParent( split );
+ gnc_quickfill_insert( xferData->qf,
+ xaccTransGetDescription (trans), QUICKFILL_LIFO);
+ }
}
static void
gnc_xfer_dialog_from_tree_selection_changed_cb (GtkTreeSelection *selection,
- gpointer data)
+ gpointer data)
{
- XferDialog *xferData = data;
- GNCPrintAmountInfo print_info;
- gnc_commodity *commodity;
- Account *account;
+ XferDialog *xferData = data;
+ GNCPrintAmountInfo print_info;
+ gnc_commodity *commodity;
+ Account *account;
- account = gnc_transfer_dialog_get_selected_account (xferData, XFER_DIALOG_FROM);
- if (!account)
- return;
+ account = gnc_transfer_dialog_get_selected_account (xferData, XFER_DIALOG_FROM);
+ if (!account)
+ return;
- commodity = xaccAccountGetCommodity(account);
- gtk_label_set_text(GTK_LABEL(xferData->from_currency_label),
- gnc_commodity_get_printname(commodity));
+ commodity = xaccAccountGetCommodity(account);
+ gtk_label_set_text(GTK_LABEL(xferData->from_currency_label),
+ gnc_commodity_get_printname(commodity));
- xferData->from_commodity = commodity;
+ xferData->from_commodity = commodity;
- print_info = gnc_account_print_info (account, FALSE);
- gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (xferData->amount_edit),
- print_info);
- gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (xferData->amount_edit),
- xaccAccountGetCommoditySCU (account));
+ print_info = gnc_account_print_info (account, FALSE);
+ gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (xferData->amount_edit),
+ print_info);
+ gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (xferData->amount_edit),
+ xaccAccountGetCommoditySCU (account));
- gnc_xfer_dialog_curr_acct_activate(xferData);
+ gnc_xfer_dialog_curr_acct_activate(xferData);
- /* Reload the xferDialog quickfill if it is based on the from account */
- if (xferData->quickfill == XFER_DIALOG_FROM)
- gnc_xfer_dialog_reload_quickfill(xferData);
+ /* Reload the xferDialog quickfill if it is based on the from account */
+ if (xferData->quickfill == XFER_DIALOG_FROM)
+ gnc_xfer_dialog_reload_quickfill(xferData);
}
static void
gnc_xfer_dialog_to_tree_selection_changed_cb (GtkTreeSelection *selection, gpointer data)
{
- XferDialog *xferData = data;
- GNCPrintAmountInfo print_info;
- gnc_commodity *commodity;
- Account *account;
+ XferDialog *xferData = data;
+ GNCPrintAmountInfo print_info;
+ gnc_commodity *commodity;
+ Account *account;
- account = gnc_transfer_dialog_get_selected_account (xferData, XFER_DIALOG_TO);
- if (!account)
- return;
+ account = gnc_transfer_dialog_get_selected_account (xferData, XFER_DIALOG_TO);
+ if (!account)
+ return;
- commodity = xaccAccountGetCommodity(account);
- gtk_label_set_text(GTK_LABEL(xferData->to_currency_label),
- gnc_commodity_get_printname(commodity));
+ commodity = xaccAccountGetCommodity(account);
+ gtk_label_set_text(GTK_LABEL(xferData->to_currency_label),
+ gnc_commodity_get_printname(commodity));
- xferData->to_commodity = commodity;
+ xferData->to_commodity = commodity;
- print_info = gnc_account_print_info (account, FALSE);
- gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (xferData->to_amount_edit),
- print_info);
- gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (xferData->to_amount_edit),
- xaccAccountGetCommoditySCU (account));
+ print_info = gnc_account_print_info (account, FALSE);
+ gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (xferData->to_amount_edit),
+ print_info);
+ gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (xferData->to_amount_edit),
+ xaccAccountGetCommoditySCU (account));
- gnc_xfer_dialog_curr_acct_activate(xferData);
+ gnc_xfer_dialog_curr_acct_activate(xferData);
- /* Reload the xferDialog quickfill if it is based on the to account */
- if (xferData->quickfill == XFER_DIALOG_TO)
- gnc_xfer_dialog_reload_quickfill(xferData);
+ /* Reload the xferDialog quickfill if it is based on the to account */
+ if (xferData->quickfill == XFER_DIALOG_TO)
+ gnc_xfer_dialog_reload_quickfill(xferData);
}
static gboolean
gnc_xfer_dialog_show_inc_exp_visible_cb (Account *account,
- gpointer data)
+ gpointer data)
{
- AccountTreeFilterInfo* info;
- GNCAccountType type;
+ AccountTreeFilterInfo* info;
+ GNCAccountType type;
- info = (AccountTreeFilterInfo*)data;
+ info = (AccountTreeFilterInfo*)data;
- if (!info->show_hidden && xaccAccountIsHidden(account)) {
- return FALSE;
- }
+ if (!info->show_hidden && xaccAccountIsHidden(account))
+ {
+ return FALSE;
+ }
- if (info->show_inc_exp) {
- return TRUE;
- }
+ if (info->show_inc_exp)
+ {
+ return TRUE;
+ }
- type = xaccAccountGetType(account);
- return ((type != ACCT_TYPE_INCOME) && (type != ACCT_TYPE_EXPENSE));
+ type = xaccAccountGetType(account);
+ return ((type != ACCT_TYPE_INCOME) && (type != ACCT_TYPE_EXPENSE));
}
static void
gnc_xfer_dialog_fill_tree_view(XferDialog *xferData,
- XferDirection direction)
+ XferDirection direction)
{
- GtkTreeView *tree_view;
- const char *show_inc_exp_message = _("Show the income and expense accounts");
- GtkWidget *scroll_win;
- GtkWidget *button;
- GtkTreeSelection *selection;
- gboolean use_accounting_labels;
- AccountTreeFilterInfo info;
+ GtkTreeView *tree_view;
+ const char *show_inc_exp_message = _("Show the income and expense accounts");
+ GtkWidget *scroll_win;
+ GtkWidget *button;
+ GtkTreeSelection *selection;
+ gboolean use_accounting_labels;
+ AccountTreeFilterInfo info;
- use_accounting_labels = gnc_gconf_get_bool(GCONF_GENERAL,
- KEY_ACCOUNTING_LABELS, NULL);
+ use_accounting_labels = gnc_gconf_get_bool(GCONF_GENERAL,
+ KEY_ACCOUNTING_LABELS, NULL);
- /* In "normal" mode (non accounting terms) the account where the
- * money comes from is displayed on the left side and the account
- * where the money gets transferred to is displayed on the right
- * side. In accounting terms the "from" account is called the
- * "credit" account ("Haben" in german) and the "to" account is
- * called "debit" account ("Soll" in german). Accountants told me
- * that they always want the credit account on the right side
- * and the debit on the left side (like the debit and credit
- * columns in the register window). So reverse from and to account
- * trees when in "accountant" mode. -- Herbert Thoma, 2004-01-18
- */
- if(use_accounting_labels) {
- button = gnc_glade_lookup_widget (xferData->dialog,
- (direction == XFER_DIALOG_TO) ?
- "left_show_button" : "right_show_button");
- scroll_win = gnc_glade_lookup_widget (xferData->dialog,
- (direction == XFER_DIALOG_TO) ?
- "left_trans_window" : "right_trans_window");
- }
- else {
- button = gnc_glade_lookup_widget (xferData->dialog,
- (direction == XFER_DIALOG_TO) ?
- "right_show_button" : "left_show_button");
- scroll_win = gnc_glade_lookup_widget (xferData->dialog,
- (direction == XFER_DIALOG_TO) ?
- "right_trans_window" : "left_trans_window");
- }
+ /* In "normal" mode (non accounting terms) the account where the
+ * money comes from is displayed on the left side and the account
+ * where the money gets transferred to is displayed on the right
+ * side. In accounting terms the "from" account is called the
+ * "credit" account ("Haben" in german) and the "to" account is
+ * called "debit" account ("Soll" in german). Accountants told me
+ * that they always want the credit account on the right side
+ * and the debit on the left side (like the debit and credit
+ * columns in the register window). So reverse from and to account
+ * trees when in "accountant" mode. -- Herbert Thoma, 2004-01-18
+ */
+ if (use_accounting_labels)
+ {
+ button = gnc_glade_lookup_widget (xferData->dialog,
+ (direction == XFER_DIALOG_TO) ?
+ "left_show_button" : "right_show_button");
+ scroll_win = gnc_glade_lookup_widget (xferData->dialog,
+ (direction == XFER_DIALOG_TO) ?
+ "left_trans_window" : "right_trans_window");
+ }
+ else
+ {
+ button = gnc_glade_lookup_widget (xferData->dialog,
+ (direction == XFER_DIALOG_TO) ?
+ "right_show_button" : "left_show_button");
+ scroll_win = gnc_glade_lookup_widget (xferData->dialog,
+ (direction == XFER_DIALOG_TO) ?
+ "right_trans_window" : "left_trans_window");
+ }
- tree_view = GTK_TREE_VIEW(gnc_tree_view_account_new(FALSE));
- gtk_container_add(GTK_CONTAINER(scroll_win), GTK_WIDGET(tree_view));
- info.show_inc_exp = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
- info.show_hidden = FALSE;
- gnc_tree_view_account_set_filter (GNC_TREE_VIEW_ACCOUNT (tree_view),
- gnc_xfer_dialog_show_inc_exp_visible_cb,
- &info, /* user data */
- NULL /* destroy callback */);
+ tree_view = GTK_TREE_VIEW(gnc_tree_view_account_new(FALSE));
+ gtk_container_add(GTK_CONTAINER(scroll_win), GTK_WIDGET(tree_view));
+ info.show_inc_exp = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
+ info.show_hidden = FALSE;
+ gnc_tree_view_account_set_filter (GNC_TREE_VIEW_ACCOUNT (tree_view),
+ gnc_xfer_dialog_show_inc_exp_visible_cb,
+ &info, /* user data */
+ NULL /* destroy callback */);
- /* Have to force the filter once. Alt is to show income/expense by default. */
- gnc_tree_view_account_refilter (GNC_TREE_VIEW_ACCOUNT (tree_view));
- gtk_widget_show(GTK_WIDGET(tree_view));
- g_signal_connect (G_OBJECT (tree_view), "key-press-event",
- G_CALLBACK (gnc_xfer_dialog_key_press_cb), NULL);
+ /* Have to force the filter once. Alt is to show income/expense by default. */
+ gnc_tree_view_account_refilter (GNC_TREE_VIEW_ACCOUNT (tree_view));
+ gtk_widget_show(GTK_WIDGET(tree_view));
+ g_signal_connect (G_OBJECT (tree_view), "key-press-event",
+ G_CALLBACK (gnc_xfer_dialog_key_press_cb), NULL);
- selection = gtk_tree_view_get_selection (tree_view);
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
+ selection = gtk_tree_view_get_selection (tree_view);
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE);
- gtk_tooltips_set_tip (xferData->tips, GTK_WIDGET (button), show_inc_exp_message, NULL);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE);
+ gtk_tooltips_set_tip (xferData->tips, GTK_WIDGET (button), show_inc_exp_message, NULL);
- if (direction == XFER_DIALOG_TO) {
- xferData->to_tree_view = tree_view;
- xferData->to_window = scroll_win;
- xferData->to_show_button = GTK_WIDGET (button);
- g_signal_connect (G_OBJECT (selection), "changed",
- G_CALLBACK (gnc_xfer_dialog_to_tree_selection_changed_cb), xferData);
- } else {
- xferData->from_tree_view = tree_view;
- xferData->from_window = scroll_win;
- xferData->from_show_button = GTK_WIDGET (button);
- g_signal_connect (G_OBJECT (selection), "changed",
- G_CALLBACK (gnc_xfer_dialog_from_tree_selection_changed_cb), xferData);
- }
- g_signal_connect (G_OBJECT (button), "toggled",
- G_CALLBACK (gnc_xfer_dialog_toggle_cb), tree_view);
+ if (direction == XFER_DIALOG_TO)
+ {
+ xferData->to_tree_view = tree_view;
+ xferData->to_window = scroll_win;
+ xferData->to_show_button = GTK_WIDGET (button);
+ g_signal_connect (G_OBJECT (selection), "changed",
+ G_CALLBACK (gnc_xfer_dialog_to_tree_selection_changed_cb), xferData);
+ }
+ else
+ {
+ xferData->from_tree_view = tree_view;
+ xferData->from_window = scroll_win;
+ xferData->from_show_button = GTK_WIDGET (button);
+ g_signal_connect (G_OBJECT (selection), "changed",
+ G_CALLBACK (gnc_xfer_dialog_from_tree_selection_changed_cb), xferData);
+ }
+ g_signal_connect (G_OBJECT (button), "toggled",
+ G_CALLBACK (gnc_xfer_dialog_toggle_cb), tree_view);
}
static void
gnc_parse_error_dialog (XferDialog *xferData, const char *error_string)
{
- const char * parse_error_string;
+ const char * parse_error_string;
- parse_error_string = gnc_exp_parser_error_string ();
- if (parse_error_string == NULL)
- parse_error_string = "";
+ parse_error_string = gnc_exp_parser_error_string ();
+ if (parse_error_string == NULL)
+ parse_error_string = "";
- if (error_string == NULL)
- error_string = "";
+ if (error_string == NULL)
+ error_string = "";
- gnc_error_dialog (xferData->dialog,
- "%s\n\n%s: %s.",
- error_string, _("Error"),
- parse_error_string);
+ gnc_error_dialog (xferData->dialog,
+ "%s\n\n%s: %s.",
+ error_string, _("Error"),
+ parse_error_string);
}
/*** Callbacks for description quickfill. ***/
@@ -577,117 +589,120 @@
static gboolean
gnc_xfer_dialog_quickfill( XferDialog *xferData )
{
- const char *desc;
- Account *match_account; /* the matched text was from this account */
- Split *split; /* the split to autocomplete from */
- Split *other = NULL; /* the other split of the transaction */
- Account *other_acct = NULL; /* the Account of the other split */
- gboolean changed = FALSE;
+ const char *desc;
+ Account *match_account; /* the matched text was from this account */
+ Split *split; /* the split to autocomplete from */
+ Split *other = NULL; /* the other split of the transaction */
+ Account *other_acct = NULL; /* the Account of the other split */
+ gboolean changed = FALSE;
- ENTER("xferData=%p", xferData);
- if( !xferData ) {
- LEAVE("bad args");
- return( FALSE );
- }
+ ENTER("xferData=%p", xferData);
+ if ( !xferData )
+ {
+ LEAVE("bad args");
+ return( FALSE );
+ }
- match_account = gnc_transfer_dialog_get_selected_account (xferData, xferData->quickfill);
+ match_account = gnc_transfer_dialog_get_selected_account (xferData, xferData->quickfill);
- desc = gtk_entry_get_text( GTK_ENTRY(xferData->description_entry) );
+ desc = gtk_entry_get_text( GTK_ENTRY(xferData->description_entry) );
- if( !desc || desc[0] == '\0' ) /* no description to match */
- return( FALSE );
+ if ( !desc || desc[0] == '\0' ) /* no description to match */
+ return( FALSE );
- split = xaccAccountFindSplitByDesc( match_account, desc );
+ split = xaccAccountFindSplitByDesc( match_account, desc );
- if( !split ) {
- LEAVE("split not found");
- return( FALSE );
- }
- DEBUG("split=%p", split);
+ if ( !split )
+ {
+ LEAVE("split not found");
+ return( FALSE );
+ }
+ DEBUG("split=%p", split);
- /* Now update any blank fields of the transfer dialog with
- * the memo and amount from the split, and the description
- * we were passed (assumed to match the split's transaction).
- */
-
- if( gnc_numeric_zero_p(
- gnc_amount_edit_get_amount(GNC_AMOUNT_EDIT(xferData->amount_edit))))
- {
- gnc_numeric amt;
- DEBUG("updating amount");
- amt = xaccSplitGetValue( split );
-
- /* If we've matched a previous transfer, it will appear
- * to be negative in the from account.
- * Need to swap the sign in order for this value
- * to be posted as a withdrawal from the "from" account.
+ /* Now update any blank fields of the transfer dialog with
+ * the memo and amount from the split, and the description
+ * we were passed (assumed to match the split's transaction).
*/
- if( gnc_numeric_negative_p( amt ) )
- amt = gnc_numeric_neg( amt );
- gnc_amount_edit_set_amount( GNC_AMOUNT_EDIT(xferData->amount_edit), amt );
- changed = TRUE;
- }
+ if ( gnc_numeric_zero_p(
+ gnc_amount_edit_get_amount(GNC_AMOUNT_EDIT(xferData->amount_edit))))
+ {
+ gnc_numeric amt;
+ DEBUG("updating amount");
+ amt = xaccSplitGetValue( split );
- if( !safe_strcmp(gtk_entry_get_text(GTK_ENTRY(xferData->memo_entry)),"" ))
- {
- DEBUG("updating memo");
- gtk_entry_set_text( GTK_ENTRY(xferData->memo_entry),
- xaccSplitGetMemo( split ) );
- changed = TRUE;
- }
+ /* If we've matched a previous transfer, it will appear
+ * to be negative in the from account.
+ * Need to swap the sign in order for this value
+ * to be posted as a withdrawal from the "from" account.
+ */
+ if ( gnc_numeric_negative_p( amt ) )
+ amt = gnc_numeric_neg( amt );
- /* Since we're quickfilling off of one account (either from or to)
- * that account must be the account of the matched split.
- * Find the other account from the other split,
- * and select that account in the appropriate account tree.
- */
- if( ( other = xaccSplitGetOtherSplit( split ) ) &&
- ( other_acct = xaccSplitGetAccount( other ) ) )
- {
- GNCAccountType other_type;
- GtkWidget *other_button;
- XferDirection other_direction;
+ gnc_amount_edit_set_amount( GNC_AMOUNT_EDIT(xferData->amount_edit), amt );
+ changed = TRUE;
+ }
- DEBUG("updating other split");
- if (xferData->quickfill == XFER_DIALOG_FROM) {
- other_button = xferData->to_show_button;
- other_direction = XFER_DIALOG_TO;
- }
- else
+ if ( !safe_strcmp(gtk_entry_get_text(GTK_ENTRY(xferData->memo_entry)), "" ))
{
- other_button = xferData->from_show_button;
- other_direction = XFER_DIALOG_FROM;
+ DEBUG("updating memo");
+ gtk_entry_set_text( GTK_ENTRY(xferData->memo_entry),
+ xaccSplitGetMemo( split ) );
+ changed = TRUE;
}
- other_type = xaccAccountGetType(other_acct);
-
- /* Don't want to deactivate the button just because this
- * isn't an income or expense account
+ /* Since we're quickfilling off of one account (either from or to)
+ * that account must be the account of the matched split.
+ * Find the other account from the other split,
+ * and select that account in the appropriate account tree.
*/
- if( (other_type == ACCT_TYPE_EXPENSE) || (other_type == ACCT_TYPE_INCOME) )
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(other_button), TRUE);
+ if ( ( other = xaccSplitGetOtherSplit( split ) ) &&
+ ( other_acct = xaccSplitGetAccount( other ) ) )
+ {
+ GNCAccountType other_type;
+ GtkWidget *other_button;
+ XferDirection other_direction;
- gnc_transfer_dialog_set_selected_account (xferData, other_acct, other_direction);
+ DEBUG("updating other split");
+ if (xferData->quickfill == XFER_DIALOG_FROM)
+ {
+ other_button = xferData->to_show_button;
+ other_direction = XFER_DIALOG_TO;
+ }
+ else
+ {
+ other_button = xferData->from_show_button;
+ other_direction = XFER_DIALOG_FROM;
+ }
- changed = TRUE;
- }
+ other_type = xaccAccountGetType(other_acct);
- return( changed );
+ /* Don't want to deactivate the button just because this
+ * isn't an income or expense account
+ */
+ if ( (other_type == ACCT_TYPE_EXPENSE) || (other_type == ACCT_TYPE_INCOME) )
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(other_button), TRUE);
+
+ gnc_transfer_dialog_set_selected_account (xferData, other_acct, other_direction);
+
+ changed = TRUE;
+ }
+
+ return( changed );
}
static gboolean
idle_select_region(gpointer data)
{
- XferDialog *xferData = data;
- g_return_val_if_fail(xferData, FALSE);
+ XferDialog *xferData = data;
+ g_return_val_if_fail(xferData, FALSE);
- gtk_editable_select_region(GTK_EDITABLE(xferData->description_entry),
- xferData->desc_start_selection,
- xferData->desc_end_selection);
+ gtk_editable_select_region(GTK_EDITABLE(xferData->description_entry),
+ xferData->desc_start_selection,
+ xferData->desc_end_selection);
- xferData->desc_selection_source_id = 0;
- return FALSE;
+ xferData->desc_selection_source_id = 0;
+ return FALSE;
}
/* The insert_cb will do the insert and quickfill if possible and set the
@@ -701,58 +716,59 @@
gint *start_pos,
XferDialog *xferData)
{
- gchar *prefix, *suffix, *new_text;
- QuickFill *match;
- const gchar *match_str;
- gint prefix_len, new_text_len, match_str_len;
+ gchar *prefix, *suffix, *new_text;
+ QuickFill *match;
+ const gchar *match_str;
+ gint prefix_len, new_text_len, match_str_len;
- if (insert_text_len <= 0)
- return;
+ if (insert_text_len <= 0)
+ return;
- suffix = gtk_editable_get_chars(editable, *start_pos, -1);
+ suffix = gtk_editable_get_chars(editable, *start_pos, -1);
- /* If we are inserting in the middle, do nothing */
- if (*suffix) {
+ /* If we are inserting in the middle, do nothing */
+ if (*suffix)
+ {
+ g_free(suffix);
+ return;
+ }
g_free(suffix);
- return;
- }
- g_free(suffix);
- prefix = gtk_editable_get_chars(editable, 0, *start_pos);
- new_text = g_strconcat(prefix, insert_text, (gchar*) NULL);
- prefix_len = strlen(prefix);
- new_text_len = prefix_len + insert_text_len;
- g_free(prefix);
+ prefix = gtk_editable_get_chars(editable, 0, *start_pos);
+ new_text = g_strconcat(prefix, insert_text, (gchar*) NULL);
+ prefix_len = strlen(prefix);
+ new_text_len = prefix_len + insert_text_len;
+ g_free(prefix);
- if ((match = gnc_quickfill_get_string_match(xferData->qf, new_text))
- && (match_str = gnc_quickfill_string(match))
- && ((match_str_len = strlen(match_str)) > new_text_len))
- {
- g_signal_handlers_block_matched (G_OBJECT (editable),
- G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, xferData);
+ if ((match = gnc_quickfill_get_string_match(xferData->qf, new_text))
+ && (match_str = gnc_quickfill_string(match))
+ && ((match_str_len = strlen(match_str)) > new_text_len))
+ {
+ g_signal_handlers_block_matched (G_OBJECT (editable),
+ G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, xferData);
- gtk_editable_insert_text(editable,
- match_str + prefix_len,
- match_str_len - prefix_len,
- start_pos);
+ gtk_editable_insert_text(editable,
+ match_str + prefix_len,
+ match_str_len - prefix_len,
+ start_pos);
- g_signal_handlers_unblock_matched (G_OBJECT (editable),
- G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, xferData);
+ g_signal_handlers_unblock_matched (G_OBJECT (editable),
+ G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, xferData);
- /* stop the current insert */
- g_signal_stop_emission_by_name (G_OBJECT (editable), "insert_text");
+ /* stop the current insert */
+ g_signal_stop_emission_by_name (G_OBJECT (editable), "insert_text");
- /* set the position */
- *start_pos = g_utf8_strlen(new_text, -1);
+ /* set the position */
+ *start_pos = g_utf8_strlen(new_text, -1);
- /* select region on idle, because it would be reset once this function
- finishes */
- xferData->desc_start_selection = *start_pos;
- xferData->desc_end_selection = -1;
- xferData->desc_selection_source_id = g_idle_add(idle_select_region,
- xferData);
- }
- g_free(new_text);
+ /* select region on idle, because it would be reset once this function
+ finishes */
+ xferData->desc_start_selection = *start_pos;
+ xferData->desc_end_selection = -1;
+ xferData->desc_selection_source_id = g_idle_add(idle_select_region,
+ xferData);
+ }
+ g_free(new_text);
}
static gboolean
@@ -760,38 +776,38 @@
GdkEventKey *event,
XferDialog *xferData )
{
- gboolean done_with_input = FALSE;
+ gboolean done_with_input = FALSE;
- /* Most "special" keys are allowed to be handled directly by
- * the entry's key press handler, but in some cases that doesn't
- * seem to work right, so handle them here.
- */
- ENTER(" ");
- switch( event->keyval )
- {
+ /* Most "special" keys are allowed to be handled directly by
+ * the entry's key press handler, but in some cases that doesn't
+ * seem to work right, so handle them here.
+ */
+ ENTER(" ");
+ switch ( event->keyval )
+ {
case GDK_Return:
case GDK_KP_Enter:
- gnc_xfer_dialog_quickfill( xferData );
- /* NOT done with input, activate the default button of the dialog. */
- break;
+ gnc_xfer_dialog_quickfill( xferData );
+ /* NOT done with input, activate the default button of the dialog. */
+ break;
case GDK_Tab:
case GDK_ISO_Left_Tab:
- if( !( event->state & GDK_SHIFT_MASK) ) /* Complete on Tab,
+ if ( !( event->state & GDK_SHIFT_MASK) ) /* Complete on Tab,
* but not Shift-Tab */
- {
- gnc_xfer_dialog_quickfill( xferData );
- /* NOT done with input, though, since we need to focus to the next
- * field. Unselect the current field, though.
- */
- gtk_editable_select_region( GTK_EDITABLE(xferData->description_entry),
- 0, 0 );
- }
- break;
- }
+ {
+ gnc_xfer_dialog_quickfill( xferData );
+ /* NOT done with input, though, since we need to focus to the next
+ * field. Unselect the current field, though.
+ */
+ gtk_editable_select_region( GTK_EDITABLE(xferData->description_entry),
+ 0, 0 );
+ }
+ break;
+ }
- LEAVE("done=%d", done_with_input);
- return( done_with_input );
+ LEAVE("done=%d", done_with_input);
+ return( done_with_input );
}
/*** End of quickfill-specific callbacks ***/
@@ -799,144 +815,147 @@
static void
gnc_xfer_dialog_update_conv_info (XferDialog *xferData)
{
- const gchar *to_mnemonic, *from_mnemonic;
- gchar *string;
- gnc_numeric rate;
+ const gchar *to_mnemonic, *from_mnemonic;
+ gchar *string;
+ gnc_numeric rate;
- from_mnemonic = gnc_commodity_get_mnemonic(xferData->from_commodity);
- to_mnemonic = gnc_commodity_get_mnemonic(xferData->to_commodity);
+ from_mnemonic = gnc_commodity_get_mnemonic(xferData->from_commodity);
+ to_mnemonic = gnc_commodity_get_mnemonic(xferData->to_commodity);
- /* On the theory that if we don't have a mnemonic then we don't
- * have a commodity... On Solaris this crashes without a string.
- * So, just leave now and wait for the second initialization to
- * occur.
- */
- if (!from_mnemonic || !to_mnemonic)
- return;
+ /* On the theory that if we don't have a mnemonic then we don't
+ * have a commodity... On Solaris this crashes without a string.
+ * So, just leave now and wait for the second initialization to
+ * occur.
+ */
+ if (!from_mnemonic || !to_mnemonic)
+ return;
- rate = gnc_amount_edit_get_amount(GNC_AMOUNT_EDIT(xferData->price_edit));
- if (gnc_numeric_zero_p(rate)) {
- string = g_strdup_printf("1 %s = x %s", from_mnemonic, to_mnemonic);
- gtk_label_set_text(GTK_LABEL(xferData->conv_forward), string);
- g_free(string);
+ rate = gnc_amount_edit_get_amount(GNC_AMOUNT_EDIT(xferData->price_edit));
+ if (gnc_numeric_zero_p(rate))
+ {
+ string = g_strdup_printf("1 %s = x %s", from_mnemonic, to_mnemonic);
+ gtk_label_set_text(GTK_LABEL(xferData->conv_forward), string);
+ g_free(string);
- string = g_strdup_printf("1 %s = x %s", to_mnemonic, from_mnemonic);
- gtk_label_set_text(GTK_LABEL(xferData->conv_reverse), string);
- g_free(string);
- } else {
- string = g_strdup_printf("1 %s = %f %s", from_mnemonic,
- gnc_numeric_to_double(rate), to_mnemonic);
- gtk_label_set_text(GTK_LABEL(xferData->conv_forward), string);
- g_free(string);
+ string = g_strdup_printf("1 %s = x %s", to_mnemonic, from_mnemonic);
+ gtk_label_set_text(GTK_LABEL(xferData->conv_reverse), string);
+ g_free(string);
+ }
+ else
+ {
+ string = g_strdup_printf("1 %s = %f %s", from_mnemonic,
+ gnc_numeric_to_double(rate), to_mnemonic);
+ gtk_label_set_text(GTK_LABEL(xferData->conv_forward), string);
+ g_free(string);
- rate = gnc_numeric_div(gnc_numeric_create (1, 1), rate,
- GNC_DENOM_AUTO, GNC_DENOM_REDUCE);
- string = g_strdup_printf("1 %s = %f %s", to_mnemonic,
- gnc_numeric_to_double(rate), from_mnemonic);
- gtk_label_set_text(GTK_LABEL(xferData->conv_reverse), string);
- g_free(string);
- }
+ rate = gnc_numeric_div(gnc_numeric_create (1, 1), rate,
+ GNC_DENOM_AUTO, GNC_DENOM_REDUCE);
+ string = g_strdup_printf("1 %s = %f %s", to_mnemonic,
+ gnc_numeric_to_double(rate), from_mnemonic);
+ gtk_label_set_text(GTK_LABEL(xferData->conv_reverse), string);
+ g_free(string);
+ }
}
static gboolean
gnc_xfer_amount_update_cb(GtkWidget *widget, GdkEventFocus *event,
- gpointer data)
+ gpointer data)
{
- XferDialog * xferData = data;
+ XferDialog * xferData = data;
- gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (xferData->amount_edit));
+ gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (xferData->amount_edit));
- gnc_xfer_update_to_amount (xferData);
+ gnc_xfer_update_to_amount (xferData);
- return FALSE;
+ return FALSE;
}
static void
gnc_xfer_update_to_amount (XferDialog *xferData)
{
- GNCAmountEdit *amount_edit, *price_edit, *to_amount_edit;
- gnc_numeric price, to_amount;
- Account *account;
- int scu = 0;
+ GNCAmountEdit *amount_edit, *price_edit, *to_amount_edit;
+ gnc_numeric price, to_amount;
+ Account *account;
+ int scu = 0;
- g_return_if_fail(xferData);
+ g_return_if_fail(xferData);
- /* Get the amount editing controls of the dialog. */
- amount_edit = GNC_AMOUNT_EDIT(xferData->amount_edit);
- price_edit = GNC_AMOUNT_EDIT(xferData->price_edit);
- to_amount_edit = GNC_AMOUNT_EDIT(xferData->to_amount_edit);
+ /* Get the amount editing controls of the dialog. */
+ amount_edit = GNC_AMOUNT_EDIT(xferData->amount_edit);
+ price_edit = GNC_AMOUNT_EDIT(xferData->price_edit);
+ to_amount_edit = GNC_AMOUNT_EDIT(xferData->to_amount_edit);
- /* Determine the SCU (smallest commodity unit) of the "to" amount. */
- account = gnc_transfer_dialog_get_selected_account(xferData, XFER_DIALOG_TO);
- if (account == NULL)
- account = gnc_transfer_dialog_get_selected_account(xferData,
- XFER_DIALOG_FROM);
- if (account != NULL)
- scu = xaccAccountGetCommoditySCU(account);
- else if (xferData->to_commodity != NULL)
- scu = gnc_commodity_get_fraction(xferData->to_commodity);
+ /* Determine the SCU (smallest commodity unit) of the "to" amount. */
+ account = gnc_transfer_dialog_get_selected_account(xferData, XFER_DIALOG_TO);
+ if (account == NULL)
+ account = gnc_transfer_dialog_get_selected_account(xferData,
+ XFER_DIALOG_FROM);
+ if (account != NULL)
+ scu = xaccAccountGetCommoditySCU(account);
+ else if (xferData->to_commodity != NULL)
+ scu = gnc_commodity_get_fraction(xferData->to_commodity);
- /* Determine the amount to transfer. */
- if (!gnc_amount_edit_evaluate(price_edit) ||
- gnc_numeric_zero_p(price = gnc_amount_edit_get_amount(price_edit)))
- to_amount = gnc_numeric_zero();
- else
- to_amount = gnc_numeric_mul(gnc_amount_edit_get_amount(amount_edit),
- price, scu, GNC_RND_ROUND);
+ /* Determine the amount to transfer. */
+ if (!gnc_amount_edit_evaluate(price_edit) ||
+ gnc_numeric_zero_p(price = gnc_amount_edit_get_amount(price_edit)))
+ to_amount = gnc_numeric_zero();
+ else
+ to_amount = gnc_numeric_mul(gnc_amount_edit_get_amount(amount_edit),
+ price, scu, GNC_RND_ROUND);
- /* Update the dialog. */
- gnc_amount_edit_set_amount(to_amount_edit, to_amount);
- if (gnc_numeric_zero_p(to_amount))
- gtk_entry_set_text(GTK_ENTRY(gnc_amount_edit_gtk_entry(to_amount_edit)),
- "");
+ /* Update the dialog. */
+ gnc_amount_edit_set_amount(to_amount_edit, to_amount);
+ if (gnc_numeric_zero_p(to_amount))
+ gtk_entry_set_text(GTK_ENTRY(gnc_amount_edit_gtk_entry(to_amount_edit)),
+ "");
- gnc_xfer_dialog_update_conv_info(xferData);
+ gnc_xfer_dialog_update_conv_info(xferData);
}
static gboolean
gnc_xfer_price_update_cb(GtkWidget *widget, GdkEventFocus *event,
- gpointer data)
+ gpointer data)
{
- XferDialog *xferData = data;
+ XferDialog *xferData = data;
- gnc_xfer_update_to_amount (xferData);
+ gnc_xfer_update_to_amount (xferData);
- return FALSE;
+ return FALSE;
}
static gboolean
gnc_xfer_date_changed_cb(GtkWidget *widget, gpointer data)
{
- XferDialog *xferData = data;
+ XferDialog *xferData = data;
- if (xferData)
- gnc_xfer_dialog_update_price (xferData);
+ if (xferData)
+ gnc_xfer_dialog_update_price (xferData);
- return FALSE;
+ return FALSE;
}
static gboolean
gnc_xfer_to_amount_update_cb(GtkWidget *widget, GdkEventFocus *event,
gpointer data)
{
- XferDialog *xferData = data;
- gnc_numeric price;
- Account *account;
+ XferDialog *xferData = data;
+ gnc_numeric price;
+ Account *account;
- account = gnc_transfer_dialog_get_selected_account (xferData, XFER_DIALOG_TO);
- if (account == NULL)
- account = gnc_transfer_dialog_get_selected_account (xferData, XFER_DIALOG_FROM);
+ account = gnc_transfer_dialog_get_selected_account (xferData, XFER_DIALOG_TO);
+ if (account == NULL)
+ account = gnc_transfer_dialog_get_selected_account (xferData, XFER_DIALOG_FROM);
- gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (xferData->to_amount_edit));
+ gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (xferData->to_amount_edit));
- price = gnc_xfer_dialog_compute_price(xferData);
- price = gnc_numeric_convert (price, PRECISION, GNC_RND_ROUND);
- gnc_amount_edit_set_amount(GNC_AMOUNT_EDIT(xferData->price_edit), price);
- gnc_xfer_dialog_update_conv_info(xferData);
+ price = gnc_xfer_dialog_compute_price(xferData);
+ price = gnc_numeric_convert (price, PRECISION, GNC_RND_ROUND);
+ gnc_amount_edit_set_amount(GNC_AMOUNT_EDIT(xferData->price_edit), price);
+ gnc_xfer_dialog_update_conv_info(xferData);
- return FALSE;
+ return FALSE;
}
@@ -951,7 +970,7 @@
void
gnc_xfer_dialog_select_from_account(XferDialog *xferData, Account *account)
{
- gnc_transfer_dialog_set_selected_account (xferData, account, XFER_DIALOG_FROM);
+ gnc_transfer_dialog_set_selected_account (xferData, account, XFER_DIALOG_FROM);
}
@@ -966,77 +985,78 @@
void
gnc_xfer_dialog_select_to_account(XferDialog *xferData, Account *account)
{
- gnc_transfer_dialog_set_selected_account (xferData, account, XFER_DIALOG_TO);
+ gnc_transfer_dialog_set_selected_account (xferData, account, XFER_DIALOG_TO);
}
void
gnc_xfer_dialog_select_from_currency(XferDialog *xferData, gnc_commodity *cur)
{
- if (!xferData) return;
- if (!cur) return;
+ if (!xferData) return;
+ if (!cur) return;
- gtk_label_set_text(GTK_LABEL(xferData->from_currency_label),
- gnc_commodity_get_printname(cur));
+ gtk_label_set_text(GTK_LABEL(xferData->from_currency_label),
+ gnc_commodity_get_printname(cur));
- gnc_amount_edit_set_print_info(GNC_AMOUNT_EDIT(xferData->amount_edit),
- gnc_commodity_print_info(cur, FALSE));
- gnc_amount_edit_set_fraction(GNC_AMOUNT_EDIT(xferData->amount_edit),
- gnc_commodity_get_fraction (cur));
+ gnc_amount_edit_set_print_info(GNC_AMOUNT_EDIT(xferData->amount_edit),
+ gnc_commodity_print_info(cur, FALSE));
+ gnc_amount_edit_set_fraction(GNC_AMOUNT_EDIT(xferData->amount_edit),
+ gnc_commodity_get_fraction (cur));
- xferData->from_commodity = cur;
- gnc_xfer_dialog_curr_acct_activate(xferData);
+ xferData->from_commodity = cur;
+ gnc_xfer_dialog_curr_acct_activate(xferData);
}
void
gnc_xfer_dialog_select_to_currency(XferDialog *xferData, gnc_commodity *cur)
{
- gtk_label_set_text(GTK_LABEL(xferData->to_currency_label),
- gnc_commodity_get_printname(cur));
+ gtk_label_set_text(GTK_LABEL(xferData->to_currency_label),
+ gnc_commodity_get_printname(cur));
- gnc_amount_edit_set_print_info(GNC_AMOUNT_EDIT(xferData->to_amount_edit),
- gnc_commodity_print_info(cur, FALSE));
- gnc_amount_edit_set_fraction(GNC_AMOUNT_EDIT(xferData->to_amount_edit),
- gnc_commodity_get_fraction(cur));
+ gnc_amount_edit_set_print_info(GNC_AMOUNT_EDIT(xferData->to_amount_edit),
+ gnc_commodity_print_info(cur, FALSE));
+ gnc_amount_edit_set_fraction(GNC_AMOUNT_EDIT(xferData->to_amount_edit),
+ gnc_commodity_get_fraction(cur));
- xferData->to_commodity = cur;
- gnc_xfer_dialog_curr_acct_activate(xferData);
+ xferData->to_commodity = cur;
+ gnc_xfer_dialog_curr_acct_activate(xferData);
}
static void
gnc_xfer_dialog_lock_account_tree(XferDialog *xferData,
XferDirection direction,
- gboolean hide)
+ gboolean hide)
{
- GtkTreeView *tree_view;
- GtkWidget *show_button;
- GtkWidget *scroll_win;
+ GtkTreeView *tree_view;
+ GtkWidget *show_button;
+ GtkWidget *scroll_win;
- if (xferData == NULL)
- return;
+ if (xferData == NULL)
+ return;
- switch (direction)
- {
+ switch (direction)
+ {
case XFER_DIALOG_FROM:
- tree_view = xferData->from_tree_view;
- scroll_win = xferData->from_window;
- show_button = xferData->from_show_button;
- break;
+ tree_view = xferData->from_tree_view;
+ scroll_win = xferData->from_window;
+ show_button = xferData->from_show_button;
+ break;
case XFER_DIALOG_TO:
- tree_view = xferData->to_tree_view;
- scroll_win = xferData->to_window;
- show_button = xferData->to_show_button;
- break;
+ tree_view = xferData->to_tree_view;
+ scroll_win = xferData->to_window;
+ show_button = xferData->to_show_button;
+ break;
default:
- return;
- }
+ return;
+ }
- gtk_widget_set_sensitive( GTK_WIDGET(tree_view), FALSE );
- gtk_widget_set_sensitive( GTK_WIDGET(show_button), FALSE );
+ gtk_widget_set_sensitive( GTK_WIDGET(tree_view), FALSE );
+ gtk_widget_set_sensitive( GTK_WIDGET(show_button), FALSE );
- if (hide) {
- gtk_widget_hide( scroll_win );
- gtk_widget_hide( GTK_WIDGET(show_button) );
- }
+ if (hide)
+ {
+ gtk_widget_hide( scroll_win );
+ gtk_widget_hide( GTK_WIDGET(show_button) );
+ }
}
@@ -1050,7 +1070,7 @@
void
gnc_xfer_dialog_lock_from_account_tree(XferDialog *xferData)
{
- gnc_xfer_dialog_lock_account_tree(xferData, XFER_DIALOG_FROM, FALSE);
+ gnc_xfer_dialog_lock_account_tree(xferData, XFER_DIALOG_FROM, FALSE);
}
@@ -1064,7 +1084,7 @@
void
gnc_xfer_dialog_lock_to_account_tree(XferDialog *xferData)
{
- gnc_xfer_dialog_lock_account_tree(xferData, XFER_DIALOG_TO, FALSE);
+ gnc_xfer_dialog_lock_account_tree(xferData, XFER_DIALOG_TO, FALSE);
}
@@ -1078,7 +1098,7 @@
void
gnc_xfer_dialog_hide_from_account_tree(XferDialog *xferData)
{
- gnc_xfer_dialog_lock_account_tree(xferData, XFER_DIALOG_FROM, TRUE);
+ gnc_xfer_dialog_lock_account_tree(xferData, XFER_DIALOG_FROM, TRUE);
}
@@ -1092,7 +1112,7 @@
void
gnc_xfer_dialog_hide_to_account_tree(XferDialog *xferData)
{
- gnc_xfer_dialog_lock_account_tree(xferData, XFER_DIALOG_TO, TRUE);
+ gnc_xfer_dialog_lock_account_tree(xferData, XFER_DIALOG_TO, TRUE);
}
@@ -1110,26 +1130,26 @@
gnc_xfer_dialog_is_exchange_dialog (XferDialog *xferData,
gnc_numeric *exch_rate)
{
- GNCAmountEdit *gae;
+ GNCAmountEdit *gae;
- g_return_if_fail(xferData);
- ENTER("xferData=%p, exch_rate=%p (%s)", xferData, exch_rate,
- exch_rate == NULL ? "NULL" : xaccPrintAmount(*exch_rate,
- gnc_default_print_info(FALSE)));
+ g_return_if_fail(xferData);
+ ENTER("xferData=%p, exch_rate=%p (%s)", xferData, exch_rate,
+ exch_rate == NULL ? "NULL" : xaccPrintAmount(*exch_rate,
+ gnc_default_print_info(FALSE)));
- gtk_widget_set_sensitive (xferData->amount_edit, FALSE);
- gtk_widget_set_sensitive (xferData->date_entry, FALSE);
- gtk_widget_set_sensitive (xferData->num_entry, FALSE);
- gtk_widget_set_sensitive (xferData->description_entry, FALSE);
- gtk_widget_set_sensitive (xferData->memo_entry, FALSE);
+ gtk_widget_set_sensitive (xferData->amount_edit, FALSE);
+ gtk_widget_set_sensitive (xferData->date_entry, FALSE);
+ gtk_widget_set_sensitive (xferData->num_entry, FALSE);
+ gtk_widget_set_sensitive (xferData->description_entry, FALSE);
+ gtk_widget_set_sensitive (xferData->memo_entry, FALSE);
- gae = GNC_AMOUNT_EDIT (xferData->price_edit);
- gtk_widget_grab_focus (gnc_amount_edit_gtk_entry (gae));
+ gae = GNC_AMOUNT_EDIT (xferData->price_edit);
+ gtk_widget_grab_focus (gnc_amount_edit_gtk_entry (gae));
- xferData->exch_rate = exch_rate;
+ xferData->exch_rate = exch_rate;
- LEAVE(" ");
+ LEAVE(" ");
}
/********************************************************************\
@@ -1143,18 +1163,18 @@
void
gnc_xfer_dialog_set_amount(XferDialog *xferData, gnc_numeric amount)
{
- Account * account;
+ Account * account;
- if (xferData == NULL)
- return;
+ if (xferData == NULL)
+ return;
- account = gnc_transfer_dialog_get_selected_account (xferData,
- XFER_DIALOG_FROM);
- if (account == NULL)
account = gnc_transfer_dialog_get_selected_account (xferData,
- XFER_DIALOG_TO);
+ XFER_DIALOG_FROM);
+ if (account == NULL)
+ account = gnc_transfer_dialog_get_selected_account (xferData,
+ XFER_DIALOG_TO);
- gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (xferData->amount_edit), amount);
+ gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (xferData->amount_edit), amount);
}
@@ -1169,11 +1189,11 @@
void
gnc_xfer_dialog_set_description(XferDialog *xferData, const char *description)
{
- if (xferData == NULL)
- return;
+ if (xferData == NULL)
+ return;
- gtk_entry_set_text(GTK_ENTRY(xferData->description_entry), description);
- gnc_quickfill_insert( xferData->qf, description, QUICKFILL_LIFO );
+ gtk_entry_set_text(GTK_ENTRY(xferData->description_entry), description);
+ gnc_quickfill_insert( xferData->qf, description, QUICKFILL_LIFO );
}
/********************************************************************\
@@ -1187,11 +1207,11 @@
void
gnc_xfer_dialog_set_memo(XferDialog *xferData, const char *memo)
{
- if (xferData == NULL)
- return;
+ if (xferData == NULL)
+ return;
- gtk_entry_set_text(GTK_ENTRY(xferData->memo_entry), memo);
- /* gnc_quickfill_insert( xferData->qf, memo, QUICKFILL_LIFO ); */
+ gtk_entry_set_text(GTK_ENTRY(xferData->memo_entry), memo);
+ /* gnc_quickfill_insert( xferData->qf, memo, QUICKFILL_LIFO ); */
}
/********************************************************************\
@@ -1205,11 +1225,11 @@
void
gnc_xfer_dialog_set_num(XferDialog *xferData, const char *num)
{
- if (xferData == NULL)
- return;
+ if (xferData == NULL)
+ return;
- gtk_entry_set_text(GTK_ENTRY(xferData->num_entry), num);
- /* gnc_quickfill_insert( xferData->qf, num, QUICKFILL_LIFO ); */
+ gtk_entry_set_text(GTK_ENTRY(xferData->num_entry), num);
+ /* gnc_quickfill_insert( xferData->qf, num, QUICKFILL_LIFO ); */
}
/********************************************************************\
@@ -1223,609 +1243,632 @@
void
gnc_xfer_dialog_set_date(XferDialog *xferData, time_t set_date)
{
- if (xferData == NULL)
- return;
+ if (xferData == NULL)
+ return;
- gnc_date_edit_set_time( GNC_DATE_EDIT(xferData->date_entry), set_date );
+ gnc_date_edit_set_time( GNC_DATE_EDIT(xferData->date_entry), set_date );
}
void
gnc_xfer_dialog_set_exchange_rate(XferDialog *xferData, gnc_numeric exchange_rate)
{
- if (xferData == NULL)
- return;
+ if (xferData == NULL)
+ return;
- if (gnc_numeric_zero_p (exchange_rate))
- return;
+ if (gnc_numeric_zero_p (exchange_rate))
+ return;
- gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (xferData->price_edit),
- exchange_rate);
+ gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (xferData->price_edit),
+ exchange_rate);
- gnc_xfer_update_to_amount (xferData);
+ gnc_xfer_update_to_amount (xferData);
}
void
gnc_xfer_dialog_response_cb (GtkDialog *dialog, gint response, gpointer data)
{
- XferDialog *xferData = data;
- Account *to_account;
- Account *from_account;
- gnc_commodity *from_commodity;
- gnc_commodity *to_commodity;
- gnc_numeric amount, to_amount;
- const char *string;
- Timespec ts;
+ XferDialog *xferData = data;
+ Account *to_account;
+ Account *from_account;
+ gnc_commodity *from_commodity;
+ gnc_commodity *to_commodity;
+ gnc_numeric amount, to_amount;
+ const char *string;
+ Timespec ts;
- gboolean curr_trans;
+ gboolean curr_trans;
- Transaction *trans;
- Split *from_split;
- Split *to_split;
+ Transaction *trans;
+ Split *from_split;
+ Split *to_split;
- ENTER(" ");
+ ENTER(" ");
- if (response == GTK_RESPONSE_APPLY)
- {
- LEAVE("fetching exchange rate");
- return;
- }
-
- if (response != GTK_RESPONSE_OK) {
- gnc_close_gui_component_by_data (DIALOG_TRANSFER_CM_CLASS, xferData);
- LEAVE("cancel, etc.");
- return;
- }
-
- from_account = gnc_transfer_dialog_get_selected_account (xferData, XFER_DIALOG_FROM);
- to_account = gnc_transfer_dialog_get_selected_account (xferData, XFER_DIALOG_TO);
-
- if (xferData->exch_rate == NULL)
- {
- if ((from_account == NULL) || (to_account == NULL))
+ if (response == GTK_RESPONSE_APPLY)
{
- const char *message = _("You must specify an account to transfer from, "
- "or to, or both, for this transaction. "
- "Otherwise, it will not be recorded.");
- gnc_error_dialog(xferData->dialog, "%s", message);
- LEAVE("bad account");
- return;
+ LEAVE("fetching exchange rate");
+ return;
}
- if (from_account == to_account)
+ if (response != GTK_RESPONSE_OK)
{
- const char *message = _("You can't transfer from and to the same "
- "account!");
- gnc_error_dialog(xferData->dialog, "%s", message);
- LEAVE("same account");
- return;
+ gnc_close_gui_component_by_data (DIALOG_TRANSFER_CM_CLASS, xferData);
+ LEAVE("cancel, etc.");
+ return;
}
- if (xaccAccountGetPlaceholder(from_account) ||
- xaccAccountGetPlaceholder(to_account))
+ from_account = gnc_transfer_dialog_get_selected_account (xferData, XFER_DIALOG_FROM);
+ to_account = gnc_transfer_dialog_get_selected_account (xferData, XFER_DIALOG_TO);
+
+ if (xferData->exch_rate == NULL)
{
- const char *placeholder_format =
- _("The account %s does not allow transactions.");
- char *name;
+ if ((from_account == NULL) || (to_account == NULL))
+ {
+ const char *message = _("You must specify an account to transfer from, "
+ "or to, or both, for this transaction. "
+ "Otherwise, it will not be recorded.");
+ gnc_error_dialog(xferData->dialog, "%s", message);
+ LEAVE("bad account");
+ return;
+ }
- if (xaccAccountGetPlaceholder(from_account))
- name = gnc_account_get_full_name(from_account);
- else
- name = gnc_account_get_full_name(to_account);
- gnc_error_dialog(xferData->dialog, placeholder_format, name);
- g_free(name);
- LEAVE("placeholder");
- return;
+ if (from_account == to_account)
+ {
+ const char *message = _("You can't transfer from and to the same "
+ "account!");
+ gnc_error_dialog(xferData->dialog, "%s", message);
+ LEAVE("same account");
+ return;
+ }
+
+ if (xaccAccountGetPlaceholder(from_account) ||
+ xaccAccountGetPlaceholder(to_account))
+ {
+ const char *placeholder_format =
+ _("The account %s does not allow transactions.");
+ char *name;
+
+ if (xaccAccountGetPlaceholder(from_account))
+ name = gnc_account_get_full_name(from_account);
+ else
+ name = gnc_account_get_full_name(to_account);
+ gnc_error_dialog(xferData->dialog, placeholder_format, name);
+ g_free(name);
+ LEAVE("placeholder");
+ return;
+ }
+
+ if (!gnc_commodity_is_iso (xferData->from_commodity))
+ {
+ const char *message = _("You can't transfer from a non-currency account. "
+ "Try reversing the \"from\" and \"to\" accounts "
+ "and making the \"amount\" negative.");
+ gnc_error_dialog(xferData->dialog, "%s", message);
+ LEAVE("non-currency");
+ return;
+ }
}
- if (!gnc_commodity_is_iso (xferData->from_commodity))
+ if (!gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (xferData->amount_edit)))
{
- const char *message = _("You can't transfer from a non-currency account. "
- "Try reversing the \"from\" and \"to\" accounts "
- "and making the \"amount\" negative.");
- gnc_error_dialog(xferData->dialog, "%s", message);
- LEAVE("non-currency");
- return;
+ gnc_parse_error_dialog (xferData, _("You must enter a valid amount."));
+ LEAVE("no account");
+ return;
}
- }
- if (!gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (xferData->amount_edit)))
- {
- gnc_parse_error_dialog (xferData, _("You must enter a valid amount."));
- LEAVE("no account");
- return;
- }
+ from_commodity = xferData->from_commodity;
+ to_commodity = xferData->to_commodity;
- from_commodity = xferData->from_commodity;
- to_commodity = xferData->to_commodity;
+ curr_trans = !gnc_commodity_equiv(from_commodity, to_commodity);
- curr_trans = !gnc_commodity_equiv(from_commodity, to_commodity);
+ amount = gnc_amount_edit_get_amount(GNC_AMOUNT_EDIT(xferData->amount_edit));
- amount = gnc_amount_edit_get_amount(GNC_AMOUNT_EDIT(xferData->amount_edit));
-
- if (gnc_numeric_zero_p (amount))
- {
- const char *message = _("You must enter an amount to transfer.");
- gnc_error_dialog(xferData->dialog, "%s", message);
- LEAVE("invalid from amount");
- return;
- }
-
- ts = gnc_date_edit_get_date_ts(GNC_DATE_EDIT(xferData->date_entry));
-
- if (curr_trans)
- {
- if (!gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (xferData->price_edit)))
+ if (gnc_numeric_zero_p (amount))
{
- if (gtk_toggle_button_get_active
- (GTK_TOGGLE_BUTTON(xferData->price_radio)))
- {
- gnc_parse_error_dialog (xferData, _("You must enter a valid price."));
- LEAVE("invalid price");
- return;
- }
+ const char *message = _("You must enter an amount to transfer.");
+ gnc_error_dialog(xferData->dialog, "%s", message);
+ LEAVE("invalid from amount");
+ return;
}
- if (!gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (xferData->to_amount_edit)))
+ ts = gnc_date_edit_get_date_ts(GNC_DATE_EDIT(xferData->date_entry));
+
+ if (curr_trans)
{
- if (gtk_toggle_button_get_active
- (GTK_TOGGLE_BUTTON(xferData->amount_radio)))
- {
- gnc_parse_error_dialog (xferData,
- _("You must enter a valid `to' amount."));
- LEAVE("invalid to amount");
- return;
- }
- }
+ if (!gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (xferData->price_edit)))
+ {
+ if (gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON(xferData->price_radio)))
+ {
+ gnc_parse_error_dialog (xferData, _("You must enter a valid price."));
+ LEAVE("invalid price");
+ return;
+ }
+ }
- to_amount = gnc_amount_edit_get_amount
- (GNC_AMOUNT_EDIT(xferData->to_amount_edit));
- }
- else
- to_amount = amount;
+ if (!gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (xferData->to_amount_edit)))
+ {
+ if (gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON(xferData->amount_radio)))
+ {
+ gnc_parse_error_dialog (xferData,
+ _("You must enter a valid `to' amount."));
+ LEAVE("invalid to amount");
+ return;
+ }
+ }
- gnc_suspend_gui_refresh ();
+ to_amount = gnc_amount_edit_get_amount
+ (GNC_AMOUNT_EDIT(xferData->to_amount_edit));
+ }
+ else
+ to_amount = amount;
- if (xferData->exch_rate)
- {
- gnc_numeric price;
+ gnc_suspend_gui_refresh ();
- /* If we've got the price-button set, then make sure we update the
- * to-amount before we use it.
- */
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(xferData->price_radio)))
- gnc_xfer_update_to_amount(xferData);
+ if (xferData->exch_rate)
+ {
+ gnc_numeric price;
- price = gnc_xfer_dialog_compute_price(xferData);
- *(xferData->exch_rate) = gnc_numeric_abs(price);
- }
- else
- {
- /* Create the transaction */
- trans = xaccMallocTransaction(xferData->book);
+ /* If we've got the price-button set, then make sure we update the
+ * to-amount before we use it.
+ */
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(xferData->price_radio)))
+ gnc_xfer_update_to_amount(xferData);
- xaccTransBeginEdit(trans);
+ price = gnc_xfer_dialog_compute_price(xferData);
+ *(xferData->exch_rate) = gnc_numeric_abs(price);
+ }
+ else
+ {
+ /* Create the transaction */
+ trans = xaccMallocTransaction(xferData->book);
- xaccTransSetCurrency(trans, from_commodity);
- xaccTransSetDatePostedTS(trans, &ts);
+ xaccTransBeginEdit(trans);
- string = gtk_entry_get_text(GTK_ENTRY(xferData->num_entry));
- xaccTransSetNum(trans, string);
+ xaccTransSetCurrency(trans, from_commodity);
+ xaccTransSetDatePostedTS(trans, &ts);
- string = gtk_entry_get_text(GTK_ENTRY(xferData->description_entry));
- xaccTransSetDescription(trans, string);
+ string = gtk_entry_get_text(GTK_ENTRY(xferData->num_entry));
+ xaccTransSetNum(trans, string);
- /* create from split */
- from_split = xaccMallocSplit(xferData->book);
- xaccTransAppendSplit(trans, from_split);
+ string = gtk_entry_get_text(GTK_ENTRY(xferData->description_entry));
+ xaccTransSetDescription(trans, string);
- /* create to split */
- to_split = xaccMallocSplit(xferData->book);
- xaccTransAppendSplit(trans, to_split);
+ /* create from split */
+ from_split = xaccMallocSplit(xferData->book);
+ xaccTransAppendSplit(trans, from_split);
- xaccAccountBeginEdit(from_account);
- xaccAccountInsertSplit(from_account, from_split);
+ /* create to split */
+ to_split = xaccMallocSplit(xferData->book);
+ xaccTransAppendSplit(trans, to_split);
- xaccAccountBeginEdit(to_account);
- xaccAccountInsertSplit(to_account, to_split);
+ xaccAccountBeginEdit(from_account);
+ xaccAccountInsertSplit(from_account, from_split);
- xaccSplitSetBaseValue(from_split, gnc_numeric_neg (amount), from_commodity);
- xaccSplitSetBaseValue(to_split, amount, from_commodity);
- xaccSplitSetBaseValue(to_split, to_amount, to_commodity);
+ xaccAccountBeginEdit(to_account);
+ xaccAccountInsertSplit(to_account, to_split);
- /* Set the memo fields */
- string = gtk_entry_get_text(GTK_ENTRY(xferData->memo_entry));
- xaccSplitSetMemo(from_split, string);
- xaccSplitSetMemo(to_split, string);
+ xaccSplitSetBaseValue(from_split, gnc_numeric_neg (amount), from_commodity);
+ xaccSplitSetBaseValue(to_split, amount, from_commodity);
+ xaccSplitSetBaseValue(to_split, to_amount, to_commodity);
- /* finish transaction */
- xaccTransCommitEdit(trans);
- xaccAccountCommitEdit(from_account);
- xaccAccountCommitEdit(to_account);
+ /* Set the memo fields */
+ string = gtk_entry_get_text(GTK_ENTRY(xferData->memo_entry));
+ xaccSplitSetMemo(from_split, string);
+ xaccSplitSetMemo(to_split, string);
- /* If there is a registered callback handler that should be
- notified of the newly created Transaction, call it now. */
- if (xferData->transaction_cb)
- xferData->transaction_cb(trans, xferData->transaction_user_data);
- }
+ /* finish transaction */
+ xaccTransCommitEdit(trans);
+ xaccAccountCommitEdit(from_account);
+ xaccAccountCommitEdit(to_account);
- /* try to save this to the pricedb */
- if (xferData->pricedb) {
- gnc_commodity *from = xferData->from_commodity;
- gnc_commodity *to = xferData->to_commodity;
+ /* If there is a registered callback handler that should be
+ notified of the newly created Transaction, call it now. */
+ if (xferData->transaction_cb)
+ xferData->transaction_cb(trans, xferData->transaction_user_data);
+ }
- /* only continue if the currencies are DIFFERENT and are
- * not both euroland currencies
- */
- if (!gnc_commodity_equal (from, to) &&
- !(gnc_is_euro_currency (from) && gnc_is_euro_currency (to)))
+ /* try to save this to the pricedb */
+ if (xferData->pricedb)
{
- GNCPrice *price;
- GList *prices;
+ gnc_commodity *from = xferData->from_commodity;
+ gnc_commodity *to = xferData->to_commodity;
- /* First see if an entry exists at time ts */
- prices = gnc_pricedb_lookup_at_time (xferData->pricedb, from, to, ts);
- if (prices) {
- PINFO("Found price for %s in %s", gnc_commodity_get_mnemonic(from),
- gnc_commodity_get_mnemonic(to));
- } else {
- prices = gnc_pricedb_lookup_at_time (xferData->pricedb, to, from, ts);
- if (prices) {
- PINFO("Found reverse price for %s in %s", gnc_commodity_get_mnemonic(to),
- gnc_commodity_get_mnemonic(from));
- }
- }
+ /* only continue if the currencies are DIFFERENT and are
+ * not both euroland currencies
+ */
+ if (!gnc_commodity_equal (from, to) &&
+ !(gnc_is_euro_currency (from) && gnc_is_euro_currency (to)))
+ {
+ GNCPrice *price;
+ GList *prices;
- /* If so, do nothing (well, destroy the list). if not, create one. */
- if (prices) {
- gnc_price_list_destroy (prices);
- } else {
- gnc_commodity *tmp;
- gnc_numeric value;
+ /* First see if an entry exists at time ts */
+ prices = gnc_pricedb_lookup_at_time (xferData->pricedb, from, to, ts);
+ if (prices)
+ {
+ PINFO("Found price for %s in %s", gnc_commodity_get_mnemonic(from),
+ gnc_commodity_get_mnemonic(to));
+ }
+ else
+ {
+ prices = gnc_pricedb_lookup_at_time (xferData->pricedb, to, from, ts);
+ if (prices)
+ {
+ PINFO("Found reverse price for %s in %s", gnc_commodity_get_mnemonic(to),
+ gnc_commodity_get_mnemonic(from));
+ }
+ }
- /* compute the price -- maybe we need to swap? */
- value = gnc_xfer_dialog_compute_price(xferData);
- value = gnc_numeric_abs (value);
+ /* If so, do nothing (well, destroy the list). if not, create one. */
+ if (prices)
+ {
+ gnc_price_list_destroy (prices);
+ }
+ else
+ {
+ gnc_commodity *tmp;
+ gnc_numeric value;
- /* Try to be consistent about how quotes are installed. */
- if (from == gnc_default_currency()) {
- tmp = from; from = to; to = tmp;
- value = gnc_numeric_div (gnc_numeric_create(1,1), value,
- GNC_DENOM_AUTO, GNC_DENOM_REDUCE);
- } else if ((to != gnc_default_currency()) &&
- (strcmp (gnc_commodity_get_mnemonic(from),
- gnc_commodity_get_mnemonic(to)) < 0)) {
- tmp = from; from = to; to = tmp;
- value = gnc_numeric_div (gnc_numeric_create(1,1), value,
- GNC_DENOM_AUTO, GNC_DENOM_REDUCE);
- }
+ /* compute the price -- maybe we need to swap? */
+ value = gnc_xfer_dialog_compute_price(xferData);
+ value = gnc_numeric_abs (value);
- price = gnc_price_create (xferData->book);
- gnc_price_begin_edit (price);
- gnc_price_set_commodity (price, from);
- gnc_price_set_currency (price, to);
- gnc_price_set_time (price, ts);
- gnc_price_set_source (price, "user:xfer-dialog");
- gnc_price_set_value (price, value);
- gnc_pricedb_add_price (xferData->pricedb, price);
- gnc_price_commit_edit (price);
- gnc_price_unref (price);
- PINFO("Created price: 1 %s = %f %s", gnc_commodity_get_mnemonic(from),
- gnc_numeric_to_double(value), gnc_commodity_get_mnemonic(to));
- }
+ /* Try to be consistent about how quotes are installed. */
+ if (from == gnc_default_currency())
+ {
+ tmp = from;
+ from = to;
+ to = tmp;
+ value = gnc_numeric_div (gnc_numeric_create(1, 1), value,
+ GNC_DENOM_AUTO, GNC_DENOM_REDUCE);
+ }
+ else if ((to != gnc_default_currency()) &&
+ (strcmp (gnc_commodity_get_mnemonic(from),
+ gnc_commodity_get_mnemonic(to)) < 0))
+ {
+ tmp = from;
+ from = to;
+ to = tmp;
+ value = gnc_numeric_div (gnc_numeric_create(1, 1), value,
+ GNC_DENOM_AUTO, GNC_DENOM_REDUCE);
+ }
+
+ price = gnc_price_create (xferData->book);
+ gnc_price_begin_edit (price);
+ gnc_price_set_commodity (price, from);
+ gnc_price_set_currency (price, to);
+ gnc_price_set_time (price, ts);
+ gnc_price_set_source (price, "user:xfer-dialog");
+ gnc_price_set_value (price, value);
+ gnc_pricedb_add_price (xferData->pricedb, price);
+ gnc_price_commit_edit (price);
+ gnc_price_unref (price);
+ PINFO("Created price: 1 %s = %f %s", gnc_commodity_get_mnemonic(from),
+ gnc_numeric_to_double(value), gnc_commodity_get_mnemonic(to));
+ }
+ }
}
- }
- /* Refresh everything */
- gnc_resume_gui_refresh ();
+ /* Refresh everything */
+ gnc_resume_gui_refresh ();
- DEBUG("close component");
- gnc_close_gui_component_by_data (DIALOG_TRANSFER_CM_CLASS, xferData);
- LEAVE("ok");
+ DEBUG("close component");
+ gnc_close_gui_component_by_data (DIALOG_TRANSFER_CM_CLASS, xferData);
+ LEAVE("ok");
}
void
gnc_xfer_dialog_close_cb(GtkDialog *dialog, gpointer data)
{
- XferDialog * xferData = data;
- GtkWidget *entry;
+ XferDialog * xferData = data;
+ GtkWidget *entry;
- /* Notify transaction callback to unregister here */
- if (xferData->transaction_cb)
- xferData->transaction_cb(NULL, xferData->transaction_user_data);
+ /* Notify transaction callback to unregister here */
+ if (xferData->transaction_cb)
+ xferData->transaction_cb(NULL, xferData->transaction_user_data);
- entry = gnc_amount_edit_gtk_entry(GNC_AMOUNT_EDIT(xferData->amount_edit));
- g_signal_handlers_disconnect_matched (G_OBJECT (entry), G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, xferData);
+ entry = gnc_amount_edit_gtk_entry(GNC_AMOUNT_EDIT(xferData->amount_edit));
+ g_signal_handlers_disconnect_matched (G_OBJECT (entry), G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, xferData);
- entry = gnc_amount_edit_gtk_entry(GNC_AMOUNT_EDIT(xferData->price_edit));
- g_signal_handlers_disconnect_matched (G_OBJECT (entry), G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, xferData);
+ entry = gnc_amount_edit_gtk_entry(GNC_AMOUNT_EDIT(xferData->price_edit));
+ g_signal_handlers_disconnect_matched (G_OBJECT (entry), G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, xferData);
- entry = gnc_amount_edit_gtk_entry(GNC_AMOUNT_EDIT(xferData->to_amount_edit));
- g_signal_handlers_disconnect_matched (G_OBJECT (entry), G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, xferData);
+ entry = gnc_amount_edit_gtk_entry(GNC_AMOUNT_EDIT(xferData->to_amount_edit));
+ g_signal_handlers_disconnect_matched (G_OBJECT (entry), G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, xferData);
- entry = xferData->description_entry;
- g_signal_handlers_disconnect_matched (G_OBJECT (entry), G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, xferData);
+ entry = xferData->description_entry;
+ g_signal_handlers_disconnect_matched (G_OBJECT (entry), G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, xferData);
- g_object_unref (xferData->tips);
+ g_object_unref (xferData->tips);
- DEBUG("unregister component");
- gnc_unregister_gui_component_by_data (DIALOG_TRANSFER_CM_CLASS, xferData);
+ DEBUG("unregister component");
+ gnc_unregister_gui_component_by_data (DIALOG_TRANSFER_CM_CLASS, xferData);
- gnc_quickfill_destroy (xferData->qf);
- xferData->qf = NULL;
+ gnc_quickfill_destroy (xferData->qf);
+ xferData->qf = NULL;
- if (xferData->desc_selection_source_id)
- g_source_remove (xferData->desc_selection_source_id);
+ if (xferData->desc_selection_source_id)
+ g_source_remove (xferData->desc_selection_source_id);
- g_free(xferData);
+ g_free(xferData);
- DEBUG("xfer dialog destroyed");
+ DEBUG("xfer dialog destroyed");
}
static void
gnc_xfer_dialog_fetch (GtkButton *button, XferDialog *xferData)
{
- gnc_numeric rate;
- GNCPrice *prc;
- gnc_commodity *from = xferData->from_commodity;
- gnc_commodity *to = xferData->to_commodity;
- SCM quotes_func;
- SCM book_scm;
- SCM scm_window;
+ gnc_numeric rate;
+ GNCPrice *prc;
+ gnc_commodity *from = xferData->from_commodity;
+ gnc_commodity *to = xferData->to_commodity;
+ SCM quotes_func;
+ SCM book_scm;
+ SCM scm_window;
- g_return_if_fail (xferData);
+ g_return_if_fail (xferData);
- ENTER(" ");
+ ENTER(" ");
- quotes_func = scm_c_eval_string ("gnc:book-add-quotes");
+ quotes_func = scm_c_eval_string ("gnc:book-add-quotes");
- if (!scm_is_procedure (quotes_func)) {
- LEAVE("quote retrieval failed");
- return;
- }
+ if (!scm_is_procedure (quotes_func))
+ {
+ LEAVE("quote retrieval failed");
+ return;
+ }
- book_scm = gnc_book_to_scm (xferData->book);
- if (scm_is_true (scm_not (book_scm))) {
- LEAVE("no book");
- return;
- }
+ book_scm = gnc_book_to_scm (xferData->book);
+ if (scm_is_true (scm_not (book_scm)))
+ {
+ LEAVE("no book");
+ return;
+ }
- scm_window = SWIG_NewPointerObj(xferData->dialog,
- SWIG_TypeQuery("_p_GtkWidget"), 0);
+ scm_window = SWIG_NewPointerObj(xferData->dialog,
+ SWIG_TypeQuery("_p_GtkWidget"), 0);
- if (scm_is_true (scm_not (book_scm))) {
- LEAVE("no scm window");
- return;
- }
+ if (scm_is_true (scm_not (book_scm)))
+ {
+ LEAVE("no scm window");
+ return;
+ }
- gnc_set_busy_cursor (NULL, TRUE);
- scm_call_2 (quotes_func, scm_window, book_scm);
- gnc_unset_busy_cursor (NULL);
+ gnc_set_busy_cursor (NULL, TRUE);
+ scm_call_2 (quotes_func, scm_window, book_scm);
+ gnc_unset_busy_cursor (NULL);
- /*the results should be in the price db now */
+ /*the results should be in the price db now */
- prc = gnc_pricedb_lookup_latest(xferData->pricedb, from, to);
- rate = gnc_price_get_value (prc);
- gnc_amount_edit_set_amount(GNC_AMOUNT_EDIT(xferData->price_edit), rate);
+ prc = gnc_pricedb_lookup_latest(xferData->pricedb, from, to);
+ rate = gnc_price_get_value (prc);
+ gnc_amount_edit_set_amount(GNC_AMOUNT_EDIT(xferData->price_edit), rate);
- LEAVE("quote retrieved");
+ LEAVE("quote retrieved");
}
static void
gnc_xfer_dialog_create(GtkWidget *parent, XferDialog *xferData)
{
- GtkWidget *dialog;
- GladeXML *xml;
- gboolean use_accounting_labels;
+ GtkWidget *dialog;
+ GladeXML *xml;
+ gboolean use_accounting_labels;
- use_accounting_labels = gnc_gconf_get_bool(GCONF_GENERAL,
- KEY_ACCOUNTING_LABELS, NULL);
+ use_accounting_labels = gnc_gconf_get_bool(GCONF_GENERAL,
+ KEY_ACCOUNTING_LABELS, NULL);
- ENTER(" ");
- xml = gnc_glade_xml_new ("transfer.glade", "Transfer Dialog");
+ ENTER(" ");
+ xml = gnc_glade_xml_new ("transfer.glade", "Transfer Dialog");
- dialog = glade_xml_get_widget (xml, "Transfer Dialog");
- xferData->dialog = dialog;
- g_object_set_data_full (G_OBJECT (dialog), "xml", xml, g_object_unref);
+ dialog = glade_xml_get_widget (xml, "Transfer Dialog");
+ xferData->dialog = dialog;
+ g_object_set_data_full (G_OBJECT (dialog), "xml", xml, g_object_unref);
- /* parent */
- if (parent != NULL)
- gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
+ /* parent */
+ if (parent != NULL)
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
- glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func, xferData);
+ glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func, xferData);
- xferData->tips = gtk_tooltips_new();
+ xferData->tips = gtk_tooltips_new();
- g_object_ref_sink(xferData->tips);
+ g_object_ref_sink(xferData->tips);
- /* default to quickfilling off of the "From" account. */
- xferData->quickfill = XFER_DIALOG_FROM;
+ /* default to quickfilling off of the "From" account. */
+ xferData->quickfill = XFER_DIALOG_FROM;
- xferData->transferinfo_label = glade_xml_get_widget (xml, "transferinfo-label");
+ xferData->transferinfo_label = glade_xml_get_widget (xml, "transferinfo-label");
- xferData->fetch_button = glade_xml_get_widget (xml, "fetch");
- glade_xml_signal_connect_data (xml, "gnc_xfer_dialog_fetch",
- G_CALLBACK (gnc_xfer_dialog_fetch), xferData);
+ xferData->fetch_button = glade_xml_get_widget (xml, "fetch");
+ glade_xml_signal_connect_data (xml, "gnc_xfer_dialog_fetch",
+ G_CALLBACK (gnc_xfer_dialog_fetch), xferData);
- /* amount & date widgets */
- {
- GtkWidget *amount;
- GtkWidget *entry;
- GtkWidget *date;
- GtkWidget *hbox;
+ /* amount & date widgets */
+ {
+ GtkWidget *amount;
+ GtkWidget *entry;
+ GtkWidget *date;
+ GtkWidget *hbox;
- amount = gnc_amount_edit_new();
- hbox = glade_xml_get_widget (xml, "amount_hbox");
- gtk_box_pack_end(GTK_BOX(hbox), amount, TRUE, TRUE, 0);
- gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (amount), TRUE);
- xferData->amount_edit = amount;
+ amount = gnc_amount_edit_new();
+ hbox = glade_xml_get_widget (xml, "amount_hbox");
+ gtk_box_pack_end(GTK_BOX(hbox), amount, TRUE, TRUE, 0);
+ gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (amount), TRUE);
+ xferData->amount_edit = amount;
- entry = gnc_amount_edit_gtk_entry (GNC_AMOUNT_EDIT (amount));
- gtk_entry_set_activates_default (GTK_ENTRY(entry), TRUE);
- g_signal_connect (G_OBJECT (entry), "focus-out-event",
- G_CALLBACK (gnc_xfer_amount_update_cb), xferData);
+ entry = gnc_amount_edit_gtk_entry (GNC_AMOUNT_EDIT (amount));
+ gtk_entry_set_activates_default (GTK_ENTRY(entry), TRUE);
+ g_signal_connect (G_OBJECT (entry), "focus-out-event",
+ G_CALLBACK (gnc_xfer_amount_update_cb), xferData);
- date = gnc_date_edit_new(time (NULL), FALSE, FALSE);
- gnc_date_activates_default (GNC_DATE_EDIT(date), TRUE);
- hbox = glade_xml_get_widget (xml, "date_hbox");
+ date = gnc_date_edit_new(time (NULL), FALSE, FALSE);
+ gnc_date_activates_default (GNC_DATE_EDIT(date), TRUE);
+ hbox = glade_xml_get_widget (xml, "date_hbox");
- gtk_box_pack_end(GTK_BOX(hbox), date, TRUE, TRUE, 0);
- xferData->date_entry = date;
- g_signal_connect (G_OBJECT (date), "date_changed",
- G_CALLBACK (gnc_xfer_date_changed_cb), xferData);
- }
+ gtk_box_pack_end(GTK_BOX(hbox), date, TRUE, TRUE, 0);
+ xferData->date_entry = date;
+ g_signal_connect (G_OBJECT (date), "date_changed",
+ G_CALLBACK (gnc_xfer_date_changed_cb), xferData);
+ }
- {
- GtkWidget *entry;
+ {
+ GtkWidget *entry;
- entry = glade_xml_get_widget (xml, "num_entry");
- xferData->num_entry = entry;
+ entry = glade_xml_get_widget (xml, "num_entry");
+ xferData->num_entry = entry;
- entry = glade_xml_get_widget (xml, "description_entry");
- xferData->description_entry = entry;
+ entry = glade_xml_get_widget (xml, "description_entry");
+ xferData->description_entry = entry;
- /* Get signals from the Description for quickfill. */
- g_signal_connect (G_OBJECT (entry), "insert_text",
- G_CALLBACK (gnc_xfer_description_insert_cb), xferData);
- g_signal_connect (G_OBJECT (entry), "key_press_event",
- G_CALLBACK (gnc_xfer_description_key_press_cb), xferData);
+ /* Get signals from the Description for quickfill. */
+ g_signal_connect (G_OBJECT (entry), "insert_text",
+ G_CALLBACK (gnc_xfer_description_insert_cb), xferData);
+ g_signal_connect (G_OBJECT (entry), "key_press_event",
+ G_CALLBACK (gnc_xfer_description_key_press_cb), xferData);
- entry = glade_xml_get_widget (xml, "memo_entry");
- xferData->memo_entry = entry;
- }
+ entry = glade_xml_get_widget (xml, "memo_entry");
+ xferData->memo_entry = entry;
+ }
- /* from and to */
- {
- GtkWidget *label;
- gchar *text;
+ /* from and to */
+ {
+ GtkWidget *label;
+ gchar *text;
- gnc_xfer_dialog_fill_tree_view (xferData, XFER_DIALOG_TO);
- gnc_xfer_dialog_fill_tree_view (xferData, XFER_DIALOG_FROM);
+ gnc_xfer_dialog_fill_tree_view (xferData, XFER_DIALOG_TO);
+ gnc_xfer_dialog_fill_tree_view (xferData, XFER_DIALOG_FROM);
- /* Reverse from and to account trees when in "accountant" mode,
- see comment in function gnc_xfer_dialog_fill_tree_table */
- if(use_accounting_labels) {
- label = glade_xml_get_widget (xml, "right_trans_label");
- xferData->from_transfer_label = label;
+ /* Reverse from and to account trees when in "accountant" mode,
+ see comment in function gnc_xfer_dialog_fill_tree_table */
+ if (use_accounting_labels)
+ {
+ label = glade_xml_get_widget (xml, "right_trans_label");
+ xferData->from_transfer_label = label;
- label = glade_xml_get_widget (xml, "left_trans_label");
- xferData->to_transfer_label = label;
+ label = glade_xml_get_widget (xml, "left_trans_label");
+ xferData->to_transfer_label = label;
- text = g_strconcat ("<b>", _("Credit Account"), "</b>", NULL);
- gtk_label_set_markup (GTK_LABEL (xferData->from_transfer_label), text);
- g_free (text);
+ text = g_strconcat ("<b>", _("Credit Account"), "</b>", NULL);
+ gtk_label_set_markup (GTK_LABEL (xferData->from_transfer_label), text);
+ g_free (text);
- text = g_strconcat ("<b>", _("Debit Account"), "</b>", NULL);
- gtk_label_set_markup (GTK_LABEL (xferData->to_transfer_label), text);
- g_free (text);
+ text = g_strconcat ("<b>", _("Debit Account"), "</b>", NULL);
+ gtk_label_set_markup (GTK_LABEL (xferData->to_transfer_label), text);
+ g_free (text);
- label = glade_xml_get_widget (xml, "right_currency_label");
- xferData->from_currency_label = label;
+ label = glade_xml_get_widget (xml, "right_currency_label");
+ xferData->from_currency_label = label;
- label = glade_xml_get_widget (xml, "left_currency_label");
- xferData->to_currency_label = label;
- }
- else {
- label = glade_xml_get_widget (xml, "left_trans_label");
- xferData->from_transfer_label = label;
+ label = glade_xml_get_widget (xml, "left_currency_label");
+ xferData->to_currency_label = label;
+ }
+ else
+ {
+ label = glade_xml_get_widget (xml, "left_trans_label");
+ xferData->from_transfer_label = label;
- label = glade_xml_get_widget (xml, "right_trans_label");
- xferData->to_transfer_label = label;
+ label = glade_xml_get_widget (xml, "right_trans_label");
+ xferData->to_transfer_label = label;
- text = g_strconcat ("<b>", _("Transfer From"), "</b>", NULL);
- gtk_label_set_markup (GTK_LABEL (xferData->from_transfer_label), text);
- g_free (text);
+ text = g_strconcat ("<b>", _("Transfer From"), "</b>", NULL);
+ gtk_label_set_markup (GTK_LABEL (xferData->from_transfer_label), text);
+ g_free (text);
- text = g_strconcat ("<b>", _("Transfer To"), "</b>", NULL);
- gtk_label_set_markup (GTK_LABEL (xferData->to_transfer_label), text);
+ text = g_strconcat ("<b>", _("Transfer To"), "</b>", NULL);
+ gtk_label_set_markup (GTK_LABEL (xferData->to_transfer_label), text);
- label = glade_xml_get_widget (xml, "left_currency_label");
- xferData->from_currency_label = label;
+ label = glade_xml_get_widget (xml, "left_currency_label");
+ xferData->from_currency_label = label;
- label = glade_xml_get_widget (xml, "right_currency_label");
- xferData->to_currency_label = label;
- }
+ label = glade_xml_get_widget (xml, "right_currency_label");
+ xferData->to_currency_label = label;
+ }
- label = glade_xml_get_widget (xml, "conv_forward");
- xferData->conv_forward = label;
+ label = glade_xml_get_widget (xml, "conv_forward");
+ xferData->conv_forward = label;
- label = glade_xml_get_widget (xml, "conv_reverse");
- xferData->conv_reverse = label;
- }
+ label = glade_xml_get_widget (xml, "conv_reverse");
+ xferData->conv_reverse = label;
+ }
- /* optional intermediate currency account */
- {
- GtkWidget *table;
- GtkWidget *entry;
- GtkWidget *edit;
- GtkWidget *hbox;
- GtkWidget *button;
+ /* optional intermediate currency account */
+ {
+ GtkWidget *table;
+ GtkWidget *entry;
+ GtkWidget *edit;
+ GtkWidget *hbox;
+ GtkWidget *button;
- table = glade_xml_get_widget (xml, "curr_transfer_table");
- xferData->curr_xfer_table = table;
+ table = glade_xml_get_widget (xml, "curr_transfer_table");
+ xferData->curr_xfer_table = table;
- edit = gnc_amount_edit_new();
- gnc_amount_edit_set_print_info(GNC_AMOUNT_EDIT(edit),
- gnc_default_print_info (FALSE));
- hbox = glade_xml_get_widget (xml, "price_hbox");
- gtk_box_pack_start(GTK_BOX(hbox), edit, TRUE, TRUE, 0);
- xferData->price_edit = edit;
- entry = gnc_amount_edit_gtk_entry (GNC_AMOUNT_EDIT (edit));
- g_signal_connect (G_OBJECT (entry), "focus-out-event",
- G_CALLBACK (gnc_xfer_price_update_cb), xferData);
- gtk_entry_set_activates_default(GTK_ENTRY (entry), TRUE);
+ edit = gnc_amount_edit_new();
+ gnc_amount_edit_set_print_info(GNC_AMOUNT_EDIT(edit),
+ gnc_default_print_info (FALSE));
+ hbox = glade_xml_get_widget (xml, "price_hbox");
+ gtk_box_pack_start(GTK_BOX(hbox), edit, TRUE, TRUE, 0);
+ xferData->price_edit = edit;
+ entry = gnc_amount_edit_gtk_entry (GNC_AMOUNT_EDIT (edit));
+ g_signal_connect (G_OBJECT (entry), "focus-out-event",
+ G_CALLBACK (gnc_xfer_price_update_cb), xferData);
+ gtk_entry_set_activates_default(GTK_ENTRY (entry), TRUE);
- edit = gnc_amount_edit_new();
- hbox = glade_xml_get_widget (xml, "right_amount_hbox");
- gtk_box_pack_start(GTK_BOX(hbox), edit, TRUE, TRUE, 0);
- xferData->to_amount_edit = edit;
- entry = gnc_amount_edit_gtk_entry (GNC_AMOUNT_EDIT (edit));
- g_signal_connect (G_OBJECT (entry), "focus-out-event",
- G_CALLBACK (gnc_xfer_to_amount_update_cb), xferData);
- gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
+ edit = gnc_amount_edit_new();
+ hbox = glade_xml_get_widget (xml, "right_amount_hbox");
+ gtk_box_pack_start(GTK_BOX(hbox), edit, TRUE, TRUE, 0);
+ xferData->to_amount_edit = edit;
+ entry = gnc_amount_edit_gtk_entry (GNC_AMOUNT_EDIT (edit));
+ g_signal_connect (G_OBJECT (entry), "focus-out-event",
+ G_CALLBACK (gnc_xfer_to_amount_update_cb), xferData);
+ gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
- button = glade_xml_get_widget (xml, "price_radio");
- xferData->price_radio = button;
- g_signal_connect (G_OBJECT (xferData->price_radio), "toggled",
- G_CALLBACK (price_amount_radio_toggled_cb), xferData);
+ button = glade_xml_get_widget (xml, "price_radio");
+ xferData->price_radio = button;
+ g_signal_connect (G_OBJECT (xferData->price_radio), "toggled",
+ G_CALLBACK (price_amount_radio_toggled_cb), xferData);
- button = glade_xml_get_widget (xml, "amount_radio");
- xferData->amount_radio = button;
- g_signal_connect(G_OBJECT(xferData->amount_radio), "toggled",
- G_CALLBACK(price_amount_radio_toggled_cb),
- xferData);
- if(use_accounting_labels) {
- gtk_label_set_text(GTK_LABEL(GTK_BIN(xferData->amount_radio)->child),
- _("Debit Amount:"));
+ button = glade_xml_get_widget (xml, "amount_radio");
+ xferData->amount_radio = button;
+ g_signal_connect(G_OBJECT(xferData->amount_radio), "toggled",
+ G_CALLBACK(price_amount_radio_toggled_cb),
+ xferData);
+ if (use_accounting_labels)
+ {
+ gtk_label_set_text(GTK_LABEL(GTK_BIN(xferData->amount_radio)->child),
+ _("Debit Amount:"));
+ }
+ else
+ {
+ gtk_label_set_text(GTK_LABEL(GTK_BIN(xferData->amount_radio)->child),
+ _("To Amount:"));
+ }
}
- else {
- gtk_label_set_text(GTK_LABEL(GTK_BIN(xferData->amount_radio)->child),
- _("To Amount:"));
- }
- }
- gnc_restore_window_size (GCONF_SECTION, GTK_WINDOW (dialog));
- LEAVE(" ");
+ gnc_restore_window_size (GCONF_SECTION, GTK_WINDOW (dialog));
+ LEAVE(" ");
}
static void
close_handler (gpointer user_data)
{
- XferDialog *xferData = user_data;
- GtkWidget *dialog;
+ XferDialog *xferData = user_data;
+ GtkWidget *dialog;
- ENTER(" ");
- dialog = GTK_WIDGET (xferData->dialog);
+ ENTER(" ");
+ dialog = GTK_WIDGET (xferData->dialog);
- gnc_save_window_size (GCONF_SECTION, GTK_WINDOW (dialog));
- gtk_widget_hide (dialog);
- gnc_xfer_dialog_close_cb(GTK_DIALOG(dialog), xferData);
- gtk_widget_destroy (dialog);
- LEAVE(" ");
+ gnc_save_window_size (GCONF_SECTION, GTK_WINDOW (dialog));
+ gtk_widget_hide (dialog);
+ gnc_xfer_dialog_close_cb(GTK_DIALOG(dialog), xferData);
+ gtk_widget_destroy (dialog);
+ LEAVE(" ");
}
/********************************************************************\
@@ -1839,159 +1882,165 @@
XferDialog *
gnc_xfer_dialog (GtkWidget * parent, Account * initial)
{
- XferDialog *xferData;
- GNCAmountEdit *gae;
- GtkWidget *amount_entry;
- QofBook *book = NULL;
+ XferDialog *xferData;
+ GNCAmountEdit *gae;
+ GtkWidget *amount_entry;
+ QofBook *book = NULL;
- xferData = g_new0 (XferDialog, 1);
+ xferData = g_new0 (XferDialog, 1);
- xferData->desc_start_selection = 0;
- xferData->desc_end_selection = 0;
- xferData->desc_selection_source_id = 0;
- xferData->quickfill = XFER_DIALOG_FROM;
- xferData->transaction_cb = NULL;
+ xferData->desc_start_selection = 0;
+ xferData->desc_end_selection = 0;
+ xferData->desc_selection_source_id = 0;
+ xferData->quickfill = XFER_DIALOG_FROM;
+ xferData->transaction_cb = NULL;
- if (initial) {
- book = gnc_account_get_book (initial);
- } else {
- book = gnc_get_current_book ();
- }
+ if (initial)
+ {
+ book = gnc_account_get_book (initial);
+ }
+ else
+ {
+ book = gnc_get_current_book ();
+ }
- xferData->book = book;
- xferData->pricedb = gnc_book_get_pricedb (book);
+ xferData->book = book;
+ xferData->pricedb = gnc_book_get_pricedb (book);
- gnc_xfer_dialog_create(parent, xferData);
+ gnc_xfer_dialog_create(parent, xferData);
- DEBUG("register component");
- gnc_register_gui_component (DIALOG_TRANSFER_CM_CLASS,
- NULL, close_handler, xferData);
+ DEBUG("register component");
+ gnc_register_gui_component (DIALOG_TRANSFER_CM_CLASS,
+ NULL, close_handler, xferData);
- gae = GNC_AMOUNT_EDIT(xferData->amount_edit);
- amount_entry = gnc_amount_edit_gtk_entry (gae);
+ gae = GNC_AMOUNT_EDIT(xferData->amount_edit);
+ amount_entry = gnc_amount_edit_gtk_entry (gae);
- gtk_widget_grab_focus(amount_entry);
+ gtk_widget_grab_focus(amount_entry);
- gnc_xfer_dialog_select_from_account(xferData, initial);
- gnc_xfer_dialog_select_to_account(xferData, initial);
+ gnc_xfer_dialog_select_from_account(xferData, initial);
+ gnc_xfer_dialog_select_to_account(xferData, initial);
- gnc_xfer_dialog_curr_acct_activate(xferData);
+ gnc_xfer_dialog_curr_acct_activate(xferData);
- gtk_widget_show_all(xferData->dialog);
+ gtk_widget_show_all(xferData->dialog);
- gnc_window_adjust_for_screen(GTK_WINDOW(xferData->dialog));
+ gnc_window_adjust_for_screen(GTK_WINDOW(xferData->dialog));
- return xferData;
+ return xferData;
}
void
gnc_xfer_dialog_close( XferDialog *xferData )
{
- if( xferData ) {
- DEBUG("close component");
- gtk_dialog_response( GTK_DIALOG(xferData->dialog), GTK_RESPONSE_NONE );
- }
+ if ( xferData )
+ {
+ DEBUG("close component");
+ gtk_dialog_response( GTK_DIALOG(xferData->dialog), GTK_RESPONSE_NONE );
+ }
}
void
gnc_xfer_dialog_set_title( XferDialog *xferData, const gchar *title )
{
- if( xferData && title )
- {
- gtk_window_set_title (GTK_WINDOW (xferData->dialog), title);
- }
+ if ( xferData && title )
+ {
+ gtk_window_set_title (GTK_WINDOW (xferData->dialog), title);
+ }
}
void
gnc_xfer_dialog_set_information_label( XferDialog *xferData,
- const gchar *text )
+ const gchar *text )
{
- if(xferData && text) {
- gchar *markup_text = g_strdup_printf ("<b>%s</b>", text);
- gtk_label_set_markup (GTK_LABEL (xferData->transferinfo_label), markup_text);
- g_free (markup_text);
- }
+ if (xferData && text)
+ {
+ gchar *markup_text = g_strdup_printf ("<b>%s</b>", text);
+ gtk_label_set_markup (GTK_LABEL (xferData->transferinfo_label), markup_text);
+ g_free (markup_text);
+ }
}
static void
gnc_xfer_dialog_set_account_label( XferDialog *xferData,
- const gchar *text,
- XferDirection direction )
+ const gchar *text,
+ XferDirection direction )
{
- if(xferData && text) {
- gchar *markup_text = g_strdup_printf ("<b>%s</b>", text);
- gtk_label_set_markup (GTK_LABEL ((direction == XFER_DIALOG_FROM ?
- xferData->from_transfer_label :
- xferData->to_transfer_label)),
- markup_text);
- g_free (markup_text);
- }
+ if (xferData && text)
+ {
+ gchar *markup_text = g_strdup_printf ("<b>%s</b>", text);
+ gtk_label_set_markup (GTK_LABEL ((direction == XFER_DIALOG_FROM ?
+ xferData->from_transfer_label :
+ xferData->to_transfer_label)),
+ markup_text);
+ g_free (markup_text);
+ }
}
void
gnc_xfer_dialog_set_from_account_label( XferDialog *xferData,
- const gchar *label )
+ const gchar *label )
{
- gnc_xfer_dialog_set_account_label (xferData, label, XFER_DIALOG_FROM);
+ gnc_xfer_dialog_set_account_label (xferData, label, XFER_DIALOG_FROM);
}
void
gnc_xfer_dialog_set_to_account_label( XferDialog *xferData,
- const gchar *label )
+ const gchar *label )
{
- gnc_xfer_dialog_set_account_label (xferData, label, XFER_DIALOG_TO);
+ gnc_xfer_dialog_set_account_label (xferData, label, XFER_DIALOG_TO);
}
void
gnc_xfer_dialog_set_from_show_button_active( XferDialog *xferData,
- gboolean set_value )
+ gboolean set_value )
{
- if( xferData && xferData->from_show_button )
- {
- gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(xferData->from_show_button),
- set_value );
- }
+ if ( xferData && xferData->from_show_button )
+ {
+ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(xferData->from_show_button),
+ set_value );
+ }
}
void
gnc_xfer_dialog_set_to_show_button_active( XferDialog *xferData,
- gboolean set_value )
+ gboolean set_value )
{
- if( xferData && xferData->to_show_button )
- {
- gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(xferData->to_show_button),
- set_value );
- }
+ if ( xferData && xferData->to_show_button )
+ {
+ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(xferData->to_show_button),
+ set_value );
+ }
}
/* Add a button with a user-specified label and "clicked" callback */
void gnc_xfer_dialog_add_user_specified_button( XferDialog *xferData,
- const gchar *label,
- GCallback callback,
- gpointer user_data )
+ const gchar *label,
+ GCallback callback,
+ gpointer user_data )
{
- if( xferData && label && callback )
- {
- GtkWidget *button = gtk_button_new_with_label( label );
- GtkWidget *box = gnc_glade_lookup_widget (xferData->dialog,
- "transfermain-vbox" );
- gtk_box_pack_end( GTK_BOX(box), button, FALSE, FALSE, 0 );
- g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (callback), user_data);
- gtk_widget_show( button );
- }
+ if ( xferData && label && callback )
+ {
+ GtkWidget *button = gtk_button_new_with_label( label );
+ GtkWidget *box = gnc_glade_lookup_widget (xferData->dialog,
+ "transfermain-vbox" );
+ gtk_box_pack_end( GTK_BOX(box), button, FALSE, FALSE, 0 );
+ g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (callback), user_data);
+ gtk_widget_show( button );
+ }
}
void gnc_xfer_dialog_toggle_currency_table( XferDialog *xferData,
- gboolean show_table )
+ gboolean show_table )
{
- if (xferData && xferData->curr_xfer_table)
- {
- if (show_table)
- gtk_widget_show(xferData->curr_xfer_table);
- else
- gtk_widget_hide(xferData->curr_xfer_table);
- }
+ if (xferData && xferData->curr_xfer_table)
+ {
+ if (show_table)
+ gtk_widget_show(xferData->curr_xfer_table);
+ else
+ gtk_widget_hide(xferData->curr_xfer_table);
+ }
}
@@ -1999,7 +2048,7 @@
static gboolean
find_xfer (gpointer find_data, gpointer user_data)
{
- return( find_data == user_data );
+ return( find_data == user_data );
}
/* Run the dialog until the user has either successfully completed the
@@ -2008,56 +2057,59 @@
*/
gboolean gnc_xfer_dialog_run_until_done( XferDialog *xferData )
{
- GtkDialog *dialog;
- gint count, response;
+ GtkDialog *dialog;
+ gint count, response;
- ENTER("xferData=%p", xferData);
- if( xferData == NULL ) {
- LEAVE("bad args");
- return( FALSE );
- }
+ ENTER("xferData=%p", xferData);
+ if ( xferData == NULL )
+ {
+ LEAVE("bad args");
+ return( FALSE );
+ }
- dialog = GTK_DIALOG (xferData->dialog);
+ dialog = GTK_DIALOG (xferData->dialog);
- /*
- * We need to call the response_cb function by hand. Calling it
- * automatically on a button click can destroy the window, and
- * that's bad mojo whole gtk_dialog_run is still in control.
- */
- count = g_signal_handlers_disconnect_by_func(dialog,
- gnc_xfer_dialog_response_cb,
- xferData);
- g_assert(count == 1);
+ /*
+ * We need to call the response_cb function by hand. Calling it
+ * automatically on a button click can destroy the window, and
+ * that's bad mojo whole gtk_dialog_run is still in control.
+ */
+ count = g_signal_handlers_disconnect_by_func(dialog,
+ gnc_xfer_dialog_response_cb,
+ xferData);
+ g_assert(count == 1);
- while( TRUE ) {
- DEBUG("calling gtk_dialog_run");
- response = gtk_dialog_run (dialog);
- DEBUG("gtk_dialog_run returned %d", response);
- gnc_xfer_dialog_response_cb (dialog, response, xferData);
+ while ( TRUE )
+ {
+ DEBUG("calling gtk_dialog_run");
+ response = gtk_dialog_run (dialog);
+ DEBUG("gtk_dialog_run returned %d", response);
+ gnc_xfer_dialog_response_cb (dialog, response, xferData);
- if ((response != GTK_RESPONSE_OK) && (response != GTK_RESPONSE_APPLY)) {
- LEAVE("not ok");
- return FALSE;
- }
+ if ((response != GTK_RESPONSE_OK) && (response != GTK_RESPONSE_APPLY))
+ {
+ LEAVE("not ok");
+ return FALSE;
+ }
- /* See if the dialog is still there. For various reasons, the
- * user could have hit OK but remained in the dialog. We don't
- * want to return processing back to anyone else until we clear
- * off this dialog, so if the dialog is still there we'll just
- * run it again.
- */
- if( !gnc_find_first_gui_component( DIALOG_TRANSFER_CM_CLASS,
- find_xfer, xferData ) )
- {
- /* no more dialog, and OK was clicked, so assume it's all good */
- LEAVE("ok");
- return TRUE;
- }
+ /* See if the dialog is still there. For various reasons, the
+ * user could have hit OK but remained in the dialog. We don't
+ * want to return processing back to anyone else until we clear
+ * off this dialog, so if the dialog is still there we'll just
+ * run it again.
+ */
+ if ( !gnc_find_first_gui_component( DIALOG_TRANSFER_CM_CLASS,
+ find_xfer, xferData ) )
+ {
+ /* no more dialog, and OK was clicked, so assume it's all good */
+ LEAVE("ok");
+ return TRUE;
+ }
- /* else run the dialog again */
- }
+ /* else run the dialog again */
+ }
- g_assert_not_reached();
+ g_assert_not_reached();
}
@@ -2069,81 +2121,83 @@
gnc_xfer_dialog_quickfill_to_account(XferDialog *xferData,
gboolean qf_to_account )
{
- XferDirection old = xferData->quickfill;
+ XferDirection old = xferData->quickfill;
- xferData->quickfill = qf_to_account ? XFER_DIALOG_TO : XFER_DIALOG_FROM;
+ xferData->quickfill = qf_to_account ? XFER_DIALOG_TO : XFER_DIALOG_FROM;
- /* reload the quickfill if necessary */
- if( old != xferData->quickfill )
- gnc_xfer_dialog_reload_quickfill( xferData );
+ /* reload the quickfill if necessary */
+ if ( old != xferData->quickfill )
+ gnc_xfer_dialog_reload_quickfill( xferData );
}
static Account *
gnc_transfer_dialog_get_selected_account (XferDialog *dialog,
- XferDirection direction)
+ XferDirection direction)
{
- GtkTreeView *tree_view;
- Account *account;
+ GtkTreeView *tree_view;
+ Account *account;
- switch (direction) {
- case XFER_DIALOG_FROM:
- tree_view = dialog->from_tree_view;
- break;
- case XFER_DIALOG_TO:
- tree_view = dialog->to_tree_view;
- break;
- default:
- g_assert_not_reached ();
- return NULL;
- }
+ switch (direction)
+ {
+ case XFER_DIALOG_FROM:
+ tree_view = dialog->from_tree_view;
+ break;
+ case XFER_DIALOG_TO:
+ tree_view = dialog->to_tree_view;
+ break;
+ default:
+ g_assert_not_reached ();
+ return NULL;
+ }
- account = gnc_tree_view_account_get_selected_account (GNC_TREE_VIEW_ACCOUNT (tree_view));
- return account;
+ account = gnc_tree_view_account_get_selected_account (GNC_TREE_VIEW_ACCOUNT (tree_view));
+ return account;
}
static void
gnc_transfer_dialog_set_selected_account (XferDialog *dialog,
- Account *account,
- XferDirection direction)
+ Account *account,
+ XferDirection direction)
{
- GtkTreeView *tree_view;
- GtkCheckButton *show_button;
- GNCAccountType type;
+ GtkTreeView *tree_view;
+ GtkCheckButton *show_button;
+ GNCAccountType type;
- if (account == NULL)
- return;
+ if (account == NULL)
+ return;
- switch (direction) {
- case XFER_DIALOG_FROM:
- tree_view = dialog->from_tree_view;
- show_button = GTK_CHECK_BUTTON (dialog->from_show_button);
- break;
- case XFER_DIALOG_TO:
- tree_view = dialog->to_tree_view;
- show_button = GTK_CHECK_BUTTON (dialog->to_show_button);
- break;
- default:
- g_assert_not_reached ();
- return;
- }
+ switch (direction)
+ {
+ case XFER_DIALOG_FROM:
+ tree_view = dialog->from_tree_view;
+ show_button = GTK_CHECK_BUTTON (dialog->from_show_button);
+ break;
+ case XFER_DIALOG_TO:
+ tree_view = dialog->to_tree_view;
+ show_button = GTK_CHECK_BUTTON (dialog->to_show_button);
+ break;
+ default:
+ g_assert_not_reached ();
+ return;
+ }
- type = xaccAccountGetType (account);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (show_button),
- (type == ACCT_TYPE_EXPENSE) ||
- (type == ACCT_TYPE_INCOME));
+ type = xaccAccountGetType (account);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (show_button),
+ (type == ACCT_TYPE_EXPENSE) ||
+ (type == ACCT_TYPE_INCOME));
- gnc_tree_view_account_set_selected_account (GNC_TREE_VIEW_ACCOUNT (tree_view),
- account);
+ gnc_tree_view_account_set_selected_account (GNC_TREE_VIEW_ACCOUNT (tree_view),
+ account);
}
void gnc_xfer_dialog_set_txn_cb(XferDialog *xferData,
- gnc_xfer_dialog_cb handler,
- gpointer user_data)
+ gnc_xfer_dialog_cb handler,
+ gpointer user_data)
{
- g_assert(xferData);
- xferData->transaction_cb = handler;
- xferData->transaction_user_data = user_data;
+ g_assert(xferData);
+ xferData->transaction_cb = handler;
+ xferData->transaction_user_data = user_data;
}
@@ -2158,31 +2212,37 @@
g_return_val_if_fail(txn_cur, TRUE);
- if (xaccTransUseTradingAccounts (txn)) {
- /* If we're using commodity trading accounts then "amount" is
- really the split's amount and it's in xfer_com. We need an
- exchange rate that will convert this amount into a value in
- the transaction currency. */
- if (gnc_commodity_equal(xfer_com, txn_cur)) {
- /* Transaction is in the same currency as the split, exchange
- rate is 1. */
- *exch_rate = gnc_numeric_create(1, 1);
- return FALSE;
- }
- swap_amounts = TRUE;
+ if (xaccTransUseTradingAccounts (txn))
+ {
+ /* If we're using commodity trading accounts then "amount" is
+ really the split's amount and it's in xfer_com. We need an
+ exchange rate that will convert this amount into a value in
+ the transaction currency. */
+ if (gnc_commodity_equal(xfer_com, txn_cur))
+ {
+ /* Transaction is in the same currency as the split, exchange
+ rate is 1. */
+ *exch_rate = gnc_numeric_create(1, 1);
+ return FALSE;
+ }
+ swap_amounts = TRUE;
- /* We know that "amount" is always in the reg_com currency.
- * Unfortunately it is possible that neither xfer_com or txn_cur are
- * the same as reg_com, in which case we need to convert to the txn
- * currency... Or, if the register commodity is the xfer_com, then we
- * need to flip-flop the commodities and the exchange rates.
- */
+ /* We know that "amount" is always in the reg_com currency.
+ * Unfortunately it is possible that neither xfer_com or txn_cur are
+ * the same as reg_com, in which case we need to convert to the txn
+ * currency... Or, if the register commodity is the xfer_com, then we
+ * need to flip-flop the commodities and the exchange rates.
+ */
- } else if (gnc_commodity_equal(reg_com, txn_cur)) {
+ }
+ else if (gnc_commodity_equal(reg_com, txn_cur))
+ {
/* we're working in the txn currency. Great. Nothing to do! */
swap_amounts = FALSE;
- } else if (gnc_commodity_equal(reg_com, xfer_com)) {
+ }
+ else if (gnc_commodity_equal(reg_com, xfer_com))
+ {
/* We're working in the xfer commodity. Great. Just swap the
amounts. */
swap_amounts = TRUE;
@@ -2190,7 +2250,9 @@
/* XXX: Do we need to check for expanded v. non-expanded
accounts here? */
- } else {
+ }
+ else
+ {
/* UGGH -- we're not in either. That means we need to convert
* 'amount' from the register commodity to the txn currency.
*/
@@ -2198,19 +2260,22 @@
/* XXX: should we tell the user we've done the conversion? */
amount = gnc_numeric_div(
- amount, rate,
- gnc_commodity_get_fraction(txn_cur), GNC_DENOM_REDUCE);
+ amount, rate,
+ gnc_commodity_get_fraction(txn_cur), GNC_DENOM_REDUCE);
}
/* enter the accounts */
- if (swap_amounts) {
+ if (swap_amounts)
+ {
gnc_xfer_dialog_select_to_currency(xfer, txn_cur);
gnc_xfer_dialog_select_from_currency(xfer, xfer_com);
if (!gnc_numeric_zero_p(*exch_rate))
*exch_rate = gnc_numeric_div(gnc_numeric_create(1, 1), *exch_rate,
GNC_DENOM_AUTO, GNC_DENOM_REDUCE);
amount = gnc_numeric_neg(amount);
- } else {
+ }
+ else
+ {
gnc_xfer_dialog_select_to_currency(xfer, xfer_com);
gnc_xfer_dialog_select_from_currency(xfer, txn_cur);
}
Modified: gnucash/trunk/src/gnome-utils/dialog-transfer.h
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-transfer.h 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/dialog-transfer.h 2010-03-02 21:42:11 UTC (rev 18791)
@@ -30,10 +30,10 @@
typedef struct _xferDialog XferDialog;
/** Opens up a window to do an automatic transfer between accounts
- *
- * Args: parent - the parent of the window to be created
- * initial - the initial account in the from/to fields
- * Return: XferDialog structure
+ *
+ * Args: parent - the parent of the window to be created
+ * initial - the initial account in the from/to fields
+ * Return: XferDialog structure
*/
XferDialog * gnc_xfer_dialog(GtkWidget * parent, Account *initial);
@@ -50,21 +50,21 @@
/** Set the label of the topmost table */
void gnc_xfer_dialog_set_information_label( XferDialog *,
- const gchar * );
+ const gchar * );
/** Add a button with a user-specified label and "clicked" callback.
* For now this doesn't offer a lot of flexibility, but it doesn't have to.
*/
void gnc_xfer_dialog_add_user_specified_button( XferDialog *xferData,
- const gchar *label,
- GCallback callback,
- gpointer user_data );
+ const gchar *label,
+ GCallback callback,
+ gpointer user_data );
void gnc_xfer_dialog_toggle_currency_table ( XferDialog *xferData,
- gboolean show_table );
+ gboolean show_table );
void gnc_xfer_dialog_set_from_account_label( XferDialog *,
- const gchar * );
+ const gchar * );
void gnc_xfer_dialog_set_to_account_label( XferDialog *, const gchar * );
/** Set the buttons for "Show Income/Expense" */
@@ -73,7 +73,7 @@
/** select the from account in a xfer dialog */
void gnc_xfer_dialog_select_from_account(XferDialog *xferData,
- Account *account);
+ Account *account);
/** select the to account in a xfer dialog */
void gnc_xfer_dialog_select_to_account(XferDialog *xferData,
Account *account);
@@ -92,64 +92,64 @@
/**
- * set the amount in the given xfer dialog
- *
- * Args: xferData - xfer dialog structure
- * amount - the amount to set
- * Return: none
+ * set the amount in the given xfer dialog
+ *
+ * Args: xferData - xfer dialog structure
+ * amount - the amount to set
+ * Return: none
*/
void gnc_xfer_dialog_set_amount(XferDialog *xferData, gnc_numeric amount);
/**
- * set the description in the given xfer dialog
- *
- * Args: xferData - xfer dialog structure
- * description - the description to set
- * Return: none
+ * set the description in the given xfer dialog
+ *
+ * Args: xferData - xfer dialog structure
+ * description - the description to set
+ * Return: none
*/
void gnc_xfer_dialog_set_description(XferDialog *xferData,
const char *description);
-/** set the memo in the given xfer dialog
- *
- * Args: xferData - xfer dialog structure
- * memo - the memo to set
- * Return: none
+/** set the memo in the given xfer dialog
+ *
+ * Args: xferData - xfer dialog structure
+ * memo - the memo to set
+ * Return: none
*/
void gnc_xfer_dialog_set_memo(XferDialog *xferData, const char *memo);
/**
- * set the num in the given xfer dialog
- *
- * Args: xferData - xfer dialog structure
- * num - the num to set
- * Return: none
+ * set the num in the given xfer dialog
+ *
+ * Args: xferData - xfer dialog structure
+ * num - the num to set
+ * Return: none
*/
void gnc_xfer_dialog_set_num(XferDialog *xferData, const char *num);
/**
- * Set the date in the given xfer dialog
- *
- * Args: xferData - xfer dialog structure
- * set_date - the date to set
- * Return: none
+ * Set the date in the given xfer dialog
+ *
+ * Args: xferData - xfer dialog structure
+ * set_date - the date to set
+ * Return: none
*/
void gnc_xfer_dialog_set_date(XferDialog *xferData, time_t set_time);
/** Set the exchange rate. If exchange-rate is 0, then do nothing */
void gnc_xfer_dialog_set_exchange_rate(XferDialog *xferData,
- gnc_numeric exchange_rate);
+ gnc_numeric exchange_rate);
/** Indicate whether the dialog should quickfill based on the "To" account,
* rather than the default which is the "From" account.
*/
void gnc_xfer_dialog_quickfill_to_account(XferDialog *xferData,
- gboolean qf_to_account );
+ gboolean qf_to_account );
/**
- * Set the dialog as an "exchange-dialog", which means that the
- * Transfer Information table read-only (and the dialog
- * will NOT create a transaction when it is closed).
+ * Set the dialog as an "exchange-dialog", which means that the
+ * Transfer Information table read-only (and the dialog
+ * will NOT create a transaction when it is closed).
*
* In other words: Indicate that this is just trying to obtain the
* to_amount, so make the Transfer Information read-only and the
@@ -158,12 +158,12 @@
* caller should call the dialog 'run' function to make sure exch_rate
* pointer remains valid.
*
- * Args: xferData - xfer dialog structure
- * exch_rate - place to store the exchange rate at exit
- * Return: none
+ * Args: xferData - xfer dialog structure
+ * exch_rate - place to store the exchange rate at exit
+ * Return: none
*/
void gnc_xfer_dialog_is_exchange_dialog(XferDialog *xferData,
- gnc_numeric * exch_rate);
+ gnc_numeric * exch_rate);
/** Callback function type for gnc_xfer_dialog_set_txn_cb().
@@ -173,10 +173,10 @@
*
* @param user_data User-supplied pointer to some data */
typedef void (*gnc_xfer_dialog_cb)(Transaction *new_trans,
- gpointer user_data);
+ gpointer user_data);
/** Register a callback function to be called with the created
- * Transaction as soon as it is created.
+ * Transaction as soon as it is created.
*
* Note: The caller is responsible to unregister this function in case
* it becomes invalid. In other words, you have to reset the handler
@@ -187,16 +187,16 @@
* transaction==NULL to notify the callback of destruction of the
* XferData structure.
*
- * @param xferData Dialog data structure
+ * @param xferData Dialog data structure
*
* @param handler Callback function that should be notified of the
- * newly created Transaction
+ * newly created Transaction
*
* @param user_data User-supplied pointer that will be passed to
* handler. */
void gnc_xfer_dialog_set_txn_cb(XferDialog *xferData,
- gnc_xfer_dialog_cb handler,
- gpointer user_data);
+ gnc_xfer_dialog_cb handler,
+ gpointer user_data);
/* Uses the XferDialog to obtain from the user an explicit exchange
rate. This exchange rate will then be uses to converting 'amount',
@@ -210,7 +210,7 @@
TRUE is returned and the 'exch_rate' argument is undefined.
*/
gboolean gnc_xfer_dialog_run_exchange_dialog(
- XferDialog *xfer, gnc_numeric *exch_rate, gnc_numeric amount,
+ XferDialog *xfer, gnc_numeric *exch_rate, gnc_numeric amount,
Account *reg_acc, Transaction *txn, gnc_commodity *xfer_com);
#endif
Modified: gnucash/trunk/src/gnome-utils/dialog-utils.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-utils.c 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/dialog-utils.c 2010-03-02 21:42:11 UTC (rev 18791)
@@ -53,24 +53,24 @@
static void
gnc_option_menu_cb(GtkWidget *w, gpointer data)
{
- GNCOptionCallback cb;
- gpointer _index;
- gint index;
+ GNCOptionCallback cb;
+ gpointer _index;
+ gint index;
- cb = g_object_get_data(G_OBJECT(w), "gnc_option_cb");
+ cb = g_object_get_data(G_OBJECT(w), "gnc_option_cb");
- _index = g_object_get_data(G_OBJECT(w), "gnc_option_index");
- index = GPOINTER_TO_INT(_index);
+ _index = g_object_get_data(G_OBJECT(w), "gnc_option_index");
+ index = GPOINTER_TO_INT(_index);
- cb(w, index, data);
+ cb(w, index, data);
}
static void
option_menu_destroy_cb (GtkObject *obj, gpointer data)
{
- GtkTooltips *tips = data;
+ GtkTooltips *tips = data;
- g_object_unref (tips);
+ g_object_unref (tips);
}
/********************************************************************\
@@ -84,54 +84,54 @@
GtkWidget *
gnc_build_option_menu(GNCOptionInfo *option_info, gint num_options)
{
- GtkTooltips *tooltips;
- GtkWidget *omenu;
- GtkWidget *menu;
- GtkWidget *menu_item;
- gint i;
+ GtkTooltips *tooltips;
+ GtkWidget *omenu;
+ GtkWidget *menu;
+ GtkWidget *menu_item;
+ gint i;
- omenu = gtk_option_menu_new();
- gtk_widget_show(omenu);
+ omenu = gtk_option_menu_new();
+ gtk_widget_show(omenu);
- menu = gtk_menu_new();
- gtk_widget_show(menu);
+ menu = gtk_menu_new();
+ gtk_widget_show(menu);
- tooltips = gtk_tooltips_new();
+ tooltips = gtk_tooltips_new();
- g_object_ref_sink(tooltips);
+ g_object_ref_sink(tooltips);
- for (i = 0; i < num_options; i++)
- {
- menu_item = gtk_menu_item_new_with_label(option_info[i].name);
- gtk_tooltips_set_tip(tooltips, menu_item, option_info[i].tip, NULL);
- gtk_widget_show(menu_item);
+ for (i = 0; i < num_options; i++)
+ {
+ menu_item = gtk_menu_item_new_with_label(option_info[i].name);
+ gtk_tooltips_set_tip(tooltips, menu_item, option_info[i].tip, NULL);
+ gtk_widget_show(menu_item);
- g_object_set_data(G_OBJECT(menu_item),
- "gnc_option_cb",
- option_info[i].callback);
+ g_object_set_data(G_OBJECT(menu_item),
+ "gnc_option_cb",
+ option_info[i].callback);
- g_object_set_data(G_OBJECT(menu_item),
- "gnc_option_index",
- GINT_TO_POINTER(i));
+ g_object_set_data(G_OBJECT(menu_item),
+ "gnc_option_index",
+ GINT_TO_POINTER(i));
- g_object_set_data(G_OBJECT(menu_item),
- "gnc_option_menu",
- omenu);
+ g_object_set_data(G_OBJECT(menu_item),
+ "gnc_option_menu",
+ omenu);
- if (option_info[i].callback != NULL)
- g_signal_connect(menu_item, "activate",
- G_CALLBACK(gnc_option_menu_cb),
- option_info[i].user_data);
+ if (option_info[i].callback != NULL)
+ g_signal_connect(menu_item, "activate",
+ G_CALLBACK(gnc_option_menu_cb),
+ option_info[i].user_data);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
- }
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
+ }
- gtk_option_menu_set_menu(GTK_OPTION_MENU(omenu), menu);
+ gtk_option_menu_set_menu(GTK_OPTION_MENU(omenu), menu);
- g_signal_connect (omenu, "destroy",
- G_CALLBACK (option_menu_destroy_cb), tooltips);
+ g_signal_connect (omenu, "destroy",
+ G_CALLBACK (option_menu_destroy_cb), tooltips);
- return omenu;
+ return omenu;
}
@@ -145,25 +145,26 @@
GtkToolbarStyle
gnc_get_toolbar_style(void)
{
- GtkToolbarStyle tbstyle = GTK_TOOLBAR_BOTH;
- char *style_string;
+ GtkToolbarStyle tbstyle = GTK_TOOLBAR_BOTH;
+ char *style_string;
- style_string = gnc_gconf_get_string(GCONF_GENERAL,
- KEY_TOOLBAR_STYLE, NULL);
- if (!style_string || strcmp(style_string, "system") == 0) {
- if (style_string)
- g_free(style_string);
- style_string = gnc_gconf_get_string(DESKTOP_GNOME_INTERFACE,
- KEY_TOOLBAR_STYLE, NULL);
- }
+ style_string = gnc_gconf_get_string(GCONF_GENERAL,
+ KEY_TOOLBAR_STYLE, NULL);
+ if (!style_string || strcmp(style_string, "system") == 0)
+ {
+ if (style_string)
+ g_free(style_string);
+ style_string = gnc_gconf_get_string(DESKTOP_GNOME_INTERFACE,
+ KEY_TOOLBAR_STYLE, NULL);
+ }
- if (style_string == NULL)
- return GTK_TOOLBAR_BOTH;
- tbstyle = gnc_enum_from_nick(GTK_TYPE_TOOLBAR_STYLE, style_string,
- GTK_TOOLBAR_BOTH);
- g_free(style_string);
+ if (style_string == NULL)
+ return GTK_TOOLBAR_BOTH;
+ tbstyle = gnc_enum_from_nick(GTK_TYPE_TOOLBAR_STYLE, style_string,
+ GTK_TOOLBAR_BOTH);
+ g_free(style_string);
- return tbstyle;
+ return tbstyle;
}
/********************************************************************\
@@ -176,9 +177,9 @@
void
gnc_get_deficit_color(GdkColor *color)
{
- color->red = 50000;
- color->green = 0;
- color->blue = 0;
+ color->red = 50000;
+ color->green = 0;
+ color->blue = 0;
}
@@ -193,32 +194,32 @@
void
gnc_set_label_color(GtkWidget *label, gnc_numeric value)
{
- gboolean deficit;
- GdkColormap *cm;
- GtkStyle *style;
+ gboolean deficit;
+ GdkColormap *cm;
+ GtkStyle *style;
- if (!gnc_gconf_get_bool(GCONF_GENERAL, "red_for_negative", NULL))
- return;
+ if (!gnc_gconf_get_bool(GCONF_GENERAL, "red_for_negative", NULL))
+ return;
- cm = gtk_widget_get_colormap(GTK_WIDGET(label));
- gtk_widget_ensure_style(GTK_WIDGET(label));
- style = gtk_widget_get_style(GTK_WIDGET(label));
+ cm = gtk_widget_get_colormap(GTK_WIDGET(label));
+ gtk_widget_ensure_style(GTK_WIDGET(label));
+ style = gtk_widget_get_style(GTK_WIDGET(label));
- style = gtk_style_copy(style);
+ style = gtk_style_copy(style);
- deficit = gnc_numeric_negative_p (value);
+ deficit = gnc_numeric_negative_p (value);
- if (deficit)
- {
- gnc_get_deficit_color(&style->fg[GTK_STATE_NORMAL]);
- gdk_colormap_alloc_color(cm, &style->fg[GTK_STATE_NORMAL], FALSE, TRUE);
- }
- else
- style->fg[GTK_STATE_NORMAL] = style->black;
+ if (deficit)
+ {
+ gnc_get_deficit_color(&style->fg[GTK_STATE_NORMAL]);
+ gdk_colormap_alloc_color(cm, &style->fg[GTK_STATE_NORMAL], FALSE, TRUE);
+ }
+ else
+ style->fg[GTK_STATE_NORMAL] = style->black;
- gtk_widget_set_style(label, style);
+ gtk_widget_set_style(label, style);
- g_object_unref(style);
+ g_object_unref(style);
}
@@ -235,33 +236,35 @@
void
gnc_restore_window_size(const char *section, GtkWindow *window)
{
- GSList *coord_list;
- gint coords[2];
+ GSList *coord_list;
+ gint coords[2];
- g_return_if_fail(section != NULL);
- g_return_if_fail(window != NULL);
+ g_return_if_fail(section != NULL);
+ g_return_if_fail(window != NULL);
- if (!gnc_gconf_get_bool(GCONF_GENERAL, KEY_SAVE_GEOMETRY, NULL))
- return;
+ if (!gnc_gconf_get_bool(GCONF_GENERAL, KEY_SAVE_GEOMETRY, NULL))
+ return;
- coord_list = gnc_gconf_get_list(section, WINDOW_POSITION,
- GCONF_VALUE_INT, NULL);
- if (coord_list) {
- coords[0] = GPOINTER_TO_INT(g_slist_nth_data(coord_list, 0));
- coords[1] = GPOINTER_TO_INT(g_slist_nth_data(coord_list, 1));
- gtk_window_move(window, coords[0], coords[1]);
- g_slist_free(coord_list);
- }
+ coord_list = gnc_gconf_get_list(section, WINDOW_POSITION,
+ GCONF_VALUE_INT, NULL);
+ if (coord_list)
+ {
+ coords[0] = GPOINTER_TO_INT(g_slist_nth_data(coord_list, 0));
+ coords[1] = GPOINTER_TO_INT(g_slist_nth_data(coord_list, 1));
+ gtk_window_move(window, coords[0], coords[1]);
+ g_slist_free(coord_list);
+ }
- coord_list = gnc_gconf_get_list(section, WINDOW_GEOMETRY,
- GCONF_VALUE_INT, NULL);
- if (coord_list) {
- coords[0] = GPOINTER_TO_INT(g_slist_nth_data(coord_list, 0));
- coords[1] = GPOINTER_TO_INT(g_slist_nth_data(coord_list, 1));
- if ((coords[0] != 0) && (coords[1] != 0))
- gtk_window_resize(window, coords[0], coords[1]);
- g_slist_free(coord_list);
- }
+ coord_list = gnc_gconf_get_list(section, WINDOW_GEOMETRY,
+ GCONF_VALUE_INT, NULL);
+ if (coord_list)
+ {
+ coords[0] = GPOINTER_TO_INT(g_slist_nth_data(coord_list, 0));
+ coords[1] = GPOINTER_TO_INT(g_slist_nth_data(coord_list, 1));
+ if ((coords[0] != 0) && (coords[1] != 0))
+ gtk_window_resize(window, coords[0], coords[1]);
+ g_slist_free(coord_list);
+ }
}
@@ -278,101 +281,102 @@
void
gnc_save_window_size(const char *section, GtkWindow *window)
{
- GSList *coord_list = NULL;
- gint coords[2];
+ GSList *coord_list = NULL;
+ gint coords[2];
- g_return_if_fail(section != NULL);
- g_return_if_fail(window != NULL);
+ g_return_if_fail(section != NULL);
+ g_return_if_fail(window != NULL);
- if (GTK_OBJECT_FLAGS(window) & GTK_IN_DESTRUCTION)
- return;
+ if (GTK_OBJECT_FLAGS(window) & GTK_IN_DESTRUCTION)
+ return;
- if (!gnc_gconf_get_bool(GCONF_GENERAL, KEY_SAVE_GEOMETRY, NULL))
- return;
+ if (!gnc_gconf_get_bool(GCONF_GENERAL, KEY_SAVE_GEOMETRY, NULL))
+ return;
- gtk_window_get_size(GTK_WINDOW(window), &coords[0], &coords[1]);
- coord_list = g_slist_append(coord_list, GUINT_TO_POINTER(coords[0]));
- coord_list = g_slist_append(coord_list, GUINT_TO_POINTER(coords[1]));
- gnc_gconf_set_list(section, WINDOW_GEOMETRY, GCONF_VALUE_INT,
- coord_list, NULL);
- g_slist_free(coord_list);
- coord_list = NULL;
+ gtk_window_get_size(GTK_WINDOW(window), &coords[0], &coords[1]);
+ coord_list = g_slist_append(coord_list, GUINT_TO_POINTER(coords[0]));
+ coord_list = g_slist_append(coord_list, GUINT_TO_POINTER(coords[1]));
+ gnc_gconf_set_list(section, WINDOW_GEOMETRY, GCONF_VALUE_INT,
+ coord_list, NULL);
+ g_slist_free(coord_list);
+ coord_list = NULL;
- gtk_window_get_position(GTK_WINDOW(window), &coords[0], &coords[1]);
- coord_list = g_slist_append(coord_list, GUINT_TO_POINTER(coords[0]));
- coord_list = g_slist_append(coord_list, GUINT_TO_POINTER(coords[1]));
- gnc_gconf_set_list(section, WINDOW_POSITION, GCONF_VALUE_INT,
- coord_list, NULL);
- g_slist_free(coord_list);
+ gtk_window_get_position(GTK_WINDOW(window), &coords[0], &coords[1]);
+ coord_list = g_slist_append(coord_list, GUINT_TO_POINTER(coords[0]));
+ coord_list = g_slist_append(coord_list, GUINT_TO_POINTER(coords[1]));
+ gnc_gconf_set_list(section, WINDOW_POSITION, GCONF_VALUE_INT,
+ coord_list, NULL);
+ g_slist_free(coord_list);
}
void
gnc_option_menu_init(GtkWidget * w)
{
- GtkWidget * menu;
- GtkWidget * active;
- unsigned int i;
+ GtkWidget * menu;
+ GtkWidget * active;
+ unsigned int i;
- menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(w));
+ menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(w));
- for(i = 0; i < g_list_length(GTK_MENU_SHELL(menu)->children); i++)
- {
- gtk_option_menu_set_history(GTK_OPTION_MENU(w), i);
- active = gtk_menu_get_active(GTK_MENU(menu));
- g_object_set_data(G_OBJECT(active),
- "option_index",
- GINT_TO_POINTER(i));
- }
+ for (i = 0; i < g_list_length(GTK_MENU_SHELL(menu)->children); i++)
+ {
+ gtk_option_menu_set_history(GTK_OPTION_MENU(w), i);
+ active = gtk_menu_get_active(GTK_MENU(menu));
+ g_object_set_data(G_OBJECT(active),
+ "option_index",
+ GINT_TO_POINTER(i));
+ }
- gtk_option_menu_set_history(GTK_OPTION_MENU(w), 0);
+ gtk_option_menu_set_history(GTK_OPTION_MENU(w), 0);
}
-typedef struct {
- int i;
- GCallback f;
- gpointer cb_data;
+typedef struct
+{
+ int i;
+ GCallback f;
+ gpointer cb_data;
} menu_init_data;
static void
gnc_option_menu_set_one_item (gpointer loop_data, gpointer user_data)
{
- GObject *item = G_OBJECT(loop_data);
- menu_init_data *args = (menu_init_data *) user_data;
+ GObject *item = G_OBJECT(loop_data);
+ menu_init_data *args = (menu_init_data *) user_data;
- g_object_set_data(item, "option_index", GINT_TO_POINTER(args->i++));
- g_signal_connect(item, "activate", args->f, args->cb_data);
+ g_object_set_data(item, "option_index", GINT_TO_POINTER(args->i++));
+ g_signal_connect(item, "activate", args->f, args->cb_data);
}
void
gnc_option_menu_init_w_signal(GtkWidget * w, GCallback f, gpointer cb_data)
{
- GtkWidget * menu;
- menu_init_data foo;
+ GtkWidget * menu;
+ menu_init_data foo;
- foo.i = 0;
- foo.f = f;
- foo.cb_data = cb_data;
+ foo.i = 0;
+ foo.f = f;
+ foo.cb_data = cb_data;
- menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(w));
- g_list_foreach(GTK_MENU_SHELL(menu)->children,
- gnc_option_menu_set_one_item, &foo);
- gtk_option_menu_set_history(GTK_OPTION_MENU(w), 0);
+ menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(w));
+ g_list_foreach(GTK_MENU_SHELL(menu)->children,
+ gnc_option_menu_set_one_item, &foo);
+ gtk_option_menu_set_history(GTK_OPTION_MENU(w), 0);
}
int
gnc_option_menu_get_active(GtkWidget * w)
{
- GtkWidget * menu;
- GtkWidget * menuitem;
+ GtkWidget * menu;
+ GtkWidget * menuitem;
- menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(w));
- menuitem = gtk_menu_get_active(GTK_MENU(menu));
+ menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(w));
+ menuitem = gtk_menu_get_active(GTK_MENU(menu));
- return GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menuitem),
- "option_index"));
+ return GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menuitem),
+ "option_index"));
}
@@ -386,33 +390,33 @@
void
gnc_window_adjust_for_screen(GtkWindow * window)
{
- gint screen_width;
- gint screen_height;
- gint width;
- gint height;
+ gint screen_width;
+ gint screen_height;
+ gint width;
+ gint height;
- if (window == NULL)
- return;
+ if (window == NULL)
+ return;
- g_return_if_fail(GTK_IS_WINDOW(window));
- if (GTK_WIDGET(window)->window == NULL)
- return;
+ g_return_if_fail(GTK_IS_WINDOW(window));
+ if (GTK_WIDGET(window)->window == NULL)
+ return;
- screen_width = gdk_screen_width();
- screen_height = gdk_screen_height();
- gdk_drawable_get_size(GTK_WIDGET(window)->window, &width, &height);
+ screen_width = gdk_screen_width();
+ screen_height = gdk_screen_height();
+ gdk_drawable_get_size(GTK_WIDGET(window)->window, &width, &height);
- if ((width <= screen_width) && (height <= screen_height))
- return;
+ if ((width <= screen_width) && (height <= screen_height))
+ return;
- width = MIN(width, screen_width - 10);
- width = MAX(width, 0);
+ width = MIN(width, screen_width - 10);
+ width = MAX(width, 0);
- height = MIN(height, screen_height - 10);
- height = MAX(height, 0);
+ height = MIN(height, screen_height - 10);
+ height = MAX(height, 0);
- gdk_window_resize(GTK_WIDGET(window)->window, width, height);
- gtk_widget_queue_resize(GTK_WIDGET(window));
+ gdk_window_resize(GTK_WIDGET(window)->window, width, height);
+ gtk_widget_queue_resize(GTK_WIDGET(window));
}
gboolean
@@ -420,372 +424,372 @@
struct tm *tm,
const char *date_str)
{
- GDate gdate;
+ GDate gdate;
- g_return_val_if_fail (event != NULL, FALSE);
- g_return_val_if_fail (tm != NULL, FALSE);
- g_return_val_if_fail (date_str != NULL, FALSE);
+ g_return_val_if_fail (event != NULL, FALSE);
+ g_return_val_if_fail (tm != NULL, FALSE);
+ g_return_val_if_fail (date_str != NULL, FALSE);
- if (event->type != GDK_KEY_PRESS)
- return FALSE;
+ if (event->type != GDK_KEY_PRESS)
+ return FALSE;
- if ((tm->tm_mday <= 0) || (tm->tm_mon == -1) || (tm->tm_year == -1))
- return FALSE;
+ if ((tm->tm_mday <= 0) || (tm->tm_mon == -1) || (tm->tm_year == -1))
+ return FALSE;
- g_date_set_dmy (&gdate,
- tm->tm_mday,
- tm->tm_mon + 1,
- tm->tm_year + 1900);
+ g_date_set_dmy (&gdate,
+ tm->tm_mday,
+ tm->tm_mon + 1,
+ tm->tm_year + 1900);
- /*
- * Check those keys where the code does different things depending
- * upon the modifiers.
- */
- switch (event->keyval)
- {
+ /*
+ * Check those keys where the code does different things depending
+ * upon the modifiers.
+ */
+ switch (event->keyval)
+ {
case GDK_KP_Add:
case GDK_plus:
case GDK_equal:
- if (event->state & GDK_SHIFT_MASK)
- g_date_add_days (&gdate, 7);
- else if (event->state & GDK_MOD1_MASK)
- g_date_add_months (&gdate, 1);
- else if (event->state & GDK_CONTROL_MASK)
- g_date_add_years (&gdate, 1);
- else
- g_date_add_days (&gdate, 1);
- g_date_to_struct_tm (&gdate, tm);
- return TRUE;
+ if (event->state & GDK_SHIFT_MASK)
+ g_date_add_days (&gdate, 7);
+ else if (event->state & GDK_MOD1_MASK)
+ g_date_add_months (&gdate, 1);
+ else if (event->state & GDK_CONTROL_MASK)
+ g_date_add_years (&gdate, 1);
+ else
+ g_date_add_days (&gdate, 1);
+ g_date_to_struct_tm (&gdate, tm);
+ return TRUE;
case GDK_minus:
case GDK_KP_Subtract:
case GDK_underscore:
- if ((strlen (date_str) != 0) && (dateSeparator () == '-'))
- {
- const char *c;
- gunichar uc;
- int count = 0;
+ if ((strlen (date_str) != 0) && (dateSeparator () == '-'))
+ {
+ const char *c;
+ gunichar uc;
+ int count = 0;
- /* rough check for existing date */
- c = date_str;
- while (*c)
- {
- uc = g_utf8_get_char (c);
- if (uc == '-')
- count++;
- c = g_utf8_next_char (c);
+ /* rough check for existing date */
+ c = date_str;
+ while (*c)
+ {
+ uc = g_utf8_get_char (c);
+ if (uc == '-')
+ count++;
+ c = g_utf8_next_char (c);
+ }
+
+ if (count < 2)
+ return FALSE;
}
- if (count < 2)
- return FALSE;
- }
+ if (event->state & GDK_SHIFT_MASK)
+ g_date_subtract_days (&gdate, 7);
+ else if (event->state & GDK_MOD1_MASK)
+ g_date_subtract_months (&gdate, 1);
+ else if (event->state & GDK_CONTROL_MASK)
+ g_date_subtract_years (&gdate, 1);
+ else
+ g_date_subtract_days (&gdate, 1);
+ g_date_to_struct_tm (&gdate, tm);
+ return TRUE;
- if (event->state & GDK_SHIFT_MASK)
- g_date_subtract_days (&gdate, 7);
- else if (event->state & GDK_MOD1_MASK)
- g_date_subtract_months (&gdate, 1);
- else if (event->state & GDK_CONTROL_MASK)
- g_date_subtract_years (&gdate, 1);
- else
- g_date_subtract_days (&gdate, 1);
- g_date_to_struct_tm (&gdate, tm);
- return TRUE;
-
default:
- break;
- }
+ break;
+ }
- /*
- * Control and Alt key combinations should be ignored by this
- * routine so that the menu system gets to handle them. This
- * prevents weird behavior of the menu accelerators (i.e. work in
- * some widgets but not others.)
- */
- if (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))
- return FALSE;
+ /*
+ * Control and Alt key combinations should be ignored by this
+ * routine so that the menu system gets to handle them. This
+ * prevents weird behavior of the menu accelerators (i.e. work in
+ * some widgets but not others.)
+ */
+ if (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))
+ return FALSE;
- /* Now check for the remaining keystrokes. */
- switch (event->keyval)
- {
+ /* Now check for the remaining keystrokes. */
+ switch (event->keyval)
+ {
case GDK_braceright:
case GDK_bracketright:
- /* increment month */
- g_date_add_months (&gdate, 1);
- break;
+ /* increment month */
+ g_date_add_months (&gdate, 1);
+ break;
case GDK_braceleft:
case GDK_bracketleft:
- /* decrement month */
- g_date_subtract_months (&gdate, 1);
- break;
+ /* decrement month */
+ g_date_subtract_months (&gdate, 1);
+ break;
case GDK_M:
case GDK_m:
- /* beginning of month */
- g_date_set_day (&gdate, 1);
- break;
+ /* beginning of month */
+ g_date_set_day (&gdate, 1);
+ break;
case GDK_H:
case GDK_h:
- /* end of month */
- g_date_set_day (&gdate, 1);
- g_date_add_months (&gdate, 1);
- g_date_subtract_days (&gdate, 1);
- break;
+ /* end of month */
+ g_date_set_day (&gdate, 1);
+ g_date_add_months (&gdate, 1);
+ g_date_subtract_days (&gdate, 1);
+ break;
case GDK_Y:
case GDK_y:
- /* beginning of year */
- g_date_set_day (&gdate, 1);
- g_date_set_month (&gdate, 1);
- break;
+ /* beginning of year */
+ g_date_set_day (&gdate, 1);
+ g_date_set_month (&gdate, 1);
+ break;
case GDK_R:
case GDK_r:
- /* end of year */
- g_date_set_day (&gdate, 1);
- g_date_set_month (&gdate, 1);
- g_date_add_years (&gdate, 1);
- g_date_subtract_days (&gdate, 1);
- break;
+ /* end of year */
+ g_date_set_day (&gdate, 1);
+ g_date_set_month (&gdate, 1);
+ g_date_add_years (&gdate, 1);
+ g_date_subtract_days (&gdate, 1);
+ break;
case GDK_T:
case GDK_t:
- {
+ {
/* today */
GTime gtime;
gtime = time (NULL);
g_date_set_time_t (&gdate, gtime);
break;
- }
+ }
default:
- return FALSE;
- }
+ return FALSE;
+ }
- g_date_to_struct_tm (&gdate, tm);
+ g_date_to_struct_tm (&gdate, tm);
- return TRUE;
+ return TRUE;
}
typedef struct
{
- int row;
- int col;
- gboolean checked;
+ int row;
+ int col;
+ gboolean checked;
} GNCCListCheckNode;
typedef struct
{
- GdkPixmap *on_pixmap;
- GdkPixmap *off_pixmap;
- GdkBitmap *mask;
+ GdkPixmap *on_pixmap;
+ GdkPixmap *off_pixmap;
+ GdkBitmap *mask;
- GList *pending_checks;
+ GList *pending_checks;
} GNCCListCheckInfo;
static void
free_check_list (GList *list)
{
- GList *node;
+ GList *node;
- for (node = list; node; node = node->next)
- g_free (node->data);
+ for (node = list; node; node = node->next)
+ g_free (node->data);
- g_list_free (list);
+ g_list_free (list);
}
static void
check_realize (GtkWidget *widget, gpointer user_data)
{
- GNCCListCheckInfo *check_info = user_data;
- GdkGCValues gc_values;
- GtkCList *clist;
- gint font_height;
- gint check_size;
- GdkColormap *cm;
- GtkStyle *style;
- GList *list;
- GList *node;
- GdkGC *gc;
- PangoLayout *layout;
+ GNCCListCheckInfo *check_info = user_data;
+ GdkGCValues gc_values;
+ GtkCList *clist;
+ gint font_height;
+ gint check_size;
+ GdkColormap *cm;
+ GtkStyle *style;
+ GList *list;
+ GList *node;
+ GdkGC *gc;
+ PangoLayout *layout;
- if (check_info->mask)
- return;
+ if (check_info->mask)
+ return;
- layout = gtk_widget_create_pango_layout(widget, "sample");
- pango_layout_get_pixel_size(layout, NULL, &font_height);
- g_object_unref(layout);
- check_size = (font_height > 0) ? font_height - 6 : 9;
+ layout = gtk_widget_create_pango_layout(widget, "sample");
+ pango_layout_get_pixel_size(layout, NULL, &font_height);
+ g_object_unref(layout);
+ check_size = (font_height > 0) ? font_height - 6 : 9;
- check_info->mask = gdk_pixmap_new (NULL, check_size, check_size, 1);
+ check_info->mask = gdk_pixmap_new (NULL, check_size, check_size, 1);
- check_info->on_pixmap = gdk_pixmap_new (widget->window,
- check_size, check_size, -1);
+ check_info->on_pixmap = gdk_pixmap_new (widget->window,
+ check_size, check_size, -1);
- check_info->off_pixmap = gdk_pixmap_new (widget->window,
- check_size, check_size, -1);
+ check_info->off_pixmap = gdk_pixmap_new (widget->window,
+ check_size, check_size, -1);
- style = gtk_widget_get_style (widget);
- gc_values.foreground = style->white;
- gc = gtk_gc_get (1, gtk_widget_get_colormap (widget),
- &gc_values, GDK_GC_FOREGROUND);
+ style = gtk_widget_get_style (widget);
+ gc_values.foreground = style->white;
+ gc = gtk_gc_get (1, gtk_widget_get_colormap (widget),
+ &gc_values, GDK_GC_FOREGROUND);
- gdk_draw_rectangle (check_info->mask, gc, TRUE,
- 0, 0, check_size, check_size);
+ gdk_draw_rectangle (check_info->mask, gc, TRUE,
+ 0, 0, check_size, check_size);
- gtk_gc_release (gc);
+ gtk_gc_release (gc);
- gc = style->base_gc[GTK_STATE_NORMAL];
+ gc = style->base_gc[GTK_STATE_NORMAL];
- gdk_draw_rectangle (check_info->on_pixmap, gc, TRUE,
- 0, 0, check_size, check_size);
- gdk_draw_rectangle (check_info->off_pixmap, gc, TRUE,
- 0, 0, check_size, check_size);
+ gdk_draw_rectangle (check_info->on_pixmap, gc, TRUE,
+ 0, 0, check_size, check_size);
+ gdk_draw_rectangle (check_info->off_pixmap, gc, TRUE,
+ 0, 0, check_size, check_size);
- cm = gtk_widget_get_colormap (widget);
+ cm = gtk_widget_get_colormap (widget);
- gc_values.foreground.red = 0;
- gc_values.foreground.green = 65535 / 2;
- gc_values.foreground.blue = 0;
+ gc_values.foreground.red = 0;
+ gc_values.foreground.green = 65535 / 2;
+ gc_values.foreground.blue = 0;
- gdk_colormap_alloc_color (cm, &gc_values.foreground, FALSE, TRUE);
+ gdk_colormap_alloc_color (cm, &gc_values.foreground, FALSE, TRUE);
- gc = gdk_gc_new_with_values (widget->window, &gc_values, GDK_GC_FOREGROUND);
+ gc = gdk_gc_new_with_values (widget->window, &gc_values, GDK_GC_FOREGROUND);
- gdk_draw_line (check_info->on_pixmap, gc,
- 1, check_size / 2,
- check_size / 3, check_size - 5);
- gdk_draw_line (check_info->on_pixmap, gc,
- 1, check_size / 2 + 1,
- check_size / 3, check_size - 4);
+ gdk_draw_line (check_info->on_pixmap, gc,
+ 1, check_size / 2,
+ check_size / 3, check_size - 5);
+ gdk_draw_line (check_info->on_pixmap, gc,
+ 1, check_size / 2 + 1,
+ check_size / 3, check_size - 4);
- gdk_draw_line (check_info->on_pixmap, gc,
- check_size / 3, check_size - 5,
- check_size - 3, 2);
- gdk_draw_line (check_info->on_pixmap, gc,
- check_size / 3, check_size - 4,
- check_size - 3, 1);
+ gdk_draw_line (check_info->on_pixmap, gc,
+ check_size / 3, check_size - 5,
+ check_size - 3, 2);
+ gdk_draw_line (check_info->on_pixmap, gc,
+ check_size / 3, check_size - 4,
+ check_size - 3, 1);
- g_object_unref (gc);
+ g_object_unref (gc);
- clist = GTK_CLIST (widget);
+ clist = GTK_CLIST (widget);
- list = check_info->pending_checks;
- check_info->pending_checks = NULL;
+ list = check_info->pending_checks;
+ check_info->pending_checks = NULL;
- /* reverse so we apply in the order of the calls */
- list = g_list_reverse (list);
+ /* reverse so we apply in the order of the calls */
+ list = g_list_reverse (list);
- for (node = list; node; node = node->next)
- {
- GNCCListCheckNode *cl_node = node->data;
+ for (node = list; node; node = node->next)
+ {
+ GNCCListCheckNode *cl_node = node->data;
- gnc_clist_set_check (clist, cl_node->row, cl_node->col, cl_node->checked);
- }
+ gnc_clist_set_check (clist, cl_node->row, cl_node->col, cl_node->checked);
+ }
- free_check_list (list);
+ free_check_list (list);
}
static void
check_unrealize (GtkWidget *widget, gpointer user_data)
{
- GNCCListCheckInfo *check_info = user_data;
+ GNCCListCheckInfo *check_info = user_data;
- if (check_info->mask)
- g_object_unref (check_info->mask);
+ if (check_info->mask)
+ g_object_unref (check_info->mask);
- if (check_info->on_pixmap)
- g_object_unref (check_info->on_pixmap);
+ if (check_info->on_pixmap)
+ g_object_unref (check_info->on_pixmap);
- if (check_info->off_pixmap)
- g_object_unref (check_info->off_pixmap);
+ if (check_info->off_pixmap)
+ g_object_unref (check_info->off_pixmap);
- check_info->mask = NULL;
- check_info->on_pixmap = NULL;
- check_info->off_pixmap = NULL;
+ check_info->mask = NULL;
+ check_info->on_pixmap = NULL;
+ check_info->off_pixmap = NULL;
}
static void
check_destroy (GtkWidget *widget, gpointer user_data)
{
- GNCCListCheckInfo *check_info = user_data;
+ GNCCListCheckInfo *check_info = user_data;
- free_check_list (check_info->pending_checks);
- check_info->pending_checks = NULL;
+ free_check_list (check_info->pending_checks);
+ check_info->pending_checks = NULL;
- g_free (check_info);
+ g_free (check_info);
}
static GNCCListCheckInfo *
gnc_clist_add_check (GtkCList *list)
{
- GNCCListCheckInfo *check_info;
- GObject *object;
+ GNCCListCheckInfo *check_info;
+ GObject *object;
- object = G_OBJECT (list);
+ object = G_OBJECT (list);
- check_info = g_object_get_data (object, "gnc-check-info");
- if (check_info)
- {
- PWARN ("clist already has check");
- return check_info;
- }
+ check_info = g_object_get_data (object, "gnc-check-info");
+ if (check_info)
+ {
+ PWARN ("clist already has check");
+ return check_info;
+ }
- check_info = g_new0 (GNCCListCheckInfo, 1);
+ check_info = g_new0 (GNCCListCheckInfo, 1);
- g_object_set_data (object, "gnc-check-info", check_info);
+ g_object_set_data (object, "gnc-check-info", check_info);
- g_signal_connect (object, "realize",
- G_CALLBACK (check_realize), check_info);
- g_signal_connect (object, "unrealize",
- G_CALLBACK (check_unrealize), check_info);
- g_signal_connect (object, "destroy",
- G_CALLBACK (check_destroy), check_info);
+ g_signal_connect (object, "realize",
+ G_CALLBACK (check_realize), check_info);
+ g_signal_connect (object, "unrealize",
+ G_CALLBACK (check_unrealize), check_info);
+ g_signal_connect (object, "destroy",
+ G_CALLBACK (check_destroy), check_info);
- if (GTK_WIDGET_REALIZED (GTK_WIDGET (list)))
- check_realize (GTK_WIDGET (list), check_info);
+ if (GTK_WIDGET_REALIZED (GTK_WIDGET (list)))
+ check_realize (GTK_WIDGET (list), check_info);
- return check_info;
+ return check_info;
}
void
gnc_clist_set_check (GtkCList *list, int row, int col, gboolean checked)
{
- GNCCListCheckInfo *check_info;
- GdkPixmap *pixmap;
+ GNCCListCheckInfo *check_info;
+ GdkPixmap *pixmap;
- g_return_if_fail (GTK_IS_CLIST (list));
+ g_return_if_fail (GTK_IS_CLIST (list));
- check_info = g_object_get_data (G_OBJECT (list), "gnc-check-info");
- if (!check_info)
- check_info = gnc_clist_add_check (list);
+ check_info = g_object_get_data (G_OBJECT (list), "gnc-check-info");
+ if (!check_info)
+ check_info = gnc_clist_add_check (list);
- if (!GTK_WIDGET_REALIZED (GTK_WIDGET (list)))
- {
- GNCCListCheckNode *node;
+ if (!GTK_WIDGET_REALIZED (GTK_WIDGET (list)))
+ {
+ GNCCListCheckNode *node;
- node = g_new0 (GNCCListCheckNode, 1);
+ node = g_new0 (GNCCListCheckNode, 1);
- node->row = row;
- node->col = col;
- node->checked = checked;
+ node->row = row;
+ node->col = col;
+ node->checked = checked;
- check_info->pending_checks =
- g_list_prepend (check_info->pending_checks, node);
+ check_info->pending_checks =
+ g_list_prepend (check_info->pending_checks, node);
- return;
- }
+ return;
+ }
- pixmap = checked ? check_info->on_pixmap : check_info->off_pixmap;
+ pixmap = checked ? check_info->on_pixmap : check_info->off_pixmap;
- if (checked)
- gtk_clist_set_pixmap (list, row, col, pixmap, check_info->mask);
- else
- gtk_clist_set_text (list, row, col, "");
+ if (checked)
+ gtk_clist_set_pixmap (list, row, col, pixmap, check_info->mask);
+ else
+ gtk_clist_set_text (list, row, col, "");
}
/* Glade Stuff
@@ -802,28 +806,28 @@
GladeXML *
gnc_glade_xml_new (const char *filename, const char *root)
{
- GladeXML *xml;
- char *fname;
- gchar *gnc_glade_dir;
+ GladeXML *xml;
+ char *fname;
+ gchar *gnc_glade_dir;
- g_return_val_if_fail (filename != NULL, NULL);
- g_return_val_if_fail (root != NULL, NULL);
+ g_return_val_if_fail (filename != NULL, NULL);
+ g_return_val_if_fail (root != NULL, NULL);
- if (!glade_inited)
- {
- glade_gnome_init ();
- glade_inited = TRUE;
- }
+ if (!glade_inited)
+ {
+ glade_gnome_init ();
+ glade_inited = TRUE;
+ }
- gnc_glade_dir = gnc_path_get_gladedir ();
- fname = g_build_filename(gnc_glade_dir, filename, (char *)NULL);
- g_free (gnc_glade_dir);
+ gnc_glade_dir = gnc_path_get_gladedir ();
+ fname = g_build_filename(gnc_glade_dir, filename, (char *)NULL);
+ g_free (gnc_glade_dir);
- xml = glade_xml_new (fname, root, NULL);
+ xml = glade_xml_new (fname, root, NULL);
- g_free (fname);
+ g_free (fname);
- return xml;
+ return xml;
}
/* gnc_glade_lookup_widget: Given a root (or at least ancestor) widget,
@@ -832,19 +836,19 @@
GtkWidget *
gnc_glade_lookup_widget (GtkWidget *widget, const char *name)
{
- GladeXML *xml;
- GtkWidget *wid;
+ GladeXML *xml;
+ GtkWidget *wid;
- if (!widget || !name) return NULL;
+ if (!widget || !name) return NULL;
- xml = glade_get_widget_tree (widget);
- if (!xml) return NULL;
+ xml = glade_get_widget_tree (widget);
+ if (!xml) return NULL;
- wid = glade_xml_get_widget (xml, name);
- if (!wid)
- PWARN("I know nothing of this '%s' whom you seek.", name);
+ wid = glade_xml_get_widget (xml, name);
+ if (!wid)
+ PWARN("I know nothing of this '%s' whom you seek.", name);
- return wid;
+ return wid;
}
/*
@@ -854,71 +858,78 @@
void
gnc_glade_autoconnect_full_func(const gchar *handler_name,
- GObject *signal_object,
- const gchar *signal_name,
- const gchar *signal_data,
- GObject *other_object,
- gboolean signal_after,
- gpointer user_data)
+ GObject *signal_object,
+ const gchar *signal_name,
+ const gchar *signal_data,
+ GObject *other_object,
+ gboolean signal_after,
+ gpointer user_data)
{
- GCallback func;
- GCallback *p_func = &func;
+ GCallback func;
+ GCallback *p_func = &func;
- if (allsymbols == NULL) {
- /* get a handle on the main executable -- use this to find symbols */
- allsymbols = g_module_open(NULL, 0);
- }
+ if (allsymbols == NULL)
+ {
+ /* get a handle on the main executable -- use this to find symbols */
+ allsymbols = g_module_open(NULL, 0);
+ }
- if (!g_module_symbol(allsymbols, handler_name, (gpointer *)p_func)) {
+ if (!g_module_symbol(allsymbols, handler_name, (gpointer *)p_func))
+ {
#ifdef HAVE_DLSYM
- /* Fallback to dlsym -- necessary for *BSD linkers */
- func = dlsym(RTLD_DEFAULT, handler_name);
+ /* Fallback to dlsym -- necessary for *BSD linkers */
+ func = dlsym(RTLD_DEFAULT, handler_name);
#else
- func = NULL;
+ func = NULL;
#endif
- if (func == NULL) {
- g_warning("ggaff: could not find signal handler '%s'.", handler_name);
- return;
+ if (func == NULL)
+ {
+ g_warning("ggaff: could not find signal handler '%s'.", handler_name);
+ return;
+ }
}
- }
- if (other_object) {
- if (signal_after)
- g_signal_connect_object (signal_object, signal_name, func,
- other_object, G_CONNECT_AFTER);
+ if (other_object)
+ {
+ if (signal_after)
+ g_signal_connect_object (signal_object, signal_name, func,
+ other_object, G_CONNECT_AFTER);
+ else
+ g_signal_connect_object (signal_object, signal_name, func, other_object, 0);
+ }
else
- g_signal_connect_object (signal_object, signal_name, func, other_object, 0);
- } else {
- if (signal_after)
- g_signal_connect_after(signal_object, signal_name, func, user_data);
- else
- g_signal_connect(signal_object, signal_name, func, user_data);
- }
+ {
+ if (signal_after)
+ g_signal_connect_after(signal_object, signal_name, func, user_data);
+ else
+ g_signal_connect(signal_object, signal_name, func, user_data);
+ }
}
void
gnc_gtk_dialog_add_button (GtkWidget *dialog, const gchar *label, const gchar *stock_id, guint response)
{
- GtkWidget *button;
+ GtkWidget *button;
- button = gtk_button_new_with_mnemonic(label);
- if (stock_id) {
- GtkWidget *image;
+ button = gtk_button_new_with_mnemonic(label);
+ if (stock_id)
+ {
+ GtkWidget *image;
- image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON);
- gtk_button_set_image(GTK_BUTTON(button), image);
- }
- gtk_widget_show_all(button);
- gtk_dialog_add_action_widget(GTK_DIALOG(dialog), button, response);
+ image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON);
+ gtk_button_set_image(GTK_BUTTON(button), image);
+ }
+ gtk_widget_show_all(button);
+ gtk_dialog_add_action_widget(GTK_DIALOG(dialog), button, response);
}
static void
gnc_perm_button_cb (GtkButton *perm, gpointer user_data)
{
- gboolean perm_active;
+ gboolean perm_active;
- perm_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(perm));
- gtk_widget_set_sensitive(user_data, !perm_active);
+ perm_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(perm));
+ gtk_widget_set_sensitive(user_data, !perm_active);
}
gint
@@ -932,29 +943,32 @@
* previous answer. */
response = gnc_gconf_get_int(GCONF_WARNINGS_PERM, gconf_key, NULL);
if (response != 0)
- return response;
+ return response;
response = gnc_gconf_get_int(GCONF_WARNINGS_TEMP, gconf_key, NULL);
if (response != 0)
- return response;
+ return response;
/* Add in the checkboxes to find out if the answer should be remembered. */
#if 0
- if (GTK_IS_MESSAGE_DIALOG(dialog)) {
- GtkMessageType type;
- g_object_get(dialog, "message-type", &type, (gchar*)NULL);
- ask = (type == GTK_MESSAGE_QUESTION);
- } else {
- ask = FALSE;
+ if (GTK_IS_MESSAGE_DIALOG(dialog))
+ {
+ GtkMessageType type;
+ g_object_get(dialog, "message-type", &type, (gchar*)NULL);
+ ask = (type == GTK_MESSAGE_QUESTION);
}
+ else
+ {
+ ask = FALSE;
+ }
#endif
perm = gtk_check_button_new_with_mnemonic
- (ask
- ? _("Remember and don't _ask me again.")
- : _("Don't _tell me again."));
+ (ask
+ ? _("Remember and don't _ask me again.")
+ : _("Don't _tell me again."));
temp = gtk_check_button_new_with_mnemonic
- (ask
- ? _("Remember and don't ask me again this _session.")
- : _("Don't tell me again this _session."));
+ (ask
+ ? _("Remember and don't ask me again this _session.")
+ : _("Don't tell me again this _session."));
gtk_widget_show(perm);
gtk_widget_show(temp);
gtk_box_pack_start_defaults(GTK_BOX(dialog->vbox), perm);
@@ -963,16 +977,20 @@
/* OK. Present the dialog. */
response = gtk_dialog_run(dialog);
- if ((response == GTK_RESPONSE_NONE) || (response == GTK_RESPONSE_DELETE_EVENT)) {
- return GTK_RESPONSE_NO;
+ if ((response == GTK_RESPONSE_NONE) || (response == GTK_RESPONSE_DELETE_EVENT))
+ {
+ return GTK_RESPONSE_NO;
}
/* Save the answer? */
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(perm))) {
- gnc_gconf_set_int(GCONF_WARNINGS_PERM, gconf_key, response, NULL);
- } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(temp))) {
- gnc_gconf_set_int(GCONF_WARNINGS_TEMP, gconf_key, response, NULL);
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(perm)))
+ {
+ gnc_gconf_set_int(GCONF_WARNINGS_PERM, gconf_key, response, NULL);
}
+ else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(temp)))
+ {
+ gnc_gconf_set_int(GCONF_WARNINGS_TEMP, gconf_key, response, NULL);
+ }
return response;
}
Modified: gnucash/trunk/src/gnome-utils/dialog-utils.h
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-utils.h 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/dialog-utils.h 2010-03-02 21:42:11 UTC (rev 18791)
@@ -43,17 +43,17 @@
typedef struct _GNCOptionInfo GNCOptionInfo;
struct _GNCOptionInfo
{
- char *name;
- char *tip;
- GNCOptionCallback callback;
- gpointer user_data;
+ char *name;
+ char *tip;
+ GNCOptionCallback callback;
+ gpointer user_data;
};
/**** PROTOTYPES *************************************************/
GtkWidget * gnc_build_option_menu (GNCOptionInfo *option_info,
- gint num_options);
+ gint num_options);
GtkToolbarStyle gnc_get_toolbar_style (void);
@@ -86,8 +86,8 @@
void gnc_option_menu_init (GtkWidget * option_menu);
void gnc_option_menu_init_w_signal(GtkWidget * w,
- GCallback f,
- gpointer cb_data);
+ GCallback f,
+ gpointer cb_data);
int gnc_option_menu_get_active (GtkWidget * option_menu);
/********************************************************************\
@@ -114,19 +114,19 @@
* after you have built the list. This only applies to unrealized
* widgets. */
#ifdef __GTK_CLIST_H__
-void gnc_clist_set_check (GtkCList *list, int row, int col,
- gboolean checked);
+void gnc_clist_set_check (GtkCList *list, int row, int col,
+ gboolean checked);
#endif
GladeXML * gnc_glade_xml_new (const char *filename, const char *root);
GtkWidget * gnc_glade_lookup_widget (GtkWidget *widget, const char *name);
void gnc_glade_autoconnect_full_func(const gchar *handler_name,
- GObject *signal_object,
- const gchar *signal_name,
- const gchar *signal_data,
- GObject *connect_object,
- gboolean after,
- gpointer user_data);
+ GObject *signal_object,
+ const gchar *signal_name,
+ const gchar *signal_data,
+ GObject *connect_object,
+ gboolean after,
+ gpointer user_data);
/** This function generates a button with icon and adds it to a
* GtkDialog. This is similar to just adding a stock button to the
@@ -136,15 +136,15 @@
* @param dialog The dialog where the button should be added.
*
* @param label The text of the button.
- *
+ *
* @param stock_id The name of the stock button to use.
*
* @param response The response id to return if this button is
* clicked.*/
void gnc_gtk_dialog_add_button (GtkWidget *dialog,
- const gchar *label,
- const gchar *stock_id,
- guint response);
+ const gchar *label,
+ const gchar *stock_id,
+ guint response);
/** Note: This dialog is modal! (It calls gtk_dialog_run() which is modal.)
Modified: gnucash/trunk/src/gnome-utils/druid-gconf-setup.c
===================================================================
--- gnucash/trunk/src/gnome-utils/druid-gconf-setup.c 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/druid-gconf-setup.c 2010-03-02 21:42:11 UTC (rev 18791)
@@ -110,66 +110,72 @@
static gboolean
druid_gconf_update_path (GError **error)
{
- gchar *path_filename, *data_filename;
- gchar *contents, **lines, *line;
- gboolean found_user_dir = FALSE;
- FILE *output;
- gchar *gconfdir;
+ gchar *path_filename, *data_filename;
+ gchar *contents, **lines, *line;
+ gboolean found_user_dir = FALSE;
+ FILE *output;
+ gchar *gconfdir;
- data_filename = g_build_filename(g_get_home_dir(), ".gconf", (char *)NULL);
- path_filename = g_build_filename(g_get_home_dir(), ".gconf.path", (char *)NULL);
- if (g_file_test(path_filename, G_FILE_TEST_EXISTS)) {
- if (!g_file_get_contents(path_filename, &contents, NULL, error)) {
- g_free(path_filename);
- g_free(data_filename);
- return FALSE;
+ data_filename = g_build_filename(g_get_home_dir(), ".gconf", (char *)NULL);
+ path_filename = g_build_filename(g_get_home_dir(), ".gconf.path", (char *)NULL);
+ if (g_file_test(path_filename, G_FILE_TEST_EXISTS))
+ {
+ if (!g_file_get_contents(path_filename, &contents, NULL, error))
+ {
+ g_free(path_filename);
+ g_free(data_filename);
+ return FALSE;
+ }
+
+ lines = g_strsplit_set(contents, "\r\n", -1);
+ for (line = *lines; line; line++)
+ {
+ if (line[0] == '#')
+ continue;
+ if ((strstr(line, "$(HOME)/.gconf") == 0) ||
+ (strstr(line, "~/.gconf") == 0) ||
+ (strstr(line, data_filename)))
+ {
+ found_user_dir = TRUE;
+ break;
+ }
+ }
+ g_strfreev(lines);
}
-
- lines = g_strsplit_set(contents, "\r\n", -1);
- for (line = *lines; line; line++) {
- if (line[0] == '#')
- continue;
- if ((strstr(line, "$(HOME)/.gconf") == 0) ||
- (strstr(line, "~/.gconf") == 0) ||
- (strstr(line, data_filename))) {
- found_user_dir = TRUE;
- break;
- }
+
+ output = g_fopen(path_filename, "a");
+ if (output == NULL)
+ {
+ *error = g_error_new (G_FILE_ERROR,
+ g_file_error_from_errno(errno),
+ "Error opening file %s for writing.",
+ path_filename);
+ g_free(path_filename);
+ g_free(data_filename);
+ return FALSE;
}
- g_strfreev(lines);
- }
- output = g_fopen(path_filename, "a");
- if (output == NULL) {
- *error = g_error_new (G_FILE_ERROR,
- g_file_error_from_errno(errno),
- "Error opening file %s for writing.",
- path_filename);
- g_free(path_filename);
- g_free(data_filename);
- return FALSE;
- }
+ fprintf(output, "\n######## The following lines were added by GnuCash. ########\n");
+ if (!found_user_dir)
+ fprintf(output, PATH_STRING1);
+ gconfdir = gnc_path_get_gconfdir (TRUE);
+ fprintf(output, PATH_STRING2, gconfdir);
+ g_free (gconfdir);
+ fprintf(output, "############## End of lines added by GnuCash. ##############\n");
+ if (fclose(output) != 0)
+ {
+ *error = g_error_new (G_FILE_ERROR,
+ g_file_error_from_errno(errno),
+ "Error closing file %s.",
+ path_filename);
+ g_free(path_filename);
+ g_free(data_filename);
+ return FALSE;
+ }
- fprintf(output, "\n######## The following lines were added by GnuCash. ########\n");
- if (!found_user_dir)
- fprintf(output, PATH_STRING1);
- gconfdir = gnc_path_get_gconfdir (TRUE);
- fprintf(output, PATH_STRING2, gconfdir);
- g_free (gconfdir);
- fprintf(output, "############## End of lines added by GnuCash. ##############\n");
- if (fclose(output) != 0) {
- *error = g_error_new (G_FILE_ERROR,
- g_file_error_from_errno(errno),
- "Error closing file %s.",
- path_filename);
g_free(path_filename);
g_free(data_filename);
- return FALSE;
- }
-
- g_free(path_filename);
- g_free(data_filename);
- return TRUE;
+ return TRUE;
}
@@ -190,7 +196,7 @@
static gboolean
druid_gconf_install_keys (GError **error)
{
- return g_spawn_command_line_sync(SCRIPT_NAME, NULL, NULL, NULL, error);
+ return g_spawn_command_line_sync(SCRIPT_NAME, NULL, NULL, NULL, error);
}
/********************
@@ -204,11 +210,11 @@
*/
gboolean
druid_gconf_delete_event (GtkWidget *window,
- GdkEvent *event,
- gpointer user_data)
+ GdkEvent *event,
+ gpointer user_data)
{
- gtk_widget_destroy(GTK_WIDGET(window));
- exit(40);
+ gtk_widget_destroy(GTK_WIDGET(window));
+ exit(40);
}
@@ -217,13 +223,13 @@
*/
void
druid_gconf_cancel (GnomeDruid *druid,
- gpointer user_data)
+ gpointer user_data)
{
- GtkWidget *window;
+ GtkWidget *window;
- window = gnc_glade_lookup_widget(GTK_WIDGET(druid), "GConf Install Druid");
- gtk_widget_destroy(GTK_WIDGET(window));
- exit(41);
+ window = gnc_glade_lookup_widget(GTK_WIDGET(druid), "GConf Install Druid");
+ gtk_widget_destroy(GTK_WIDGET(window));
+ exit(41);
}
@@ -238,8 +244,8 @@
*/
void
druid_gconf_choose_page_prepare (GnomeDruidPage *druidpage,
- GnomeDruid *druid,
- gpointer user_data)
+ GnomeDruid *druid,
+ gpointer user_data)
{
}
@@ -251,22 +257,25 @@
*/
gboolean
druid_gconf_choose_page_next (GnomeDruidPage *druidpage,
- GnomeDruid *druid,
- gpointer user_data)
+ GnomeDruid *druid,
+ gpointer user_data)
{
- GtkWidget *page, *button;
+ GtkWidget *page, *button;
- button = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "update_path");
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) {
- page = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "update_page");
- g_object_set_data(G_OBJECT(druid), HOW, GINT_TO_POINTER(HOW_UPDATE));
- } else {
- page = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "install_page");
- g_object_set_data(G_OBJECT(druid), HOW, GINT_TO_POINTER(HOW_INSTALL));
- }
+ button = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "update_path");
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)))
+ {
+ page = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "update_page");
+ g_object_set_data(G_OBJECT(druid), HOW, GINT_TO_POINTER(HOW_UPDATE));
+ }
+ else
+ {
+ page = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "install_page");
+ g_object_set_data(G_OBJECT(druid), HOW, GINT_TO_POINTER(HOW_INSTALL));
+ }
- gnome_druid_set_page(druid, GNOME_DRUID_PAGE(page));
- return TRUE;
+ gnome_druid_set_page(druid, GNOME_DRUID_PAGE(page));
+ return TRUE;
}
@@ -282,19 +291,19 @@
*/
void
druid_gconf_update_page_prepare (GnomeDruidPage *druidpage,
- GnomeDruid *druid,
- gpointer user_data)
+ GnomeDruid *druid,
+ gpointer user_data)
{
- GtkTextBuffer *textbuffer;
- GtkWidget *textview;
- gchar *msg;
- gchar *gconfdir = gnc_path_get_gconfdir (TRUE);
+ GtkTextBuffer *textbuffer;
+ GtkWidget *textview;
+ gchar *msg;
+ gchar *gconfdir = gnc_path_get_gconfdir (TRUE);
- textview = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "update_text");
- textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
- msg = g_strdup_printf(PATH_STRING1 PATH_STRING2, gconfdir);
- gtk_text_buffer_set_text(textbuffer, msg, -1);
- g_free (gconfdir);
+ textview = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "update_text");
+ textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
+ msg = g_strdup_printf(PATH_STRING1 PATH_STRING2, gconfdir);
+ gtk_text_buffer_set_text(textbuffer, msg, -1);
+ g_free (gconfdir);
}
@@ -304,24 +313,29 @@
*/
gboolean
druid_gconf_update_page_next (GnomeDruidPage *druidpage,
- GnomeDruid *druid,
- gpointer user_data)
+ GnomeDruid *druid,
+ gpointer user_data)
{
- GtkWidget *page, *button1, *button2;
+ GtkWidget *page, *button1, *button2;
- button1 = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "program1");
- button2 = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "user1");
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button1))) {
- g_object_set_data(G_OBJECT(druid), WHO_DOES, GINT_TO_POINTER(WHO_GNUCASH));
- } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button2))) {
- g_object_set_data(G_OBJECT(druid), WHO_DOES, GINT_TO_POINTER(WHO_USER));
- } else {
- g_object_set_data(G_OBJECT(druid), WHO_DOES, GINT_TO_POINTER(WHO_ALREADY_DONE));
- }
+ button1 = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "program1");
+ button2 = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "user1");
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button1)))
+ {
+ g_object_set_data(G_OBJECT(druid), WHO_DOES, GINT_TO_POINTER(WHO_GNUCASH));
+ }
+ else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button2)))
+ {
+ g_object_set_data(G_OBJECT(druid), WHO_DOES, GINT_TO_POINTER(WHO_USER));
+ }
+ else
+ {
+ g_object_set_data(G_OBJECT(druid), WHO_DOES, GINT_TO_POINTER(WHO_ALREADY_DONE));
+ }
- page = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "finish_page");
- gnome_druid_set_page(druid, GNOME_DRUID_PAGE(page));
- return TRUE;
+ page = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "finish_page");
+ gnome_druid_set_page(druid, GNOME_DRUID_PAGE(page));
+ return TRUE;
}
/********************
@@ -334,15 +348,15 @@
*/
void
druid_gconf_install_page_prepare (GnomeDruidPage *druidpage,
- GnomeDruid *druid,
- gpointer user_data)
+ GnomeDruid *druid,
+ gpointer user_data)
{
- GtkTextBuffer *textbuffer;
- GtkWidget *textview;
+ GtkTextBuffer *textbuffer;
+ GtkWidget *textview;
- textview = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "install_text");
- textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
- gtk_text_buffer_set_text(textbuffer, SCRIPT_NAME, -1);
+ textview = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "install_text");
+ textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
+ gtk_text_buffer_set_text(textbuffer, SCRIPT_NAME, -1);
}
@@ -352,24 +366,29 @@
*/
gboolean
druid_gconf_install_page_next (GnomeDruidPage *druidpage,
- GnomeDruid *druid,
- gpointer user_data)
+ GnomeDruid *druid,
+ gpointer user_data)
{
- GtkWidget *page, *button1, *button2;
+ GtkWidget *page, *button1, *button2;
- button1 = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "program2");
- button2 = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "user2");
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button1))) {
- g_object_set_data(G_OBJECT(druid), WHO_DOES, GINT_TO_POINTER(WHO_GNUCASH));
- } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button2))) {
- g_object_set_data(G_OBJECT(druid), WHO_DOES, GINT_TO_POINTER(WHO_USER));
- } else {
- g_object_set_data(G_OBJECT(druid), WHO_DOES, GINT_TO_POINTER(WHO_ALREADY_DONE));
- }
+ button1 = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "program2");
+ button2 = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "user2");
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button1)))
+ {
+ g_object_set_data(G_OBJECT(druid), WHO_DOES, GINT_TO_POINTER(WHO_GNUCASH));
+ }
+ else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button2)))
+ {
+ g_object_set_data(G_OBJECT(druid), WHO_DOES, GINT_TO_POINTER(WHO_USER));
+ }
+ else
+ {
+ g_object_set_data(G_OBJECT(druid), WHO_DOES, GINT_TO_POINTER(WHO_ALREADY_DONE));
+ }
- page = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "finish_page");
- gnome_druid_set_page(druid, GNOME_DRUID_PAGE(page));
- return TRUE;
+ page = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "finish_page");
+ gnome_druid_set_page(druid, GNOME_DRUID_PAGE(page));
+ return TRUE;
}
@@ -378,14 +397,14 @@
*/
gboolean
druid_gconf_install_page_back (GnomeDruidPage *druidpage,
- GnomeDruid *druid,
- gpointer user_data)
+ GnomeDruid *druid,
+ gpointer user_data)
{
- GtkWidget *page;
+ GtkWidget *page;
- page = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "choose_page");
- gnome_druid_set_page(druid, GNOME_DRUID_PAGE(page));
- return TRUE;
+ page = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "choose_page");
+ gnome_druid_set_page(druid, GNOME_DRUID_PAGE(page));
+ return TRUE;
}
@@ -400,64 +419,71 @@
*/
void
druid_gconf_finish_page_prepare (GnomeDruidPage *druidpage,
- GnomeDruid *druid,
- gpointer user_data)
+ GnomeDruid *druid,
+ gpointer user_data)
{
- gint who, how;
- gchar *text;
- const gchar *pgm_path =
- _("When you click Apply, GnuCash will modify your ~/.gconf.path file "
- "and restart the gconf backend.");
- const gchar *pgm_install =
- _("When you click Apply, GnuCash will install the gconf data into your "
- "local ~/.gconf file and restart the gconf backend. The %s script "
- "must be found in your search path for this to work correctly.");
- const gchar *user_path =
- _("You have chosen to correct the problem by yourself. When you click "
- "Apply, GnuCash will exit. Please correct the problem and restart "
- "the gconf backend with the command 'gconftool-2 --shutdown' before "
- "restarting GnuCash. If you have not already done so, you can click "
- "the Back button and copy the necessary text from the dialog.");
- const gchar *user_install =
- _("You have chosen to correct the problem by yourself. When you "
- "click Apply, GnuCash will exit. Please run the %s script which "
- "will install the configuration data and restart the gconf backend.");
- const gchar *user_did =
- _("You have already corrected the problem and restarted the gconf "
- "backend with the command 'gconftool-2 --shutdown'. When you click "
- "Apply, GnuCash will continue loading.");
+ gint who, how;
+ gchar *text;
+ const gchar *pgm_path =
+ _("When you click Apply, GnuCash will modify your ~/.gconf.path file "
+ "and restart the gconf backend.");
+ const gchar *pgm_install =
+ _("When you click Apply, GnuCash will install the gconf data into your "
+ "local ~/.gconf file and restart the gconf backend. The %s script "
+ "must be found in your search path for this to work correctly.");
+ const gchar *user_path =
+ _("You have chosen to correct the problem by yourself. When you click "
+ "Apply, GnuCash will exit. Please correct the problem and restart "
+ "the gconf backend with the command 'gconftool-2 --shutdown' before "
+ "restarting GnuCash. If you have not already done so, you can click "
+ "the Back button and copy the necessary text from the dialog.");
+ const gchar *user_install =
+ _("You have chosen to correct the problem by yourself. When you "
+ "click Apply, GnuCash will exit. Please run the %s script which "
+ "will install the configuration data and restart the gconf backend.");
+ const gchar *user_did =
+ _("You have already corrected the problem and restarted the gconf "
+ "backend with the command 'gconftool-2 --shutdown'. When you click "
+ "Apply, GnuCash will continue loading.");
- who = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(druid), WHO_DOES));
- switch (who) {
+ who = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(druid), WHO_DOES));
+ switch (who)
+ {
case WHO_ALREADY_DONE:
- gnome_druid_page_edge_set_text(GNOME_DRUID_PAGE_EDGE(druidpage),
- user_did);
- break;
+ gnome_druid_page_edge_set_text(GNOME_DRUID_PAGE_EDGE(druidpage),
+ user_did);
+ break;
case WHO_USER:
- how = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(druid), HOW));
- if (how == HOW_INSTALL) {
- text = g_strdup_printf(user_install, SCRIPT_NAME);
- gnome_druid_page_edge_set_text(GNOME_DRUID_PAGE_EDGE(druidpage), text);
- g_free(text);
- } else {
- gnome_druid_page_edge_set_text(GNOME_DRUID_PAGE_EDGE(druidpage),
- user_path);
- }
- break;
+ how = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(druid), HOW));
+ if (how == HOW_INSTALL)
+ {
+ text = g_strdup_printf(user_install, SCRIPT_NAME);
+ gnome_druid_page_edge_set_text(GNOME_DRUID_PAGE_EDGE(druidpage), text);
+ g_free(text);
+ }
+ else
+ {
+ gnome_druid_page_edge_set_text(GNOME_DRUID_PAGE_EDGE(druidpage),
+ user_path);
+ }
+ break;
default:
- how = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(druid), HOW));
- if (how == HOW_INSTALL) {
- text = g_strdup_printf(pgm_install, SCRIPT_NAME);
- gnome_druid_page_edge_set_text(GNOME_DRUID_PAGE_EDGE(druidpage), text);
- g_free(text);
- } else {
- gnome_druid_page_edge_set_text(GNOME_DRUID_PAGE_EDGE(druidpage),
- pgm_path);
- }
- break;
- }
+ how = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(druid), HOW));
+ if (how == HOW_INSTALL)
+ {
+ text = g_strdup_printf(pgm_install, SCRIPT_NAME);
+ gnome_druid_page_edge_set_text(GNOME_DRUID_PAGE_EDGE(druidpage), text);
+ g_free(text);
+ }
+ else
+ {
+ gnome_druid_page_edge_set_text(GNOME_DRUID_PAGE_EDGE(druidpage),
+ pgm_path);
+ }
+ break;
+ }
}
@@ -467,10 +493,10 @@
*/
gboolean
druid_gconf_finish_page_back (GnomeDruidPage *druidpage,
- GnomeDruid *druid,
- gpointer user_data)
+ GnomeDruid *druid,
+ gpointer user_data)
{
- return druid_gconf_choose_page_next(druidpage, druid, user_data);
+ return druid_gconf_choose_page_next(druidpage, druid, user_data);
}
@@ -481,53 +507,60 @@
*/
void
druid_gconf_finish_page_finish (GnomeDruidPage *druidpage,
- GnomeDruid *druid,
- gpointer user_data)
+ GnomeDruid *druid,
+ gpointer user_data)
{
- GtkWidget *window;
- gint value, value2;
- GError *error = NULL;
- gboolean keep_going = TRUE;
+ GtkWidget *window;
+ gint value, value2;
+ GError *error = NULL;
+ gboolean keep_going = TRUE;
- /* What to do... what to do... */
- value = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(druid), WHO_DOES));
- switch (value) {
+ /* What to do... what to do... */
+ value = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(druid), WHO_DOES));
+ switch (value)
+ {
case WHO_ALREADY_DONE:
- break;
+ break;
case WHO_USER:
- keep_going = FALSE;
- break;
+ keep_going = FALSE;
+ break;
default:
- value2 = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(druid), HOW));
- switch(value2) {
- case HOW_INSTALL:
- if (!druid_gconf_install_keys(&error)) {
- keep_going = FALSE;
- gnc_error_dialog(NULL, "%s", error->message);
- g_error_free(error);
- }
- break;
+ value2 = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(druid), HOW));
+ switch (value2)
+ {
+ case HOW_INSTALL:
+ if (!druid_gconf_install_keys(&error))
+ {
+ keep_going = FALSE;
+ gnc_error_dialog(NULL, "%s", error->message);
+ g_error_free(error);
+ }
+ break;
- default:
- if (!druid_gconf_update_path(&error)) {
- keep_going = FALSE;
- gnc_error_dialog(NULL, "%s", error->message);
- g_error_free(error);
- }
- break;
- }
- break;
- }
+ default:
+ if (!druid_gconf_update_path(&error))
+ {
+ keep_going = FALSE;
+ gnc_error_dialog(NULL, "%s", error->message);
+ g_error_free(error);
+ }
+ break;
+ }
+ break;
+ }
- window = gnc_glade_lookup_widget(GTK_WIDGET(druid), "GConf Install Druid");
- gtk_widget_destroy(GTK_WIDGET(window));
- if (keep_going) {
- gtk_main_quit();
- } else {
- exit(42);
- }
+ window = gnc_glade_lookup_widget(GTK_WIDGET(druid), "GConf Install Druid");
+ gtk_widget_destroy(GTK_WIDGET(window));
+ if (keep_going)
+ {
+ gtk_main_quit();
+ }
+ else
+ {
+ exit(42);
+ }
}
@@ -538,26 +571,28 @@
static void
druid_gconf_fix_textview_color (GtkWidget *window)
{
- GdkColor *color;
- GtkWidget *widget;
- gint i;
- const gchar *names[] = {
- "textview1",
- "textview2",
- "textview3",
- "textview4",
- "textview5",
- "textview6",
- NULL
- };
+ GdkColor *color;
+ GtkWidget *widget;
+ gint i;
+ const gchar *names[] =
+ {
+ "textview1",
+ "textview2",
+ "textview3",
+ "textview4",
+ "textview5",
+ "textview6",
+ NULL
+ };
- widget = gnc_glade_lookup_widget(window, "choose_page");
- color = &GNOME_DRUID_PAGE_STANDARD(widget)->contents_background;
+ widget = gnc_glade_lookup_widget(window, "choose_page");
+ color = &GNOME_DRUID_PAGE_STANDARD(widget)->contents_background;
- for (i = 0; names[i]; i++) {
- widget = gnc_glade_lookup_widget(widget, names[i]);
- gtk_widget_modify_base(widget, GTK_STATE_INSENSITIVE, color);
- }
+ for (i = 0; names[i]; i++)
+ {
+ widget = gnc_glade_lookup_widget(widget, names[i]);
+ gtk_widget_modify_base(widget, GTK_STATE_INSENSITIVE, color);
+ }
}
/** This function build and presents the druid that presents the user
@@ -571,25 +606,26 @@
static void
gnc_gnome_install_gconf_schemas (void)
{
- GladeXML *xml;
- GtkWidget *window;
- GError *error = NULL;
+ GladeXML *xml;
+ GtkWidget *window;
+ GError *error = NULL;
- xml = gnc_glade_xml_new ("druid-gconf-setup.glade", "GConf Install Druid");
- glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func, NULL);
- window = glade_xml_get_widget (xml, "GConf Install Druid");
- druid_gconf_fix_textview_color(window);
- gtk_widget_show_all(window);
+ xml = gnc_glade_xml_new ("druid-gconf-setup.glade", "GConf Install Druid");
+ glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func, NULL);
+ window = glade_xml_get_widget (xml, "GConf Install Druid");
+ druid_gconf_fix_textview_color(window);
+ gtk_widget_show_all(window);
- /* This won't return until the dialog is finished */
- gtk_main();
+ /* This won't return until the dialog is finished */
+ gtk_main();
- /* Kill the backend daemon. When it restarts it will find our changes */
- if (!g_spawn_command_line_sync("gconftool-2 --shutdown", NULL, NULL,
- NULL, &error)) {
- gnc_warning_dialog(NULL, "%s", error->message);
- g_error_free(error);
- }
+ /* Kill the backend daemon. When it restarts it will find our changes */
+ if (!g_spawn_command_line_sync("gconftool-2 --shutdown", NULL, NULL,
+ NULL, &error))
+ {
+ gnc_warning_dialog(NULL, "%s", error->message);
+ g_error_free(error);
+ }
}
@@ -605,64 +641,72 @@
void
druid_gconf_install_check_schemas (void)
{
- GladeXML *xml;
- GtkWidget *dialog;
- gboolean done = FALSE;
- gint response;
+ GladeXML *xml;
+ GtkWidget *dialog;
+ gboolean done = FALSE;
+ gint response;
- if (gnc_gconf_schemas_found()) {
- gnc_gconf_unset_dir(GCONF_WARNINGS_TEMP, NULL);
- return;
- }
+ if (gnc_gconf_schemas_found())
+ {
+ gnc_gconf_unset_dir(GCONF_WARNINGS_TEMP, NULL);
+ return;
+ }
#ifdef G_OS_WIN32
- {
- /* automatically update the search path on windows */
- GError *error = NULL;
- if (!druid_gconf_update_path (&error)) {
- gnc_error_dialog (NULL, error->message);
- g_error_free (error);
- exit(42);
- } else {
- if (!g_spawn_command_line_sync("gconftool-2 --shutdown", NULL, NULL,
- NULL, &error)) {
- gnc_warning_dialog(NULL, error->message);
- g_error_free(error);
- }
- return;
+ {
+ /* automatically update the search path on windows */
+ GError *error = NULL;
+ if (!druid_gconf_update_path (&error))
+ {
+ gnc_error_dialog (NULL, error->message);
+ g_error_free (error);
+ exit(42);
+ }
+ else
+ {
+ if (!g_spawn_command_line_sync("gconftool-2 --shutdown", NULL, NULL,
+ NULL, &error))
+ {
+ gnc_warning_dialog(NULL, error->message);
+ g_error_free(error);
+ }
+ return;
+ }
}
- }
#endif /* G_OS_WIN32 */
- xml = gnc_glade_xml_new ("druid-gconf-setup.glade", "GConf Query");
- dialog = glade_xml_get_widget (xml, "GConf Query");
- do {
- response = gtk_dialog_run(GTK_DIALOG(dialog));
+ xml = gnc_glade_xml_new ("druid-gconf-setup.glade", "GConf Query");
+ dialog = glade_xml_get_widget (xml, "GConf Query");
+ do
+ {
+ response = gtk_dialog_run(GTK_DIALOG(dialog));
- switch (response) {
- case GTK_RESPONSE_CANCEL:
- default:
- gnc_shutdown(42);
- /* never returns */
+ switch (response)
+ {
+ case GTK_RESPONSE_CANCEL:
+ default:
+ gnc_shutdown(42);
+ /* never returns */
- case GTK_RESPONSE_NO:
- /* User wants to run without setting up gconf */
- done = TRUE;
- break;
+ case GTK_RESPONSE_NO:
+ /* User wants to run without setting up gconf */
+ done = TRUE;
+ break;
- case GTK_RESPONSE_ACCEPT:
- gtk_widget_hide(dialog);
- gnc_gnome_install_gconf_schemas();
- done = TRUE;
- break;
+ case GTK_RESPONSE_ACCEPT:
+ gtk_widget_hide(dialog);
+ gnc_gnome_install_gconf_schemas();
+ done = TRUE;
+ break;
- case GTK_RESPONSE_HELP:
- gnc_gnome_help(HF_HELP, HL_GCONF);
- break;
+ case GTK_RESPONSE_HELP:
+ gnc_gnome_help(HF_HELP, HL_GCONF);
+ break;
+ }
}
- } while (!done);
+ while (!done);
- gtk_widget_destroy(dialog);
+ gtk_widget_destroy(dialog);
}
/** @} */
Modified: gnucash/trunk/src/gnome-utils/druid-gnc-xml-import.c
===================================================================
--- gnucash/trunk/src/gnome-utils/druid-gnc-xml-import.c 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/druid-gnc-xml-import.c 2010-03-02 21:42:11 UTC (rev 18791)
@@ -50,91 +50,98 @@
* - as pointer, containing above gquark, used in lists
*/
-typedef enum {
- XML_CONVERT_SINGLE_FILE,
- XML_MERGE_FILES
+typedef enum
+{
+ XML_CONVERT_SINGLE_FILE,
+ XML_MERGE_FILES
} GncXmlImportType;
-typedef struct {
- GncXmlImportType import_type;
+typedef struct
+{
+ GncXmlImportType import_type;
- GtkWidget *dialog; /* global window */
- GtkWidget *druid; /* druid */
- GtkWidget *file_chooser; /* file chooser widget on load file page */
- GtkWidget *default_encoding_combo; /* top combo on conversion page */
- GtkWidget *summary_label; /* label on conversion page */
- GtkWidget *string_box; /* vbox of combos on conversion page */
- GtkWidget *encodings_dialog; /* dialog for selection of encodings */
- GtkTreeView *available_encs_view; /* list view of standard encodings */
- GtkTreeView *selected_encs_view; /* list view of selected encodings */
- GtkListStore *file_list_store; /* list store for loaded files */
- GtkTreeView *file_list_view; /* list view for loaded files */
+ GtkWidget *dialog; /* global window */
+ GtkWidget *druid; /* druid */
+ GtkWidget *file_chooser; /* file chooser widget on load file page */
+ GtkWidget *default_encoding_combo; /* top combo on conversion page */
+ GtkWidget *summary_label; /* label on conversion page */
+ GtkWidget *string_box; /* vbox of combos on conversion page */
+ GtkWidget *encodings_dialog; /* dialog for selection of encodings */
+ GtkTreeView *available_encs_view; /* list view of standard encodings */
+ GtkTreeView *selected_encs_view; /* list view of selected encodings */
+ GtkListStore *file_list_store; /* list store for loaded files */
+ GtkTreeView *file_list_view; /* list view for loaded files */
- GList *files; /* list of loaded files */
+ GList *files; /* list of loaded files */
- GList *encodings; /* list of GQuarks for encodings */
- GQuark default_encoding; /* default GQuark, may be zero */
+ GList *encodings; /* list of GQuarks for encodings */
+ GQuark default_encoding; /* default GQuark, may be zero */
- /* hash table that maps byte sequences to conversions, i.e. in the current
- encodings setting, there is only one possible conversion */
- GHashTable *unique;
+ /* hash table that maps byte sequences to conversions, i.e. in the current
+ encodings setting, there is only one possible conversion */
+ GHashTable *unique;
- /* hash table that maps byte sequences to a list of conversions, i.e. in the
- current encodings setting, there exactly these conversions are possible */
- GHashTable *ambiguous_ht;
+ /* hash table that maps byte sequences to a list of conversions, i.e. in the
+ current encodings setting, there exactly these conversions are possible */
+ GHashTable *ambiguous_ht;
- /* sorted list of ambiguous words, used for the construction of the combos */
- GList *ambiguous_list;
+ /* sorted list of ambiguous words, used for the construction of the combos */
+ GList *ambiguous_list;
- /* hash table that maps byte sequences to conversions. these reflect the
- choices the user made, accumulated and updated in the whole conversion.
- Note: this may contain conversions that are not available in the current
- encodings setting, just imagine, user accidentally removed an important
- encoding from the list */
- GHashTable *choices;
+ /* hash table that maps byte sequences to conversions. these reflect the
+ choices the user made, accumulated and updated in the whole conversion.
+ Note: this may contain conversions that are not available in the current
+ encodings setting, just imagine, user accidentally removed an important
+ encoding from the list */
+ GHashTable *choices;
- /* number of byte sequences that have multiple possible conversions, but not in
- the default encoding. and the user has not decided yet, of course. */
- gint n_unassigned;
+ /* number of byte sequences that have multiple possible conversions, but not in
+ the default encoding. and the user has not decided yet, of course. */
+ gint n_unassigned;
- /* number of byte sequences without any reasonable interpretation */
- gint n_impossible;
+ /* number of byte sequences without any reasonable interpretation */
+ gint n_impossible;
- /* hash table that maps byte sequences to other byte sequences to be replaced
- by them. */
- GHashTable *subst;
+ /* hash table that maps byte sequences to other byte sequences to be replaced
+ by them. */
+ GHashTable *subst;
- gchar *filename;
- QofSession *session;
+ gchar *filename;
+ QofSession *session;
} GncXmlImportData;
-typedef struct {
- gchar *filename;
- GtkTreeIter *file_list_iter;
+typedef struct
+{
+ gchar *filename;
+ GtkTreeIter *file_list_iter;
} GncXmlImportFile;
/* used for the string combos, see ambiguous_free */
-typedef struct {
- gchar *byte_sequence;
- GList *conv_list;
+typedef struct
+{
+ gchar *byte_sequence;
+ GList *conv_list;
} ambiguous_type;
-enum {
- FILE_COL_NAME = 0,
- FILE_COL_INFO,
- FILE_NUM_COLS
+enum
+{
+ FILE_COL_NAME = 0,
+ FILE_COL_INFO,
+ FILE_NUM_COLS
};
-enum {
- WORD_COL_STRING = 0,
- WORD_COL_ENCODING,
- WORD_NUM_COLS
+enum
+{
+ WORD_COL_STRING = 0,
+ WORD_COL_ENCODING,
+ WORD_NUM_COLS
};
-enum {
- ENC_COL_STRING = 0,
- ENC_COL_QUARK,
- ENC_NUM_COLS
+enum
+{
+ ENC_COL_STRING = 0,
+ ENC_COL_QUARK,
+ ENC_NUM_COLS
};
static void gxi_data_destroy (GncXmlImportData *data);
@@ -150,7 +157,7 @@
static void gxi_update_string_box (GncXmlImportData *data);
static void gxi_update_conversion_forward (GncXmlImportData *data);
static GnomeDruidPage *gxi_get_named_page (GncXmlImportData *data,
- const gchar *name);
+ const gchar *name);
void gxi_dialog_destroy_cb (GtkObject *object, GncXmlImportData *data);
void gxi_cancel_cb (GnomeDruid *druid, GncXmlImportData *data);
void gxi_chooser_file_activated_cb (GtkFileChooser *chooser,
@@ -160,9 +167,9 @@
void gxi_conversion_prepare_cb (GnomeDruidPage *page, GtkWidget *widget,
GncXmlImportData *data);
static void gxi_default_enc_combo_changed_cb (GtkComboBox *combo,
- GncXmlImportData *data);
+ GncXmlImportData *data);
static void gxi_string_combo_changed_cb (GtkComboBox *combo,
- GncXmlImportData *data);
+ GncXmlImportData *data);
void gxi_edit_encodings_clicked_cb (GtkButton *button, GncXmlImportData *data);
void gxi_available_enc_activated_cb (GtkTreeView *view, GtkTreePath *path,
GtkTreeViewColumn *column,
@@ -186,33 +193,33 @@
GncXmlImportData *data);
static const gchar *encodings_doc_string = N_(
- "The file you are trying to load is from an older version of "
- "GnuCash. The file format in the older versions was missing the "
- "detailed specification of the character encoding being used. This "
- "means the text in your data file could be read in multiple ambiguous "
- "ways. This ambiguity cannot be resolved automatically, but the new "
- "GnuCash 2.0.0 file format will include all necessary specifications so "
- "that you do not have to go through this step again."
- "\n\n"
- "GnuCash will try to guess the correct character encoding for your data "
- "file. On the next page GnuCash will show the resulting texts when "
- "using this guess. You have to check whether the words look as "
- "expected. Either everything looks fine and you can simply press "
- "'Forward'. Or the words contain unexpected characters, in which "
- "case you should select different character encodings to see "
- "different results. You may have to edit the list of character "
- "encodings by clicking on the respective button."
- "\n\n"
- "Press 'Forward' now to select the correct character encoding for "
- "your data file.");
+ "The file you are trying to load is from an older version of "
+ "GnuCash. The file format in the older versions was missing the "
+ "detailed specification of the character encoding being used. This "
+ "means the text in your data file could be read in multiple ambiguous "
+ "ways. This ambiguity cannot be resolved automatically, but the new "
+ "GnuCash 2.0.0 file format will include all necessary specifications so "
+ "that you do not have to go through this step again."
+ "\n\n"
+ "GnuCash will try to guess the correct character encoding for your data "
+ "file. On the next page GnuCash will show the resulting texts when "
+ "using this guess. You have to check whether the words look as "
+ "expected. Either everything looks fine and you can simply press "
+ "'Forward'. Or the words contain unexpected characters, in which "
+ "case you should select different character encodings to see "
+ "different results. You may have to edit the list of character "
+ "encodings by clicking on the respective button."
+ "\n\n"
+ "Press 'Forward' now to select the correct character encoding for "
+ "your data file.");
static const gchar *encodings_doc_page_title = N_("Ambiguous character encoding");
static const gchar *finish_convert_string = N_(
- "The file has been loaded successfully. If you click 'Apply' it will be saved "
- "and reloaded into the main application. That way you will have a working "
- "file as backup in the same directory.\n\n"
- "You can also go back and verify your selections by clicking on 'Back'.");
+ "The file has been loaded successfully. If you click 'Apply' it will be saved "
+ "and reloaded into the main application. That way you will have a working "
+ "file as backup in the same directory.\n\n"
+ "You can also go back and verify your selections by clicking on 'Back'.");
/* The debugging module that this .o belongs to. */
static QofLogModule log_module = GNC_MOD_GUI;
@@ -224,1144 +231,1260 @@
/* this is used for a static tree of system encodings. encoding may be NULL.
parent declares how often to go up in the path of the previous element and use
that as parent, e.g. 0 -> child of previous, 1 -> same level as previous */
-typedef struct {
- gchar *text;
- gchar *encoding;
- gint parent;
+typedef struct
+{
+ gchar *text;
+ gchar *encoding;
+ gint parent;
} system_encoding_type;
static system_encoding_type system_encodings [] =
{
- { N_("Unicode"), NULL, 2 },
- { "UTF-8", "UTF-8", 0 },
- { N_("European"), NULL, 2 },
- { N_("ISO-8859-1 (West European)"), "ISO-8859-1", 0 },
- { N_("ISO-8859-2 (East European)"), "ISO-8859-2", 1 },
- { N_("ISO-8859-3 (South European)"), "ISO-8859-3", 1 },
- { N_("ISO-8859-4 (North European)"), "ISO-8859-4", 1 },
- { N_("ISO-8859-5 (Cyrillic)"), "ISO-8859-5", 1 },
- { N_("ISO-8859-6 (Arabic)"), "ISO-8859-6", 1 },
- { N_("ISO-8859-7 (Greek)"), "ISO-8859-7", 1 },
- { N_("ISO-8859-8 (Hebrew)"), "ISO-8859-8", 1 },
- { N_("ISO-8859-9 (Turkish)"), "ISO-8859-9", 1 },
- { N_("ISO-8859-10 (Nordic)"), "ISO-8859-10", 1 },
- { N_("ISO-8859-11 (Thai)"), "ISO-8859-11", 1 },
- { N_("ISO-8859-13 (Baltic)"), "ISO-8859-13", 1 },
- { N_("ISO-8859-14 (Celtic)"), "ISO-8859-14", 1 },
- { N_("ISO-8859-15 (West European, Euro sign)"), "ISO-8859-15", 1 },
- { N_("ISO-8859-16 (South-East European)"), "ISO-8859-16", 1 },
- { N_("Cyrillic"), NULL, 2 },
- { N_("KOI8-R (Russian)"), "KOI8-R", 0 },
- { N_("KOI8-U (Ukrainian)"), "KOI8-U", 1 },
+ { N_("Unicode"), NULL, 2 },
+ { "UTF-8", "UTF-8", 0 },
+ { N_("European"), NULL, 2 },
+ { N_("ISO-8859-1 (West European)"), "ISO-8859-1", 0 },
+ { N_("ISO-8859-2 (East European)"), "ISO-8859-2", 1 },
+ { N_("ISO-8859-3 (South European)"), "ISO-8859-3", 1 },
+ { N_("ISO-8859-4 (North European)"), "ISO-8859-4", 1 },
+ { N_("ISO-8859-5 (Cyrillic)"), "ISO-8859-5", 1 },
+ { N_("ISO-8859-6 (Arabic)"), "ISO-8859-6", 1 },
+ { N_("ISO-8859-7 (Greek)"), "ISO-8859-7", 1 },
+ { N_("ISO-8859-8 (Hebrew)"), "ISO-8859-8", 1 },
+ { N_("ISO-8859-9 (Turkish)"), "ISO-8859-9", 1 },
+ { N_("ISO-8859-10 (Nordic)"), "ISO-8859-10", 1 },
+ { N_("ISO-8859-11 (Thai)"), "ISO-8859-11", 1 },
+ { N_("ISO-8859-13 (Baltic)"), "ISO-8859-13", 1 },
+ { N_("ISO-8859-14 (Celtic)"), "ISO-8859-14", 1 },
+ { N_("ISO-8859-15 (West European, Euro sign)"), "ISO-8859-15", 1 },
+ { N_("ISO-8859-16 (South-East European)"), "ISO-8859-16", 1 },
+ { N_("Cyrillic"), NULL, 2 },
+ { N_("KOI8-R (Russian)"), "KOI8-R", 0 },
+ { N_("KOI8-U (Ukrainian)"), "KOI8-U", 1 },
};
static guint n_system_encodings = G_N_ELEMENTS (system_encodings);
gboolean
gnc_xml_convert_single_file (const gchar *filename)
{
- GncXmlImportData *data;
- GtkWidget *dialog, *widget;
- GladeXML *xml;
- gboolean success;
+ GncXmlImportData *data;
+ GtkWidget *dialog, *widget;
+ GladeXML *xml;
+ gboolean success;
- data = g_new0 (GncXmlImportData, 1);
- data->import_type = XML_CONVERT_SINGLE_FILE;
- data->filename = g_strdup (filename);
+ data = g_new0 (GncXmlImportData, 1);
+ data->import_type = XML_CONVERT_SINGLE_FILE;
+ data->filename = g_strdup (filename);
- /* gather ambiguous info */
- gxi_check_file (data);
- if (data->n_impossible == -1)
- return FALSE;
+ /* gather ambiguous info */
+ gxi_check_file (data);
+ if (data->n_impossible == -1)
+ return FALSE;
- if (!g_hash_table_size (data->ambiguous_ht)) {
+ if (!g_hash_table_size (data->ambiguous_ht))
+ {
- /* no ambiguous strings */
- success =
- gxi_parse_file (data) &&
- gxi_save_file (data);
+ /* no ambiguous strings */
+ success =
+ gxi_parse_file (data) &&
+ gxi_save_file (data);
- gxi_data_destroy (data);
+ gxi_data_destroy (data);
- } else {
+ }
+ else
+ {
- /* common druid initialization */
- xml = gnc_glade_xml_new (XML_GLADE_FILE, "GnuCash XML Import Dialog");
+ /* common druid initialization */
+ xml = gnc_glade_xml_new (XML_GLADE_FILE, "GnuCash XML Import Dialog");
- dialog = glade_xml_get_widget (xml, "GnuCash XML Import Dialog");
- gtk_widget_hide ((GTK_DIALOG (dialog))->action_area);
- data->dialog = dialog;
- g_object_set_data_full (G_OBJECT (dialog), "xml", xml, g_object_unref);
- glade_xml_signal_autoconnect_full (xml, gnc_glade_autoconnect_full_func,
- data);
+ dialog = glade_xml_get_widget (xml, "GnuCash XML Import Dialog");
+ gtk_widget_hide ((GTK_DIALOG (dialog))->action_area);
+ data->dialog = dialog;
+ g_object_set_data_full (G_OBJECT (dialog), "xml", xml, g_object_unref);
+ glade_xml_signal_autoconnect_full (xml, gnc_glade_autoconnect_full_func,
+ data);
- data->druid = glade_xml_get_widget (xml, "gnc_xml_import_druid");
- gnc_druid_set_colors (GNOME_DRUID (data->druid));
+ data->druid = glade_xml_get_widget (xml, "gnc_xml_import_druid");
+ gnc_druid_set_colors (GNOME_DRUID (data->druid));
- /* start page, explanations */
- widget = glade_xml_get_widget (xml, "start_page");
- gnome_druid_page_edge_set_text (GNOME_DRUID_PAGE_EDGE (widget),
- gettext (encodings_doc_string));
- gnome_druid_page_edge_set_title (GNOME_DRUID_PAGE_EDGE (widget),
- gettext (encodings_doc_page_title));
- gtk_widget_show (widget);
+ /* start page, explanations */
+ widget = glade_xml_get_widget (xml, "start_page");
+ gnome_druid_page_edge_set_text (GNOME_DRUID_PAGE_EDGE (widget),
+ gettext (encodings_doc_string));
+ gnome_druid_page_edge_set_title (GNOME_DRUID_PAGE_EDGE (widget),
+ gettext (encodings_doc_page_title));
+ gtk_widget_show (widget);
- gtk_widget_hide (glade_xml_get_widget (xml, "encodings_doc_page"));
- gtk_widget_hide (glade_xml_get_widget (xml, "load_file_page"));
- gtk_widget_hide (glade_xml_get_widget (xml, "loaded_files_page"));
- gtk_widget_hide (glade_xml_get_widget (xml, "merge_page"));
+ gtk_widget_hide (glade_xml_get_widget (xml, "encodings_doc_page"));
+ gtk_widget_hide (glade_xml_get_widget (xml, "load_file_page"));
+ gtk_widget_hide (glade_xml_get_widget (xml, "loaded_files_page"));
+ gtk_widget_hide (glade_xml_get_widget (xml, "merge_page"));
- /* finish page */
- widget = glade_xml_get_widget (xml, "end_page");
- gnome_druid_page_edge_set_text (GNOME_DRUID_PAGE_EDGE (widget),
- gettext (finish_convert_string));
- gtk_widget_show (widget);
+ /* finish page */
+ widget = glade_xml_get_widget (xml, "end_page");
+ gnome_druid_page_edge_set_text (GNOME_DRUID_PAGE_EDGE (widget),
+ gettext (finish_convert_string));
+ gtk_widget_show (widget);
- gxi_update_default_enc_combo (data);
- gxi_update_string_box (data);
+ gxi_update_default_enc_combo (data);
+ gxi_update_string_box (data);
- success =
- gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_APPLY &&
- gxi_save_file (data);
+ success =
+ gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_APPLY &&
+ gxi_save_file (data);
- gtk_widget_destroy (data->dialog);
- }
+ gtk_widget_destroy (data->dialog);
+ }
- return success;
+ return success;
}
/* this is NOT fully implemented */
void
gnc_xml_merge_files (void)
{
- GncXmlImportData *data;
- GtkWidget *dialog, *widget, *box;
- GladeXML *xml;
+ GncXmlImportData *data;
+ GtkWidget *dialog, *widget, *box;
+ GladeXML *xml;
- data = g_new0 (GncXmlImportData, 1);
- data->import_type = XML_MERGE_FILES;
+ data = g_new0 (GncXmlImportData, 1);
+ data->import_type = XML_MERGE_FILES;
- /* common druid initialization */
- xml = gnc_glade_xml_new (XML_GLADE_FILE, "GnuCash XML Import Dialog");
+ /* common druid initialization */
+ xml = gnc_glade_xml_new (XML_GLADE_FILE, "GnuCash XML Import Dialog");
- dialog = glade_xml_get_widget (xml, "GnuCash XML Import Dialog");
- gtk_widget_hide ((GTK_DIALOG (dialog))->action_area);
- data->dialog = dialog;
- g_object_set_data_full (G_OBJECT (dialog), "xml", xml, g_object_unref);
- glade_xml_signal_autoconnect_full (xml, gnc_glade_autoconnect_full_func,
- data);
+ dialog = glade_xml_get_widget (xml, "GnuCash XML Import Dialog");
+ gtk_widget_hide ((GTK_DIALOG (dialog))->action_area);
+ data->dialog = dialog;
+ g_object_set_data_full (G_OBJECT (dialog), "xml", xml, g_object_unref);
+ glade_xml_signal_autoconnect_full (xml, gnc_glade_autoconnect_full_func,
+ data);
- data->druid = glade_xml_get_widget (xml, "gnc_xml_import_druid");
- gnc_druid_set_colors (GNOME_DRUID (data->druid));
+ data->druid = glade_xml_get_widget (xml, "gnc_xml_import_druid");
+ gnc_druid_set_colors (GNOME_DRUID (data->druid));
- /* encodings explanations */
- widget = glade_xml_get_widget (xml, "encodings_doc_label");
- gtk_label_set_text (GTK_LABEL (widget), gettext (encodings_doc_string));
- widget = glade_xml_get_widget (xml, "encodings_doc_page");
- gnome_druid_page_standard_set_title (GNOME_DRUID_PAGE_STANDARD (widget),
- gettext (encodings_doc_page_title));
+ /* encodings explanations */
+ widget = glade_xml_get_widget (xml, "encodings_doc_label");
+ gtk_label_set_text (GTK_LABEL (widget), gettext (encodings_doc_string));
+ widget = glade_xml_get_widget (xml, "encodings_doc_page");
+ gnome_druid_page_standard_set_title (GNOME_DRUID_PAGE_STANDARD (widget),
+ gettext (encodings_doc_page_title));
- gtk_widget_show (glade_xml_get_widget (xml, "start_page"));
- gtk_widget_show (glade_xml_get_widget (xml, "end_page"));
+ gtk_widget_show (glade_xml_get_widget (xml, "start_page"));
+ gtk_widget_show (glade_xml_get_widget (xml, "end_page"));
- /* file chooser */
- data->file_chooser = gtk_file_chooser_widget_new (
- GTK_FILE_CHOOSER_ACTION_OPEN);
- box = glade_xml_get_widget (xml, "file_chooser_box");
- gtk_box_pack_start (GTK_BOX (box), data->file_chooser, TRUE, TRUE, 0);
- g_signal_connect (G_OBJECT (data->file_chooser), "file-activated",
- G_CALLBACK (gxi_chooser_file_activated_cb), data);
- gtk_widget_show (data->file_chooser);
+ /* file chooser */
+ data->file_chooser = gtk_file_chooser_widget_new (
+ GTK_FILE_CHOOSER_ACTION_OPEN);
+ box = glade_xml_get_widget (xml, "file_chooser_box");
+ gtk_box_pack_start (GTK_BOX (box), data->file_chooser, TRUE, TRUE, 0);
+ g_signal_connect (G_OBJECT (data->file_chooser), "file-activated",
+ G_CALLBACK (gxi_chooser_file_activated_cb), data);
+ gtk_widget_show (data->file_chooser);
- /* selected file list */
- data->file_list_store = gtk_list_store_new (FILE_NUM_COLS,
- G_TYPE_STRING, G_TYPE_POINTER);
- data->file_list_view = GTK_TREE_VIEW (glade_xml_get_widget (
- xml, "selected_file_list"));
- gtk_tree_view_insert_column_with_attributes (
- data->file_list_view, -1, NULL,
- gtk_cell_renderer_text_new (), "text", FILE_COL_NAME, NULL);
- gtk_tree_view_set_model (data->file_list_view,
- GTK_TREE_MODEL (data->file_list_store));
- g_object_unref (data->file_list_store);
+ /* selected file list */
+ data->file_list_store = gtk_list_store_new (FILE_NUM_COLS,
+ G_TYPE_STRING, G_TYPE_POINTER);
+ data->file_list_view = GTK_TREE_VIEW (glade_xml_get_widget (
+ xml, "selected_file_list"));
+ gtk_tree_view_insert_column_with_attributes (
+ data->file_list_view, -1, NULL,
+ gtk_cell_renderer_text_new (), "text", FILE_COL_NAME, NULL);
+ gtk_tree_view_set_model (data->file_list_view,
+ GTK_TREE_MODEL (data->file_list_store));
+ g_object_unref (data->file_list_store);
- gtk_widget_show (dialog);
+ gtk_widget_show (dialog);
}
static void
gxi_data_destroy (GncXmlImportData *data)
{
- if (!data)
- return;
+ if (!data)
+ return;
- if (data->dialog)
- gtk_widget_hide (data->dialog);
+ if (data->dialog)
+ gtk_widget_hide (data->dialog);
- if (data->file_chooser) {
- gtk_widget_destroy (data->file_chooser);
- data->file_chooser = NULL;
- }
+ if (data->file_chooser)
+ {
+ gtk_widget_destroy (data->file_chooser);
+ data->file_chooser = NULL;
+ }
- if (data->filename) {
- g_free (data->filename);
- data->filename = NULL;
- }
+ if (data->filename)
+ {
+ g_free (data->filename);
+ data->filename = NULL;
+ }
- gxi_session_destroy (data);
- gxi_ambiguous_info_destroy (data);
+ gxi_session_destroy (data);
+ gxi_ambiguous_info_destroy (data);
- if (data->choices) {
- g_hash_table_destroy (data->choices);
- data->choices = NULL;
- }
+ if (data->choices)
+ {
+ g_hash_table_destroy (data->choices);
+ data->choices = NULL;
+ }
- if (data->string_box) {
- gtk_widget_destroy (data->string_box);
- data->string_box = NULL;
- }
+ if (data->string_box)
+ {
+ gtk_widget_destroy (data->string_box);
+ data->string_box = NULL;
+ }
- if (data->dialog) {
- gtk_widget_destroy (data->dialog);
- data->dialog = NULL;
- }
+ if (data->dialog)
+ {
+ gtk_widget_destroy (data->dialog);
+ data->dialog = NULL;
+ }
- g_free (data);
+ g_free (data);
}
static void
-conv_free (conv_type *conv) {
- if (conv) {
- g_free(conv->utf8_string);
- g_free(conv);
- }
+conv_free (conv_type *conv)
+{
+ if (conv)
+ {
+ g_free(conv->utf8_string);
+ g_free(conv);
+ }
}
static conv_type *
-conv_copy (const conv_type *conv) {
- conv_type *new = NULL;
- if (conv) {
- new = g_new(conv_type, 1);
- new->encoding = conv->encoding;
- new->utf8_string = g_strdup (conv->utf8_string);
- }
- return new;
+conv_copy (const conv_type *conv)
+{
+ conv_type *new = NULL;
+ if (conv)
+ {
+ new = g_new(conv_type, 1);
+ new->encoding = conv->encoding;
+ new->utf8_string = g_strdup (conv->utf8_string);
+ }
+ return new;
}
static gint
conv_enc_cmp (const conv_type *conv, const GQuark *enc)
{
- return conv->encoding - *enc;
+ return conv->encoding - *enc;
}
static const gchar *
get_decoded_string (const ambiguous_type *amb, const GQuark enc)
{
- GList *found = g_list_find_custom (amb->conv_list, &enc,
- (GCompareFunc) conv_enc_cmp);
+ GList *found = g_list_find_custom (amb->conv_list, &enc,
+ (GCompareFunc) conv_enc_cmp);
- if (found) {
- return ((conv_type*) found->data)->utf8_string;
- } else {
- return NULL;
- }
+ if (found)
+ {
+ return ((conv_type*) found->data)->utf8_string;
+ }
+ else
+ {
+ return NULL;
+ }
}
static gint
ambiguous_cmp (const ambiguous_type *a, const ambiguous_type *b,
GncXmlImportData *data)
{
- const gchar *string_a = get_decoded_string (a, data->default_encoding);
- const gchar *string_b = get_decoded_string (b, data->default_encoding);
+ const gchar *string_a = get_decoded_string (a, data->default_encoding);
+ const gchar *string_b = get_decoded_string (b, data->default_encoding);
- if (string_a) {
- if (string_b) {
- /* both look good, usual compare */
- return strcmp (string_a, string_b);
- } else {
- /* a look good, b not. put b to the top */
- return 1;
+ if (string_a)
+ {
+ if (string_b)
+ {
+ /* both look good, usual compare */
+ return strcmp (string_a, string_b);
+ }
+ else
+ {
+ /* a look good, b not. put b to the top */
+ return 1;
+ }
}
- } else {
- if (string_b) {
- /* b looks good, a not. put a to the top */
- return -1;
- } else {
- /* both look suboptimal, see whether one has a decision attached to it */
- conv_type *conv_a = g_hash_table_lookup (data->choices, a->byte_sequence);
- conv_type *conv_b = g_hash_table_lookup (data->choices, b->byte_sequence);
- if (conv_a && !conv_b) return 1;
- if (conv_b && !conv_a) return -1;
- return strcmp (a->byte_sequence, b->byte_sequence);
+ else
+ {
+ if (string_b)
+ {
+ /* b looks good, a not. put a to the top */
+ return -1;
+ }
+ else
+ {
+ /* both look suboptimal, see whether one has a decision attached to it */
+ conv_type *conv_a = g_hash_table_lookup (data->choices, a->byte_sequence);
+ conv_type *conv_b = g_hash_table_lookup (data->choices, b->byte_sequence);
+ if (conv_a && !conv_b) return 1;
+ if (conv_b && !conv_a) return -1;
+ return strcmp (a->byte_sequence, b->byte_sequence);
+ }
}
- }
}
static void
ambiguous_list_insert (gchar *byte_sequence, GList *conv_list,
GncXmlImportData *data)
{
- GList *iter;
+ GList *iter;
- ambiguous_type *amb = g_new (ambiguous_type, 1);
- amb->byte_sequence = g_strdup (byte_sequence);
- amb->conv_list = NULL;
- for (iter = g_list_last (conv_list); iter; iter = iter->prev)
- amb->conv_list = g_list_prepend (amb->conv_list, conv_copy (iter->data));
+ ambiguous_type *amb = g_new (ambiguous_type, 1);
+ amb->byte_sequence = g_strdup (byte_sequence);
+ amb->conv_list = NULL;
+ for (iter = g_list_last (conv_list); iter; iter = iter->prev)
+ amb->conv_list = g_list_prepend (amb->conv_list, conv_copy (iter->data));
- data->ambiguous_list = g_list_prepend (data->ambiguous_list, amb);
+ data->ambiguous_list = g_list_prepend (data->ambiguous_list, amb);
}
static void
-ambiguous_free (ambiguous_type *amb) {
- if (amb) {
- g_free (amb->byte_sequence);
- g_list_foreach (amb->conv_list, (GFunc) conv_free, NULL);
- g_list_free (amb->conv_list);
- g_free (amb);
- }
+ambiguous_free (ambiguous_type *amb)
+{
+ if (amb)
+ {
+ g_free (amb->byte_sequence);
+ g_list_foreach (amb->conv_list, (GFunc) conv_free, NULL);
+ g_list_free (amb->conv_list);
+ g_free (amb);
+ }
}
static void
gxi_ambiguous_info_destroy (GncXmlImportData *data)
{
- if (data->unique) {
- g_hash_table_destroy (data->unique);
- data->unique = NULL;
- }
- if (data->ambiguous_ht) {
- g_hash_table_destroy (data->ambiguous_ht);
- data->unique = NULL;
- }
- if (data->ambiguous_list) {
- g_list_foreach (data->ambiguous_list, (GFunc) ambiguous_free, NULL);
- g_list_free (data->ambiguous_list);
- data->ambiguous_list = NULL;
- }
+ if (data->unique)
+ {
+ g_hash_table_destroy (data->unique);
+ data->unique = NULL;
+ }
+ if (data->ambiguous_ht)
+ {
+ g_hash_table_destroy (data->ambiguous_ht);
+ data->unique = NULL;
+ }
+ if (data->ambiguous_list)
+ {
+ g_list_foreach (data->ambiguous_list, (GFunc) ambiguous_free, NULL);
+ g_list_free (data->ambiguous_list);
+ data->ambiguous_list = NULL;
+ }
}
static void
gxi_session_destroy (GncXmlImportData *data)
{
- if (data->session) {
- xaccLogDisable ();
- qof_session_destroy (data->session);
- xaccLogEnable ();
- data->session = NULL;
- }
+ if (data->session)
+ {
+ xaccLogDisable ();
+ qof_session_destroy (data->session);
+ xaccLogEnable ();
+ data->session = NULL;
+ }
}
static void
gxi_check_file (GncXmlImportData *data)
{
- if (!data->encodings) {
- gboolean is_utf8;
- const gchar *locale_enc;
- gchar *enc_string, **enc_array, **enc_cursor;
- gpointer enc_ptr;
- GIConv iconv;
+ if (!data->encodings)
+ {
+ gboolean is_utf8;
+ const gchar *locale_enc;
+ gchar *enc_string, **enc_array, **enc_cursor;
+ gpointer enc_ptr;
+ GIConv iconv;
- /* first locale encoding */
- is_utf8 = g_get_charset (&locale_enc);
- enc_string = g_ascii_strup (locale_enc, -1);
- enc_ptr = GUINT_TO_POINTER (g_quark_from_string (enc_string));
- g_free (enc_string);
- data->encodings = g_list_append (NULL, enc_ptr);
+ /* first locale encoding */
+ is_utf8 = g_get_charset (&locale_enc);
+ enc_string = g_ascii_strup (locale_enc, -1);
+ enc_ptr = GUINT_TO_POINTER (g_quark_from_string (enc_string));
+ g_free (enc_string);
+ data->encodings = g_list_append (NULL, enc_ptr);
- /* add utf-8 */
- if (!is_utf8) {
- enc_ptr = GUINT_TO_POINTER (g_quark_from_string ("UTF-8"));
- data->encodings = g_list_append (data->encodings, enc_ptr);
- }
+ /* add utf-8 */
+ if (!is_utf8)
+ {
+ enc_ptr = GUINT_TO_POINTER (g_quark_from_string ("UTF-8"));
+ data->encodings = g_list_append (data->encodings, enc_ptr);
+ }
- /* Translators: Please insert encodings here that are typically used in your
- * locale, separated by spaces. No need for ASCII or UTF-8, check `locale -m`
- * for assistance with spelling. */
- enc_array = g_strsplit (_("ISO-8859-1 KOI8-U"), " ", 0);
+ /* Translators: Please insert encodings here that are typically used in your
+ * locale, separated by spaces. No need for ASCII or UTF-8, check `locale -m`
+ * for assistance with spelling. */
+ enc_array = g_strsplit (_("ISO-8859-1 KOI8-U"), " ", 0);
- /* loop through typical encodings */
- for (enc_cursor = enc_array; *enc_cursor; enc_cursor++) {
- if (!**enc_cursor) continue;
- enc_string = g_ascii_strup (*enc_cursor, -1);
- enc_ptr = GUINT_TO_POINTER (g_quark_from_string (enc_string));
+ /* loop through typical encodings */
+ for (enc_cursor = enc_array; *enc_cursor; enc_cursor++)
+ {
+ if (!**enc_cursor) continue;
+ enc_string = g_ascii_strup (*enc_cursor, -1);
+ enc_ptr = GUINT_TO_POINTER (g_quark_from_string (enc_string));
- if (!g_list_find (data->encodings, enc_ptr)) {
- /* test whether we like this encoding */
- iconv = g_iconv_open ("UTF-8", enc_string);
- if (iconv != (GIConv) -1)
- /* we like it */
- data->encodings = g_list_append (data->encodings, enc_ptr);
- g_iconv_close (iconv);
- }
- g_free (enc_string);
+ if (!g_list_find (data->encodings, enc_ptr))
+ {
+ /* test whether we like this encoding */
+ iconv = g_iconv_open ("UTF-8", enc_string);
+ if (iconv != (GIConv) - 1)
+ /* we like it */
+ data->encodings = g_list_append (data->encodings, enc_ptr);
+ g_iconv_close (iconv);
+ }
+ g_free (enc_string);
+ }
+ g_strfreev (enc_array);
}
- g_strfreev (enc_array);
- }
- if (!data->default_encoding) {
- /* choose top one */
- data->default_encoding = GPOINTER_TO_UINT (data->encodings->data);
- }
+ if (!data->default_encoding)
+ {
+ /* choose top one */
+ data->default_encoding = GPOINTER_TO_UINT (data->encodings->data);
+ }
- if (!data->choices) {
- data->choices = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, (GDestroyNotify) conv_free);
- }
+ if (!data->choices)
+ {
+ data->choices = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, (GDestroyNotify) conv_free);
+ }
- gxi_ambiguous_info_destroy (data);
+ gxi_ambiguous_info_destroy (data);
- /* analyze file */
- data->n_impossible = gnc_xml2_find_ambiguous (
- data->filename, data->encodings, &data->unique, &data->ambiguous_ht, NULL);
+ /* analyze file */
+ data->n_impossible = gnc_xml2_find_ambiguous (
+ data->filename, data->encodings, &data->unique, &data->ambiguous_ht, NULL);
- if (data->n_impossible != -1) {
- /* sort ambiguous words */
- g_hash_table_foreach (data->ambiguous_ht, (GHFunc)ambiguous_list_insert,
- data);
- gxi_sort_ambiguous_list (data);
- }
+ if (data->n_impossible != -1)
+ {
+ /* sort ambiguous words */
+ g_hash_table_foreach (data->ambiguous_ht, (GHFunc)ambiguous_list_insert,
+ data);
+ gxi_sort_ambiguous_list (data);
+ }
}
static void
gxi_sort_ambiguous_list (GncXmlImportData *data)
{
- data->ambiguous_list = g_list_sort_with_data (
- data->ambiguous_list, (GCompareDataFunc) ambiguous_cmp, data);
+ data->ambiguous_list = g_list_sort_with_data (
+ data->ambiguous_list, (GCompareDataFunc) ambiguous_cmp, data);
}
static void
subst_insert_amb (gchar *byte_sequence, GList *conv_list, GncXmlImportData *data)
{
- conv_type *choice;
- GList *default_conv;
- gchar *default_utf8;
+ conv_type *choice;
+ GList *default_conv;
+ gchar *default_utf8;
- if (!data->subst)
- return;
- choice = g_hash_table_lookup (data->choices, byte_sequence);
- if (choice) {
- /* user choice */
- g_hash_table_insert (data->subst, g_strdup (byte_sequence),
- g_strdup (choice->utf8_string));
- } else {
- default_conv = g_list_find_custom (conv_list, &data->default_encoding,
- (GCompareFunc) conv_enc_cmp);
- if (default_conv) {
- /* default conversion */
- default_utf8 = ((conv_type*) default_conv->data)->utf8_string;
- g_hash_table_insert (data->subst, g_strdup (byte_sequence),
- g_strdup (default_utf8));
- } else {
- /* no conversion avaiable, stop filling of subst */
- g_hash_table_destroy (data->subst);
- data->subst = NULL;
+ if (!data->subst)
+ return;
+ choice = g_hash_table_lookup (data->choices, byte_sequence);
+ if (choice)
+ {
+ /* user choice */
+ g_hash_table_insert (data->subst, g_strdup (byte_sequence),
+ g_strdup (choice->utf8_string));
}
- }
+ else
+ {
+ default_conv = g_list_find_custom (conv_list, &data->default_encoding,
+ (GCompareFunc) conv_enc_cmp);
+ if (default_conv)
+ {
+ /* default conversion */
+ default_utf8 = ((conv_type*) default_conv->data)->utf8_string;
+ g_hash_table_insert (data->subst, g_strdup (byte_sequence),
+ g_strdup (default_utf8));
+ }
+ else
+ {
+ /* no conversion avaiable, stop filling of subst */
+ g_hash_table_destroy (data->subst);
+ data->subst = NULL;
+ }
+ }
}
static void
subst_insert_unique (gchar *byte_sequence, conv_type *conv,
GncXmlImportData *data)
{
- if (!data->subst)
- return;
- g_hash_table_insert (data->subst, g_strdup (byte_sequence),
- g_strdup (conv->utf8_string));
+ if (!data->subst)
+ return;
+ g_hash_table_insert (data->subst, g_strdup (byte_sequence),
+ g_strdup (conv->utf8_string));
}
static gboolean
gxi_parse_file (GncXmlImportData *data)
{
- QofSession *session=NULL;
- QofBook *book;
- FileBackend *backend;
- QofBackendError io_err = ERR_BACKEND_NO_ERR;
- gchar *logpath, *message=NULL;
- gboolean success=FALSE;
+ QofSession *session = NULL;
+ QofBook *book;
+ FileBackend *backend;
+ QofBackendError io_err = ERR_BACKEND_NO_ERR;
+ gchar *logpath, *message = NULL;
+ gboolean success = FALSE;
- if (data->n_unassigned || data->n_impossible)
- goto cleanup_parse_file;
+ if (data->n_unassigned || data->n_impossible)
+ goto cleanup_parse_file;
- /* fill subst hash table with byte sequence substitutions */
- data->subst = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- g_hash_table_foreach (data->ambiguous_ht, (GHFunc) subst_insert_amb, data);
- g_hash_table_foreach (data->unique, (GHFunc) subst_insert_unique, data);
+ /* fill subst hash table with byte sequence substitutions */
+ data->subst = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+ g_hash_table_foreach (data->ambiguous_ht, (GHFunc) subst_insert_amb, data);
+ g_hash_table_foreach (data->unique, (GHFunc) subst_insert_unique, data);
- if (!data->subst)
- goto cleanup_parse_file;
+ if (!data->subst)
+ goto cleanup_parse_file;
- /* create a temporary QofSession */
- gxi_session_destroy (data);
- session = qof_session_new ();
- data->session = session;
- qof_session_begin (session, data->filename, TRUE, FALSE);
- io_err = qof_session_get_error (session);
- if (io_err != ERR_BACKEND_NO_ERR) {
- message = _("The file could not be reopened.");
- goto cleanup_parse_file;
- }
+ /* create a temporary QofSession */
+ gxi_session_destroy (data);
+ session = qof_session_new ();
+ data->session = session;
+ qof_session_begin (session, data->filename, TRUE, FALSE);
+ io_err = qof_session_get_error (session);
+ if (io_err != ERR_BACKEND_NO_ERR)
+ {
+ message = _("The file could not be reopened.");
+ goto cleanup_parse_file;
+ }
- logpath = xaccResolveFilePath (data->filename);
- xaccLogSetBaseName (logpath);
- xaccLogDisable ();
- gxi_update_progress_bar (_("Reading file..."), 0.0);
- qof_session_load (session, gxi_update_progress_bar);
- gxi_update_progress_bar (NULL, -1.0);
- xaccLogEnable ();
+ logpath = xaccResolveFilePath (data->filename);
+ xaccLogSetBaseName (logpath);
+ xaccLogDisable ();
+ gxi_update_progress_bar (_("Reading file..."), 0.0);
+ qof_session_load (session, gxi_update_progress_bar);
+ gxi_update_progress_bar (NULL, -1.0);
+ xaccLogEnable ();
- io_err = qof_session_get_error (session);
- if (io_err == ERR_BACKEND_NO_ERR) {
- /* loaded sucessfully now. strange, but ok */
- success = TRUE;
- goto cleanup_parse_file;
- } else if (io_err != ERR_FILEIO_NO_ENCODING) {
- /* another error, cannot handle this here */
- message = _("The file could not be reopened.");
- goto cleanup_parse_file;
- }
+ io_err = qof_session_get_error (session);
+ if (io_err == ERR_BACKEND_NO_ERR)
+ {
+ /* loaded sucessfully now. strange, but ok */
+ success = TRUE;
+ goto cleanup_parse_file;
+ }
+ else if (io_err != ERR_FILEIO_NO_ENCODING)
+ {
+ /* another error, cannot handle this here */
+ message = _("The file could not be reopened.");
+ goto cleanup_parse_file;
+ }
- qof_session_pop_error (session);
- book = qof_session_get_book (session);
- backend = (FileBackend*) qof_book_get_backend (book);
+ qof_session_pop_error (session);
+ book = qof_session_get_book (session);
+ backend = (FileBackend*) qof_book_get_backend (book);
- gxi_update_progress_bar (_("Parsing file..."), 0.0);
- success = gnc_xml2_parse_with_subst (backend, book, data->subst);
- gxi_update_progress_bar (NULL, -1.0);
+ gxi_update_progress_bar (_("Parsing file..."), 0.0);
+ success = gnc_xml2_parse_with_subst (backend, book, data->subst);
+ gxi_update_progress_bar (NULL, -1.0);
- if (success)
- data->session = session;
- else
- message = _("There was an error parsing the file.");
+ if (success)
+ data->session = session;
+ else
+ message = _("There was an error parsing the file.");
- cleanup_parse_file:
+cleanup_parse_file:
- if (data->subst) {
- g_hash_table_destroy (data->subst);
- data->subst = NULL;
- }
- if (message) {
- gnc_error_dialog (data->dialog, "%s", message);
- }
- if (!success)
- gxi_session_destroy (data);
+ if (data->subst)
+ {
+ g_hash_table_destroy (data->subst);
+ data->subst = NULL;
+ }
+ if (message)
+ {
+ gnc_error_dialog (data->dialog, "%s", message);
+ }
+ if (!success)
+ gxi_session_destroy (data);
- return success;
+ return success;
}
static gboolean
gxi_save_file (GncXmlImportData *data)
{
- QofBackendError io_err;
- g_return_val_if_fail (data && data->session, FALSE);
+ QofBackendError io_err;
+ g_return_val_if_fail (data && data->session, FALSE);
- gxi_update_progress_bar (_("Writing file..."), 0.0);
- qof_session_save (data->session, gxi_update_progress_bar);
- gxi_update_progress_bar (NULL, -1.0);
+ gxi_update_progress_bar (_("Writing file..."), 0.0);
+ qof_session_save (data->session, gxi_update_progress_bar);
+ gxi_update_progress_bar (NULL, -1.0);
- io_err = qof_session_get_error (data->session);
+ io_err = qof_session_get_error (data->session);
- if (io_err == ERR_BACKEND_NO_ERR) {
- return TRUE;
- } else {
- gxi_session_destroy (data);
- return FALSE;
- }
+ if (io_err == ERR_BACKEND_NO_ERR)
+ {
+ return TRUE;
+ }
+ else
+ {
+ gxi_session_destroy (data);
+ return FALSE;
+ }
}
static void
gxi_update_progress_bar (const gchar *message, double percentage)
{
- if (!progress_window) {
- progress_window = gtk_window_new (GTK_WINDOW_POPUP);
- progress_bar = GTK_PROGRESS_BAR (gtk_progress_bar_new ());
- gtk_container_set_border_width (GTK_CONTAINER (progress_window), 12);
- gtk_container_add (GTK_CONTAINER (progress_window),
- GTK_WIDGET (progress_bar));
- gtk_widget_show (GTK_WIDGET (progress_bar));
- }
+ if (!progress_window)
+ {
+ progress_window = gtk_window_new (GTK_WINDOW_POPUP);
+ progress_bar = GTK_PROGRESS_BAR (gtk_progress_bar_new ());
+ gtk_container_set_border_width (GTK_CONTAINER (progress_window), 12);
+ gtk_container_add (GTK_CONTAINER (progress_window),
+ GTK_WIDGET (progress_bar));
+ gtk_widget_show (GTK_WIDGET (progress_bar));
+ }
- if (percentage < 0) {
- gtk_progress_bar_set_text (progress_bar, NULL);
- gtk_progress_bar_set_fraction (progress_bar, 0.0);
- gtk_widget_hide (progress_window);
- } else {
- gtk_progress_bar_set_text (progress_bar, message);
- if (percentage <= 100)
- gtk_progress_bar_set_fraction (progress_bar, percentage/100);
+ if (percentage < 0)
+ {
+ gtk_progress_bar_set_text (progress_bar, NULL);
+ gtk_progress_bar_set_fraction (progress_bar, 0.0);
+ gtk_widget_hide (progress_window);
+ }
else
- gtk_progress_bar_pulse (progress_bar);
- gtk_widget_show (progress_window);
- }
+ {
+ gtk_progress_bar_set_text (progress_bar, message);
+ if (percentage <= 100)
+ gtk_progress_bar_set_fraction (progress_bar, percentage / 100);
+ else
+ gtk_progress_bar_pulse (progress_bar);
+ gtk_widget_show (progress_window);
+ }
}
static void
gxi_update_default_enc_combo (GncXmlImportData *data)
{
- GtkComboBox *combo;
- GList *enc_iter;
+ GtkComboBox *combo;
+ GList *enc_iter;
- /* add encodings list */
- if (data->default_encoding_combo)
- gtk_widget_destroy (data->default_encoding_combo);
- data->default_encoding_combo = gtk_combo_box_new_text ();
- combo = GTK_COMBO_BOX (data->default_encoding_combo);
+ /* add encodings list */
+ if (data->default_encoding_combo)
+ gtk_widget_destroy (data->default_encoding_combo);
+ data->default_encoding_combo = gtk_combo_box_new_text ();
+ combo = GTK_COMBO_BOX (data->default_encoding_combo);
- for (enc_iter = data->encodings; enc_iter; enc_iter = enc_iter->next) {
- gtk_combo_box_append_text (
- combo, g_quark_to_string (GPOINTER_TO_UINT (enc_iter->data)));
- }
- gtk_combo_box_set_active (
- combo,
- g_list_index (data->encodings, GUINT_TO_POINTER (data->default_encoding)));
+ for (enc_iter = data->encodings; enc_iter; enc_iter = enc_iter->next)
+ {
+ gtk_combo_box_append_text (
+ combo, g_quark_to_string (GPOINTER_TO_UINT (enc_iter->data)));
+ }
+ gtk_combo_box_set_active (
+ combo,
+ g_list_index (data->encodings, GUINT_TO_POINTER (data->default_encoding)));
- /* show encodings */
- g_signal_connect (G_OBJECT (combo), "changed",
- G_CALLBACK (gxi_default_enc_combo_changed_cb), data);
- gtk_container_add (GTK_CONTAINER (gnc_glade_lookup_widget (
- data->druid, "default_enc_box")),
- GTK_WIDGET (combo));
- gtk_widget_show (GTK_WIDGET (combo));
+ /* show encodings */
+ g_signal_connect (G_OBJECT (combo), "changed",
+ G_CALLBACK (gxi_default_enc_combo_changed_cb), data);
+ gtk_container_add (GTK_CONTAINER (gnc_glade_lookup_widget (
+ data->druid, "default_enc_box")),
+ GTK_WIDGET (combo));
+ gtk_widget_show (GTK_WIDGET (combo));
}
static void
gxi_update_summary_label (GncXmlImportData *data)
{
- gchar *string=NULL;
- gboolean show=FALSE;
+ gchar *string = NULL;
+ gboolean show = FALSE;
- if (data->n_unassigned) {
- if (data->n_impossible) {
- string = g_strdup_printf (
- _("There are %d unassigned and %d undecodable words. "
- "Please add encodings."),
- data->n_unassigned, data->n_impossible);
- show = TRUE;
- } else {
- string = g_strdup_printf (
- _("There are %d unassigned words. "
- "Please decide on them or add encodings."),
- data->n_unassigned);
- show = TRUE;
+ if (data->n_unassigned)
+ {
+ if (data->n_impossible)
+ {
+ string = g_strdup_printf (
+ _("There are %d unassigned and %d undecodable words. "
+ "Please add encodings."),
+ data->n_unassigned, data->n_impossible);
+ show = TRUE;
+ }
+ else
+ {
+ string = g_strdup_printf (
+ _("There are %d unassigned words. "
+ "Please decide on them or add encodings."),
+ data->n_unassigned);
+ show = TRUE;
+ }
}
- } else {
- if (data->n_impossible) {
- string = g_strdup_printf (
- _("There are %d undecodable words. "
- "Please add encodings."),
- data->n_impossible);
- show = TRUE;
- } else {
- show = FALSE;
+ else
+ {
+ if (data->n_impossible)
+ {
+ string = g_strdup_printf (
+ _("There are %d undecodable words. "
+ "Please add encodings."),
+ data->n_impossible);
+ show = TRUE;
+ }
+ else
+ {
+ show = FALSE;
+ }
}
- }
- if (show) {
- gtk_label_set_text (GTK_LABEL (data->summary_label), string);
- g_free (string);
- gtk_widget_show (data->summary_label);
- } else {
- gtk_widget_hide (data->summary_label);
- }
+ if (show)
+ {
+ gtk_label_set_text (GTK_LABEL (data->summary_label), string);
+ g_free (string);
+ gtk_widget_show (data->summary_label);
+ }
+ else
+ {
+ gtk_widget_hide (data->summary_label);
+ }
}
static void
gxi_update_string_box (GncXmlImportData *data)
{
- gchar *string;
- const gchar *utf8;
- GtkBox *vbox;
- GtkComboBox *combo;
- GtkListStore *store;
- GList *word_iter, *conv_iter;
- GtkCellRenderer *renderer;
- GtkTreeIter iter;
- GQuark chosen_encoding;
- GtkTreeIter *chosen_iter, *default_iter;
- ambiguous_type *amb;
- conv_type *conv;
+ gchar *string;
+ const gchar *utf8;
+ GtkBox *vbox;
+ GtkComboBox *combo;
+ GtkListStore *store;
+ GList *word_iter, *conv_iter;
+ GtkCellRenderer *renderer;
+ GtkTreeIter iter;
+ GQuark chosen_encoding;
+ GtkTreeIter *chosen_iter, *default_iter;
+ ambiguous_type *amb;
+ conv_type *conv;
- if (data->string_box)
- gtk_widget_destroy (data->string_box);
+ if (data->string_box)
+ gtk_widget_destroy (data->string_box);
- data->string_box = gtk_vbox_new (FALSE, 6);
- vbox = GTK_BOX (data->string_box);
+ data->string_box = gtk_vbox_new (FALSE, 6);
+ vbox = GTK_BOX (data->string_box);
- data->n_unassigned = 0;
+ data->n_unassigned = 0;
- /* loop through words */
- for (word_iter=data->ambiguous_list; word_iter; word_iter=word_iter->next) {
+ /* loop through words */
+ for (word_iter = data->ambiguous_list; word_iter; word_iter = word_iter->next)
+ {
- store = gtk_list_store_new (WORD_NUM_COLS, G_TYPE_STRING, G_TYPE_POINTER);
- combo = GTK_COMBO_BOX (gtk_combo_box_new_with_model (
- GTK_TREE_MODEL (store)));
- g_object_unref (store);
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,
- "text", WORD_COL_STRING, NULL);
+ store = gtk_list_store_new (WORD_NUM_COLS, G_TYPE_STRING, G_TYPE_POINTER);
+ combo = GTK_COMBO_BOX (gtk_combo_box_new_with_model (
+ GTK_TREE_MODEL (store)));
+ g_object_unref (store);
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,
+ "text", WORD_COL_STRING, NULL);
- /* add default string, if possible */
- amb = (ambiguous_type*) word_iter->data;
- utf8 = get_decoded_string (amb, data->default_encoding);
- default_iter = NULL;
- if (utf8) {
- string = g_strdup_printf ("%s (default)", utf8);
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter, WORD_COL_STRING, string,
- WORD_COL_ENCODING,
- GUINT_TO_POINTER (data->default_encoding), -1);
- g_free (string);
- default_iter = gtk_tree_iter_copy (&iter);
- }
+ /* add default string, if possible */
+ amb = (ambiguous_type*) word_iter->data;
+ utf8 = get_decoded_string (amb, data->default_encoding);
+ default_iter = NULL;
+ if (utf8)
+ {
+ string = g_strdup_printf ("%s (default)", utf8);
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, WORD_COL_STRING, string,
+ WORD_COL_ENCODING,
+ GUINT_TO_POINTER (data->default_encoding), -1);
+ g_free (string);
+ default_iter = gtk_tree_iter_copy (&iter);
+ }
- /* user has selected this previously */
- conv = (conv_type*) g_hash_table_lookup (data->choices, amb->byte_sequence);
- chosen_encoding = (conv) ? conv->encoding : 0;
- chosen_iter = NULL;
+ /* user has selected this previously */
+ conv = (conv_type*) g_hash_table_lookup (data->choices, amb->byte_sequence);
+ chosen_encoding = (conv) ? conv->encoding : 0;
+ chosen_iter = NULL;
- /* loop through conversions */
- for (conv_iter = amb->conv_list; conv_iter; conv_iter = conv_iter->next) {
- conv = (conv_type*) conv_iter->data;
- string = g_strdup_printf ("%s (%s)", conv->utf8_string,
- g_quark_to_string (conv->encoding));
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter, WORD_COL_STRING, string,
- WORD_COL_ENCODING,
- GUINT_TO_POINTER (conv->encoding), -1);
- g_free (string);
+ /* loop through conversions */
+ for (conv_iter = amb->conv_list; conv_iter; conv_iter = conv_iter->next)
+ {
+ conv = (conv_type*) conv_iter->data;
+ string = g_strdup_printf ("%s (%s)", conv->utf8_string,
+ g_quark_to_string (conv->encoding));
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, WORD_COL_STRING, string,
+ WORD_COL_ENCODING,
+ GUINT_TO_POINTER (conv->encoding), -1);
+ g_free (string);
- if (chosen_encoding && conv->encoding == chosen_encoding) {
- chosen_iter = gtk_tree_iter_copy (&iter);
- }
- } /* next conversion */
+ if (chosen_encoding && conv->encoding == chosen_encoding)
+ {
+ chosen_iter = gtk_tree_iter_copy (&iter);
+ }
+ } /* next conversion */
- if (chosen_iter) {
- /* select previous selection again, are not we cute */
- gtk_combo_box_set_active_iter (combo, chosen_iter);
- gtk_tree_iter_free (chosen_iter);
- } else {
- if (default_iter) {
- /* select default entry */
- gtk_combo_box_set_active_iter (combo, default_iter);
- } else {
- /* count it */
- data->n_unassigned++;
- }
- }
+ if (chosen_iter)
+ {
+ /* select previous selection again, are not we cute */
+ gtk_combo_box_set_active_iter (combo, chosen_iter);
+ gtk_tree_iter_free (chosen_iter);
+ }
+ else
+ {
+ if (default_iter)
+ {
+ /* select default entry */
+ gtk_combo_box_set_active_iter (combo, default_iter);
+ }
+ else
+ {
+ /* count it */
+ data->n_unassigned++;
+ }
+ }
- /* wire up combo */
- g_object_set_data (G_OBJECT (combo), "ambiguous", amb);
- g_signal_connect (G_OBJECT (combo), "changed",
- G_CALLBACK (gxi_string_combo_changed_cb), data);
- gtk_box_pack_start (vbox, GTK_WIDGET (combo), FALSE, FALSE, 0);
- gtk_widget_show (GTK_WIDGET (combo));
+ /* wire up combo */
+ g_object_set_data (G_OBJECT (combo), "ambiguous", amb);
+ g_signal_connect (G_OBJECT (combo), "changed",
+ G_CALLBACK (gxi_string_combo_changed_cb), data);
+ gtk_box_pack_start (vbox, GTK_WIDGET (combo), FALSE, FALSE, 0);
+ gtk_widget_show (GTK_WIDGET (combo));
- } /* next word */
+ } /* next word */
- /* wire up whole string vbox */
- gtk_container_add (GTK_CONTAINER (gnc_glade_lookup_widget (
- data->druid, "string_box_container")),
- GTK_WIDGET (vbox));
- gtk_widget_show (GTK_WIDGET (vbox));
+ /* wire up whole string vbox */
+ gtk_container_add (GTK_CONTAINER (gnc_glade_lookup_widget (
+ data->druid, "string_box_container")),
+ GTK_WIDGET (vbox));
+ gtk_widget_show (GTK_WIDGET (vbox));
- /* update label now, n_unassigned is calculated */
- if (!data->summary_label)
- data->summary_label = gnc_glade_lookup_widget (data->druid,
- "impossible_label");
- gxi_update_summary_label (data);
+ /* update label now, n_unassigned is calculated */
+ if (!data->summary_label)
+ data->summary_label = gnc_glade_lookup_widget (data->druid,
+ "impossible_label");
+ gxi_update_summary_label (data);
}
static void
gxi_update_conversion_forward (GncXmlImportData *data)
{
- if (data->n_unassigned || data->n_impossible)
- gnome_druid_set_buttons_sensitive (GNOME_DRUID (data->druid),
- TRUE, FALSE, TRUE, TRUE);
- else
- gnome_druid_set_buttons_sensitive (GNOME_DRUID (data->druid),
- TRUE, TRUE, TRUE, TRUE);
+ if (data->n_unassigned || data->n_impossible)
+ gnome_druid_set_buttons_sensitive (GNOME_DRUID (data->druid),
+ TRUE, FALSE, TRUE, TRUE);
+ else
+ gnome_druid_set_buttons_sensitive (GNOME_DRUID (data->druid),
+ TRUE, TRUE, TRUE, TRUE);
}
static GnomeDruidPage *
gxi_get_named_page (GncXmlImportData *data, const gchar *name)
{
- return GNOME_DRUID_PAGE (gnc_glade_lookup_widget (data->dialog, name));
+ return GNOME_DRUID_PAGE (gnc_glade_lookup_widget (data->dialog, name));
}
void
gxi_dialog_destroy_cb (GtkObject *object, GncXmlImportData *data)
{
- data->dialog = NULL;
- gxi_data_destroy (data);
+ data->dialog = NULL;
+ gxi_data_destroy (data);
}
void
gxi_cancel_cb (GnomeDruid *druid, GncXmlImportData *data)
{
- if (data->import_type == XML_CONVERT_SINGLE_FILE) {
- gtk_dialog_response (GTK_DIALOG (data->dialog), GTK_RESPONSE_CANCEL);
- } else {
- gtk_widget_destroy (data->dialog);
- }
+ if (data->import_type == XML_CONVERT_SINGLE_FILE)
+ {
+ gtk_dialog_response (GTK_DIALOG (data->dialog), GTK_RESPONSE_CANCEL);
+ }
+ else
+ {
+ gtk_widget_destroy (data->dialog);
+ }
}
static gint
file_filename_cmp (const GncXmlImportFile *file, const gchar *filename)
{
- return strcmp (file->filename, filename);
+ return strcmp (file->filename, filename);
}
static void
gxi_load_file (GncXmlImportData *data)
{
- GncXmlImportFile *file;
- gchar *filename;
- GtkTreeIter iter;
+ GncXmlImportFile *file;
+ gchar *filename;
+ GtkTreeIter iter;
- g_return_if_fail (data != NULL);
+ g_return_if_fail (data != NULL);
- filename = gtk_file_chooser_get_filename (
- GTK_FILE_CHOOSER (data->file_chooser));
+ filename = gtk_file_chooser_get_filename (
+ GTK_FILE_CHOOSER (data->file_chooser));
- if (filename == NULL) {
- return;
- }
- if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR)) {
- g_free (filename);
- return;
- }
+ if (filename == NULL)
+ {
+ return;
+ }
+ if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR))
+ {
+ g_free (filename);
+ return;
+ }
- if (g_list_find_custom (data->files, filename,
- (GCompareFunc) file_filename_cmp)) {
- const gchar *message = _(
- "That GnuCash XML file is already loaded. Please select another file.");
- gnc_error_dialog (data->dialog, "%s", message);
- g_free (filename);
- return;
- }
+ if (g_list_find_custom (data->files, filename,
+ (GCompareFunc) file_filename_cmp))
+ {
+ const gchar *message = _(
+ "That GnuCash XML file is already loaded. Please select another file.");
+ gnc_error_dialog (data->dialog, "%s", message);
+ g_free (filename);
+ return;
+ }
- file = g_new0 (GncXmlImportFile, 1);
- file->filename = filename;
+ file = g_new0 (GncXmlImportFile, 1);
+ file->filename = filename;
- data->files = g_list_append (data->files, file);
+ data->files = g_list_append (data->files, file);
- gtk_list_store_append (data->file_list_store, &iter);
- gtk_list_store_set (data->file_list_store, &iter,
- FILE_COL_NAME, filename,
- FILE_COL_INFO, file,
- -1);
- file->file_list_iter = gtk_tree_iter_copy (&iter);
+ gtk_list_store_append (data->file_list_store, &iter);
+ gtk_list_store_set (data->file_list_store, &iter,
+ FILE_COL_NAME, filename,
+ FILE_COL_INFO, file,
+ -1);
+ file->file_list_iter = gtk_tree_iter_copy (&iter);
- gnome_druid_set_page (
- GNOME_DRUID (data->druid),
-/* gxi_get_named_page (data, "loaded_files_page")); */
- gxi_get_named_page (data, "encodings_doc_page"));
+ gnome_druid_set_page (
+ GNOME_DRUID (data->druid),
+ /* gxi_get_named_page (data, "loaded_files_page")); */
+ gxi_get_named_page (data, "encodings_doc_page"));
}
static void
gxi_unload_file (GncXmlImportData *data, GncXmlImportFile *file)
{
- g_return_if_fail (data != NULL && file != NULL);
+ g_return_if_fail (data != NULL && file != NULL);
- data->files = g_list_remove (data->files, file);
- gtk_list_store_remove (data->file_list_store, file->file_list_iter);
- gtk_tree_iter_free (file->file_list_iter);
+ data->files = g_list_remove (data->files, file);
+ gtk_list_store_remove (data->file_list_store, file->file_list_iter);
+ gtk_tree_iter_free (file->file_list_iter);
- g_free (file->filename);
+ g_free (file->filename);
}
void
gxi_chooser_file_activated_cb (GtkFileChooser *chooser, GncXmlImportData *data)
{
- gxi_load_file (data);
+ gxi_load_file (data);
}
gboolean
gxi_load_file_next_cb (GnomeDruidPage *page, GtkWidget *widget,
GncXmlImportData *data)
{
- GtkFileChooser *chooser = GTK_FILE_CHOOSER (data->file_chooser);
- gchar *filename = gtk_file_chooser_get_filename (chooser);
+ GtkFileChooser *chooser = GTK_FILE_CHOOSER (data->file_chooser);
+ gchar *filename = gtk_file_chooser_get_filename (chooser);
- if (filename != NULL) {
- if (g_file_test (filename, G_FILE_TEST_IS_DIR)) {
- gtk_file_chooser_set_current_folder (chooser, filename);
- } else {
- gxi_load_file (data);
+ if (filename != NULL)
+ {
+ if (g_file_test (filename, G_FILE_TEST_IS_DIR))
+ {
+ gtk_file_chooser_set_current_folder (chooser, filename);
+ }
+ else
+ {
+ gxi_load_file (data);
+ }
+ g_free (filename);
}
- g_free (filename);
- }
- return TRUE;
+ return TRUE;
}
void
gxi_conversion_prepare_cb (GnomeDruidPage *page, GtkWidget *widget,
GncXmlImportData *data)
{
- gxi_update_conversion_forward (data);
+ gxi_update_conversion_forward (data);
}
static void
gxi_default_enc_combo_changed_cb (GtkComboBox *combo, GncXmlImportData *data)
{
- GtkTreeIter iter;
- gchar *enc_string;
- GQuark curr_enc;
+ GtkTreeIter iter;
+ gchar *enc_string;
+ GQuark curr_enc;
- if (!gtk_combo_box_get_active_iter (combo, &iter))
- return;
+ if (!gtk_combo_box_get_active_iter (combo, &iter))
+ return;
- gtk_tree_model_get (gtk_combo_box_get_model (combo), &iter,
- 0, &enc_string, -1);
- curr_enc = g_quark_from_string (enc_string);
- g_free (enc_string);
+ gtk_tree_model_get (gtk_combo_box_get_model (combo), &iter,
+ 0, &enc_string, -1);
+ curr_enc = g_quark_from_string (enc_string);
+ g_free (enc_string);
- if (data->default_encoding == curr_enc)
- return;
- if (!g_list_find (data->encodings, GUINT_TO_POINTER (curr_enc))) {
- /* should not happen */
- PERR("invalid encoding selection");
- return;
- }
+ if (data->default_encoding == curr_enc)
+ return;
+ if (!g_list_find (data->encodings, GUINT_TO_POINTER (curr_enc)))
+ {
+ /* should not happen */
+ PERR("invalid encoding selection");
+ return;
+ }
- data->default_encoding = curr_enc;
- gxi_sort_ambiguous_list (data);
- gxi_update_string_box (data);
- gxi_update_conversion_forward (data);
+ data->default_encoding = curr_enc;
+ gxi_sort_ambiguous_list (data);
+ gxi_update_string_box (data);
+ gxi_update_conversion_forward (data);
}
static void
gxi_string_combo_changed_cb (GtkComboBox *combo, GncXmlImportData *data)
{
- GtkTreeIter iter;
- GList *found, *default_conv;
- gboolean is_active;
- ambiguous_type *amb;
- conv_type *prev_conv, *curr_conv=NULL;
- gpointer ptr;
- GQuark prev_enc, curr_enc;
+ GtkTreeIter iter;
+ GList *found, *default_conv;
+ gboolean is_active;
+ ambiguous_type *amb;
+ conv_type *prev_conv, *curr_conv = NULL;
+ gpointer ptr;
+ GQuark prev_enc, curr_enc;
- amb = (ambiguous_type*) g_object_get_data (G_OBJECT (combo), "ambiguous");
- prev_conv = (conv_type*) g_hash_table_lookup (data->choices,
- amb->byte_sequence);
- if (prev_conv)
- prev_enc = prev_conv->encoding;
+ amb = (ambiguous_type*) g_object_get_data (G_OBJECT (combo), "ambiguous");
+ prev_conv = (conv_type*) g_hash_table_lookup (data->choices,
+ amb->byte_sequence);
+ if (prev_conv)
+ prev_enc = prev_conv->encoding;
- default_conv = g_list_find_custom (amb->conv_list, &data->default_encoding,
- (GCompareFunc) conv_enc_cmp);
+ default_conv = g_list_find_custom (amb->conv_list, &data->default_encoding,
+ (GCompareFunc) conv_enc_cmp);
- is_active = gtk_combo_box_get_active_iter (combo, &iter);
- if (is_active) {
- gtk_tree_model_get (gtk_combo_box_get_model (combo), &iter,
- WORD_COL_ENCODING, &ptr, -1);
- curr_enc = GPOINTER_TO_UINT (ptr);
- found = g_list_find_custom (amb->conv_list, &curr_enc,
- (GCompareFunc) conv_enc_cmp);
- if (found) {
- curr_conv = (conv_type*) found->data;
- } else {
- /* should not happen */
- PERR("invalid string selection");
- is_active = FALSE;
+ is_active = gtk_combo_box_get_active_iter (combo, &iter);
+ if (is_active)
+ {
+ gtk_tree_model_get (gtk_combo_box_get_model (combo), &iter,
+ WORD_COL_ENCODING, &ptr, -1);
+ curr_enc = GPOINTER_TO_UINT (ptr);
+ found = g_list_find_custom (amb->conv_list, &curr_enc,
+ (GCompareFunc) conv_enc_cmp);
+ if (found)
+ {
+ curr_conv = (conv_type*) found->data;
+ }
+ else
+ {
+ /* should not happen */
+ PERR("invalid string selection");
+ is_active = FALSE;
+ }
}
- }
- if (is_active) {
- if (prev_conv) {
- if (curr_enc == prev_enc)
- return;
+ if (is_active)
+ {
+ if (prev_conv)
+ {
+ if (curr_enc == prev_enc)
+ return;
- /* remember new choice */
- g_hash_table_replace (data->choices, g_strdup (amb->byte_sequence),
- conv_copy (curr_conv));
+ /* remember new choice */
+ g_hash_table_replace (data->choices, g_strdup (amb->byte_sequence),
+ conv_copy (curr_conv));
- found = g_list_find_custom (amb->conv_list, &prev_enc,
- (GCompareFunc) conv_enc_cmp);
- if (!found && !default_conv) {
- /* user selected encoding for a byte sequence undecodable in the default
- encoding, for the first time. previous selection is invalid now */
- data->n_unassigned--;
- gxi_update_summary_label (data);
- gxi_update_conversion_forward (data);
- }
- }
- else {
- /* first choice ever */
- g_hash_table_insert (data->choices, g_strdup (amb->byte_sequence),
- conv_copy (curr_conv));
+ found = g_list_find_custom (amb->conv_list, &prev_enc,
+ (GCompareFunc) conv_enc_cmp);
+ if (!found && !default_conv)
+ {
+ /* user selected encoding for a byte sequence undecodable in the default
+ encoding, for the first time. previous selection is invalid now */
+ data->n_unassigned--;
+ gxi_update_summary_label (data);
+ gxi_update_conversion_forward (data);
+ }
+ }
+ else
+ {
+ /* first choice ever */
+ g_hash_table_insert (data->choices, g_strdup (amb->byte_sequence),
+ conv_copy (curr_conv));
- if (!default_conv) {
- /* user selected encoding for a byte sequence undecodable in the default
- encoding, for the first time. no previous selection */
- data->n_unassigned--;
- gxi_update_summary_label (data);
- gxi_update_conversion_forward (data);
- }
+ if (!default_conv)
+ {
+ /* user selected encoding for a byte sequence undecodable in the default
+ encoding, for the first time. no previous selection */
+ data->n_unassigned--;
+ gxi_update_summary_label (data);
+ gxi_update_conversion_forward (data);
+ }
+ }
}
- }
- else {
- if (prev_conv) {
- /* user decided not to decide... however he did that */
- g_hash_table_remove (data->choices, amb->byte_sequence);
+ else
+ {
+ if (prev_conv)
+ {
+ /* user decided not to decide... however he did that */
+ g_hash_table_remove (data->choices, amb->byte_sequence);
- if (!default_conv) {
- /* user deselected encoding for a byte sequence undecodable in the
- default encoding */
- data->n_unassigned++;
- gxi_update_summary_label (data);
- gxi_update_conversion_forward (data);
- }
+ if (!default_conv)
+ {
+ /* user deselected encoding for a byte sequence undecodable in the
+ default encoding */
+ data->n_unassigned++;
+ gxi_update_summary_label (data);
+ gxi_update_conversion_forward (data);
+ }
+ }
+ /* the missing else clause means pure ignorance of this dialog ;-) */
}
- /* the missing else clause means pure ignorance of this dialog ;-) */
- }
}
void
gxi_edit_encodings_clicked_cb (GtkButton *button, GncXmlImportData *data)
{
- GladeXML *xml;
- GtkWidget *dialog;
- GtkListStore *list_store;
- GtkTreeStore *tree_store;
- GtkTreeIter iter, parent, *parent_ptr;
- GList *encodings_bak, *enc_iter;
- const gchar *encoding;
- gchar *string;
- system_encoding_type *system_enc;
- gpointer enc_ptr;
- gint i, j;
+ GladeXML *xml;
+ GtkWidget *dialog;
+ GtkListStore *list_store;
+ GtkTreeStore *tree_store;
+ GtkTreeIter iter, parent, *parent_ptr;
+ GList *encodings_bak, *enc_iter;
+ const gchar *encoding;
+ gchar *string;
+ system_encoding_type *system_enc;
+ gpointer enc_ptr;
+ gint i, j;
- xml = gnc_glade_xml_new (XML_GLADE_FILE, "Encodings Dialog");
- dialog = glade_xml_get_widget (xml, "Encodings Dialog");
- data->encodings_dialog = dialog;
- g_object_set_data_full (G_OBJECT (dialog), "xml", xml, g_object_unref);
- glade_xml_signal_autoconnect_full (xml, gnc_glade_autoconnect_full_func, data);
- gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (data->dialog));
+ xml = gnc_glade_xml_new (XML_GLADE_FILE, "Encodings Dialog");
+ dialog = glade_xml_get_widget (xml, "Encodings Dialog");
+ data->encodings_dialog = dialog;
+ g_object_set_data_full (G_OBJECT (dialog), "xml", xml, g_object_unref);
+ glade_xml_signal_autoconnect_full (xml, gnc_glade_autoconnect_full_func, data);
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (data->dialog));
- data->available_encs_view = GTK_TREE_VIEW (glade_xml_get_widget (
- xml, "available_encs_view"));
+ data->available_encs_view = GTK_TREE_VIEW (glade_xml_get_widget (
+ xml, "available_encs_view"));
- /* set up selected encodings list */
- data->selected_encs_view = GTK_TREE_VIEW (glade_xml_get_widget (
- xml, "selected_encs_view"));
- list_store = gtk_list_store_new (ENC_NUM_COLS, G_TYPE_STRING, G_TYPE_POINTER);
- for (enc_iter = data->encodings; enc_iter; enc_iter = enc_iter->next) {
- encoding = g_quark_to_string (GPOINTER_TO_UINT (enc_iter->data));
- gtk_list_store_append (list_store, &iter);
- gtk_list_store_set (list_store, &iter, ENC_COL_STRING, encoding,
- ENC_COL_QUARK, enc_iter->data, -1);
- }
- gtk_tree_view_insert_column_with_attributes (
- data->selected_encs_view, -1, NULL,
- gtk_cell_renderer_text_new (), "text", ENC_COL_STRING, NULL);
- gtk_tree_view_set_model (data->selected_encs_view,
- GTK_TREE_MODEL (list_store));
- g_object_unref (list_store);
+ /* set up selected encodings list */
+ data->selected_encs_view = GTK_TREE_VIEW (glade_xml_get_widget (
+ xml, "selected_encs_view"));
+ list_store = gtk_list_store_new (ENC_NUM_COLS, G_TYPE_STRING, G_TYPE_POINTER);
+ for (enc_iter = data->encodings; enc_iter; enc_iter = enc_iter->next)
+ {
+ encoding = g_quark_to_string (GPOINTER_TO_UINT (enc_iter->data));
+ gtk_list_store_append (list_store, &iter);
+ gtk_list_store_set (list_store, &iter, ENC_COL_STRING, encoding,
+ ENC_COL_QUARK, enc_iter->data, -1);
+ }
+ gtk_tree_view_insert_column_with_attributes (
+ data->selected_encs_view, -1, NULL,
+ gtk_cell_renderer_text_new (), "text", ENC_COL_STRING, NULL);
+ gtk_tree_view_set_model (data->selected_encs_view,
+ GTK_TREE_MODEL (list_store));
+ g_object_unref (list_store);
- /* set up system encodings list */
- data->available_encs_view = GTK_TREE_VIEW (glade_xml_get_widget (
- xml, "available_encs_view"));
- tree_store = gtk_tree_store_new (ENC_NUM_COLS, G_TYPE_STRING, G_TYPE_POINTER);
- for (i = 0, system_enc = system_encodings;
- i < n_system_encodings;
- i++, system_enc++) {
- if (i == 0) {
- /* first system encoding */
- parent_ptr = NULL;
- } else {
- parent_ptr = &iter;
- for (j = 0; j < system_enc->parent; j++)
- if (gtk_tree_model_iter_parent (GTK_TREE_MODEL (tree_store),
- &parent, &iter)) {
- /* go up one level */
- iter = parent;
- } else {
- /* no parent to toplevel element */
- parent_ptr = NULL;
+ /* set up system encodings list */
+ data->available_encs_view = GTK_TREE_VIEW (glade_xml_get_widget (
+ xml, "available_encs_view"));
+ tree_store = gtk_tree_store_new (ENC_NUM_COLS, G_TYPE_STRING, G_TYPE_POINTER);
+ for (i = 0, system_enc = system_encodings;
+ i < n_system_encodings;
+ i++, system_enc++)
+ {
+ if (i == 0)
+ {
+ /* first system encoding */
+ parent_ptr = NULL;
}
+ else
+ {
+ parent_ptr = &iter;
+ for (j = 0; j < system_enc->parent; j++)
+ if (gtk_tree_model_iter_parent (GTK_TREE_MODEL (tree_store),
+ &parent, &iter))
+ {
+ /* go up one level */
+ iter = parent;
+ }
+ else
+ {
+ /* no parent to toplevel element */
+ parent_ptr = NULL;
+ }
+ }
+ if (system_enc->encoding)
+ enc_ptr = GUINT_TO_POINTER (g_quark_from_string (system_enc->encoding));
+ else
+ enc_ptr = NULL;
+ string = gettext (system_enc->text);
+ gtk_tree_store_append (tree_store, &iter, parent_ptr);
+ gtk_tree_store_set (tree_store, &iter, ENC_COL_STRING,
+ gettext (system_enc->text), ENC_COL_QUARK, enc_ptr, -1);
}
- if (system_enc->encoding)
- enc_ptr = GUINT_TO_POINTER (g_quark_from_string (system_enc->encoding));
- else
- enc_ptr = NULL;
- string = gettext (system_enc->text);
- gtk_tree_store_append (tree_store, &iter, parent_ptr);
- gtk_tree_store_set (tree_store, &iter, ENC_COL_STRING,
- gettext (system_enc->text), ENC_COL_QUARK, enc_ptr, -1);
- }
- gtk_tree_view_insert_column_with_attributes (
- data->available_encs_view, -1, NULL,
- gtk_cell_renderer_text_new (), "text", ENC_COL_STRING, NULL);
- gtk_tree_view_set_model (data->available_encs_view,
- GTK_TREE_MODEL (tree_store));
- g_object_unref (tree_store);
+ gtk_tree_view_insert_column_with_attributes (
+ data->available_encs_view, -1, NULL,
+ gtk_cell_renderer_text_new (), "text", ENC_COL_STRING, NULL);
+ gtk_tree_view_set_model (data->available_encs_view,
+ GTK_TREE_MODEL (tree_store));
+ g_object_unref (tree_store);
- /* run the dialog */
- encodings_bak = g_list_copy (data->encodings);
- if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {
- g_list_free (encodings_bak);
- if (!g_list_find (data->encodings,
- GUINT_TO_POINTER (data->default_encoding))) {
- /* choose top level encoding then */
- data->default_encoding = GPOINTER_TO_UINT (data->encodings->data);
+ /* run the dialog */
+ encodings_bak = g_list_copy (data->encodings);
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
+ {
+ g_list_free (encodings_bak);
+ if (!g_list_find (data->encodings,
+ GUINT_TO_POINTER (data->default_encoding)))
+ {
+ /* choose top level encoding then */
+ data->default_encoding = GPOINTER_TO_UINT (data->encodings->data);
+ }
+
+ /* update whole page */
+ gxi_check_file (data);
+ gxi_update_default_enc_combo (data);
+ gxi_update_string_box (data);
+ gxi_update_conversion_forward (data);
}
+ else
+ {
+ g_list_free (data->encodings);
+ data->encodings = encodings_bak;
+ }
- /* update whole page */
- gxi_check_file (data);
- gxi_update_default_enc_combo (data);
- gxi_update_string_box (data);
- gxi_update_conversion_forward (data);
- }
- else {
- g_list_free (data->encodings);
- data->encodings = encodings_bak;
- }
-
- gtk_widget_destroy (dialog);
- data->encodings_dialog = NULL;
+ gtk_widget_destroy (dialog);
+ data->encodings_dialog = NULL;
}
static void
gxi_add_encoding (GncXmlImportData *data, gpointer encoding_ptr)
{
- GIConv iconv;
- const gchar *message;
- gchar *enc_string;
- GtkListStore *store;
- GtkTreeIter iter;
+ GIConv iconv;
+ const gchar *message;
+ gchar *enc_string;
+ GtkListStore *store;
+ GtkTreeIter iter;
- enc_string = g_ascii_strup (
- g_quark_to_string (GPOINTER_TO_UINT (encoding_ptr)), -1);
- encoding_ptr = GUINT_TO_POINTER (g_quark_from_string (enc_string));
+ enc_string = g_ascii_strup (
+ g_quark_to_string (GPOINTER_TO_UINT (encoding_ptr)), -1);
+ encoding_ptr = GUINT_TO_POINTER (g_quark_from_string (enc_string));
- if (g_list_find (data->encodings, encoding_ptr)) {
- message = _("This encoding has been added to the list already.");
- gnc_error_dialog (data->encodings_dialog, "%s", message);
- return;
- }
+ if (g_list_find (data->encodings, encoding_ptr))
+ {
+ message = _("This encoding has been added to the list already.");
+ gnc_error_dialog (data->encodings_dialog, "%s", message);
+ return;
+ }
- /* test whether we like this encoding */
- iconv = g_iconv_open ("UTF-8", enc_string);
- if (iconv == (GIConv) -1) {
+ /* test whether we like this encoding */
+ iconv = g_iconv_open ("UTF-8", enc_string);
+ if (iconv == (GIConv) - 1)
+ {
+ g_iconv_close (iconv);
+ g_free (enc_string);
+ message = _("This is an invalid encoding.");
+ gnc_error_dialog (data->encodings_dialog, "%s", message);
+ return;
+ }
g_iconv_close (iconv);
- g_free (enc_string);
- message = _("This is an invalid encoding.");
- gnc_error_dialog (data->encodings_dialog, "%s", message);
- return;
- }
- g_iconv_close (iconv);
- /* add to the list */
- data->encodings = g_list_append (data->encodings, encoding_ptr);
- store = GTK_LIST_STORE (gtk_tree_view_get_model (data->selected_encs_view));
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter, ENC_COL_STRING, enc_string,
- ENC_COL_QUARK, encoding_ptr, -1);
+ /* add to the list */
+ data->encodings = g_list_append (data->encodings, encoding_ptr);
+ store = GTK_LIST_STORE (gtk_tree_view_get_model (data->selected_encs_view));
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, ENC_COL_STRING, enc_string,
+ ENC_COL_QUARK, encoding_ptr, -1);
- g_free (enc_string);
+ g_free (enc_string);
- if (!data->encodings->next)
- gtk_dialog_set_response_sensitive (GTK_DIALOG (data->encodings_dialog),
- GTK_RESPONSE_OK, TRUE);
+ if (!data->encodings->next)
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (data->encodings_dialog),
+ GTK_RESPONSE_OK, TRUE);
}
void
@@ -1369,157 +1492,161 @@
GtkTreeViewColumn *column,
GncXmlImportData *data)
{
- GtkTreeModel *model;
- GtkTreeIter iter;
- gpointer enc_ptr;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gpointer enc_ptr;
- model = gtk_tree_view_get_model (data->available_encs_view);
- if (!gtk_tree_model_get_iter (model, &iter, path))
- return;
- gtk_tree_model_get (model, &iter, ENC_COL_QUARK, &enc_ptr, -1);
- if (!enc_ptr)
- return;
- gxi_add_encoding (data, enc_ptr);
+ model = gtk_tree_view_get_model (data->available_encs_view);
+ if (!gtk_tree_model_get_iter (model, &iter, path))
+ return;
+ gtk_tree_model_get (model, &iter, ENC_COL_QUARK, &enc_ptr, -1);
+ if (!enc_ptr)
+ return;
+ gxi_add_encoding (data, enc_ptr);
}
void
gxi_add_enc_clicked_cb (GtkButton *button, GncXmlImportData *data)
{
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gpointer enc_ptr;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gpointer enc_ptr;
- selection = gtk_tree_view_get_selection (data->available_encs_view);
- if (!gtk_tree_selection_get_selected (selection, &model, &iter))
- return;
- gtk_tree_model_get (model, &iter, ENC_COL_QUARK, &enc_ptr, -1);
- if (!enc_ptr)
- return;
- gxi_add_encoding (data, enc_ptr);
+ selection = gtk_tree_view_get_selection (data->available_encs_view);
+ if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+ return;
+ gtk_tree_model_get (model, &iter, ENC_COL_QUARK, &enc_ptr, -1);
+ if (!enc_ptr)
+ return;
+ gxi_add_encoding (data, enc_ptr);
}
void
gxi_custom_enc_activate_cb (GtkEntry *entry, GncXmlImportData *data)
{
- const gchar *enc_string;
+ const gchar *enc_string;
- enc_string = gtk_entry_get_text (entry);
- if (!enc_string)
- return;
- gxi_add_encoding (data, GUINT_TO_POINTER (g_quark_from_string (enc_string)));
+ enc_string = gtk_entry_get_text (entry);
+ if (!enc_string)
+ return;
+ gxi_add_encoding (data, GUINT_TO_POINTER (g_quark_from_string (enc_string)));
}
void
gxi_add_custom_enc_clicked_cb (GtkButton *button, GncXmlImportData *data)
{
- GtkWidget *entry = gnc_glade_lookup_widget (data->encodings_dialog,
- "custom_enc_entry");
- gxi_custom_enc_activate_cb (GTK_ENTRY (entry), data);
+ GtkWidget *entry = gnc_glade_lookup_widget (data->encodings_dialog,
+ "custom_enc_entry");
+ gxi_custom_enc_activate_cb (GTK_ENTRY (entry), data);
}
static void
gxi_remove_encoding (GncXmlImportData *data, GtkTreeModel *model,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
- gpointer enc_ptr;
+ gpointer enc_ptr;
- gtk_tree_model_get (model, iter, ENC_COL_QUARK, &enc_ptr, -1);
- data->encodings = g_list_remove (data->encodings, enc_ptr);
- gtk_list_store_remove (GTK_LIST_STORE (model), iter);
- if (!data->encodings)
- gtk_dialog_set_response_sensitive (GTK_DIALOG (data->encodings_dialog),
- GTK_RESPONSE_OK, FALSE);
+ gtk_tree_model_get (model, iter, ENC_COL_QUARK, &enc_ptr, -1);
+ data->encodings = g_list_remove (data->encodings, enc_ptr);
+ gtk_list_store_remove (GTK_LIST_STORE (model), iter);
+ if (!data->encodings)
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (data->encodings_dialog),
+ GTK_RESPONSE_OK, FALSE);
}
void
gxi_selected_enc_activated_cb (GtkTreeView *view, GtkTreePath *path,
GtkTreeViewColumn *column, GncXmlImportData *data)
{
- GtkTreeModel *model;
- GtkTreeIter iter;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
- model = gtk_tree_view_get_model (data->selected_encs_view);
- if (!gtk_tree_model_get_iter (model, &iter, path))
- return;
- gxi_remove_encoding (data, model, &iter);
+ model = gtk_tree_view_get_model (data->selected_encs_view);
+ if (!gtk_tree_model_get_iter (model, &iter, path))
+ return;
+ gxi_remove_encoding (data, model, &iter);
}
void
gxi_remove_enc_clicked_cb (GtkButton *button, GncXmlImportData *data)
{
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreeIter iter;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
- selection = gtk_tree_view_get_selection (data->selected_encs_view);
- if (!gtk_tree_selection_get_selected (selection, &model, &iter))
- return;
- gxi_remove_encoding (data, model, &iter);
+ selection = gtk_tree_view_get_selection (data->selected_encs_view);
+ if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+ return;
+ gxi_remove_encoding (data, model, &iter);
}
gboolean
gxi_conversion_next_cb (GnomeDruidPage *page, GtkWidget *widget,
GncXmlImportData *data)
{
- return !gxi_parse_file (data);
+ return !gxi_parse_file (data);
}
void
gxi_loaded_files_prepare_cb (GnomeDruidPage *page, GtkWidget *widget,
GncXmlImportData *data)
{
- gnome_druid_set_buttons_sensitive (GNOME_DRUID (data->druid),
- FALSE, TRUE, TRUE, TRUE);
+ gnome_druid_set_buttons_sensitive (GNOME_DRUID (data->druid),
+ FALSE, TRUE, TRUE, TRUE);
}
gboolean
gxi_loaded_files_next_cb (GnomeDruidPage *page, GtkWidget *widget,
GncXmlImportData *data)
{
- if (!g_list_first (data->files)) {
- const gchar *message = _(
- "No files to merge. Please add ones by clicking on 'Load another file'.");
- gnc_error_dialog (data->dialog, "%s", message);
- return TRUE;
- }
+ if (!g_list_first (data->files))
+ {
+ const gchar *message = _(
+ "No files to merge. Please add ones by clicking on 'Load another file'.");
+ gnc_error_dialog (data->dialog, "%s", message);
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
void
gxi_unload_file_clicked_cb (GtkButton *button, GncXmlImportData *data)
{
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GncXmlImportFile *file;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GncXmlImportFile *file;
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (data->file_list_view));
- if (!gtk_tree_selection_get_selected (selection, &model, &iter))
- return;
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (data->file_list_view));
+ if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+ return;
- gtk_tree_model_get (model, &iter, FILE_COL_INFO, &file, -1);
+ gtk_tree_model_get (model, &iter, FILE_COL_INFO, &file, -1);
- gxi_unload_file (data, file);
+ gxi_unload_file (data, file);
}
void
gxi_load_file_clicked_cb (GtkButton *button, GncXmlImportData *data)
{
- gnome_druid_set_page (GNOME_DRUID (data->druid),
- gxi_get_named_page (data, "load_file_page"));
+ gnome_druid_set_page (GNOME_DRUID (data->druid),
+ gxi_get_named_page (data, "load_file_page"));
}
void
gxi_end_finish_cb (GnomeDruidPage *page, GtkWidget *widget,
GncXmlImportData *data)
{
- if (data->import_type == XML_CONVERT_SINGLE_FILE) {
- gtk_dialog_response (GTK_DIALOG (data->dialog), GTK_RESPONSE_APPLY);
- } else {
- gtk_widget_destroy (data->dialog);
- }
+ if (data->import_type == XML_CONVERT_SINGLE_FILE)
+ {
+ gtk_dialog_response (GTK_DIALOG (data->dialog), GTK_RESPONSE_APPLY);
+ }
+ else
+ {
+ gtk_widget_destroy (data->dialog);
+ }
}
Modified: gnucash/trunk/src/gnome-utils/druid-utils.c
===================================================================
--- gnucash/trunk/src/gnome-utils/druid-utils.c 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/druid-utils.c 2010-03-02 21:42:11 UTC (rev 18791)
@@ -33,115 +33,122 @@
void
gnc_druid_set_watermark_images (GnomeDruid *druid,
- const char *top_path,
- const char *side_path)
+ const char *top_path,
+ const char *side_path)
{
- GdkPixbuf *top_pixbuf, *side_pixbuf;
- GList *page_list, *item;
- GtkWidget *page;
+ GdkPixbuf *top_pixbuf, *side_pixbuf;
+ GList *page_list, *item;
+ GtkWidget *page;
- page_list = gtk_container_get_children(GTK_CONTAINER(druid));
- top_pixbuf = gnc_gnome_get_gdkpixbuf(top_path);
- side_pixbuf = gnc_gnome_get_gdkpixbuf(side_path);
+ page_list = gtk_container_get_children(GTK_CONTAINER(druid));
+ top_pixbuf = gnc_gnome_get_gdkpixbuf(top_path);
+ side_pixbuf = gnc_gnome_get_gdkpixbuf(side_path);
- for (item = page_list; item; item = g_list_next(item)) {
- page = item->data;
- if (GNOME_IS_DRUID_PAGE_EDGE (page)) {
- GnomeDruidPageEdge *page_edge;
+ for (item = page_list; item; item = g_list_next(item))
+ {
+ page = item->data;
+ if (GNOME_IS_DRUID_PAGE_EDGE (page))
+ {
+ GnomeDruidPageEdge *page_edge;
- page_edge = GNOME_DRUID_PAGE_EDGE (page);
- gnome_druid_page_edge_set_top_watermark (page_edge, top_pixbuf);
- gnome_druid_page_edge_set_watermark (page_edge, side_pixbuf);
- } else {
- GnomeDruidPageStandard *page_standard;
+ page_edge = GNOME_DRUID_PAGE_EDGE (page);
+ gnome_druid_page_edge_set_top_watermark (page_edge, top_pixbuf);
+ gnome_druid_page_edge_set_watermark (page_edge, side_pixbuf);
+ }
+ else
+ {
+ GnomeDruidPageStandard *page_standard;
- page_standard = GNOME_DRUID_PAGE_STANDARD (page);
- gnome_druid_page_standard_set_top_watermark (page_standard, top_pixbuf);
+ page_standard = GNOME_DRUID_PAGE_STANDARD (page);
+ gnome_druid_page_standard_set_top_watermark (page_standard, top_pixbuf);
+ }
}
- }
- g_object_unref (G_OBJECT(side_pixbuf));
- g_object_unref (G_OBJECT(top_pixbuf));
- g_list_free(page_list);
+ g_object_unref (G_OBJECT(side_pixbuf));
+ g_object_unref (G_OBJECT(top_pixbuf));
+ g_list_free(page_list);
}
void
gnc_druid_set_logo_image (GnomeDruid *druid, char *image_path)
{
- GdkPixbuf *logo_pixbuf;
- GList *page_list, *item;
- GtkWidget *page;
+ GdkPixbuf *logo_pixbuf;
+ GList *page_list, *item;
+ GtkWidget *page;
- page_list = gtk_container_get_children(GTK_CONTAINER(druid));
- logo_pixbuf = gnc_gnome_get_gdkpixbuf(image_path);
+ page_list = gtk_container_get_children(GTK_CONTAINER(druid));
+ logo_pixbuf = gnc_gnome_get_gdkpixbuf(image_path);
- for (item = page_list; item; item = g_list_next(item)) {
- page = item->data;
- if (GNOME_IS_DRUID_PAGE_EDGE (page))
+ for (item = page_list; item; item = g_list_next(item))
{
- GnomeDruidPageEdge *page_edge;
+ page = item->data;
+ if (GNOME_IS_DRUID_PAGE_EDGE (page))
+ {
+ GnomeDruidPageEdge *page_edge;
- page_edge = GNOME_DRUID_PAGE_EDGE (page);
- gnome_druid_page_edge_set_logo (page_edge, logo_pixbuf);
- } else {
- GnomeDruidPageStandard *page_standard;
+ page_edge = GNOME_DRUID_PAGE_EDGE (page);
+ gnome_druid_page_edge_set_logo (page_edge, logo_pixbuf);
+ }
+ else
+ {
+ GnomeDruidPageStandard *page_standard;
- page_standard = GNOME_DRUID_PAGE_STANDARD (page);
- gnome_druid_page_standard_set_logo (page_standard, logo_pixbuf);
- }
- }
+ page_standard = GNOME_DRUID_PAGE_STANDARD (page);
+ gnome_druid_page_standard_set_logo (page_standard, logo_pixbuf);
+ }
+ }
- g_object_unref (G_OBJECT(logo_pixbuf));
- g_list_free(page_list);
+ g_object_unref (G_OBJECT(logo_pixbuf));
+ g_list_free(page_list);
}
void
gnc_druid_set_colors (GnomeDruid *druid)
{
- GList *pages = gtk_container_get_children (GTK_CONTAINER (druid));
- GList *item = pages;
- GdkColor bluish;
- GdkColor white;
- GdkColormap *cm;
+ GList *pages = gtk_container_get_children (GTK_CONTAINER (druid));
+ GList *item = pages;
+ GdkColor bluish;
+ GdkColor white;
+ GdkColormap *cm;
- if (!druid) return;
- if (!GNOME_IS_DRUID (druid)) return;
+ if (!druid) return;
+ if (!GNOME_IS_DRUID (druid)) return;
- bluish.red = (gushort) (.40 * 65535);
- bluish.green = (gushort) (.40 * 65535);
- bluish.blue = (gushort) (.60 * 65535);
+ bluish.red = (gushort) (.40 * 65535);
+ bluish.green = (gushort) (.40 * 65535);
+ bluish.blue = (gushort) (.60 * 65535);
- white.red = 65535;
- white.green = 65535;
- white.blue = 65535;
+ white.red = 65535;
+ white.green = 65535;
+ white.blue = 65535;
- cm = gtk_widget_get_colormap (GTK_WIDGET (druid));
+ cm = gtk_widget_get_colormap (GTK_WIDGET (druid));
- gdk_colormap_alloc_color(cm, &bluish, FALSE, TRUE);
- gdk_colormap_alloc_color(cm, &white, FALSE, TRUE);
+ gdk_colormap_alloc_color(cm, &bluish, FALSE, TRUE);
+ gdk_colormap_alloc_color(cm, &white, FALSE, TRUE);
- while (item != NULL)
- {
- GnomeDruidPage *page = GNOME_DRUID_PAGE (item->data);
-
- if (GNOME_IS_DRUID_PAGE_EDGE (page))
+ while (item != NULL)
{
- GnomeDruidPageEdge *page_edge;
+ GnomeDruidPage *page = GNOME_DRUID_PAGE (item->data);
- page_edge = GNOME_DRUID_PAGE_EDGE (page);
- gnome_druid_page_edge_set_bg_color (page_edge, &bluish);
- gnome_druid_page_edge_set_logo_bg_color (page_edge, &bluish);
+ if (GNOME_IS_DRUID_PAGE_EDGE (page))
+ {
+ GnomeDruidPageEdge *page_edge;
+
+ page_edge = GNOME_DRUID_PAGE_EDGE (page);
+ gnome_druid_page_edge_set_bg_color (page_edge, &bluish);
+ gnome_druid_page_edge_set_logo_bg_color (page_edge, &bluish);
+ }
+ else
+ {
+ GnomeDruidPageStandard *page_standard;
+
+ page_standard = GNOME_DRUID_PAGE_STANDARD (page);
+ gnome_druid_page_standard_set_background (page_standard, &bluish);
+ gnome_druid_page_standard_set_logo_background (page_standard, &bluish);
+ gnome_druid_page_standard_set_title_foreground (page_standard, &white);
+ }
+ item = item->next;
}
- else
- {
- GnomeDruidPageStandard *page_standard;
-
- page_standard = GNOME_DRUID_PAGE_STANDARD (page);
- gnome_druid_page_standard_set_background (page_standard, &bluish);
- gnome_druid_page_standard_set_logo_background (page_standard, &bluish);
- gnome_druid_page_standard_set_title_foreground (page_standard, &white);
- }
- item = item->next;
- }
- g_list_free(pages);
+ g_list_free(pages);
}
Modified: gnucash/trunk/src/gnome-utils/druid-utils.h
===================================================================
--- gnucash/trunk/src/gnome-utils/druid-utils.h 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/druid-utils.h 2010-03-02 21:42:11 UTC (rev 18791)
@@ -27,8 +27,8 @@
#include <libgnomeui/gnome-druid.h>
void gnc_druid_set_watermark_images (GnomeDruid *druid,
- const char *top_path,
- const char *side_path);
+ const char *top_path,
+ const char *side_path);
void gnc_druid_set_logo_image (GnomeDruid *druid, char *image_path);
void gnc_druid_set_colors (GnomeDruid *druid);
Modified: gnucash/trunk/src/gnome-utils/gnc-account-sel.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-account-sel.c 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/gnc-account-sel.c 2010-03-02 21:42:11 UTC (rev 18791)
@@ -43,14 +43,15 @@
/* Signal codes */
enum
{
- ACCOUNT_SEL_CHANGED,
- LAST_SIGNAL
+ ACCOUNT_SEL_CHANGED,
+ LAST_SIGNAL
};
-enum account_cols {
- ACCT_COL_NAME = 0,
- ACCT_COL_PTR,
- NUM_ACCT_COLS
+enum account_cols
+{
+ ACCT_COL_NAME = 0,
+ ACCT_COL_PTR,
+ NUM_ACCT_COLS
};
static guint account_sel_signals [LAST_SIGNAL] = { 0 };
@@ -71,27 +72,29 @@
GType
gnc_account_sel_get_type (void)
{
- static GType account_sel_type = 0;
+ static GType account_sel_type = 0;
- if (account_sel_type == 0) {
- GTypeInfo account_sel_info = {
- sizeof (GNCAccountSelClass),
- NULL,
- NULL,
- (GClassInitFunc) gnc_account_sel_class_init,
- NULL,
- NULL,
- sizeof (GNCAccountSel),
- 0,
- (GInstanceInitFunc) gnc_account_sel_init
- };
+ if (account_sel_type == 0)
+ {
+ GTypeInfo account_sel_info =
+ {
+ sizeof (GNCAccountSelClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) gnc_account_sel_class_init,
+ NULL,
+ NULL,
+ sizeof (GNCAccountSel),
+ 0,
+ (GInstanceInitFunc) gnc_account_sel_init
+ };
- account_sel_type = g_type_register_static (GTK_TYPE_HBOX,
- "GNCAccountSel",
- &account_sel_info, 0);
- }
+ account_sel_type = g_type_register_static (GTK_TYPE_HBOX,
+ "GNCAccountSel",
+ &account_sel_info, 0);
+ }
- return account_sel_type;
+ return account_sel_type;
}
static
@@ -99,412 +102,438 @@
gnc_account_sel_event_cb( QofInstance *entity,
QofEventId event_type,
gpointer user_data,
- gpointer event_data )
+ gpointer event_data )
{
- if ( ! ( event_type == QOF_EVENT_CREATE
- || event_type == QOF_EVENT_MODIFY
- || event_type == QOF_EVENT_DESTROY )
- || !GNC_IS_ACCOUNT(entity) ) {
- return;
- }
- gas_populate_list( (GNCAccountSel*)user_data );
+ if ( ! ( event_type == QOF_EVENT_CREATE
+ || event_type == QOF_EVENT_MODIFY
+ || event_type == QOF_EVENT_DESTROY )
+ || !GNC_IS_ACCOUNT(entity) )
+ {
+ return;
+ }
+ gas_populate_list( (GNCAccountSel*)user_data );
}
static
void
gnc_account_sel_class_init (GNCAccountSelClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- parent_class = g_type_class_peek_parent (klass);
+ parent_class = g_type_class_peek_parent (klass);
- object_class->finalize = gnc_account_sel_finalize;
- object_class->dispose = gnc_account_sel_dispose;
+ object_class->finalize = gnc_account_sel_finalize;
+ object_class->dispose = gnc_account_sel_dispose;
- account_sel_signals [ACCOUNT_SEL_CHANGED] =
- g_signal_new ("account_sel_changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GNCAccountSelClass, account_sel_changed),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
+ account_sel_signals [ACCOUNT_SEL_CHANGED] =
+ g_signal_new ("account_sel_changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GNCAccountSelClass, account_sel_changed),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
}
static void
combo_changed_cb(GNCAccountSel *gas, gpointer combo)
{
- g_signal_emit_by_name(gas, "account_sel_changed");
+ g_signal_emit_by_name(gas, "account_sel_changed");
}
static void
gnc_account_sel_init (GNCAccountSel *gas)
{
- GtkWidget *widget;
+ GtkWidget *widget;
- gas->initDone = FALSE;
- gas->acctTypeFilters = FALSE;
- gas->newAccountButton = NULL;
+ gas->initDone = FALSE;
+ gas->acctTypeFilters = FALSE;
+ gas->newAccountButton = NULL;
- g_object_set(gas, "spacing", 2, (gchar*)NULL);
+ g_object_set(gas, "spacing", 2, (gchar*)NULL);
- gas->store = gtk_list_store_new(NUM_ACCT_COLS, G_TYPE_STRING, G_TYPE_POINTER);
- widget =
- gtk_combo_box_entry_new_with_model(GTK_TREE_MODEL(gas->store), ACCT_COL_NAME);
- gas->combo = GTK_COMBO_BOX_ENTRY(widget);
- gtk_combo_box_set_model(GTK_COMBO_BOX(widget),
- GTK_TREE_MODEL(gas->store));
- g_object_unref(gas->store);
- g_signal_connect_swapped(gas->combo, "changed",
- G_CALLBACK(combo_changed_cb), gas);
- gtk_container_add( GTK_CONTAINER(gas), widget );
+ gas->store = gtk_list_store_new(NUM_ACCT_COLS, G_TYPE_STRING, G_TYPE_POINTER);
+ widget =
+ gtk_combo_box_entry_new_with_model(GTK_TREE_MODEL(gas->store), ACCT_COL_NAME);
+ gas->combo = GTK_COMBO_BOX_ENTRY(widget);
+ gtk_combo_box_set_model(GTK_COMBO_BOX(widget),
+ GTK_TREE_MODEL(gas->store));
+ g_object_unref(gas->store);
+ g_signal_connect_swapped(gas->combo, "changed",
+ G_CALLBACK(combo_changed_cb), gas);
+ gtk_container_add( GTK_CONTAINER(gas), widget );
- /* Add completion. */
- gnc_cbe_require_list_item(GTK_COMBO_BOX_ENTRY(widget));
+ /* Add completion. */
+ gnc_cbe_require_list_item(GTK_COMBO_BOX_ENTRY(widget));
- /* Get the accounts, place into combo list */
- gas_populate_list( gas );
+ /* Get the accounts, place into combo list */
+ gas_populate_list( gas );
- gas->eventHandlerId =
- qof_event_register_handler( gnc_account_sel_event_cb, gas );
+ gas->eventHandlerId =
+ qof_event_register_handler( gnc_account_sel_event_cb, gas );
- gas->initDone = TRUE;
+ gas->initDone = TRUE;
}
-typedef struct {
- GNCAccountSel *gas;
- GList **outList;
+typedef struct
+{
+ GNCAccountSel *gas;
+ GList **outList;
} account_filter_data;
static
void
gas_populate_list( GNCAccountSel *gas )
{
- account_filter_data atnd;
- Account *root;
- Account *acc;
- GtkTreeIter iter;
- GtkEntry *entry;
- gint i, active = -1;
- GList *accts, *ptr, *filteredAccts;
- gchar *currentSel, *name;
+ account_filter_data atnd;
+ Account *root;
+ Account *acc;
+ GtkTreeIter iter;
+ GtkEntry *entry;
+ gint i, active = -1;
+ GList *accts, *ptr, *filteredAccts;
+ gchar *currentSel, *name;
- entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(gas->combo)));
- currentSel = gtk_editable_get_chars(
- GTK_EDITABLE(entry), 0, -1 );
+ entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(gas->combo)));
+ currentSel = gtk_editable_get_chars(
+ GTK_EDITABLE(entry), 0, -1 );
- root = gnc_book_get_root_account( gnc_get_current_book() );
- accts = gnc_account_get_descendants_sorted( root );
+ root = gnc_book_get_root_account( gnc_get_current_book() );
+ accts = gnc_account_get_descendants_sorted( root );
- filteredAccts = NULL;
- atnd.gas = gas;
- atnd.outList = &filteredAccts;
+ filteredAccts = NULL;
+ atnd.gas = gas;
+ atnd.outList = &filteredAccts;
- g_list_foreach( accts, gas_filter_accounts, (gpointer)&atnd );
- g_list_free( accts );
+ g_list_foreach( accts, gas_filter_accounts, (gpointer)&atnd );
+ g_list_free( accts );
- gtk_list_store_clear(gas->store);
- for (ptr = filteredAccts, i = 0; ptr; ptr = g_list_next(ptr), i++) {
- acc = ptr->data;
- name = gnc_account_get_full_name(acc);
- gtk_list_store_append(gas->store, &iter);
- gtk_list_store_set(gas->store, &iter,
- ACCT_COL_NAME, name,
- ACCT_COL_PTR, acc,
- -1);
- if (g_utf8_collate(name, currentSel) == 0) {
- active = i;
- g_free(name);
- }
- }
+ gtk_list_store_clear(gas->store);
+ for (ptr = filteredAccts, i = 0; ptr; ptr = g_list_next(ptr), i++)
+ {
+ acc = ptr->data;
+ name = gnc_account_get_full_name(acc);
+ gtk_list_store_append(gas->store, &iter);
+ gtk_list_store_set(gas->store, &iter,
+ ACCT_COL_NAME, name,
+ ACCT_COL_PTR, acc,
+ -1);
+ if (g_utf8_collate(name, currentSel) == 0)
+ {
+ active = i;
+ g_free(name);
+ }
+ }
- /* If the account which was in the text box before still exists, then
- * reset to it. */
- if (active != -1)
- gtk_combo_box_set_active(GTK_COMBO_BOX(gas->combo), active);
+ /* If the account which was in the text box before still exists, then
+ * reset to it. */
+ if (active != -1)
+ gtk_combo_box_set_active(GTK_COMBO_BOX(gas->combo), active);
- g_list_free( filteredAccts );
- if ( currentSel ) {
- g_free( currentSel );
- }
+ g_list_free( filteredAccts );
+ if ( currentSel )
+ {
+ g_free( currentSel );
+ }
}
static
void
gas_filter_accounts( gpointer data, gpointer user_data )
{
- account_filter_data *atnd;
- Account *a;
+ account_filter_data *atnd;
+ Account *a;
- atnd = (account_filter_data*)user_data;
- a = (Account*)data;
- /* Filter as we've been configured to do. */
- if ( atnd->gas->acctTypeFilters ) {
- /* g_list_find is the poor-mans '(member ...)', especially
- * easy when the data pointers in the list are just casted
- * account type identifiers. */
- if ( g_list_find( atnd->gas->acctTypeFilters,
- GINT_TO_POINTER(xaccAccountGetType( a )) )
- == NULL ) {
- return;
- }
+ atnd = (account_filter_data*)user_data;
+ a = (Account*)data;
+ /* Filter as we've been configured to do. */
+ if ( atnd->gas->acctTypeFilters )
+ {
+ /* g_list_find is the poor-mans '(member ...)', especially
+ * easy when the data pointers in the list are just casted
+ * account type identifiers. */
+ if ( g_list_find( atnd->gas->acctTypeFilters,
+ GINT_TO_POINTER(xaccAccountGetType( a )) )
+ == NULL )
+ {
+ return;
}
+ }
- if ( atnd->gas->acctCommodityFilters ) {
- if ( g_list_find_custom( atnd->gas->acctCommodityFilters,
- GINT_TO_POINTER(xaccAccountGetCommodity( a )),
- gnc_commodity_compare_void)
- == NULL ) {
- return;
- }
+ if ( atnd->gas->acctCommodityFilters )
+ {
+ if ( g_list_find_custom( atnd->gas->acctCommodityFilters,
+ GINT_TO_POINTER(xaccAccountGetCommodity( a )),
+ gnc_commodity_compare_void)
+ == NULL )
+ {
+ return;
}
+ }
-
- *atnd->outList = g_list_append( *atnd->outList, a );
+
+ *atnd->outList = g_list_append( *atnd->outList, a );
}
GtkWidget *
gnc_account_sel_new (void)
{
- GNCAccountSel *gas;
+ GNCAccountSel *gas;
- gas = g_object_new (GNC_TYPE_ACCOUNT_SEL, NULL);
+ gas = g_object_new (GNC_TYPE_ACCOUNT_SEL, NULL);
- return GTK_WIDGET (gas);
+ return GTK_WIDGET (gas);
}
-typedef struct {
- GNCAccountSel *gas;
- Account *acct;
+typedef struct
+{
+ GNCAccountSel *gas;
+ Account *acct;
} gas_find_data;
static
gboolean
gnc_account_sel_find_account (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gas_find_data *data)
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gas_find_data *data)
{
- Account *model_acc;
+ Account *model_acc;
- gtk_tree_model_get(model, iter, ACCT_COL_PTR, &model_acc, -1);
- if (data->acct != model_acc)
- return FALSE;
+ gtk_tree_model_get(model, iter, ACCT_COL_PTR, &model_acc, -1);
+ if (data->acct != model_acc)
+ return FALSE;
- gtk_combo_box_set_active_iter(GTK_COMBO_BOX(data->gas->combo), iter);
- return TRUE;
+ gtk_combo_box_set_active_iter(GTK_COMBO_BOX(data->gas->combo), iter);
+ return TRUE;
}
void
gnc_account_sel_set_account( GNCAccountSel *gas, Account *acct, gboolean set_default_acct )
{
- gas_find_data data;
+ gas_find_data data;
- if (set_default_acct)
- {
- gtk_combo_box_set_active(GTK_COMBO_BOX(gas->combo), 0);
- }
- else
- {
- gtk_combo_box_set_active( GTK_COMBO_BOX(gas->combo), -1 );
- }
- if ( acct == NULL )
- return;
+ if (set_default_acct)
+ {
+ gtk_combo_box_set_active(GTK_COMBO_BOX(gas->combo), 0);
+ }
+ else
+ {
+ gtk_combo_box_set_active( GTK_COMBO_BOX(gas->combo), -1 );
+ }
+ if ( acct == NULL )
+ return;
- data.gas = gas;
- data.acct = acct;
- gtk_tree_model_foreach(GTK_TREE_MODEL(gas->store),
- (GtkTreeModelForeachFunc)gnc_account_sel_find_account,
- &data);
+ data.gas = gas;
+ data.acct = acct;
+ gtk_tree_model_foreach(GTK_TREE_MODEL(gas->store),
+ (GtkTreeModelForeachFunc)gnc_account_sel_find_account,
+ &data);
}
Account*
gnc_account_sel_get_account( GNCAccountSel *gas )
{
- GtkTreeIter iter;
- Account *acc;
+ GtkTreeIter iter;
+ Account *acc;
- if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(gas->combo), &iter))
- return NULL;
+ if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(gas->combo), &iter))
+ return NULL;
- gtk_tree_model_get(GTK_TREE_MODEL(gas->store), &iter,
- ACCT_COL_PTR, &acc,
- -1);
- return acc;
+ gtk_tree_model_get(GTK_TREE_MODEL(gas->store), &iter,
+ ACCT_COL_PTR, &acc,
+ -1);
+ return acc;
}
void
gnc_account_sel_set_acct_filters( GNCAccountSel *gas, GList *typeFilters, GList *commodityFilters )
{
- GList *src=NULL;
- GList *dest=NULL;
- gnc_commodity* commClone=NULL;
+ GList *src = NULL;
+ GList *dest = NULL;
+ gnc_commodity* commClone = NULL;
- if ( gas->acctTypeFilters != NULL ) {
- g_list_free( gas->acctTypeFilters );
- gas->acctTypeFilters = NULL;
- }
+ if ( gas->acctTypeFilters != NULL )
+ {
+ g_list_free( gas->acctTypeFilters );
+ gas->acctTypeFilters = NULL;
+ }
- if ( gas->acctCommodityFilters != NULL) {
- g_list_free( gas->acctCommodityFilters );
- gas->acctCommodityFilters = NULL;
- }
+ if ( gas->acctCommodityFilters != NULL)
+ {
+ g_list_free( gas->acctCommodityFilters );
+ gas->acctCommodityFilters = NULL;
+ }
- /* If both filters are null, then no filters exist. */
- if (( ! typeFilters ) && ( ! commodityFilters)) {
- return;
- }
+ /* If both filters are null, then no filters exist. */
+ if (( ! typeFilters ) && ( ! commodityFilters))
+ {
+ return;
+ }
- /* This works because the GNCAccountTypes in the list are
- * ints-casted-as-pointers. */
- if (typeFilters)
- {
- gas->acctTypeFilters = g_list_copy( typeFilters );
- }
+ /* This works because the GNCAccountTypes in the list are
+ * ints-casted-as-pointers. */
+ if (typeFilters)
+ {
+ gas->acctTypeFilters = g_list_copy( typeFilters );
+ }
- /* Save the commodity filter list */
- if (commodityFilters)
- {
- gas->acctCommodityFilters = g_list_copy(commodityFilters);
- }
+ /* Save the commodity filter list */
+ if (commodityFilters)
+ {
+ gas->acctCommodityFilters = g_list_copy(commodityFilters);
+ }
- gas_populate_list( gas );
+ gas_populate_list( gas );
}
static void
gnc_account_sel_finalize (GObject *object)
{
- GNCAccountSel *gas;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (GNC_IS_ACCOUNT_SEL (object));
+ GNCAccountSel *gas;
- gas = GNC_ACCOUNT_SEL (object);
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GNC_IS_ACCOUNT_SEL (object));
- if (gas->acctTypeFilters) {
- g_list_free (gas->acctTypeFilters);
- }
+ gas = GNC_ACCOUNT_SEL (object);
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ if (gas->acctTypeFilters)
+ {
+ g_list_free (gas->acctTypeFilters);
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gnc_account_sel_dispose (GObject *object)
{
- GNCAccountSel *gas;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (GNC_IS_ACCOUNT_SEL (object));
+ GNCAccountSel *gas;
- gas = GNC_ACCOUNT_SEL (object);
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GNC_IS_ACCOUNT_SEL (object));
- if (gas->eventHandlerId) {
- qof_event_unregister_handler (gas->eventHandlerId);
- gas->eventHandlerId = 0;
- }
+ gas = GNC_ACCOUNT_SEL (object);
- G_OBJECT_CLASS (parent_class)->dispose (object);
+ if (gas->eventHandlerId)
+ {
+ qof_event_unregister_handler (gas->eventHandlerId);
+ gas->eventHandlerId = 0;
+ }
+
+ G_OBJECT_CLASS (parent_class)->dispose (object);
}
void
gnc_account_sel_set_new_account_ability( GNCAccountSel *gas,
- gboolean state )
+ gboolean state )
{
- g_return_if_fail (gas != NULL);
+ g_return_if_fail (gas != NULL);
- if ( state == (gas->newAccountButton != NULL) ) {
- /* We're already in that state; don't do anything. */
- return;
- }
+ if ( state == (gas->newAccountButton != NULL) )
+ {
+ /* We're already in that state; don't do anything. */
+ return;
+ }
- if ( gas->newAccountButton ) {
- g_assert( state == TRUE );
- /* destroy the existing button. */
- gtk_container_remove( GTK_CONTAINER(gas),
- gas->newAccountButton );
- gtk_widget_destroy( gas->newAccountButton );
- gas->newAccountButton = NULL;
- return;
- }
-
- /* create the button. */
- gas->newAccountButton = gtk_button_new_with_label( _("New...") );
- g_signal_connect( gas->newAccountButton,
- "clicked",
- G_CALLBACK( gas_new_account_click ),
- gas );
- gtk_box_pack_start( GTK_BOX(gas), gas->newAccountButton,
- FALSE, FALSE, 0 );
+ if ( gas->newAccountButton )
+ {
+ g_assert( state == TRUE );
+ /* destroy the existing button. */
+ gtk_container_remove( GTK_CONTAINER(gas),
+ gas->newAccountButton );
+ gtk_widget_destroy( gas->newAccountButton );
+ gas->newAccountButton = NULL;
+ return;
+ }
+
+ /* create the button. */
+ gas->newAccountButton = gtk_button_new_with_label( _("New...") );
+ g_signal_connect( gas->newAccountButton,
+ "clicked",
+ G_CALLBACK( gas_new_account_click ),
+ gas );
+ gtk_box_pack_start( GTK_BOX(gas), gas->newAccountButton,
+ FALSE, FALSE, 0 );
}
void
gnc_account_sel_set_new_account_modal( GNCAccountSel *gas,
- gboolean state )
+ gboolean state )
{
- g_return_if_fail (gas != NULL);
- gas->isModal = state;
+ g_return_if_fail (gas != NULL);
+ gas->isModal = state;
}
static void
gas_new_account_click( GtkButton *b, gpointer ud )
{
- GNCAccountSel *gas = (GNCAccountSel*)ud;
- if (gas->isModal)
- gnc_ui_new_accounts_from_name_window_with_types ( NULL,
- gas->acctTypeFilters );
- else
- gnc_ui_new_account_with_types( gnc_get_current_book(), gas->acctTypeFilters );
+ GNCAccountSel *gas = (GNCAccountSel*)ud;
+ if (gas->isModal)
+ gnc_ui_new_accounts_from_name_window_with_types ( NULL,
+ gas->acctTypeFilters );
+ else
+ gnc_ui_new_account_with_types( gnc_get_current_book(), gas->acctTypeFilters );
}
gint
gnc_account_sel_get_num_account( GNCAccountSel *gas )
{
- if (NULL == gas)
- return 0;
- return gtk_tree_model_iter_n_children( GTK_TREE_MODEL(gas->store), NULL );
+ if (NULL == gas)
+ return 0;
+ return gtk_tree_model_iter_n_children( GTK_TREE_MODEL(gas->store), NULL );
}
void
gnc_account_sel_purge_account( GNCAccountSel *gas,
- Account *target,
- gboolean recursive)
+ Account *target,
+ gboolean recursive)
{
- GtkTreeModel *model = GTK_TREE_MODEL(gas->store);
- GtkTreeIter iter;
- Account *acc;
- gboolean more;
+ GtkTreeModel *model = GTK_TREE_MODEL(gas->store);
+ GtkTreeIter iter;
+ Account *acc;
+ gboolean more;
- if (!gtk_tree_model_get_iter_first(model, &iter))
- return;
+ if (!gtk_tree_model_get_iter_first(model, &iter))
+ return;
- if (!recursive) {
- do {
- gtk_tree_model_get(model, &iter, ACCT_COL_PTR, &acc, -1);
- if (acc == target) {
- gtk_list_store_remove(gas->store, &iter);
- break;
- }
- } while (gtk_tree_model_iter_next(model, &iter));
- } else {
- do {
- gtk_tree_model_get(model, &iter, ACCT_COL_PTR, &acc, -1);
- while (acc) {
- if (acc == target)
- break;
- acc = gnc_account_get_parent(acc);
- }
+ if (!recursive)
+ {
+ do
+ {
+ gtk_tree_model_get(model, &iter, ACCT_COL_PTR, &acc, -1);
+ if (acc == target)
+ {
+ gtk_list_store_remove(gas->store, &iter);
+ break;
+ }
+ }
+ while (gtk_tree_model_iter_next(model, &iter));
+ }
+ else
+ {
+ do
+ {
+ gtk_tree_model_get(model, &iter, ACCT_COL_PTR, &acc, -1);
+ while (acc)
+ {
+ if (acc == target)
+ break;
+ acc = gnc_account_get_parent(acc);
+ }
- if (acc == target)
- more = gtk_list_store_remove(gas->store, &iter);
- else
- more = gtk_tree_model_iter_next(model, &iter);
- } while (more);
- }
+ if (acc == target)
+ more = gtk_list_store_remove(gas->store, &iter);
+ else
+ more = gtk_tree_model_iter_next(model, &iter);
+ }
+ while (more);
+ }
- gtk_combo_box_set_active(GTK_COMBO_BOX(gas->combo), 0);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(gas->combo), 0);
}
Modified: gnucash/trunk/src/gnome-utils/gnc-account-sel.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-account-sel.h 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/gnc-account-sel.h 2010-03-02 21:42:11 UTC (rev 18791)
@@ -33,36 +33,36 @@
#include "Account.h"
-#define GNC_TYPE_ACCOUNT_SEL (gnc_account_sel_get_type())
+#define GNC_TYPE_ACCOUNT_SEL (gnc_account_sel_get_type())
#define GNC_ACCOUNT_SEL(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, GNC_TYPE_ACCOUNT_SEL, GNCAccountSel)
#define GNC_ACCOUNT_SEL_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, GNC_TYPE_ACCOUNT_SEL, GNCAccountSelClass)
#define GNC_IS_ACCOUNT_SEL(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, GNC_TYPE_ACCOUNT_SEL)
typedef struct
{
- GtkHBox hbox;
- gboolean initDone;
- gboolean isModal;
- GtkListStore *store;
- GtkComboBoxEntry *combo;
- GList *acctTypeFilters;
- GList *acctCommodityFilters;
- gint eventHandlerId;
- /* The state of this pointer also serves as a flag about what state
- * the widget is in WRT the new-account-button ability. */
- GtkWidget *newAccountButton;
+ GtkHBox hbox;
+ gboolean initDone;
+ gboolean isModal;
+ GtkListStore *store;
+ GtkComboBoxEntry *combo;
+ GList *acctTypeFilters;
+ GList *acctCommodityFilters;
+ gint eventHandlerId;
+ /* The state of this pointer also serves as a flag about what state
+ * the widget is in WRT the new-account-button ability. */
+ GtkWidget *newAccountButton;
#if 0 /* completion not implemented. */
- GCompletion *completion;
+ GCompletion *completion;
#endif /* 0 - completion not implemented */
} GNCAccountSel;
typedef struct
{
- GtkHBoxClass parent_class;
+ GtkHBoxClass parent_class;
- /* Signals for notification/filtering of changes */
- void (*account_sel_changed) (GNCAccountSel *gas);
+ /* Signals for notification/filtering of changes */
+ void (*account_sel_changed) (GNCAccountSel *gas);
} GNCAccountSelClass;
GType gnc_account_sel_get_type (void);
@@ -94,14 +94,14 @@
* @param state TRUE if the new-account button is desired, FALSE otherwise.
**/
void gnc_account_sel_set_new_account_ability( GNCAccountSel *gas,
- gboolean state );
+ gboolean state );
/**
* Conditional call of the new-account window in modal mode.
* @param state TRUE if the new-account window should be modal, FALSE otherwise.
**/
void gnc_account_sel_set_new_account_modal( GNCAccountSel *gas,
- gboolean state );
+ gboolean state );
gint gnc_account_sel_get_num_account( GNCAccountSel *gas );
void gnc_account_sel_purge_account( GNCAccountSel *gas, Account *acc, gboolean recursive);
Modified: gnucash/trunk/src/gnome-utils/gnc-amount-edit.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-amount-edit.c 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/gnc-amount-edit.c 2010-03-02 21:42:11 UTC (rev 18791)
@@ -46,8 +46,8 @@
/* Signal codes */
enum
{
- AMOUNT_CHANGED,
- LAST_SIGNAL
+ AMOUNT_CHANGED,
+ LAST_SIGNAL
};
@@ -58,7 +58,7 @@
static void gnc_amount_edit_class_init (GNCAmountEditClass *class);
static void gnc_amount_edit_changed (GtkEditable *gae, gpointer data);
static gint gnc_amount_edit_key_press (GtkWidget *widget,
- GdkEventKey *event);
+ GdkEventKey *event);
static GtkEntryClass *parent_class;
@@ -71,113 +71,117 @@
GType
gnc_amount_edit_get_type (void)
{
- static GType amount_edit_type = 0;
+ static GType amount_edit_type = 0;
- if (amount_edit_type == 0) {
- GTypeInfo amount_edit_info = {
- sizeof (GNCAmountEditClass),
- NULL,
- NULL,
- (GClassInitFunc) gnc_amount_edit_class_init,
- NULL,
- NULL,
- sizeof (GNCAmountEdit),
- 0,
- (GInstanceInitFunc) gnc_amount_edit_init
- };
-
- amount_edit_type = g_type_register_static (GTK_TYPE_ENTRY,
- "GNCAmountEdit",
- &amount_edit_info,
- 0);
- }
+ if (amount_edit_type == 0)
+ {
+ GTypeInfo amount_edit_info =
+ {
+ sizeof (GNCAmountEditClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) gnc_amount_edit_class_init,
+ NULL,
+ NULL,
+ sizeof (GNCAmountEdit),
+ 0,
+ (GInstanceInitFunc) gnc_amount_edit_init
+ };
- return amount_edit_type;
+ amount_edit_type = g_type_register_static (GTK_TYPE_ENTRY,
+ "GNCAmountEdit",
+ &amount_edit_info,
+ 0);
+ }
+
+ return amount_edit_type;
}
static void
gnc_amount_edit_class_init (GNCAmountEditClass *klass)
{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
- /* GtkEditableClass *editable_class; */
+ GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
+ /* GtkEditableClass *editable_class; */
- object_class = G_OBJECT_CLASS (klass);
- widget_class = GTK_WIDGET_CLASS (klass);
- /* editable_class = GTK_EDITABLE_CLASS (g_type_interface_peek (klass, GTK_TYPE_EDITABLE)); */
+ object_class = G_OBJECT_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (klass);
+ /* editable_class = GTK_EDITABLE_CLASS (g_type_interface_peek (klass, GTK_TYPE_EDITABLE)); */
- parent_class = g_type_class_peek_parent (klass);
+ parent_class = g_type_class_peek_parent (klass);
- amount_edit_signals [AMOUNT_CHANGED] =
- g_signal_new ("amount_changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GNCAmountEditClass, amount_changed),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
+ amount_edit_signals [AMOUNT_CHANGED] =
+ g_signal_new ("amount_changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GNCAmountEditClass, amount_changed),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
- widget_class->key_press_event = gnc_amount_edit_key_press;
+ widget_class->key_press_event = gnc_amount_edit_key_press;
- /* editable_class->changed = gnc_amount_edit_changed; */
+ /* editable_class->changed = gnc_amount_edit_changed; */
}
static void
gnc_amount_edit_init (GNCAmountEdit *gae)
{
- gae->need_to_parse = FALSE;
- gae->amount = gnc_numeric_zero ();
- gae->print_info = gnc_default_print_info (FALSE);
- gae->fraction = 0;
- gae->evaluate_on_enter = FALSE;
+ gae->need_to_parse = FALSE;
+ gae->amount = gnc_numeric_zero ();
+ gae->print_info = gnc_default_print_info (FALSE);
+ gae->fraction = 0;
+ gae->evaluate_on_enter = FALSE;
- g_signal_connect (G_OBJECT (gae), "changed",
- G_CALLBACK (gnc_amount_edit_changed), NULL);
+ g_signal_connect (G_OBJECT (gae), "changed",
+ G_CALLBACK (gnc_amount_edit_changed), NULL);
}
static void
gnc_amount_edit_changed (GtkEditable *editable, gpointer data)
{
- /*GTK_EDITABLE_CLASS (parent_class)->changed(editable);*/
+ /*GTK_EDITABLE_CLASS (parent_class)->changed(editable);*/
- GNC_AMOUNT_EDIT(editable)->need_to_parse = TRUE;
+ GNC_AMOUNT_EDIT(editable)->need_to_parse = TRUE;
}
static gint
gnc_amount_edit_key_press(GtkWidget *widget, GdkEventKey *event)
{
- GNCAmountEdit *gae = GNC_AMOUNT_EDIT(widget);
- gint result;
+ GNCAmountEdit *gae = GNC_AMOUNT_EDIT(widget);
+ gint result;
- if (event->keyval == GDK_KP_Decimal) {
- if (gae->print_info.monetary) {
- struct lconv *lc = gnc_localeconv ();
- event->keyval = lc->decimal_point[0];
- event->string[0] = lc->decimal_point[0];
+ if (event->keyval == GDK_KP_Decimal)
+ {
+ if (gae->print_info.monetary)
+ {
+ struct lconv *lc = gnc_localeconv ();
+ event->keyval = lc->decimal_point[0];
+ event->string[0] = lc->decimal_point[0];
+ }
}
- }
- result = (* GTK_WIDGET_CLASS (parent_class)->key_press_event)(widget, event);
+ result = (* GTK_WIDGET_CLASS (parent_class)->key_press_event)(widget, event);
- switch (event->keyval)
- {
+ switch (event->keyval)
+ {
case GDK_Return:
- if (gae->evaluate_on_enter)
+ if (gae->evaluate_on_enter)
+ break;
+ if (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_SHIFT_MASK))
+ break;
+ return result;
+ case GDK_KP_Enter:
break;
- if (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_SHIFT_MASK))
- break;
- return result;
- case GDK_KP_Enter:
- break;
default:
- return result;
- }
+ return result;
+ }
- gnc_amount_edit_evaluate (gae);
+ gnc_amount_edit_evaluate (gae);
- return TRUE;
+ return TRUE;
}
/**
@@ -186,18 +190,18 @@
* Creates a new GNCAmountEdit widget which can be used to provide
* an easy to use way for entering amounts, allowing the user to
* enter and evaluate expressions.
- *
+ *
* Returns a GNCAmountEdit widget.
*/
GtkWidget *
gnc_amount_edit_new (void)
{
- GNCAmountEdit *gae;
+ GNCAmountEdit *gae;
- gae = g_object_new (GNC_TYPE_AMOUNT_EDIT, NULL);
- gtk_widget_show (GTK_WIDGET(gae));
+ gae = g_object_new (GNC_TYPE_AMOUNT_EDIT, NULL);
+ gtk_widget_show (GTK_WIDGET(gae));
- return GTK_WIDGET (gae);
+ return GTK_WIDGET (gae);
}
/**
@@ -214,54 +218,54 @@
gboolean
gnc_amount_edit_evaluate (GNCAmountEdit *gae)
{
- const char *string;
- char *error_loc;
- gnc_numeric amount;
- gboolean ok;
+ const char *string;
+ char *error_loc;
+ gnc_numeric amount;
+ gboolean ok;
- g_return_val_if_fail(gae != NULL, FALSE);
- g_return_val_if_fail(GNC_IS_AMOUNT_EDIT(gae), FALSE);
+ g_return_val_if_fail(gae != NULL, FALSE);
+ g_return_val_if_fail(GNC_IS_AMOUNT_EDIT(gae), FALSE);
- if (!gae->need_to_parse)
- return TRUE;
+ if (!gae->need_to_parse)
+ return TRUE;
- string = gtk_entry_get_text(GTK_ENTRY(gae));
- if (!string || *string == '\0')
- {
- gnc_numeric old_amount = gae->amount;
+ string = gtk_entry_get_text(GTK_ENTRY(gae));
+ if (!string || *string == '\0')
+ {
+ gnc_numeric old_amount = gae->amount;
- gnc_amount_edit_set_amount (gae, gnc_numeric_zero ());
+ gnc_amount_edit_set_amount (gae, gnc_numeric_zero ());
- if (!gnc_numeric_equal (gnc_numeric_zero (), old_amount))
- g_signal_emit (gae, amount_edit_signals [AMOUNT_CHANGED], 0);
+ if (!gnc_numeric_equal (gnc_numeric_zero (), old_amount))
+ g_signal_emit (gae, amount_edit_signals [AMOUNT_CHANGED], 0);
- return TRUE;
- }
+ return TRUE;
+ }
- error_loc = NULL;
+ error_loc = NULL;
- ok = gnc_exp_parser_parse (string, &amount, &error_loc);
+ ok = gnc_exp_parser_parse (string, &amount, &error_loc);
- if (ok)
- {
- gnc_numeric old_amount = gae->amount;
+ if (ok)
+ {
+ gnc_numeric old_amount = gae->amount;
- if (gae->fraction > 0)
- amount = gnc_numeric_convert (amount, gae->fraction, GNC_RND_ROUND);
+ if (gae->fraction > 0)
+ amount = gnc_numeric_convert (amount, gae->fraction, GNC_RND_ROUND);
- gnc_amount_edit_set_amount (gae, amount);
+ gnc_amount_edit_set_amount (gae, amount);
- if (!gnc_numeric_equal (amount, old_amount))
- g_signal_emit (gae, amount_edit_signals [AMOUNT_CHANGED], 0);
+ if (!gnc_numeric_equal (amount, old_amount))
+ g_signal_emit (gae, amount_edit_signals [AMOUNT_CHANGED], 0);
- return TRUE;
- }
+ return TRUE;
+ }
- /* Not ok */
- if (error_loc != NULL)
- gtk_editable_set_position (GTK_EDITABLE(gae), error_loc - string);
+ /* Not ok */
+ if (error_loc != NULL)
+ gtk_editable_set_position (GTK_EDITABLE(gae), error_loc - string);
- return FALSE;
+ return FALSE;
}
@@ -276,12 +280,12 @@
gnc_numeric
gnc_amount_edit_get_amount (GNCAmountEdit *gae)
{
- g_return_val_if_fail(gae != NULL, gnc_numeric_zero ());
- g_return_val_if_fail(GNC_IS_AMOUNT_EDIT(gae), gnc_numeric_zero ());
+ g_return_val_if_fail(gae != NULL, gnc_numeric_zero ());
+ g_return_val_if_fail(GNC_IS_AMOUNT_EDIT(gae), gnc_numeric_zero ());
- gnc_amount_edit_evaluate (gae);
+ gnc_amount_edit_evaluate (gae);
- return gae->amount;
+ return gae->amount;
}
@@ -296,12 +300,12 @@
double
gnc_amount_edit_get_damount (GNCAmountEdit *gae)
{
- g_return_val_if_fail(gae != NULL, 0.0);
- g_return_val_if_fail(GNC_IS_AMOUNT_EDIT(gae), 0.0);
+ g_return_val_if_fail(gae != NULL, 0.0);
+ g_return_val_if_fail(GNC_IS_AMOUNT_EDIT(gae), 0.0);
- gnc_amount_edit_evaluate (gae);
+ gnc_amount_edit_evaluate (gae);
- return gnc_numeric_to_double (gae->amount);
+ return gnc_numeric_to_double (gae->amount);
}
@@ -315,18 +319,18 @@
void
gnc_amount_edit_set_amount (GNCAmountEdit *gae, gnc_numeric amount)
{
- const char * amount_string;
+ const char * amount_string;
- g_return_if_fail(gae != NULL);
- g_return_if_fail(GNC_IS_AMOUNT_EDIT(gae));
- g_return_if_fail(!gnc_numeric_check (amount));
+ g_return_if_fail(gae != NULL);
+ g_return_if_fail(GNC_IS_AMOUNT_EDIT(gae));
+ g_return_if_fail(!gnc_numeric_check (amount));
- /* Update the display. */
- amount_string = xaccPrintAmount (amount, gae->print_info);
- gtk_entry_set_text (GTK_ENTRY(gae), amount_string);
+ /* Update the display. */
+ amount_string = xaccPrintAmount (amount, gae->print_info);
+ gtk_entry_set_text (GTK_ENTRY(gae), amount_string);
- gae->amount = amount;
- gae->need_to_parse = FALSE;
+ gae->amount = amount;
+ gae->need_to_parse = FALSE;
}
/**
@@ -339,20 +343,20 @@
void
gnc_amount_edit_set_damount (GNCAmountEdit *gae, double damount)
{
- gnc_numeric amount;
- int fraction;
+ gnc_numeric amount;
+ int fraction;
- g_return_if_fail(gae != NULL);
- g_return_if_fail(GNC_IS_AMOUNT_EDIT(gae));
+ g_return_if_fail(gae != NULL);
+ g_return_if_fail(GNC_IS_AMOUNT_EDIT(gae));
- if (gae->fraction > 0)
- fraction = gae->fraction;
- else
- fraction = 100000;
+ if (gae->fraction > 0)
+ fraction = gae->fraction;
+ else
+ fraction = 100000;
- amount = double_to_gnc_numeric (damount, fraction, GNC_RND_ROUND);
+ amount = double_to_gnc_numeric (damount, fraction, GNC_RND_ROUND);
- gnc_amount_edit_set_amount (gae, amount);
+ gnc_amount_edit_set_amount (gae, amount);
}
/**
@@ -366,11 +370,11 @@
gnc_amount_edit_set_print_info (GNCAmountEdit *gae,
GNCPrintAmountInfo print_info)
{
- g_return_if_fail(gae != NULL);
- g_return_if_fail(GNC_IS_AMOUNT_EDIT(gae));
+ g_return_if_fail(gae != NULL);
+ g_return_if_fail(GNC_IS_AMOUNT_EDIT(gae));
- gae->print_info = print_info;
- gae->print_info.use_symbol = 0;
+ gae->print_info = print_info;
+ gae->print_info.use_symbol = 0;
}
@@ -384,12 +388,12 @@
void
gnc_amount_edit_set_fraction (GNCAmountEdit *gae, int fraction)
{
- g_return_if_fail(gae != NULL);
- g_return_if_fail(GNC_IS_AMOUNT_EDIT(gae));
+ g_return_if_fail(gae != NULL);
+ g_return_if_fail(GNC_IS_AMOUNT_EDIT(gae));
- fraction = MAX (0, fraction);
+ fraction = MAX (0, fraction);
- gae->fraction = fraction;
+ gae->fraction = fraction;
}
@@ -402,10 +406,10 @@
GtkWidget *
gnc_amount_edit_gtk_entry (GNCAmountEdit *gae)
{
- g_return_val_if_fail(gae != NULL, NULL);
- g_return_val_if_fail(GNC_IS_AMOUNT_EDIT(gae), NULL);
+ g_return_val_if_fail(gae != NULL, NULL);
+ g_return_val_if_fail(GNC_IS_AMOUNT_EDIT(gae), NULL);
- return (GtkWidget *)gae;
+ return (GtkWidget *)gae;
}
@@ -420,8 +424,8 @@
gnc_amount_edit_set_evaluate_on_enter (GNCAmountEdit *gae,
gboolean evaluate_on_enter)
{
- g_return_if_fail(gae != NULL);
- g_return_if_fail(GNC_IS_AMOUNT_EDIT(gae));
+ g_return_if_fail(gae != NULL);
+ g_return_if_fail(GNC_IS_AMOUNT_EDIT(gae));
- gae->evaluate_on_enter = evaluate_on_enter;
+ gae->evaluate_on_enter = evaluate_on_enter;
}
Modified: gnucash/trunk/src/gnome-utils/gnc-amount-edit.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-amount-edit.h 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/gnc-amount-edit.h 2010-03-02 21:42:11 UTC (rev 18791)
@@ -27,7 +27,7 @@
*/
#ifndef GNC_AMOUNT_EDIT_H
-#define GNC_AMOUNT_EDIT_H
+#define GNC_AMOUNT_EDIT_H
#include "qof.h"
#include "gnc-ui-util.h"
@@ -39,26 +39,26 @@
typedef struct
{
- GtkEntry entry;
+ GtkEntry entry;
- gboolean need_to_parse;
+ gboolean need_to_parse;
- GNCPrintAmountInfo print_info;
+ GNCPrintAmountInfo print_info;
- gnc_numeric amount;
+ gnc_numeric amount;
- int fraction;
+ int fraction;
- gboolean evaluate_on_enter;
+ gboolean evaluate_on_enter;
} GNCAmountEdit;
typedef struct
{
- GtkEntryClass parent_class;
+ GtkEntryClass parent_class;
- /* Signals for notification/filtering of changes */
- void (*amount_changed) (GNCAmountEdit *gae);
+ /* Signals for notification/filtering of changes */
+ void (*amount_changed) (GNCAmountEdit *gae);
} GNCAmountEditClass;
GType gnc_amount_edit_get_type (void);
@@ -68,9 +68,9 @@
GtkWidget *gnc_amount_edit_gtk_entry (GNCAmountEdit *gae);
void gnc_amount_edit_set_amount (GNCAmountEdit *gae,
- gnc_numeric amount);
+ gnc_numeric amount);
void gnc_amount_edit_set_damount (GNCAmountEdit *gae,
- double amount);
+ double amount);
gnc_numeric gnc_amount_edit_get_amount (GNCAmountEdit *gae);
double gnc_amount_edit_get_damount (GNCAmountEdit *gae);
@@ -78,10 +78,10 @@
gboolean gnc_amount_edit_evaluate (GNCAmountEdit *gae);
void gnc_amount_edit_set_print_info (GNCAmountEdit *gae,
- GNCPrintAmountInfo print_info);
+ GNCPrintAmountInfo print_info);
void gnc_amount_edit_set_fraction (GNCAmountEdit *gae, int fraction);
void gnc_amount_edit_set_evaluate_on_enter (GNCAmountEdit *gae,
- gboolean evaluate_on_enter);
+ gboolean evaluate_on_enter);
#endif
Modified: gnucash/trunk/src/gnome-utils/gnc-autosave.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-autosave.c 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/gnc-autosave.c 2010-03-02 21:42:11 UTC (rev 18791)
@@ -1,4 +1,4 @@
-/*
+/*
* gnc-autosave.c -- Functions related to the auto-save feature.
*
* Copyright (C) 2007 Christian Stimming <stimming at tuhh.de>
@@ -44,10 +44,10 @@
#endif
#define G_LOG_DOMAIN "gnc.gui.autosave"
-static void
+static void
autosave_remove_timer_cb(QofBook *book, gpointer key, gpointer user_data);
-/* Here's how autosave works:
+/* Here's how autosave works:
*
* Initially, the book is in state "undirty". Once the book changes
* state to "dirty", hence calling
@@ -77,211 +77,225 @@
static gboolean autosave_confirm(GtkWidget *toplevel)
{
- GtkWidget *dialog, *label;
- guint interval_mins =
- gnc_gconf_get_float(GCONF_GENERAL, KEY_AUTOSAVE_INTERVAL, NULL);
- gboolean switch_off_autosave, show_expl_again, save_now;
- gchar *message;
- gint response;
+ GtkWidget *dialog, *label;
+ guint interval_mins =
+ gnc_gconf_get_float(GCONF_GENERAL, KEY_AUTOSAVE_INTERVAL, NULL);
+ gboolean switch_off_autosave, show_expl_again, save_now;
+ gchar *message;
+ gint response;
#define YES_THIS_TIME 1
#define YES_ALWAYS 2
#define NO_NEVER 3
#define NO_NOT_THIS_TIME 4
- /* The autosave timeout has occurred, and we should show the
- explanation dialog. */
- dialog =
- gtk_message_dialog_new(GTK_WINDOW(toplevel),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_NONE,
- "%s",
- _("Save file automatically?"));
- gtk_message_dialog_format_secondary_text
+ /* The autosave timeout has occurred, and we should show the
+ explanation dialog. */
+ dialog =
+ gtk_message_dialog_new(GTK_WINDOW(toplevel),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+ "%s",
+ _("Save file automatically?"));
+ gtk_message_dialog_format_secondary_text
(GTK_MESSAGE_DIALOG(dialog),
_("Your data file needs to be saved to your hard disk to save your changes. GnuCash has a feature to save the file automatically every %d minutes, just as if you had pressed the \"Save\" button each time. \n\n"
"You can change the time interval or turn off this feature under Edit -> Preferences -> General -> Auto-save time interval. \n\n"
"Should your file be saved automatically?"),
interval_mins);
- gtk_dialog_add_buttons(GTK_DIALOG(dialog),
- _("_Yes, this time"), YES_THIS_TIME,
- _("Yes, _always"), YES_ALWAYS,
- _("No, n_ever"), NO_NEVER,
- _("_No, not this time"), NO_NOT_THIS_TIME,
- NULL);
- gtk_dialog_set_default_response( GTK_DIALOG(dialog), NO_NOT_THIS_TIME);
+ gtk_dialog_add_buttons(GTK_DIALOG(dialog),
+ _("_Yes, this time"), YES_THIS_TIME,
+ _("Yes, _always"), YES_ALWAYS,
+ _("No, n_ever"), NO_NEVER,
+ _("_No, not this time"), NO_NOT_THIS_TIME,
+ NULL);
+ gtk_dialog_set_default_response( GTK_DIALOG(dialog), NO_NOT_THIS_TIME);
- /* Run the modal dialog */
- response = gtk_dialog_run( GTK_DIALOG( dialog ) );
- gtk_widget_destroy( dialog );
+ /* Run the modal dialog */
+ response = gtk_dialog_run( GTK_DIALOG( dialog ) );
+ gtk_widget_destroy( dialog );
- /* Evaluate the response */
- switch (response) {
- case YES_THIS_TIME:
- switch_off_autosave = FALSE;
- show_expl_again = TRUE;
- save_now = TRUE;
- break;
- case YES_ALWAYS:
- switch_off_autosave = FALSE;
- show_expl_again = FALSE;
- save_now = TRUE;
- break;
- case NO_NEVER:
- switch_off_autosave = TRUE;
- show_expl_again = FALSE;
- save_now = FALSE;
- break;
- default:
- case NO_NOT_THIS_TIME:
- switch_off_autosave = FALSE;
- show_expl_again = TRUE;
- save_now = FALSE;
- };
+ /* Evaluate the response */
+ switch (response)
+ {
+ case YES_THIS_TIME:
+ switch_off_autosave = FALSE;
+ show_expl_again = TRUE;
+ save_now = TRUE;
+ break;
+ case YES_ALWAYS:
+ switch_off_autosave = FALSE;
+ show_expl_again = FALSE;
+ save_now = TRUE;
+ break;
+ case NO_NEVER:
+ switch_off_autosave = TRUE;
+ show_expl_again = FALSE;
+ save_now = FALSE;
+ break;
+ default:
+ case NO_NOT_THIS_TIME:
+ switch_off_autosave = FALSE;
+ show_expl_again = TRUE;
+ save_now = FALSE;
+ };
- /* Should we show this explanation again? */
- gnc_gconf_set_bool(GCONF_GENERAL, KEY_AUTOSAVE_SHOW_EXPLANATION, show_expl_again, NULL);
- g_debug("autosave_timeout_cb: Show explanation again=%s\n",
- (show_expl_again ? "TRUE" : "FALSE"));
+ /* Should we show this explanation again? */
+ gnc_gconf_set_bool(GCONF_GENERAL, KEY_AUTOSAVE_SHOW_EXPLANATION, show_expl_again, NULL);
+ g_debug("autosave_timeout_cb: Show explanation again=%s\n",
+ (show_expl_again ? "TRUE" : "FALSE"));
- /* Should we switch off autosave? */
- if (switch_off_autosave) {
- gnc_gconf_set_float(GCONF_GENERAL, KEY_AUTOSAVE_INTERVAL, 0, NULL);
- g_debug("autosave_timeout_cb: User chose to disable auto-save.\n");
- }
+ /* Should we switch off autosave? */
+ if (switch_off_autosave)
+ {
+ gnc_gconf_set_float(GCONF_GENERAL, KEY_AUTOSAVE_INTERVAL, 0, NULL);
+ g_debug("autosave_timeout_cb: User chose to disable auto-save.\n");
+ }
- return save_now;
+ return save_now;
}
static gboolean autosave_timeout_cb(gpointer user_data)
{
- QofBook *book = user_data;
- gboolean show_explanation;
- gboolean save_now = TRUE;
- GtkWidget *toplevel;
+ QofBook *book = user_data;
+ gboolean show_explanation;
+ gboolean save_now = TRUE;
+ GtkWidget *toplevel;
- g_debug("autosave_timeout_cb called\n");
+ g_debug("autosave_timeout_cb called\n");
- /* Is there already a save in progress? If yes, return FALSE so that
- the timeout is automatically destroyed and the function will not
- be called again. */
- if (gnc_file_save_in_progress() || !gnc_current_session_exist())
- return FALSE;
+ /* Is there already a save in progress? If yes, return FALSE so that
+ the timeout is automatically destroyed and the function will not
+ be called again. */
+ if (gnc_file_save_in_progress() || !gnc_current_session_exist())
+ return FALSE;
- /* Store the current toplevel window for later use. */
- toplevel = gnc_ui_get_toplevel();
+ /* Store the current toplevel window for later use. */
+ toplevel = gnc_ui_get_toplevel();
- /* Lookup gconf key to show an explanatory dialog, if wanted. */
- show_explanation =
- gnc_gconf_get_bool(GCONF_GENERAL, KEY_AUTOSAVE_SHOW_EXPLANATION, NULL);
- if (show_explanation) {
- save_now = autosave_confirm(toplevel);
- }
+ /* Lookup gconf key to show an explanatory dialog, if wanted. */
+ show_explanation =
+ gnc_gconf_get_bool(GCONF_GENERAL, KEY_AUTOSAVE_SHOW_EXPLANATION, NULL);
+ if (show_explanation)
+ {
+ save_now = autosave_confirm(toplevel);
+ }
- if (save_now) {
- g_debug("autosave_timeout_cb: Really trigger auto-save now.\n");
+ if (save_now)
+ {
+ g_debug("autosave_timeout_cb: Really trigger auto-save now.\n");
- /* Timeout has passed - save the file. */
- if (GNC_IS_MAIN_WINDOW(toplevel))
- gnc_main_window_set_progressbar_window( GNC_MAIN_WINDOW( toplevel ) );
- else
- g_debug("autosave_timeout_cb: toplevel is not a GNC_MAIN_WINDOW\n");
- if (GNC_IS_WINDOW(toplevel))
- gnc_window_set_progressbar_window( GNC_WINDOW( toplevel ) );
- else
- g_debug("autosave_timeout_cb: toplevel is not a GNC_WINDOW\n");
+ /* Timeout has passed - save the file. */
+ if (GNC_IS_MAIN_WINDOW(toplevel))
+ gnc_main_window_set_progressbar_window( GNC_MAIN_WINDOW( toplevel ) );
+ else
+ g_debug("autosave_timeout_cb: toplevel is not a GNC_MAIN_WINDOW\n");
+ if (GNC_IS_WINDOW(toplevel))
+ gnc_window_set_progressbar_window( GNC_WINDOW( toplevel ) );
+ else
+ g_debug("autosave_timeout_cb: toplevel is not a GNC_WINDOW\n");
- gnc_file_save();
+ gnc_file_save();
- gnc_main_window_set_progressbar_window(NULL);
+ gnc_main_window_set_progressbar_window(NULL);
- /* Return FALSE so that the timeout is automatically destroyed and
- the function will not be called again. However, at least in my
- glib-2.12.4 the timer event source still exists after returning
- FALSE?! */
- return FALSE;
- } else {
- g_debug("autosave_timeout_cb: No auto-save this time, let the timeout run again.\n");
- /* Return TRUE so that the timeout is not removed but will be
- triggered again after the next time interval. */
- return TRUE;
- }
+ /* Return FALSE so that the timeout is automatically destroyed and
+ the function will not be called again. However, at least in my
+ glib-2.12.4 the timer event source still exists after returning
+ FALSE?! */
+ return FALSE;
+ }
+ else
+ {
+ g_debug("autosave_timeout_cb: No auto-save this time, let the timeout run again.\n");
+ /* Return TRUE so that the timeout is not removed but will be
+ triggered again after the next time interval. */
+ return TRUE;
+ }
}
-static void
+static void
autosave_remove_timer_cb(QofBook *book, gpointer key, gpointer user_data)
{
- guint autosave_source_id = GPOINTER_TO_UINT(user_data);
- gboolean res;
- /* Remove the timer that would have triggered the next autosave */
- if (autosave_source_id > 0) {
- res = g_source_remove (autosave_source_id);
- g_debug("Removing auto save timer with id %d, result=%s\n",
- autosave_source_id, (res ? "TRUE" : "FALSE"));
+ guint autosave_source_id = GPOINTER_TO_UINT(user_data);
+ gboolean res;
+ /* Remove the timer that would have triggered the next autosave */
+ if (autosave_source_id > 0)
+ {
+ res = g_source_remove (autosave_source_id);
+ g_debug("Removing auto save timer with id %d, result=%s\n",
+ autosave_source_id, (res ? "TRUE" : "FALSE"));
- /* Set the event source id to zero. */
- qof_book_set_data_fin(book, AUTOSAVE_SOURCE_ID,
- GUINT_TO_POINTER(0), autosave_remove_timer_cb);
- }
+ /* Set the event source id to zero. */
+ qof_book_set_data_fin(book, AUTOSAVE_SOURCE_ID,
+ GUINT_TO_POINTER(0), autosave_remove_timer_cb);
+ }
}
void gnc_autosave_remove_timer(QofBook *book)
{
- autosave_remove_timer_cb(book, AUTOSAVE_SOURCE_ID,
- qof_book_get_data(book, AUTOSAVE_SOURCE_ID));
+ autosave_remove_timer_cb(book, AUTOSAVE_SOURCE_ID,
+ qof_book_get_data(book, AUTOSAVE_SOURCE_ID));
}
static void gnc_autosave_add_timer(QofBook *book)
{
- guint interval_mins =
- gnc_gconf_get_float(GCONF_GENERAL, KEY_AUTOSAVE_INTERVAL, NULL);
+ guint interval_mins =
+ gnc_gconf_get_float(GCONF_GENERAL, KEY_AUTOSAVE_INTERVAL, NULL);
- /* Interval zero means auto-save is turned off. */
- if ( interval_mins > 0
- && ( ! gnc_file_save_in_progress() )
- && gnc_current_session_exist() ) {
- /* Add a new timer (timeout) that runs until the next autosave
- timeout. */
- guint autosave_source_id =
+ /* Interval zero means auto-save is turned off. */
+ if ( interval_mins > 0
+ && ( ! gnc_file_save_in_progress() )
+ && gnc_current_session_exist() )
+ {
+ /* Add a new timer (timeout) that runs until the next autosave
+ timeout. */
+ guint autosave_source_id =
#if GLIB_CHECK_VERSION(2, 14, 0)
- /* g_timeout_add_seconds is much more suitable here, but is new in
- glib-2.14. */
- g_timeout_add_seconds(interval_mins * 60,
- autosave_timeout_cb, book);
+ /* g_timeout_add_seconds is much more suitable here, but is new in
+ glib-2.14. */
+ g_timeout_add_seconds(interval_mins * 60,
+ autosave_timeout_cb, book);
#else
- g_timeout_add(interval_mins * 60 * 1000,
- autosave_timeout_cb, book);
+ g_timeout_add(interval_mins * 60 * 1000,
+ autosave_timeout_cb, book);
#endif
- g_debug("Adding new auto-save timer with id %d\n", autosave_source_id);
+ g_debug("Adding new auto-save timer with id %d\n", autosave_source_id);
- /* Save the event source id for a potential removal, and also
- set the callback upon book closing */
- qof_book_set_data_fin(book, AUTOSAVE_SOURCE_ID,
- GUINT_TO_POINTER(autosave_source_id),
- autosave_remove_timer_cb);
- }
+ /* Save the event source id for a potential removal, and also
+ set the callback upon book closing */
+ qof_book_set_data_fin(book, AUTOSAVE_SOURCE_ID,
+ GUINT_TO_POINTER(autosave_source_id),
+ autosave_remove_timer_cb);
+ }
}
void gnc_autosave_dirty_handler (QofBook *book, gboolean dirty)
{
- g_debug("gnc_main_window_autosave_dirty(dirty = %s)\n",
- (dirty ? "TRUE" : "FALSE"));
- if (dirty) {
- /* Book state changed from non-dirty to dirty. */
- if (!qof_book_shutting_down(book)) {
- /* Start the autosave timer.
- First stop a potentially running old timer. */
- gnc_autosave_remove_timer(book);
- /* Add a new timer (timeout) that runs until the next autosave
- timeout. */
- gnc_autosave_add_timer(book);
- } else {
- g_debug("Shutting down book, ignoring dirty book");
+ g_debug("gnc_main_window_autosave_dirty(dirty = %s)\n",
+ (dirty ? "TRUE" : "FALSE"));
+ if (dirty)
+ {
+ /* Book state changed from non-dirty to dirty. */
+ if (!qof_book_shutting_down(book))
+ {
+ /* Start the autosave timer.
+ First stop a potentially running old timer. */
+ gnc_autosave_remove_timer(book);
+ /* Add a new timer (timeout) that runs until the next autosave
+ timeout. */
+ gnc_autosave_add_timer(book);
+ }
+ else
+ {
+ g_debug("Shutting down book, ignoring dirty book");
+ }
}
- } else {
- /* Book state changed from dirty to non-dirty (probably due to
- saving). Delete the running autosave timer. */
- gnc_autosave_remove_timer(book);
- }
+ else
+ {
+ /* Book state changed from dirty to non-dirty (probably due to
+ saving). Delete the running autosave timer. */
+ gnc_autosave_remove_timer(book);
+ }
}
Modified: gnucash/trunk/src/gnome-utils/gnc-autosave.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-autosave.h 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/gnc-autosave.h 2010-03-02 21:42:11 UTC (rev 18791)
@@ -1,4 +1,4 @@
-/*
+/*
* gnc-autosave.h -- Functions related to the auto-save feature.
*
* Copyright (C) 2007 Christian Stimming <stimming at tuhh.de>
Modified: gnucash/trunk/src/gnome-utils/gnc-commodity-edit.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-commodity-edit.c 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/gnc-commodity-edit.c 2010-03-02 21:42:11 UTC (rev 18791)
@@ -42,19 +42,19 @@
const char * gnc_commodity_edit_get_string (gpointer ptr)
{
- gnc_commodity * comm = (gnc_commodity *)ptr;
- return gnc_commodity_get_printname(comm);
+ gnc_commodity * comm = (gnc_commodity *)ptr;
+ return gnc_commodity_get_printname(comm);
}
gpointer gnc_commodity_edit_new_select (gpointer arg, gpointer ptr,
- GtkWidget *toplevel)
+ GtkWidget *toplevel)
{
- gnc_commodity * comm = (gnc_commodity *)ptr;
- dialog_commodity_mode *mode_ptr = arg;
- dialog_commodity_mode mode;
+ gnc_commodity * comm = (gnc_commodity *)ptr;
+ dialog_commodity_mode *mode_ptr = arg;
+ dialog_commodity_mode mode;
- mode = mode_ptr ? *mode_ptr : DIAG_COMM_ALL;
- return gnc_ui_select_commodity_modal(comm, toplevel, mode);
+ mode = mode_ptr ? *mode_ptr : DIAG_COMM_ALL;
+ return gnc_ui_select_commodity_modal(comm, toplevel, mode);
}
/*
Modified: gnucash/trunk/src/gnome-utils/gnc-commodity-edit.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-commodity-edit.h 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/gnc-commodity-edit.h 2010-03-02 21:42:11 UTC (rev 18791)
@@ -43,7 +43,7 @@
* enum. This tells the dialog how to limit the namespaces provided.
*/
gpointer gnc_commodity_edit_new_select (gpointer arg, gpointer ptr,
- GtkWidget *toplevel);
+ GtkWidget *toplevel);
#endif
Modified: gnucash/trunk/src/gnome-utils/gnc-currency-edit.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-currency-edit.c 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/gnc-currency-edit.c 2010-03-02 21:42:11 UTC (rev 18791)
@@ -75,7 +75,7 @@
/** The instance private data for a content plugin. */
typedef struct _GNCCurrencyEditPrivate
{
- gint dummy;
+ gint dummy;
} GNCCurrencyEditPrivate;
#define GET_PRIVATE(o) \
@@ -89,28 +89,30 @@
GType
gnc_currency_edit_get_type (void)
{
- static GType currency_edit_type = 0;
+ static GType currency_edit_type = 0;
- if (currency_edit_type == 0) {
- static const GTypeInfo currency_edit_info = {
- sizeof (GNCCurrencyEditClass),
- NULL,
- NULL,
- (GClassInitFunc) gnc_currency_edit_class_init,
- NULL,
- NULL,
- sizeof (GNCCurrencyEdit),
- 0, /* n_preallocs */
- (GInstanceInitFunc) gnc_currency_edit_init,
- NULL
- };
+ if (currency_edit_type == 0)
+ {
+ static const GTypeInfo currency_edit_info =
+ {
+ sizeof (GNCCurrencyEditClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) gnc_currency_edit_class_init,
+ NULL,
+ NULL,
+ sizeof (GNCCurrencyEdit),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gnc_currency_edit_init,
+ NULL
+ };
- currency_edit_type = g_type_register_static (GTK_TYPE_COMBO_BOX_ENTRY,
- "GNCCurrencyEdit",
- ¤cy_edit_info, 0);
- }
+ currency_edit_type = g_type_register_static (GTK_TYPE_COMBO_BOX_ENTRY,
+ "GNCCurrencyEdit",
+ ¤cy_edit_info, 0);
+ }
- return currency_edit_type;
+ return currency_edit_type;
}
@@ -123,9 +125,9 @@
static void
gnc_currency_edit_class_init (GNCCurrencyEditClass *klass)
{
- parent_class = g_type_class_peek_parent (klass);
+ parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private(klass, sizeof(GNCCurrencyEditPrivate));
+ g_type_class_add_private(klass, sizeof(GNCCurrencyEditPrivate));
}
@@ -155,10 +157,10 @@
static void
add_item(gnc_commodity *commodity, GNCCurrencyEdit *gce)
{
- const char *string;
+ const char *string;
- string = gnc_commodity_get_printname(commodity);
- gtk_combo_box_append_text(GTK_COMBO_BOX(gce), string);
+ string = gnc_commodity_get_printname(commodity);
+ gtk_combo_box_append_text(GTK_COMBO_BOX(gce), string);
}
@@ -173,43 +175,43 @@
static void
fill_currencies(GNCCurrencyEdit *gce)
{
- GList *currencies;
+ GList *currencies;
- currencies = gnc_commodity_table_get_commodities
- (gnc_get_current_commodities (), GNC_COMMODITY_NS_CURRENCY);
- g_list_foreach(currencies, (GFunc)add_item, gce);
- g_list_free(currencies);
+ currencies = gnc_commodity_table_get_commodities
+ (gnc_get_current_commodities (), GNC_COMMODITY_NS_CURRENCY);
+ g_list_foreach(currencies, (GFunc)add_item, gce);
+ g_list_free(currencies);
}
/* Create a new GNCCurrencyEdit widget which can be used to provide
* an easy way to enter ISO currency codes.
- *
+ *
* @return A GNCCurrencyEdit widget.
*/
GtkWidget *
gnc_currency_edit_new (void)
{
- GNCCurrencyEdit *gce;
- GtkListStore *store;
+ GNCCurrencyEdit *gce;
+ GtkListStore *store;
- store = gtk_list_store_new (1, G_TYPE_STRING);
- gce = g_object_new (GNC_TYPE_CURRENCY_EDIT,
- "model", store,
- "text-column", 0,
- NULL);
- g_object_unref (store);
+ store = gtk_list_store_new (1, G_TYPE_STRING);
+ gce = g_object_new (GNC_TYPE_CURRENCY_EDIT,
+ "model", store,
+ "text-column", 0,
+ NULL);
+ g_object_unref (store);
- /* Now the signals to make sure the user can't leave the
- widget without a valid currency. */
- gnc_cbe_require_list_item(GTK_COMBO_BOX_ENTRY(gce));
+ /* Now the signals to make sure the user can't leave the
+ widget without a valid currency. */
+ gnc_cbe_require_list_item(GTK_COMBO_BOX_ENTRY(gce));
- /* Fill in all the data. */
- fill_currencies (gce);
- gtk_tree_sortable_set_sort_column_id
- (GTK_TREE_SORTABLE(store), 0, GTK_SORT_ASCENDING);
+ /* Fill in all the data. */
+ fill_currencies (gce);
+ gtk_tree_sortable_set_sort_column_id
+ (GTK_TREE_SORTABLE(store), 0, GTK_SORT_ASCENDING);
- return GTK_WIDGET (gce);
+ return GTK_WIDGET (gce);
}
/** @} */
@@ -228,14 +230,14 @@
gnc_currency_edit_set_currency (GNCCurrencyEdit *gce,
const gnc_commodity *currency)
{
- const gchar *printname;
+ const gchar *printname;
- g_return_if_fail(gce != NULL);
- g_return_if_fail(GNC_IS_CURRENCY_EDIT(gce));
- g_return_if_fail(currency != NULL);
-
- printname = gnc_commodity_get_printname(currency);
- gnc_cbe_set_by_string(GTK_COMBO_BOX_ENTRY(gce), printname);
+ g_return_if_fail(gce != NULL);
+ g_return_if_fail(GNC_IS_CURRENCY_EDIT(gce));
+ g_return_if_fail(currency != NULL);
+
+ printname = gnc_commodity_get_printname(currency);
+ gnc_cbe_set_by_string(GTK_COMBO_BOX_ENTRY(gce), printname);
}
@@ -249,37 +251,40 @@
gnc_commodity *
gnc_currency_edit_get_currency (GNCCurrencyEdit *gce)
{
- gnc_commodity *commodity;
- const char *fullname;
- char *mnemonic, *name;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GValue value = { 0 };
+ gnc_commodity *commodity;
+ const char *fullname;
+ char *mnemonic, *name;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GValue value = { 0 };
- g_return_val_if_fail(gce != NULL, NULL);
- g_return_val_if_fail(GNC_IS_CURRENCY_EDIT(gce), NULL);
+ g_return_val_if_fail(gce != NULL, NULL);
+ g_return_val_if_fail(GNC_IS_CURRENCY_EDIT(gce), NULL);
- if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(gce), &iter)) {
- model = gtk_combo_box_get_model(GTK_COMBO_BOX(gce));
- gtk_tree_model_get_value(model, &iter, 0, &value);
- fullname = g_value_get_string(&value);
- mnemonic = g_strdup(fullname);
- g_value_unset(&value);
+ if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(gce), &iter))
+ {
+ model = gtk_combo_box_get_model(GTK_COMBO_BOX(gce));
+ gtk_tree_model_get_value(model, &iter, 0, &value);
+ fullname = g_value_get_string(&value);
+ mnemonic = g_strdup(fullname);
+ g_value_unset(&value);
- name = strchr(mnemonic, ' ');
- if (name != NULL)
- *name = '\0';
- commodity = gnc_commodity_table_lookup (gnc_get_current_commodities (),
- GNC_COMMODITY_NS_CURRENCY,
- mnemonic);
- g_free(mnemonic);
- } else {
- g_warning("Combo box returned 'inactive'. Using locale default currency.");
- commodity = gnc_locale_default_currency();
- }
+ name = strchr(mnemonic, ' ');
+ if (name != NULL)
+ *name = '\0';
+ commodity = gnc_commodity_table_lookup (gnc_get_current_commodities (),
+ GNC_COMMODITY_NS_CURRENCY,
+ mnemonic);
+ g_free(mnemonic);
+ }
+ else
+ {
+ g_warning("Combo box returned 'inactive'. Using locale default currency.");
+ commodity = gnc_locale_default_currency();
+ }
- return commodity;
+ return commodity;
}
/** @} */
Modified: gnucash/trunk/src/gnome-utils/gnc-currency-edit.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-currency-edit.h 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/gnc-currency-edit.h 2010-03-02 21:42:11 UTC (rev 18791)
@@ -65,12 +65,14 @@
#define GNC_CURRENCY_EDIT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GNC_TYPE_CURRENCY_EDIT, GNCCurrencyEditClass))
#define GNC_IS_CURRENCY_EDIT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_CURRENCY_EDIT))
-typedef struct {
- GtkComboBoxEntry combobox;
+typedef struct
+{
+ GtkComboBoxEntry combobox;
} GNCCurrencyEdit;
-typedef struct {
- GtkComboBoxEntryClass combobox;
+typedef struct
+{
+ GtkComboBoxEntryClass combobox;
} GNCCurrencyEditClass;
/** Return the GType for the GNCCurrencyEdit currency selection widget.
@@ -82,7 +84,7 @@
/** Create a new GNCCurrencyEdit widget which can be used to provide
* an easy way to enter ISO currency codes.
- *
+ *
* @return A GNCCurrencyEdit widget.
*/
GtkWidget *gnc_currency_edit_new (void);
Modified: gnucash/trunk/src/gnome-utils/gnc-date-delta.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-date-delta.c 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/gnc-date-delta.c 2010-03-02 21:42:11 UTC (rev 18791)
@@ -48,11 +48,11 @@
enum
{
- VALUE_CHANGED,
- UNITS_CHANGED,
- POLARITY_CHANGED,
- DELTA_CHANGED,
- LAST_SIGNAL
+ VALUE_CHANGED,
+ UNITS_CHANGED,
+ POLARITY_CHANGED,
+ DELTA_CHANGED,
+ LAST_SIGNAL
};
static guint date_delta_signals [LAST_SIGNAL] = { 0 };
@@ -75,206 +75,208 @@
GType
gnc_date_delta_get_type (void)
{
- static GType date_delta_type = 0;
-
- if (date_delta_type == 0) {
- GTypeInfo date_delta_info = {
- sizeof (GNCDateDeltaClass),
- NULL,
- NULL,
- (GClassInitFunc) gnc_date_delta_class_init,
- NULL,
- NULL,
- sizeof (GNCDateDelta),
- 0,
- (GInstanceInitFunc) gnc_date_delta_init
- };
-
- date_delta_type = g_type_register_static (gtk_hbox_get_type (),
- "GNCDateDelta",
- &date_delta_info,
- 0);
- }
-
- return date_delta_type;
+ static GType date_delta_type = 0;
+
+ if (date_delta_type == 0)
+ {
+ GTypeInfo date_delta_info =
+ {
+ sizeof (GNCDateDeltaClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) gnc_date_delta_class_init,
+ NULL,
+ NULL,
+ sizeof (GNCDateDelta),
+ 0,
+ (GInstanceInitFunc) gnc_date_delta_init
+ };
+
+ date_delta_type = g_type_register_static (gtk_hbox_get_type (),
+ "GNCDateDelta",
+ &date_delta_info,
+ 0);
+ }
+
+ return date_delta_type;
}
static void
gnc_date_delta_class_init (GNCDateDeltaClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
- parent_class = g_type_class_peek_parent (klass);
+ parent_class = g_type_class_peek_parent (klass);
- date_delta_signals [VALUE_CHANGED] =
- g_signal_new ("value_changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GNCDateDeltaClass, value_changed),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
+ date_delta_signals [VALUE_CHANGED] =
+ g_signal_new ("value_changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GNCDateDeltaClass, value_changed),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
- date_delta_signals [UNITS_CHANGED] =
- g_signal_new ("units_changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GNCDateDeltaClass, units_changed),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
+ date_delta_signals [UNITS_CHANGED] =
+ g_signal_new ("units_changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GNCDateDeltaClass, units_changed),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
- date_delta_signals [POLARITY_CHANGED] =
- g_signal_new ("polarity_changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GNCDateDeltaClass, polarity_changed),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- date_delta_signals [DELTA_CHANGED] =
- g_signal_new ("delta_changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GNCDateDeltaClass, delta_changed),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
+ date_delta_signals [POLARITY_CHANGED] =
+ g_signal_new ("polarity_changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GNCDateDeltaClass, polarity_changed),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
- container_class->forall = gnc_date_delta_forall;
+ date_delta_signals [DELTA_CHANGED] =
+ g_signal_new ("delta_changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GNCDateDeltaClass, delta_changed),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
+ container_class->forall = gnc_date_delta_forall;
}
static void
gnc_date_delta_init (GNCDateDelta *gdd)
{
- gdd->value_spin = NULL;
- gdd->units_combo = NULL;
- gdd->polarity_combo = NULL;
+ gdd->value_spin = NULL;
+ gdd->units_combo = NULL;
+ gdd->polarity_combo = NULL;
- gdd->units = 0;
- gdd->polarity = 0;
+ gdd->units = 0;
+ gdd->polarity = 0;
- gdd->show_polarity = FALSE;
+ gdd->show_polarity = FALSE;
}
static void
gnc_date_delta_forall (GtkContainer *container, gboolean include_internals,
GtkCallback callback, gpointer callback_data)
{
- g_return_if_fail (container != NULL);
- g_return_if_fail (GNC_IS_DATE_DELTA (container));
- g_return_if_fail (callback != NULL);
+ g_return_if_fail (container != NULL);
+ g_return_if_fail (GNC_IS_DATE_DELTA (container));
+ g_return_if_fail (callback != NULL);
- /* Let GtkBox handle things only if the internal widgets need to be
- * poked.
- */
- if (include_internals)
- if (GTK_CONTAINER_CLASS (parent_class)->forall)
- (* GTK_CONTAINER_CLASS (parent_class)->forall)
- (container, include_internals, callback, callback_data);
+ /* Let GtkBox handle things only if the internal widgets need to be
+ * poked.
+ */
+ if (include_internals)
+ if (GTK_CONTAINER_CLASS (parent_class)->forall)
+ (* GTK_CONTAINER_CLASS (parent_class)->forall)
+ (container, include_internals, callback, callback_data);
}
static void
value_changed(GtkEditable *editable, gpointer data)
{
- GNCDateDelta *gdd = GNC_DATE_DELTA(data);
+ GNCDateDelta *gdd = GNC_DATE_DELTA(data);
- g_signal_emit(gdd, date_delta_signals [VALUE_CHANGED], 0);
- g_signal_emit(gdd, date_delta_signals [DELTA_CHANGED], 0);
+ g_signal_emit(gdd, date_delta_signals [VALUE_CHANGED], 0);
+ g_signal_emit(gdd, date_delta_signals [DELTA_CHANGED], 0);
}
static void
set_units (GtkComboBox *combo, GNCDateDelta *gdd)
{
- gint active;
+ gint active;
- active = gtk_combo_box_get_active(GTK_COMBO_BOX(gdd->units_combo));
- if ((active < GNC_DATE_DELTA_DAYS) || (active > GNC_DATE_DELTA_YEARS))
- active = GNC_DATE_DELTA_DAYS;
- gdd->units = active;
+ active = gtk_combo_box_get_active(GTK_COMBO_BOX(gdd->units_combo));
+ if ((active < GNC_DATE_DELTA_DAYS) || (active > GNC_DATE_DELTA_YEARS))
+ active = GNC_DATE_DELTA_DAYS;
+ gdd->units = active;
- g_signal_emit (gdd, date_delta_signals [UNITS_CHANGED], 0);
- g_signal_emit (gdd, date_delta_signals [DELTA_CHANGED], 0);
+ g_signal_emit (gdd, date_delta_signals [UNITS_CHANGED], 0);
+ g_signal_emit (gdd, date_delta_signals [DELTA_CHANGED], 0);
}
static void
fill_units_combo(GNCDateDelta *gdd)
{
- gtk_combo_box_append_text(GTK_COMBO_BOX(gdd->units_combo),
- _("Days"));
- gtk_combo_box_append_text(GTK_COMBO_BOX(gdd->units_combo),
- _("Weeks"));
- gtk_combo_box_append_text(GTK_COMBO_BOX(gdd->units_combo),
- _("Months"));
- gtk_combo_box_append_text(GTK_COMBO_BOX(gdd->units_combo),
- _("Years"));
+ gtk_combo_box_append_text(GTK_COMBO_BOX(gdd->units_combo),
+ _("Days"));
+ gtk_combo_box_append_text(GTK_COMBO_BOX(gdd->units_combo),
+ _("Weeks"));
+ gtk_combo_box_append_text(GTK_COMBO_BOX(gdd->units_combo),
+ _("Months"));
+ gtk_combo_box_append_text(GTK_COMBO_BOX(gdd->units_combo),
+ _("Years"));
- g_signal_connect (gdd->units_combo, "changed",
- G_CALLBACK (set_units), gdd);
+ g_signal_connect (gdd->units_combo, "changed",
+ G_CALLBACK (set_units), gdd);
}
static void
set_polarity (GtkComboBox *combo, GNCDateDelta *gdd)
{
- gint active;
+ gint active;
- active = gtk_combo_box_get_active(GTK_COMBO_BOX(gdd->units_combo));
- if ((active < GNC_DATE_DELTA_PAST) || (active > GNC_DATE_DELTA_FUTURE))
- active = GNC_DATE_DELTA_PAST;
- gdd->polarity = active;
+ active = gtk_combo_box_get_active(GTK_COMBO_BOX(gdd->units_combo));
+ if ((active < GNC_DATE_DELTA_PAST) || (active > GNC_DATE_DELTA_FUTURE))
+ active = GNC_DATE_DELTA_PAST;
+ gdd->polarity = active;
- g_signal_emit (gdd, date_delta_signals [POLARITY_CHANGED], 0);
- g_signal_emit (gdd, date_delta_signals [DELTA_CHANGED], 0);
+ g_signal_emit (gdd, date_delta_signals [POLARITY_CHANGED], 0);
+ g_signal_emit (gdd, date_delta_signals [DELTA_CHANGED], 0);
}
static void
fill_polarity_combo(GNCDateDelta *gdd)
{
- gtk_combo_box_append_text(GTK_COMBO_BOX(gdd->polarity_combo),
- _("Ago"));
- gtk_combo_box_append_text(GTK_COMBO_BOX(gdd->polarity_combo),
- _("From Now"));
+ gtk_combo_box_append_text(GTK_COMBO_BOX(gdd->polarity_combo),
+ _("Ago"));
+ gtk_combo_box_append_text(GTK_COMBO_BOX(gdd->polarity_combo),
+ _("From Now"));
- g_signal_connect (gdd->polarity_combo, "changed",
- G_CALLBACK(set_polarity), gdd);
+ g_signal_connect (gdd->polarity_combo, "changed",
+ G_CALLBACK(set_polarity), gdd);
}
static void
create_children (GNCDateDelta *gdd)
{
- GtkObject *adj;
+ GtkObject *adj;
- adj = gtk_adjustment_new(1.0, 1.0, 1000.0, 1.0, 5.0, 5.0);
- gdd->value_spin = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 1.0, 0);
- gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(gdd->value_spin), TRUE);
- gtk_box_pack_start(GTK_BOX(gdd), gdd->value_spin, FALSE, FALSE, 0);
- gtk_widget_show(gdd->value_spin);
+ adj = gtk_adjustment_new(1.0, 1.0, 1000.0, 1.0, 5.0, 5.0);
+ gdd->value_spin = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 1.0, 0);
+ gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(gdd->value_spin), TRUE);
+ gtk_box_pack_start(GTK_BOX(gdd), gdd->value_spin, FALSE, FALSE, 0);
+ gtk_widget_show(gdd->value_spin);
- g_signal_connect(gdd->value_spin, "changed",
- G_CALLBACK(value_changed), gdd);
+ g_signal_connect(gdd->value_spin, "changed",
+ G_CALLBACK(value_changed), gdd);
- gdd->units_combo = gtk_combo_box_new_text();
- fill_units_combo(gdd);
- gtk_combo_box_set_active(GTK_COMBO_BOX(gdd->units_combo), 0);
- gtk_box_pack_start(GTK_BOX(gdd), gdd->units_combo, FALSE, FALSE, 0);
- gtk_widget_show(gdd->units_combo);
+ gdd->units_combo = gtk_combo_box_new_text();
+ fill_units_combo(gdd);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(gdd->units_combo), 0);
+ gtk_box_pack_start(GTK_BOX(gdd), gdd->units_combo, FALSE, FALSE, 0);
+ gtk_widget_show(gdd->units_combo);
- gdd->polarity_combo = gtk_combo_box_new_text();
- fill_polarity_combo(gdd);
- gtk_combo_box_set_active(GTK_COMBO_BOX(gdd->polarity_combo), 0);
- gtk_box_pack_start(GTK_BOX(gdd), gdd->polarity_combo, FALSE, FALSE, 0);
- if (gdd->show_polarity)
- gtk_widget_show(gdd->polarity_combo);
+ gdd->polarity_combo = gtk_combo_box_new_text();
+ fill_polarity_combo(gdd);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(gdd->polarity_combo), 0);
+ gtk_box_pack_start(GTK_BOX(gdd), gdd->polarity_combo, FALSE, FALSE, 0);
+ if (gdd->show_polarity)
+ gtk_widget_show(gdd->polarity_combo);
}
/**
@@ -284,21 +286,21 @@
* Creates a new GNCDateDelta widget which can be used to provide
* an easy to use way for entering time deltas in terms of 7 days,
* 5 weeks, 2 months, etc.
- *
+ *
* Returns a GNCDateDelta widget.
*/
GtkWidget *
gnc_date_delta_new (gboolean show_polarity)
{
- GNCDateDelta *gdd;
+ GNCDateDelta *gdd;
- gdd = g_object_new (gnc_date_delta_get_type (), NULL);
+ gdd = g_object_new (gnc_date_delta_get_type (), NULL);
- gdd->show_polarity = show_polarity;
+ gdd->show_polarity = show_polarity;
- create_children (gdd);
+ create_children (gdd);
- return GTK_WIDGET (gdd);
+ return GTK_WIDGET (gdd);
}
/**
@@ -311,10 +313,10 @@
void
gnc_date_delta_set_value (GNCDateDelta *gdd, int value)
{
- g_return_if_fail(gdd != NULL);
- g_return_if_fail(GNC_IS_DATE_DELTA(gdd));
+ g_return_if_fail(gdd != NULL);
+ g_return_if_fail(GNC_IS_DATE_DELTA(gdd));
- gtk_spin_button_set_value(GTK_SPIN_BUTTON(gdd->value_spin), value);
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(gdd->value_spin), value);
}
/**
@@ -326,10 +328,10 @@
int
gnc_date_delta_get_value (GNCDateDelta *gdd)
{
- g_return_val_if_fail(gdd != NULL, 0);
- g_return_val_if_fail(GNC_IS_DATE_DELTA(gdd), 0);
+ g_return_val_if_fail(gdd != NULL, 0);
+ g_return_val_if_fail(GNC_IS_DATE_DELTA(gdd), 0);
- return gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(gdd->value_spin));
+ return gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(gdd->value_spin));
}
/**
@@ -342,13 +344,13 @@
void
gnc_date_delta_set_units (GNCDateDelta *gdd, GNCDateDeltaUnits units)
{
- g_return_if_fail(gdd != NULL);
- g_return_if_fail(GNC_IS_DATE_DELTA(gdd));
- g_return_if_fail((units >= 0) && (units < GNC_DATE_DELTA_NUM_UNITS));
+ g_return_if_fail(gdd != NULL);
+ g_return_if_fail(GNC_IS_DATE_DELTA(gdd));
+ g_return_if_fail((units >= 0) && (units < GNC_DATE_DELTA_NUM_UNITS));
- gdd->units = units;
+ gdd->units = units;
- gtk_combo_box_set_active(GTK_COMBO_BOX(gdd->units_combo), units);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(gdd->units_combo), units);
}
/**
@@ -360,10 +362,10 @@
GNCDateDeltaUnits
gnc_date_delta_get_units (GNCDateDelta *gdd)
{
- g_return_val_if_fail(gdd != NULL, GNC_DATE_DELTA_DAYS);
- g_return_val_if_fail(GNC_IS_DATE_DELTA(gdd), GNC_DATE_DELTA_DAYS);
+ g_return_val_if_fail(gdd != NULL, GNC_DATE_DELTA_DAYS);
+ g_return_val_if_fail(GNC_IS_DATE_DELTA(gdd), GNC_DATE_DELTA_DAYS);
- return gdd->units;
+ return gdd->units;
}
/**
@@ -376,14 +378,14 @@
void
gnc_date_delta_set_polarity (GNCDateDelta *gdd, GNCDateDeltaPolarity polarity)
{
- g_return_if_fail(gdd != NULL);
- g_return_if_fail(GNC_IS_DATE_DELTA(gdd));
- g_return_if_fail((polarity >= 0) &&
- (polarity < GNC_DATE_DELTA_NUM_POLARITY));
+ g_return_if_fail(gdd != NULL);
+ g_return_if_fail(GNC_IS_DATE_DELTA(gdd));
+ g_return_if_fail((polarity >= 0) &&
+ (polarity < GNC_DATE_DELTA_NUM_POLARITY));
- gdd->polarity = polarity;
+ gdd->polarity = polarity;
- gtk_combo_box_set_active(GTK_COMBO_BOX(gdd->polarity_combo), polarity);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(gdd->polarity_combo), polarity);
}
/**
@@ -395,10 +397,10 @@
GNCDateDeltaPolarity
gnc_date_delta_get_polarity (GNCDateDelta *gdd)
{
- g_return_val_if_fail(gdd != NULL, GNC_DATE_DELTA_PAST);
- g_return_val_if_fail(GNC_IS_DATE_DELTA(gdd), GNC_DATE_DELTA_PAST);
+ g_return_val_if_fail(gdd != NULL, GNC_DATE_DELTA_PAST);
+ g_return_val_if_fail(GNC_IS_DATE_DELTA(gdd), GNC_DATE_DELTA_PAST);
- return gdd->polarity;
+ return gdd->polarity;
}
/**
@@ -411,13 +413,13 @@
void
gnc_date_delta_show_polarity (GNCDateDelta *gdd, gboolean show_polarity)
{
- g_return_if_fail(gdd != NULL);
- g_return_if_fail(GNC_IS_DATE_DELTA(gdd));
+ g_return_if_fail(gdd != NULL);
+ g_return_if_fail(GNC_IS_DATE_DELTA(gdd));
- gdd->show_polarity = show_polarity;
+ gdd->show_polarity = show_polarity;
- if (show_polarity)
- gtk_widget_show(gdd->polarity_combo);
- else
- gtk_widget_hide(gdd->polarity_combo);
+ if (show_polarity)
+ gtk_widget_show(gdd->polarity_combo);
+ else
+ gtk_widget_hide(gdd->polarity_combo);
}
Modified: gnucash/trunk/src/gnome-utils/gnc-date-delta.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-date-delta.h 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/gnc-date-delta.h 2010-03-02 21:42:11 UTC (rev 18791)
@@ -29,20 +29,22 @@
*/
#ifndef GNC_DATE_DELTA_H
-#define GNC_DATE_DELTA_H
+#define GNC_DATE_DELTA_H
-typedef enum {
- GNC_DATE_DELTA_DAYS,
- GNC_DATE_DELTA_WEEKS,
- GNC_DATE_DELTA_MONTHS,
- GNC_DATE_DELTA_YEARS,
- GNC_DATE_DELTA_NUM_UNITS
+typedef enum
+{
+ GNC_DATE_DELTA_DAYS,
+ GNC_DATE_DELTA_WEEKS,
+ GNC_DATE_DELTA_MONTHS,
+ GNC_DATE_DELTA_YEARS,
+ GNC_DATE_DELTA_NUM_UNITS
} GNCDateDeltaUnits;
-typedef enum {
- GNC_DATE_DELTA_PAST,
- GNC_DATE_DELTA_FUTURE,
- GNC_DATE_DELTA_NUM_POLARITY
+typedef enum
+{
+ GNC_DATE_DELTA_PAST,
+ GNC_DATE_DELTA_FUTURE,
+ GNC_DATE_DELTA_NUM_POLARITY
} GNCDateDeltaPolarity;
#define GNC_TYPE_DATE_DELTA (gnc_date_delta_get_type())
@@ -50,25 +52,27 @@
#define GNC_DATE_DELTA_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, GNC_TYPE_DATE_DELTA, GNCDateDeltaClass)
#define GNC_IS_DATE_DELTA(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, GNC_TYPE_DATE_DELTA)
-typedef struct {
- GtkHBox hbox;
+typedef struct
+{
+ GtkHBox hbox;
- GtkWidget *value_spin;
- GtkWidget *units_combo;
- GtkWidget *polarity_combo;
+ GtkWidget *value_spin;
+ GtkWidget *units_combo;
+ GtkWidget *polarity_combo;
- GNCDateDeltaUnits units;
- GNCDateDeltaPolarity polarity;
+ GNCDateDeltaUnits units;
+ GNCDateDeltaPolarity polarity;
- gboolean show_polarity;
+ gboolean show_polarity;
} GNCDateDelta;
-typedef struct {
- GtkHBoxClass parent_class;
- void (*value_changed) (GNCDateDelta *gdd);
- void (*units_changed) (GNCDateDelta *gdd);
- void (*polarity_changed) (GNCDateDelta *gdd);
- void (*delta_changed) (GNCDateDelta *gdd);
+typedef struct
+{
+ GtkHBoxClass parent_class;
+ void (*value_changed) (GNCDateDelta *gdd);
+ void (*units_changed) (GNCDateDelta *gdd);
+ void (*polarity_changed) (GNCDateDelta *gdd);
+ void (*delta_changed) (GNCDateDelta *gdd);
} GNCDateDeltaClass;
GType gnc_date_delta_get_type (void);
Modified: gnucash/trunk/src/gnome-utils/gnc-date-edit.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-date-edit.c 2010-03-02 21:41:39 UTC (rev 18790)
+++ gnucash/trunk/src/gnome-utils/gnc-date-edit.c 2010-03-02 21:42:11 UTC (rev 18791)
@@ -51,10 +51,11 @@
#include "dialog-utils.h"
#include "gnc-date-edit.h"
-enum {
- DATE_CHANGED,
- TIME_CHANGED,
- LAST_SIGNAL
+enum
+{
+ DATE_CHANGED,
+ TIME_CHANGED,
+ LAST_SIGNAL
};
static QofLogModule log_module = GNC_MOD_GUI;
@@ -85,149 +86,151 @@
GType
gnc_date_edit_get_type (void)
{
- static GType date_edit_type = 0;
+ static GType date_edit_type = 0;
- if (date_edit_type == 0){
- static const GTypeInfo date_edit_info = {
- sizeof (GNCDateEditClass),
- NULL,
- NULL,
- (GClassInitFunc) gnc_date_edit_class_init,
- NULL,
- NULL,
- sizeof (GNCDateEdit),
- 0, /* n_preallocs */
- (GInstanceInitFunc) gnc_date_edit_init,
- NULL,
- };
+ if (date_edit_type == 0)
+ {
+ static const GTypeInfo date_edit_info =
+ {
+ sizeof (GNCDateEditClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) gnc_date_edit_class_init,
+ NULL,
+ NULL,
+ sizeof (GNCDateEdit),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gnc_date_edit_init,
+ NULL,
+ };
- date_edit_type = g_type_register_static (GTK_TYPE_HBOX,
- "GNCDateEdit",
- &date_edit_info, 0);
- }
+ date_edit_type = g_type_register_static (GTK_TYPE_HBOX,
+ "GNCDateEdit",
+ &date_edit_info, 0);
+ }
- return date_edit_type;
+ return date_edit_type;
}
static char *
gnc_strtok_r (char *s, const char *delim, char **save_ptr)
{
- char *token;
+ char *token;
- if (s == NULL)
- s = *save_ptr;
+ if (s == NULL)
+ s = *save_ptr;
- /* Scan leading delimiters. */
- s += strspn (s, delim);
- if (*s == '\0')
- return NULL;
+ /* Scan leading delimiters. */
+ s += strspn (s, delim);
+ if (*s == '\0')
+ return NULL;
- /* Find the end of the token. */
- token = s;
- s = strpbrk (token, delim);
- if (s == NULL)
- /* This token finishes the string. */
- *save_ptr = strchr (token, '\0');
- else
+ /* Find the end of the token. */
+ token = s;
+ s = strpbrk (token, delim);
+ if (s == NULL)
+ /* This token finishes the string. */
+ *save_ptr = strchr (token, '\0');
+ else
{
- /* Terminate the token and make *SAVE_PTR point past it. */
- *s = '\0';
- *save_ptr = s + 1;
+ /* Terminate the token and make *SAVE_PTR point past it. */
+ *s = '\0';
+ *save_ptr = s + 1;
}
- return token;
+ return token;
}
static void
gnc_date_edit_popdown(GNCDateEdit *gde)
{
- g_return_if_fail (GNC_IS_DATE_EDIT (gde));
+ g_return_if_fail (GNC_IS_DATE_EDIT (gde));
- ENTER("gde %p", gde);
+ ENTER("gde %p", gde);
- gtk_grab_remove (gde->cal_popup);
- gtk_widget_hide (gde->cal_popup);
- gdk_pointer_ungrab (GDK_CURRENT_TIME);
+ gtk_grab_remove (gde->cal_popup);
+ gtk_widget_hide (gde->cal_popup);
+ gdk_pointer_ungrab (GDK_CURRENT_TIME);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gde->date_button),
- FALSE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gde->date_button),
+ FALSE);
- LEAVE(" ");
+ LEAVE(" ");
}
static void
day_selected (GtkCalendar *calendar, GNCDateEdit *gde)
{
- char buffer [40];
- guint year, month, day;
+ char buffer [40];
+ guint year, month, day;
- gtk_calendar_get_date (calendar, &year, &month, &day);
+ gtk_calendar_get_date (calendar, &year, &month, &day);
- qof_print_date_dmy_buff (buffer, 40, day, month + 1, year);
- gtk_entry_set_text (GTK_ENTRY (gde->date_entry), buffer);
- g_signal_emit (G_OBJECT (gde), date_edit_signals [DATE_CHANGED], 0);
+ qof_print_date_dmy_buff (buffer, 40, day, month + 1, year);
+ gtk_entry_set_text (GTK_ENTRY (gde->date_entry), buffer);
+ g_signal_emit (G_OBJECT (gde), date_edit_signals [DATE_CHANGED], 0);
}
static void
day_selected_double_click (GtkCalendar *calendar, GNCDateEdit *gde)
{
- gnc_date_edit_popdown (gde);
+ gnc_date_edit_popdown (gde);
}
static gint
delete_popup (GtkWidget *widget, gpointer data)
{
- GNCDateEdit *gde;
+ GNCDateEdit *gde;
- gde = data;
- gnc_date_edit_popdown (gde);
+ gde = data;
+ gnc_date_edit_popdown (gde);
- return TRUE;
+ return TRUE;
}
static gint
key_press_popup (GtkWidget *widget, GdkEventKey *event, gpointer data)
{
- GNCDateEdit *gde = data;
+ GNCDateEdit *gde = data;
- if (event->keyval != GDK_Return &&
- event->keyval != GDK_KP_Enter &&
- event->keyval != GDK_Escape)
- return date_accel_key_press(gde->date_entry, event, data);
+ if (event->keyval != GDK_Return &&
+ event->keyval != GDK_KP_Enter &&
+ event->keyval != GDK_Escape)
+ return date_accel_key_press(gde->date_entry, event, data);
- gde = data;
- g_signal_stop_emission_by_name (G_OBJECT (widget), "key-press-event");
- gnc_date_edit_popdown (gde);
+ gde = data;
+ g_signal_stop_emission_by_name (G_OBJECT (widget), "key-press-event");
+ gnc_date_edit_popdown (gde);
- return TRUE;
+ return TRUE;
}
static void
position_popup (GNCDateEdit *gde)
{
- gint x, y;
- gint bwidth, bheight;
- GtkRequisition req;
+ gint x, y;
+ gint bwidth, bheight;
+ GtkRequisition req;
- gtk_widget_size_request (gde->cal_popup, &req);
+ gtk_widget_size_request (gde->cal_popup, &req);
- gdk_window_get_origin (gde->date_button->window, &x, &y);
+ gdk_window_get_origin (gde->date_button->window, &x, &y);
- x += gde->date_button->allocation.x;
- y += gde->date_button->allocation.y;
- bwidth = gde->date_button->allocation.width;
- bheight = gde->date_button->allocation.height;
+ x += gde->date_button->allocation.x;
+ y += gde->date_button->allocation.y;
+ bwidth = gde->date_button->allocation.width;
+ bheight = gde->date_button->allocation.height;
- x += bwidth - req.width;
- y += bheight;
+ x += bwidth - req.width;
+ y += bheight;
- if (x < 0)
- x = 0;
+ if (x < 0)
+ x = 0;
- if (y < 0)
- y = 0;
+ if (y < 0)
+ y = 0;
- gtk_window_move (GTK_WINDOW (gde->cal_popup), x, y);
+ gtk_window_move (GTK_WINDOW (gde->cal_popup), x, y);
}
/* Pulled from gtkcombobox.c */
@@ -236,95 +239,95 @@
guint32 activate_time,
gboolean grab_keyboard)
{
- if ((gdk_pointer_grab (window, TRUE,
- GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
- GDK_POINTER_MOTION_MASK,
- NULL, NULL, activate_time) == 0))
- {
- if (!grab_keyboard ||
- gdk_keyboard_grab (window, TRUE,
- activate_time) == 0)
- return TRUE;
- else
+ if ((gdk_pointer_grab (window, TRUE,
+ GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
+ GDK_POINTER_MOTION_MASK,
+ NULL, NULL, activate_time) == 0))
{
- gdk_display_pointer_ungrab (gdk_drawable_get_display (window),
- activate_time);
- return FALSE;
+ if (!grab_keyboard ||
+ gdk_keyboard_grab (window, TRUE,
+ activate_time) == 0)
+ return TRUE;
+ else
+ {
+ gdk_display_pointer_ungrab (gdk_drawable_get_display (window),
+ activate_time);
+ return FALSE;
+ }
}
- }
- return FALSE;
+ return FALSE;
}
static void
gnc_date_edit_popup (GNCDateEdit *gde)
{
- GtkWidget *toplevel;
- struct tm mtm;
+ GtkWidget *toplevel;
+ struct tm mtm;
- g_return_if_fail (GNC_IS_DATE_EDIT (gde));
+ g_return_if_fail (GNC_IS_DATE_EDIT (gde));
- ENTER("gde %p", gde);
+ ENTER("gde %p", gde);
- /* This code is pretty much just copied from gtk_date_edit_get_date */
- qof_scan_date (gtk_entry_get_text (GTK_ENTRY (gde->date_entry)),
- &mtm.tm_mday, &mtm.tm_mon, &mtm.tm_year);
+ /* This code is pretty much just copied from gtk_date_edit_get_date */
+ qof_scan_date (gtk_entry_get_text (GTK_ENTRY (gde->date_entry)),
+ &mtm.tm_mday, &mtm.tm_mon, &mtm.tm_year);
- mtm.tm_mon--;
+ mtm.tm_mon--;
- /* Hope the user does not actually mean years early in the A.D. days...
- * This date widget will obviously not work for a history program :-)
- */
- if (mtm.tm_year >= 1900)
- mtm.tm_year -= 1900;
+ /* Hope the user does not actually mean years early in the A.D. days...
+ * This date widget will obviously not work for a history program :-)
+ */
+ if (mtm.tm_year >= 1900)
+ mtm.tm_year -= 1900;
- gnc_tm_set_day_start(&mtm);
- if (mktime (&mtm) == (time_t) -1)
- {
- gnc_tm_get_today_start (&mtm);
- gnc_date_edit_set_time (gde, mktime (&mtm));
- }
+ gnc_tm_set_day_start(&mtm);
+ if (mktime (&mtm) == (time_t) - 1)
+ {
+ gnc_tm_get_today_start (&mtm);
+ gnc_date_edit_set_time (gde, mktime (&mtm));
+ }
- /* Set the calendar. */
- gtk_calendar_select_day (GTK_CALENDAR (gde->calendar), 1);
- gtk_calendar_select_month (GTK_CALENDAR (gde->calendar), mtm.tm_mon,
- 1900 + mtm.tm_year);
- gtk_calendar_select_day (GTK_CALENDAR (gde->calendar), mtm.tm_mday);
+ /* Set the calendar. */
+ gtk_calendar_select_day (GTK_CALENDAR (gde->calendar), 1);
+ gtk_calendar_select_month (GTK_CALENDAR (gde->calendar), mtm.tm_mon,
+ 1900 + mtm.tm_year);
+ gtk_calendar_select_day (GTK_CALENDAR (gde->calendar), mtm.tm_mday);
- /* Make sure we'll get notified of clicks outside the popup
- * window so we can properly pop down if that happens. */
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (gde));
- if (GTK_IS_WINDOW (toplevel))
- {
- gtk_window_group_add_window (
- gtk_window_get_group (GTK_WINDOW (toplevel)),
- GTK_WINDOW (gde->cal_popup));
- gtk_window_set_transient_for (GTK_WINDOW (gde->cal_popup),
- GTK_WINDOW (toplevel));
- }
+ /* Make sure we'll get notified of clicks outside the popup
+ * window so we can properly pop down if that happens. */
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (gde));
+ if (GTK_IS_WINDOW (toplevel))
+ {
+ gtk_window_group_add_window (
+ gtk_window_get_group (GTK_WINDOW (toplevel)),
+ GTK_WINDOW (gde->cal_popup));
+ gtk_window_set_transient_for (GTK_WINDOW (gde->cal_popup),
+ GTK_WINDOW (toplevel));
+ }
- position_popup (gde);
+ position_popup (gde);
- gtk_widget_show (gde->cal_popup);
+ gtk_widget_show (gde->cal_popup);
- gtk_widget_grab_focus (gde->cal_popup);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gde->date_button),
- TRUE);
+ gtk_widget_grab_focus (gde->cal_popup);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gde->date_button),
+ TRUE);
- if (!GTK_WIDGET_HAS_FOCUS (gde->calendar))
- gtk_widget_grab_focus (gde->calendar);
+ if (!GTK_WIDGET_HAS_FOCUS (gde->calendar))
+ gtk_widget_grab_focus (gde->calendar);
- if (!popup_grab_on_window ((GTK_WIDGET(gde->cal_popup))->window,
- GDK_CURRENT_TIME, TRUE))
- {
- gtk_widget_hide (gde->cal_popup);
- LEAVE("Failed to grab window");
- return;
- }
+ if (!popup_grab_on_window ((GTK_WIDGET(gde->cal_popup))->window,
+ GDK_CURRENT_TIME, TRUE))
+ {
+ gtk_widget_hide (gde->cal_popup);
+ LEAVE("Failed to grab window");
+ return;
+ }
- gtk_grab_add (gde->cal_popup);
+ gtk_grab_add (gde->cal_popup);
- LEAVE(" ");
+ LEAVE(" ");
}
/* This function is a customized gtk_combo_box_list_button_pressed(). */
@@ -333,37 +336,37 @@
GdkEventButton *event,
gpointer data)
{
- GNCDateEdit *gde = GNC_DATE_EDIT(data);
- GtkWidget *ewidget = gtk_get_event_widget ((GdkEvent *)event);
+ GNCDateEdit *gde = GNC_DATE_EDIT(data);
+ GtkWidget *ewidget = gtk_get_event_widget ((GdkEvent *)event);
- ENTER("widget=%p, ewidget=%p, event=%p, gde=%p", widget, ewidget, event, gde);
+ ENTER("widget=%p, ewidget=%p, event=%p, gde=%p", widget, ewidget, event, gde);
- /* While popped up, ignore presses outside the popup window. */
- if (ewidget == gde->cal_popup)
- {
- LEAVE("Press on calendar. Ignoring.");
- return TRUE;
- }
+ /* While popped up, ignore presses outside the popup window. */
+ if (ewidget == gde->cal_popup)
+ {
+ LEAVE("Press on calendar. Ignoring.");
+ return TRUE;
+ }
- /* If the press isn't to make the popup appear, just propagate it. */
- if (ewidget != gde->date_button ||
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gde->date_button)))
- {
- LEAVE("Press, not on popup button, or while popup is raised.");
- return FALSE;
- }
+ /* If the press isn't to make the popup appear, just propagate it. */
+ if (ewidget != gde->date_button ||
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gde->date_button)))
+ {
+ LEAVE("Press, not on popup button, or while popup is raised.");
+ return FALSE;
+ }
- if (!GTK_WIDGET_HAS_FOCUS (gde->date_button))
- gtk_widget_grab_focus (gde->date_button);
+ if (!GTK_WIDGET_HAS_FOCUS (gde->date_button))
+ gtk_widget_grab_focus (gde->date_button);
- gde->popup_in_progress = TRUE;
+ gde->popup_in_progress = TRUE;
- gnc_date_edit_popup (gde);
+ gnc_date_edit_popup (gde);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gde->date_button), TRUE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gde->date_button), TRUE);
- LEAVE("Popup in progress.");
- return TRUE;
+ LEAVE("Popup in progress.");
+ return TRUE;
}
static gboolean
@@ -371,297 +374,300 @@
GdkEventButton *event,
gpointer data)
{
- GNCDateEdit *gde = GNC_DATE_EDIT(data);
- GtkWidget *ewidget = gtk_get_event_widget ((GdkEvent *)event);
- gboolean popup_in_progress = FALSE;
+ GNCDateEdit *gde = GNC_DATE_EDIT(data);
+ GtkWidget *ewidget = gtk_get_event_widget ((GdkEvent *)event);
+ gboolean popup_in_progress = FALSE;
- ENTER("widget=%p, ewidget=%p, event=%p, gde=%p", widget, ewidget, event, gde);
+ ENTER("widget=%p, ewidget=%p, event=%p, gde=%p", widget, ewidget, event, gde);
- if (gde->popup_in_progress)
- {
- popup_in_progress = TRUE;
- gde->popup_in_progress = FALSE;
- }
+ if (gde->popup_in_progress)
+ {
+ popup_in_progress = TRUE;
+ gde->popup_in_progress = FALSE;
+ }
- /* Propagate releases on the calendar. */
- if (ewidget == gde->calendar)
- {
- LEAVE("Button release on calendar.");
- return FALSE;
- }
+ /* Propagate releases on the calendar. */
+ if (ewidget == gde->calendar)
+ {
+ LEAVE("Button release on calendar.");
+ return FALSE;
+ }
- if (ewidget == gde->date_button)
- {
- /* Pop down if we're up and it isn't due to the preceding press. */
- if (!popup_in_progress &&
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gde->date_button)))
+ if (ewidget == gde->date_button)
{
- gnc_date_edit_popdown (gde);
- LEAVE("Release on button, not in progress. Popped down.");
- return TRUE;
+ /* Pop down if we're up and it isn't due to the preceding press. */
+ if (!popup_in_progress &&
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gde->date_button)))
+ {
+ gnc_date_edit_popdown (gde);
+ LEAVE("Release on button, not in progress. Popped down.");
+ return TRUE;
+ }
+
+ LEAVE("Button release on button. Allowing.");
+ return FALSE;
}
- LEAVE("Button release on button. Allowing.");
- return FALSE;
- }
-
- /* Pop down on a release anywhere else. */
- gnc_date_edit_popdown (gde);
- LEAVE("Release not on button or calendar. Popping down.");
- return TRUE;
+ /* Pop down on a release anywhere else. */
+ gnc_date_edit_popdown (gde);
+ LEAVE("Release not on button or calendar. Popping down.");
+ return TRUE;
}
static void
gnc_date_edit_button_toggled (GtkWidget *widget, GNCDateEdit *gde)
{
- ENTER("widget %p, gde %p", widget, gde);
+ ENTER("widget %p, gde %p", widget, gde);
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
- {
- if (!gde->popup_in_progress)
- gnc_date_edit_popup (gde);
- }
- else
- gnc_date_edit_popdown (gde);
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
+ {
+ if (!gde->popup_in_progress)
+ gnc_date_edit_popup (gde);
+ }
+ else
+ gnc_date_edit_popdown (gde);
- LEAVE(" ");
+ LEAVE(" ");
}
-typedef struct {
- char *hour;
- GNCDateEdit *gde;
+typedef struct
+{
+ char *hour;
+ GNCDateEdit *gde;
} hour_info_t;
static void
set_time (GtkWidget *widget, hour_info_t *hit)
{
- gtk_entry_set_text (GTK_ENTRY (hit->gde->time_entry), hit->hour);
- g_signal_emit (G_OBJECT (hit->gde), date_edit_signals [TIME_CHANGED], 0);
+ gtk_entry_set_text (GTK_ENTRY (hit->gde->time_entry), hit->hour);
+ g_signal_emit (G_OBJECT (hit->gde), date_edit_signals [TIME_CHANGED], 0);
}
static void
free_resources (GtkWidget *widget, hour_info_t *hit)
{
- g_free (hit->hour);
- g_free (hit);
+ g_free (hit->hour);
+ g_free (hit);
}
static void
fill_time_popup (GtkWidget *widget, GNCDateEdit *gde)
{
- GtkWidget *menu;
- struct tm *tm_returned;
- struct tm mtm;
- time_t current_time;
- int i, j;
+ GtkWidget *menu;
+ struct tm *tm_returned;
+ struct tm mtm;
+ time_t current_time;
+ int i, j;
- if (gde->lower_hour > gde->upper_hour)
- return;
+ if (gde->lower_hour > gde->upper_hour)
+ return;
- menu = gtk_menu_new ();
- gtk_option_menu_set_menu (GTK_OPTION_MENU (gde->time_popup), menu);
+ menu = gtk_menu_new ();
+ gtk_option_menu_set_menu (GTK_OPTION_MENU (gde->time_popup), menu);
- time (¤t_time);
- tm_returned = localtime_r (¤t_time, &mtm);
- g_return_if_fail(tm_returned != NULL);
+ time (¤t_time);
+ tm_returned = localtime_r (¤t_time, &mtm);
+ g_return_if_fail(tm_returned != NULL);
- for (i = gde->lower_hour; i <= gde->upper_hour; i++){
- GtkWidget *item, *submenu;
- hour_info_t *hit;
- char buffer [40];
+ for (i = gde->lower_hour; i <= gde->upper_hour; i++)
+ {
+ GtkWidget *item, *submenu;
+ hour_info_t *hit;
+ char buffer [40];
- mtm.tm_hour = i;
- mtm.tm_min = 0;
- hit = g_new (hour_info_t, 1);
+ mtm.tm_hour = i;
+ mtm.tm_min = 0;
+ hit = g_new (hour_info_t, 1);
- if (gde->flags & GNC_DATE_EDIT_24_HR)
- qof_strftime (buffer, sizeof (buffer), "%H:00", &mtm);
- else
- qof_strftime (buffer, sizeof (buffer), "%I:00 %p ", &mtm);
- hit->hour = g_strdup (buffer);
- hit->gde = gde;
+ if (gde->flags & GNC_DATE_EDIT_24_HR)
+ qof_strftime (buffer, sizeof (buffer), "%H:00", &mtm);
+ else
+ qof_strftime (buffer, sizeof (buffer), "%I:00 %p ", &mtm);
+ hit->hour = g_strdup (buffer);
+ hit->gde = gde;
- item = gtk_menu_item_new_with_label (buffer);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ item = gtk_menu_item_new_with_label (buffer);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
#if 0
- g_signal_connect (G_OBJECT (item), "activate",
- G_CALLBACK (set_time), hit);
+ g_signal_connect (G_OBJECT (item), "activate",
+ G_CALLBACK (set_time), hit);
#endif
- g_signal_connect (G_OBJECT (item), "destroy",
- G_CALLBACK (free_resources), hit);
- gtk_widget_show (item);
+ g_signal_connect (G_OBJECT (item), "destroy",
+ G_CALLBACK (free_resources), hit);
+ gtk_widget_show (item);
- submenu = gtk_menu_new ();
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
- for (j = 0; j < 60; j += 15){
- GtkWidget *mins;
+ submenu = gtk_menu_new ();
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
+ for (j = 0; j < 60; j += 15)
+ {
+ GtkWidget *mins;
- mtm.tm_min = j;
- hit = g_new (hour_info_t, 1);
- if (gde->flags & GNC_DATE_EDIT_24_HR)
- qof_strftime (buffer, sizeof (buffer),
- "%H:%M", &mtm);
- else
- qof_strftime (buffer, sizeof (buffer),
- "%I:%M %p", &mtm);
- hit->hour = g_strdup (buffer);
- hit->gde = gde;
+ mtm.tm_min = j;
+ hit = g_new (hour_info_t, 1);
+ if (gde->flags & GNC_DATE_EDIT_24_HR)
+ qof_strftime (buffer, sizeof (buffer),
+ "%H:%M", &mtm);
+ else
+ qof_strftime (buffer, sizeof (buffer),
+ "%I:%M %p", &mtm);
+ hit->hour = g_strdup (buffer);
+ hit->gde = gde;
- mins = gtk_menu_item_new_with_label (buffer);
- gtk_menu_shell_append (GTK_MENU_SHELL (submenu), mins);
- g_signal_connect (G_OBJECT (mins), "activate",
- G_CALLBACK (set_time), hit);
- g_signal_connect (G_OBJECT (item), "destroy",
- G_CALLBACK (free_resources),
- hit);
- gtk_widget_show (mins);
- }
- }
+ mins = gtk_menu_item_new_with_label (buffer);
+ gtk_menu_shell_append (GTK_MENU_SHELL (submenu), mins);
+ g_signal_connect (G_OBJECT (mins), "activate",
+ G_CALLBACK (set_time), hit);
+ g_signal_connect (G_OBJECT (item), "destroy",
+ G_CALLBACK (free_resources),
+ hit);
+ gtk_widget_show (mins);
+ }
+ }
}
static void
gnc_date_edit_class_init (GNCDateEditClass *klass)
{
- GtkContainerClass *container_class = (GtkContainerClass *) klass;
- GObjectClass *object_class = (GObjectClass *) klass;
+ GtkContainerClass *container_class = (GtkContainerClass *) klass;
+ GObjectClass *object_class = (GObjectClass *) klass;
- object_class = (GObjectClass*) klass;
+ object_class = (GObjectClass*) klass;
- parent_class = g_type_class_ref(GTK_TYPE_HBOX);
+ parent_class = g_type_class_ref(GTK_TYPE_HBOX);
- date_edit_signals [TIME_CHANGED] =
- g_signal_new ("time_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GnomeDateEditClass, time_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ date_edit_signals [TIME_CHANGED] =
+ g_signal_new ("time_changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GnomeDateEditClass, time_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
- date_edit_signals [DATE_CHANGED] =
- g_signal_new ("date_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GnomeDateEditClass, date_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ date_edit_signals [DATE_CHANGED] =
+ g_signal_new ("date_changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GnomeDateEditClass, date_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
- container_class->forall = gnc_date_edit_forall;
+ container_class->forall = gnc_date_edit_forall;
- object_class->dispose = gnc_date_edit_dispose;
- object_class->finalize = gnc_date_edit_finalize;
+ object_class->dispose = gnc_date_edit_dispose;
+ object_class->finalize = gnc_date_edit_finalize;
- klass->date_changed = NULL;
- klass->time_changed = NULL;
+ klass->date_changed = NULL;
+ klass->time_changed = NULL;
}
static void
gnc_date_edit_init (GNCDateEdit *gde)
{
- gde->disposed = FALSE;
- gde->popup_in_progress = FALSE;
- gde->lower_hour = 7;
- gde->upper_hour = 19;
- gde->flags = GNC_DATE_EDIT_SHOW_TIME;
+ gde->disposed = FALSE;
+ gde->popup_in_progress = FALSE;
+ gde->lower_hour = 7;
+ gde->upper_hour = 19;
+ gde->flags = GNC_DATE_EDIT_SHOW_TIME;
}
static void
gnc_date_edit_finalize (GObject *object)
{
- GNCDateEdit *gde;
+ GNCDateEdit *gde;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GNC_IS_DATE_EDIT (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GNC_IS_DATE_EDIT (object));
- gde = GNC_DATE_EDIT (object);
+ gde = GNC_DATE_EDIT (object);
- if (G_OBJECT_CLASS (parent_class)->finalize)
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
+ if (G_OBJECT_CLASS (parent_class)->finalize)
+ (* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
static void
gnc_date_edit_dispose (GObject *object)
{
- GNCDateEdit *gde;
+ GNCDateEdit *gde;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GNC_IS_DATE_EDIT (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GNC_IS_DATE_EDIT (object));
- gde = GNC_DATE_EDIT (object);
+ gde = GNC_DATE_EDIT (object);
- if(gde->disposed)
- return;
+ if (gde->disposed)
+ return;
- gde->disposed = TRUE;
+ gde->disposed = TRUE;
- /* Only explicitly destroy the toplevel elements */
+ /* Only explicitly destroy the toplevel elements */
- gtk_widget_destroy (GTK_WIDGET(gde->date_entry));
- gde->date_entry = NULL;
+ gtk_widget_destroy (GTK_WIDGET(gde->date_entry));
+ gde->date_entry = NULL;
- gtk_widget_destroy (GTK_WIDGET(gde->date_button));
- gde->date_button= NULL;
+ gtk_widget_destroy (GTK_WIDGET(gde->date_button));
+ gde->date_button = NULL;
- gtk_widget_destroy (GTK_WIDGET(gde->time_entry));
- gde->time_entry = NULL;
+ gtk_widget_destroy (GTK_WIDGET(gde->time_entry));
+ gde->time_entry = NULL;
- gtk_widget_destroy (GTK_WIDGET(gde->time_popup));
- gde->time_popup = NULL;
+ gtk_widget_destroy (GTK_WIDGET(gde->time_popup));
+ gde->time_popup = NULL;
- if (G_OBJECT_CLASS (parent_class)->dispose)
- (* G_OBJECT_CLASS (parent_class)->dispose) (object);
+ if (G_OBJECT_CLASS (parent_class)->dispose)
+ (* G_OBJECT_CLASS (parent_class)->dispose) (object);
}
static void
gnc_date_edit_forall (GtkContainer *container, gboolean include_internals,
GtkCallback callback, gpointer callback_data)
{
- g_return_if_fail (container != NULL);
- g_return_if_fail (GNC_IS_DATE_EDIT (container));
- g_return_if_fail (callback != NULL);
+ g_return_if_fail (container != NULL);
+ g_return_if_fail (GNC_IS_DATE_EDIT (container));
+ g_return_if_fail (callback != NULL);
- /* Let GtkBox handle things only if the internal widgets need
- * to be poked. */
- if (!include_internals)
- return;
+ /* Let GtkBox handle things only if the internal widgets need
+ * to be poked. */
+ if (!include_internals)
+ return;
- if (!GTK_CONTAINER_CLASS (parent_class)->forall)
- return;
+ if (!GTK_CONTAINER_CLASS (parent_class)->forall)
+ return;
- GTK_CONTAINER_CLASS (parent_class)->forall (container,
- include_internals,
- callback,
- callback_data);
+ GTK_CONTAINER_CLASS (parent_class)->forall (container,
+ include_internals,
+ callback,
+ callback_data);
}
static void
gnc_date_edit_set_time_tm (GNCDateEdit *gde, struct tm *mytm)
{
- char buffer [40];
+ char buffer [40];
- g_return_if_fail(mytm != NULL);
+ g_return_if_fail(mytm != NULL);
- /* Update the date text. */
- qof_print_date_dmy_buff(buffer, 40,
- mytm->tm_mday,
- mytm->tm_mon + 1,
- 1900 + mytm->tm_year);
- gtk_entry_set_text(GTK_ENTRY(gde->date_entry), buffer);
+ /* Update the date text. */
+ qof_print_date_dmy_buff(buffer, 40,
+ mytm->tm_mday,
+ mytm->tm_mon + 1,
+ 1900 + mytm->tm_year);
+ gtk_entry_set_text(GTK_ENTRY(gde->date_entry), buffer);
- /* Update the calendar. */
- gtk_calendar_select_day(GTK_CALENDAR (gde->calendar), 1);
- gtk_calendar_select_month(GTK_CALENDAR (gde->calendar),
- mytm->tm_mon, 1900 + mytm->tm_year);
- gtk_calendar_select_day(GTK_CALENDAR (gde->calendar), mytm->tm_mday);
+ /* Update the calendar. */
+ gtk_calendar_select_day(GTK_CALENDAR (gde->calendar), 1);
+ gtk_calendar_select_month(GTK_CALENDAR (gde->calendar),
+ mytm->tm_mon, 1900 + mytm->tm_year);
+ gtk_calendar_select_day(GTK_CALENDAR (gde->calendar), mytm->tm_mday);
- /* Set the time of day. */
- if (gde->flags & GNC_DATE_EDIT_24_HR)
- qof_strftime (buffer, sizeof (buffer), "%H:%M", mytm);
- else
- qof_strftime (buffer, sizeof (buffer), "%I:%M %p", mytm);
- gtk_entry_set_text(GTK_ENTRY(gde->time_entry), buffer);
+ /* Set the time of day. */
+ if (gde->flags & GNC_DATE_EDIT_24_HR)
+ qof_strftime (buffer, sizeof (buffer), "%H:%M", mytm);
+ else
+ qof_strftime (buffer, sizeof (buffer), "%I:%M %p", mytm);
+ gtk_entry_set_text(GTK_ENTRY(gde->time_entry), buffer);
}
/**
@@ -675,48 +681,48 @@
void
gnc_date_edit_set_time (GNCDateEdit *gde, time_t the_time)
{
- struct tm *tm_returned;
- struct tm tm_to_set;
+ struct tm *tm_returned;
+ struct tm tm_to_set;
- g_return_if_fail (gde != NULL);
- g_return_if_fail (GNC_IS_DATE_EDIT (gde));
+ g_return_if_fail (gde != NULL);
+ g_return_if_fail (GNC_IS_DATE_EDIT (gde));
- /* If the_time is invalid, use the last valid time
- * seen (or as a last resort, the current date). */
- if (the_time == (time_t) -1)
- {
- if (gde->initial_time == (time_t) -1)
+ /* If the_time is invalid, use the last valid time
+ * seen (or as a last resort, the current date). */
+ if (the_time == (time_t) - 1)
+ {
+ if (gde->initial_time == (time_t) - 1)
gde->initial_time = gnc_timet_get_today_start();
- the_time = gde->initial_time;
- }
- else
- gde->initial_time = the_time;
+ the_time = gde->initial_time;
+ }
+ else
+ gde->initial_time = the_time;
- /* Convert time_t to tm. */
- tm_returned = localtime_r (&the_time, &tm_to_set);
- g_return_if_fail(tm_returned != NULL);
+ /* Convert time_t to tm. */
+ tm_returned = localtime_r (&the_time, &tm_to_set);
+ g_return_if_fail(tm_returned != NULL);
- gnc_date_edit_set_time_tm(gde, &tm_to_set);
+ gnc_date_edit_set_time_tm(gde, &tm_to_set);
}
void
gnc_date_edit_set_gdate (GNCDateEdit *gde, const GDate *date)
{
- struct tm mytm;
- time_t t;
+ struct tm mytm;
+ time_t t;
- g_return_if_fail(gde && GNC_IS_DATE_EDIT(gde) &&
- date && g_date_valid(date));
- g_date_to_struct_tm(date, &mytm);
- t = mktime(&mytm);
- if (t != (time_t)(-1))
- gnc_date_edit_set_time(gde, t);
+ g_return_if_fail(gde && GNC_IS_DATE_EDIT(gde) &&
+ date && g_date_valid(date));
+ g_date_to_struct_tm(date, &mytm);
+ t = mktime(&mytm);
+ if (t != (time_t)(-1))
+ gnc_date_edit_set_time(gde, t);
}
void
gnc_date_edit_set_time_ts (GNCDateEdit *gde, Timespec the_time)
{
- gnc_date_edit_set_time (gde, the_time.tv_sec);
+ gnc_date_edit_set_time (gde, the_time.tv_sec);
}
/**
@@ -731,172 +737,173 @@
void
gnc_date_edit_set_popup_range (GNCDateEdit *gde, int low_hour, int up_hour)
{
- g_return_if_fail (gde != NULL);
- g_return_if_fail (GNC_IS_DATE_EDIT (gde));
+ g_return_if_fail (gde != NULL);
+ g_return_if_fail (GNC_IS_DATE_EDIT (gde));
- gde->lower_hour = low_hour;
- gde->upper_hour = up_hour;
+ gde->lower_hour = low_hour;
+ gde->upper_hour = up_hour;
- fill_time_popup(NULL, gde);
+ fill_time_popup(NULL, gde);
}
/* This code should be kept in sync with src/register/datecell.c */
static int
date_accel_key_press(GtkWidget *widget, GdkEventKey *event, gpointer data)
{
- GNCDateEdit *gde = data;
- G_CONST_RETURN char *string;
- struct tm tm;
+ GNCDateEdit *gde = data;
+ G_CONST_RETURN char *string;
+ struct tm tm;
- string = gtk_entry_get_text (GTK_ENTRY (widget));
+ string = gtk_entry_get_text (GTK_ENTRY (widget));
- tm = gnc_date_edit_get_date_internal (gde);
+ tm = gnc_date_edit_get_date_internal (gde);
- if (!gnc_handle_date_accelerator (event, &tm, string))
- return FALSE;
+ if (!gnc_handle_date_accelerator (event, &tm, string))
+ return FALSE;
- gnc_date_edit_set_time (gde, mktime (&tm));
+ gnc_date_edit_set_time (gde, mktime (&tm));
- g_signal_emit (G_OBJECT (gde), date_edit_signals [TIME_CHANGED], 0);
- return TRUE;
+ g_signal_emit (G_OBJECT (gde), date_edit_signals [TIME_CHANGED], 0);
+ return TRUE;
}
static gint
key_press_entry (GtkWidget *widget, GdkEventKey *event, gpointer data)
{
- if (!date_accel_key_press(widget, event, data))
- return FALSE;
+ if (!date_accel_key_press(widget, event, data))
+ return FALSE;
- g_signal_stop_emission_by_name (widget, "key-press-event");
- return TRUE;
+ g_signal_stop_emission_by_name (widget, "key-press-event");
+ return TRUE;
}
static int
date_focus_out_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
{
- GNCDateEdit *gde = data;
- struct tm tm;
+ GNCDateEdit *gde = data;
+ struct tm tm;
- /* Get the date entered and attempt to use it. */
- tm = gnc_date_edit_get_date_internal (gde);
- gnc_date_edit_set_time (gde, mktime (&tm));
+ /* Get the date entered and attempt to use it. */
+ tm = gnc_date_edit_get_date_internal (gde);
+ gnc_date_edit_set_time (gde, mktime (&tm));
- /* Get the date again in case it was invalid the first time. */
- tm = gnc_date_edit_get_date_internal (gde);
+ /* Get the date again in case it was invalid the first time. */
+ tm = gnc_date_edit_get_date_internal (gde);
- g_signal_emit (gde, date_edit_signals [DATE_CHANGED], 0);
- g_signal_emit (gde, date_edit_signals [TIME_CHANGED], 0);
+ g_signal_emit (gde, date_edit_signals [DATE_CHANGED], 0);
+ g_signal_emit (gde, date_edit_signals [TIME_CHANGED], 0);
- return FALSE;
+ return FALSE;
}
static void
create_children (GNCDateEdit *gde)
{
- GtkWidget *frame;
- GtkWidget *hbox;
- GtkWidget *arrow;
+ GtkWidget *frame;
+ GtkWidget *hbox;
+ GtkWidget *arrow;
- /* Create the text entry area. */
- gde->date_entry = gtk_entry_new ();
- gtk_entry_set_width_chars (GTK_ENTRY (gde->date_entry), 11);
- gtk_box_pack_start (GTK_BOX (gde), gde->date_entry, TRUE, TRUE, 0);
- gtk_widget_show (GTK_WIDGET(gde->date_entry));
- g_signal_connect (G_OBJECT (gde->date_entry), "key-press-event",
- G_CALLBACK (key_press_entry), gde);
- g_signal_connect (G_OBJECT (gde->date_entry), "focus-out-event",
- G_CALLBACK (date_focus_out_event), gde);
+ /* Create the text entry area. */
+ gde->date_entry = gtk_entry_new ();
+ gtk_entry_set_width_chars (GTK_ENTRY (gde->date_entry), 11);
+ gtk_box_pack_start (GTK_BOX (gde), gde->date_entry, TRUE, TRUE, 0);
+ gtk_widget_show (GTK_WIDGET(gde->date_entry));
+ g_signal_connect (G_OBJECT (gde->date_entry), "key-press-event",
+ G_CALLBACK (key_press_entry), gde);
+ g_signal_connect (G_OBJECT (gde->date_entry), "focus-out-event",
+ G_CALLBACK (date_focus_out_event), gde);
- /* Create the popup button. */
- gde->date_button = gtk_toggle_button_new ();
- g_signal_connect (gde->date_button, "button-press-event",
- G_CALLBACK(gnc_date_edit_button_pressed), gde);
- g_signal_connect (G_OBJECT (gde->date_button), "toggled",
- G_CALLBACK (gnc_date_edit_button_toggled), gde);
- gtk_box_pack_start (GTK_BOX (gde), gde->date_button, FALSE, FALSE, 0);
+ /* Create the popup button. */
+ gde->date_button = gtk_toggle_button_new ();
+ g_signal_connect (gde->date_button, "button-press-event",
+ G_CALLBACK(gnc_date_edit_button_pressed), gde);
+ g_signal_connect (G_OBJECT (gde->date_button), "toggled",
+ G_CALLBACK (gnc_date_edit_button_toggled), gde);
+ gtk_box_pack_start (GTK_BOX (gde), gde->date_button, FALSE, FALSE, 0);
- hbox = gtk_hbox_new (FALSE, 3);
- gtk_container_add (GTK_CONTAINER (gde->date_button), hbox);
- gtk_widget_show (GTK_WIDGET(hbox));
+ hbox = gtk_hbox_new (FALSE, 3);
+ gtk_container_add (GTK_CONTAINER (gde->date_button), hbox);
+ gtk_widget_show (GTK_WIDGET(hbox));
- /* Calendar label, only shown if the date editor has a time field */
- gde->cal_label = gtk_label_new (_("Calendar"));
- gtk_misc_set_alignment (GTK_MISC (gde->cal_label), 0.0, 0.5);
- gtk_box_pack_start (GTK_BOX (hbox), gde->cal_label, TRUE, TRUE, 0);
- if (gde->flags & GNC_DATE_EDIT_SHOW_TIME)
- gtk_widget_show (GTK_WIDGET(gde->cal_label));
+ /* Calendar label, only shown if the date editor has a time field */
+ gde->cal_label = gtk_label_new (_("Calendar"));
+ gtk_misc_set_alignment (GTK_MISC (gde->cal_label), 0.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (hbox), gde->cal_label, TRUE, TRUE, 0);
+ if (gde->flags & GNC_DATE_EDIT_SHOW_TIME)
+ gtk_widget_show (GTK_WIDGET(gde->cal_label));
- /* Graphic for the popup button. */
- arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
- gtk_box_pack_start (GTK_BOX (hbox), arrow, TRUE, FALSE, 0);
- gtk_widget_show (GTK_WIDGET(arrow));
+ /* Graphic for the popup button. */
+ arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
+ gtk_box_pack_start (GTK_BOX (hbox), arrow, TRUE, FALSE, 0);
+ gtk_widget_show (GTK_WIDGET(arrow));
- gtk_widget_show (GTK_WIDGET(gde->date_button));
+ gtk_widget_show (GTK_WIDGET(gde->date_button));
- /* Time entry controls. */
- gde->time_entry = gtk_entry_new ();
- gtk_entry_set_max_length (GTK_ENTRY(gde->time_entry), 12);
- gtk_widget_set_size_request (GTK_WIDGET(gde->time_entry), 88, -1);
- gtk_box_pack_start (GTK_BOX (gde), gde->time_entry, TRUE, TRUE, 0);
+ /* Time entry controls. */
+ gde->time_entry = gtk_entry_new ();
+ gtk_entry_set_max_length (GTK_ENTRY(gde->time_entry), 12);
+ gtk_widget_set_size_request (GTK_WIDGET(gde->time_entry), 88, -1);
+ gtk_box_pack_start (GTK_BOX (gde), gde->time_entry, TRUE, TRUE, 0);
- gde->time_popup = gtk_option_menu_new ();
- gtk_box_pack_start (GTK_BOX (gde), gde->time_popup, FALSE, FALSE, 0);
+ gde->time_popup = gtk_option_menu_new ();
+ gtk_box_pack_start (GTK_BOX (gde), gde->time_popup, FALSE, FALSE, 0);
- /* We do not create the popup menu with the hour range until we are
- * realized, so that it uses the values that the user might supply in a
- * future call to gnc_date_edit_set_popup_range
- */
- g_signal_connect (G_OBJECT (gde), "realize",
- G_CALLBACK (fill_time_popup), gde);
+ /* We do not create the popup menu with the hour range until we are
+ * realized, so that it uses the values that the user might supply in a
+ * future call to gnc_date_edit_set_popup_range
+ */
+ g_signal_connect (G_OBJECT (gde), "realize",
+ G_CALLBACK (fill_time_popup), gde);
- if (gde->flags & GNC_DATE_EDIT_SHOW_TIME) {
- gtk_widget_show (GTK_WIDGET(gde->time_entry));
- gtk_widget_show (GTK_WIDGET(gde->time_popup));
- }
+ if (gde->flags & GNC_DATE_EDIT_SHOW_TIME)
+ {
+ gtk_widget_show (GTK_WIDGET(gde->time_entry));
+ gtk_widget_show (GTK_WIDGET(gde->time_popup));
+ }
- gde->cal_popup = gtk_window_new (GTK_WINDOW_POPUP);
- gtk_widget_set_name (gde->cal_popup, "gnc-date-edit-popup-window");
+ gde->cal_popup = gtk_window_new (GTK_WINDOW_POPUP);
+ gtk_widget_set_name (gde->cal_popup, "gnc-date-edit-popup-window");
gtk_window_set_type_hint (GTK_WINDOW (gde->cal_popup),
GDK_WINDOW_TYPE_HINT_COMBO);
- gtk_widget_set_events (GTK_WIDGET(gde->cal_popup),
- gtk_