1 /********************************************************************\
2  * gnucash-item-list.h -- A scrollable list box                     *
3  *                                                                  *
4  * This program is free software; you can redistribute it and/or    *
5  * modify it under the terms of the GNU General Public License as   *
6  * published by the Free Software Foundation; either version 2 of   *
7  * the License, or (at your option) any later version.              *
8  *                                                                  *
9  * This program is distributed in the hope that it will be useful,  *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
12  * GNU General Public License for more details.                     *
13  *                                                                  *
14  * You should have received a copy of the GNU General Public License*
15  * along with this program; if not, contact:                        *
16  *                                                                  *
17  * Free Software Foundation           Voice:  +1-617-542-5942       *
18  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
19  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
20  *                                                                  *
21 \********************************************************************/
22 
23 #ifndef GNUCASH_ITEM_LIST_H
24 #define GNUCASH_ITEM_LIST_H
25 
26 #include <gtk/gtk.h>
27 
28 /** @ingroup Register
29  * @addtogroup Gnome
30  * @{
31  */
32 /** @file gnucash-item-list.h
33  * @brief Public Declarations for GncItemList class
34  */
35 #define GNC_TYPE_ITEM_LIST     (gnc_item_list_get_type ())
36 #define GNC_ITEM_LIST(o)       (G_TYPE_CHECK_INSTANCE_CAST((o), GNC_TYPE_ITEM_LIST, GncItemList))
37 #define GNC_ITEM_LIST_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GNC_TYPE_ITEM_LIST, GncItemListClass))
38 #define IS_GNC_ITEM_LIST(o)    (G_TYPE_CHECK_INSTANCE_TYPE((o), GNC_TYPE_ITEM_LIST))
39 
40 typedef struct
41 {
42     GtkEventBox ebox;
43 
44     GtkTreeView *tree_view;
45     GtkScrolledWindow* scrollwin;
46     GtkListStore *list_store; /* Contains the list items */
47     GtkListStore *temp_store; /* Temporary store for typeahead select */
48     GtkCellRenderer *renderer;
49     gint cell_height;
50 } GncItemList;
51 
52 typedef struct
53 {
54     GtkEventBoxClass parent_class;
55 
56     void (*select_item) (GncItemList *item_list,
57                          char        *item_string);
58 
59     void (*change_item) (GncItemList *item_list,
60                          char        *item_string);
61 
62     void (*activate_item) (GncItemList *item_list,
63                            char        *item_string);
64 
65 } GncItemListClass;
66 
67 
68 GType gnc_item_list_get_type (void);
69 
70 GtkWidget *gnc_item_list_new (GtkListStore *shared_store);
71 
72 gint gnc_item_list_num_entries (GncItemList *item_list);
73 
74 gint gnc_item_list_get_cell_height (GncItemList *item_list);
75 
76 void gnc_item_list_clear (GncItemList *item_list);
77 
78 void gnc_item_list_append (GncItemList *item_list, const char *string);
79 
80 void gnc_item_list_set_sort_enabled(GncItemList *item_list, gboolean enabled);
81 
82 gboolean gnc_item_in_list (GncItemList *item_list, const char *string);
83 
84 void gnc_item_list_select (GncItemList *item_list, const char *string);
85 
86 void gnc_item_list_show_selected (GncItemList *item_list);
87 
88 /** Retrieve the selected string from the item_list's active GtkListStore.
89  *
90  * @param item_list the GncItemList
91  * @return the string value. It must be freed with g_free().
92  */
93 char* gnc_item_list_get_selection (GncItemList *item_list);
94 
95 int gnc_item_list_autosize (GncItemList *item_list);
96 
97 void gnc_item_list_set_temp_store (GncItemList *item_list, GtkListStore *store);
98 
99 gboolean gnc_item_list_using_temp (GncItemList *item_list);
100 
101 /** @} */
102 #endif /* GNUCASH_ITEM_LIST_H */
103