From d195a87079110063f8cbeb8af8f0fca3c9c0dfe4 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Sun, 8 May 2022 10:29:27 +0100 Subject: [PATCH] Change source files dialog-account.* for spaces and tabs --- gnucash/gnome-utils/dialog-account.c | 682 +++++++++++++-------------- gnucash/gnome-utils/dialog-account.h | 10 +- 2 files changed, 336 insertions(+), 356 deletions(-) diff --git a/gnucash/gnome-utils/dialog-account.c b/gnucash/gnome-utils/dialog-account.c index e7ecf2e6cc..4db03d97b2 100644 --- a/gnucash/gnome-utils/dialog-account.c +++ b/gnucash/gnome-utils/dialog-account.c @@ -73,13 +73,13 @@ typedef enum typedef struct _AccountWindow { - QofBook *book; - gboolean modal; + QofBook *book; + gboolean modal; GtkWidget *dialog; AccountDialogType dialog_type; - GncGUID account; + GncGUID account; Account *created_account; gchar **subaccount_names; @@ -87,38 +87,38 @@ typedef struct _AccountWindow 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; + GtkWidget *commodity_edit; dialog_commodity_mode commodity_mode; - GtkWidget * account_scu; + GtkWidget *account_scu; - guint32 valid_types; + guint32 valid_types; GNCAccountType preferred_account_type; - GtkWidget * type_view; - GtkTreeView * parent_tree; - GtkWidget * parent_scroll; + GtkWidget *type_view; + GtkTreeView *parent_tree; + GtkWidget *parent_scroll; - GtkWidget * opening_balance_button; - GtkWidget * opening_balance_edit; - GtkWidget * opening_balance_date_edit; - GtkWidget * opening_balance_page; + GtkWidget *opening_balance_button; + 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 * auto_interest_button; + GtkWidget *tax_related_button; + GtkWidget *placeholder_button; + GtkWidget *hidden_button; + GtkWidget *auto_interest_button; gint component_id; } AccountWindow; @@ -131,8 +131,8 @@ typedef struct _RenumberDialog GtkWidget *example1; GtkWidget *example2; - Account *parent; - gint num_children; + Account *parent; + gint num_children; } RenumberDialog; /** Static Globals *******************************************************/ @@ -152,8 +152,8 @@ void gnc_account_renumber_response_cb (GtkDialog *dialog, gint response, Renumbe void gnc_account_window_destroy_cb (GtkWidget *object, gpointer data); void opening_equity_cb (GtkWidget *w, gpointer data); static void gnc_account_parent_changed_cb (GtkTreeSelection *selection, gpointer data); -void gnc_account_name_changed_cb(GtkWidget *widget, gpointer data); -void gnc_account_color_default_cb(GtkWidget *widget, gpointer data); +void gnc_account_name_changed_cb (GtkWidget *widget, gpointer data); +void gnc_account_color_default_cb (GtkWidget *widget, gpointer data); void gnc_account_name_insert_text_cb (GtkWidget *entry, const gchar *text, gint length, @@ -199,10 +199,9 @@ gnc_account_commodity_from_type (AccountWindow * aw, gboolean update) if (update && (new_mode != aw->commodity_mode)) { - gnc_general_select_set_selected(GNC_GENERAL_SELECT (aw->commodity_edit), - NULL); + gnc_general_select_set_selected (GNC_GENERAL_SELECT(aw->commodity_edit), + NULL); } - aw->commodity_mode = new_mode; } @@ -226,10 +225,12 @@ gnc_account_opening_balance_button_update (AccountWindow *aw, gnc_commodity *com if (!gnc_using_equity_type_opening_balance_account (gnc_get_current_book())) return; - switch(aw->dialog_type) + switch (aw->dialog_type) { case EDIT_ACCOUNT: - gtk_widget_set_sensitive (aw->opening_balance_button, (ob_account == NULL || ob_account == account) && has_splits == 0); + gtk_widget_set_sensitive (aw->opening_balance_button, (ob_account == NULL || + ob_account == account) && + has_splits == 0); break; case NEW_ACCOUNT: gtk_widget_set_sensitive (aw->opening_balance_button, ob_account == NULL); @@ -239,7 +240,7 @@ gnc_account_opening_balance_button_update (AccountWindow *aw, gnc_commodity *com /* Copy the account values to the GUI widgets */ static void -gnc_account_to_ui(AccountWindow *aw) +gnc_account_to_ui (AccountWindow *aw) { Account *account; gnc_commodity * commodity; @@ -257,12 +258,14 @@ gnc_account_to_ui(AccountWindow *aw) } string = xaccAccountGetName (account); - if (string == NULL) string = ""; - gtk_entry_set_text(GTK_ENTRY(aw->name_entry), string); + 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); + if (string == NULL) + string = ""; + gtk_entry_set_text (GTK_ENTRY(aw->description_entry), string); string = xaccAccountGetColor (account); @@ -272,57 +275,58 @@ gnc_account_to_ui(AccountWindow *aw) if (!gdk_rgba_parse (&color, string)) gdk_rgba_parse (&color, DEFAULT_COLOR); - gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(aw->color_entry_button), &color); + gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER(aw->color_entry_button), &color); commodity = xaccAccountGetCommodity (account); - gnc_general_select_set_selected (GNC_GENERAL_SELECT (aw->commodity_edit), + 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; + index = xaccAccountGetCommoditySCUi (account); + index = log10 (index) + 1; } else { index = 0; } - gtk_combo_box_set_active(GTK_COMBO_BOX(aw->account_scu), index); + 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); + if (string == NULL) + string = ""; + gtk_entry_set_text (GTK_ENTRY(aw->code_entry), string); string = xaccAccountGetNotes (account); - if (string == NULL) string = ""; + if (string == NULL) + string = ""; gtk_text_buffer_set_text (aw->notes_text_buffer, string, strlen(string)); gnc_account_opening_balance_button_update (aw, commodity); flag = xaccAccountGetIsOpeningBalance (account); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (aw->opening_balance_button), + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(aw->opening_balance_button), flag); flag = xaccAccountGetTaxRelated (account); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (aw->tax_related_button), + 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), + 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), + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(aw->hidden_button), flag); set_auto_interest_box (aw); LEAVE(" "); } - static gboolean gnc_account_create_transfer_balance (QofBook *book, Account *account, @@ -377,7 +381,7 @@ gnc_account_create_transfer_balance (QofBook *book, /* Record the GUI values into the Account structure */ static void -gnc_ui_to_account(AccountWindow *aw) +gnc_ui_to_account (AccountWindow *aw) { Account *account; gnc_commodity *commodity; @@ -423,8 +427,8 @@ gnc_ui_to_account(AccountWindow *aw) if (g_strcmp0 (string, old_string) != 0) xaccAccountSetDescription (account, string); - gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(aw->color_entry_button), &color ); - string = gdk_rgba_to_string(&color); + gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER(aw->color_entry_button), &color); + string = gdk_rgba_to_string (&color); if (g_strcmp0 (string, DEFAULT_COLOR) == 0) string = NULL; @@ -440,25 +444,25 @@ gnc_ui_to_account(AccountWindow *aw) } commodity = (gnc_commodity *) - gnc_general_select_get_selected (GNC_GENERAL_SELECT (aw->commodity_edit)); + gnc_general_select_get_selected (GNC_GENERAL_SELECT(aw->commodity_edit)); if (commodity && - !gnc_commodity_equiv(commodity, xaccAccountGetCommodity (account))) + !gnc_commodity_equiv (commodity, xaccAccountGetCommodity (account))) { xaccAccountSetCommodity (account, commodity); old_scu = 0; } else { - old_scu = xaccAccountGetCommoditySCU(account); + old_scu = xaccAccountGetCommoditySCU (account); } - index = gtk_combo_box_get_active(GTK_COMBO_BOX(aw->account_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 (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); + xaccAccountSetCommoditySCU (account, new_scu); string = gtk_entry_get_text (GTK_ENTRY(aw->code_entry)); old_string = xaccAccountGetCode (account); @@ -472,42 +476,36 @@ gnc_ui_to_account(AccountWindow *aw) if (null_strcmp (string, old_string) != 0) xaccAccountSetNotes (account, string); - flag = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (aw->opening_balance_button)); + flag = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(aw->opening_balance_button)); if (xaccAccountGetIsOpeningBalance (account) != flag) xaccAccountSetIsOpeningBalance (account, flag); - flag = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (aw->tax_related_button)); + flag = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(aw->tax_related_button)); if (xaccAccountGetTaxRelated (account) != flag) xaccAccountSetTaxRelated (account, flag); - flag = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (aw->placeholder_button)); + flag = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(aw->placeholder_button)); if (xaccAccountGetPlaceholder (account) != flag) xaccAccountSetPlaceholder (account, flag); - flag = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (aw->hidden_button)); + flag = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(aw->hidden_button)); if (xaccAccountGetHidden (account) != flag) xaccAccountSetHidden (account, flag); - flag = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (aw->auto_interest_button)); + flag = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(aw->auto_interest_button)); if (xaccAccountGetAutoInterest (account) != flag) xaccAccountSetAutoInterest (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); + 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); - 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)) { @@ -518,25 +516,23 @@ gnc_ui_to_account(AccountWindow *aw) if (gnc_reverse_balance (account)) balance = gnc_numeric_neg (balance); - date = gnc_date_edit_get_date ( - GNC_DATE_EDIT (aw->opening_balance_date_edit)); + date = gnc_date_edit_get_date (GNC_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)) { const char *message = _("Could not create opening balance."); - gnc_error_dialog (GTK_WINDOW (aw->dialog), "%s", message); + gnc_error_dialog (GTK_WINDOW(aw->dialog), "%s", message); } } else { Account *transfer = NULL; - transfer = gnc_tree_view_account_get_selected_account (GNC_TREE_VIEW_ACCOUNT (aw->transfer_tree)); + transfer = gnc_tree_view_account_get_selected_account (GNC_TREE_VIEW_ACCOUNT(aw->transfer_tree)); if (!transfer) { LEAVE("no transfer account"); @@ -548,20 +544,19 @@ gnc_ui_to_account(AccountWindow *aw) LEAVE(" "); } - static void set_children_types (Account *account, GNCAccountType type) { GList *children, *iter; - children = gnc_account_get_children(account); + children = gnc_account_get_children (account); if (children == NULL) return; for (iter = children; iter; iter = iter->next) { account = iter->data; - if (type == xaccAccountGetType(account)) + if (type == xaccAccountGetType (account)) continue; /* Just refreshing won't work. */ @@ -573,7 +568,7 @@ set_children_types (Account *account, GNCAccountType type) set_children_types (account, type); } - g_list_free(children); + g_list_free (children); } static void @@ -595,7 +590,6 @@ make_children_compatible (AccountWindow *aw) set_children_types (account, aw->type); } - static void gnc_finish_ok (AccountWindow *aw) { @@ -622,7 +616,7 @@ gnc_finish_ok (AccountWindow *aw) gtk_container_add (GTK_CONTAINER(aw->parent_scroll), 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)); + 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); @@ -641,12 +635,13 @@ gnc_finish_ok (AccountWindow *aw) gnc_account_window_set_name (aw); commodity = xaccAccountGetCommodity (parent); - gnc_general_select_set_selected (GNC_GENERAL_SELECT (aw->commodity_edit), + 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"); @@ -663,29 +658,28 @@ gnc_finish_ok (AccountWindow *aw) LEAVE("2"); } - static void add_children_to_expander (GObject *object, GParamSpec *param_spec, gpointer data) { - GtkExpander *expander = GTK_EXPANDER (object); + 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))) + !gtk_bin_get_child (GTK_BIN(expander))) { - 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_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(scrolled_window), GTK_WIDGET(view)); - gtk_container_add (GTK_CONTAINER (expander), scrolled_window); + gtk_container_add (GTK_CONTAINER(expander), scrolled_window); gtk_widget_set_vexpand (GTK_WIDGET(scrolled_window), TRUE); gtk_widget_show_all (scrolled_window); } @@ -712,7 +706,7 @@ verify_children_compatible (AccountWindow *aw) if (xaccAccountTypesCompatible (aw->type, xaccAccountGetType (account))) return TRUE; - if (gnc_account_n_children(account) == 0) + if (gnc_account_n_children (account) == 0) return TRUE; dialog = gtk_dialog_new_with_buttons ("", @@ -723,28 +717,27 @@ verify_children_compatible (AccountWindow *aw) _("_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_box_new (GTK_ORIENTATION_HORIZONTAL, 12); - gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE); + gtk_box_set_homogeneous (GTK_BOX(hbox), FALSE); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); - gtk_box_set_homogeneous (GTK_BOX (vbox), FALSE); + gtk_box_set_homogeneous (GTK_BOX(vbox), FALSE); - gtk_box_pack_start ( - GTK_BOX (hbox), - gtk_image_new_from_icon_name ("dialog-information", GTK_ICON_SIZE_DIALOG), - FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX(hbox), + gtk_image_new_from_icon_name ("dialog-information", + 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_label_set_line_wrap (GTK_LABEL(label), TRUE); + gtk_label_set_selectable (GTK_LABEL(label), TRUE); gnc_label_set_alignment (label, 0.0, 0.0); /* make label large */ gnc_widget_style_context_add_class (GTK_WIDGET(label), "gnc-class-title"); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 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 " @@ -752,40 +745,39 @@ verify_children_compatible (AccountWindow *aw) 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_label_set_line_wrap (GTK_LABEL(label), TRUE); + gtk_label_set_selectable (GTK_LABEL(label), TRUE); gnc_label_set_alignment (label, 0.0, 0.0); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 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); + 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_get_content_area (GTK_DIALOG (dialog))), hbox, - TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area (GTK_DIALOG(dialog))), + 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_get_content_area (GTK_DIALOG (dialog))), 14); + 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_get_content_area (GTK_DIALOG(dialog))), 14); 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; } - static gboolean gnc_filter_parent_accounts (Account *account, gpointer data) { @@ -798,19 +790,18 @@ gnc_filter_parent_accounts (Account *account, gpointer data) if (aw_account == NULL) return FALSE; - if (gnc_account_is_root(account)) + if (gnc_account_is_root (account)) return TRUE; if (account == aw_account) return FALSE; - if (xaccAccountHasAncestor(account, aw_account)) + if (xaccAccountHasAncestor (account, aw_account)) return FALSE; return TRUE; } - static gboolean gnc_common_ok (AccountWindow *aw) { @@ -822,49 +813,49 @@ gnc_common_ok (AccountWindow *aw) 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 (g_strcmp0(name, "") == 0) + name = gtk_entry_get_text (GTK_ENTRY(aw->name_entry)); + if (g_strcmp0 (name, "") == 0) { const char *message = _("The account must be given a name."); - gnc_error_dialog (GTK_WINDOW (aw->dialog), "%s", message); + gnc_error_dialog (GTK_WINDOW(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)); + (GNC_TREE_VIEW_ACCOUNT(aw->parent_tree)); if (parent == NULL) { - account = gnc_account_lookup_by_full_name(root, name); + 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); + 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); + g_free (fullname_parent); + g_free (fullname); } if ((account != NULL) && - !guid_equal(&aw->account, xaccAccountGetGUID (account))) + !guid_equal (&aw->account, xaccAccountGetGUID (account))) { const char *message = _("There is already an account with that name."); - gnc_error_dialog (GTK_WINDOW (aw->dialog), "%s", message); + gnc_error_dialog (GTK_WINDOW(aw->dialog), "%s", message); LEAVE("duplicate name"); return FALSE; } /* Parent check, probably not needed, but be safe */ - if (!gnc_filter_parent_accounts(parent, aw)) + if (!gnc_filter_parent_accounts (parent, aw)) { const char *message = _("You must choose a valid parent account."); - gnc_error_dialog (GTK_WINDOW (aw->dialog), "%s", message); + gnc_error_dialog (GTK_WINDOW(aw->dialog), "%s", message); LEAVE("invalid parent"); return FALSE; } @@ -873,7 +864,7 @@ gnc_common_ok (AccountWindow *aw) if (aw->type == ACCT_TYPE_INVALID) { const char *message = _("You must select an account type."); - gnc_error_dialog (GTK_WINDOW (aw->dialog), "%s", message); + gnc_error_dialog (GTK_WINDOW(aw->dialog), "%s", message); LEAVE("invalid type"); return FALSE; } @@ -883,18 +874,18 @@ gnc_common_ok (AccountWindow *aw) { const char *message = _("The selected account type is incompatible with " "the one of the selected parent."); - gnc_error_dialog (GTK_WINDOW (aw->dialog), "%s", message); + gnc_error_dialog (GTK_WINDOW(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)); + gnc_general_select_get_selected (GNC_GENERAL_SELECT(aw->commodity_edit)); if (!commodity) { const char *message = _("You must choose a commodity."); - gnc_error_dialog (GTK_WINDOW (aw->dialog), "%s", message); + gnc_error_dialog (GTK_WINDOW(aw->dialog), "%s", message); LEAVE("invalid commodity"); return FALSE; } @@ -904,7 +895,7 @@ gnc_common_ok (AccountWindow *aw) } static void -gnc_edit_account_ok(AccountWindow *aw) +gnc_edit_account_ok (AccountWindow *aw) { Account *account; @@ -917,7 +908,7 @@ gnc_edit_account_ok(AccountWindow *aw) return; } - if (!gnc_common_ok(aw)) + if (!gnc_common_ok (aw)) { LEAVE(" "); return; @@ -933,7 +924,6 @@ gnc_edit_account_ok(AccountWindow *aw) LEAVE(" "); } - static void gnc_new_account_ok (AccountWindow *aw) { @@ -941,41 +931,41 @@ gnc_new_account_ok (AccountWindow *aw) ENTER("aw %p", aw); - if (!gnc_common_ok(aw)) + if (!gnc_common_ok (aw)) { LEAVE(" "); return; } - if (!gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (aw->opening_balance_edit), NULL)) + if (!gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT(aw->opening_balance_edit), NULL)) { const char *message = _("You must enter a valid opening balance " "or leave it blank."); - gnc_error_dialog (GTK_WINDOW (aw->dialog), "%s", message); + gnc_error_dialog (GTK_WINDOW(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; use_equity = gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (aw->opening_equity_radio)); + (GTK_TOGGLE_BUTTON(aw->opening_equity_radio)); if (!use_equity) { Account *transfer = NULL; - transfer = gnc_tree_view_account_get_selected_account (GNC_TREE_VIEW_ACCOUNT (aw->transfer_tree)); + 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 (GTK_WINDOW (aw->dialog), "%s", message); + gnc_error_dialog (GTK_WINDOW(aw->dialog), "%s", message); LEAVE(" "); return; } @@ -1077,7 +1067,7 @@ gnc_account_window_destroy_cb (GtkWidget *object, gpointer data) if (aw->subaccount_names) { - g_strfreev(aw->subaccount_names); + g_strfreev (aw->subaccount_names); aw->subaccount_names = NULL; aw->next_name = NULL; } @@ -1099,11 +1089,11 @@ gnc_account_parent_changed_cb (GtkTreeSelection *selection, gpointer data) g_return_if_fail (aw); parent_account = gnc_tree_view_account_get_selected_account ( - GNC_TREE_VIEW_ACCOUNT (aw->parent_tree)); + GNC_TREE_VIEW_ACCOUNT(aw->parent_tree)); if (!parent_account) return; - if (gnc_account_is_root(parent_account)) + if (gnc_account_is_root (parent_account)) { types = aw->valid_types; } @@ -1113,7 +1103,7 @@ gnc_account_parent_changed_cb (GtkTreeSelection *selection, gpointer data) xaccParentAccountTypesCompatibleWith (xaccAccountGetType (parent_account)); } - type_model = gtk_tree_view_get_model (GTK_TREE_VIEW (aw->type_view)); + type_model = gtk_tree_view_get_model (GTK_TREE_VIEW(aw->type_view)); if (!type_model) return; @@ -1141,11 +1131,11 @@ gnc_account_parent_changed_cb (GtkTreeSelection *selection, gpointer data) 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); + 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 @@ -1154,9 +1144,9 @@ set_auto_interest_box(AccountWindow *aw) Account* account = aw_get_account (aw); gboolean type_ok = account_type_has_auto_interest_xfer (aw->type); gboolean pref_set = xaccAccountGetAutoInterest (account); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (aw->auto_interest_button), + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(aw->auto_interest_button), type_ok && pref_set); - gtk_widget_set_sensitive (GTK_WIDGET (aw->auto_interest_button), type_ok); + gtk_widget_set_sensitive (GTK_WIDGET(aw->auto_interest_button), type_ok); } static void @@ -1170,7 +1160,7 @@ gnc_account_type_changed_cb (GtkTreeSelection *selection, gpointer data) sensitive = FALSE; - type_id = gnc_tree_model_account_types_get_selection_single(selection); + type_id = gnc_tree_model_account_types_get_selection_single (selection); if (type_id == ACCT_TYPE_NONE) { aw->type = ACCT_TYPE_INVALID; @@ -1193,10 +1183,10 @@ gnc_account_type_changed_cb (GtkTreeSelection *selection, gpointer data) if (!sensitive) { - gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (aw->opening_balance_edit), + gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT(aw->opening_balance_edit), gnc_numeric_zero ()); } - set_auto_interest_box(aw); + set_auto_interest_box (aw); } static void @@ -1241,22 +1231,21 @@ gnc_account_type_view_create (AccountWindow *aw, guint32 compat_types) model = gnc_tree_model_account_types_filter_using_mask (aw->valid_types); - view = GTK_TREE_VIEW (aw->type_view); + view = GTK_TREE_VIEW(aw->type_view); gtk_tree_view_set_model (view, model); - g_object_unref (G_OBJECT (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_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); + 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); } void @@ -1266,31 +1255,31 @@ gnc_account_name_insert_text_cb (GtkWidget *entry, gint *position, gpointer data) { - GtkEditable *editable = GTK_EDITABLE( entry ); + GtkEditable *editable = GTK_EDITABLE(entry); const gchar *separator = NULL; gchar **strsplit; - separator = gnc_get_account_separator_string(); - strsplit = g_strsplit ( text, separator, 0 ); - if ( strsplit[1] != NULL ) + separator = gnc_get_account_separator_string (); + strsplit = g_strsplit (text, separator, 0); + if (strsplit[1] != NULL) { - gchar *result = g_strjoinv ( NULL, strsplit ); - g_signal_handlers_block_by_func ( G_OBJECT ( editable ), - G_CALLBACK ( gnc_account_name_insert_text_cb ), - data ); - gtk_editable_insert_text ( editable, result, g_utf8_strlen ( result, -1 ), position ); - g_signal_handlers_unblock_by_func ( G_OBJECT ( editable ), - G_CALLBACK ( gnc_account_name_insert_text_cb ), - data ); - g_signal_stop_emission_by_name (G_OBJECT ( editable ), "insert_text"); + gchar *result = g_strjoinv (NULL, strsplit); + g_signal_handlers_block_by_func (G_OBJECT(editable), + G_CALLBACK(gnc_account_name_insert_text_cb), + data); + gtk_editable_insert_text (editable, result, g_utf8_strlen (result, -1), position); + g_signal_handlers_unblock_by_func (G_OBJECT(editable), + G_CALLBACK(gnc_account_name_insert_text_cb), + data); + g_signal_stop_emission_by_name (G_OBJECT(editable), "insert_text"); g_free (result); } - g_strfreev ( strsplit ); + g_strfreev (strsplit); } void -gnc_account_name_changed_cb(GtkWidget *widget, gpointer data) +gnc_account_name_changed_cb (GtkWidget *widget, gpointer data) { AccountWindow *aw = data; @@ -1298,13 +1287,13 @@ gnc_account_name_changed_cb(GtkWidget *widget, gpointer data) } void -gnc_account_color_default_cb(GtkWidget *widget, gpointer data) +gnc_account_color_default_cb (GtkWidget *widget, gpointer data) { GdkRGBA color; AccountWindow *aw = data; - gdk_rgba_parse(&color, DEFAULT_COLOR); - gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(aw->color_entry_button), &color); + gdk_rgba_parse (&color, DEFAULT_COLOR); + gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER(aw->color_entry_button), &color); } @@ -1333,9 +1322,9 @@ commodity_changed_cb (GNCGeneralSelect *gsl, gpointer data) GTK_BUTTONS_OK, "%s", dialog_title); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG(dialog), - "%s", dialog_msg); - gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy(dialog); + "%s", dialog_msg); + gtk_dialog_run (GTK_DIALOG(dialog)); + gtk_widget_destroy (dialog); g_signal_handlers_block_by_func (gsl, commodity_changed_cb, data); gnc_general_select_set_selected (gsl, xaccAccountGetCommodity (account)); g_signal_handlers_unblock_by_func (gsl, commodity_changed_cb, data); @@ -1343,12 +1332,12 @@ commodity_changed_cb (GNCGeneralSelect *gsl, gpointer data) } } - gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (aw->opening_balance_edit), + 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_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)); + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(aw->transfer_tree)); gtk_tree_selection_unselect_all (selection); gnc_account_opening_balance_button_update (aw, currency); } @@ -1364,7 +1353,7 @@ account_commodity_filter (GtkTreeSelection *selection, 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; @@ -1374,14 +1363,14 @@ account_commodity_filter (GtkTreeSelection *selection, return TRUE; } - account = gnc_tree_view_account_get_account_from_path (GNC_TREE_VIEW_ACCOUNT (aw->transfer_tree), s_path); + 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)); + gnc_general_select_get_selected (GNC_GENERAL_SELECT(aw->commodity_edit)); return gnc_commodity_equiv (xaccAccountGetCommodity (account), commodity); } @@ -1392,7 +1381,7 @@ opening_equity_cb (GtkWidget *w, gpointer data) 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); } @@ -1406,7 +1395,7 @@ opening_equity_cb (GtkWidget *w, gpointer data) * Return: the created window * \*******************************************************************/ static void -gnc_account_window_create(GtkWindow *parent, AccountWindow *aw) +gnc_account_window_create (GtkWindow *parent, AccountWindow *aw) { GtkWidget *amount; GtkWidget *date_edit; @@ -1419,15 +1408,15 @@ gnc_account_window_create(GtkWindow *parent, AccountWindow *aw) guint32 compat_types = xaccAccountTypesValid (); ENTER("aw %p, modal %d", aw, aw->modal); - builder = gtk_builder_new(); + builder = gtk_builder_new (); gnc_builder_add_from_file (builder, "dialog-account.glade", "fraction_liststore"); gnc_builder_add_from_file (builder, "dialog-account.glade", "account_dialog"); aw->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "account_dialog")); - awo = G_OBJECT (aw->dialog); + awo = G_OBJECT(aw->dialog); if (parent) - gtk_window_set_transient_for (GTK_WINDOW (aw->dialog), parent); + gtk_window_set_transient_for (GTK_WINDOW(aw->dialog), parent); // Set the name for this dialog so it can be easily manipulated with css gtk_widget_set_name (GTK_WIDGET(aw->dialog), "gnc-id-account"); @@ -1438,28 +1427,31 @@ gnc_account_window_create(GtkWindow *parent, AccountWindow *aw) if (!aw->modal) g_signal_connect (awo, "response", - G_CALLBACK (gnc_account_window_response_cb), aw); + G_CALLBACK(gnc_account_window_response_cb), aw); else - gtk_window_set_modal (GTK_WINDOW (aw->dialog), TRUE); + gtk_window_set_modal (GTK_WINDOW(aw->dialog), TRUE); aw->notebook = GTK_WIDGET(gtk_builder_get_object (builder, "account_notebook")); aw->name_entry = GTK_WIDGET(gtk_builder_get_object (builder, "name_entry")); aw->description_entry = GTK_WIDGET(gtk_builder_get_object (builder, "description_entry")); aw->color_entry_button = GTK_WIDGET(gtk_builder_get_object (builder, "color_entry_button")); aw->color_default_button = GTK_WIDGET(gtk_builder_get_object (builder, "color_default_button")); - aw->code_entry = GTK_WIDGET(gtk_builder_get_object (builder, "code_entry")); - aw->notes_text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (GTK_WIDGET(gtk_builder_get_object (builder, "notes_text")))); + aw->code_entry = GTK_WIDGET(gtk_builder_get_object (builder, "code_entry")); + aw->notes_text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(GTK_WIDGET( + gtk_builder_get_object (builder, + "notes_text")))); box = GTK_WIDGET(gtk_builder_get_object (builder, "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); + gnc_commodity_edit_get_string, + gnc_commodity_edit_new_select, + &aw->commodity_mode); // If the account has transactions, prevent changes by displaying a label and tooltip if (xaccAccountGetSplitList (aw_get_account (aw)) != NULL) { - const gchar *sec_name = gnc_commodity_get_printname (xaccAccountGetCommodity(aw_get_account (aw))); + const gchar *sec_name = gnc_commodity_get_printname (xaccAccountGetCommodity ( + aw_get_account (aw))); GtkWidget *label = gtk_label_new (sec_name); gtk_widget_set_tooltip_text (label, tt); gtk_box_pack_start (GTK_BOX(box), label, FALSE, FALSE, 0); @@ -1467,15 +1459,15 @@ gnc_account_window_create(GtkWindow *parent, AccountWindow *aw) } else { - gtk_box_pack_start(GTK_BOX(box), aw->commodity_edit, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX(box), aw->commodity_edit, TRUE, TRUE, 0); gtk_widget_show (aw->commodity_edit); } label = GTK_WIDGET(gtk_builder_get_object (builder, "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 = GTK_WIDGET(gtk_builder_get_object (builder, "account_scu")); @@ -1484,23 +1476,24 @@ gnc_account_window_create(GtkWindow *parent, AccountWindow *aw) aw->parent_tree = gnc_tree_view_account_new (TRUE); gtk_container_add (GTK_CONTAINER(aw->parent_scroll), 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); + 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->opening_balance_button = GTK_WIDGET(gtk_builder_get_object (builder, "opening_balance_button")); aw->tax_related_button = GTK_WIDGET(gtk_builder_get_object (builder, "tax_related_button")); aw->placeholder_button = GTK_WIDGET(gtk_builder_get_object (builder, "placeholder_button")); aw->hidden_button = GTK_WIDGET(gtk_builder_get_object (builder, "hidden_button")); aw->auto_interest_button = GTK_WIDGET(gtk_builder_get_object (builder, "auto_interest_button")); - set_auto_interest_box(aw); + set_auto_interest_box (aw); box = GTK_WIDGET(gtk_builder_get_object (builder, "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_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 = GTK_WIDGET(gtk_builder_get_object (builder, "balance_label")); @@ -1511,11 +1504,11 @@ gnc_account_window_create(GtkWindow *parent, AccountWindow *aw) date_edit = gnc_date_edit_new (gnc_time (NULL), 0, 0); gnc_date_make_mnemonic_target (GNC_DATE_EDIT(date_edit), label); aw->opening_balance_date_edit = date_edit; - gtk_box_pack_start(GTK_BOX(box), date_edit, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX(box), date_edit, TRUE, TRUE, 0); gtk_widget_show (date_edit); aw->opening_balance_page = - gtk_notebook_get_nth_page (GTK_NOTEBOOK (aw->notebook), 1); + gtk_notebook_get_nth_page (GTK_NOTEBOOK(aw->notebook), 1); aw->opening_equity_radio = GTK_WIDGET(gtk_builder_get_object (builder, "opening_equity_radio")); @@ -1523,11 +1516,11 @@ gnc_account_window_create(GtkWindow *parent, AccountWindow *aw) box = GTK_WIDGET(gtk_builder_get_object (builder, "transfer_account_scroll")); aw->transfer_account_scroll = box; - aw->transfer_tree = GTK_WIDGET(gnc_tree_view_account_new(FALSE)); + 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_tree_selection_set_select_function (selection, account_commodity_filter, aw, NULL); - gtk_container_add(GTK_CONTAINER(box), 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 = GTK_WIDGET(gtk_builder_get_object (builder, "parent_label")); @@ -1555,15 +1548,14 @@ gnc_account_window_create(GtkWindow *parent, AccountWindow *aw) gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(aw->dialog), parent); - gtk_widget_grab_focus(GTK_WIDGET(aw->name_entry)); + gtk_widget_grab_focus (GTK_WIDGET(aw->name_entry)); - gtk_builder_connect_signals(builder, aw); - g_object_unref(G_OBJECT(builder)); + gtk_builder_connect_signals (builder, aw); + g_object_unref (G_OBJECT(builder)); LEAVE(" "); } - static char * get_ui_fullname (AccountWindow *aw) { @@ -1575,18 +1567,14 @@ get_ui_fullname (AccountWindow *aw) if (!name || *name == '\0') 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)) + if (parent_account && !gnc_account_is_root (parent_account)) { - char *parent_name; - const gchar *separator; + char *parent_name = gnc_account_get_full_name (parent_account); + const gchar *separator = gnc_get_account_separator_string (); - parent_name = gnc_account_get_full_name (parent_account); - - separator = gnc_get_account_separator_string (); fullname = g_strconcat (parent_name, separator, name, NULL); - g_free (parent_name); } else @@ -1608,15 +1596,13 @@ gnc_account_window_set_name (AccountWindow *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)) + 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); + char *prefix = g_strdup_printf (format, + g_strv_length (aw->next_name) + 1); title = g_strconcat (prefix, " - ", fullname, " ...", NULL); - g_free (prefix); } else @@ -1628,7 +1614,6 @@ gnc_account_window_set_name (AccountWindow *aw) g_free (title); } - static void close_handler (gpointer user_data) { @@ -1637,11 +1622,10 @@ close_handler (gpointer user_data) ENTER("aw %p, modal %d", aw, aw->modal); gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(aw->dialog)); - gtk_widget_destroy (GTK_WIDGET (aw->dialog)); + gtk_widget_destroy (GTK_WIDGET(aw->dialog)); LEAVE(" "); } - /********************************************************************\ * gnc_ui_refresh_account_window * * refreshes the edit window * @@ -1660,12 +1644,10 @@ gnc_ui_refresh_account_window (AccountWindow *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; account = aw_get_account (aw); @@ -1677,18 +1659,16 @@ refresh_handler (GHashTable *changes, gpointer user_data) if (changes) { - info = gnc_gui_get_entity_events (changes, &aw->account); + const EventInfo *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); } - static AccountWindow * gnc_ui_new_account_window_internal (GtkWindow *parent, QofBook *book, @@ -1748,10 +1728,10 @@ gnc_ui_new_account_window_internal (GtkWindow *parent, 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)); + 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)) @@ -1762,18 +1742,19 @@ gnc_ui_new_account_window_internal (GtkWindow *parent, { commodity = NULL; } - gnc_general_select_set_selected (GNC_GENERAL_SELECT (aw->commodity_edit), + gnc_general_select_set_selected (GNC_GENERAL_SELECT(aw->commodity_edit), (gpointer) commodity); gnc_account_commodity_from_type (aw, FALSE); if (base_account == NULL) { - base_account = gnc_book_get_root_account(book); + 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); + gnc_tree_view_account_set_selected_account (GNC_TREE_VIEW_ACCOUNT( + aw->parent_tree), + base_account); gtk_widget_show (aw->dialog); @@ -1782,9 +1763,9 @@ gnc_ui_new_account_window_internal (GtkWindow *parent, 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); + 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, @@ -1793,7 +1774,6 @@ gnc_ui_new_account_window_internal (GtkWindow *parent, return aw; } - static gchar ** gnc_split_account_name (QofBook *book, const char *in_name, Account **base_account) { @@ -1802,8 +1782,8 @@ gnc_split_account_name (QofBook *book, const char *in_name, Account **base_accou 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); + list = gnc_account_get_children (root); + names = g_strsplit (in_name, gnc_get_account_separator_string (), -1); for (ptr = names; *ptr; ptr++) { @@ -1812,11 +1792,11 @@ gnc_split_account_name (QofBook *book, const char *in_name, Account **base_accou break; /* Look for the first name in the children. */ - for (node = list; node; node = g_list_next(node)) + for (node = list; node; node = g_list_next (node)) { account = node->data; - if (g_strcmp0(xaccAccountGetName (account), *ptr) == 0) + if (g_strcmp0 (xaccAccountGetName (account), *ptr) == 0) { /* We found an account. */ *base_account = account; @@ -1828,18 +1808,17 @@ gnc_split_account_name (QofBook *book, const char *in_name, Account **base_accou if (node == NULL) break; - g_list_free(list); + g_list_free (list); list = gnc_account_get_children (account); } - out_names = g_strdupv(ptr); - g_strfreev(names); + out_names = g_strdupv (ptr); + g_strfreev (names); if (list) - g_list_free(list); + g_list_free (list); return out_names; } - /************************************************************ * Entry points for a Modal Dialog * ************************************************************/ @@ -1856,8 +1835,8 @@ gnc_ui_new_accounts_from_name_window_with_types (GtkWindow *parent, const char *name, GList *valid_types) { - return gnc_ui_new_accounts_from_name_with_defaults(parent, name, - valid_types, NULL, NULL); + return gnc_ui_new_accounts_from_name_with_defaults (parent, name, + valid_types, NULL, NULL); } Account * @@ -1877,7 +1856,7 @@ gnc_ui_new_accounts_from_name_with_defaults (GtkWindow *parent, ENTER("name %s, valid %p, commodity %p, account %p", name, valid_types, default_commodity, parent_acct); - book = gnc_get_current_book(); + book = gnc_get_current_book (); if (!name || *name == '\0') { subaccount_names = NULL; @@ -1920,8 +1899,8 @@ gnc_ui_new_accounts_from_name_with_defaults (GtkWindow *parent, } } - close_handler(aw); - LEAVE("created %s (%p)", xaccAccountGetName(created_account), created_account); + close_handler (aw); + LEAVE("created %s (%p)", xaccAccountGetName (created_account), created_account); return created_account; } @@ -1948,7 +1927,7 @@ find_by_account (gpointer find_data, gpointer user_data) * Return: EditAccountWindow object */ void -gnc_ui_edit_account_window(GtkWindow *parent, Account *account) +gnc_ui_edit_account_window (GtkWindow *parent, Account *account) { AccountWindow * aw; Account *parent_acct; @@ -1960,13 +1939,13 @@ gnc_ui_edit_account_window(GtkWindow *parent, Account *account) find_by_account, account); if (aw) { - gtk_window_present(GTK_WINDOW(aw->dialog)); + gtk_window_present (GTK_WINDOW(aw->dialog)); return; } aw = g_new0 (AccountWindow, 1); - aw->book = gnc_account_get_book(account); + aw->book = gnc_account_get_book (account); aw->modal = FALSE; aw->dialog_type = EDIT_ACCOUNT; aw->account = *xaccAccountGetGUID (account); @@ -1986,29 +1965,29 @@ gnc_ui_edit_account_window(GtkWindow *parent, Account *account) parent_acct = gnc_account_get_parent (account); if (parent_acct == NULL) - parent_acct = account; /* must be at the root */ + parent_acct = 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_acct); + gnc_tree_view_account_set_selected_account (GNC_TREE_VIEW_ACCOUNT( + aw->parent_tree), + parent_acct); 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); + refresh_handler, + close_handler, aw); - gnc_gui_component_set_session (aw->component_id, gnc_get_current_session()); + 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 * @@ -2021,7 +2000,7 @@ gnc_ui_new_account_window (GtkWindow *parent, QofBook *book, { g_return_if_fail(book != NULL); if (parent_acct && book) - g_return_if_fail(gnc_account_get_book(parent_acct) == book); + g_return_if_fail(gnc_account_get_book (parent_acct) == book); gnc_ui_new_account_window_internal (parent, book, parent_acct, NULL, NULL, NULL, FALSE); @@ -2068,45 +2047,45 @@ gnc_account_renumber_update_examples (RenumberDialog *data) unsigned int num_digits = 1; g_return_if_fail (data->num_children > 0); - prefix = gtk_editable_get_chars(GTK_EDITABLE(data->prefix), 0, -1); - interval = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(data->interval)); + prefix = gtk_editable_get_chars (GTK_EDITABLE(data->prefix), 0, -1); + interval = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(data->interval)); if (interval <= 0) - interval = 10; + interval = 10; num_digits = (unsigned int)log10((double)(data->num_children * interval)) + 1; if (strlen (prefix)) - str = g_strdup_printf("%s-%0*d", prefix, num_digits, interval); + str = g_strdup_printf ("%s-%0*d", prefix, num_digits, interval); else - str = g_strdup_printf("%0*d", num_digits, interval); + str = g_strdup_printf ("%0*d", num_digits, interval); - gtk_label_set_text(GTK_LABEL(data->example1), str); - g_free(str); + gtk_label_set_text (GTK_LABEL(data->example1), str); + g_free (str); if (strlen (prefix)) - str = g_strdup_printf("%s-%0*d", prefix, num_digits, - interval * data->num_children); + str = g_strdup_printf ("%s-%0*d", prefix, num_digits, + interval * data->num_children); else - str = g_strdup_printf("%0*d", num_digits, - interval * data->num_children); + str = g_strdup_printf ("%0*d", num_digits, + interval * data->num_children); - gtk_label_set_text(GTK_LABEL(data->example2), str); - g_free(str); + gtk_label_set_text (GTK_LABEL(data->example2), str); - g_free(prefix); + g_free (str); + g_free (prefix); } void gnc_account_renumber_prefix_changed_cb (GtkEditable *editable, 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 @@ -2115,23 +2094,22 @@ gnc_account_renumber_response_cb (GtkDialog *dialog, RenumberDialog *data) { GList *children = NULL, *tmp; - gchar *str; gchar *prefix; gint interval; unsigned int num_digits, i; if (response == GTK_RESPONSE_OK) { - gtk_widget_hide(data->dialog); - children = gnc_account_get_children_sorted(data->parent); + gtk_widget_hide (data->dialog); + children = gnc_account_get_children_sorted (data->parent); if (children == NULL) { - PWARN ("Can't renumber children of an account with no children!"); + PWARN("Can't renumber children of an account with no children!"); g_free (data); return; } - prefix = gtk_editable_get_chars(GTK_EDITABLE(data->prefix), 0, -1); - interval = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(data->interval)); + prefix = gtk_editable_get_chars (GTK_EDITABLE(data->prefix), 0, -1); + interval = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(data->interval)); if (interval <= 0) interval = 10; @@ -2141,20 +2119,21 @@ gnc_account_renumber_response_cb (GtkDialog *dialog, gnc_set_busy_cursor (NULL, TRUE); for (tmp = children, i = 1; tmp; tmp = g_list_next(tmp), i += 1) { + gchar *str; if (strlen (prefix)) - str = g_strdup_printf("%s-%0*d", prefix, - num_digits, interval * i); + str = g_strdup_printf ("%s-%0*d", prefix, + num_digits, interval * i); else - str = g_strdup_printf("%0*d", num_digits, interval * i); - xaccAccountSetCode(tmp->data, str); - g_free(str); + str = g_strdup_printf ("%0*d", num_digits, interval * i); + xaccAccountSetCode (tmp->data, str); + g_free (str); } gnc_unset_busy_cursor (NULL); - g_list_free(children); + g_list_free (children); } - gtk_widget_destroy(data->dialog); - g_free(data); + gtk_widget_destroy (data->dialog); + g_free (data); } void @@ -2169,26 +2148,27 @@ gnc_account_renumber_create_dialog (GtkWidget *window, Account *account) * should be disabled if the account has no children. */ g_return_if_fail (gnc_account_n_children (account) > 0); - data = g_new(RenumberDialog, 1); + data = g_new (RenumberDialog, 1); data->parent = account; - data->num_children = gnc_account_n_children(account); + data->num_children = gnc_account_n_children (account); - builder = gtk_builder_new(); + builder = gtk_builder_new (); gnc_builder_add_from_file (builder, "dialog-account.glade", "interval_adjustment"); gnc_builder_add_from_file (builder, "dialog-account.glade", "account_renumber_dialog"); data->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "account_renumber_dialog")); - gtk_window_set_transient_for(GTK_WINDOW(data->dialog), GTK_WINDOW(window)); - g_object_set_data_full(G_OBJECT(data->dialog), "builder", builder, - g_object_unref); + gtk_window_set_transient_for (GTK_WINDOW(data->dialog), GTK_WINDOW(window)); + + g_object_set_data_full (G_OBJECT(data->dialog), "builder", builder, + g_object_unref); widget = GTK_WIDGET(gtk_builder_get_object (builder, "header_label")); fullname = gnc_account_get_full_name (account); - 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."), - fullname); - gtk_label_set_text(GTK_LABEL(widget), string); - g_free(string); + 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."), + fullname); + gtk_label_set_text (GTK_LABEL(widget), string); + g_free (string); g_free (fullname); data->prefix = GTK_WIDGET(gtk_builder_get_object (builder, "prefix_entry")); @@ -2196,12 +2176,12 @@ gnc_account_renumber_create_dialog (GtkWidget *window, Account *account) data->example1 = GTK_WIDGET(gtk_builder_get_object (builder, "example1_label")); data->example2 = GTK_WIDGET(gtk_builder_get_object (builder, "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); - gtk_builder_connect_signals(builder, data); + gtk_builder_connect_signals (builder, data); - gtk_widget_show_all(data->dialog); + gtk_widget_show_all (data->dialog); } static void @@ -2267,7 +2247,7 @@ gnc_account_cascade_properties_dialog (GtkWidget *window, Account *account) // check if we actually do have sub accounts g_return_if_fail (gnc_account_n_children (account) > 0); - builder = gtk_builder_new(); + builder = gtk_builder_new (); gnc_builder_add_from_file (builder, "dialog-account.glade", "account_cascade_dialog"); dialog = GTK_WIDGET(gtk_builder_get_object (builder, "account_cascade_dialog")); gtk_window_set_transient_for (GTK_WINDOW(dialog), GTK_WINDOW(window)); diff --git a/gnucash/gnome-utils/dialog-account.h b/gnucash/gnome-utils/dialog-account.h index 52c40058b2..d0ac5611f9 100644 --- a/gnucash/gnome-utils/dialog-account.h +++ b/gnucash/gnome-utils/dialog-account.h @@ -138,7 +138,7 @@ Account * gnc_ui_new_accounts_from_name_window (GtkWindow *parent, /* Note that the caller owns the valid_types list */ Account * gnc_ui_new_accounts_from_name_window_with_types (GtkWindow *parent, const char *name, - GList *valid_types); + GList *valid_types); /** Display a modal window for creating a new account. This function @@ -162,10 +162,10 @@ Account * gnc_ui_new_accounts_from_name_window_with_types (GtkWindow *parent, * @return A pointer to the newly created account. */ Account * gnc_ui_new_accounts_from_name_with_defaults (GtkWindow *parent, - const char *name, - GList *valid_types, - const gnc_commodity * default_commodity, - Account * parent_acct); + const char *name, + GList *valid_types, + const gnc_commodity *default_commodity, + Account *parent_acct); /* * register a callback that gets called when the account has changed