/********************************************************************\ * gnc_stock_split_dialog * * opens up a window to record a stock split * * * * Args: parent - the parent ofthis window * * initial - the initial account to use * * Return: nothing * \********************************************************************/ void gnc_stock_split_dialog (GtkWidget *parent, Account * initial) { StockSplitInfo *info; gint component_id; info = g_new0 (StockSplitInfo, 1); info->acct = NULL; gnc_stock_split_assistant_create (info); component_id = gnc_register_gui_component (ASSISTANT_STOCK_SPLIT_CM_CLASS, refresh_handler, close_handler, info); gnc_gui_component_watch_entity_type (component_id, GNC_ID_ACCOUNT, QOF_EVENT_MODIFY | QOF_EVENT_DESTROY); if (fill_account_list (info, initial) == 0) { gnc_warning_dialog (parent, "%s", _("You don't have any stock accounts with balances!")); gnc_close_gui_component_by_data (ASSISTANT_STOCK_SPLIT_CM_CLASS, info); return; } gtk_widget_show_all (info->window); gnc_window_adjust_for_screen (GTK_WINDOW(info->window)); }
void gnc_commodities_dialog_response (GtkDialog *dialog, gint response, CommoditiesDialog *cd) { switch (response) { case GNC_RESPONSE_NEW: add_clicked (cd); return; case GNC_RESPONSE_DELETE: remove_clicked (cd); return; case GNC_RESPONSE_EDIT: edit_clicked (cd); return; case GTK_RESPONSE_CLOSE: default: gnc_close_gui_component_by_data (DIALOG_COMMODITIES_CM_CLASS, cd); return; } }
static void ap_finish (GnomeDruidPageEdge *druidpage, GtkWidget *druid, gpointer user_data) { AcctPeriodInfo *info = user_data; gnc_close_gui_component_by_data (DRUID_ACCT_PERIOD_CM_CLASS, info); }
void gnc_ui_fincalc_dialog_destroy(FinCalcDialog *fcd) { if (fcd == NULL) return; gnc_close_gui_component_by_data (DIALOG_FINCALC_CM_CLASS, fcd); }
void gnc_prices_dialog_response (GtkDialog *dialog, gint response_id, gpointer data) { PricesDialog *pdb_dialog = data; ENTER(" "); gnc_close_gui_component_by_data (DIALOG_PRICE_DB_CM_CLASS, pdb_dialog); LEAVE(" "); }
void gnc_find_account_dialog_close_cb (GtkDialog *dialog, gpointer user_data) { FindAccountDialog *facc_dialog = user_data; ENTER(" "); gnc_close_gui_component_by_data (DIALOG_FIND_ACCOUNT_CM_CLASS, facc_dialog); LEAVE(" "); }
static void refresh_handler (GHashTable *changes, gpointer user_data) { StockSplitInfo *info = user_data; Account *old_account; old_account = info->acct; if (fill_account_list (info, info->acct) == 0) { gnc_close_gui_component_by_data (ASSISTANT_STOCK_SPLIT_CM_CLASS, info); return; } if (NULL == info->acct || old_account == info->acct) return; }
void fincalc_response_cb (GtkDialog *dialog, gint response, FinCalcDialog *fcd) { switch (response) { case GTK_RESPONSE_OK: /* Do something here whenever the hidden schedule button is clicked. */ /* Fall through */ case GTK_RESPONSE_CLOSE: gnc_save_window_size(GNC_PREFS_GROUP, GTK_WINDOW(dialog)); break; default: /* Cancel, destroy, etc. Do nothing. */ break; } gnc_close_gui_component_by_data (DIALOG_FINCALC_CM_CLASS, fcd); }
void gnc_find_account_dialog_response_cb (GtkDialog *dialog, gint response_id, gpointer user_data) { FindAccountDialog *facc_dialog = user_data; switch (response_id) { case GTK_RESPONSE_APPLY: gnc_find_account_dialog_jump_to (facc_dialog); return; case GTK_RESPONSE_YES: gnc_find_account_dialog_jump_set (facc_dialog); return; case GTK_RESPONSE_CLOSE: default: gnc_close_gui_component_by_data (DIALOG_FIND_ACCOUNT_CM_CLASS, facc_dialog); return; } }
void csv_import_assistant_close (GtkAssistant *assistant, gpointer user_data) { CsvImportInfo *info = user_data; gnc_close_gui_component_by_data (ASSISTANT_CSV_IMPORT_CM_CLASS, info); }
void gnc_stock_split_assistant_cancel (GtkAssistant *assistant, gpointer user_data) { StockSplitInfo *info = user_data; gnc_close_gui_component_by_data (ASSISTANT_STOCK_SPLIT_CM_CLASS, info); }
void gnc_stock_split_assistant_finish (GtkAssistant *assistant, gpointer user_data) { StockSplitInfo *info = user_data; GList *account_commits; GList *node; gnc_numeric amount; Transaction *trans; Account *account; Split *split; time64 date; account = info->acct; g_return_if_fail (account != NULL); amount = gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (info->distribution_edit)); g_return_if_fail (!gnc_numeric_zero_p (amount)); gnc_suspend_gui_refresh (); trans = xaccMallocTransaction (gnc_get_current_book ()); xaccTransBeginEdit (trans); xaccTransSetCurrency (trans, gnc_default_currency ()); date = gnc_date_edit_get_date (GNC_DATE_EDIT (info->date_edit)); xaccTransSetDatePostedSecsNormalized (trans, date); { const char *description; description = gtk_entry_get_text (GTK_ENTRY (info->description_entry)); xaccTransSetDescription (trans, description); } split = xaccMallocSplit (gnc_get_current_book ()); xaccAccountBeginEdit (account); account_commits = g_list_prepend (NULL, account); xaccTransAppendSplit (trans, split); xaccAccountInsertSplit (account, split); xaccSplitSetAmount (split, amount); xaccSplitMakeStockSplit (split); /* Set split-action with gnc_set_num_action which is the same as * xaccSplitSetAction with these arguments */ /* Translators: This string has a disambiguation prefix */ gnc_set_num_action (NULL, split, NULL, Q_("Action Column|Split")); amount = gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (info->price_edit)); if (gnc_numeric_positive_p (amount)) { QofBook *book; GNCPrice *price; GNCPriceDB *pdb; GNCCurrencyEdit *ce; Timespec ts; ce = GNC_CURRENCY_EDIT (info->price_currency_edit); ts.tv_sec = date; ts.tv_nsec = 0; price = gnc_price_create (gnc_get_current_book ()); gnc_price_begin_edit (price); gnc_price_set_commodity (price, xaccAccountGetCommodity (account)); gnc_price_set_currency (price, gnc_currency_edit_get_currency (ce)); gnc_price_set_time (price, ts); gnc_price_set_source (price, PRICE_SOURCE_STOCK_SPLIT); gnc_price_set_typestr (price, PRICE_TYPE_UNK); gnc_price_set_value (price, amount); gnc_price_commit_edit (price); book = gnc_get_current_book (); pdb = gnc_pricedb_get_db (book); if (!gnc_pricedb_add_price (pdb, price)) gnc_error_dialog (info->window, "%s", _("Error adding price.")); } amount = gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (info->cash_edit)); if (gnc_numeric_positive_p (amount)) { const char *memo; memo = gtk_entry_get_text (GTK_ENTRY (info->memo_entry)); /* asset split */ account = gnc_tree_view_account_get_selected_account (GNC_TREE_VIEW_ACCOUNT(info->asset_tree)); split = xaccMallocSplit (gnc_get_current_book ()); xaccAccountBeginEdit (account); account_commits = g_list_prepend (account_commits, account); xaccAccountInsertSplit (account, split); xaccTransAppendSplit (trans, split); xaccSplitSetAmount (split, amount); xaccSplitSetValue (split, amount); xaccSplitSetMemo (split, memo); /* income split */ account = gnc_tree_view_account_get_selected_account (GNC_TREE_VIEW_ACCOUNT(info->income_tree)); split = xaccMallocSplit (gnc_get_current_book ()); xaccAccountBeginEdit (account); account_commits = g_list_prepend (account_commits, account); xaccAccountInsertSplit (account, split); xaccTransAppendSplit (trans, split); xaccSplitSetAmount (split, gnc_numeric_neg (amount)); xaccSplitSetValue (split, gnc_numeric_neg (amount)); xaccSplitSetMemo (split, memo); } xaccTransCommitEdit (trans); for (node = account_commits; node; node = node->next) xaccAccountCommitEdit (node->data); g_list_free (account_commits); gnc_resume_gui_refresh (); gnc_close_gui_component_by_data (ASSISTANT_STOCK_SPLIT_CM_CLASS, info); }
void ap_assistant_close (GtkAssistant *assistant, gpointer user_data) { AcctPeriodInfo *info = user_data; gnc_close_gui_component_by_data (ASSISTANT_ACCT_PERIOD_CM_CLASS, info); }
static void ap_druid_cancel (GnomeDruid *druid, gpointer user_data) { AcctPeriodInfo *info = user_data; gnc_close_gui_component_by_data (DRUID_ACCT_PERIOD_CM_CLASS, info); }