GnuCash c935c2f+
Loading...
Searching...
No Matches
business-gnome-utils.c
1/*
2 * business-gnome-utils.c -- General GUI Utilities for GNC Business Objects
3 *
4 * Written By: Derek Atkins <warlord@MIT.EDU>
5 * Copyright (C) 2001,2002,2006 Derek Atkins
6 * Copyright (c) 2006 David Hampton <hampton@employees.org>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, contact:
20 *
21 * Free Software Foundation Voice: +1-617-542-5942
22 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
23 * Boston, MA 02110-1301, USA gnu@gnu.org
24 */
25
26#include <assert.h>
27#include <config.h>
28
29#include <gtk/gtk.h>
30#include <glib/gi18n.h>
31
32#include "Account.h"
33#include "gnc-ui-util.h"
34#include "qof.h"
35#include "gnc-component-manager.h"
36#include "gnc-gtk-utils.h"
37
38#include "gncCustomer.h"
39#include "gncJob.h"
40#include "gncVendor.h"
41#include "gncOwner.h"
42#include "gncInvoice.h"
43
44#include "gnc-general-search.h"
45#include "qof.h"
46#include "qofbook.h"
47#include "business-gnome-utils.h"
48#include "dialog-customer.h"
49#include "dialog-job.h"
50#include "dialog-vendor.h"
51#include "dialog-employee.h"
52#include "dialog-invoice.h"
53
54#include "guile-mappings.h"
55#include "gnc-guile-utils.h"
56#include "gnc-prefs.h"
57#include "gnc-commodity.h"
58#include "gnc-report-combo.h"
59#include "qofinstance.h"
60#include "qoflog.h"
61
62static const QofLogModule log_module = G_LOG_DOMAIN;
63
64typedef enum
65{
66 GNCSEARCH_TYPE_SELECT,
67 GNCSEARCH_TYPE_EDIT
68} GNCSearchType;
69
70enum
71{
72 COL_INV_NAME = 0,
73 COL_INV_GUID,
74 COL_INV_MISSING,
75 NUM_INV_COLS
76};
77
78#define PRINTABLE_INVOICE_GUID "5123a759ceb9483abf2182d01c140e8d"
79#define TAX_INVOICE_GUID "0769e242be474010b4acf264a5512e6e"
80#define EASY_INVOICE_GUID "67112f318bef4fc496bdc27d106bbda4"
81#define FANCY_INVOICE_GUID "3ce293441e894423a2425d7a22dd1ac6"
82
83enum
84{
85 PRINTABLE_INVOICE_PREF_NUM = 0,
86 TAX_INVOICE_PREF_NUM,
87 EASY_INVOICE_PREF_NUM,
88 FANCY_INVOICE_PREF_NUM,
89};
90
91static const char* invoice_printreport_values[] =
92{
93 /* The list below are the guids of reports that can
94 * be used to print an invoice.
95 *
96 * Important: This list matches the order of existing saved
97 * preference entries.
98 */
99 PRINTABLE_INVOICE_GUID,
100 TAX_INVOICE_GUID,
101 EASY_INVOICE_GUID,
102 FANCY_INVOICE_GUID,
103 NULL
104};
105
106#define GNC_PREFS_GROUP_INVOICE "dialogs.business.invoice"
107#define GNC_PREF_INV_PRINT_RPT "invoice-printreport"
108
109const char *
110gnc_get_builtin_default_invoice_print_report (void)
111{
112 return PRINTABLE_INVOICE_GUID;
113}
114
115const char *
116gnc_migrate_default_invoice_print_report (void)
117{
118 QofBook *book = gnc_get_current_book ();
119 int old_style_value = gnc_prefs_get_int (GNC_PREFS_GROUP_INVOICE,
120 GNC_PREF_INV_PRINT_RPT);
121
122 if (old_style_value >= TAX_INVOICE_PREF_NUM &&
123 old_style_value <= FANCY_INVOICE_PREF_NUM)
124 {
125 const gchar *ret = invoice_printreport_values[old_style_value];
127 return ret;
128 }
129 else
130 return gnc_get_builtin_default_invoice_print_report ();
131}
132
133char *
134gnc_get_default_invoice_print_report (void)
135{
136 QofBook *book = gnc_get_current_book ();
137 gchar *default_guid = qof_book_get_default_invoice_report_guid (book);
138
139 if (!default_guid)
140 return g_strdup (gnc_migrate_default_invoice_print_report ());
141
142 return default_guid;
143}
144
145GtkWidget *
146gnc_default_invoice_report_combo (const char* guid_scm_function)
147{
148 GSList *invoice_list = NULL;
149 SCM template_menu_name = scm_c_eval_string ("gnc:report-template-menu-name/report-guid");
150 SCM get_rpt_guids = scm_c_eval_string (guid_scm_function);
151 SCM reportlist;
152 SCM rpt_guids;
153
154 if (!scm_is_procedure (get_rpt_guids))
155 return NULL;
156
157 reportlist = scm_call_0 (get_rpt_guids);
158 rpt_guids = reportlist;
159
160 if (scm_is_list (rpt_guids))
161 {
162 while (!scm_is_null (rpt_guids))
163 {
164 gchar *guid_str = scm_to_utf8_string (SCM_CAR(rpt_guids));
165 gchar *name = gnc_scm_to_utf8_string (scm_call_2(template_menu_name,
166 SCM_CAR(rpt_guids), SCM_BOOL_F));
167
168 // Note: invoice_list and entries freed in report combo
169 ReportListEntry *rle = g_new0 (ReportListEntry, 1);
170
171 rle->report_guid = guid_str;
172 rle->report_name = name;
173
174 invoice_list = g_slist_append (invoice_list, rle);
175
176 rpt_guids = SCM_CDR(rpt_guids);
177 }
178 }
179 return gnc_report_combo_new (invoice_list);
180}
181
182static GtkWidget * gnc_owner_new (GtkWidget *label, GtkWidget *hbox,
183 QofBook *book, GncOwner *owner,
184 GNCSearchType type)
185{
186 GtkWidget *edit;
187 GNCSearchCB search_cb = NULL;
188 const char *type_name = NULL;
189 const char *text = NULL;
190 gboolean text_editable = FALSE;
191
192 switch (type)
193 {
194 case GNCSEARCH_TYPE_SELECT:
195 text = _("Select…");
196 text_editable = TRUE;
197 break;
198 case GNCSEARCH_TYPE_EDIT:
199 text = _("Edit…");
200 text_editable = FALSE;
201 break;
202 };
203
204 switch (owner->type)
205 {
206 case GNC_OWNER_NONE:
207 case GNC_OWNER_UNDEFINED:
208 return NULL;
209
210 case GNC_OWNER_CUSTOMER:
211 if (type == GNCSEARCH_TYPE_SELECT)
212 search_cb = gnc_customer_search_select;
213 else
214 search_cb = gnc_customer_search_edit;
215 type_name = GNC_CUSTOMER_MODULE_NAME;
216 break;
217
218 case GNC_OWNER_JOB:
219 if (type == GNCSEARCH_TYPE_SELECT)
220 search_cb = gnc_job_search_select;
221 else
222 search_cb = gnc_job_search_edit;
223 type_name = GNC_JOB_MODULE_NAME;
224 break;
225
226 case GNC_OWNER_VENDOR:
227 if (type == GNCSEARCH_TYPE_SELECT)
228 search_cb = gnc_vendor_search_select;
229 else
230 search_cb = gnc_vendor_search_edit;
231 type_name = GNC_VENDOR_MODULE_NAME;
232 break;
233
234 case GNC_OWNER_EMPLOYEE:
235 if (type == GNCSEARCH_TYPE_SELECT)
236 search_cb = gnc_employee_search_select;
237 else
238 search_cb = gnc_employee_search_edit;
239 type_name = GNC_EMPLOYEE_MODULE_NAME;
240 break;
241
242 default:
243 g_warning ("Unknown type");
244 return NULL;
245 }
246
247 edit = gnc_general_search_new (type_name, text, text_editable, search_cb, book, book);
248 if (!edit)
249 return NULL;
250
251 gnc_general_search_set_selected (GNC_GENERAL_SEARCH (edit),
252 owner->owner.undefined);
253 gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0);
254 if (label)
255 gtk_label_set_text (GTK_LABEL (label), _(qof_object_get_type_label (type_name)));
256
257 return edit;
258}
259
260GtkWidget * gnc_owner_select_create (GtkWidget *label, GtkWidget *hbox,
261 QofBook *book, GncOwner *owner)
262{
263 g_return_val_if_fail (hbox != NULL, NULL);
264 g_return_val_if_fail (book != NULL, NULL);
265 g_return_val_if_fail (owner != NULL, NULL);
266
267 return gnc_owner_new (label, hbox, book, owner, GNCSEARCH_TYPE_SELECT);
268}
269
270GtkWidget * gnc_owner_edit_create (GtkWidget *label, GtkWidget *hbox,
271 QofBook *book, GncOwner *owner)
272{
273 g_return_val_if_fail (hbox != NULL, NULL);
274 g_return_val_if_fail (book != NULL, NULL);
275 g_return_val_if_fail (owner != NULL, NULL);
276
277 return gnc_owner_new (label, hbox, book, owner, GNCSEARCH_TYPE_EDIT);
278}
279
280void gnc_owner_get_owner (GtkWidget *widget, GncOwner *owner)
281{
282 g_return_if_fail (widget != NULL);
283 g_return_if_fail (owner != NULL);
284
285 QofInstance *instance =
286 gnc_general_search_get_selected (GNC_GENERAL_SEARCH (widget));
287
288 if (!instance)
289 return;
290
291 if (owner->type == GNC_OWNER_NONE ||
292 g_strcmp0(instance->e_type, qofOwnerGetType(owner)) == 0)
293 qofOwnerSetEntity(owner, instance);
294 else
295 {
296 PWARN("Owner type mismatch: Instance %s, Owner %s",
297 instance->e_type, qofOwnerGetType(owner));
298 owner->owner.undefined = instance;
299 }
300}
301
302void gnc_owner_set_owner (GtkWidget *widget, const GncOwner *owner)
303{
304 g_return_if_fail (widget != NULL);
305 g_return_if_fail (owner != NULL);
306
307 /* We'll assume that the owner has the proper 'type' because we
308 * can't change it here. Hopefully the caller has it set properly
309 */
310
311 gnc_general_search_set_selected (GNC_GENERAL_SEARCH (widget),
312 owner->owner.undefined);
313}
314
315typedef struct _invoice_select_info
316{
317 GtkWidget *label;
318 QofBook *book;
319 GncOwner owner;
320 gboolean have_owner;
321} GncISI;
322
323static GNCSearchWindow *
324gnc_invoice_select_search_cb (GtkWindow *parent, gpointer start, gpointer isip)
325{
326 GncISI *isi = isip;
327
328 if (!isi) return NULL;
329 g_assert(isi->book);
330
331 return gnc_invoice_search (parent, start,
332 isi->have_owner ? &isi->owner : NULL,
333 isi->book);
334}
335
336static void
337gnc_invoice_select_search_set_label(GncISI* isi)
338{
339 GncOwnerType owner_type;
340 char *label;
341
342 g_assert(isi);
343 if (!isi->label) return;
344
345 owner_type = gncOwnerGetType(gncOwnerGetEndOwner(&isi->owner));
346
347 /* Translators: See comments in dialog-invoice.c:gnc_invoice_search() */
348 switch (owner_type)
349 {
350 case GNC_OWNER_VENDOR:
351 label = _("Bill");
352 break;
353 case GNC_OWNER_EMPLOYEE:
354 label = _("Voucher");
355 break;
356 default:
357 label = _("Invoice");
358 break;
359 }
360
361 gtk_label_set_text(GTK_LABEL(isi->label), label);
362}
363
364GtkWidget * gnc_invoice_select_create (GtkWidget *hbox, QofBook *book,
365 const GncOwner *owner,
366 GncInvoice *invoice,
367 GtkWidget *label)
368{
369 GtkWidget *edit;
370 GncISI *isi;
371
372 g_return_val_if_fail (hbox != NULL, NULL);
373 g_return_val_if_fail (book != NULL, NULL);
374 /* Note: it is legal to have no owner or invoice */
375
376 isi = g_new0(GncISI, 1);
377 if (!isi)
378 return NULL;
379
380 if (owner)
381 {
382 gncOwnerCopy(owner, &isi->owner);
383 isi->have_owner = TRUE;
384 }
385 else
386 {
387 gncOwnerInitCustomer(&isi->owner, NULL);
388 }
389 isi->book = book;
390 isi->label = label;
391
392 edit = gnc_general_search_new (GNC_INVOICE_MODULE_NAME, _("Select…"),
393 TRUE, gnc_invoice_select_search_cb, isi, isi->book);
394 if (!edit)
395 {
396 g_free(isi);
397 return NULL;
398 }
399
400 gnc_general_search_set_selected (GNC_GENERAL_SEARCH (edit), invoice);
401 gtk_box_pack_start (GTK_BOX (hbox), edit, FALSE, FALSE, 0);
402 g_object_set_data_full(G_OBJECT(edit), "isi-state", isi, g_free);
403
404 /* Set the label */
405 gnc_invoice_select_search_set_label(isi);
406
407 return edit;
408}
409
410GncInvoice * gnc_invoice_get_invoice (GtkWidget *widget)
411{
412 g_return_val_if_fail (widget != NULL, NULL);
413
414 return gnc_general_search_get_selected (GNC_GENERAL_SEARCH (widget));
415}
416
417void gnc_invoice_set_invoice (GtkWidget *widget, GncInvoice *invoice)
418{
419 g_return_if_fail (widget != NULL);
420 g_return_if_fail (invoice != NULL);
421
422 gnc_general_search_set_selected (GNC_GENERAL_SEARCH (widget), invoice);
423}
424
425void gnc_invoice_set_owner (GtkWidget *widget, GncOwner *owner)
426{
427 GncISI *isi;
428
429 g_return_if_fail (widget != NULL);
430 g_return_if_fail (owner != NULL);
431
432 isi = g_object_get_data(G_OBJECT(widget), "isi-state");
433 g_assert(isi);
434
435 if (isi->owner.owner.undefined == owner->owner.undefined)
436 return;
437
438 gncOwnerCopy(owner, &isi->owner);
439 isi->have_owner = TRUE;
440 gnc_general_search_set_selected(GNC_GENERAL_SEARCH(widget), NULL);
441
442 /* Reset the label */
443 gnc_invoice_select_search_set_label(isi);
444}
445
446Account *
447gnc_account_select_combo_fill (GtkWidget *combo, QofBook *book,
448 GList *acct_types, GList *acct_commodities)
449{
450 GtkListStore *store;
451 GtkTreeIter iter;
452 GList *list, *node;
453
454 g_return_val_if_fail (combo && GTK_IS_COMBO_BOX(combo), NULL);
455 g_return_val_if_fail (book, NULL);
456 g_return_val_if_fail (acct_types, NULL);
457
458 /* Figure out if anything is set in the combo */
459 char* text =
460 g_strdup (gtk_entry_get_text(GTK_ENTRY (gtk_bin_get_child(GTK_BIN (GTK_COMBO_BOX(combo))))));
461
462 g_object_set_data (G_OBJECT(combo), "book", book);
463 list = gnc_account_get_descendants (gnc_book_get_root_account (book));
464
465 /* Clear the existing list */
466 store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(combo)));
467 gtk_list_store_clear(store);
468
469 /* Add the account names to the combo box */
470 for (node = list; node; node = node->next)
471 {
472 Account *account = node->data;
473 char *name;
474
475 /* Only present accounts of the appropriate type */
476 if (g_list_index (acct_types, (gpointer)xaccAccountGetType (account))
477 == -1)
478 continue;
479
480 /* Only present accounts with the right commodity, if that's a
481 restriction */
482 if (acct_commodities)
483 {
484 if ( g_list_find_custom( acct_commodities,
485 GINT_TO_POINTER(xaccAccountGetCommodity(account)),
487 {
488 continue;
489 }
490 }
491
492 name = gnc_account_get_full_name (account);
493 gtk_list_store_append(store, &iter);
494 gtk_list_store_set (store, &iter, 0, name, -1);
495
496 /* Save the first account name in case no account name was set */
497 if (!text || g_strcmp0 (text, "") == 0)
498 {
499 g_free (text);
500 text = g_strdup (name);
501 }
502 g_free(name);
503 }
504 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
505
506 g_list_free (list);
507
508 gnc_cbwe_set_by_string(GTK_COMBO_BOX(combo), text);
509
510 g_free (text);
511 return gnc_account_select_combo_get_active (combo);
512}
513
514Account *
515gnc_account_select_combo_get_active (GtkWidget *combo)
516{
517 const gchar *text;
518 QofBook *book;
519
520 if (!combo || !GTK_IS_COMBO_BOX(combo))
521 return NULL;
522
523 book = g_object_get_data (G_OBJECT(combo), "book");
524 if (!book)
525 return NULL;
526
527 text = gtk_entry_get_text( GTK_ENTRY( gtk_bin_get_child( GTK_BIN( GTK_COMBO_BOX(combo)))));
528
529 if (!text || g_strcmp0 (text, "") == 0)
530 return NULL;
531
532 return gnc_account_lookup_by_full_name (gnc_book_get_root_account (book), text);
533}
534
535/***********************************************************************
536 * gnc_simple_combo implementation functions
537 */
538
539typedef const char * (*GenericLookup_t)(gpointer);
540typedef gboolean (*GenericEqual_t)(gpointer, gpointer);
541
542typedef struct
543{
544 gint component_id;
545 GtkComboBox *cbox;
546 QofBook *book;
547 gboolean none_ok;
548 const char * (*get_name)(gpointer);
549 GList * (*get_list)(QofBook*);
550 gboolean (*is_equal)(gpointer, gpointer);
551
553
554static void
555gnc_simple_combo_add_item (GtkListStore *liststore, const char *label, gpointer this_item)
556{
557 GtkTreeIter iter;
558
559 gtk_list_store_append (liststore, &iter);
560 gtk_list_store_set (liststore, &iter, 0, label, 1, this_item, -1);
561}
562
563static void
564gnc_simple_combo_generate_liststore (ListStoreData *lsd)
565{
566 GList *items;
567 GtkListStore *liststore;
568
569 if (!(lsd->get_list))
570 return;
571 if (!(lsd->get_name))
572 return;
573
574 /* Get the list of items */
575 items = (lsd->get_list)(lsd->book);
576
577 /* Reset the combobox' liststore */
578 liststore = GTK_LIST_STORE (gtk_combo_box_get_model (lsd->cbox));
579 gtk_list_store_clear (liststore);
580
581 if (lsd->none_ok || !items)
582 gnc_simple_combo_add_item (liststore, _("None"), NULL);
583
584 for ( ; items; items = items->next)
585 gnc_simple_combo_add_item (liststore, (lsd->get_name)(items->data), items->data);
586}
587
588static void
589gnc_simple_combo_refresh_handler (GHashTable *changes, gpointer user_data)
590{
591 ListStoreData *lsd = user_data;
592 gnc_simple_combo_generate_liststore (lsd);
593}
594
595static void
596gnc_simple_combo_destroy_cb (GtkWidget *widget, gpointer data)
597{
598 ListStoreData *lsd = data;
599
600 gnc_unregister_gui_component (lsd->component_id);
601 g_free (lsd);
602}
603
604static void
605gnc_simple_combo_make (GtkComboBox *cbox, QofBook *book,
606 gboolean none_ok, QofIdType type_name,
607 GList * (*get_list)(QofBook*),
608 GenericLookup_t get_name,
609 GenericEqual_t is_equal,
610 gpointer initial_choice)
611{
612 ListStoreData *lsd;
613
614 lsd = g_object_get_data (G_OBJECT (cbox), "liststore-data");
615
616 /* If this is the first time we've been called, then build the
617 * Option Menu Data object, register with the component manager, and
618 * watch for changed items. Then register for deletion, so we can
619 * unregister and free the data when this menu is destroyed.
620 */
621 if (!lsd)
622 {
623
624 lsd = g_new0 (ListStoreData, 1);
625 lsd->cbox = cbox;
626 lsd->book = book;
627 lsd->none_ok = none_ok;
628 lsd->get_name = get_name;
629 lsd->get_list = get_list;
630 lsd->is_equal = is_equal;
631 g_object_set_data (G_OBJECT (cbox), "liststore-data", lsd);
632
633 lsd->component_id =
634 gnc_register_gui_component ("gnc-simple-combo-refresh-hook",
635 gnc_simple_combo_refresh_handler,
636 NULL, lsd);
637
638 if (type_name)
639 gnc_gui_component_watch_entity_type (lsd->component_id,
640 type_name,
641 QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);
642
643 g_signal_connect (G_OBJECT (cbox), "destroy",
644 G_CALLBACK (gnc_simple_combo_destroy_cb), lsd);
645 }
646
647 gnc_simple_combo_generate_liststore (lsd);
648 gnc_simple_combo_set_value (cbox, initial_choice);
649}
650
651/***********************************************************
652 * Specific invocations of the gnc_simple_combo widget
653 */
654
655/* Use a list available billing terms to fill the model of
656 * the combobox passed in. If none_ok is true, then add "none" as a
657 * choice (with data set to NULL).. If initial_choice is non-NULL,
658 * then that will be the default option setting when the menu is
659 * created.
660 */
661void
662gnc_billterms_combo (GtkComboBox *cbox, QofBook *book,
663 gboolean none_ok, GncBillTerm *initial_choice)
664{
665 if (!cbox || !book) return;
666
667 gnc_simple_combo_make (cbox, book, none_ok, GNC_BILLTERM_MODULE_NAME,
668 gncBillTermGetTerms,
669 (GenericLookup_t)gncBillTermGetName,
670 (GenericEqual_t)gncBillTermIsFamily,
671 (gpointer)initial_choice);
672}
673
674void
675gnc_taxtables_combo (GtkComboBox *cbox, QofBook *book,
676 gboolean none_ok, GncTaxTable *initial_choice)
677{
678 if (!cbox || !book) return;
679
680 gnc_simple_combo_make (cbox, book, none_ok, GNC_TAXTABLE_MODULE_NAME,
681 gncTaxTableGetTables,
682 (GenericLookup_t)gncTaxTableGetName,
683 NULL,
684 (gpointer)initial_choice);
685}
686
687void
688gnc_taxincluded_combo (GtkComboBox *cbox, GncTaxIncluded initial_choice)
689{
690 GtkListStore *liststore;
691
692 if (!cbox) return;
693
694 gnc_simple_combo_make (cbox, NULL, FALSE, NULL, NULL, NULL, NULL,
695 GINT_TO_POINTER(initial_choice));
696 liststore = GTK_LIST_STORE (gtk_combo_box_get_model (cbox));
697
698 gnc_simple_combo_add_item (liststore, _("Yes"),
699 GINT_TO_POINTER (GNC_TAXINCLUDED_YES));
700 gnc_simple_combo_add_item (liststore, _("No"),
701 GINT_TO_POINTER (GNC_TAXINCLUDED_NO));
702 gnc_simple_combo_add_item (liststore, _("Use Global"),
703 GINT_TO_POINTER (GNC_TAXINCLUDED_USEGLOBAL));
704
705 gnc_simple_combo_set_value (cbox, GINT_TO_POINTER(initial_choice));
706}
707
708/* Convenience functions for the above simple combo box types. */
709
711gpointer
712gnc_simple_combo_get_value (GtkComboBox *cbox)
713{
714 GtkTreeIter iter;
715 GtkTreeModel *model;
716 gpointer retval;
717
718 if (!cbox) return NULL;
719
720 model = gtk_combo_box_get_model (cbox);
721 if (!gtk_combo_box_get_active_iter (cbox, &iter))
722 return NULL;
723 gtk_tree_model_get (model, &iter, 1, &retval, -1);
724 return retval;
725}
726
729void
730gnc_simple_combo_set_value (GtkComboBox *cbox, gpointer data)
731{
732 GtkTreeIter iter;
733 GtkTreeModel *model;
734 gboolean valid_iter;
735 ListStoreData *lsd = g_object_get_data (G_OBJECT (cbox), "liststore-data");
736
737 if (!cbox) return;
738
739 model = gtk_combo_box_get_model (cbox);
740 valid_iter = gtk_tree_model_get_iter_first (model, &iter);
741
742 while (valid_iter)
743 {
744 gpointer ptr;
745
746 gtk_tree_model_get (model, &iter, 1, &ptr, -1);
747 if (lsd && lsd->is_equal) // A specific comparator function was set
748 {
749 if ((lsd->is_equal)(ptr, data))
750 {
751 gtk_combo_box_set_active_iter (cbox, &iter);
752 return;
753 }
754 }
755 else // No specific comparator function set, use generic pointer comparison instead
756 {
757 if (ptr == data)
758 {
759 gtk_combo_box_set_active_iter (cbox, &iter);
760 return;
761 }
762 }
763 valid_iter = gtk_tree_model_iter_next (model, &iter);
764 }
765}
Account handling public routines.
Commodity handling public routines.
gtk helper routines.
Generic api to store and retrieve preferences.
utility functions for the GnuCash UI
Core Customer Interface.
Business Invoice Interface.
Job Interface.
Business Interface: Object OWNERs.
Vendor Interface.
gchar * gnc_account_get_full_name(const Account *account)
The gnc_account_get_full_name routine returns the fully qualified name of the account using the given...
Definition Account.cpp:3305
GNCAccountType xaccAccountGetType(const Account *acc)
Returns the account's account type.
Definition Account.cpp:3267
GList * gnc_account_get_descendants(const Account *account)
This routine returns a flat list of all of the accounts that are descendants of the specified account...
Definition Account.cpp:3044
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account's commodity
Definition Account.cpp:3408
gboolean gncBillTermIsFamily(const GncBillTerm *a, const GncBillTerm *b)
Check only if the bill terms are "family".
gchar * qof_book_get_default_invoice_report_guid(const QofBook *book)
Get the guid of the Invoice Report to be used as the default for printing Invoices.
Definition qofbook.cpp:1090
void qof_book_set_default_invoice_report(QofBook *book, const gchar *guid, const gchar *name)
Save the Invoice Report name / guid to be used as the default for printing Invoices.
Definition qofbook.cpp:1044
int gnc_commodity_compare_void(const void *a, const void *b)
A wrapper around gnc_commodity_compare() which offers the function declaration that is needed for g_l...
Account * gnc_account_lookup_by_full_name(const Account *any_acc, const gchar *name)
The gnc_account_lookup_full_name() subroutine works like gnc_account_lookup_by_name,...
Definition Account.cpp:3163
const gchar * QofIdType
QofIdType declaration.
Definition qofid.h:80
void gnc_cbwe_set_by_string(GtkComboBox *cbwe, const gchar *text)
Find an entry in the GtkComboBox by its text value, and set the widget to that value.
QofIdType e_type
Entity type.
Definition qofinstance.h:75
#define PWARN(format, args...)
Log a warning.
Definition qoflog.h:250
const char * qof_object_get_type_label(QofIdTypeConst type_name)
Get the printable label for a type.
QofIdTypeConst qofOwnerGetType(const GncOwner *owner)
return the type for the collection.
Definition gncOwner.c:230
const GncOwner * gncOwnerGetEndOwner(const GncOwner *owner)
Get the "parent" Owner or GncGUID thereof.
Definition gncOwner.c:572
GncOwnerType gncOwnerGetType(const GncOwner *owner)
Returns the GncOwnerType of this owner.
Definition gncOwner.c:200
void qofOwnerSetEntity(GncOwner *owner, QofInstance *ent)
set the owner from the entity.
Definition gncOwner.c:319
gint gnc_prefs_get_int(const gchar *group, const gchar *pref_name)
Get an integer value from the preferences backend.
GncTaxIncluded
How to interpret the TaxIncluded.
Definition gncTaxTable.h:86
Encapsulate all the information about a dataset.
Object instance holds common fields that most gnucash objects use.
STRUCTS.
modtime is the internal date of the last modtime See libgnucash/engine/TaxTableBillTermImmutability....
QofBook reference.
Definition qofbook-p.hpp:47