diff --git a/ChangeLog b/ChangeLog index 7d8e7a1212..fad1c7efff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2006-06-01 Andreas Köhler + * src/gnome-utils/dialog-preferences.c: Do not try to find + positions for alphabetic insertions of add_on pages, but rather + append and then sort pages in the end. Solves appearance of pref + dialog in non-C locales. + + * src/gnome-utils/glade/preferences.glade: Move "Accounting + Period" to the top, regardless of above. + * src/gnome-utils/gnc-main-window.c: Cancel renaming of a page when GDK_Escape is pressed. Fixes #343226. diff --git a/src/gnome-utils/dialog-preferences.c b/src/gnome-utils/dialog-preferences.c index 9b58fe05c2..3b9efb0f26 100644 --- a/src/gnome-utils/dialog-preferences.c +++ b/src/gnome-utils/dialog-preferences.c @@ -161,7 +161,7 @@ static gint gnc_prefs_compare_addins (addition *a, addition *b) { - return strcmp(a->tabname, b->tabname); + return g_utf8_collate(a->tabname, b->tabname); } @@ -316,26 +316,6 @@ gnc_prefs_build_widget_table (GladeXML *xml, g_list_free(interesting); } - -/** This data structure is used while building the preferences dialog - * to perform lookups in the dialog under construction. It maintains - * state information between invocations of the function - * gnc_prefs_find_page which is called via a foreach loop over each - * addition. */ -struct find_data { - /** The notebook being searched. */ - GtkNotebook *notebook; - /** The name of the tab being searched for. */ - const gchar *tabname; - /** The notebook index where the tab was found. */ - gint index; - /** If TRUE, the code will search for an exact match of tab name. If - * FALSE, the code will search for where this tab falls - * alphabetically. */ - gboolean exact; -}; - - /** This data structure is used while building the preferences dialog * to copy a table from a glade file to the dialog under * construction. It maintains state information between invocations @@ -352,58 +332,35 @@ struct copy_data { }; -/** This function is used while building the preferences dialog. It - * searches through the existing pages in the dialog to determine - * where a new page should go alphabetically. If a matching page - * name is found, a pointer to that page will be returned. This - * function can also be called and asked to perform an exact match - * instead of just determining where a page would go. - * - * @internal - * - * @param child A pointer to one page from the GtkNotebook contained - * in the preferences dialog. - * - * @param data A pointer to a data structure passed in by the caller. - */ -static void -gnc_prefs_find_page (GtkWidget *child, - gpointer data) +static GtkWidget * +gnc_prefs_find_page (GtkNotebook *notebook, const gchar *name) { - struct find_data *location; - const gchar *child_tabname; - gint index; + int n_pages; + GtkWidget *child; + const gchar *child_name; - g_return_if_fail(child != NULL); - g_return_if_fail(data != NULL); + g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), NULL); + g_return_val_if_fail (name, NULL); ENTER(""); - location = data; - if (location->index >= 0) { - LEAVE("already found"); - return; - } - child_tabname = gtk_notebook_get_tab_label_text(location->notebook, child); - index = gtk_notebook_page_num(location->notebook, child); - DEBUG("Checking index %d, name %s", index, child_tabname); - - if (location->exact) { - if (strcmp(location->tabname, child_tabname) == 0) { - location->index = index; - LEAVE("index is %d", index); - return; - } - LEAVE("not page %d", index); - return; - } - if (strcmp(location->tabname, child_tabname) > 0) { - LEAVE("after page %d", index); - return; + n_pages = gtk_notebook_get_n_pages (notebook); + + for (int i=0; iindex = index; - LEAVE("insert at offset %d", index); + LEAVE("not found"); + return NULL; } @@ -468,7 +425,6 @@ gnc_preferences_build_page (gpointer data, GtkWidget *dialog, *existing_content, *new_content, *label; GtkNotebook *notebook; addition *add_in; - struct find_data location; struct copy_data copydata; gint rows, cols; @@ -498,18 +454,12 @@ gnc_preferences_build_page (gpointer data, /* Prepare for recursion */ notebook = g_object_get_data(G_OBJECT(dialog), NOTEBOOK); - location.notebook = notebook; - location.index = -1; - location.tabname = add_in->tabname; - location.exact = FALSE; if (add_in->full_page) { - gtk_container_foreach(GTK_CONTAINER(notebook), gnc_prefs_find_page, - &location); label = gtk_label_new(add_in->tabname); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - gtk_notebook_insert_page(notebook, new_content, label, location.index); - LEAVE("added page at index %d", location.index); + gtk_notebook_append_page(notebook, new_content, label); + LEAVE("appended page"); return; } @@ -529,26 +479,21 @@ gnc_preferences_build_page (gpointer data, } /* Does the page exist or must we create it */ - location.exact = TRUE; - gtk_container_foreach(GTK_CONTAINER(notebook), gnc_prefs_find_page, - &location); - if (location.index == -1) { + existing_content = gnc_prefs_find_page(notebook, add_in->tabname); + + if (!existing_content) { /* No existing content with this name. Create a blank page */ - location.exact = FALSE; rows = 0; existing_content = gtk_table_new(0, 4, FALSE); gtk_container_set_border_width(GTK_CONTAINER(existing_content), 6); - gtk_container_foreach(GTK_CONTAINER(notebook), gnc_prefs_find_page, - &location); label = gtk_label_new(add_in->tabname); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - gtk_notebook_insert_page(notebook, existing_content, label, location.index); + gtk_notebook_append_page(notebook, existing_content, label); gtk_widget_show_all(existing_content); - DEBUG("created new page %s at index %d", add_in->tabname, location.index); + DEBUG("created new page %s, appended it", add_in->tabname); } else { - existing_content = gtk_notebook_get_nth_page(notebook, location.index); g_object_get(G_OBJECT(existing_content), "n-rows", &rows, NULL); - DEBUG("found existing page %s at index %d", add_in->tabname, location.index); + DEBUG("found existing page %s", add_in->tabname); } /* Maybe add a spacer row */ @@ -569,7 +514,37 @@ gnc_preferences_build_page (gpointer data, ©data); gtk_object_sink(GTK_OBJECT(new_content)); - LEAVE("added to page at index %d", location.index); + 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)); +} + +static void +gnc_prefs_sort_pages (GtkNotebook *notebook) +{ + gint n_pages, i; + GList *tabs=NULL, *iter=NULL; + + 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)); + + /* 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); + + g_list_free (tabs); } @@ -661,7 +636,7 @@ gnc_prefs_connect_radio_button (GtkRadioButton *button) /* Get the current value. */ value = gnc_gconf_get_string(key, NULL, NULL); if (value) { - active = (strcmp(value, button_name) == 0); + 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. */ @@ -1395,6 +1370,10 @@ gnc_preferences_dialog_create(void) 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); + DEBUG("We have the following interesting widgets:"); g_hash_table_foreach(table, (GHFunc)gnc_prefs_connect_one, dialog); DEBUG("Done with interesting widgets."); diff --git a/src/gnome-utils/glade/preferences.glade b/src/gnome-utils/glade/preferences.glade index a46d59eff5..6131997242 100644 --- a/src/gnome-utils/glade/preferences.glade +++ b/src/gnome-utils/glade/preferences.glade @@ -211,19 +211,19 @@ False - + 6 True - 15 + 11 4 False 0 - 12 + 0 - + True - <b>Separator Character</b> + <b>Summarybar Content</b> False True GTK_JUSTIFY_LEFT @@ -236,7 +236,7 @@ 0 - 3 + 4 0 1 fill @@ -245,11 +245,11 @@ - + True - Use only 'debit' and 'credit' instead of informal synonyms + Show a grand total of all accounts converted to the default report currency. True - Use _formal accounting labels + Include _grand total True GTK_RELIEF_NORMAL True @@ -260,8 +260,8 @@ 0 4 - 10 - 11 + 1 + 2 12 fill @@ -269,9 +269,33 @@ - + True - <b>Labels</b> + If checked, non-currency commodities will be shown in the summary bar. If clear, only currencies will be shown. + True + Include _non-currency totals + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + 4 + 2 + 3 + 12 + fill + + + + + + + True + <b>Start Date</b> False True GTK_JUSTIFY_LEFT @@ -284,20 +308,20 @@ 0 - 1 - 9 - 10 + 4 + 4 + 5 fill - + True - + <b>End Date</b> False - False + True GTK_JUSTIFY_LEFT False False @@ -308,7 +332,7 @@ 0 - 1 + 4 8 9 fill @@ -317,11 +341,11 @@ - + True - Don't sign reverse any accounts. + Use the specified relative starting date for profit/loss calculations. True - _None + _Relative: True GTK_RELIEF_NORMAL True @@ -331,91 +355,162 @@ 0 - 2 - 7 - 8 + 1 + 5 + 6 12 fill - + fill - + True - Sign reverse balances on the following: Credit Card, Payable, Liability, Equity, and Income. + Use the specified absolute starting date for profit/loss calculations. True - C_redit accounts + _Absolute: True GTK_RELIEF_NORMAL True False False True - gconf/general/reversed_accounts/none + gconf/window/pages/account_tree/summary/start_choice/relative 0 - 2 + 1 6 7 12 fill - + fill - + True - Sign reverse balances on income and expense accounts. + Use the specified relative ending date for profit/loss calculations. Also use this date for net assets calculations. True - _Income & expense + Re_lative: True GTK_RELIEF_NORMAL True False False True - gconf/general/reversed_accounts/none 0 - 2 - 5 - 6 + 1 + 9 + 10 12 fill - + fill - + True - <b>Reverse Balanced Accounts</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 + Use the specified absolute ending date for profit/loss calculations. Also use this date for net assets calculations. + True + Ab_solute: + True + GTK_RELIEF_NORMAL + True + False + False + True + gconf/window/pages/account_tree/summary/end_choice/relative 0 + 1 + 10 + 11 + 12 + fill + fill + + + + + + True + gnc_date_edit_new_glade + 0 + 0 + Sun, 11 Sep 2005 22:33:58 GMT + + + 1 4 - 4 - 5 + 6 + 7 fill - + fill - + + True + gnc_date_edit_new_glade + 0 + 0 + Sun, 11 Sep 2005 22:33:50 GMT + + + 1 + 4 + 10 + 11 + fill + + + + + + True + gnc_period_select_new_glade + 0 + 1 + Tue, 13 Sep 2005 05:43:49 GMT + + + 1 + 4 + 9 + 10 + fill + fill + + + + + + True + gnc_period_select_new_glade + 1 + 1 + Tue, 13 Sep 2005 05:43:49 GMT + + + 1 + 4 + 5 + 6 + fill + fill + + + + + True False @@ -431,15 +526,15 @@ 0 1 - 3 - 4 + 7 + 8 fill - + True False @@ -455,17 +550,294 @@ 0 1 - 11 - 12 + 3 + 4 fill + + + False + True + + + + + + True + Accounting Period + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + tab + + + + + + 6 + True + 15 + 4 + False + 0 + 12 - + True - <b>Default Currency</b> + <b>Separator Character</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 3 + 0 + 1 + fill + + + + + + + True + Use only 'debit' and 'credit' instead of informal synonyms + True + Use _formal accounting labels + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + 4 + 10 + 11 + 12 + fill + + + + + + + True + <b>Labels</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 9 + 10 + fill + + + + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 8 + 9 + fill + + + + + + + True + Don't sign reverse any accounts. + True + _None + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + 2 + 7 + 8 + 12 + fill + + + + + + + True + Sign reverse balances on the following: Credit Card, Payable, Liability, Equity, and Income. + True + C_redit accounts + True + GTK_RELIEF_NORMAL + True + False + False + True + gconf/general/reversed_accounts/none + + + 0 + 2 + 6 + 7 + 12 + fill + + + + + + + True + Sign reverse balances on income and expense accounts. + True + _Income & expense + True + GTK_RELIEF_NORMAL + True + False + False + True + gconf/general/reversed_accounts/none + + + 0 + 2 + 5 + 6 + 12 + fill + + + + + + + True + <b>Reverse Balanced Accounts</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 4 + 4 + 5 + fill + + + + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 11 + 12 + fill + + + + + + + True + <b>Default Currency</b> False True GTK_JUSTIFY_LEFT @@ -2644,378 +3016,6 @@ - - - 6 - True - 11 - 4 - False - 0 - 0 - - - - True - <b>Summarybar Content</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 4 - 0 - 1 - fill - - - - - - - True - Show a grand total of all accounts converted to the default report currency. - True - Include _grand total - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 0 - 4 - 1 - 2 - 12 - fill - - - - - - - True - If checked, non-currency commodities will be shown in the summary bar. If clear, only currencies will be shown. - True - Include _non-currency totals - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 0 - 4 - 2 - 3 - 12 - fill - - - - - - - True - <b>Start Date</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 4 - 4 - 5 - fill - - - - - - - True - <b>End Date</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 4 - 8 - 9 - fill - - - - - - - True - Use the specified relative starting date for profit/loss calculations. - True - _Relative: - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 0 - 1 - 5 - 6 - 12 - fill - fill - - - - - - True - Use the specified absolute starting date for profit/loss calculations. - True - _Absolute: - True - GTK_RELIEF_NORMAL - True - False - False - True - gconf/window/pages/account_tree/summary/start_choice/relative - - - 0 - 1 - 6 - 7 - 12 - fill - fill - - - - - - True - Use the specified relative ending date for profit/loss calculations. Also use this date for net assets calculations. - True - Re_lative: - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 0 - 1 - 9 - 10 - 12 - fill - fill - - - - - - True - Use the specified absolute ending date for profit/loss calculations. Also use this date for net assets calculations. - True - Ab_solute: - True - GTK_RELIEF_NORMAL - True - False - False - True - gconf/window/pages/account_tree/summary/end_choice/relative - - - 0 - 1 - 10 - 11 - 12 - fill - fill - - - - - - True - gnc_date_edit_new_glade - 0 - 0 - Sun, 11 Sep 2005 22:33:58 GMT - - - 1 - 4 - 6 - 7 - fill - fill - - - - - - True - gnc_date_edit_new_glade - 0 - 0 - Sun, 11 Sep 2005 22:33:50 GMT - - - 1 - 4 - 10 - 11 - fill - - - - - - True - gnc_period_select_new_glade - 0 - 1 - Tue, 13 Sep 2005 05:43:49 GMT - - - 1 - 4 - 9 - 10 - fill - fill - - - - - - True - gnc_period_select_new_glade - 1 - 1 - Tue, 13 Sep 2005 05:43:49 GMT - - - 1 - 4 - 5 - 6 - fill - fill - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 7 - 8 - fill - - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 3 - 4 - fill - - - - - - False - True - - - - - - True - Accounting Period - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - tab - - - 6