Convert "Delete Account" dialog to gtkbuilder.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20661 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Geert Janssens 2011-05-19 17:22:49 +00:00
parent 78ff087594
commit fb2e4af923
3 changed files with 153 additions and 515 deletions

View File

@ -2,431 +2,6 @@
<glade-interface> <glade-interface>
<!-- interface-requires gtk+ 2.10 --> <!-- interface-requires gtk+ 2.10 -->
<!-- interface-naming-policy toplevel-contextual --> <!-- interface-naming-policy toplevel-contextual -->
<widget class="GtkDialog" id="Delete Account">
<property name="border_width">6</property>
<property name="title" translatable="yes">Delete Account</property>
<property name="modal">True</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="vbox126">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<widget class="GtkVBox" id="vbox127">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<widget class="GtkLabel" id="header">
<property name="visible">True</property>
<property name="label">Deleting account xxx</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="transactions">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<widget class="GtkLabel" id="label8477423">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Transactions&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment8">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkTable" id="table8">
<property name="visible">True</property>
<property name="n_rows">4</property>
<property name="n_columns">2</property>
<property name="column_spacing">12</property>
<child>
<widget class="Custom" id="tmas">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="creation_function">gnc_account_sel_new</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="tmrb">
<property name="label" translatable="yes">M_ove to:</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="tdrb">
<property name="label" translatable="yes">Delete all _transactions</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<property name="group">tmrb</property>
<signal name="toggled" handler="gppat_set_insensitive_iff_rb_active" object="tmas"/>
</widget>
<packing>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="trans_rw">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">This account contains transactions. What would you like to do with these transactions?</property>
<property name="wrap">True</property>
</widget>
<packing>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="trans_ro">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">This account contains read-only transactions which may not be deleted.</property>
<property name="wrap">True</property>
</widget>
<packing>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="subaccounts">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<widget class="GtkLabel" id="label8477419">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Sub-accounts&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment7">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkTable" id="table7">
<property name="visible">True</property>
<property name="n_rows">3</property>
<property name="n_columns">2</property>
<property name="column_spacing">12</property>
<child>
<widget class="GtkLabel" id="label8477420">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">This account contains sub-accounts. What would you like to do with these sub-accounts?</property>
<property name="wrap">True</property>
</widget>
<packing>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="damrb">
<property name="label" translatable="yes">_Move to:</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="gppat_set_insensitive_iff_rb_active" object="subaccount_trans"/>
<signal name="toggled" handler="gppat_populate_tmas_list" object="tmas"/>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="dadrb">
<property name="label" translatable="yes">Delete all _subaccounts</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<property name="group">damrb</property>
<signal name="toggled" handler="gppat_set_insensitive_iff_rb_active" object="damas"/>
</widget>
<packing>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="Custom" id="damas">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="creation_function">gnc_account_sel_new</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="subaccount_trans">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="orientation">vertical</property>
<child>
<widget class="GtkLabel" id="label8477429">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Sub-account Transactions&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment9">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkTable" id="table9">
<property name="visible">True</property>
<property name="n_rows">4</property>
<property name="n_columns">2</property>
<property name="column_spacing">12</property>
<child>
<widget class="Custom" id="dtmas">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="creation_function">gnc_account_sel_new</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="dtmrb">
<property name="label" translatable="yes">M_ove to:</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="dtdrb">
<property name="label" translatable="yes">Delete all _transactions</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<property name="group">dtmrb</property>
<signal name="toggled" handler="gppat_set_insensitive_iff_rb_active" object="dtmas"/>
</widget>
<packing>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="sa_trans_rw">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">One or more sub-accounts contain transactions. What would you like to do with these transactions?</property>
<property name="wrap">True</property>
</widget>
<packing>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="sa_trans_ro">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">One or more sub-accounts contain read-only transactions which may not be deleted.</property>
<property name="wrap">True</property>
</widget>
<packing>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="hbuttonbox2">
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
<widget class="GtkButton" id="cancelbutton">
<property name="label">gtk-cancel</property>
<property name="response_id">-6</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="deletebutton">
<property name="label">gtk-delete</property>
<property name="response_id">-3</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class="GtkDialog" id="Filter By"> <widget class="GtkDialog" id="Filter By">
<property name="visible">True</property> <property name="visible">True</property>
<property name="border_width">6</property> <property name="border_width">6</property>

View File

@ -74,6 +74,10 @@ static QofLogModule log_module = GNC_MOD_GUI;
#define DELETE_DIALOG_FILTER "filter" #define DELETE_DIALOG_FILTER "filter"
#define DELETE_DIALOG_ACCOUNT "account" #define DELETE_DIALOG_ACCOUNT "account"
#define DELETE_DIALOG_TRANS_MAS "trans_mas"
#define DELETE_DIALOG_SA_MAS "sa_mas"
#define DELETE_DIALOG_SA_TRANS_MAS "sa_trans_mas"
#define DELETE_DIALOG_OK_BUTTON "deletebutton"
enum enum
{ {
@ -120,8 +124,8 @@ static void gnc_plugin_page_account_tree_double_click_cb (GtkTreeView *tr
static void gnc_plugin_page_account_tree_selection_changed_cb (GtkTreeSelection *selection, static void gnc_plugin_page_account_tree_selection_changed_cb (GtkTreeSelection *selection,
GncPluginPageAccountTree *page); GncPluginPageAccountTree *page);
void gppat_populate_tmas_list(GtkToggleButton *dmrb, gpointer tmas); void gppat_populate_trans_mas_list(GtkToggleButton *sa_mrb, GtkWidget *dialog);
void gppat_set_insensitive_iff_rb_active(GtkToggleButton *b, GtkWidget *widget); void gppat_set_insensitive_iff_rb_active(GtkWidget *widget, GtkToggleButton *b);
/* Command callbacks */ /* Command callbacks */
static void gnc_plugin_page_account_tree_cmd_new_account (GtkAction *action, GncPluginPageAccountTree *plugin_page); static void gnc_plugin_page_account_tree_cmd_new_account (GtkAction *action, GncPluginPageAccountTree *plugin_page);
@ -875,21 +879,21 @@ static void
set_ok_sensitivity(GtkWidget *dialog) set_ok_sensitivity(GtkWidget *dialog)
{ {
GtkWidget *button; GtkWidget *button;
gpointer dmas, tmas; GtkWidget *sa_mas, *trans_mas;
gint dmas_cnt, tmas_cnt; gint sa_mas_cnt, trans_mas_cnt;
gboolean sensitive; gboolean sensitive;
dmas = g_object_get_data(G_OBJECT(dialog), "dmas"); sa_mas = g_object_get_data(G_OBJECT(dialog), DELETE_DIALOG_SA_MAS);
tmas = g_object_get_data(G_OBJECT(dialog), "tmas"); trans_mas = g_object_get_data(G_OBJECT(dialog), DELETE_DIALOG_TRANS_MAS);
dmas_cnt = gnc_account_sel_get_num_account(GNC_ACCOUNT_SEL(dmas)); sa_mas_cnt = gnc_account_sel_get_num_account(GNC_ACCOUNT_SEL(sa_mas));
tmas_cnt = gnc_account_sel_get_num_account(GNC_ACCOUNT_SEL(tmas)); trans_mas_cnt = gnc_account_sel_get_num_account(GNC_ACCOUNT_SEL(trans_mas));
sensitive = (((NULL == dmas) || sensitive = (((NULL == sa_mas) ||
(!GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(dmas)) || dmas_cnt)) && (!GTK_WIDGET_IS_SENSITIVE(sa_mas) || sa_mas_cnt)) &&
((NULL == tmas) || ((NULL == trans_mas) ||
(!GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(tmas)) || tmas_cnt))); (!GTK_WIDGET_IS_SENSITIVE(trans_mas) || trans_mas_cnt)));
button = gnc_glade_lookup_widget(dialog, "deletebutton"); button = g_object_get_data(G_OBJECT(dialog), DELETE_DIALOG_OK_BUTTON);
gtk_widget_set_sensitive(button, sensitive); gtk_widget_set_sensitive(button, sensitive);
} }
@ -914,22 +918,29 @@ gppat_populate_gas_list(GtkWidget *dialog,
gnc_account_sel_purge_account( gas, account, exclude_subaccounts); gnc_account_sel_purge_account( gas, account, exclude_subaccounts);
/* The sensitivity of the OK button needs to be reevaluated. */ /* The sensitivity of the OK button needs to be reevaluated. */
set_ok_sensitivity(GTK_WIDGET(dialog)); set_ok_sensitivity(dialog);
} }
void void
gppat_populate_tmas_list(GtkToggleButton *damrb, gppat_populate_trans_mas_list(GtkToggleButton *sa_mrb,
gpointer tmas) GtkWidget *dialog)
{ {
GtkWidget *dialog; GtkWidget *trans_mas;
g_return_if_fail(GTK_IS_DIALOG(dialog));
/* Cannot move transactions to subaccounts if they are to be deleted. */ /* Cannot move transactions to subaccounts if they are to be deleted. */
dialog = gnc_glade_lookup_widget(GTK_WIDGET(damrb), "Delete Account"); trans_mas = g_object_get_data(G_OBJECT(dialog), DELETE_DIALOG_TRANS_MAS);
gppat_populate_gas_list(dialog, tmas, !gtk_toggle_button_get_active(damrb)); gppat_populate_gas_list(dialog, GNC_ACCOUNT_SEL(trans_mas), !gtk_toggle_button_get_active(sa_mrb));
} }
/* Note that the emitting object (the toggle button) and the signal data
* are swapped in below callback function. This is a gtkbuilder feature:
* it swaps if you explicitly set an object for a signal handler in the
* gtkbuilder xml file.
*/
void void
gppat_set_insensitive_iff_rb_active(GtkToggleButton *b, GtkWidget *widget) gppat_set_insensitive_iff_rb_active(GtkWidget *widget, GtkToggleButton *b)
{ {
gtk_widget_set_sensitive(widget, !gtk_toggle_button_get_active(b)); gtk_widget_set_sensitive(widget, !gtk_toggle_button_get_active(b));
set_ok_sensitivity(gtk_widget_get_toplevel(widget)); set_ok_sensitivity(gtk_widget_get_toplevel(widget));
@ -940,19 +951,17 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
{ {
Account *account = gnc_plugin_page_account_tree_get_current_account (page); Account *account = gnc_plugin_page_account_tree_get_current_account (page);
gchar *acct_name; gchar *acct_name;
GList *splits;
delete_helper_t delete_res = { FALSE, FALSE }; delete_helper_t delete_res = { FALSE, FALSE };
GtkWidget *widget;
GtkWidget *window; GtkWidget *window;
GtkWidget *dialog = NULL; GtkWidget *trans_mas = NULL; /* transaction move to account selector */
GNCAccountSel *damas = NULL; /* descendant account move account selector */ GtkWidget *sa_mas = NULL; /* subaccount move to account selector */
GNCAccountSel *dtmas = NULL; /* descendant transaction move account selector */ GtkWidget *sa_trans_mas = NULL; /* subaccount's transaction move to account selector */
GNCAccountSel *tmas = NULL; /* transaction move account selector */
gint response;
Account *ta = NULL; /* transaction adopter */ Account *ta = NULL; /* transaction adopter */
Account *daa = NULL; /* descendant account adopter */ Account *saa = NULL; /* subaccount adopter */
Account *dta = NULL; /* descendant transaction adopter */ Account *sta = NULL; /* subaccount transaction adopter */
GList *splits;
GList* list; GList* list;
gint response;
if (NULL == account) if (NULL == account)
return; return;
@ -984,20 +993,26 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
*/ */
if ((NULL != splits) || (gnc_account_n_children(account) > 0)) if ((NULL != splits) || (gnc_account_n_children(account) > 0))
{ {
GList *filter; GList *filter = NULL;
GladeXML *xml; GtkBuilder *builder = NULL;
GtkWidget *label; GtkWidget *dialog = NULL;
gchar *message; GtkWidget *box = NULL;
GtkWidget *widget = NULL;
gchar *title = NULL;
xml = gnc_glade_xml_new ("account.glade", "Delete Account"); builder = gtk_builder_new();
dialog = glade_xml_get_widget (xml, "Delete Account"); gnc_builder_add_from_file (builder, "account.glade", "Delete Account");
dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Delete Account"));
gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(window)); gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(window));
glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func, dialog);
label = glade_xml_get_widget (xml, "header"); widget = GTK_WIDGET(gtk_builder_get_object (builder, "header"));
message = g_strdup_printf(_("Deleting account %s"), acct_name); title = g_strdup_printf(_("Deleting account %s"), acct_name);
gtk_label_set_text(GTK_LABEL(label), message); gtk_label_set_text(GTK_LABEL(widget), title);
g_free(message); g_free(title);
widget = GTK_WIDGET(gtk_builder_get_object (builder, DELETE_DIALOG_OK_BUTTON));
g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_OK_BUTTON, widget);
/* /*
* Reparent only to accounts of the same * Reparent only to accounts of the same
@ -1015,24 +1030,27 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
{ {
delete_helper_t delete_res2 = { FALSE, FALSE }; delete_helper_t delete_res2 = { FALSE, FALSE };
tmas = GNC_ACCOUNT_SEL(glade_xml_get_widget (xml, "tmas")); trans_mas = gnc_account_sel_new();
gppat_populate_gas_list(dialog, tmas, FALSE); box = GTK_WIDGET(gtk_builder_get_object (builder, "trans_mas_hbox"));
gtk_box_pack_start (GTK_BOX(box), trans_mas, TRUE, TRUE, 0);
g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_TRANS_MAS, trans_mas);
gppat_populate_gas_list(dialog, GNC_ACCOUNT_SEL(trans_mas), FALSE);
delete_account_helper(account, &delete_res2); delete_account_helper(account, &delete_res2);
if (delete_res2.has_ro_splits) if (delete_res2.has_ro_splits)
{ {
gtk_widget_destroy(glade_xml_get_widget (xml, "trans_rw")); gtk_widget_destroy(GTK_WIDGET(gtk_builder_get_object (builder, "trans_rw")));
widget = glade_xml_get_widget (xml, "tdrb"); widget = GTK_WIDGET(gtk_builder_get_object (builder, "trans_drb"));
gtk_widget_set_sensitive(widget, FALSE); gtk_widget_set_sensitive(widget, FALSE);
} }
else else
{ {
gtk_widget_destroy(glade_xml_get_widget (xml, "trans_ro")); gtk_widget_destroy(GTK_WIDGET(gtk_builder_get_object (builder, "trans_ro")));
} }
} }
else else
{ {
gtk_widget_destroy(glade_xml_get_widget (xml, "transactions")); gtk_widget_destroy(GTK_WIDGET(gtk_builder_get_object (builder, "transactions")));
} }
/* /*
@ -1047,32 +1065,43 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
&delete_res); &delete_res);
if (delete_res.has_ro_splits) if (delete_res.has_ro_splits)
{ {
gtk_widget_destroy(glade_xml_get_widget (xml, "sa_trans_rw")); gtk_widget_destroy(GTK_WIDGET(gtk_builder_get_object (builder, "sa_trans_rw")));
widget = glade_xml_get_widget (xml, "dtdrb"); widget = GTK_WIDGET(gtk_builder_get_object (builder, "sa_trans_drb"));
gtk_widget_set_sensitive(widget, FALSE); gtk_widget_set_sensitive(widget, FALSE);
} }
else if (delete_res.has_splits) else if (delete_res.has_splits)
{ {
gtk_widget_destroy(glade_xml_get_widget (xml, "sa_trans_ro")); gtk_widget_destroy(GTK_WIDGET(gtk_builder_get_object (builder, "sa_trans_ro")));
} }
else else
{ {
gtk_widget_destroy(glade_xml_get_widget (xml, "subaccount_trans")); gtk_widget_destroy(GTK_WIDGET(gtk_builder_get_object (builder, "subaccount_trans")));
} }
damas = GNC_ACCOUNT_SEL(glade_xml_get_widget (xml, "damas"));
gppat_populate_gas_list(dialog, damas, TRUE); sa_mas = gnc_account_sel_new();
dtmas = GNC_ACCOUNT_SEL(glade_xml_get_widget (xml, "dtmas")); box = GTK_WIDGET(gtk_builder_get_object (builder, "sa_mas_hbox"));
gppat_populate_gas_list(dialog, dtmas, TRUE); gtk_box_pack_start (GTK_BOX(box), sa_mas, TRUE, TRUE, 0);
g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_SA_MAS, sa_mas);
gppat_populate_gas_list(dialog, GNC_ACCOUNT_SEL(sa_mas), TRUE);
sa_trans_mas = gnc_account_sel_new();
box = GTK_WIDGET(gtk_builder_get_object (builder, "sa_trans_mas_hbox"));
gtk_box_pack_start (GTK_BOX(box), sa_trans_mas, TRUE, TRUE, 0);
g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_SA_TRANS_MAS, sa_trans_mas);
gppat_populate_gas_list(dialog, GNC_ACCOUNT_SEL(sa_trans_mas), TRUE);
} }
else else
{ {
gtk_widget_destroy(glade_xml_get_widget (xml, "subaccounts")); gtk_widget_destroy(GTK_WIDGET(gtk_builder_get_object (builder, "subaccounts")));
gtk_widget_destroy(glade_xml_get_widget (xml, "subaccount_trans")); gtk_widget_destroy(GTK_WIDGET(gtk_builder_get_object (builder, "subaccount_trans")));
} }
/* default to cancel */ /* default to cancel */
gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL); gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
gtk_builder_connect_signals(builder, dialog);
g_object_unref(G_OBJECT(builder));
/* /*
* Note that one effect of the modal dialog is preventing * Note that one effect of the modal dialog is preventing
* the account selectors from being repopulated. * the account selectors from being repopulated.
@ -1087,12 +1116,12 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
g_free(acct_name); g_free(acct_name);
return; return;
} }
if (tmas && GTK_WIDGET_IS_SENSITIVE(tmas)) if (trans_mas && GTK_WIDGET_IS_SENSITIVE(trans_mas))
ta = gnc_account_sel_get_account(tmas); ta = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(trans_mas));
if (damas && GTK_WIDGET_IS_SENSITIVE(damas)) if (sa_mas && GTK_WIDGET_IS_SENSITIVE(sa_mas))
daa = gnc_account_sel_get_account(damas); saa = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(sa_mas));
if (dtmas && GTK_WIDGET_IS_SENSITIVE(dtmas)) if (sa_trans_mas && GTK_WIDGET_IS_SENSITIVE(sa_trans_mas))
dta = gnc_account_sel_get_account(dtmas); sta = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(sa_trans_mas));
gtk_widget_destroy(dialog); gtk_widget_destroy(dialog);
g_list_free(filter); g_list_free(filter);
} /* (NULL != splits) || (NULL != children) */ } /* (NULL != splits) || (NULL != children) */
@ -1107,6 +1136,7 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
char *message; char *message;
char *name; char *name;
int i = 0; int i = 0;
GtkWidget *dialog;
lines[0] = g_strdup_printf(format, acct_name); lines[0] = g_strdup_printf(format, acct_name);
if (splits) if (splits)
@ -1126,9 +1156,9 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
} }
if (gnc_account_n_children(account) > 0) if (gnc_account_n_children(account) > 0)
{ {
if (daa) if (saa)
{ {
name = gnc_account_get_full_name(daa); name = gnc_account_get_full_name(saa);
format = _("All of its sub-accounts will be moved to " format = _("All of its sub-accounts will be moved to "
"the account %s."); "the account %s.");
lines[++i] = g_strdup_printf(format, name); lines[++i] = g_strdup_printf(format, name);
@ -1137,9 +1167,9 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
{ {
format = _("All of its subaccounts will be deleted."); format = _("All of its subaccounts will be deleted.");
lines[++i] = g_strdup_printf("%s", format); lines[++i] = g_strdup_printf("%s", format);
if (dta) if (sta)
{ {
name = gnc_account_get_full_name(dta); name = gnc_account_get_full_name(sta);
format = _("All sub-account transactions will be moved to " format = _("All sub-account transactions will be moved to "
"the account %s."); "the account %s.");
lines[++i] = g_strdup_printf(format, name); lines[++i] = g_strdup_printf(format, name);
@ -1179,23 +1209,23 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
gnc_set_busy_cursor(NULL, TRUE); gnc_set_busy_cursor(NULL, TRUE);
gnc_suspend_gui_refresh (); gnc_suspend_gui_refresh ();
xaccAccountBeginEdit (account); xaccAccountBeginEdit (account);
if (NULL != daa) if (NULL != saa)
{ {
GList *acct_list, *ptr; GList *acct_list, *ptr;
xaccAccountBeginEdit (daa); xaccAccountBeginEdit (saa);
acct_list = gnc_account_get_children(account); acct_list = gnc_account_get_children(account);
for (ptr = acct_list; ptr; ptr = g_list_next(ptr)) for (ptr = acct_list; ptr; ptr = g_list_next(ptr))
gnc_account_append_child (daa, ptr->data); gnc_account_append_child (saa, ptr->data);
g_list_free(acct_list); g_list_free(acct_list);
xaccAccountCommitEdit (daa); xaccAccountCommitEdit (saa);
} }
else if (NULL != dta) else if (NULL != sta)
{ {
/* Move the splits of its subaccounts, if any. */ /* Move the splits of its subaccounts, if any. */
gnc_account_foreach_descendant(account, gnc_account_foreach_descendant(account,
(AccountCb)xaccAccountMoveAllSplits, (AccountCb)xaccAccountMoveAllSplits,
dta); sta);
} }
if (NULL != ta) if (NULL != ta)
{ {

View File

@ -901,7 +901,7 @@
<property name="n_columns">2</property> <property name="n_columns">2</property>
<property name="column_spacing">12</property> <property name="column_spacing">12</property>
<child> <child>
<object class="GtkRadioButton" id="tmrb"> <object class="GtkRadioButton" id="trans_mrb">
<property name="label" translatable="yes">M_ove to:</property> <property name="label" translatable="yes">M_ove to:</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
@ -918,15 +918,15 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkRadioButton" id="tdrb"> <object class="GtkRadioButton" id="trans_drb">
<property name="label" translatable="yes">Delete all _transactions</property> <property name="label" translatable="yes">Delete all _transactions</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">False</property> <property name="receives_default">False</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
<property name="group">tmrb</property> <property name="group">trans_mrb</property>
<signal name="toggled" handler="gppat_set_insensitive_iff_rb_active" object="tmas"/> <signal name="toggled" handler="gppat_set_insensitive_iff_rb_active" object="trans_mas_hbox"/>
</object> </object>
<packing> <packing>
<property name="right_attach">2</property> <property name="right_attach">2</property>
@ -964,10 +964,21 @@
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkHBox" id="trans_mas_hbox">
<property name="visible">True</property>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>
</object> </object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
</object>
</child> </child>
</object> </object>
<packing> <packing>
@ -1022,7 +1033,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkRadioButton" id="damrb"> <object class="GtkRadioButton" id="sa_mrb">
<property name="label" translatable="yes">_Move to:</property> <property name="label" translatable="yes">_Move to:</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
@ -1031,7 +1042,7 @@
<property name="active">True</property> <property name="active">True</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
<signal name="toggled" handler="gppat_set_insensitive_iff_rb_active" object="subaccount_trans"/> <signal name="toggled" handler="gppat_set_insensitive_iff_rb_active" object="subaccount_trans"/>
<signal name="toggled" handler="gppat_populate_tmas_list" object="tmas"/> <signal name="toggled" handler="gppat_populate_trans_mas_list"/>
</object> </object>
<packing> <packing>
<property name="top_attach">2</property> <property name="top_attach">2</property>
@ -1041,15 +1052,15 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkRadioButton" id="dadrb"> <object class="GtkRadioButton" id="sa_drb">
<property name="label" translatable="yes">Delete all _subaccounts</property> <property name="label" translatable="yes">Delete all _subaccounts</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">False</property> <property name="receives_default">False</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
<property name="group">damrb</property> <property name="group">sa_mrb</property>
<signal name="toggled" handler="gppat_set_insensitive_iff_rb_active" object="damas"/> <signal name="toggled" handler="gppat_set_insensitive_iff_rb_active" object="sa_mas_hbox"/>
</object> </object>
<packing> <packing>
<property name="right_attach">2</property> <property name="right_attach">2</property>
@ -1059,10 +1070,21 @@
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkHBox" id="sa_mas_hbox">
<property name="visible">True</property>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>
</object> </object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
</object>
</child> </child>
</object> </object>
<packing> <packing>
@ -1107,7 +1129,7 @@
<property name="n_columns">2</property> <property name="n_columns">2</property>
<property name="column_spacing">12</property> <property name="column_spacing">12</property>
<child> <child>
<object class="GtkRadioButton" id="dtmrb"> <object class="GtkRadioButton" id="sa_trans_mrb">
<property name="label" translatable="yes">M_ove to:</property> <property name="label" translatable="yes">M_ove to:</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
@ -1124,15 +1146,15 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkRadioButton" id="dtdrb"> <object class="GtkRadioButton" id="sa_trans_drb">
<property name="label" translatable="yes">Delete all _transactions</property> <property name="label" translatable="yes">Delete all _transactions</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">False</property> <property name="receives_default">False</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
<property name="group">dtmrb</property> <property name="group">sa_trans_mrb</property>
<signal name="toggled" handler="gppat_set_insensitive_iff_rb_active" object="dtmas"/> <signal name="toggled" handler="gppat_set_insensitive_iff_rb_active" object="sa_trans_mas_hbox"/>
</object> </object>
<packing> <packing>
<property name="right_attach">2</property> <property name="right_attach">2</property>
@ -1170,10 +1192,21 @@
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkHBox" id="sa_trans_mas_hbox">
<property name="visible">True</property>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>
</object> </object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
</object>
</child> </child>
</object> </object>
<packing> <packing>