mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Remove registered pref callbacks for the register
A couple of preference callbacks are setup to track the 'negative_color_preference' and 'auto_raise_lists' which are setup with a call to 'g_once'. To be able to remove these, the the preference id is saved so that they can be used in gnc_main_window_remove_prefs to remove the callback.
This commit is contained in:
parent
8a44814378
commit
6157251573
@ -2652,6 +2652,22 @@ gnc_main_window_remove_prefs (GncMainWindow *window)
|
||||
GNC_PREF_TAB_POSITION_RIGHT,
|
||||
gnc_main_window_update_tab_position,
|
||||
window);
|
||||
|
||||
// remove the registered negative color preference callback.
|
||||
if (gnc_prefs_get_reg_negative_color_pref_id() > 0)
|
||||
{
|
||||
gnc_prefs_remove_cb_by_id (GNC_PREFS_GROUP_GENERAL,
|
||||
gnc_prefs_get_reg_negative_color_pref_id());
|
||||
gnc_prefs_set_reg_negative_color_pref_id (0);
|
||||
}
|
||||
|
||||
// remove the registered auto_raise_lists preference callback.
|
||||
if (gnc_prefs_get_reg_auto_raise_lists_id() > 0)
|
||||
{
|
||||
gnc_prefs_remove_cb_by_id (GNC_PREFS_GROUP_GENERAL_REGISTER,
|
||||
gnc_prefs_get_reg_auto_raise_lists_id());
|
||||
gnc_prefs_set_reg_auto_raise_lists_id (0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -2459,9 +2459,13 @@ gnc_split_register_colorize_negative (gpointer gsettings, gchar *key, gpointer u
|
||||
static gpointer
|
||||
gnc_split_register_model_add_hooks (gpointer unused)
|
||||
{
|
||||
gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED,
|
||||
gnc_split_register_colorize_negative,
|
||||
NULL);
|
||||
gulong id = gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL,
|
||||
GNC_PREF_NEGATIVE_IN_RED,
|
||||
gnc_split_register_colorize_negative,
|
||||
NULL);
|
||||
|
||||
gnc_prefs_set_reg_negative_color_pref_id (id);
|
||||
|
||||
/* Get the initial value */
|
||||
use_red_for_negative = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL,
|
||||
GNC_PREF_NEGATIVE_IN_RED);
|
||||
|
@ -99,13 +99,16 @@ gnc_combo_cell_set_autopop (gpointer prefs, gchar *pref, gpointer user_data)
|
||||
static gpointer
|
||||
gnc_combo_cell_autopop_init (gpointer unused)
|
||||
{
|
||||
gulong id;
|
||||
auto_pop_combos = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL_REGISTER,
|
||||
GNC_PREF_AUTO_RAISE_LISTS);
|
||||
|
||||
gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL_REGISTER,
|
||||
GNC_PREF_AUTO_RAISE_LISTS,
|
||||
gnc_combo_cell_set_autopop,
|
||||
NULL);
|
||||
id = gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL_REGISTER,
|
||||
GNC_PREF_AUTO_RAISE_LISTS,
|
||||
gnc_combo_cell_set_autopop,
|
||||
NULL);
|
||||
|
||||
gnc_prefs_set_reg_auto_raise_lists_id (id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,12 @@ static gboolean use_compression = TRUE; // This is also the default in the pre
|
||||
static gint file_retention_policy = 1; // 1 = "days", the default in the prefs backend
|
||||
static gint file_retention_days = 30; // This is also the default in the prefs backend
|
||||
|
||||
|
||||
/* Global variables used to remove the preference registered callbacks
|
||||
* that were setup via a g_once. */
|
||||
static gulong reg_auto_raise_lists_id;
|
||||
static gulong reg_negative_color_pref_id;
|
||||
|
||||
PrefsBackend *prefsbackend = NULL;
|
||||
|
||||
const gchar *
|
||||
@ -379,3 +385,24 @@ void gnc_prefs_unblock_all (void)
|
||||
if (prefsbackend && prefsbackend->unblock_all)
|
||||
(prefsbackend->unblock_all) ();
|
||||
}
|
||||
|
||||
gulong gnc_prefs_get_reg_auto_raise_lists_id (void)
|
||||
{
|
||||
return reg_auto_raise_lists_id;
|
||||
}
|
||||
|
||||
void gnc_prefs_set_reg_auto_raise_lists_id (gulong id)
|
||||
{
|
||||
reg_auto_raise_lists_id = id;
|
||||
}
|
||||
|
||||
gulong gnc_prefs_get_reg_negative_color_pref_id (void)
|
||||
{
|
||||
return reg_negative_color_pref_id;
|
||||
}
|
||||
|
||||
void gnc_prefs_set_reg_negative_color_pref_id (gulong id)
|
||||
{
|
||||
reg_negative_color_pref_id = id;
|
||||
}
|
||||
|
||||
|
@ -553,6 +553,16 @@ void gnc_prefs_reset (const gchar *group,
|
||||
*/
|
||||
void gnc_prefs_reset_group (const gchar *group);
|
||||
|
||||
/** Get and Set registered preference id for register auto_raise_lists
|
||||
*/
|
||||
gulong gnc_prefs_get_reg_auto_raise_lists_id (void);
|
||||
void gnc_prefs_set_reg_auto_raise_lists_id (gulong id);
|
||||
|
||||
/** Get and Set registered preference id for register negative_color_pref
|
||||
*/
|
||||
gulong gnc_prefs_get_reg_negative_color_pref_id (void);
|
||||
void gnc_prefs_set_reg_negative_color_pref_id (gulong id);
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user