Bug797486 - Add dialog to cascade placeholder and hidden

Make changes to the existing cascade colour dialog to allow the
selection of cascading colour, placeholder and hidden account properties
This commit is contained in:
Robert Fewell
2020-02-17 12:07:01 +00:00
parent ad4c150db9
commit ff514e3b37
5 changed files with 391 additions and 78 deletions

View File

@@ -2122,12 +2122,28 @@ update_account_color (Account *acc, const gchar *old_color, const gchar *new_col
}
}
static void
enable_box_cb (GtkToggleButton *toggle_button, gpointer user_data)
{
gboolean sensitive = FALSE;
if (gtk_toggle_button_get_active (toggle_button))
sensitive = TRUE;
gtk_widget_set_sensitive (GTK_WIDGET(user_data), sensitive);
}
void
gnc_account_cascade_color_dialog (GtkWidget *window, Account *account)
gnc_account_cascade_properties_dialog (GtkWidget *window, Account *account)
{
GtkWidget *dialog;
GtkBuilder *builder;
GtkWidget *color_label, *color_button, *over_write, *color_button_default;
GtkWidget *label;
GtkWidget *color_button, *over_write, *color_button_default;
GtkWidget *enable_color, *enable_placeholder, *enable_hidden;
GtkWidget *color_box, *placeholder_box, *hidden_box;
GtkWidget *placeholder_button, *hidden_button;
gchar *string;
const char *color_string;
gchar *old_color_string = NULL;
@@ -2138,24 +2154,31 @@ gnc_account_cascade_color_dialog (GtkWidget *window, Account *account)
g_return_if_fail (gnc_account_n_children (account) > 0);
builder = gtk_builder_new();
gnc_builder_add_from_file (builder, "dialog-account.glade", "account_cascade_color_dialog");
dialog = GTK_WIDGET(gtk_builder_get_object (builder, "account_cascade_color_dialog"));
gnc_builder_add_from_file (builder, "dialog-account.glade", "account_cascade_dialog");
dialog = GTK_WIDGET(gtk_builder_get_object (builder, "account_cascade_dialog"));
gtk_window_set_transient_for (GTK_WINDOW(dialog), GTK_WINDOW(window));
color_label = GTK_WIDGET(gtk_builder_get_object (builder, "color_label"));
// Color section
enable_color = GTK_WIDGET(gtk_builder_get_object (builder, "enable_cascade_color"));
color_box = GTK_WIDGET(gtk_builder_get_object (builder, "color_box"));
label = GTK_WIDGET(gtk_builder_get_object (builder, "color_label"));
over_write = GTK_WIDGET(gtk_builder_get_object (builder, "replace_check"));
color_button = GTK_WIDGET(gtk_builder_get_object (builder, "color_button"));
color_button_default = GTK_WIDGET(gtk_builder_get_object (builder, "color_button_default"));
gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER(color_button), FALSE);
g_signal_connect (G_OBJECT(enable_color), "toggled",
G_CALLBACK(enable_box_cb), (gpointer)color_box);
g_signal_connect (G_OBJECT(color_button_default), "clicked",
G_CALLBACK(default_color_button_cb), (gpointer)color_button);
string = g_strdup_printf(_( "Set the account color for account '%s' "
"including all sub-accounts to the selected color"),
gnc_account_get_full_name(account));
gtk_label_set_text (GTK_LABEL(color_label), string);
string = g_strdup_printf (_( "Set the account color for account '%s' "
"including all sub-accounts to the selected color"),
gnc_account_get_full_name (account));
gtk_label_set_text (GTK_LABEL(label), string);
g_free (string);
color_string = xaccAccountGetColor (account); // get existing account color
@@ -2171,6 +2194,34 @@ gnc_account_cascade_color_dialog (GtkWidget *window, Account *account)
// set the color chooser to account color
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER(color_button), &color);
// Placeholder section
enable_placeholder = GTK_WIDGET(gtk_builder_get_object (builder, "enable_cascade_placeholder"));
placeholder_box = GTK_WIDGET(gtk_builder_get_object (builder, "placeholder_box"));
label = GTK_WIDGET(gtk_builder_get_object (builder, "placeholder_label"));
placeholder_button = GTK_WIDGET(gtk_builder_get_object (builder, "placeholder_check_button"));
g_signal_connect (G_OBJECT(enable_placeholder), "toggled",
G_CALLBACK(enable_box_cb), (gpointer)placeholder_box);
string = g_strdup_printf (_( "Set the account placeholder value for account '%s' "
"including all sub-accounts"),
gnc_account_get_full_name (account));
gtk_label_set_text (GTK_LABEL(label), string);
g_free (string);
// Hidden section
enable_hidden = GTK_WIDGET(gtk_builder_get_object (builder, "enable_cascade_hidden"));
hidden_box = GTK_WIDGET(gtk_builder_get_object (builder, "hidden_box"));
label = GTK_WIDGET(gtk_builder_get_object (builder, "hidden_label"));
hidden_button = GTK_WIDGET(gtk_builder_get_object (builder, "hidden_check_button"));
g_signal_connect (G_OBJECT(enable_hidden), "toggled",
G_CALLBACK(enable_box_cb), (gpointer)hidden_box);
string = g_strdup_printf (_( "Set the account hidden value for account '%s' "
"including all sub-accounts"),
gnc_account_get_full_name (account));
gtk_label_set_text (GTK_LABEL(label), string);
g_free (string);
/* default to cancel */
gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
@@ -2184,31 +2235,56 @@ gnc_account_cascade_color_dialog (GtkWidget *window, Account *account)
if (response == GTK_RESPONSE_OK)
{
GList *accounts = gnc_account_get_descendants (account);
gboolean replace = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(over_write));
GList *acct;
GdkRGBA new_color;
const gchar *new_color_string;
const gchar *new_color_string = NULL;
gboolean color_active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(enable_color));
gboolean placeholder_active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(enable_placeholder));
gboolean hidden_active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(enable_hidden));
gboolean replace = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(over_write));
gboolean placeholder = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(placeholder_button));
gboolean hidden = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(hidden_button));
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER(color_button), &new_color);
new_color_string = gdk_rgba_to_string (&new_color);
// Update Account Colors
if (color_active)
{
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER(color_button), &new_color);
new_color_string = gdk_rgba_to_string (&new_color);
if (g_strcmp0 (new_color_string, DEFAULT_COLOR) == 0)
new_color_string = NULL;
if (g_strcmp0 (new_color_string, DEFAULT_COLOR) == 0)
new_color_string = NULL;
// check/update selected account
update_account_color (account, old_color_string, new_color_string, replace);
// check/update selected account
update_account_color (account, old_color_string, new_color_string, replace);
}
// Update Account Placeholder value
if (placeholder_active)
xaccAccountSetPlaceholder (account, placeholder);
// Update Account Hidden value
if (hidden_active)
xaccAccountSetHidden (account, hidden);
// Update SubAccounts
if (accounts)
{
for (acct = accounts; acct; acct = g_list_next(acct))
for (GList *acct = accounts; acct; acct = g_list_next(acct))
{
const char *string = xaccAccountGetColor (acct->data);
// check/update sub-accounts
update_account_color (acct->data, string, new_color_string, replace);
// Update SubAccount Colors
if (color_active)
{
const char *string = xaccAccountGetColor (acct->data);
update_account_color (acct->data, string, new_color_string, replace);
}
// Update SubAccount PlaceHolder
if (placeholder_active)
xaccAccountSetPlaceholder (acct->data, placeholder);
// Update SubAccount Hidden
if (hidden_active)
xaccAccountSetHidden (acct->data, hidden);
}
g_list_free (accounts);
}
g_list_free (accounts);
}
if (old_color_string)
g_free (old_color_string);

View File

@@ -161,7 +161,7 @@ void gnc_ui_register_account_destroy_callback (void (*cb)(Account *));
void gnc_account_renumber_create_dialog (GtkWidget *window, Account *account);
void gnc_account_cascade_color_dialog (GtkWidget *window, Account *account);
void gnc_account_cascade_properties_dialog (GtkWidget *window, Account *account);
/** @} */
/** @} */

View File

@@ -155,7 +155,7 @@ static void gnc_plugin_page_account_tree_cmd_lots (GtkAction *action, GncPluginP
static void gnc_plugin_page_account_tree_cmd_scrub (GtkAction *action, GncPluginPageAccountTree *page);
static void gnc_plugin_page_account_tree_cmd_scrub_sub (GtkAction *action, GncPluginPageAccountTree *page);
static void gnc_plugin_page_account_tree_cmd_scrub_all (GtkAction *action, GncPluginPageAccountTree *page);
static void gnc_plugin_page_account_tree_cmd_cascade_color_account (GtkAction *action, GncPluginPageAccountTree *page);
static void gnc_plugin_page_account_tree_cmd_cascade_account_properties (GtkAction *action, GncPluginPageAccountTree *page);
/* Command callback for new Register Test */
static void gnc_plugin_page_account_tree_cmd_open2_account (GtkAction *action, GncPluginPageAccountTree *page);
@@ -230,9 +230,9 @@ static GtkActionEntry gnc_plugin_page_account_tree_actions [] =
G_CALLBACK (gnc_plugin_page_account_tree_cmd_delete_account)
},
{
"EditColorCascadeAccountAction", NULL, N_("_Cascade Account Color..."), NULL,
N_("Cascade selected account color"),
G_CALLBACK (gnc_plugin_page_account_tree_cmd_cascade_color_account)
"EditCascadeAccountAction", NULL, N_("_Cascade Account Properties..."), NULL,
N_("Cascade selected properties for account"),
G_CALLBACK (gnc_plugin_page_account_tree_cmd_cascade_account_properties)
},
{
"EditFindAccountAction", "edit-find", N_("F_ind Account"), "<primary>i",
@@ -1072,7 +1072,7 @@ gnc_plugin_page_account_tree_selection_changed_cb (GtkTreeSelection *selection,
g_object_set (G_OBJECT(action), "sensitive",
is_readwrite && sensitive && subaccounts, NULL);
action = gtk_action_group_get_action (action_group, "EditColorCascadeAccountAction");
action = gtk_action_group_get_action (action_group, "EditCascadeAccountAction");
g_object_set (G_OBJECT(action), "sensitive", subaccounts, NULL);
gnc_plugin_update_actions (action_group, actions_requiring_account_rw,
@@ -1190,7 +1190,7 @@ gnc_plugin_page_account_tree_cmd_find_account_popup (GtkAction *action, GncPlugi
}
static void
gnc_plugin_page_account_tree_cmd_cascade_color_account (GtkAction *action, GncPluginPageAccountTree *page)
gnc_plugin_page_account_tree_cmd_cascade_account_properties (GtkAction *action, GncPluginPageAccountTree *page)
{
Account *account = NULL;
GtkWidget *window;
@@ -1199,10 +1199,10 @@ gnc_plugin_page_account_tree_cmd_cascade_color_account (GtkAction *action, GncPl
account = gnc_plugin_page_account_tree_get_current_account (page);
window = gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(page));
window = gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(page));
if (account != NULL)
gnc_account_cascade_color_dialog (window, account);
gnc_account_cascade_properties_dialog (window, account);
LEAVE(" ");
}

View File

@@ -2,9 +2,9 @@
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkDialog" id="account_cascade_color_dialog">
<object class="GtkDialog" id="account_cascade_dialog">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Cascade Account Color</property>
<property name="title" translatable="yes">Cascade Account Values</property>
<property name="type_hint">dialog</property>
<child>
<placeholder/>
@@ -56,33 +56,23 @@
</packing>
</child>
<child>
<object class="GtkBox">
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel" id="color_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="halign">start</property>
<property name="spacing">3</property>
<child>
<object class="GtkColorButton" id="color_button">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Enable Cascading Account Color</property>
</object>
<packing>
<property name="expand">False</property>
@@ -91,11 +81,11 @@
</packing>
</child>
<child>
<object class="GtkButton" id="color_button_default">
<property name="label" translatable="yes">Default</property>
<object class="GtkCheckButton" id="enable_cascade_color">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -105,44 +95,291 @@
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="sub_label">
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">If any account has an existing color it will not be replaced unless the following is ticked.</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="replace_check">
<property name="label" translatable="yes">Replace any existing account colors</property>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">center</property>
<property name="draw_indicator">True</property>
<property name="can_focus">False</property>
<property name="spacing">3</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Enable Cascading Account Placeholder</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="enable_cascade_placeholder">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">6</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">3</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Enable Cascading Account Hidden</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="enable_cascade_hidden">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">7</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Enable the sections to Cascade</property>
<attributes>
<attribute name="underline" value="True"/>
</attributes>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="color_box">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">3</property>
<child>
<object class="GtkLabel" id="color_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="color_button_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<child>
<object class="GtkColorButton" id="color_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="color_button_default">
<property name="label" translatable="yes">Default</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="sub_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">If any account has an existing color it will not be replaced unless the following is ticked.</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="replace_check">
<property name="label" translatable="yes">Replace any existing account colors</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">center</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkBox" id="placeholder_box">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">3</property>
<child>
<object class="GtkLabel" id="placeholder_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="placeholder_check_button">
<property name="label" translatable="yes">Placeholder</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">center</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
<object class="GtkBox" id="hidden_box">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">3</property>
<child>
<object class="GtkLabel" id="hidden_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="hidden_check_button">
<property name="label" translatable="yes">Hidden</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">center</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">8</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">0</property>
</packing>
</child>
</object>

View File

@@ -5,7 +5,7 @@
<menuitem name="EditEditAccount" action="EditEditAccountAction"/>
<menuitem name="EditDeleteAccount" action="EditDeleteAccountAction"/>
<menuitem name="EditAccountFindAccount" action="EditFindAccountAction"/>
<menuitem name="AccountColorCascade" action="EditColorCascadeAccountAction"/>
<menuitem name="AccountCascadeProperty" action="EditCascadeAccountAction"/>
<menuitem name="EditRenumberSubaccounts" action="EditRenumberSubaccountsAction"/>
<separator name="EditSep2"/>
<menuitem name="FileOpenAccount" action="FileOpenAccountAction"/>
@@ -46,7 +46,7 @@
<menuitem name="AccountOpenAccount" action="FileOpenAccountAction"/>
<menuitem name="AccountOpenSubaccounts" action="FileOpenSubaccountsAction"/>
<menuitem name="AccountEditAccount" action="EditEditAccountAction"/>
<menuitem name="AccountColorCascade" action="EditColorCascadeAccountAction"/>
<menuitem name="AccountCascadeProperty" action="EditCascadeAccountAction"/>
<menuitem name="AccountFindAccountPopup" action="EditFindAccountPopupAction"/>
<separator name="AccountSep1"/>
<menuitem name="AccountReconcile" action="ActionsReconcileAction"/>