GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dialog-choose-owner.c
1 /*
2  * dialog-choose-owner.c -- Dialog to choose an owner for a business Split
3  * Copyright (C) 2006 Derek Atkins
4  * Author: Derek Atkins <[email protected]>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, contact:
18  *
19  * Free Software Foundation Voice: +1-617-542-5942
20  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
21  * Boston, MA 02110-1301, USA [email protected]
22  */
23 
24 #include "config.h"
25 
26 #include <gtk/gtk.h>
27 #include <glib/gi18n.h>
28 #include "qof.h"
29 
30 #include "Transaction.h"
31 #include "dialog-utils.h"
32 #include "gncOwner.h"
33 
34 #include "dialog-choose-owner.h"
35 #include "business-gnome-utils.h"
36 
38 {
39  GtkWidget * dialog;
40  GtkWidget * owner_choice;
41  QofBook * book;
42  GncOwner owner;
43  Split * split;
44 };
45 
46 static DialogChooseOwner *
47 gcoi_create_dialog(Split* split)
48 {
49  DialogChooseOwner* dco;
50  GtkBuilder *builder;
51  GtkWidget *widget, *box;
52 
53  g_return_val_if_fail(split, NULL);
54 
55  dco = g_new0(DialogChooseOwner, 1);
56  g_assert(dco);
57  dco->book = qof_instance_get_book(QOF_INSTANCE(split));
58  dco->split = split;
59 
60  /* Open the Glade file */
61  builder = gtk_builder_new();
62  gnc_builder_add_from_file (builder, "dialog-choose-owner.glade", "Choose Owner Dialog");
63  g_assert(builder);
64 
65  /* Get the dialog handle */
66  dco->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Choose Owner Dialog"));
67  g_assert(dco->dialog);
68 
69  /* Get the title widget and set the title */
70  widget = GTK_WIDGET(gtk_builder_get_object (builder, "title_label"));
71  if (1 == 1)
72  {
73  gncOwnerInitCustomer(&(dco->owner), NULL);
74  gtk_label_set_text(GTK_LABEL(widget),
75  _("This transaction needs to be assigned to a Customer."
76  " Please choose the Customer below."));
77  }
78  else
79  {
80  gncOwnerInitVendor(&(dco->owner), NULL);
81  gtk_label_set_text(GTK_LABEL(widget),
82  _("This transaction needs to be assigned to a Vendor."
83  " Please choose the Vendor below."));
84  }
85 
86  /* Get the transaction description and set it */
87  widget = GTK_WIDGET(gtk_builder_get_object (builder, "desc_label"));
88  gtk_label_set_text(GTK_LABEL(widget),
90 
91  /* Get the owner label and the owner box */
92  widget = GTK_WIDGET(gtk_builder_get_object (builder, "owner_label"));
93  box = GTK_WIDGET(gtk_builder_get_object (builder, "owner_box"));
94  dco->owner_choice = gnc_owner_select_create(widget, box, dco->book,
95  &(dco->owner));
96 
97  gtk_widget_show_all(dco->dialog);
98 
99  g_object_unref(G_OBJECT(builder));
100 
101  return dco;
102 }
103 
104 
105 gboolean
106 gnc_split_assign_owner(GtkWidget* window, Split* split)
107 {
108  if (1 == 0)
109  gcoi_create_dialog(split);
110 
111  return FALSE;
112 }
Business Interface: Object OWNERs.
QofBook * qof_instance_get_book(gconstpointer)
Transaction * xaccSplitGetParent(const Split *split)
Definition: Split.c:1903
const char * xaccTransGetDescription(const Transaction *trans)
Definition: Transaction.c:2184
Definition: SplitP.h:71
API for Transactions and Splits (journal entries)