diff --git a/gnucash/gnome-utils/gnc-plugin-page.c b/gnucash/gnome-utils/gnc-plugin-page.c index 0298d59a03..9e6c70dcaa 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.c +++ b/gnucash/gnome-utils/gnc-plugin-page.c @@ -107,6 +107,7 @@ typedef struct _GncPluginPagePrivate gchar *statusbar_text; gulong page_changed_id; + guint focus_source_id; } GncPluginPagePrivate; @@ -521,6 +522,7 @@ gnc_plugin_page_init (GncPluginPage *page, void *data) priv->page_color = NULL; priv->uri = NULL; priv->page_changed_id = 0; + priv->focus_source_id = 0; page->window = NULL; page->summarybar = NULL; @@ -856,6 +858,14 @@ gnc_plugin_page_set_page_color (GncPluginPage *page, const gchar *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 gnc_plugin_page_default_focus (GncPluginPage *plugin_page, gboolean on_current_page) @@ -873,9 +883,14 @@ gnc_plugin_page_default_focus (GncPluginPage *plugin_page, { // The page changed signal is emitted multiple times so we need // 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), - GNC_PLUGIN_PAGE(plugin_page)); + + if (priv->focus_source_id > 0) + 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 +922,7 @@ gnc_plugin_page_main_window_changed (GtkWindow *window, (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 * the callback for the "page_changed" signal and save a pointer to the * page focus function. */ diff --git a/gnucash/gnome-utils/gnc-plugin-page.h b/gnucash/gnome-utils/gnc-plugin-page.h index 82416acfe8..4501b6c85a 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.h +++ b/gnucash/gnome-utils/gnc-plugin-page.h @@ -167,8 +167,8 @@ typedef struct * widget. * * @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); /** This function vector allows page specific actions to occur diff --git a/gnucash/gnome/gnc-plugin-budget.c b/gnucash/gnome/gnc-plugin-budget.c index ff50121e2d..ab7364f9a2 100644 --- a/gnucash/gnome/gnc-plugin-budget.c +++ b/gnucash/gnome/gnc-plugin-budget.c @@ -156,7 +156,7 @@ gnc_plugin_budget_cmd_new_budget (GtkAction *action, budget = gnc_budget_new (gnc_get_current_book()); 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); gnc_budget_set_description (budget, description); g_free (description);