Fix PR comments so far.

Except for gnc-option-date's normalize_tm and set_day_and_time.
This commit is contained in:
John Ralls 2021-11-14 15:28:22 -08:00
parent 4c43dac1b6
commit f6c9e63e3d
9 changed files with 29 additions and 60 deletions

View File

@ -99,39 +99,6 @@ gnc_book_options_help_cb (GNCOptionWin *win, gpointer dat)
gnc_gnome_help (GTK_WINDOW(gnc_options_dialog_widget (win)), HF_HELP, HL_BOOK_OPTIONS); gnc_gnome_help (GTK_WINDOW(gnc_options_dialog_widget (win)), HF_HELP, HL_BOOK_OPTIONS);
} }
#if 0 // Reimplemented in dialog-options.cpp
void
gnc_options_dialog_set_book_options_help_cb (GNCOptionWin *win)
{
gnc_options_dialog_set_help_cb(win,
(GNCOptionWinCallback)gnc_book_options_help_cb,
NULL);
}
void
gnc_options_dialog_set_new_book_option_values (GNCOptionDB *odb)
{
GNCOption *num_source_option;
GtkWidget *num_source_is_split_action_button;
gboolean num_source_is_split_action;
if (!odb) return;
num_source_is_split_action = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL,
GNC_PREF_NUM_SOURCE);
if (num_source_is_split_action)
{
num_source_option = gnc_option_db_get_option_by_name(odb,
OPTION_SECTION_ACCOUNTS,
OPTION_NAME_NUM_FIELD_SOURCE);
num_source_is_split_action_button =
gnc_option_get_gtk_widget (num_source_option);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (num_source_is_split_action_button),
num_source_is_split_action);
}
}
#endif
static void static void
gnc_style_sheet_options_help_cb (GNCOptionWin *win, gpointer dat) gnc_style_sheet_options_help_cb (GNCOptionWin *win, gpointer dat)
{ {

View File

@ -1924,13 +1924,13 @@ gnc_main_window_update_radio_button (GncMainWindow *window)
{ {
first_action = static_cast<GtkAction*>(g_slist_last(action_list)->data); first_action = static_cast<GtkAction*>(g_slist_last(action_list)->data);
g_signal_handlers_block_by_func(G_OBJECT(first_action), g_signal_handlers_block_by_func(G_OBJECT(first_action),
(void*)gnc_main_window_cmd_window_raise, (gpointer)gnc_main_window_cmd_window_raise,
window); window);
DEBUG("blocked signal on %p, set %p active, window %p", first_action, DEBUG("blocked signal on %p, set %p active, window %p", first_action,
action, window); action, window);
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), TRUE); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), TRUE);
g_signal_handlers_unblock_by_func(G_OBJECT(first_action), g_signal_handlers_unblock_by_func(G_OBJECT(first_action),
(void*)gnc_main_window_cmd_window_raise, (gpointer)gnc_main_window_cmd_window_raise,
window); window);
} }
g_free(action_name); g_free(action_name);

View File

@ -131,8 +131,6 @@ typedef struct
} hierarchy_data; } hierarchy_data;
extern gboolean gnc_book_options_dialog_apply_helper(GncOptionDB * options);
void on_prepare (GtkAssistant *assistant, GtkWidget *page, void on_prepare (GtkAssistant *assistant, GtkWidget *page,
hierarchy_data *data); hierarchy_data *data);
void on_choose_account_categories_prepare (hierarchy_data *data); void on_choose_account_categories_prepare (hierarchy_data *data);

View File

@ -1748,7 +1748,7 @@ gnc_plugin_page_report_export_cb( GtkAction *action, GncPluginPageReport *report
gnc_error_dialog (parent, "%s", gnc_error_dialog (parent, "%s",
_("This report must be upgraded to return a " _("This report must be upgraded to return a "
"document object with export-string or " "document object with export-string or "
"pexport-error.")); "export-error."));
} }
result = TRUE; result = TRUE;
} }

View File

@ -65,10 +65,6 @@ PyObject* SWIG_init (void);
%import "base-typemaps.i" %import "base-typemaps.i"
/* OBSOLETE
typedef void (*GNCOptionChangeCallback) (gpointer user_data);
typedef int GNCOptionDBHandle;
*/
void gnc_prefs_init(); void gnc_prefs_init();
QofBook * gnc_get_current_book (void); QofBook * gnc_get_current_book (void);
@ -99,9 +95,6 @@ gnc_commodity_table_get_quotable_commodities(const gnc_commodity_table * table);
gnc_commodity * gnc_default_currency (void); gnc_commodity * gnc_default_currency (void);
gnc_commodity * gnc_default_report_currency (void); gnc_commodity * gnc_default_report_currency (void);
/* Obsolete: Options are C++ now, no need for convoluted callbacks.
void gncp_option_invoke_callback(GNCOptionChangeCallback callback, void *data);
*/
GNCPrintAmountInfo gnc_default_print_info (gboolean use_symbol); GNCPrintAmountInfo gnc_default_print_info (gboolean use_symbol);
GNCPrintAmountInfo gnc_account_print_info (const Account *account, GNCPrintAmountInfo gnc_account_print_info (const Account *account,
gboolean use_symbol); gboolean use_symbol);
@ -128,9 +121,6 @@ gnc_numeric gnc_convert_from_euro(const gnc_commodity * currency,
time64 gnc_accounting_period_fiscal_start(void); time64 gnc_accounting_period_fiscal_start(void);
time64 gnc_accounting_period_fiscal_end(void); time64 gnc_accounting_period_fiscal_end(void);
/* OBSOLETE Options are C++, no SCM generators.
void gnc_register_kvp_option_generator(QofIdType id_type, SCM generator);
*/
%typemap(out) GHashTable * { %typemap(out) GHashTable * {
SCM table = scm_c_make_hash_table (g_hash_table_size($1) + 17); SCM table = scm_c_make_hash_table (g_hash_table_size($1) + 17);
GHashTableIter iter; GHashTableIter iter;

View File

@ -426,7 +426,7 @@ reldate_offset(RelativeDatePeriod per)
static constexpr int days_in_month[12]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; static constexpr int days_in_month[12]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
static void static void
normalize_tm(struct tm& now) normalize_reldate_tm(struct tm& now)
{ {
auto tmp_mon = now.tm_mon + (now.tm_mon < 0 ? 12 : auto tmp_mon = now.tm_mon + (now.tm_mon < 0 ? 12 :
now.tm_mon > 11 ? -12 : 0); now.tm_mon > 11 ? -12 : 0);
@ -453,7 +453,7 @@ normalize_tm(struct tm& now)
} }
static void static void
set_day_and_time(struct tm& now, RelativeDateType type) reldate_set_day_and_time(struct tm& now, RelativeDateType type)
{ {
if (type == RelativeDateType::START) if (type == RelativeDateType::START)
{ {
@ -549,8 +549,8 @@ gnc_relative_date_to_time64(RelativeDatePeriod period)
else if (reldate_is_next(period)) else if (reldate_is_next(period))
now.tm_mday += 7; now.tm_mday += 7;
} }
normalize_tm(now); normalize_reldate_tm(now);
set_day_and_time(now, checked_reldate(period).m_type); reldate_set_day_and_time(now, checked_reldate(period).m_type);
return static_cast<time64>(GncDateTime(now)); return static_cast<time64>(GncDateTime(now));
} }

View File

@ -127,7 +127,7 @@ const char* gnc_relative_date_storage_string(RelativeDatePeriod);
/** /**
* Provide the string representation of a relative date for displaying * Provide the string representation of a relative date for displaying
* value to a user. This string is not localizable. * value to a user. This string is localizable.
* *
* @param period The relative date period. * @param period The relative date period.
* @return A constant string or nullptr if the period is ABSOLUTE. The string's * @return A constant string or nullptr if the period is ABSOLUTE. The string's
@ -158,7 +158,16 @@ const char* gnc_relative_date_description(RelativeDatePeriod);
RelativeDatePeriod gnc_relative_date_from_storage_string(const char*); RelativeDatePeriod gnc_relative_date_from_storage_string(const char*);
/** /**
* Convert a RelativeDatePeriod value to a concrete time64 by applying the value to the current time. For example if it is now 3:15:42 PM local time 3 June, calling this with a period RelativeDatePeriod::ONE_WEEK_AHEAD will return a time64 representing 3:15:42 PM local time 10 June of this year. * Convert a RelativeDatePeriod value to a concrete time64 by applying the value
* to the current time.
* For example if it is now 3:15:42 PM local time 3 June, calling this with a
* period RelativeDatePeriod::ONE_WEEK_AHEAD will return a time64 representing
* 3:15:42 PM local time 10 June of this year. Times for START periods are
* changed to midnight local time and for END periods to 23:59:59 local time so
* for example if the period is instead RelativeDatePeriod::START_THIS_MONTH the
* time64 will represent 00:00:00 1 June and if it is
* RelativeDatePeriod::END_THIS_MONTH the time64 will be for 23:59:59 30 June,
* both in the current time zone.
* *
* @param period The relative date period to use to calculate the concrete date. * @param period The relative date period to use to calculate the concrete date.
* @return a time64. * @return a time64.

View File

@ -104,7 +104,7 @@ GncOptionAccountListValue::account_type_list() const noexcept
{ {
if (m_allowed.empty()) if (m_allowed.empty())
return nullptr; return nullptr;
GList* retval; GList* retval{nullptr};
for (auto type : m_allowed) for (auto type : m_allowed)
retval = g_list_prepend(retval, GINT_TO_POINTER(type)); retval = g_list_prepend(retval, GINT_TO_POINTER(type));
return g_list_reverse(retval); return g_list_reverse(retval);
@ -170,7 +170,7 @@ GncOptionAccountSelValue::account_type_list() const noexcept
{ {
if (m_allowed.empty()) if (m_allowed.empty())
return nullptr; return nullptr;
GList* retval; GList* retval{nullptr};
for (auto type : m_allowed) for (auto type : m_allowed)
retval = g_list_prepend(retval, GINT_TO_POINTER(type)); retval = g_list_prepend(retval, GINT_TO_POINTER(type));
return g_list_reverse(retval); return g_list_reverse(retval);

View File

@ -443,9 +443,14 @@ using GncMultichoiceOptionChoices = std::vector<GncMultichoiceOptionEntry>;
/** @class GncOptionMultichoiceValue /** @class GncOptionMultichoiceValue
* Multichoice options have a vector of valid options * Multichoice options have a vector of valid options
* (GncMultichoiceOptionChoices) and validate the selection as being one of * (GncMultichoiceOptionChoices) and validate the selection as being one of
* those values. The value is the index of the selected item in the vector. The * those values. The value is the index of the selected item in the vector.
* tuple contains three strings, a key, and a display
* name, which * should be localized at the point of use. * GncMultichoiceOptionEntry is a tuple of two strings and a
* GncOptionMultichoiceKeyType value; the first string is the internal value of
* the option, the second is the display name that should be localized at the
* point of use (so mark it with N_() or (N_ ) when creating the multichoices)
* and the third is an enum value indicating whether the key should be
* interpreted as a Scheme symbol, a string, or a number.
* *
* *
*/ */
@ -910,7 +915,7 @@ template<> inline std::istream&
operator>> <GncOptionAccountSelValue>(std::istream& iss, operator>> <GncOptionAccountSelValue>(std::istream& iss,
GncOptionAccountSelValue& opt) GncOptionAccountSelValue& opt)
{ {
const Account* value; Account* value{nullptr};
std::string str; std::string str;
std::getline(iss, str, ' '); std::getline(iss, str, ' ');
if (!str.empty()) if (!str.empty())