dialog-choose-owner.c

00001 /*
00002  * dialog-choose-owner.c -- Dialog to choose an owner for a business Split
00003  * Copyright (C) 2006 Derek Atkins
00004  * Author: Derek Atkins <warlord@MIT.EDU>
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License as
00008  * published by the Free Software Foundation; either version 2 of
00009  * the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, contact:
00018  *
00019  * Free Software Foundation           Voice:  +1-617-542-5942
00020  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
00021  * Boston, MA  02110-1301,  USA       gnu@gnu.org
00022  */
00023 
00024 #include "config.h"
00025 
00026 #include <gtk/gtk.h>
00027 #include <glib/gi18n.h>
00028 #include <qof.h>
00029 
00030 #include "Transaction.h"
00031 #include "dialog-utils.h"
00032 #include "gncOwner.h"
00033 
00034 #include "dialog-choose-owner.h"
00035 #include "business-gnome-utils.h"
00036 
00037 struct _choose_owner_dialog {
00038   GtkWidget *   dialog;
00039   GtkWidget *   owner_choice;
00040   QofBook *     book;
00041   GncOwner      owner;
00042   Split *       split;
00043 };
00044 
00045 static DialogChooseOwner *
00046 gcoi_create_dialog(Split* split)
00047 {
00048   DialogChooseOwner* dco;
00049   GladeXML *xml;
00050   GtkWidget *widget, *box;
00051 
00052   g_return_val_if_fail(split, NULL);
00053 
00054   dco = g_new0(DialogChooseOwner, 1);
00055   g_assert(dco);
00056   dco->book = qof_instance_get_book(QOF_INSTANCE(split));
00057   dco->split = split;
00058 
00059   /* Open the Glade file */
00060   xml = gnc_glade_xml_new("choose-owner.glade", "Choose Owner Dialog");
00061   g_assert(xml);
00062 
00063   /* Get the dialog handle */
00064   dco->dialog = glade_xml_get_widget(xml, "Choose Owner Dialog");
00065   g_assert(dco->dialog);
00066 
00067   /* Get the title widget and set the title */
00068   widget = glade_xml_get_widget(xml, "title_label");
00069   if (1 == 1) {
00070     gncOwnerInitCustomer(&(dco->owner), NULL);
00071     gtk_label_set_text(GTK_LABEL(widget),
00072                        _("This transaction needs to be assigned to a Customer."
00073                          "  Please choose the Customer below."));
00074   } else {
00075     gncOwnerInitVendor(&(dco->owner), NULL);
00076     gtk_label_set_text(GTK_LABEL(widget),
00077                        _("This transaction needs to be assigned to a Vendor."
00078                          "  Please choose the Vendor below."));
00079   }
00080 
00081   /* Get the transaction description and set it */
00082   widget = glade_xml_get_widget(xml, "desc_label");
00083   gtk_label_set_text(GTK_LABEL(widget),
00084                      xaccTransGetDescription(xaccSplitGetParent(split)));
00085 
00086   /* Get the owner label and the owner box */
00087   widget = glade_xml_get_widget(xml, "owner_label");
00088   box = glade_xml_get_widget(xml, "owner_box");
00089   dco->owner_choice = gnc_owner_select_create(widget, box, dco->book,
00090                                               &(dco->owner));
00091 
00092   gtk_widget_show_all(dco->dialog);
00093   return dco;
00094 }
00095 
00096 
00097 gboolean
00098 gnc_split_assign_owner(GtkWidget* window, Split* split)
00099 {
00100   if (1 == 0)
00101     gcoi_create_dialog(split);
00102 
00103   return FALSE;
00104 }

Generated on Thu Jul 3 05:06:29 2008 for GnuCash by  doxygen 1.5.2