mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[gnc-plugin-page-register.cpp] input_date to return an optional time64
launches time64 input dialog
This commit is contained in:
parent
46aa584ab9
commit
6b1944f17b
@ -35,6 +35,8 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
#include <libguile.h>
|
#include <libguile.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
@ -3857,6 +3859,15 @@ gnc_plugin_page_register_cmd_unvoid_transaction (GSimpleAction *simple,
|
|||||||
LEAVE (" ");
|
LEAVE (" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::optional<time64>
|
||||||
|
input_date (GtkWidget * parent, const char *window_title, const char* title)
|
||||||
|
{
|
||||||
|
time64 rv = gnc_time (nullptr);
|
||||||
|
if (!gnc_dup_time64_dialog (parent, window_title, title, &rv))
|
||||||
|
return {};
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gnc_plugin_page_register_cmd_reverse_transaction (GSimpleAction *simple,
|
gnc_plugin_page_register_cmd_reverse_transaction (GSimpleAction *simple,
|
||||||
@ -3868,7 +3879,6 @@ gnc_plugin_page_register_cmd_reverse_transaction (GSimpleAction *simple,
|
|||||||
SplitRegister* reg;
|
SplitRegister* reg;
|
||||||
GNCSplitReg* gsr;
|
GNCSplitReg* gsr;
|
||||||
Transaction* trans, *new_trans;
|
Transaction* trans, *new_trans;
|
||||||
time64 date = gnc_time (NULL);
|
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
Account *account;
|
Account *account;
|
||||||
Split *split;
|
Split *split;
|
||||||
@ -3906,8 +3916,8 @@ gnc_plugin_page_register_cmd_reverse_transaction (GSimpleAction *simple,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!gnc_dup_time64_dialog (window, _("Reverse Transaction"),
|
auto date = input_date (window, _("Reverse Transaction"), _("New Transaction Information"));
|
||||||
_("New Transaction Information"), &date))
|
if (!date)
|
||||||
{
|
{
|
||||||
LEAVE ("reverse cancelled");
|
LEAVE ("reverse cancelled");
|
||||||
return;
|
return;
|
||||||
@ -3917,7 +3927,7 @@ gnc_plugin_page_register_cmd_reverse_transaction (GSimpleAction *simple,
|
|||||||
new_trans = xaccTransReverse (trans);
|
new_trans = xaccTransReverse (trans);
|
||||||
|
|
||||||
/* Clear transaction level info */
|
/* Clear transaction level info */
|
||||||
xaccTransSetDatePostedSecsNormalized (new_trans, date);
|
xaccTransSetDatePostedSecsNormalized (new_trans, date.value());
|
||||||
xaccTransSetDateEnteredSecs (new_trans, gnc_time (NULL));
|
xaccTransSetDateEnteredSecs (new_trans, gnc_time (NULL));
|
||||||
|
|
||||||
gnc_resume_gui_refresh();
|
gnc_resume_gui_refresh();
|
||||||
@ -4672,14 +4682,14 @@ gnc_plugin_page_register_cmd_goto_date (GSimpleAction *simple,
|
|||||||
auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
|
auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
|
||||||
GNCSplitReg* gsr;
|
GNCSplitReg* gsr;
|
||||||
Query* query;
|
Query* query;
|
||||||
time64 date = gnc_time (NULL);
|
|
||||||
GList *splits;
|
GList *splits;
|
||||||
|
GtkWidget *window = gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page));
|
||||||
|
|
||||||
ENTER ("(action %p, page %p)", simple, page);
|
ENTER ("(action %p, page %p)", simple, page);
|
||||||
g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
|
g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
|
||||||
|
|
||||||
if (!gnc_dup_time64_dialog (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page)),
|
auto date = input_date (window, _("Go to Date"), _("Go to Date"));
|
||||||
_("Go to Date"), _("Go to Date"), &date))
|
if (!date)
|
||||||
{
|
{
|
||||||
LEAVE ("goto_date cancelled");
|
LEAVE ("goto_date cancelled");
|
||||||
return;
|
return;
|
||||||
@ -4692,7 +4702,7 @@ gnc_plugin_page_register_cmd_goto_date (GSimpleAction *simple,
|
|||||||
|
|
||||||
for (GList *lp = splits; lp; lp = lp->next)
|
for (GList *lp = splits; lp; lp = lp->next)
|
||||||
{
|
{
|
||||||
if (xaccTransGetDate (xaccSplitGetParent (GNC_SPLIT(lp->data))) >= date)
|
if (xaccTransGetDate (xaccSplitGetParent (GNC_SPLIT(lp->data))) >= date.value())
|
||||||
{
|
{
|
||||||
gnc_split_reg_jump_to_split (gsr, GNC_SPLIT(lp->data));
|
gnc_split_reg_jump_to_split (gsr, GNC_SPLIT(lp->data));
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user