Merge branch 'maint'

This commit is contained in:
John Ralls
2020-04-25 15:45:59 -07:00
9 changed files with 52 additions and 28 deletions

View File

@@ -4,6 +4,7 @@
# instead of
# >>> from gnucash.gnucash_core import thingy
from gnucash.gnucash_core import *
from . import app_utils
## @file
# @brief helper file for the importing of gnucash
# @author Mark Jenkins, ParIT Worker Co-operative <mark@parit.ca>

View File

@@ -4,13 +4,14 @@
## @file
# @brief High level python wrapper for app-utils
# @ingroup python_bindings
#
# further functions in _sw_app_utils that have not been included:
# _gnc_get_current_book is available through Session.get_book()
# _gnc_get_current_root_account is available through Book.get_root_account()
from gnucash import _sw_app_utils
def gnc_get_current_session():
from gnucash import Session
return Session(instance=_sw_app_utils.gnc_get_current_session())
# further functions in _sw_app_utils
# _gnc_get_current_book is availabe through Session.get_book()
# _gnc_get_current_root_account is available through Session.get_root_account()

View File

@@ -1933,10 +1933,13 @@ gdc_model_added_cb(GncDenseCalModel *model, guint added_tag, gpointer user_data)
static void
gdc_model_update_cb(GncDenseCalModel *model, guint update_tag, gpointer user_data)
{
GncDenseCal *cal = GNC_DENSE_CAL(user_data);
g_debug("gdc_model_update_cb update for tag [%d]\n", update_tag);
gdc_mark_remove(cal, update_tag, FALSE);
gdc_add_tag_markings(cal, update_tag);
GncDenseCal *cal = GNC_DENSE_CAL (user_data);
gint num_marks = 0;
g_debug ("gdc_model_update_cb update for tag [%d]\n", update_tag);
num_marks = gnc_dense_cal_model_get_instance_count (cal->model, update_tag);
// We need to redraw if there are no mark, to ensure they're all erased.
gdc_mark_remove (cal, update_tag, num_marks==0);
gdc_add_tag_markings (cal, update_tag);
}

View File

@@ -62,6 +62,7 @@
#include "gnc-ui.h"
#include "gnc-ui-util.h"
#include "gnucash-sheet.h"
#include "gnc-session.h"
#include "gnc-split-reg.h"
@@ -1123,6 +1124,7 @@ gnc_ui_scheduled_xaction_editor_dialog_create (GtkWindow *parent,
GtkBuilder *builder;
GtkWidget *button;
int i;
int id;
GList *dlgExists = NULL;
static struct widgetSignalCallback
@@ -1209,10 +1211,12 @@ gnc_ui_scheduled_xaction_editor_dialog_create (GtkWindow *parent,
TRUE, TRUE, 0 );
}
gnc_register_gui_component( DIALOG_SCHEDXACTION_EDITOR_CM_CLASS,
NULL, /* no refresh handler */
sxed_close_handler,
sxed );
id = gnc_register_gui_component( DIALOG_SCHEDXACTION_EDITOR_CM_CLASS,
NULL, /* no refresh handler */
sxed_close_handler,
sxed );
// This ensure this dialog is closed when the session is closed.
gnc_gui_component_set_session (id, gnc_get_current_session());
g_signal_connect( sxed->dialog, "delete_event",
G_CALLBACK(sxed_delete_event), sxed );
@@ -1595,7 +1599,6 @@ gnc_sxed_update_cal(GncSxEditorDialog *sxed)
g_date_clear(&start_date, 1);
gnc_frequency_save_to_recurrence(sxed->gncfreq, &recurrences, &start_date);
g_date_subtract_days(&start_date, 1);
recurrenceListNextInstance(recurrences, &start_date, &first_date);
/* Deal with the fact that this SX may have been run before [the
@@ -1606,10 +1609,10 @@ gnc_sxed_update_cal(GncSxEditorDialog *sxed)
last_sx_inst = xaccSchedXactionGetLastOccurDate(sxed->sx);
if (g_date_valid(last_sx_inst)
&& g_date_valid(&first_date)
&& g_date_compare(last_sx_inst, &first_date) != 0)
&& g_date_compare(last_sx_inst, &first_date) > 0)
{
/* last occurrence will be passed as initial date to update store
* later on as well */
* later on as well, but only if it's past first_date */
start_date = *last_sx_inst;
recurrenceListNextInstance(recurrences, &start_date, &first_date);
}

View File

@@ -51,9 +51,10 @@
#include "import-pending-matches.h"
#include "gnc-component-manager.h"
#include "guid.h"
#include "gnc-session.h"
#define GNC_PREFS_GROUP "dialogs.import.generic.transaction-list"
#define IMPORT_MAIN_MATCHER_CM_CLASS "transaction-matcher-dialog"
struct _main_matcher_info
{
@@ -951,6 +952,8 @@ GNCImportMainMatcher *gnc_gen_trans_list_new (GtkWidget *parent,
gboolean show_update;
GtkStyleContext *stylectxt;
GdkRGBA color;
GtkWidget *button;
gint id;
info = g_new0 (GNCImportMainMatcher, 1);
info->pending_matches = gnc_import_PendingMatches_new();
@@ -1010,6 +1013,13 @@ GNCImportMainMatcher *gnc_gen_trans_list_new (GtkWidget *parent,
g_object_unref (G_OBJECT(builder));
// Register this UI, it needs to be closed when the session is closed.
id = gnc_register_gui_component (IMPORT_MAIN_MATCHER_CM_CLASS,
NULL, /* no refresh handler */
(GNCComponentCloseHandler)gnc_gen_trans_list_delete,
info);
// This ensure this dialog is closed when the session is closed.
gnc_gui_component_set_session (id, gnc_get_current_session());
return info;
}

View File

@@ -1,5 +1,4 @@
import sys
import gnucash._sw_app_utils as _sw_app_utils
from gnucash import *
from gnucash._sw_core_utils import gnc_prefs_is_extra_enabled, gnc_prefs_is_debugging_enabled
from gi import require_version
@@ -7,8 +6,12 @@ require_version('Gtk', '3.0')
from gi.repository import Gtk
import os
sys.path.append(os.path.dirname(__file__))
# output file location if gnucash has been started with
# gnucash --extra
if gnc_prefs_is_extra_enabled():
print("woop", os.path.dirname(__file__))
print("Python shell init file: %s" % (__file__))
# Importing the console class causes SIGTTOU to be thrown if GnuCash is
# started in the background. This causes a hang if it is not handled,
# so ignore it for the duration
@@ -20,15 +23,18 @@ import pycons.console as cons
# Restore the SIGTTOU handler
signal.signal(signal.SIGTTOU, old_sigttou)
# output debug information if gnucash has been started with
# gnucash --debug --extra
if gnc_prefs_is_extra_enabled() and gnc_prefs_is_debugging_enabled():
print("Hello from python!")
print("test", sys.modules.keys())
print("test2", dir(_sw_app_utils))
print("Hello from python!\n")
print("sys.modules.keys(): ", sys.modules.keys(), "\n")
print("dir(_sw_app_utils): ", dir(_sw_app_utils), "\n")
#root = _sw_app_utils.gnc_get_current_root_account()
#session = app_utils.gnc_get_current_session()
#root account can later on be accessed by session.get_book().get_root_account()
#print("test", dir(root), root.__class__)
print("test3", dir(gnucash_core_c))
print("dir(gnucash_core_c): ", dir(gnucash_core_c))
#acct = Account(instance = root)

View File

@@ -809,7 +809,6 @@ gnc_ledger_display2_internal (Account *lead_account, Query *q,
ld->use_double_line_default = use_double_line;
// JEAN: add mismatched_commodities
ld->model = gnc_tree_model_split_reg_new (reg_type, style, use_double_line, is_template, mismatched_commodities);
gnc_tree_model_split_reg_set_data (ld->model, ld, gnc_ledger_display2_parent);

View File

@@ -1254,6 +1254,7 @@ gnc_split_register_delete_current_trans (SplitRegister* reg)
xaccTransCommitEdit (trans);
}
gnc_resume_gui_refresh ();
gnc_split_register_redraw (reg);
LEAVE (" ");
}

View File

@@ -931,13 +931,13 @@ xaccSchedXactionGetNextInstance (const SchedXaction *sx, SXTmpStateData *tsd)
* we're at the beginning. We want to pretend prev_occur is the day before
* the start_date in case the start_date is today so that the SX will fire
* today. If start_date isn't valid either then the SX will fire anyway, no
* harm done.
* harm done. prev_occur cannot be before start_date either.
*/
if (! g_date_valid( &prev_occur ) && g_date_valid(&sx->start_date))
if (g_date_valid (&sx->start_date) && (!g_date_valid ( &prev_occur ) || g_date_compare (&prev_occur, &sx->start_date)<0))
{
/* We must be at the beginning. */
prev_occur = sx->start_date;
g_date_subtract_days( &prev_occur, 1 );
g_date_subtract_days (&prev_occur, 1 );
}
recurrenceListNextInstance(sx->schedule, &prev_occur, &next_occur);