mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Make sure the sheet has focus in a register when opened
This commit is contained in:
parent
660ab62df9
commit
13d5570b47
@ -836,6 +836,18 @@ gnc_plugin_page_register_get_current_txn (GncPluginPageRegister *page)
|
||||
return gnc_split_register_get_current_trans(reg);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnc_plugin_page_register_focus (GncPluginPageRegister *page)
|
||||
{
|
||||
if (GNC_IS_PLUGIN_PAGE_REGISTER(page))
|
||||
{
|
||||
GncPluginPageRegisterPrivate *priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(page);
|
||||
GNCSplitReg *gsr = gnc_plugin_page_register_get_gsr(GNC_PLUGIN_PAGE(page));
|
||||
gnc_split_reg_focus_on_sheet (gsr);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* This is the list of actions which are switched inactive in a read-only book. */
|
||||
static const char* readonly_inactive_actions[] =
|
||||
{
|
||||
|
@ -163,6 +163,16 @@ gnc_plugin_page_register_get_account (GncPluginPageRegister *page);
|
||||
Transaction *
|
||||
gnc_plugin_page_register_get_current_txn (GncPluginPageRegister *page);
|
||||
|
||||
/** Given a pointer to a register plugin page, set the focus to
|
||||
* the sheet. This is used in a g_idle_add so return FALSE.
|
||||
*
|
||||
* @param page The "register" page.
|
||||
*
|
||||
* @return FALSE
|
||||
*/
|
||||
gboolean
|
||||
gnc_plugin_page_register_focus (GncPluginPageRegister *page);
|
||||
|
||||
G_END_DECLS
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
@ -146,6 +146,26 @@ gnc_plugin_register_new (void)
|
||||
return GNC_PLUGIN (plugin);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_plugin_register_main_window_page_changed(GncMainWindow *window,
|
||||
GncPluginPage *plugin_page, gpointer user_data)
|
||||
{
|
||||
// We continue only if the plugin_page is a valid
|
||||
if (!plugin_page || !GNC_IS_PLUGIN_PAGE(plugin_page))
|
||||
return;
|
||||
|
||||
if (gnc_main_window_get_current_page (window) == plugin_page)
|
||||
{
|
||||
if (!GNC_IS_PLUGIN_PAGE_REGISTER(plugin_page))
|
||||
return;
|
||||
|
||||
// The page changed signal is emitted multiple times so we need
|
||||
// to use an idle_add to change the focus to the register
|
||||
g_idle_add ((GSourceFunc)gnc_plugin_page_register_focus,
|
||||
GNC_PLUGIN_PAGE_REGISTER (plugin_page));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_plugin_register_class_init (GncPluginRegisterClass *klass)
|
||||
{
|
||||
@ -211,6 +231,10 @@ gnc_plugin_register_add_to_window (GncPlugin *plugin,
|
||||
{
|
||||
gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL_REGISTER, NULL,
|
||||
gnc_plugin_register_pref_changed, window);
|
||||
|
||||
g_signal_connect(window, "page_changed",
|
||||
G_CALLBACK(gnc_plugin_register_main_window_page_changed),
|
||||
plugin);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1519,6 +1519,17 @@ gnc_split_reg_jump_to_blank (GNCSplitReg *gsr)
|
||||
LEAVE(" ");
|
||||
}
|
||||
|
||||
void
|
||||
gnc_split_reg_focus_on_sheet (GNCSplitReg *gsr)
|
||||
{
|
||||
GnucashRegister *reg = gsr->reg;
|
||||
GnucashSheet *sheet = gnucash_register_get_sheet (reg);
|
||||
|
||||
// Make sure the sheet is the focus
|
||||
if (!gtk_widget_has_focus(GTK_WIDGET (sheet)))
|
||||
gtk_widget_grab_focus (GTK_WIDGET (sheet));
|
||||
}
|
||||
|
||||
void
|
||||
gnc_split_reg_balancing_entry(GNCSplitReg *gsr, Account *account,
|
||||
time64 statement_date, gnc_numeric balancing_amount)
|
||||
|
@ -233,6 +233,11 @@ void gnc_split_reg_jump_to_blank (GNCSplitReg *gsr);
|
||||
void gnc_split_reg_jump_to_split(GNCSplitReg *gsr, Split *split);
|
||||
void gnc_split_reg_jump_to_split_amount(GNCSplitReg *gsr, Split *split);
|
||||
|
||||
/**
|
||||
* Set the focus of the register to the sheet
|
||||
**/
|
||||
void gnc_split_reg_focus_on_sheet (GNCSplitReg *gsr);
|
||||
|
||||
/*
|
||||
* Create a transaction entry with given amount and date. One account is
|
||||
* specified, the other is undefined i.e. it defaults to orphan account.
|
||||
|
@ -272,10 +272,6 @@ gnucash_register_sheet_resize (GnucashRegister *reg)
|
||||
if (!reg->hscrollbar_visible)
|
||||
gtk_widget_queue_resize (GTK_WIDGET (reg->sheet));
|
||||
|
||||
// Make sure the sheet is the focus
|
||||
if (!gtk_widget_has_focus(GTK_WIDGET (reg->sheet)))
|
||||
gtk_widget_grab_focus (GTK_WIDGET (reg->sheet));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user