Skip to content

Commit

Permalink
Fix PR comments so far.
Browse files Browse the repository at this point in the history
Except for gnc-option-date's normalize_tm and set_day_and_time.
  • Loading branch information
jralls committed Nov 14, 2021
1 parent 4c43dac commit f6c9e63
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 60 deletions.
33 changes: 0 additions & 33 deletions gnucash/gnome-utils/gnc-gnome-utils.c
Expand Up @@ -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);
}

#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
gnc_style_sheet_options_help_cb (GNCOptionWin *win, gpointer dat)
{
Expand Down
4 changes: 2 additions & 2 deletions gnucash/gnome-utils/gnc-main-window.cpp
Expand Up @@ -1924,13 +1924,13 @@ gnc_main_window_update_radio_button (GncMainWindow *window)
{
first_action = static_cast<GtkAction*>(g_slist_last(action_list)->data);
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);
DEBUG("blocked signal on %p, set %p active, window %p", first_action,
action, window);
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), TRUE);
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);
}
g_free(action_name);
Expand Down
2 changes: 0 additions & 2 deletions gnucash/gnome/assistant-hierarchy.cpp
Expand Up @@ -131,8 +131,6 @@ typedef struct

} hierarchy_data;

extern gboolean gnc_book_options_dialog_apply_helper(GncOptionDB * options);

void on_prepare (GtkAssistant *assistant, GtkWidget *page,
hierarchy_data *data);
void on_choose_account_categories_prepare (hierarchy_data *data);
Expand Down
2 changes: 1 addition & 1 deletion gnucash/gnome/gnc-plugin-page-report.cpp
Expand Up @@ -1748,7 +1748,7 @@ gnc_plugin_page_report_export_cb( GtkAction *action, GncPluginPageReport *report
gnc_error_dialog (parent, "%s",
_("This report must be upgraded to return a "
"document object with export-string or "
"pexport-error."));
"export-error."));
}
result = TRUE;
}
Expand Down
10 changes: 0 additions & 10 deletions libgnucash/app-utils/app-utils.i
Expand Up @@ -65,10 +65,6 @@ PyObject* SWIG_init (void);

%import "base-typemaps.i"

/* OBSOLETE
typedef void (*GNCOptionChangeCallback) (gpointer user_data);
typedef int GNCOptionDBHandle;
*/
void gnc_prefs_init();

QofBook * gnc_get_current_book (void);
Expand Down Expand Up @@ -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_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_account_print_info (const Account *account,
gboolean use_symbol);
Expand All @@ -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_end(void);

/* OBSOLETE Options are C++, no SCM generators.
void gnc_register_kvp_option_generator(QofIdType id_type, SCM generator);
*/
%typemap(out) GHashTable * {
SCM table = scm_c_make_hash_table (g_hash_table_size($1) + 17);
GHashTableIter iter;
Expand Down
8 changes: 4 additions & 4 deletions libgnucash/app-utils/gnc-option-date.cpp
Expand Up @@ -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 void
normalize_tm(struct tm& now)
normalize_reldate_tm(struct tm& now)
{
auto tmp_mon = now.tm_mon + (now.tm_mon < 0 ? 12 :
now.tm_mon > 11 ? -12 : 0);
Expand All @@ -453,7 +453,7 @@ normalize_tm(struct tm& now)
}

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)
{
Expand Down Expand Up @@ -549,8 +549,8 @@ gnc_relative_date_to_time64(RelativeDatePeriod period)
else if (reldate_is_next(period))
now.tm_mday += 7;
}
normalize_tm(now);
set_day_and_time(now, checked_reldate(period).m_type);
normalize_reldate_tm(now);
reldate_set_day_and_time(now, checked_reldate(period).m_type);
return static_cast<time64>(GncDateTime(now));
}

Expand Down
13 changes: 11 additions & 2 deletions libgnucash/app-utils/gnc-option-date.hpp
Expand Up @@ -127,7 +127,7 @@ const char* gnc_relative_date_storage_string(RelativeDatePeriod);

/**
* 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.
* @return A constant string or nullptr if the period is ABSOLUTE. The string's
Expand Down Expand Up @@ -158,7 +158,16 @@ const char* gnc_relative_date_description(RelativeDatePeriod);
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.
* @return a time64.
Expand Down
4 changes: 2 additions & 2 deletions libgnucash/app-utils/gnc-option-impl.cpp
Expand Up @@ -104,7 +104,7 @@ GncOptionAccountListValue::account_type_list() const noexcept
{
if (m_allowed.empty())
return nullptr;
GList* retval;
GList* retval{nullptr};
for (auto type : m_allowed)
retval = g_list_prepend(retval, GINT_TO_POINTER(type));
return g_list_reverse(retval);
Expand Down Expand Up @@ -170,7 +170,7 @@ GncOptionAccountSelValue::account_type_list() const noexcept
{
if (m_allowed.empty())
return nullptr;
GList* retval;
GList* retval{nullptr};
for (auto type : m_allowed)
retval = g_list_prepend(retval, GINT_TO_POINTER(type));
return g_list_reverse(retval);
Expand Down
13 changes: 9 additions & 4 deletions libgnucash/app-utils/gnc-option-impl.hpp
Expand Up @@ -443,9 +443,14 @@ using GncMultichoiceOptionChoices = std::vector<GncMultichoiceOptionEntry>;
/** @class GncOptionMultichoiceValue
* Multichoice options have a vector of valid options
* (GncMultichoiceOptionChoices) and validate the selection as being one of
* those values. The value is the index of the selected item in the vector. The
* tuple contains three strings, a key, and a display
* name, which * should be localized at the point of use.
* those values. The value is the index of the selected item in the vector.
* 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.
*
*
*/
Expand Down Expand Up @@ -910,7 +915,7 @@ template<> inline std::istream&
operator>> <GncOptionAccountSelValue>(std::istream& iss,
GncOptionAccountSelValue& opt)
{
const Account* value;
Account* value{nullptr};
std::string str;
std::getline(iss, str, ' ');
if (!str.empty())
Expand Down

0 comments on commit f6c9e63

Please sign in to comment.