Convert payment dialog to gtkbuilder

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21572 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Geert Janssens 2011-11-17 22:24:03 +00:00
parent f4749ef3ed
commit 0313539a88
5 changed files with 198 additions and 151 deletions

View File

@ -551,6 +551,7 @@ new_payment_window (GncOwner *owner, QofBook *book, GncInvoice *invoice)
{
PaymentWindow *pw;
GladeXML *xml;
GtkBuilder *builder;
GtkWidget *box, *label;
char * cm_class = (gncOwnerGetType (owner) == GNC_OWNER_CUSTOMER ?
DIALOG_PAYMENT_CUSTOMER_CM_CLASS :
@ -588,35 +589,38 @@ new_payment_window (GncOwner *owner, QofBook *book, GncInvoice *invoice)
pw->acct_commodities = gncOwnerGetCommoditiesList (owner);
/* Open and read the XML */
xml = gnc_glade_xml_new ("payment.glade", "Payment Dialog");
pw->dialog = glade_xml_get_widget (xml, "Payment Dialog");
builder = gtk_builder_new();
gnc_builder_add_from_file (builder, "dialog-payment.glade", "post_combo_model");
gnc_builder_add_from_file (builder, "dialog-payment.glade", "Payment Dialog");
pw->dialog = GTK_WIDGET (gtk_builder_get_object (builder, "Payment Dialog"));
/* Grab the widgets and build the dialog */
pw->num_entry = glade_xml_get_widget (xml, "num_entry");
pw->memo_entry = glade_xml_get_widget (xml, "memo_entry");
pw->post_combo = glade_xml_get_widget (xml, "post_combo");
pw->num_entry = GTK_WIDGET (gtk_builder_get_object (builder, "num_entry"));
pw->memo_entry = GTK_WIDGET (gtk_builder_get_object (builder, "memo_entry"));
pw->post_combo = GTK_WIDGET (gtk_builder_get_object (builder, "post_combo"));
gtk_combo_box_entry_set_text_column( GTK_COMBO_BOX_ENTRY( pw->post_combo ), 0 );
gnc_cbe_require_list_item(GTK_COMBO_BOX_ENTRY(pw->post_combo));
label = glade_xml_get_widget (xml, "owner_label");
box = glade_xml_get_widget (xml, "owner_box");
label = GTK_WIDGET (gtk_builder_get_object (builder, "owner_label"));
box = GTK_WIDGET (gtk_builder_get_object (builder, "owner_box"));
pw->owner_choice = gnc_owner_select_create (label, box, book, owner);
label = glade_xml_get_widget (xml, "invoice_label");
box = glade_xml_get_widget (xml, "invoice_box");
label = GTK_WIDGET (gtk_builder_get_object (builder, "invoice_label"));
box = GTK_WIDGET (gtk_builder_get_object (builder, "invoice_box"));
pw->invoice_choice = gnc_invoice_select_create (box, book, owner, invoice, label);
box = glade_xml_get_widget (xml, "amount_box");
box = GTK_WIDGET (gtk_builder_get_object (builder, "amount_box"));
pw->amount_edit = gnc_amount_edit_new ();
gtk_box_pack_start (GTK_BOX (box), pw->amount_edit, TRUE, TRUE, 0);
gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (pw->amount_edit),
TRUE);
gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (pw->amount_edit), gnc_numeric_zero());
box = glade_xml_get_widget (xml, "date_box");
box = GTK_WIDGET (gtk_builder_get_object (builder, "date_box"));
pw->date_edit = gnc_date_edit_new (time(NULL), FALSE, FALSE);
gtk_box_pack_start (GTK_BOX (box), pw->date_edit, TRUE, TRUE, 0);
box = glade_xml_get_widget (xml, "acct_window");
box = GTK_WIDGET (gtk_builder_get_object (builder, "acct_window"));
pw->acct_tree = GTK_WIDGET(gnc_tree_view_account_new (FALSE));
gtk_container_add (GTK_CONTAINER (box), pw->acct_tree);
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(pw->acct_tree), FALSE);
@ -630,8 +634,8 @@ new_payment_window (GncOwner *owner, QofBook *book, GncInvoice *invoice)
gnc_payment_dialog_invoice_changed(pw);
/* Setup signals */
glade_xml_signal_autoconnect_full( xml,
gnc_glade_autoconnect_full_func,
gtk_builder_connect_signals_full( builder,
gnc_builder_connect_full_func,
pw);
g_signal_connect (G_OBJECT (pw->owner_choice), "changed",
@ -672,6 +676,7 @@ new_payment_window (GncOwner *owner, QofBook *book, GncInvoice *invoice)
/* Show it all */
gtk_widget_show_all (pw->dialog);
g_object_unref(G_OBJECT(builder));
/* Warn the user if they have no valid post-to accounts */
{

View File

@ -5,8 +5,7 @@ glade_DATA = \
date-close.glade \
employee.glade \
job.glade \
order.glade \
payment.glade
order.glade
EXTRA_DIST = \
${glade_DATA}

View File

@ -4,14 +4,14 @@ gtkbuilder_DATA = \
business-prefs.glade \
dialog-customer.glade \
dialog-invoice.glade \
dialog-payment.glade \
dialog-vendor.glade
# billterms.glade \
# choose-owner.glade \
# date-close.glade \
# employee.glade \
# job.glade \
# order.glade \
# payment.glade
# order.glade
EXTRA_DIST = \
${gtkbuilder_DATA}

View File

@ -1,45 +1,97 @@
<?xml version="1.0"?>
<glade-interface>
<!-- interface-requires gtk+ 2.10 -->
<!-- interface-naming-policy toplevel-contextual -->
<widget class="GtkDialog" id="Payment Dialog">
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="2.18"/>
<object class="GtkDialog" id="Payment Dialog">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="type_hint">dialog</property>
<signal name="destroy" handler="gnc_payment_window_destroy_cb"/>
<signal name="destroy" handler="gnc_payment_window_destroy_cb" swapped="no"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
<object class="GtkBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">8</property>
<child>
<widget class="GtkHBox" id="hlayoutbox">
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="cancelbutton">
<property name="label">gtk-cancel</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_action_appearance">False</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="gnc_payment_cancel_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="okbutton">
<property name="label">gtk-ok</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_action_appearance">False</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="gnc_payment_ok_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hlayoutbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">3</property>
<child>
<widget class="GtkVBox" id="vbox1">
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="can_focus">False</property>
<child>
<widget class="GtkFrame" id="frame1">
<object class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<child>
<widget class="GtkHBox" id="hbox1">
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<widget class="GtkVBox" id="vbox2">
<object class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">3</property>
<property name="orientation">vertical</property>
<property name="homogeneous">True</property>
<child>
<widget class="GtkLabel" id="owner_label">
<object class="GtkLabel" id="owner_label">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The company associated with this payment.</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">The company associated with this payment.</property>
<property name="xalign">1</property>
<property name="label">(owner)</property>
<property name="justify">right</property>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
@ -47,15 +99,16 @@
</packing>
</child>
<child>
<widget class="GtkLabel" id="invoice_label">
<object class="GtkLabel" id="invoice_label">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The invoice being paid.
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">The invoice being paid.
Note that is field is optional. If you leave it blank, GnuCash will automatically assign the payment to the first unpaid invoice for this company.</property>
<property name="xalign">1</property>
<property name="label">(invoice)</property>
<property name="justify">right</property>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
@ -63,12 +116,13 @@ Note that is field is optional. If you leave it blank, GnuCash will automaticall
</packing>
</child>
<child>
<widget class="GtkLabel" id="date_label">
<object class="GtkLabel" id="date_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Date</property>
<property name="justify">right</property>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
@ -76,9 +130,10 @@ Note that is field is optional. If you leave it blank, GnuCash will automaticall
</packing>
</child>
<child>
<widget class="GtkLabel" id="amount_label">
<object class="GtkLabel" id="amount_label">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The amount to pay for this invoice.
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">The amount to pay for this invoice.
If you have selected an invoice, GnuCash will propose the amount still due for it. You can change this amount to create a partial payment or an over-payment.
@ -86,7 +141,7 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic
<property name="xalign">1</property>
<property name="label" translatable="yes">Amount</property>
<property name="justify">right</property>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
@ -94,12 +149,13 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic
</packing>
</child>
<child>
<widget class="GtkLabel" id="num_label">
<object class="GtkLabel" id="num_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Num</property>
<property name="justify">right</property>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
@ -107,63 +163,72 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic
</packing>
</child>
<child>
<widget class="GtkLabel" id="memo_label">
<object class="GtkLabel" id="memo_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Memo</property>
<property name="justify">right</property>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">5</property>
</packing>
</child>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox3">
<object class="GtkVBox" id="vbox3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">3</property>
<property name="orientation">vertical</property>
<property name="homogeneous">True</property>
<child>
<widget class="GtkHBox" id="owner_box">
<object class="GtkHBox" id="owner_box">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The company associated with this payment.</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">The company associated with this payment.</property>
<child>
<placeholder/>
</child>
</widget>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="invoice_box">
<object class="GtkHBox" id="invoice_box">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The invoice being paid.
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">The invoice being paid.
Note that is field is optional. If you leave it blank, GnuCash will automatically assign the payment to the first unpaid invoice for this company.</property>
<child>
<placeholder/>
</child>
</widget>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="date_box">
<object class="GtkHBox" id="date_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
@ -171,9 +236,10 @@ Note that is field is optional. If you leave it blank, GnuCash will automaticall
</packing>
</child>
<child>
<widget class="GtkHBox" id="amount_box">
<object class="GtkHBox" id="amount_box">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The amount to pay for this invoice.
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">The amount to pay for this invoice.
If you have selected an invoice, GnuCash will propose the amount still due for it. You can change this amount to create a partial payment or an over-payment.
@ -181,16 +247,18 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic
<child>
<placeholder/>
</child>
</widget>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="num_entry">
<object class="GtkEntry" id="num_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
@ -198,33 +266,33 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic
</packing>
</child>
<child>
<widget class="GtkEntry" id="memo_entry">
<object class="GtkEntry" id="memo_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">5</property>
</packing>
</child>
</widget>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</widget>
</object>
</child>
<child>
<widget class="GtkLabel" id="label1">
<child type="label">
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Payment Information</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</object>
</child>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
@ -232,118 +300,93 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame2">
<object class="GtkFrame" id="frame4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<widget class="GtkComboBoxEntry" id="post_combo">
<object class="GtkComboBoxEntry" id="post_combo">
<property name="visible">True</property>
<property name="items">Dummy Entry</property>
</widget>
<property name="can_focus">False</property>
<property name="model">post_combo_model</property>
</object>
</child>
<child>
<widget class="GtkLabel" id="label6">
<child type="label">
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Post To</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
<property name="use_markup">True</property>
</object>
</child>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</widget>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame3">
<object class="GtkFrame" id="frame3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<child>
<widget class="GtkScrolledWindow" id="acct_window">
<object class="GtkScrolledWindow" id="acct_window">
<property name="width_request">250</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">3</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<child>
<placeholder/>
</child>
</widget>
</object>
</child>
<child>
<widget class="GtkLabel" id="label7">
<child type="label">
<object class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Transfer Account</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</object>
</child>
</widget>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area1">
<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>
<signal name="clicked" handler="gnc_payment_cancel_cb"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="okbutton">
<property name="label">gtk-ok</property>
<property name="response_id">-5</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>
<signal name="clicked" handler="gnc_payment_ok_cb"/>
</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>
</object>
</child>
</widget>
</glade-interface>
<action-widgets>
<action-widget response="-6">cancelbutton</action-widget>
<action-widget response="-5">okbutton</action-widget>
</action-widgets>
</object>
<object class="GtkListStore" id="post_combo_model">
<columns>
<!-- column-name gchararray -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0">Dummy Entry</col>
</row>
</data>
</object>
</interface>

View File

@ -213,7 +213,7 @@ gnc_cbe_require_list_item (GtkComboBoxEntry *cbe)
g_object_set_data(G_OBJECT(cbe), LAST_INDEX, GINT_TO_POINTER(index));
/* Now the signals to make sure the user can't leave the
widget without a valid currency. */
widget without a valid match. */
id = g_signal_connect(cbe, "changed",
G_CALLBACK(gnc_cbe_changed_cb), cbe);
g_signal_connect(completion, "match_selected",