Merge branch 'maint'

This commit is contained in:
Robert Fewell 2020-02-17 10:33:00 +00:00
commit 5475f39f0b
9 changed files with 228 additions and 139 deletions

View File

@ -13,4 +13,9 @@
include (${SRC_DIR}/cmake/version-info2env.cmake) include (${SRC_DIR}/cmake/version-info2env.cmake)
versioninfo2env (${VCS_INFO_FILE}) versioninfo2env (${VCS_INFO_FILE})
if (GNUCASH_BUILD_ID AND NOT "${GNUCASH_BUILD_ID}" STREQUAL "${GNC_VCS_REV}")
set (GNC_VCS_REV "${GNC_VCS_REV} (${GNUCASH_BUILD_ID})")
endif()
configure_file(${SRC} ${DST}) configure_file(${SRC} ${DST})

View File

@ -40,6 +40,13 @@
#include "gnc-window.h" #include "gnc-window.h"
#include "dialog-utils.h" #include "dialog-utils.h"
/** Names of signals generated by the embedded window. */
enum
{
PAGE_CHANGED,
LAST_SIGNAL
};
/* Static Globals *******************************************************/ /* Static Globals *******************************************************/
/** The debugging module that this .o belongs to. */ /** The debugging module that this .o belongs to. */
@ -93,6 +100,10 @@ GNC_DEFINE_TYPE_WITH_CODE(GncEmbeddedWindow, gnc_embedded_window, GTK_TYPE_BOX,
#define GNC_EMBEDDED_WINDOW_GET_PRIVATE(o) \ #define GNC_EMBEDDED_WINDOW_GET_PRIVATE(o) \
((GncEmbeddedWindowPrivate*)g_type_instance_get_private((GTypeInstance*)o, GNC_TYPE_EMBEDDED_WINDOW)) ((GncEmbeddedWindowPrivate*)g_type_instance_get_private((GTypeInstance*)o, GNC_TYPE_EMBEDDED_WINDOW))
/** A holding place for all the signals generated by the embedded window
* code. */
static guint embedded_window_signals[LAST_SIGNAL] = { 0 };
/* Display a data plugin page in a window. */ /* Display a data plugin page in a window. */
void void
gnc_embedded_window_open_page (GncEmbeddedWindow *window, gnc_embedded_window_open_page (GncEmbeddedWindow *window,
@ -180,6 +191,26 @@ gnc_embedded_window_class_init (GncEmbeddedWindowClass *klass)
object_class->finalize = gnc_embedded_window_finalize; object_class->finalize = gnc_embedded_window_finalize;
object_class->dispose = gnc_embedded_window_dispose; object_class->dispose = gnc_embedded_window_dispose;
/**
* GncEmbeddedWindow::page_changed:
* @param window: the #GncEmbeddedWindow
* @param page: the #GncPluginPage
*
* The "page_changed" signal is emitted when a new page is
* selected in the notebook of a GncEmbeddedWindow. This can be
* used to to adjust menu actions based upon which page is
* currently displayed in a window.
*/
embedded_window_signals[PAGE_CHANGED] =
g_signal_new ("page_changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GncEmbeddedWindowClass, page_changed),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
G_TYPE_OBJECT);
LEAVE(" "); LEAVE(" ");
} }

View File

@ -68,6 +68,10 @@ typedef struct
{ {
/** The parent class for an embedded window. */ /** The parent class for an embedded window. */
GtkBoxClass vbox; GtkBoxClass vbox;
/* callbacks */
void (*page_changed) (GncEmbeddedWindow *window,
GncPluginPage *page);
} GncEmbeddedWindowClass; } GncEmbeddedWindowClass;

View File

@ -107,6 +107,7 @@ typedef struct _GncPluginPagePrivate
gchar *statusbar_text; gchar *statusbar_text;
gulong page_changed_id; gulong page_changed_id;
guint focus_source_id;
} GncPluginPagePrivate; } GncPluginPagePrivate;
@ -177,14 +178,10 @@ gnc_plugin_page_show_summarybar (GncPluginPage *page,
return; return;
if (visible) if (visible)
{
gtk_widget_show (page->summarybar); gtk_widget_show (page->summarybar);
}
else else
{
gtk_widget_hide (page->summarybar); gtk_widget_hide (page->summarybar);
} }
}
/* Call the plugin specific function that will save the state of a /* Call the plugin specific function that will save the state of a
@ -521,6 +518,7 @@ gnc_plugin_page_init (GncPluginPage *page, void *data)
priv->page_color = NULL; priv->page_color = NULL;
priv->uri = NULL; priv->uri = NULL;
priv->page_changed_id = 0; priv->page_changed_id = 0;
priv->focus_source_id = 0;
page->window = NULL; page->window = NULL;
page->summarybar = NULL; page->summarybar = NULL;
@ -548,10 +546,13 @@ gnc_plugin_page_finalize (GObject *object)
priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
if (priv->page_name) if (priv->page_name)
g_free (priv->page_name); g_free (priv->page_name);
if (priv->page_color) if (priv->page_color)
g_free (priv->page_color); g_free (priv->page_color);
if (priv->uri) if (priv->uri)
g_free (priv->uri); g_free (priv->uri);
if (priv->statusbar_text) if (priv->statusbar_text)
g_free (priv->statusbar_text); g_free (priv->statusbar_text);
@ -785,6 +786,7 @@ gnc_plugin_page_set_page_name (GncPluginPage *page, const gchar *name)
priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
if (priv->page_name) if (priv->page_name)
g_free (priv->page_name); g_free (priv->page_name);
priv->page_name = g_strdup (name); priv->page_name = g_strdup (name);
/* Perform page specific actions */ /* Perform page specific actions */
@ -823,6 +825,7 @@ gnc_plugin_page_set_page_long_name (GncPluginPage *page, const gchar *name)
priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
if (priv->page_long_name) if (priv->page_long_name)
g_free (priv->page_long_name); g_free (priv->page_long_name);
priv->page_long_name = g_strdup (name); priv->page_long_name = g_strdup (name);
} }
@ -851,11 +854,20 @@ gnc_plugin_page_set_page_color (GncPluginPage *page, const gchar *color)
priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
if (priv->page_color) if (priv->page_color)
g_free (priv->page_color); g_free (priv->page_color);
if (color) if (color)
priv->page_color = g_strdup (color); priv->page_color = g_strdup (color);
} }
static void
gnc_plugin_page_focus_idle_destroy (GncPluginPage *plugin_page)
{
GncPluginPagePrivate *priv = GNC_PLUGIN_PAGE_GET_PRIVATE(plugin_page);
priv->focus_source_id = 0;
}
static void static void
gnc_plugin_page_default_focus (GncPluginPage *plugin_page, gnc_plugin_page_default_focus (GncPluginPage *plugin_page,
gboolean on_current_page) gboolean on_current_page)
@ -873,9 +885,14 @@ gnc_plugin_page_default_focus (GncPluginPage *plugin_page,
{ {
// The page changed signal is emitted multiple times so we need // The page changed signal is emitted multiple times so we need
// to use an idle_add to change the focus // to use an idle_add to change the focus
g_idle_remove_by_data (GNC_PLUGIN_PAGE(plugin_page));
g_idle_add ((GSourceFunc)(GNC_PLUGIN_PAGE_GET_CLASS(plugin_page)->focus_page_function), if (priv->focus_source_id > 0)
GNC_PLUGIN_PAGE(plugin_page)); g_source_remove (priv->focus_source_id);
priv->focus_source_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
(GSourceFunc)(GNC_PLUGIN_PAGE_GET_CLASS(plugin_page)->focus_page_function),
GNC_PLUGIN_PAGE(plugin_page),
(GDestroyNotify)gnc_plugin_page_focus_idle_destroy);
} }
} }
@ -907,6 +924,7 @@ gnc_plugin_page_main_window_changed (GtkWindow *window,
(GNC_PLUGIN_PAGE_GET_CLASS(plugin_page)->focus_page)(plugin_page, on_current_page); (GNC_PLUGIN_PAGE_GET_CLASS(plugin_page)->focus_page)(plugin_page, on_current_page);
} }
/* this is the callback for the plugin "inserted" signal which will setup /* this is the callback for the plugin "inserted" signal which will setup
* the callback for the "page_changed" signal and save a pointer to the * the callback for the "page_changed" signal and save a pointer to the
* page focus function. */ * page focus function. */
@ -970,6 +988,7 @@ gnc_plugin_page_set_uri (GncPluginPage *page, const gchar *name)
priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
if (priv->uri) if (priv->uri)
g_free (priv->uri); g_free (priv->uri);
priv->uri = g_strdup (name); priv->uri = g_strdup (name);
} }
@ -998,6 +1017,7 @@ gnc_plugin_page_set_statusbar_text (GncPluginPage *page, const gchar *message)
priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
if (priv->statusbar_text) if (priv->statusbar_text)
g_free (priv->statusbar_text); g_free (priv->statusbar_text);
priv->statusbar_text = g_strdup (message); priv->statusbar_text = g_strdup (message);
} }
@ -1057,6 +1077,7 @@ gnc_plugin_page_set_ui_description (GncPluginPage *page,
priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
if (priv->ui_description) if (priv->ui_description)
g_free (priv->ui_description); g_free (priv->ui_description);
priv->ui_description = g_strdup (ui_filename); priv->ui_description = g_strdup (ui_filename);
} }
@ -1081,6 +1102,7 @@ gnc_plugin_page_get_action_group(GncPluginPage *page)
GncPluginPagePrivate *priv; GncPluginPagePrivate *priv;
g_return_val_if_fail (GNC_IS_PLUGIN_PAGE(page), NULL); g_return_val_if_fail (GNC_IS_PLUGIN_PAGE(page), NULL);
priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
return priv->action_group; return priv->action_group;
} }
@ -1105,11 +1127,13 @@ gnc_plugin_page_finish_pending (GncPluginPage *page)
{ {
if (!page) if (!page)
return TRUE; return TRUE;
if (!GNC_IS_PLUGIN_PAGE(page)) if (!GNC_IS_PLUGIN_PAGE(page))
return TRUE; return TRUE;
if (!GNC_PLUGIN_PAGE_GET_CLASS(page)->finish_pending) if (!GNC_PLUGIN_PAGE_GET_CLASS(page)->finish_pending)
return TRUE; return TRUE;
return (GNC_PLUGIN_PAGE_GET_CLASS(page)->finish_pending)(page); return (GNC_PLUGIN_PAGE_GET_CLASS(page)->finish_pending)(page);
} }

View File

@ -105,6 +105,7 @@ typedef struct
* *
* @return A displayable gtk widget. */ * @return A displayable gtk widget. */
GtkWidget *(* create_widget) (GncPluginPage *plugin_page); GtkWidget *(* create_widget) (GncPluginPage *plugin_page);
/** Function called to destroy the display widget for a /** Function called to destroy the display widget for a
* particular type of plugin. * particular type of plugin.
* *
@ -168,7 +169,7 @@ typedef struct
* *
* @param page The page that was added to a window. * @param page The page that was added to a window.
* *
* @param on_current_pgae Whether this page is the currentone. */ * @return FALSE to remove idle */
gboolean (* focus_page_function) (GncPluginPage *plugin_page); gboolean (* focus_page_function) (GncPluginPage *plugin_page);
/** This function vector allows page specific actions to occur /** This function vector allows page specific actions to occur
@ -219,7 +220,8 @@ GType gnc_plugin_page_get_type (void);
* @param plugin_page A pointer to the plugin for which a display * @param plugin_page A pointer to the plugin for which a display
* widget should be created. * widget should be created.
* *
* @return A displayable gtk widget. */ * @return A displayable gtk widget.
*/
GtkWidget *gnc_plugin_page_create_widget (GncPluginPage *plugin_page); GtkWidget *gnc_plugin_page_create_widget (GncPluginPage *plugin_page);
@ -228,7 +230,8 @@ GtkWidget *gnc_plugin_page_create_widget (GncPluginPage *plugin_page);
* code when a page is closed. * code when a page is closed.
* *
* @param plugin_page A pointer to the plugin whose display widget * @param plugin_page A pointer to the plugin whose display widget
* should be destroyed. */ * should be destroyed.
*/
void gnc_plugin_page_destroy_widget (GncPluginPage *plugin_page); void gnc_plugin_page_destroy_widget (GncPluginPage *plugin_page);
@ -251,7 +254,8 @@ void gnc_plugin_page_show_summarybar (GncPluginPage *page, gboolean visible);
* @param key_file A pointer to the GKeyFile data structure where the * @param key_file A pointer to the GKeyFile data structure where the
* page information should be written. * page information should be written.
* *
* @param group_name The group name to use when saving data. */ * @param group_name The group name to use when saving data.
*/
void gnc_plugin_page_save_page (GncPluginPage *page, void gnc_plugin_page_save_page (GncPluginPage *page,
GKeyFile *key_file, GKeyFile *key_file,
const gchar *group_name); const gchar *group_name);
@ -268,7 +272,8 @@ void gnc_plugin_page_save_page (GncPluginPage *page,
* @param key_file A pointer to the GKeyFile data structure where the * @param key_file A pointer to the GKeyFile data structure where the
* page information should be read. * page information should be read.
* *
* @param group_name The group name to use when restoring data. */ * @param group_name The group name to use when restoring data.
*/
GncPluginPage *gnc_plugin_page_recreate_page (GtkWidget *window, GncPluginPage *gnc_plugin_page_recreate_page (GtkWidget *window,
const gchar *page_type, const gchar *page_type,
GKeyFile *key_file, GKeyFile *key_file,
@ -281,7 +286,8 @@ GncPluginPage *gnc_plugin_page_recreate_page (GtkWidget *window,
* added to the user interface. * added to the user interface.
* *
* @param merge A pointer to the UI manager data structure for a * @param merge A pointer to the UI manager data structure for a
* window. */ * window.
*/
void gnc_plugin_page_merge_actions (GncPluginPage *plugin_page, void gnc_plugin_page_merge_actions (GncPluginPage *plugin_page,
GtkUIManager *merge); GtkUIManager *merge);
@ -292,7 +298,8 @@ void gnc_plugin_page_merge_actions (GncPluginPage *plugin_page,
* removed from the user interface. * removed from the user interface.
* *
* @param merge A pointer to the UI manager data structure for a * @param merge A pointer to the UI manager data structure for a
* window. */ * window.
*/
void gnc_plugin_page_unmerge_actions (GncPluginPage *plugin_page, void gnc_plugin_page_unmerge_actions (GncPluginPage *plugin_page,
GtkUIManager *merge); GtkUIManager *merge);
@ -303,7 +310,8 @@ void gnc_plugin_page_unmerge_actions (GncPluginPage *plugin_page,
* should be retrieved. * should be retrieved.
* *
* @return The name of this plugin. This string is owned by the * @return The name of this plugin. This string is owned by the
* plugin. */ * plugin.
*/
const gchar *gnc_plugin_page_get_plugin_name (GncPluginPage *plugin_page); const gchar *gnc_plugin_page_get_plugin_name (GncPluginPage *plugin_page);
@ -530,7 +538,8 @@ GtkUIManager *gnc_plugin_page_get_ui_merge (GncPluginPage *page);
* @param page The page whose menu/toolbar action group should be * @param page The page whose menu/toolbar action group should be
* retrieved. * retrieved.
* *
* @return A pointer to the GtkActionGroup object for this page. */ * @return A pointer to the GtkActionGroup object for this page.
*/
GtkActionGroup *gnc_plugin_page_get_action_group (GncPluginPage *page); GtkActionGroup *gnc_plugin_page_get_action_group (GncPluginPage *page);
@ -544,7 +553,8 @@ GtkActionGroup *gnc_plugin_page_get_action_group (GncPluginPage *page);
* be consistent across all pages of the same type. * be consistent across all pages of the same type.
* *
* @return A pointer to the newly created GtkActionGroup object for * @return A pointer to the newly created GtkActionGroup object for
* this page. */ * this page.
*/
GtkActionGroup * gnc_plugin_page_create_action_group (GncPluginPage *page, GtkActionGroup * gnc_plugin_page_create_action_group (GncPluginPage *page,
const gchar *group_name); const gchar *group_name);
@ -555,7 +565,8 @@ GtkActionGroup * gnc_plugin_page_create_action_group (GncPluginPage *page,
* *
* @param name The name of the GtkAction to find. * @param name The name of the GtkAction to find.
* *
* @return A pointer to the retuested GtkAction object or NULL. */ * @return A pointer to the retuested GtkAction object or NULL.
*/
GtkAction *gnc_plugin_page_get_action (GncPluginPage *page, const gchar *name); GtkAction *gnc_plugin_page_get_action (GncPluginPage *page, const gchar *name);
/* Signals */ /* Signals */
@ -569,7 +580,8 @@ void gnc_plugin_page_unselected (GncPluginPage *plugin_page);
* @param plugin_page A page. * @param plugin_page A page.
* *
* @return FALSE if the page could not or would not comply, which * @return FALSE if the page could not or would not comply, which
* should cancel the pending operation. TRUE otherwise */ * should cancel the pending operation. TRUE otherwise
*/
gboolean gnc_plugin_page_finish_pending (GncPluginPage *plugin_page); gboolean gnc_plugin_page_finish_pending (GncPluginPage *plugin_page);
G_END_DECLS G_END_DECLS

View File

@ -200,6 +200,7 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -D SRC=${GNC_APPDATA_IN} COMMAND ${CMAKE_COMMAND} -D SRC=${GNC_APPDATA_IN}
-D DST=${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml -D DST=${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml
-D VCS_INFO_FILE=${VCS_INFO_FILE} -D VCS_INFO_FILE=${VCS_INFO_FILE}
-D GNUCASH_BUILD_ID=${GNUCASH_BUILD_ID}
-D PROJECT_VERSION=${PROJECT_VERSION} -D PROJECT_VERSION=${PROJECT_VERSION}
-D SRC_DIR=${CMAKE_SOURCE_DIR} -D SRC_DIR=${CMAKE_SOURCE_DIR}
-P ${CMAKE_SOURCE_DIR}/cmake/insert-vcs-data.cmake) -P ${CMAKE_SOURCE_DIR}/cmake/insert-vcs-data.cmake)

View File

@ -156,7 +156,7 @@ gnc_plugin_budget_cmd_new_budget (GtkAction *action,
budget = gnc_budget_new (gnc_get_current_book()); budget = gnc_budget_new (gnc_get_current_book());
page = gnc_plugin_page_budget_new (budget); page = gnc_plugin_page_budget_new (budget);
date = qof_print_date (gnc_time (NULL)); date = gnc_print_time64 (gnc_time (NULL), qof_date_format_get_string (QOF_DATE_FORMAT_LOCALE));
description = g_strdup_printf ("%s: %s", _("Created"), date); description = g_strdup_printf ("%s: %s", _("Created"), date);
gnc_budget_set_description (budget, description); gnc_budget_set_description (budget, description);
g_free (description); g_free (description);

View File

@ -132,6 +132,8 @@
(gnc:html-document-set-style-text! (gnc:html-document-set-style-text!
ssdoc ssdoc
(string-append (string-append
;; Note: any changes in the default CSS *should* be duplicated in
;; stylesheet-css.scm
"@media (prefers-color-scheme: dark) {body {color: #000; background-color: #fff;}}\n" "@media (prefers-color-scheme: dark) {body {color: #000; background-color: #fff;}}\n"
"h3 { " title-info " }\n" "h3 { " title-info " }\n"
"a { " account-link-info " }\n" "a { " account-link-info " }\n"

View File

@ -30,6 +30,12 @@
(use-modules (gnucash html)) (use-modules (gnucash html))
(define default-css "/* default style */ (define default-css "/* default style */
@media (prefers-color-scheme: dark) {
body {
color: #000; background-color: #fff;
}
}
html, body { html, body {
height: 100vh; height: 100vh;
margin: 0; margin: 0;
@ -91,6 +97,10 @@ td.neg {
td.number-cell, td.total-number-cell, td.anchor-cell, td.date-cell { td.number-cell, td.total-number-cell, td.anchor-cell, td.date-cell {
white-space: nowrap; white-space: nowrap;
} }
td.highlight {
background-color: #e1e1e1
}
") ")
(define (css-options) (define (css-options)